Imported ViewState.cpp|h 1.2 from OpenTracker CVS.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18996 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+125
-123
@@ -32,9 +32,6 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <AppDefs.h>
|
#include <AppDefs.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
@@ -45,6 +42,11 @@ All rights reserved.
|
|||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "ViewState.h"
|
#include "ViewState.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
const char *kColumnVersionName = "BColumn:version";
|
const char *kColumnVersionName = "BColumn:version";
|
||||||
const char *kColumnTitleName = "BColumn:fTitle";
|
const char *kColumnTitleName = "BColumn:fTitle";
|
||||||
const char *kColumnOffsetName = "BColumn:fOffset";
|
const char *kColumnOffsetName = "BColumn:fOffset";
|
||||||
@@ -56,25 +58,41 @@ const char *kColumnAttrTypeName = "BColumn:fAttrType";
|
|||||||
const char *kColumnStatFieldName = "BColumn:fStatField";
|
const char *kColumnStatFieldName = "BColumn:fStatField";
|
||||||
const char *kColumnEditableName = "BColumn:fEditable";
|
const char *kColumnEditableName = "BColumn:fEditable";
|
||||||
|
|
||||||
BColumn::BColumn(const char *title, float offset, float width, alignment a,
|
const char *kViewStateVersionName = "ViewState:version";
|
||||||
const char *attributeName, uint32 attr_type, bool stat_field,
|
const char *kViewStateViewModeName = "ViewState:fViewMode";
|
||||||
bool editable)
|
const char *kViewStateLastIconModeName = "ViewState:fLastIconMode";
|
||||||
: fTitle(title),
|
const char *kViewStateListOriginName = "ViewState:fListOrigin";
|
||||||
fAttrName(attributeName)
|
const char *kViewStateIconOriginName = "ViewState:fIconOrigin";
|
||||||
|
const char *kViewStatePrimarySortAttrName = "ViewState:fPrimarySortAttr";
|
||||||
|
const char *kViewStatePrimarySortTypeName = "ViewState:fPrimarySortType";
|
||||||
|
const char *kViewStateSecondarySortAttrName = "ViewState:fSecondarySortAttr";
|
||||||
|
const char *kViewStateSecondarySortTypeName = "ViewState:fSecondarySortType";
|
||||||
|
const char *kViewStateReverseSortName = "ViewState:fReverseSort";
|
||||||
|
const char *kViewStateIconSizeName = "ViewState:fIconSize";
|
||||||
|
|
||||||
|
|
||||||
|
BColumn::BColumn(const char *title, float offset, float width, alignment align,
|
||||||
|
const char *attributeName, uint32 attrType, bool statField,
|
||||||
|
bool editable)
|
||||||
|
:
|
||||||
|
fTitle(title),
|
||||||
|
fAttrName(attributeName)
|
||||||
{
|
{
|
||||||
fOffset = offset;
|
fOffset = offset;
|
||||||
fWidth = width;
|
fWidth = width;
|
||||||
fAlignment = a;
|
fAlignment = align;
|
||||||
fAttrHash = AttrHashString(attributeName, attr_type);
|
fAttrHash = AttrHashString(attributeName, attrType);
|
||||||
fAttrType = attr_type;
|
fAttrType = attrType;
|
||||||
fStatField = stat_field;
|
fStatField = statField;
|
||||||
fEditable = editable;
|
fEditable = editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BColumn::~BColumn()
|
BColumn::~BColumn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BColumn::BColumn(BMallocIO *stream, bool endianSwap)
|
BColumn::BColumn(BMallocIO *stream, bool endianSwap)
|
||||||
{
|
{
|
||||||
StringFromStream(&fTitle, stream, endianSwap);
|
StringFromStream(&fTitle, stream, endianSwap);
|
||||||
@@ -98,6 +116,7 @@ BColumn::BColumn(BMallocIO *stream, bool endianSwap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BColumn::BColumn(const BMessage &message, int32 index)
|
BColumn::BColumn(const BMessage &message, int32 index)
|
||||||
{
|
{
|
||||||
message.FindString(kColumnTitleName, index, &fTitle);
|
message.FindString(kColumnTitleName, index, &fTitle);
|
||||||
@@ -111,6 +130,7 @@ BColumn::BColumn(const BMessage &message, int32 index)
|
|||||||
message.FindBool(kColumnEditableName, index, &fEditable);
|
message.FindBool(kColumnEditableName, index, &fEditable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BColumn *
|
BColumn *
|
||||||
BColumn::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
BColumn::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
||||||
{
|
{
|
||||||
@@ -118,7 +138,6 @@ BColumn::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
|||||||
uint32 key = AttrHashString("BColumn", B_OBJECT_TYPE);
|
uint32 key = AttrHashString("BColumn", B_OBJECT_TYPE);
|
||||||
int32 version = kColumnStateArchiveVersion;
|
int32 version = kColumnStateArchiveVersion;
|
||||||
|
|
||||||
|
|
||||||
if (endianSwap) {
|
if (endianSwap) {
|
||||||
key = SwapUInt32(key);
|
key = SwapUInt32(key);
|
||||||
version = SwapInt32(version);
|
version = SwapInt32(version);
|
||||||
@@ -129,29 +148,10 @@ BColumn::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// PRINT(("instantiating column, %s\n", endianSwap ? "endian swapping," : ""));
|
// PRINT(("instantiating column, %s\n", endianSwap ? "endian swapping," : ""));
|
||||||
BColumn *result = new BColumn(stream, endianSwap);
|
return _Sanitize(new (std::nothrow) BColumn(stream, endianSwap));
|
||||||
|
|
||||||
// sanity-check the resulting column
|
|
||||||
if (result->fTitle.Length() > 500
|
|
||||||
|| result->fOffset < 0
|
|
||||||
|| result->fOffset > 10000
|
|
||||||
|| result->fWidth < 0
|
|
||||||
|| result->fWidth > 10000
|
|
||||||
|| (int32)result->fAlignment < B_ALIGN_LEFT
|
|
||||||
|| (int32)result->fAlignment > B_ALIGN_CENTER
|
|
||||||
|| result->fAttrName.Length() > 500) {
|
|
||||||
PRINT(("column data not valid\n"));
|
|
||||||
delete result;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#if DEBUG
|
|
||||||
else if (endianSwap)
|
|
||||||
PRINT(("Instantiated foreign column ok\n"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BColumn *
|
BColumn *
|
||||||
BColumn::InstantiateFromMessage(const BMessage &message, int32 index)
|
BColumn::InstantiateFromMessage(const BMessage &message, int32 index)
|
||||||
{
|
{
|
||||||
@@ -164,24 +164,10 @@ BColumn::InstantiateFromMessage(const BMessage &message, int32 index)
|
|||||||
if (version != messageVersion)
|
if (version != messageVersion)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BColumn *result = new BColumn(message, index);
|
return _Sanitize(new (std::nothrow) BColumn(message, index));
|
||||||
|
|
||||||
// sanity-check the resulting column
|
|
||||||
if (result->fTitle.Length() > 500
|
|
||||||
|| result->fOffset < 0
|
|
||||||
|| result->fOffset > 10000
|
|
||||||
|| result->fWidth < 0
|
|
||||||
|| result->fWidth > 10000
|
|
||||||
|| (int32)result->fAlignment < B_ALIGN_LEFT
|
|
||||||
|| (int32)result->fAlignment > B_ALIGN_CENTER
|
|
||||||
|| result->fAttrName.Length() > 500) {
|
|
||||||
PRINT(("column data not valid\n"));
|
|
||||||
delete result;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BColumn::ArchiveToStream(BMallocIO *stream) const
|
BColumn::ArchiveToStream(BMallocIO *stream) const
|
||||||
{
|
{
|
||||||
@@ -204,6 +190,7 @@ BColumn::ArchiveToStream(BMallocIO *stream) const
|
|||||||
stream->Write(&fEditable, sizeof(bool));
|
stream->Write(&fEditable, sizeof(bool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BColumn::ArchiveToMessage(BMessage &message) const
|
BColumn::ArchiveToMessage(BMessage &message) const
|
||||||
{
|
{
|
||||||
@@ -220,17 +207,37 @@ BColumn::ArchiveToMessage(BMessage &message) const
|
|||||||
message.AddBool(kColumnEditableName, fEditable);
|
message.AddBool(kColumnEditableName, fEditable);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *kViewStateVersionName = "ViewState:version";
|
|
||||||
const char *kViewStateViewModeName = "ViewState:fViewMode";
|
BColumn *
|
||||||
const char *kViewStateLastIconModeName = "ViewState:fLastIconMode";
|
BColumn::_Sanitize(BColumn *column)
|
||||||
const char *kViewStateListOriginName = "ViewState:fListOrigin";
|
{
|
||||||
const char *kViewStateIconOriginName = "ViewState:fIconOrigin";
|
if (column == NULL)
|
||||||
const char *kViewStatePrimarySortAttrName = "ViewState:fPrimarySortAttr";
|
return NULL;
|
||||||
const char *kViewStatePrimarySortTypeName = "ViewState:fPrimarySortType";
|
|
||||||
const char *kViewStateSecondarySortAttrName = "ViewState:fSecondarySortAttr";
|
// sanity-check the resulting column
|
||||||
const char *kViewStateSecondarySortTypeName = "ViewState:fSecondarySortType";
|
if (column->fTitle.Length() > 500
|
||||||
const char *kViewStateReverseSortName = "ViewState:fReverseSort";
|
|| column->fOffset < 0
|
||||||
const char *kViewStateIconSizeName = "ViewState:fIconSize";
|
|| column->fOffset > 10000
|
||||||
|
|| column->fWidth < 0
|
||||||
|
|| column->fWidth > 10000
|
||||||
|
|| (int32)column->fAlignment < B_ALIGN_LEFT
|
||||||
|
|| (int32)column->fAlignment > B_ALIGN_CENTER
|
||||||
|
|| column->fAttrName.Length() > 500) {
|
||||||
|
PRINT(("column data not valid\n"));
|
||||||
|
delete column;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#if DEBUG
|
||||||
|
else if (endianSwap)
|
||||||
|
PRINT(("Instantiated foreign column ok\n"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
BViewState::BViewState()
|
BViewState::BViewState()
|
||||||
{
|
{
|
||||||
@@ -247,6 +254,7 @@ BViewState::BViewState()
|
|||||||
fStateNeedsSaving = false;
|
fStateNeedsSaving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BViewState::BViewState(BMallocIO *stream, bool endianSwap)
|
BViewState::BViewState(BMallocIO *stream, bool endianSwap)
|
||||||
{
|
{
|
||||||
stream->Read(&fViewMode, sizeof(uint32));
|
stream->Read(&fViewMode, sizeof(uint32));
|
||||||
@@ -259,7 +267,7 @@ BViewState::BViewState(BMallocIO *stream, bool endianSwap)
|
|||||||
stream->Read(&fSecondarySortType, sizeof(uint32));
|
stream->Read(&fSecondarySortType, sizeof(uint32));
|
||||||
stream->Read(&fReverseSort, sizeof(bool));
|
stream->Read(&fReverseSort, sizeof(bool));
|
||||||
stream->Read(&fIconSize, sizeof(uint32));
|
stream->Read(&fIconSize, sizeof(uint32));
|
||||||
|
|
||||||
if (endianSwap) {
|
if (endianSwap) {
|
||||||
PRINT(("endian swapping view state\n"));
|
PRINT(("endian swapping view state\n"));
|
||||||
fViewMode = B_SWAP_INT32(fViewMode);
|
fViewMode = B_SWAP_INT32(fViewMode);
|
||||||
@@ -273,15 +281,12 @@ BViewState::BViewState(BMallocIO *stream, bool endianSwap)
|
|||||||
fSecondarySortType = B_SWAP_INT32(fSecondarySortType);
|
fSecondarySortType = B_SWAP_INT32(fSecondarySortType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// assure a sane state
|
|
||||||
if (fIconSize < 16)
|
|
||||||
fIconSize = 16;
|
|
||||||
if (fIconSize > 64)
|
|
||||||
fIconSize = 64;
|
|
||||||
|
|
||||||
fStateNeedsSaving = false;
|
fStateNeedsSaving = false;
|
||||||
|
|
||||||
|
_Sanitize(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BViewState::BViewState(const BMessage &message)
|
BViewState::BViewState(const BMessage &message)
|
||||||
{
|
{
|
||||||
message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode);
|
message.FindInt32(kViewStateViewModeName, (int32 *)&fViewMode);
|
||||||
@@ -293,17 +298,12 @@ BViewState::BViewState(const BMessage &message)
|
|||||||
message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
|
message.FindInt32(kViewStateSecondarySortAttrName, (int32 *)&fSecondarySortAttr);
|
||||||
message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
|
message.FindInt32(kViewStateSecondarySortTypeName, (int32 *)&fSecondarySortType);
|
||||||
message.FindBool(kViewStateReverseSortName, &fReverseSort);
|
message.FindBool(kViewStateReverseSortName, &fReverseSort);
|
||||||
message.FindInt32(kViewStateIconSizeName, (int32 *)&fIconSize);
|
|
||||||
|
|
||||||
// assure a sane state
|
|
||||||
if (fIconSize < 16)
|
|
||||||
fIconSize = 16;
|
|
||||||
if (fIconSize > 64)
|
|
||||||
fIconSize = 64;
|
|
||||||
|
|
||||||
fStateNeedsSaving = false;
|
fStateNeedsSaving = false;
|
||||||
|
|
||||||
|
_Sanitize(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
BViewState::ArchiveToStream(BMallocIO *stream) const
|
BViewState::ArchiveToStream(BMallocIO *stream) const
|
||||||
{
|
{
|
||||||
@@ -344,14 +344,13 @@ BViewState::ArchiveToMessage(BMessage &message) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BViewState *
|
BViewState *
|
||||||
BViewState::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
BViewState::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
||||||
{
|
{
|
||||||
// compare stream header in canonical form
|
// compare stream header in canonical form
|
||||||
uint32 key = AttrHashString("BViewState", B_OBJECT_TYPE);
|
uint32 key = AttrHashString("BViewState", B_OBJECT_TYPE);
|
||||||
int32 version = kViewStateArchiveVersion;
|
int32 version = kViewStateArchiveVersion;
|
||||||
|
|
||||||
if (endianSwap) {
|
if (endianSwap) {
|
||||||
key = SwapUInt32(key);
|
key = SwapUInt32(key);
|
||||||
version = SwapInt32(version);
|
version = SwapInt32(version);
|
||||||
@@ -360,65 +359,68 @@ BViewState::InstantiateFromStream(BMallocIO *stream, bool endianSwap)
|
|||||||
if (!ValidateStream(stream, key, version))
|
if (!ValidateStream(stream, key, version))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BViewState *result = new BViewState(stream, endianSwap);
|
return _Sanitize(new (std::nothrow) BViewState(stream, endianSwap));
|
||||||
|
|
||||||
// do a sanity check here
|
|
||||||
if ((result->fViewMode != kListMode
|
|
||||||
&& result->fViewMode != kIconMode
|
|
||||||
&& result->fViewMode != kMiniIconMode
|
|
||||||
&& result->fViewMode != kScaleIconMode
|
|
||||||
&& result->fViewMode != 0)
|
|
||||||
|| (result->fLastIconMode != kListMode
|
|
||||||
&& result->fLastIconMode != kIconMode
|
|
||||||
&& result->fLastIconMode != kMiniIconMode
|
|
||||||
&& result->fLastIconMode != kScaleIconMode
|
|
||||||
&& result->fLastIconMode != 0)) {
|
|
||||||
|
|
||||||
PRINT(("Bad data instantiating ViewState, view mode %x, lastIconMode %x\n",
|
|
||||||
result->fViewMode, result->fLastIconMode));
|
|
||||||
|
|
||||||
delete result;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#if DEBUG
|
|
||||||
else if (endianSwap)
|
|
||||||
PRINT(("Instantiated foreign view state ok\n"));
|
|
||||||
#endif
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BViewState *
|
BViewState *
|
||||||
BViewState::InstantiateFromMessage(const BMessage &message)
|
BViewState::InstantiateFromMessage(const BMessage &message)
|
||||||
{
|
{
|
||||||
int32 version = kViewStateArchiveVersion;
|
int32 version = kViewStateArchiveVersion;
|
||||||
|
|
||||||
int32 messageVersion;
|
|
||||||
|
|
||||||
|
int32 messageVersion;
|
||||||
if (message.FindInt32(kViewStateVersionName, &messageVersion) != B_OK)
|
if (message.FindInt32(kViewStateVersionName, &messageVersion) != B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (version != messageVersion)
|
if (version != messageVersion)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BViewState *result = new BViewState(message);
|
return _Sanitize(new (std::nothrow) BViewState(message));
|
||||||
|
}
|
||||||
// do a sanity check here
|
|
||||||
if ((result->fViewMode != kListMode
|
|
||||||
&& result->fViewMode != kIconMode
|
|
||||||
&& result->fViewMode != kMiniIconMode
|
|
||||||
&& result->fViewMode != kScaleIconMode
|
|
||||||
&& result->fViewMode != 0)
|
|
||||||
|| (result->fLastIconMode != kListMode
|
|
||||||
&& result->fLastIconMode != kIconMode
|
|
||||||
&& result->fLastIconMode != kMiniIconMode
|
|
||||||
&& result->fLastIconMode != kScaleIconMode
|
|
||||||
&& result->fLastIconMode != 0)) {
|
|
||||||
|
|
||||||
PRINT(("Bad data instantiating ViewState, view mode %x, lastIconMode %x\n",
|
|
||||||
result->fViewMode, result->fLastIconMode));
|
|
||||||
|
|
||||||
delete result;
|
|
||||||
|
BViewState *
|
||||||
|
BViewState::_Sanitize(BViewState *state, bool fixOnly)
|
||||||
|
{
|
||||||
|
if (state == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (state->fViewMode == kListMode) {
|
||||||
|
if (state->fListOrigin.x < 0)
|
||||||
|
state->fListOrigin.x = 0;
|
||||||
|
if (state->fListOrigin.y < 0)
|
||||||
|
state->fListOrigin.y = 0;
|
||||||
|
}
|
||||||
|
if (state->fIconSize < 16)
|
||||||
|
state->fIconSize = 16;
|
||||||
|
if (state->fIconSize > 64)
|
||||||
|
state->fIconSize = 64;
|
||||||
|
|
||||||
|
if (fixOnly)
|
||||||
|
return state;
|
||||||
|
|
||||||
|
// do a sanity check here
|
||||||
|
if ((state->fViewMode != kListMode
|
||||||
|
&& state->fViewMode != kIconMode
|
||||||
|
&& state->fViewMode != kMiniIconMode
|
||||||
|
&& state->fViewMode != kScaleIconMode
|
||||||
|
&& state->fViewMode != 0)
|
||||||
|
|| (state->fLastIconMode != kListMode
|
||||||
|
&& state->fLastIconMode != kIconMode
|
||||||
|
&& state->fLastIconMode != kMiniIconMode
|
||||||
|
&& state->fLastIconMode != kScaleIconMode
|
||||||
|
&& state->fLastIconMode != 0)) {
|
||||||
|
PRINT(("Bad data instantiating ViewState, view mode %x, lastIconMode %x\n",
|
||||||
|
state->fViewMode, state->fLastIconMode));
|
||||||
|
|
||||||
|
delete state;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return result;
|
#if DEBUG
|
||||||
|
else if (endianSwap)
|
||||||
|
PRINT(("Instantiated foreign view state ok\n"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,55 +31,60 @@ of Be Incorporated in the United States and other countries. Other brand product
|
|||||||
names are registered trademarks or trademarks of their respective holders.
|
names are registered trademarks or trademarks of their respective holders.
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _VIEW_STATE_H
|
#ifndef _VIEW_STATE_H
|
||||||
#define _VIEW_STATE_H
|
#define _VIEW_STATE_H
|
||||||
|
|
||||||
|
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
const int32 kColumnStateArchiveVersion = 21;
|
const int32 kColumnStateArchiveVersion = 21;
|
||||||
// bump version when layout or size changes
|
// bump version when layout or size changes
|
||||||
|
|
||||||
class BColumn {
|
class BColumn {
|
||||||
public:
|
public:
|
||||||
BColumn(const char *title, float offset, float width,
|
BColumn(const char *title, float offset, float width,
|
||||||
alignment, const char *attributeName, uint32 attr_type,
|
alignment align, const char *attributeName, uint32 attrType,
|
||||||
bool stat_field, bool editable);
|
bool statField, bool editable);
|
||||||
~BColumn();
|
~BColumn();
|
||||||
|
|
||||||
BColumn(BMallocIO *stream, bool endianSwap = false);
|
BColumn(BMallocIO *stream, bool endianSwap = false);
|
||||||
BColumn(const BMessage &, int32 index = 0);
|
BColumn(const BMessage &, int32 index = 0);
|
||||||
static BColumn *InstantiateFromStream(BMallocIO *stream, bool endianSwap = false);
|
static BColumn *InstantiateFromStream(BMallocIO *stream,
|
||||||
static BColumn *InstantiateFromMessage(const BMessage &, int32 index = 0);
|
bool endianSwap = false);
|
||||||
void ArchiveToStream(BMallocIO *stream) const;
|
static BColumn *InstantiateFromMessage(const BMessage &archive,
|
||||||
void ArchiveToMessage(BMessage &) const;
|
int32 index = 0);
|
||||||
|
void ArchiveToStream(BMallocIO *stream) const;
|
||||||
|
void ArchiveToMessage(BMessage &) const;
|
||||||
|
|
||||||
const char *Title() const;
|
const char *Title() const;
|
||||||
float Offset() const;
|
float Offset() const;
|
||||||
float Width() const;
|
float Width() const;
|
||||||
alignment Alignment() const;
|
alignment Alignment() const;
|
||||||
const char *AttrName() const;
|
const char *AttrName() const;
|
||||||
uint32 AttrType() const;
|
uint32 AttrType() const;
|
||||||
uint32 AttrHash() const;
|
uint32 AttrHash() const;
|
||||||
bool StatField() const;
|
bool StatField() const;
|
||||||
bool Editable() const;
|
bool Editable() const;
|
||||||
|
|
||||||
void SetOffset(float);
|
|
||||||
void SetWidth(float);
|
|
||||||
|
|
||||||
private:
|
void SetOffset(float);
|
||||||
BString fTitle;
|
void SetWidth(float);
|
||||||
float fOffset;
|
|
||||||
float fWidth;
|
private:
|
||||||
alignment fAlignment;
|
static BColumn *_Sanitize(BColumn *column);
|
||||||
BString fAttrName;
|
|
||||||
uint32 fAttrHash;
|
BString fTitle;
|
||||||
uint32 fAttrType;
|
float fOffset;
|
||||||
bool fStatField;
|
float fWidth;
|
||||||
bool fEditable;
|
alignment fAlignment;
|
||||||
|
BString fAttrName;
|
||||||
|
uint32 fAttrHash;
|
||||||
|
uint32 fAttrType;
|
||||||
|
bool fStatField;
|
||||||
|
bool fEditable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -88,54 +93,57 @@ const int32 kViewStateArchiveVersion = 10;
|
|||||||
|
|
||||||
class BViewState {
|
class BViewState {
|
||||||
public:
|
public:
|
||||||
BViewState();
|
BViewState();
|
||||||
|
|
||||||
BViewState(BMallocIO *stream, bool endianSwap = false);
|
|
||||||
BViewState(const BMessage &message);
|
|
||||||
static BViewState *InstantiateFromStream(BMallocIO *stream, bool endianSwap = false);
|
|
||||||
static BViewState *InstantiateFromMessage(const BMessage &message);
|
|
||||||
void ArchiveToStream(BMallocIO *stream) const;
|
|
||||||
void ArchiveToMessage(BMessage &message) const;
|
|
||||||
|
|
||||||
uint32 ViewMode() const;
|
BViewState(BMallocIO *stream, bool endianSwap = false);
|
||||||
uint32 LastIconMode() const;
|
BViewState(const BMessage &message);
|
||||||
uint32 IconSize() const;
|
static BViewState *InstantiateFromStream(BMallocIO *stream, bool endianSwap = false);
|
||||||
BPoint ListOrigin() const;
|
static BViewState *InstantiateFromMessage(const BMessage &message);
|
||||||
BPoint IconOrigin() const;
|
void ArchiveToStream(BMallocIO *stream) const;
|
||||||
uint32 PrimarySort() const;
|
void ArchiveToMessage(BMessage &message) const;
|
||||||
uint32 SecondarySort() const;
|
|
||||||
uint32 PrimarySortType() const;
|
|
||||||
uint32 SecondarySortType() const;
|
|
||||||
bool ReverseSort() const;
|
|
||||||
|
|
||||||
void SetViewMode(uint32);
|
|
||||||
void SetLastIconMode(uint32);
|
|
||||||
void SetIconSize(uint32);
|
|
||||||
void SetListOrigin(BPoint);
|
|
||||||
void SetIconOrigin(BPoint);
|
|
||||||
void SetPrimarySort(uint32);
|
|
||||||
void SetSecondarySort(uint32);
|
|
||||||
void SetPrimarySortType(uint32);
|
|
||||||
void SetSecondarySortType(uint32);
|
|
||||||
void SetReverseSort(bool);
|
|
||||||
|
|
||||||
bool StateNeedsSaving();
|
|
||||||
void MarkSaved();
|
|
||||||
|
|
||||||
private:
|
uint32 ViewMode() const;
|
||||||
uint32 fViewMode;
|
uint32 LastIconMode() const;
|
||||||
uint32 fLastIconMode;
|
uint32 IconSize() const;
|
||||||
uint32 fIconSize;
|
BPoint ListOrigin() const;
|
||||||
BPoint fListOrigin;
|
BPoint IconOrigin() const;
|
||||||
BPoint fIconOrigin;
|
uint32 PrimarySort() const;
|
||||||
uint32 fPrimarySortAttr;
|
uint32 SecondarySort() const;
|
||||||
uint32 fSecondarySortAttr;
|
uint32 PrimarySortType() const;
|
||||||
uint32 fPrimarySortType;
|
uint32 SecondarySortType() const;
|
||||||
uint32 fSecondarySortType;
|
bool ReverseSort() const;
|
||||||
bool fReverseSort;
|
|
||||||
bool fStateNeedsSaving;
|
void SetViewMode(uint32);
|
||||||
|
void SetLastIconMode(uint32);
|
||||||
|
void SetIconSize(uint32);
|
||||||
|
void SetListOrigin(BPoint);
|
||||||
|
void SetIconOrigin(BPoint);
|
||||||
|
void SetPrimarySort(uint32);
|
||||||
|
void SetSecondarySort(uint32);
|
||||||
|
void SetPrimarySortType(uint32);
|
||||||
|
void SetSecondarySortType(uint32);
|
||||||
|
void SetReverseSort(bool);
|
||||||
|
|
||||||
|
bool StateNeedsSaving();
|
||||||
|
void MarkSaved();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static BViewState *_Sanitize(BViewState *state, bool fixOnly = false);
|
||||||
|
|
||||||
|
uint32 fViewMode;
|
||||||
|
uint32 fLastIconMode;
|
||||||
|
uint32 fIconSize;
|
||||||
|
BPoint fListOrigin;
|
||||||
|
BPoint fIconOrigin;
|
||||||
|
uint32 fPrimarySortAttr;
|
||||||
|
uint32 fSecondarySortAttr;
|
||||||
|
uint32 fPrimarySortType;
|
||||||
|
uint32 fSecondarySortType;
|
||||||
|
bool fReverseSort;
|
||||||
|
bool fStateNeedsSaving;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline const char *
|
inline const char *
|
||||||
BColumn::Title() const
|
BColumn::Title() const
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user