av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

MAC OS X Cocoa NSToolbar 的使用

瀏覽:122日期:2024-07-23 13:36:36

//向NSToolbar控件添加自定義的NSToolbarItem項 - (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifIEr: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted { // Required delegate method Given an item identifier, self method returns an item // The toolbar will use self method to obtain toolbar items that can be displayed in the customization sheet, or in the toolbar itself NSToolbarItem *toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];

if ([itemIdent isEqual: SquareDotViewItemIdentifier]) { SquareDotView *dv = [[SquareDotView alloc] initWithFrame: NSMakeRect(0,0,100,32)];

[toolbarItem setView: dv];

// set a reasonable minimum size [toolbarItem setMinSize: NSMakeSize(100,32)]; // set a maximum size that allows us to stretch. [toolbarItem setMaxSize: NSMakeSize(300,32)];

[toolbarItem setLabel: @'Dot View']; [toolbarItem setPaletteLabel: @'A Dot View']; [toolbarItem setToolTip: @'This is a dot view']; } ..... } //返回單擊后能被選中且為高亮顯示的NSToolbarItem的集合。 - (NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar {// return an array of all the items that can be highlight display after selected return [NSArray arrayWithObjects: NSColorToolbarItemIdentifier, NSFontToolbarItemIdentifier,nil]; } //返回程序加載后的默認的NSToolbarItem的集合。 - (NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar { // return an array of the items found in the default toolbar return [NSArray arrayWithObjects: NSToolbarSeparatorItemIdentifier, NSFontToolbarItemIdentifier, NSToolbarCustomizeToolbarItemIdentifier, nil]; } //以下是作為NSToolbarItem出現(xiàn)的自定義類 The 'SquareDotView' class:

@interface SquareDotView : NSView { @private float sdSide; NSPoint sdLocation; } @end

@implementation SquareDotView

#define START_SIDE 10 #define START_LOCATION NSMakePoint(10,10)

- (id)initWithFrame:(NSRect)frame { self = [super initWithFrame:frame]; if (self) { sdSide = START_SIDE; sdLocation = START_LOCATION; } return self; }

- (void)mouseDown:(NSEvent *)theEvent { sdLocation = [self convertPoint: [theEvent locationInWindow] fromView: nil]; [self setNeedsDisplay: YES]; }

- (void)drawRect:(NSRect)rect { [[NSColor redColor] set]; [[NSBezierPath bezierPathWithRect: NSMakeRect(sdLocation.x, sdLocation.y, sdSide, sdSide)] fill];

[[NSColor blackColor] set]; [[NSBezierPath bezierPathWithRect: [self bounds]] stroke]; }

- (id)initWithCoder:(NSCoder *)coder { self = [super initWithCoder: coder]; if (self) { [coder decodeValuesOfObjCTypes: 'fff', &sdSide, &sdLocation.x, &sdLocation.y]; } return self; }

- (void)encodeWithCoder:(NSCoder *)coder { [super encodeWithCoder: coder]; if (self) { [coder encodeValuesOfObjCTypes: 'fff', &sdSide, &sdLocation.x, &sdLocation.y]; } }

@end

主站蜘蛛池模板: 亚洲一区二区三区在线视频 | 日操夜操| 国产精品久久久久久亚洲调教 | 欧美性video 精品亚洲一区二区 | 伊人艹| 浮生影院免费观看中文版 | 欧美日本一区二区 | 521av网站 | 久久一二| 亚洲一区二区三区在线 | 欧美中文字幕一区二区三区亚洲 | 91直接看| 日韩国产高清在线观看 | 久久亚洲欧美日韩精品专区 | 九九热国产视频 | 中文字幕精品一区二区三区精品 | 91色在线 | 欧美激情在线精品一区二区三区 | www四虎影视 | 久久高清免费视频 | 人干人人 | 中文字幕一区在线 | 久久不卡日韩美女 | 国产性色视频 | 黄色欧美在线 | 这里有精品 | 日韩无 | 国产伦精品一区二区三区照片91 | 高清av电影 | 久草中文在线 | 91免费电影 | 人人射人人草 | 91精品国产91久久久久久吃药 | 精品欧美一区二区在线观看欧美熟 | 国产激情在线播放 | 九色在线| 碰碰视频 | 亚洲午夜精品视频 | 成人午夜精品 | 亚洲码欧美码一区二区三区 | 亚洲一区二区网站 |