mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-26 04:10:42 +00:00
571 lines
21 KiB
Plaintext
571 lines
21 KiB
Plaintext
/*
|
|
* AppController.j
|
|
* KitchenSink in Code
|
|
*
|
|
* Created by Daniel Böhringer 2026.
|
|
* Modified for TabView, SplitView, Control Sizes support & Grouped Boxes.
|
|
*/
|
|
|
|
@import <Foundation/Foundation.j>
|
|
@import <AppKit/AppKit.j>
|
|
|
|
// --------------------------------------------------------------------------------
|
|
// KitchenSinkWindowController
|
|
// Manages a single window instance with Tabs: Controls, Table/Text Split, & Sizes
|
|
// --------------------------------------------------------------------------------
|
|
|
|
@implementation KitchenSinkWindowController : CPWindowController
|
|
{
|
|
BOOL _isHUD;
|
|
BOOL _areControlsEnabled;
|
|
CPArrayController _arrayController;
|
|
}
|
|
|
|
- (id)initWithContentRect:(CGRect)aRect isHUD:(BOOL)isHUD enabled:(BOOL)isEnabled
|
|
{
|
|
var styleMask = CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask;
|
|
|
|
if (isHUD)
|
|
styleMask |= CPHUDBackgroundWindowMask;
|
|
|
|
var theWindow = [[CPWindow alloc] initWithContentRect:aRect styleMask:styleMask];
|
|
|
|
self = [super initWithWindow:theWindow];
|
|
|
|
if (self)
|
|
{
|
|
_isHUD = isHUD;
|
|
_areControlsEnabled = isEnabled;
|
|
|
|
var title = (isHUD ? @"HUD Theme" : @"Aristo3 Theme") + (isEnabled ? @" (Enabled)" : @" (Disabled)");
|
|
[theWindow setTitle:title];
|
|
|
|
var toolbar = [[CPToolbar alloc] initWithIdentifier:@"KitchenSinkToolbar" + (isHUD ? @"HUD" : @"Aqua")];
|
|
[toolbar setDelegate:self];
|
|
[toolbar setVisible:YES];
|
|
[theWindow setToolbar:toolbar];
|
|
|
|
_arrayController = [[CPArrayController alloc] init];
|
|
|
|
var contentData = [
|
|
[CPDictionary dictionaryWithObjectsAndKeys:@"Cat", @"animal", 4, @"legs"],
|
|
[CPDictionary dictionaryWithObjectsAndKeys:@"Duck", @"animal", 2, @"legs"],
|
|
[CPDictionary dictionaryWithObjectsAndKeys:@"Centipede", @"animal", 100, @"legs"],
|
|
[CPDictionary dictionaryWithObjectsAndKeys:@"Spider", @"animal", 8, @"legs"],
|
|
[CPDictionary dictionaryWithObjectsAndKeys:@"Snake", @"animal", 0, @"legs"]
|
|
];
|
|
|
|
[_arrayController setContent:contentData];
|
|
[_arrayController setEditable:YES];
|
|
|
|
[self _buildInterface];
|
|
|
|
if (!isEnabled)
|
|
[self _disableControlsInView:[theWindow contentView]];
|
|
}
|
|
|
|
return self;
|
|
}
|
|
|
|
- (void)_buildInterface
|
|
{
|
|
var window = [self window],
|
|
contentView = [window contentView],
|
|
bounds = [contentView bounds];
|
|
|
|
var tabView = [[CPTabView alloc] initWithFrame:bounds];
|
|
[tabView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
|
|
// --- TAB 1: Controls (Grouped in Boxes) ---
|
|
var item1 = [[CPTabViewItem alloc] initWithIdentifier:@"Controls"];
|
|
[item1 setLabel:@"Controls"];
|
|
|
|
var controlsView = [[CPView alloc] initWithFrame:[tabView bounds]];
|
|
[self _buildControlsTab:controlsView];
|
|
[item1 setView:controlsView];
|
|
[tabView addTabViewItem:item1];
|
|
|
|
// --- TAB 2: Table & Text Split ---
|
|
var item2 = [[CPTabViewItem alloc] initWithIdentifier:@"Table"];
|
|
[item2 setLabel:@"Data Split"];
|
|
|
|
var tableViewWrapper = [[CPView alloc] initWithFrame:[tabView bounds]];
|
|
[self _buildTableTab:tableViewWrapper];
|
|
[item2 setView:tableViewWrapper];
|
|
[tabView addTabViewItem:item2];
|
|
|
|
// --- TAB 3: Control Sizes ---
|
|
var item3 = [[CPTabViewItem alloc] initWithIdentifier:@"Sizes"];
|
|
[item3 setLabel:@"Sizes"];
|
|
|
|
var sizesView = [[CPView alloc] initWithFrame:[tabView bounds]];
|
|
[self _buildSizesTab:sizesView];
|
|
[item3 setView:sizesView];
|
|
[tabView addTabViewItem:item3];
|
|
|
|
[contentView addSubview:tabView];
|
|
}
|
|
|
|
- (void)_buildControlsTab:(CPView)containerView
|
|
{
|
|
// Layout Constants
|
|
var boxMargin = 15.0,
|
|
boxWidth = 190.0,
|
|
boxHeight = 420.0,
|
|
|
|
innerX = 15.0, // X-offset inside the box
|
|
startY = 10.0, // Y-offset inside the box
|
|
gapY = 35.0,
|
|
controlWidth = 150.0;
|
|
|
|
// ------------------------------------------------------
|
|
// LEFT BOX: Standard Controls
|
|
// ------------------------------------------------------
|
|
var leftBox = [[CPBox alloc] initWithFrame:CGRectMake(boxMargin, 15.0, boxWidth, boxHeight)];
|
|
[leftBox setTitle:@"Standard Controls"];
|
|
[leftBox setAutoresizingMask:CPViewMaxXMargin | CPViewHeightSizable];
|
|
[containerView addSubview:leftBox];
|
|
|
|
// Note: We add subviews to [leftBox contentView]
|
|
var leftContent = [leftBox contentView];
|
|
|
|
var pushButton = [[CPButton alloc] initWithFrame:CGRectMake(innerX, startY, controlWidth, 24)];
|
|
[pushButton setTitle:@"Push Button"];
|
|
[leftContent addSubview:pushButton];
|
|
|
|
var gradientButton = [[CPButton alloc] initWithFrame:CGRectMake(innerX, startY + gapY, controlWidth, 24)];
|
|
[gradientButton setTitle:@"Gradient Button"];
|
|
[leftContent addSubview:gradientButton];
|
|
|
|
var roundRectButton = [[CPButton alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 2), controlWidth, 24)];
|
|
[roundRectButton setTitle:@"Round Rect Button"];
|
|
[roundRectButton setBezelStyle:CPRoundedBezelStyle];
|
|
[leftContent addSubview:roundRectButton];
|
|
|
|
var placeholderField = [[CPTextField alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 3), controlWidth, 24)];
|
|
[placeholderField setEditable:YES];
|
|
[placeholderField setBezeled:YES];
|
|
[placeholderField setPlaceholderString:@"Placeholder"];
|
|
[leftContent addSubview:placeholderField];
|
|
|
|
var textField = [[CPTextField alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 4), controlWidth, 25)];
|
|
[textField setEditable:YES];
|
|
[textField setBezeled:YES];
|
|
[textField setStringValue:@"Text Field"];
|
|
[leftContent addSubview:textField];
|
|
|
|
var searchField = [[CPSearchField alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 5), controlWidth, 25)];
|
|
[searchField setPlaceholderString:@"Search..."];
|
|
[leftContent addSubview:searchField];
|
|
|
|
var tokenField = [[CPTokenField alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 6), controlWidth, 25)];
|
|
[tokenField setObjectValue:["Token", "Field"]];
|
|
[leftContent addSubview:tokenField];
|
|
|
|
var comboBox = [[CPComboBox alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 7), controlWidth, 25)];
|
|
[comboBox setPlaceholderString:@"Combo Box"];
|
|
[comboBox addItemsWithObjectValues:["Alpha", "Beta", "Gamma"]];
|
|
[leftContent addSubview:comboBox];
|
|
|
|
var bottomSlider = [[CPSlider alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 8.5), controlWidth, 25)];
|
|
[leftContent addSubview:bottomSlider];
|
|
|
|
|
|
// ------------------------------------------------------
|
|
// RIGHT BOX: Advanced Controls
|
|
// ------------------------------------------------------
|
|
// Calculate X position for the second box
|
|
var rightBoxX = boxMargin + boxWidth + 15.0;
|
|
var rightBoxWidth = 205.0; // Slightly wider for DatePicker/Steppers
|
|
|
|
var rightBox = [[CPBox alloc] initWithFrame:CGRectMake(rightBoxX, 15.0, rightBoxWidth, boxHeight)];
|
|
[rightBox setTitle:@"Advanced Controls"];
|
|
[rightBox setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
[containerView addSubview:rightBox];
|
|
|
|
var rightContent = [rightBox contentView];
|
|
|
|
var datePicker = [[CPDatePicker alloc] initWithFrame:CGRectMake(innerX, startY, 175, 28)];
|
|
[datePicker setDatePickerStyle:CPTextFieldAndStepperDatePickerStyle];
|
|
[datePicker setDateValue:[CPDate date]];
|
|
[rightContent addSubview:datePicker];
|
|
|
|
var cbY = startY + gapY;
|
|
var cbOn = [CPCheckBox checkBoxWithTitle:@"On"];
|
|
[cbOn setFrameOrigin:CGPointMake(innerX, cbY)];
|
|
[cbOn setState:CPOnState];
|
|
[rightContent addSubview:cbOn];
|
|
|
|
var cbOff = [CPCheckBox checkBoxWithTitle:@"Off"];
|
|
[cbOff setFrameOrigin:CGPointMake(innerX + 50, cbY)];
|
|
[cbOff setState:CPOffState];
|
|
[rightContent addSubview:cbOff];
|
|
|
|
var cbBoth = [CPCheckBox checkBoxWithTitle:@"Mixed"];
|
|
[cbBoth setFrameOrigin:CGPointMake(innerX + 100, cbY)];
|
|
[cbBoth setState:CPMixedState];
|
|
[rightContent addSubview:cbBoth];
|
|
|
|
var popUp = [[CPPopUpButton alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 2), 150, 24) pullsDown:NO];
|
|
[popUp addItemWithTitle:@"Item 1"];
|
|
[popUp addItemWithTitle:@"Item 2"];
|
|
[rightContent addSubview:popUp];
|
|
|
|
// Stepper & Progress Bar
|
|
var swapY = startY + (gapY * 3);
|
|
var stepper = [[CPStepper alloc] initWithFrame:CGRectMake(innerX, swapY + 3, 19, 27)];
|
|
[stepper setValueWraps:NO];
|
|
[stepper setAutorepeat:YES];
|
|
[stepper setMinValue:0];
|
|
[stepper setMaxValue:100];
|
|
[stepper setDoubleValue:33];
|
|
[rightContent addSubview:stepper];
|
|
|
|
var detProgress = [[CPProgressIndicator alloc] initWithFrame:CGRectMake(innerX + 25, swapY + 5.5, 125, 16)];
|
|
[detProgress setStyle:CPProgressIndicatorBarStyle];
|
|
[detProgress setIndeterminate:NO];
|
|
[detProgress setMinValue:0];
|
|
[detProgress setMaxValue:100];
|
|
[detProgress bind:CPValueBinding toObject:stepper withKeyPath:@"doubleValue" options:nil];
|
|
[rightContent addSubview:detProgress];
|
|
|
|
var radioY = startY + (gapY * 4);
|
|
var radio1 = [CPRadio radioWithTitle:@"Radio A"];
|
|
[radio1 setFrameOrigin:CGPointMake(innerX, radioY)];
|
|
[radio1 setState:CPOnState];
|
|
[rightContent addSubview:radio1];
|
|
|
|
var radio2 = [CPRadio radioWithTitle:@"Radio B"];
|
|
[radio2 setFrameOrigin:CGPointMake(innerX, radioY + 22)];
|
|
[rightContent addSubview:radio2];
|
|
[radio1 setTarget:self]; [radio1 setAction:@selector(dummyAction:)];
|
|
[radio2 setTarget:self]; [radio2 setAction:@selector(dummyAction:)];
|
|
|
|
// Level Indicator
|
|
var levelY = startY + (gapY * 5.5);
|
|
var levelInd = [[CPLevelIndicator alloc] initWithFrame:CGRectMake(innerX, levelY, 130, 18)];
|
|
[levelInd setMaxValue:5];
|
|
[levelInd setDoubleValue:3];
|
|
[levelInd setLevelIndicatorStyle:CPDiscreteCapacityLevelIndicatorStyle];
|
|
[rightContent addSubview:levelInd];
|
|
|
|
var levelStepper = [[CPStepper alloc] initWithFrame:CGRectMake(innerX + 135, levelY - 2, 19, 24)];
|
|
[levelStepper setMinValue:0];
|
|
[levelStepper setMaxValue:5];
|
|
[levelStepper setDoubleValue:3];
|
|
[levelStepper setValueWraps:NO];
|
|
[rightContent addSubview:levelStepper];
|
|
|
|
[levelInd bind:CPValueBinding toObject:levelStepper withKeyPath:@"doubleValue" options:nil];
|
|
|
|
var tickSlider = [[CPSlider alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 6.5), 110, 24)];
|
|
[rightContent addSubview:tickSlider];
|
|
|
|
var vSlider = [[CPSlider alloc] initWithFrame:CGRectMake(innerX + 130, startY + (gapY * 6.5), 24, 70)];
|
|
[rightContent addSubview:vSlider];
|
|
|
|
var knob = [[CPSlider alloc] initWithFrame:CGRectMake(innerX, startY + (gapY * 7.5), 32, 32)];
|
|
[knob setSliderType:CPCircularSlider];
|
|
[rightContent addSubview:knob];
|
|
|
|
var progressBar = [[CPProgressIndicator alloc] initWithFrame:CGRectMake(innerX + 40, startY + (gapY * 7.5) + 8, 80, 16)];
|
|
[progressBar setStyle:CPProgressIndicatorBarStyle];
|
|
[progressBar setIndeterminate:YES];
|
|
[progressBar startAnimation:self];
|
|
[rightContent addSubview:progressBar];
|
|
}
|
|
|
|
- (void)_buildTableTab:(CPView)containerView
|
|
{
|
|
var bounds = [containerView bounds];
|
|
var bottomBarHeight = 32.0;
|
|
|
|
// Split View Frame
|
|
var splitFrame = CGRectMake(0, 0, CGRectGetWidth(bounds), CGRectGetHeight(bounds) - bottomBarHeight);
|
|
|
|
var splitView = [[CPSplitView alloc] initWithFrame:splitFrame];
|
|
[splitView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
[splitView setVertical:NO];
|
|
|
|
// --- TOP PANE: Table View ---
|
|
var tableScroll = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(bounds), CGRectGetHeight(splitFrame) / 2.0)];
|
|
[tableScroll setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
[tableScroll setAutohidesScrollers:YES];
|
|
|
|
var tableView = [[CPTableView alloc] initWithFrame:[tableScroll bounds]];
|
|
[tableView setUsesAlternatingRowBackgroundColors:YES];
|
|
[tableView setCornerView:nil];
|
|
|
|
[tableView bind:CPSelectionIndexesBinding toObject:_arrayController withKeyPath:@"selectionIndexes" options:nil];
|
|
[tableView bind:@"sortDescriptors" toObject:_arrayController withKeyPath:@"sortDescriptors" options:nil];
|
|
|
|
var colAnimal = [[CPTableColumn alloc] initWithIdentifier:@"animal"];
|
|
[[colAnimal headerView] setStringValue:@"Animal"];
|
|
[colAnimal setWidth:150];
|
|
var animalCell = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
|
[animalCell setFont:[CPFont systemFontOfSize:12.0]];
|
|
[colAnimal setDataView:animalCell];
|
|
[tableView addTableColumn:colAnimal];
|
|
[colAnimal bind:CPValueBinding toObject:_arrayController withKeyPath:@"arrangedObjects.animal" options:nil];
|
|
|
|
var colLegs = [[CPTableColumn alloc] initWithIdentifier:@"legs"];
|
|
[[colLegs headerView] setStringValue:@"Legs"];
|
|
[colLegs setWidth:100];
|
|
var legsCell = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
|
|
[legsCell setFont:[CPFont systemFontOfSize:12.0]];
|
|
[colLegs setDataView:legsCell];
|
|
[tableView addTableColumn:colLegs];
|
|
[colLegs bind:CPValueBinding toObject:_arrayController withKeyPath:@"arrangedObjects.legs" options:nil];
|
|
|
|
[tableScroll setDocumentView:tableView];
|
|
|
|
// --- BOTTOM PANE: Text View ---
|
|
var textScroll = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(bounds), CGRectGetHeight(splitFrame) / 2.0)];
|
|
[textScroll setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
|
|
[textScroll setAutohidesScrollers:YES];
|
|
|
|
var textView = [[CPTextView alloc] initWithFrame:[textScroll bounds]];
|
|
[textView setEditable:YES];
|
|
[textView setString:@"Select an item in the table above...\n\n(This is a CPTextView inside a CPScrollView inside a CPSplitView)"];
|
|
[textView setFont:[CPFont fontWithName:@"Courier" size:13.0]];
|
|
|
|
[textScroll setDocumentView:textView];
|
|
|
|
[splitView addSubview:tableScroll];
|
|
[splitView addSubview:textScroll];
|
|
|
|
[containerView addSubview:splitView];
|
|
|
|
// Button Bar
|
|
var buttonBar = [[CPButtonBar alloc] initWithFrame:CGRectMake(0, CGRectGetHeight(bounds) - bottomBarHeight, CGRectGetWidth(bounds), bottomBarHeight)];
|
|
[buttonBar setAutoresizingMask:CPViewWidthSizable | CPViewMinYMargin];
|
|
|
|
if ([buttonBar respondsToSelector:@selector(setHasResizeControl:)])
|
|
[buttonBar setHasResizeControl:NO];
|
|
else if ([buttonBar respondsToSelector:@selector(setAutomaticResizeControl:)])
|
|
[buttonBar setAutomaticResizeControl:NO];
|
|
|
|
var plusBtn = [CPButtonBar plusButton];
|
|
[plusBtn setTarget:_arrayController];
|
|
[plusBtn setAction:@selector(add:)];
|
|
[plusBtn setEnabled:YES];
|
|
|
|
var minusBtn = [CPButtonBar minusButton];
|
|
[minusBtn setTarget:_arrayController];
|
|
[minusBtn setAction:@selector(remove:)];
|
|
[minusBtn bind:CPEnabledBinding toObject:_arrayController withKeyPath:@"canRemove" options:nil];
|
|
|
|
[buttonBar setButtons:[plusBtn, minusBtn]];
|
|
[containerView addSubview:buttonBar];
|
|
}
|
|
|
|
// --- SIZES TAB BUILDER ---
|
|
- (void)_buildSizesTab:(CPView)containerView
|
|
{
|
|
[self _addSizeColumnTo:containerView atX:20.0 controlSize:CPRegularControlSize title:@"Regular size"];
|
|
[self _addSizeColumnTo:containerView atX:160.0 controlSize:CPSmallControlSize title:@"Small size"];
|
|
[self _addSizeColumnTo:containerView atX:280.0 controlSize:CPMiniControlSize title:@"Mini size"];
|
|
}
|
|
|
|
- (void)_addSizeColumnTo:(CPView)parentView atX:(float)xPos controlSize:(CPControlSize)aSize title:(CPString)title
|
|
{
|
|
var y = 20.0;
|
|
var rowHeight = 40.0;
|
|
var width = (aSize == CPRegularControlSize) ? 100.0 : ((aSize == CPSmallControlSize) ? 90.0 : 80.0);
|
|
|
|
// 1. Title Label
|
|
var label = [CPTextField labelWithTitle:title];
|
|
[label setFrameOrigin:CGPointMake(xPos, y)];
|
|
[label setFont:[CPFont systemFontOfSize:13.0]];
|
|
[parentView addSubview:label];
|
|
|
|
y += 35.0;
|
|
|
|
// 2. PopUp Button
|
|
var popUp = [[CPPopUpButton alloc] initWithFrame:CGRectMake(xPos, y, width, 24)];
|
|
[popUp addItemWithTitle:@"Item 1"];
|
|
[popUp addItemWithTitle:@"Item 2"];
|
|
[popUp setControlSize:aSize];
|
|
[parentView addSubview:popUp];
|
|
|
|
y += rowHeight;
|
|
|
|
// 3. Text Field
|
|
var tf = [[CPTextField alloc] initWithFrame:CGRectMake(xPos, y, width, 24)];
|
|
[tf setStringValue:@"Input"];
|
|
[tf setBezeled:YES];
|
|
[tf setEditable:YES];
|
|
[tf setControlSize:aSize];
|
|
[parentView addSubview:tf];
|
|
|
|
y += rowHeight;
|
|
|
|
// 4. Stepper
|
|
var stepper = [[CPStepper alloc] initWithFrame:CGRectMake(xPos, y, 13, 23)];
|
|
[stepper setControlSize:aSize];
|
|
[parentView addSubview:stepper];
|
|
|
|
y += rowHeight;
|
|
|
|
// 5. Date Picker
|
|
var dpWidth = width + (aSize == CPRegularControlSize ? 30 : 20);
|
|
var dp = [[CPDatePicker alloc] initWithFrame:CGRectMake(xPos, y, dpWidth, 28)];
|
|
[dp setControlSize:aSize];
|
|
[dp setDatePickerStyle:CPTextFieldAndStepperDatePickerStyle];
|
|
[dp setDateValue:[CPDate date]];
|
|
[parentView addSubview:dp];
|
|
|
|
y += rowHeight;
|
|
|
|
// 6. Checkbox
|
|
var cb = [CPCheckBox checkBoxWithTitle:@"Check"];
|
|
[cb setFrameOrigin:CGPointMake(xPos, y)];
|
|
[cb setControlSize:aSize];
|
|
[cb sizeToFit];
|
|
[parentView addSubview:cb];
|
|
|
|
y += rowHeight;
|
|
|
|
// 7. Standard Button
|
|
var btn = [[CPButton alloc] initWithFrame:CGRectMake(xPos, y, width, 24)];
|
|
[btn setTitle:@"Button"];
|
|
[btn setControlSize:aSize];
|
|
[parentView addSubview:btn];
|
|
|
|
y += rowHeight;
|
|
|
|
// 8. Textured Button
|
|
var texBtn = [[CPButton alloc] initWithFrame:CGRectMake(xPos, y, width, 24)];
|
|
[texBtn setTitle:@"Textured"];
|
|
[texBtn setBezelStyle:CPTexturedSquareBezelStyle];
|
|
[texBtn setControlSize:aSize];
|
|
[parentView addSubview:texBtn];
|
|
|
|
y += rowHeight;
|
|
|
|
// 9. Round Textured Button
|
|
var roundTexBtn = [[CPButton alloc] initWithFrame:CGRectMake(xPos, y, width, 24)];
|
|
[roundTexBtn setTitle:@"Round"];
|
|
[roundTexBtn setBezelStyle:CPTexturedRoundedBezelStyle];
|
|
[roundTexBtn setControlSize:aSize];
|
|
[parentView addSubview:roundTexBtn];
|
|
|
|
y += rowHeight;
|
|
|
|
// 10. Radio Buttons
|
|
var rad1 = [CPRadio radioWithTitle:@"Radio"];
|
|
[rad1 setFrameOrigin:CGPointMake(xPos, y)];
|
|
[rad1 setControlSize:aSize];
|
|
[rad1 setState:CPOnState];
|
|
[rad1 sizeToFit];
|
|
[parentView addSubview:rad1];
|
|
|
|
y += 24.0;
|
|
|
|
var rad2 = [CPRadio radioWithTitle:@"Radio"];
|
|
[rad2 setFrameOrigin:CGPointMake(xPos, y)];
|
|
[rad2 setControlSize:aSize];
|
|
[rad2 sizeToFit];
|
|
[parentView addSubview:rad2];
|
|
|
|
y += rowHeight;
|
|
|
|
// 11. Small Bottom PopUp
|
|
var popUp2 = [[CPPopUpButton alloc] initWithFrame:CGRectMake(xPos, y, width, 24)];
|
|
[popUp2 setPullsDown:YES];
|
|
[popUp2 setControlSize:aSize];
|
|
[parentView addSubview:popUp2];
|
|
}
|
|
|
|
- (void)_disableControlsInView:(id)aView
|
|
{
|
|
var subviews = [aView subviews],
|
|
count = [subviews count];
|
|
|
|
for (var i = 0; i < count; i++)
|
|
{
|
|
var view = subviews[i];
|
|
|
|
// Skip CPBox so we can disable its children, but keep the box itself "enabled" (visible)
|
|
// Or simply recursively go down.
|
|
if ([view respondsToSelector:@selector(setEnabled:)])
|
|
[view setEnabled:NO];
|
|
|
|
if ([view isKindOfClass:[CPTextView class]])
|
|
[view setEditable:NO];
|
|
|
|
if ([[view subviews] count] > 0)
|
|
[self _disableControlsInView:view];
|
|
}
|
|
}
|
|
|
|
- (void)dummyAction:(id)sender
|
|
{
|
|
}
|
|
|
|
// --- TOOLBAR DELEGATE ---
|
|
|
|
- (CPArray)toolbarAllowedItemIdentifiers:(CPToolbar)aToolbar
|
|
{
|
|
return [@"ColorsItem", CPToolbarFlexibleSpaceItemIdentifier];
|
|
}
|
|
|
|
- (CPArray)toolbarDefaultItemIdentifiers:(CPToolbar)aToolbar
|
|
{
|
|
return [CPToolbarFlexibleSpaceItemIdentifier, @"ColorsItem"];
|
|
}
|
|
|
|
- (CPToolbarItem)toolbar:(CPToolbar)aToolbar itemForItemIdentifier:(CPString)anItemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
|
|
{
|
|
var item = [[CPToolbarItem alloc] initWithItemIdentifier:anItemIdentifier];
|
|
|
|
if (anItemIdentifier == @"ColorsItem")
|
|
{
|
|
[item setLabel:@"Colors"];
|
|
[item setPaletteLabel:@"Colors"];
|
|
[item setImage:[CPImage imageNamed:CPImageNameColorPanel]];
|
|
[item setAlternateImage:[CPImage imageNamed:CPImageNameColorPanelHighlighted]];
|
|
[item setTarget:self];
|
|
[item setAction:@selector(orderFrontColorPanel:)];
|
|
}
|
|
|
|
return item;
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation AppController : CPObject
|
|
{
|
|
CPArray windows;
|
|
}
|
|
|
|
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
|
{
|
|
windows = [];
|
|
|
|
var winWidth = 430.0,
|
|
winHeight = 550.0,
|
|
padding = 20.0;
|
|
|
|
var wc1 = [[KitchenSinkWindowController alloc] initWithContentRect:CGRectMake(50, 50, winWidth, winHeight) isHUD:NO enabled:YES];
|
|
[wc1 showWindow:self];
|
|
[windows addObject:wc1];
|
|
|
|
var wc2 = [[KitchenSinkWindowController alloc] initWithContentRect:CGRectMake(50 + winWidth + padding, 50, winWidth, winHeight) isHUD:NO enabled:NO];
|
|
[wc2 showWindow:self];
|
|
[windows addObject:wc2];
|
|
|
|
var wc3 = [[KitchenSinkWindowController alloc] initWithContentRect:CGRectMake(50, 50 + winHeight + padding + 30, winWidth, winHeight) isHUD:YES enabled:YES];
|
|
[wc3 showWindow:self];
|
|
[windows addObject:wc3];
|
|
|
|
var wc4 = [[KitchenSinkWindowController alloc] initWithContentRect:CGRectMake(50 + winWidth + padding, 50 + winHeight + padding + 30, winWidth, winHeight) isHUD:YES enabled:NO];
|
|
[wc4 showWindow:self];
|
|
[windows addObject:wc4];
|
|
|
|
[CPMenu setMenuBarVisible:YES];
|
|
}
|
|
|
|
@end
|