#import "AppController.h"

@implementation AppController


- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
    return YES;
}


- (IBAction)changeTitle:(id)sender
{
    int selection = [(NSPopUpButton *)sender indexOfSelectedItem];
    if (selection == 0) { // Short title
        [box setTitle:@"Short Title"];
    } else { // Long title
        [box setTitle:@"A much longer title than is commonly encountered in boxes"];
    }
}


- (IBAction)changeTitlebar:(id)sender
{
    BOOL fullTitles = ([(NSButton *)sender state] == NSOnState);
    [box setDrawsFullTitleBar:fullTitles];
}


- (IBAction)changeSelected:(id)sender
{
    BOOL selected = ([(NSButton *)sender state] == NSOnState);
    [box setSelected:selected];
    [borderColorWell setEnabled:!selected];
}


- (IBAction)changeBackground:(id)sender
{
    if ([[(NSMatrix *)sender selectedCell] tag] == 0) {
        [box setDrawsGradientBackground:YES];
        [gradientStartColorWell setEnabled:YES];
        [gradientEndColorWell setEnabled:YES];
        [backgroundColorWell setEnabled:NO];
    } else {
        [box setDrawsGradientBackground:NO];
        [gradientStartColorWell setEnabled:NO];
        [gradientEndColorWell setEnabled:NO];
        [backgroundColorWell setEnabled:YES];
    }
}


- (IBAction)changeTitleColor:(id)sender
{
    [box setTitleColor:[(NSColorWell *)sender color]];
}


- (IBAction)changeBorderColor:(id)sender
{
    [box setBorderColor:[(NSColorWell *)sender color]];
}


- (IBAction)changeGradientStartColor:(id)sender
{
    [box setGradientStartColor:[(NSColorWell *)sender color]];
}


- (IBAction)changeGradientEndColor:(id)sender
{
    [box setGradientEndColor:[(NSColorWell *)sender color]];
}


- (IBAction)changeBackgroundColor:(id)sender
{
    [box setBackgroundColor:[(NSColorWell *)sender color]];
}


@end
