久久福利_99r_国产日韩在线视频_直接看av的网站_中文欧美日韩_久久一

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

MAC OS X Cocoa NSToolbar 的使用

瀏覽:111日期: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]; } //返回程序加載后的默認(rèn)的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

標(biāo)簽: Mac OS系統(tǒng)
主站蜘蛛池模板: 求av网址| 久久三区 | 日本中文在线 | 欧美成人精品一区二区 | 日韩视频欧美视频 | 91亚洲国产亚洲国产 | 久久久久国产一区二区三区 | 日韩欧美一区二区三区视频 | 美日韩免费视频 | 国产精品99久久免费观看 | 亚洲精品二区 | 国产精品影院在线观看 | 五月天婷婷精品 | 性欧美大战久久久久久久免费观看 | 久久99精品国产91久久来源 | 欧美久草 | 国产一区二区日韩 | 一本大道久久a久久精二百 国产精品片aa在线观看 | 一区电影 | av免费观看网站 | 亚洲国产成人在线 | www.久久.com| 人人种亚洲 | 国产精品视频一区二区三区, | 天天做天天看 | 国产香蕉视频在线播放 | 国产一区在线免费 | 亚洲欧美综合乱码精品成人网 | 国产精品久久久久久久娇妻 | 日韩国产在线 | 日本成人黄色网址 | 天堂av一区 | 欧美日韩专区 | 开操网| 久热精品视频在线播放 | 国产一区二区免费 | 国产精品成av人在线视午夜片 | 免费亚洲婷婷 | 中文字幕在线观看精品视频 | 中文字幕亚洲字幕一区二区 | 日韩视频在线一区 |