API  0.9.7
 All Classes Files Functions Variables Macros Groups Pages
CPTabViewItem.j
Go to the documentation of this file.
1 /*
2  * CPTabViewItem.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2008, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
25 
26 /*
27  The tab is currently selected.
28  @global
29  @group CPTabState
30 */
32 /*
33  The tab is currently in the background (not selected).
34  @global
35  @group CPTabState
36 */
38 /*
39  The tab of this item is currently being pressed by the user.
40  @global
41  @group CPTabState
42 */
44 
52 @implementation CPTabViewItem : CPObject
53 {
54  id _identifier;
55  CPString _label;
56 
57  CPView _view;
58  CPView _auxiliaryView;
59 
60  CPTabView _tabView;
61  unsigned _tabState; // Looks like it is not yet implemented
62 }
63 
64 - (id)init
65 {
66  return [self initWithIdentifier:@""];
67 }
68 
73 - (id)initWithIdentifier:(id)anIdentifier
74 {
75  self = [super init];
76 
77  if (self)
78  _identifier = anIdentifier;
79 
80  return self;
81 }
82 
83 // Working With Labels
88 - (void)setLabel:(CPString)aLabel
89 {
90  _label = aLabel;
91 }
92 
97 {
98  return _label;
99 }
100 
101 // Checking the Tab Display State
105 - (CPTabState)tabState
106 {
107  return _tabState;
108 }
109 
110 // Assigning an Identifier Object
115 - (void)setIdentifier:(id)anIdentifier
116 {
117  _identifier = anIdentifier;
118 }
119 
123 - (id)identifier
124 {
125  return _identifier;
126 }
127 
128 // Assigning a View
132 - (void)setView:(CPView)aView
133 {
134  if (_view == aView)
135  return;
136 
137  _view = aView;
138 
139  if ([_tabView selectedTabViewItem] == self)
140  [_tabView _setContentViewFromItem:self];
141 }
142 
146 - (CPView)view
147 {
148  return _view;
149 }
150 
151 // Assigning an Auxiliary View
156 - (void)setAuxiliaryView:(CPView)anAuxiliaryView
157 {
158  _auxiliaryView = anAuxiliaryView;
159 }
160 
164 - (CPView)auxiliaryView
165 {
166  return _auxiliaryView;
167 }
168 
169 // Accessing the Parent Tab View
173 - (CPTabView)tabView
174 {
175  return _tabView;
176 }
177 
181 - (void)_setTabView:(CPTabView)aView
182 {
183  _tabView = aView;
184 }
185 
186 @end
187 
188 var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
189  CPTabViewItemLabelKey = "CPTabViewItemLabelKey",
190  CPTabViewItemViewKey = "CPTabViewItemViewKey",
191  CPTabViewItemAuxViewKey = "CPTabViewItemAuxViewKey";
192 
193 
195 
196 - (id)initWithCoder:(CPCoder)aCoder
197 {
198  self = [super init];
199 
200  if (self)
201  {
202  _identifier = [aCoder decodeObjectForKey:CPTabViewItemIdentifierKey];
203  _label = [aCoder decodeObjectForKey:CPTabViewItemLabelKey];
204 
205  _view = [aCoder decodeObjectForKey:CPTabViewItemViewKey];
206  _auxiliaryView = [aCoder decodeObjectForKey:CPTabViewItemAuxViewKey];
207  }
208 
209  return self;
210 }
211 
212 - (void)encodeWithCoder:(CPCoder)aCoder
213 {
214  [aCoder encodeObject:_identifier forKey:CPTabViewItemIdentifierKey];
215  [aCoder encodeObject:_label forKey:CPTabViewItemLabelKey];
216 
217  [aCoder encodeObject:_view forKey:CPTabViewItemViewKey];
218  [aCoder encodeObject:_auxiliaryView forKey:CPTabViewItemAuxViewKey];
219 }
220 
221 @end