Merge commit 'svn-macvim'
[MacVim.git] / PSMTabBarControl / source / PSMTabBarControlInspector.m
blobd9c5b91c4f73972f9dba1a250cdfd918df25dd7d
1 //
2 //  PSMTabBarControlInspector.m
3 //  PSMTabBarControl
4 //
5 //  Created by John Pannell on 12/21/05.
6 //  Copyright Positive Spin Media 2005 . All rights reserved.
7 //
9 #import "PSMTabBarControlInspector.h"
10 #import "PSMTabBarControl.h"
12 #define kPSMStyleTag 0
13 #define kPSMCanCloseOnlyTabTag 1
14 #define kPSMHideForSingleTabTag 2
15 #define kPSMShowAddTabTag 3
16 #define kPSMMinWidthTag 4
17 #define kPSMMaxWidthTag 5
18 #define kPSMOptimumWidthTag 6
19 #define kPSMSizeToFitTag 7
20 #define kPSMAllowsDragBetweenWindows 8
22 @implementation PSMTabBarControlInspector
24 - (id)init
26     self = [super init];
27     [NSBundle loadNibNamed:@"PSMTabBarControlInspector" owner:self];
28     return self;
31 - (void)ok:(id)sender
33     if([sender tag] == kPSMStyleTag){
34         [[self object] setStyleNamed:[sender titleOfSelectedItem]];
35         
36     } else if([sender tag] == kPSMCanCloseOnlyTabTag){
37         [[self object] setCanCloseOnlyTab:[sender state]];
38         
39     } else if([sender tag] == kPSMHideForSingleTabTag){
40         [[self object] setHideForSingleTab:[sender state]];
41         
42     } else if([sender tag] == kPSMShowAddTabTag){
43         [[self object] setShowAddTabButton:[sender state]];
44         
45     } else if([sender tag] == kPSMMinWidthTag){
46         if([[self object] cellOptimumWidth] < [sender intValue]){
47             [[self object] setCellMinWidth:[[self object] cellOptimumWidth]];
48             [sender setIntValue:[[self object] cellOptimumWidth]];
49         } else {
50             [[self object] setCellMinWidth:[sender intValue]];
51         }
52         
53     } else if([sender tag] == kPSMMaxWidthTag){
54         if([[self object] cellOptimumWidth] > [sender intValue]){
55             [[self object] setCellMaxWidth:[[self object] cellOptimumWidth]];
56             [sender setIntValue:[[self object] cellOptimumWidth]];
57         } else {
58             [[self object] setCellMaxWidth:[sender intValue]];
59         }
60         
61     } else if([sender tag] == kPSMOptimumWidthTag){
62         if([[self object] cellMaxWidth] < [sender intValue]){
63             [[self object] setCellOptimumWidth:[[self object] cellMaxWidth]];
64             [sender setIntValue:[[self object] cellMaxWidth]];
65         } else if([[self object] cellMinWidth] > [sender intValue]){
66             [[self object] setCellOptimumWidth:[[self object] cellMinWidth]];
67             [sender setIntValue:[[self object] cellMinWidth]];
68         } else {
69             [[self object] setCellOptimumWidth:[sender intValue]];
70         }
71         
72     } else if([sender tag] == kPSMSizeToFitTag){
73         [[self object] setSizeCellsToFit:[sender state]];
74         
75     } else if([sender tag] == kPSMAllowsDragBetweenWindows){
76         [[self object] setAllowsDragBetweenWindows:[sender state]];
77         
78     }
79     
80     
81     [super ok:sender];
84 - (void)revert:(id)sender
86     [_stylePopUp selectItemWithTitle:[[self object] styleName]];
87     [_canCloseOnlyTab setState:[[self object] canCloseOnlyTab]];
88     [_hideForSingleTab setState:[[self object] hideForSingleTab]];
89     [_showAddTab setState:[[self object] showAddTabButton]];
90     [_cellMinWidth setIntValue:[[self object] cellMinWidth]];
91     [_cellMaxWidth setIntValue:[[self object] cellMaxWidth]];
92     [_cellOptimumWidth setIntValue:[[self object] cellOptimumWidth]];
93     [_sizeToFit setState:[[self object] sizeCellsToFit]];
94     [_allowsDragBetweenWindows setState:[[self object] allowsDragBetweenWindows]];
95     
96     [super revert:sender];
99 @end