6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
30 of Be Incorporated in the United States and other countries. Other brand product
31 names are registered trademarks or trademarks of their respective holders.
44 const int32 kColumnStateArchiveVersion
= 22;
45 // bump version when layout or size changes
49 BColumn(const char* title
, float offset
, float width
,
50 alignment align
, const char* attributeName
, uint32 attrType
,
51 const char* displayAs
, bool statField
, bool editable
);
52 BColumn(const char* title
, float offset
, float width
,
53 alignment align
, const char* attributeName
, uint32 attrType
,
54 bool statField
, bool editable
);
57 BColumn(BMallocIO
* stream
, int32 version
, bool endianSwap
= false);
58 BColumn(const BMessage
&, int32 index
= 0);
59 static BColumn
* InstantiateFromStream(BMallocIO
* stream
,
60 bool endianSwap
= false);
61 static BColumn
* InstantiateFromMessage(const BMessage
&archive
,
63 void ArchiveToStream(BMallocIO
* stream
) const;
64 void ArchiveToMessage(BMessage
&) const;
66 const char* Title() const;
69 alignment
Alignment() const;
70 const char* AttrName() const;
71 uint32
AttrType() const;
72 const char* DisplayAs() const;
73 uint32
AttrHash() const;
74 bool StatField() const;
75 bool Editable() const;
77 void SetOffset(float);
81 void _Init(const char* title
, float offset
, float width
,
82 alignment align
, const char* attributeName
, uint32 attrType
,
83 const char* displayAs
, bool statField
, bool editable
);
84 static BColumn
* _Sanitize(BColumn
* column
);
99 const int32 kViewStateArchiveVersion
= 11;
100 // bump version when layout or size changes
106 BViewState(BMallocIO
* stream
, bool endianSwap
= false);
107 BViewState(const BMessage
&message
);
108 static BViewState
* InstantiateFromStream(BMallocIO
* stream
,
109 bool endianSwap
= false);
110 static BViewState
* InstantiateFromMessage(const BMessage
&message
);
111 void ArchiveToStream(BMallocIO
* stream
) const;
112 void ArchiveToMessage(BMessage
&message
) const;
114 uint32
ViewMode() const;
115 uint32
LastIconMode() const;
116 uint32
IconSize() const;
117 uint32
LastIconSize() const;
118 BPoint
ListOrigin() const;
119 BPoint
IconOrigin() const;
120 uint32
PrimarySort() const;
121 uint32
SecondarySort() const;
122 uint32
PrimarySortType() const;
123 uint32
SecondarySortType() const;
124 bool ReverseSort() const;
126 void SetViewMode(uint32
);
127 void SetLastIconMode(uint32
);
128 void SetIconSize(uint32
);
129 void SetLastIconSize(uint32
);
130 void SetListOrigin(BPoint
);
131 void SetIconOrigin(BPoint
);
132 void SetPrimarySort(uint32
);
133 void SetSecondarySort(uint32
);
134 void SetPrimarySortType(uint32
);
135 void SetSecondarySortType(uint32
);
136 void SetReverseSort(bool);
138 bool StateNeedsSaving();
141 static BViewState
* _Sanitize(BViewState
* state
, bool fixOnly
= false);
144 uint32 fLastIconMode
;
146 uint32 fLastIconSize
;
149 uint32 fPrimarySortAttr
;
150 uint32 fSecondarySortAttr
;
151 uint32 fPrimarySortType
;
152 uint32 fSecondarySortType
;
156 void _StorePreviousState();
158 uint32 fPreviousViewMode
;
159 uint32 fPreviousLastIconMode
;
160 uint32 fPreviousIconSize
;
161 uint32 fPreviousLastIconSize
;
162 BPoint fPreviousListOrigin
;
163 BPoint fPreviousIconOrigin
;
164 uint32 fPreviousPrimarySortAttr
;
165 uint32 fPreviousSecondarySortAttr
;
166 uint32 fPreviousPrimarySortType
;
167 uint32 fPreviousSecondarySortType
;
168 bool fPreviousReverseSort
;
173 BColumn::Title() const
175 return fTitle
.String();
180 BColumn::Offset() const
187 BColumn::Width() const
194 BColumn::Alignment() const
201 BColumn::AttrName() const
203 return fAttrName
.String();
208 BColumn::AttrHash() const
215 BColumn::AttrType() const
222 BColumn::DisplayAs() const
224 return fDisplayAs
.String();
229 BColumn::StatField() const
236 BColumn::Editable() const
243 BColumn::SetWidth(float w
)
250 BColumn::SetOffset(float o
)
257 BViewState::ViewMode() const
264 BViewState::LastIconMode() const
266 return fLastIconMode
;
271 BViewState::IconSize() const
278 BViewState::LastIconSize() const
280 return fLastIconSize
;
285 BViewState::ListOrigin() const
292 BViewState::IconOrigin() const
299 BViewState::PrimarySort() const
301 return fPrimarySortAttr
;
306 BViewState::SecondarySort() const
308 return fSecondarySortAttr
;
313 BViewState::PrimarySortType() const
315 return fPrimarySortType
;
319 BViewState::SecondarySortType() const
321 return fSecondarySortType
;
325 BViewState::ReverseSort() const
332 BViewState::SetViewMode(uint32 mode
)
339 BViewState::SetLastIconMode(uint32 mode
)
341 fLastIconMode
= mode
;
346 BViewState::SetIconSize(uint32 size
)
353 BViewState::SetLastIconSize(uint32 size
)
355 fLastIconSize
= size
;
360 BViewState::SetListOrigin(BPoint newOrigin
)
362 fListOrigin
= newOrigin
;
366 BViewState::SetIconOrigin(BPoint newOrigin
)
368 fIconOrigin
= newOrigin
;
372 BViewState::SetPrimarySort(uint32 attr
)
374 fPrimarySortAttr
= attr
;
379 BViewState::SetSecondarySort(uint32 attr
)
381 fSecondarySortAttr
= attr
;
386 BViewState::SetPrimarySortType(uint32 type
)
388 fPrimarySortType
= type
;
393 BViewState::SetSecondarySortType(uint32 type
)
395 fSecondarySortType
= type
;
400 BViewState::SetReverseSort(bool on
)
407 BViewState::StateNeedsSaving()
409 return (fPreviousViewMode
!= fViewMode
)
410 || (fPreviousLastIconMode
!= fLastIconMode
)
411 || (fPreviousIconSize
!= fIconSize
)
412 || (fPreviousLastIconSize
!= fLastIconSize
)
413 || (fPreviousListOrigin
!= fListOrigin
)
414 || (fPreviousIconOrigin
!= fIconOrigin
)
415 || (fPreviousPrimarySortAttr
!= fPrimarySortAttr
)
416 || (fPreviousSecondarySortAttr
!= fSecondarySortAttr
)
417 || (fPreviousPrimarySortType
!= fPrimarySortType
)
418 || (fPreviousSecondarySortType
!= fSecondarySortType
)
419 || (fPreviousReverseSort
!= fReverseSort
);
422 } // namespace BPrivate
424 using namespace BPrivate
;
427 #endif // _VIEW_STATE_H