![]() |
API 0.9.5
|
00001 /* 00002 * CPTabViewItem.j 00003 * AppKit 00004 * 00005 * Created by Francisco Tolmasky. 00006 * Copyright 2008, 280 North, Inc. 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 00024 00025 00026 /* 00027 The tab is currently selected. 00028 @global 00029 @group CPTabState 00030 */ 00031 CPSelectedTab = 0; 00032 /* 00033 The tab is currently in the background (not selected). 00034 @global 00035 @group CPTabState 00036 */ 00037 CPBackgroundTab = 1; 00038 /* 00039 The tab of this item is currently being pressed by the user. 00040 @global 00041 @group CPTabState 00042 */ 00043 CPPressedTab = 2; 00044 00052 @implementation CPTabViewItem : CPObject 00053 { 00054 id _identifier; 00055 CPString _label; 00056 00057 CPView _view; 00058 CPView _auxiliaryView; 00059 00060 CPTabView _tabView; 00061 } 00062 00063 - (id)init 00064 { 00065 return [self initWithIdentifier:@""]; 00066 } 00067 00072 - (id)initWithIdentifier:(id)anIdentifier 00073 { 00074 self = [super init]; 00075 00076 if (self) 00077 _identifier = anIdentifier; 00078 00079 return self; 00080 } 00081 00082 // Working With Labels 00087 - (void)setLabel:(CPString)aLabel 00088 { 00089 _label = aLabel; 00090 } 00091 00095 - (CPString)label 00096 { 00097 return _label; 00098 } 00099 00100 // Checking the Tab Display State 00104 - (CPTabState)tabState 00105 { 00106 return _tabState; 00107 } 00108 00109 // Assigning an Identifier Object 00114 - (void)setIdentifier:(id)anIdentifier 00115 { 00116 _identifier = anIdentifier; 00117 } 00118 00122 - (id)identifier 00123 { 00124 return _identifier; 00125 } 00126 00127 // Assigning a View 00131 - (void)setView:(CPView)aView 00132 { 00133 _view = aView; 00134 } 00135 00139 - (CPView)view 00140 { 00141 return _view; 00142 } 00143 00144 // Assigning an Auxiliary View 00149 - (void)setAuxiliaryView:(CPView)anAuxiliaryView 00150 { 00151 _auxiliaryView = anAuxiliaryView; 00152 } 00153 00157 - (CPView)auxiliaryView 00158 { 00159 return _auxiliaryView; 00160 } 00161 00162 // Accessing the Parent Tab View 00166 - (CPTabView)tabView 00167 { 00168 return _tabView; 00169 } 00170 00174 - (void)_setTabView:(CPTabView)aView 00175 { 00176 _tabView = aView; 00177 } 00178 00179 @end 00180 00181 var CPTabViewItemIdentifierKey = "CPTabViewItemIdentifierKey", 00182 CPTabViewItemLabelKey = "CPTabViewItemLabelKey", 00183 CPTabViewItemViewKey = "CPTabViewItemViewKey", 00184 CPTabViewItemAuxViewKey = "CPTabViewItemAuxViewKey"; 00185 00186 00187 @implementation CPTabViewItem (CPCoding) 00188 00189 - (id)initWithCoder:(CPCoder)aCoder 00190 { 00191 self = [super init]; 00192 00193 if (self) 00194 { 00195 _identifier = [aCoder decodeObjectForKey:CPTabViewItemIdentifierKey]; 00196 _label = [aCoder decodeObjectForKey:CPTabViewItemLabelKey]; 00197 00198 _view = [aCoder decodeObjectForKey:CPTabViewItemViewKey]; 00199 _auxiliaryView = [aCoder decodeObjectForKey:CPTabViewItemAuxViewKey]; 00200 } 00201 00202 return self; 00203 } 00204 00205 - (void)encodeWithCoder:(CPCoder)aCoder 00206 { 00207 [aCoder encodeObject:_identifier forKey:CPTabViewItemIdentifierKey]; 00208 [aCoder encodeObject:_label forKey:CPTabViewItemLabelKey]; 00209 00210 [aCoder encodeObject:_view forKey:CPTabViewItemViewKey]; 00211 [aCoder encodeObject:_auxiliaryView forKey:CPTabViewItemAuxViewKey]; 00212 } 00213 00214 @end