API  0.9.6
 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 }
62 
63 - (id)init
64 {
65  return [self initWithIdentifier:@""];
66 }
67 
72 - (id)initWithIdentifier:(id)anIdentifier
73 {
74  self = [super init];
75 
76  if (self)
77  _identifier = anIdentifier;
78 
79  return self;
80 }
81 
82 // Working With Labels
87 - (void)setLabel:(CPString)aLabel
88 {
89  _label = aLabel;
90 }
91 
96 {
97  return _label;
98 }
99 
100 // Checking the Tab Display State
104 - (CPTabState)tabState
105 {
106  return _tabState;
107 }
108 
109 // Assigning an Identifier Object
114 - (void)setIdentifier:(id)anIdentifier
115 {
116  _identifier = anIdentifier;
117 }
118 
122 - (id)identifier
123 {
124  return _identifier;
125 }
126 
127 // Assigning a View
131 - (void)setView:(CPView)aView
132 {
133  if (_view == aView)
134  return;
135 
136  _view = aView;
137 
138  if ([_tabView selectedTabViewItem] == self)
139  [_tabView _setContentViewFromItem:self];
140 }
141 
145 - (CPView)view
146 {
147  return _view;
148 }
149 
150 // Assigning an Auxiliary View
155 - (void)setAuxiliaryView:(CPView)anAuxiliaryView
156 {
157  _auxiliaryView = anAuxiliaryView;
158 }
159 
163 - (CPView)auxiliaryView
164 {
165  return _auxiliaryView;
166 }
167 
168 // Accessing the Parent Tab View
172 - (CPTabView)tabView
173 {
174  return _tabView;
175 }
176 
180 - (void)_setTabView:(CPTabView)aView
181 {
182  _tabView = aView;
183 }
184 
185 @end
186 
187 var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey",
188  CPTabViewItemLabelKey = "CPTabViewItemLabelKey",
189  CPTabViewItemViewKey = "CPTabViewItemViewKey",
190  CPTabViewItemAuxViewKey = "CPTabViewItemAuxViewKey";
191 
192 
194 
195 - (id)initWithCoder:(CPCoder)aCoder
196 {
197  self = [super init];
198 
199  if (self)
200  {
201  _identifier = [aCoder decodeObjectForKey:CPTabViewItemIdentifierKey];
202  _label = [aCoder decodeObjectForKey:CPTabViewItemLabelKey];
203 
204  _view = [aCoder decodeObjectForKey:CPTabViewItemViewKey];
205  _auxiliaryView = [aCoder decodeObjectForKey:CPTabViewItemAuxViewKey];
206  }
207 
208  return self;
209 }
210 
211 - (void)encodeWithCoder:(CPCoder)aCoder
212 {
213  [aCoder encodeObject:_identifier forKey:CPTabViewItemIdentifierKey];
214  [aCoder encodeObject:_label forKey:CPTabViewItemLabelKey];
215 
216  [aCoder encodeObject:_view forKey:CPTabViewItemViewKey];
217  [aCoder encodeObject:_auxiliaryView forKey:CPTabViewItemAuxViewKey];
218 }
219 
220 @end