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

主站蜘蛛池模板: 国产精品久久亚洲 | 337p日本欧洲亚洲大胆精蜜臀 | 免费在线观看黄网站 | 激情久久网 | 久久久久久久久久久久一区二区 | 欧美成人第一页 | 亚洲美女av网站 | 国产成人一区二区 | av黄色片 | 欧美黄色一区 | 精品毛片| 九九热在线精品视频 | 91免费视频观看 | 干出白浆视频 | 日本在线中文 | 亚洲精品久久久9婷婷中文字幕 | 日本淫视频 | 欧美一级艳情片免费观看 | 雨宫琴音一区二区在线 | 麻豆av片 | 天天操操| 欧美精品一区三区 | 一级毛片色一级 | 日韩欧美视频 | 色又黄又爽网站www久久 | 色婷婷一区二区三区四区 | 一区二区三区成人 | 成人免费观看视频 | 一区二区免费在线观看 | 久久黄视频 | 日日骚网 | 岛国午夜 | 99精品视频在线 | 成人黄色三级毛片 | 第一福利社区1024 | 日韩国产高清在线观看 | 777zyz色资源站在线观看 | 91精品国产日韩91久久久久久 | 国产精品毛片一区二区在线看 | 91精品国产一区二区三区 | 射久久|