Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/Classes/MyComboBoxCell.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 146 - (show annotations) (download)
Sun Dec 17 04:05:28 2017 UTC (6 years, 5 months ago) by toshinagata1964
File size: 2378 byte(s)
Xcode project is updated so that ppc/i386 universal binary can be built (as before)
1 //
2 // MyComboBoxCell.m
3 // Alchemusica
4 //
5 // Created by Toshi Nagata on 06/05/08.
6 // Copyright 2006-2011 Toshi Nagata. All rights reserved.
7 /*
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation version 2 of the License.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 */
18
19 #import "MyComboBoxCell.h"
20 #import "MyPopUpButton.h"
21
22 @implementation MyComboBoxCell
23
24 #if MAC_OS_X_VERSION_MIN_REQUIRED == MAC_OS_X_VERSION_10_3
25 - (void)setControlView: (NSView *)view
26 {
27 _controlView = view;
28 }
29 #endif
30
31 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
32 {
33 NSRect theRect, r;
34 NSPoint center;
35 NSString *theString;
36 float fraction;
37 lastDrawnRect = cellFrame;
38 theRect = cellFrame;
39 center.x = theRect.origin.x + theRect.size.width / 2;
40 center.y = theRect.origin.y + theRect.size.height / 2;
41 if ([self isEnabled])
42 fraction = 1.0f;
43 else fraction = 0.5f;
44 switch ([self type]) {
45 case NSTextCellType:
46 theString = [self stringValue];
47 if (theString != nil) {
48 NSMutableParagraphStyle *par = [[[NSMutableParagraphStyle alloc] init] autorelease];
49 NSFont *font = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]];
50 float lineHeight = [font ascender] - [font descender];
51 NSRect rect = NSMakeRect(theRect.origin.x, theRect.origin.y + (theRect.size.height - lineHeight - 2), theRect.size.width, lineHeight + 2);
52 [par setAlignment: NSCenterTextAlignment];
53 [theString drawInRect: rect withAttributes:
54 [NSDictionary dictionaryWithObjectsAndKeys:
55 font,
56 NSFontAttributeName,
57 par,
58 NSParagraphStyleAttributeName, nil]];
59 }
60 break;
61 default:
62 break;
63 }
64 // theRect = NSMakeRect(theRect.origin.x + theRect.size.width - 7, theRect.origin.y + theRect.size.height - 7, 5, 5);
65 r.origin.x = theRect.origin.x + theRect.size.width - 7;
66 r.origin.y = theRect.origin.y + theRect.size.height - 7;
67 r.size.width = 5;
68 r.size.height = 5;
69 [[MyPopUpButton triangleImage] drawInRect:r fromRect:NSZeroRect operation:NSCompositeSourceAtop fraction:fraction respectFlipped:YES hints:nil];
70 }
71
72 @end

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