Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfManager/XspfMTableView.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 584 - (hide annotations) (download)
Wed Nov 23 02:44:14 2011 UTC (12 years, 4 months ago) by masakih
File size: 6633 byte(s)
[Fix] アナライザを黙らせた。
1 masaki 70 //
2     // XspfMTableView.m
3     // XspfManager
4     //
5     // Created by Hori,Masaki on 09/11/15.
6     //
7    
8 masakih 350 /*
9 masakih 365 This source code is release under the New BSD License.
10 masakih 350 Copyright (c) 2009-2010, masakih
11     All rights reserved.
12    
13 masakih 365 ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満たす場合に
14     限り、再頒布および使用が許可されます。
15    
16     1, ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責条項を含
17     めること。
18     2, バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の著作権表
19     示、本条件一覧、および下記免責条項を含めること。
20     3, 書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売促進に、
21     コントリビューターの名前を使用してはならない。
22     本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供されており、
23     明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適合性に関する暗黙の保証
24     も含め、またそれに限定されない、いかなる保証もありません。著作権者もコントリビューター
25     も、事由のいかんを問わず、 損害発生の原因いかんを問わず、かつ責任の根拠が契約であるか
26     厳格責任であるか(過失その他の)不法行為であるかを問わず、仮にそのような損害が発生する
27     可能性を知らされていたとしても、本ソフトウェアの使用によって発生した(代替品または代用
28     サービスの調達、使用の喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定
29     されない)直接損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害につい
30     て、一切責任を負わないものとします。
31 masakih 350 -------------------------------------------------------------------
32     Copyright (c) 2009-2010, masakih
33     All rights reserved.
34    
35 masakih 365 Redistribution and use in source and binary forms, with or without
36     modification, are permitted provided that the following conditions
37     are met:
38 masakih 350
39 masakih 365 1, Redistributions of source code must retain the above copyright
40     notice, this list of conditions and the following disclaimer.
41     2, Redistributions in binary form must reproduce the above copyright
42     notice, this list of conditions and the following disclaimer in
43     the documentation and/or other materials provided with the
44     distribution.
45     3, The names of its contributors may be used to endorse or promote
46     products derived from this software without specific prior
47     written permission.
48     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
51     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
52     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
53     INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
54     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
56     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
58     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59     POSSIBILITY OF SUCH DAMAGE.
60 masakih 350 */
61    
62 masaki 70 #import "XspfMTableView.h"
63    
64 masakih 584 @interface XspfMTableView (XspfMMenueSUpport) <NSMenuDelegate>
65     @end
66 masaki 70
67 masaki 211 @interface XspfMTableView (XspfM_CocoaPravateMethodHack)
68     - (NSColor *)_highlightColorForCell:(NSCell *)cell;
69     @end
70    
71    
72 masaki 70 @implementation XspfMTableView
73 masaki 211
74     +(void)initialize
75     {
76     static BOOL isFirst = YES;
77     if(isFirst) {
78     isFirst = NO;
79    
80     if(![self instancesRespondToSelector:@selector(_highlightColorForCell:)]) {
81     HMLog(HMLogLevelError, @"this version of Mac OS X not supported!");
82     exit(-3);
83     }
84     }
85     }
86    
87 masaki 218 - (void)setup
88     {
89     contextMenuRow = -1;
90     }
91     - (id)initWithFrame:(NSRect)frame
92     {
93     self = [super initWithFrame:frame];
94     if(self) {
95     [self setup];
96     }
97     return self;
98     }
99     - (id)initWithCoder:(id)decoder
100     {
101     self = [super initWithCoder:decoder];
102     if(self) {
103     [self setup];
104     }
105     return self;
106     }
107    
108 masaki 211 #pragma mark#### NSMenu Delegate ####
109     - (void)menuDidClose:(NSMenu *)menu
110     {
111     HMLog(HMLogLevelDebug, @"Enter %@", NSStringFromSelector(_cmd));
112 masaki 218 NSRect rowRect = [self rectOfRow:contextMenuRow];
113 masaki 211 [self setNeedsDisplayInRect:rowRect];
114 masaki 218 [menu setDelegate:nil];
115    
116     contextMenuRow = -1;
117 masaki 211 }
118 masaki 218 - (void)drawRect:(NSRect)rect
119     {
120     [super drawRect:rect];
121    
122     if(contextMenuRow == -1) return;
123    
124     NSRect rowRect = [self rectOfRow:contextMenuRow];
125     [[self _highlightColorForCell:[self preparedCellAtColumn:0 row:contextMenuRow]] set];
126     NSFrameRectWithWidth(rowRect, 2);
127     }
128    
129 masaki 211 - (NSMenu *)menuForEvent:(NSEvent *)event
130     {
131     if([[self dataSource] respondsToSelector:@selector(tableView:menuForEvent:)]) {
132     NSMenu *menu = [[self dataSource] tableView:self menuForEvent:event];
133     if(menu) {
134     // draw select frame rectangle.
135     NSPoint mouse = [self convertPoint:[event locationInWindow] fromView:nil];
136 masaki 218 contextMenuRow = [self rowAtPoint:mouse];
137     NSRect rowRect= [self rectOfRow:contextMenuRow];
138     [self setNeedsDisplayInRect:rowRect];
139     [self displayIfNeeded];
140 masaki 211
141     if([menu delegate]) {
142     HMLog(HMLogLevelAlert, @"-[%@ %@] method overwrite returned NSMenu's delegate.",
143     NSStringFromClass([self class]), NSStringFromSelector(_cmd));
144 masaki 218 HMLog(HMLogLevelAlert, @"Delegate is %@(%p)", NSStringFromClass([[menu delegate] class]), [menu delegate]);
145 masaki 211 }
146     [menu setDelegate:self];
147    
148     return menu;
149     }
150     }
151    
152     return nil;
153     }
154    
155 masaki 70 - (void)keyDown:(NSEvent *)theEvent
156     {
157     if([theEvent isARepeat]) return [super keyDown:theEvent];
158    
159 masakih 567 NSString *charactor = [theEvent charactersIgnoringModifiers];
160     if([charactor length] == 0) return [super keyDown:theEvent];
161 masaki 70
162 masakih 505 BOOL interrapted = NO;
163 masakih 567 unichar uc = [charactor characterAtIndex:0];
164     switch(uc) {
165     case NSEnterCharacter:
166     case NSNewlineCharacter:
167     case NSFormFeedCharacter:
168     case NSCarriageReturnCharacter:
169 masaki 73 if([self doubleAction]) {
170     [self sendAction:[self doubleAction] to:[self target]];
171 masakih 505 interrapted = YES;
172 masaki 70 }
173     break;
174 masakih 567 case ' ':
175 masaki 297 [NSApp sendAction:@selector(togglePreviewPanel:) to:nil from:nil];
176 masakih 505 interrapted = YES;
177 masaki 297 break;
178 masakih 567 case NSDeleteCharacter:
179 masakih 505 [self doCommandBySelector:@selector(delete:)];
180     interrapted = YES;
181     break;
182 masaki 70 }
183 masakih 567
184 masakih 505 if(interrapted) return;
185 masaki 70
186     [super keyDown:theEvent];
187     }
188     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26