mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-26 21:47:04 +00:00
If a segmented control was initialised with a zero width and then expanded with setSegmentCount, it would not allocate space for any needed dividers. The more tabs were added the more the segmented control would be undersized. The fix is to automatically adjust the width when dividers are added or removed.
53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
/*
|
|
* AppController.j
|
|
* CPTabView2
|
|
*
|
|
* Created by You on August 27, 2010.
|
|
* Copyright 2010, Your Company All rights reserved.
|
|
*/
|
|
|
|
@import <Foundation/CPObject.j>
|
|
@import <AppKit/CPTabView.j>
|
|
|
|
|
|
@implementation AppController : CPObject
|
|
|
|
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
|
{
|
|
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
|
|
contentView = [theWindow contentView];
|
|
|
|
var tabView = [[CPTabView alloc] initWithFrame:CGRectMake(50,50,400,400)];
|
|
[tabView setTabViewType:CPNoTabsBezelBorder];
|
|
[tabView setTabViewType:CPTopTabsBezelBorder];
|
|
|
|
var tabs = [
|
|
"First Tab", "a label",
|
|
"Second Tab", "another label",
|
|
"Third Tab", "a third label",
|
|
"Fourth Tab", "label 4",
|
|
/*"5th Tab", "label 5",
|
|
"6th Tab", "label 6",
|
|
"7th Tab", "label 7",*/
|
|
];
|
|
|
|
for (var i = 0; i < tabs.length; i += 2)
|
|
{
|
|
var view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
|
|
[view addSubview:[CPTextField labelWithTitle:tabs[i + 1]]];
|
|
|
|
var item = [[CPTabViewItem alloc] initWithIdentifier:tabs[i]];
|
|
[item setView:view];
|
|
[item setLabel:tabs[i]];
|
|
[tabView addTabViewItem:item];
|
|
}
|
|
|
|
[contentView addSubview:tabView];
|
|
|
|
[tabView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
|
|
[theWindow orderFront:self];
|
|
}
|
|
|
|
@end
|