RemoteDrawingEngine: Reduce RP_READ_BITMAP result timeout.
[haiku.git] / src / kits / tracker / ViewState.h
blob43ce32cb1998776dbbe9c9062fdb92fdbfdfc191
1 /*
2 Open Tracker License
4 Terms and Conditions
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.
32 All rights reserved.
34 #ifndef _VIEW_STATE_H
35 #define _VIEW_STATE_H
38 #include <DataIO.h>
39 #include <String.h>
42 namespace BPrivate {
44 const int32 kColumnStateArchiveVersion = 22;
45 // bump version when layout or size changes
47 class BColumn {
48 public:
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);
55 ~BColumn();
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,
62 int32 index = 0);
63 void ArchiveToStream(BMallocIO* stream) const;
64 void ArchiveToMessage(BMessage &) const;
66 const char* Title() const;
67 float Offset() const;
68 float Width() 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);
78 void SetWidth(float);
80 private:
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);
86 BString fTitle;
87 float fOffset;
88 float fWidth;
89 alignment fAlignment;
90 BString fAttrName;
91 BString fDisplayAs;
92 uint32 fAttrHash;
93 uint32 fAttrType;
94 bool fStatField;
95 bool fEditable;
99 const int32 kViewStateArchiveVersion = 11;
100 // bump version when layout or size changes
102 class BViewState {
103 public:
104 BViewState();
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();
140 private:
141 static BViewState* _Sanitize(BViewState* state, bool fixOnly = false);
143 uint32 fViewMode;
144 uint32 fLastIconMode;
145 uint32 fIconSize;
146 uint32 fLastIconSize;
147 BPoint fListOrigin;
148 BPoint fIconOrigin;
149 uint32 fPrimarySortAttr;
150 uint32 fSecondarySortAttr;
151 uint32 fPrimarySortType;
152 uint32 fSecondarySortType;
153 bool fReverseSort;
155 void _Init();
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;
172 inline const char*
173 BColumn::Title() const
175 return fTitle.String();
179 inline float
180 BColumn::Offset() const
182 return fOffset;
186 inline float
187 BColumn::Width() const
189 return fWidth;
193 inline alignment
194 BColumn::Alignment() const
196 return fAlignment;
200 inline const char*
201 BColumn::AttrName() const
203 return fAttrName.String();
207 inline uint32
208 BColumn::AttrHash() const
210 return fAttrHash;
214 inline uint32
215 BColumn::AttrType() const
217 return fAttrType;
221 inline const char*
222 BColumn::DisplayAs() const
224 return fDisplayAs.String();
228 inline bool
229 BColumn::StatField() const
231 return fStatField;
235 inline bool
236 BColumn::Editable() const
238 return fEditable;
242 inline void
243 BColumn::SetWidth(float w)
245 fWidth = w;
249 inline void
250 BColumn::SetOffset(float o)
252 fOffset = o;
256 inline uint32
257 BViewState::ViewMode() const
259 return fViewMode;
263 inline uint32
264 BViewState::LastIconMode() const
266 return fLastIconMode;
270 inline uint32
271 BViewState::IconSize() const
273 return fIconSize;
277 inline uint32
278 BViewState::LastIconSize() const
280 return fLastIconSize;
284 inline BPoint
285 BViewState::ListOrigin() const
287 return fListOrigin;
291 inline BPoint
292 BViewState::IconOrigin() const
294 return fIconOrigin;
298 inline uint32
299 BViewState::PrimarySort() const
301 return fPrimarySortAttr;
305 inline uint32
306 BViewState::SecondarySort() const
308 return fSecondarySortAttr;
312 inline uint32
313 BViewState::PrimarySortType() const
315 return fPrimarySortType;
318 inline uint32
319 BViewState::SecondarySortType() const
321 return fSecondarySortType;
324 inline bool
325 BViewState::ReverseSort() const
327 return fReverseSort;
331 inline void
332 BViewState::SetViewMode(uint32 mode)
334 fViewMode = mode;
338 inline void
339 BViewState::SetLastIconMode(uint32 mode)
341 fLastIconMode = mode;
345 inline void
346 BViewState::SetIconSize(uint32 size)
348 fIconSize = size;
352 inline void
353 BViewState::SetLastIconSize(uint32 size)
355 fLastIconSize = size;
359 inline void
360 BViewState::SetListOrigin(BPoint newOrigin)
362 fListOrigin = newOrigin;
365 inline void
366 BViewState::SetIconOrigin(BPoint newOrigin)
368 fIconOrigin = newOrigin;
371 inline void
372 BViewState::SetPrimarySort(uint32 attr)
374 fPrimarySortAttr = attr;
378 inline void
379 BViewState::SetSecondarySort(uint32 attr)
381 fSecondarySortAttr = attr;
385 inline void
386 BViewState::SetPrimarySortType(uint32 type)
388 fPrimarySortType = type;
392 inline void
393 BViewState::SetSecondarySortType(uint32 type)
395 fSecondarySortType = type;
399 inline void
400 BViewState::SetReverseSort(bool on)
402 fReverseSort = on;
406 inline bool
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