Header indentation and *-style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29835 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-03-31 19:02:04 +00:00
parent f03b0a18cc
commit 6104360c70
+224 -202
View File
@@ -69,31 +69,31 @@ class BColumn;
class BColumnListView; class BColumnListView;
enum LatchType { enum LatchType {
B_NO_LATCH, B_NO_LATCH = 0,
B_OPEN_LATCH, B_OPEN_LATCH = 1,
B_PRESSED_LATCH, B_PRESSED_LATCH = 2,
B_CLOSED_LATCH B_CLOSED_LATCH = 3
}; };
typedef enum { typedef enum {
B_ALLOW_COLUMN_NONE = 0, B_ALLOW_COLUMN_NONE = 0,
B_ALLOW_COLUMN_MOVE = 1, B_ALLOW_COLUMN_MOVE = 1,
B_ALLOW_COLUMN_RESIZE = 2, B_ALLOW_COLUMN_RESIZE = 2,
B_ALLOW_COLUMN_POPUP = 4, B_ALLOW_COLUMN_POPUP = 4,
B_ALLOW_COLUMN_REMOVE = 8, B_ALLOW_COLUMN_REMOVE = 8
} column_flags; } column_flags;
enum ColumnListViewColor { enum ColumnListViewColor {
B_COLOR_BACKGROUND = 0, B_COLOR_BACKGROUND = 0,
B_COLOR_TEXT = 1, B_COLOR_TEXT = 1,
B_COLOR_ROW_DIVIDER = 2, B_COLOR_ROW_DIVIDER = 2,
B_COLOR_SELECTION = 3, B_COLOR_SELECTION = 3,
B_COLOR_SELECTION_TEXT = 4, B_COLOR_SELECTION_TEXT = 4,
B_COLOR_NON_FOCUS_SELECTION = 5, B_COLOR_NON_FOCUS_SELECTION = 5,
B_COLOR_EDIT_BACKGROUND = 6, B_COLOR_EDIT_BACKGROUND = 6,
B_COLOR_EDIT_TEXT = 7, B_COLOR_EDIT_TEXT = 7,
B_COLOR_HEADER_BACKGROUND = 8, B_COLOR_HEADER_BACKGROUND = 8,
B_COLOR_HEADER_TEXT = 9, B_COLOR_HEADER_TEXT = 9,
B_COLOR_SEPARATOR_LINE = 10, B_COLOR_SEPARATOR_LINE = 10,
B_COLOR_SEPARATOR_BORDER = 11, B_COLOR_SEPARATOR_BORDER = 11,
@@ -101,18 +101,18 @@ enum ColumnListViewColor {
}; };
enum ColumnListViewFont { enum ColumnListViewFont {
B_FONT_ROW = 0, B_FONT_ROW = 0,
B_FONT_HEADER = 1, B_FONT_HEADER = 1,
B_FONT_TOTAL = 2 B_FONT_TOTAL = 2
}; };
// A single row/column intersection in the list. // A single row/column intersection in the list.
class BField { class BField {
public: public:
BField(); BField();
virtual ~BField(); virtual ~BField();
}; };
// A single line in the list. Each line contains a BField object // A single line in the list. Each line contains a BField object
@@ -121,32 +121,34 @@ public:
// a parent of a row, using the AddRow() function in BColumnListView(). // a parent of a row, using the AddRow() function in BColumnListView().
class BRow { class BRow {
public: public:
BRow(float height = 16.0); BRow(float height = 16.0);
virtual ~BRow(); virtual ~BRow();
virtual bool HasLatch() const; virtual bool HasLatch() const;
int32 CountFields() const; int32 CountFields() const;
BField* GetField(int32 logicalFieldIndex); BField* GetField(int32 logicalFieldIndex);
const BField* GetField(int32 logicalFieldIndex) const; const BField* GetField(int32 logicalFieldIndex) const;
void SetField(BField* field, int32 logicalFieldIndex); void SetField(BField* field,
int32 logicalFieldIndex);
float Height() const; float Height() const;
bool IsExpanded() const; bool IsExpanded() const;
private: private:
// Blows up into the debugger if the validation fails. // Blows up into the debugger if the validation fails.
void ValidateFields() const; void ValidateFields() const;
void ValidateField(const BField *field, int32 logicalFieldIndex) const; void ValidateField(const BField* field,
int32 logicalFieldIndex) const;
private: private:
BList fFields; BList fFields;
BPrivate:: BPrivate::
BRowContainer* fChildList; BRowContainer* fChildList;
bool fIsExpanded; bool fIsExpanded;
float fHeight; float fHeight;
BRow* fNextSelected; BRow* fNextSelected;
BRow* fPrevSelected; BRow* fPrevSelected;
BRow* fParent; BRow* fParent;
BColumnListView* fList; BColumnListView* fList;
friend class BColumnListView; friend class BColumnListView;
@@ -158,211 +160,231 @@ private:
// how to display the BField objects that occur at its location in // how to display the BField objects that occur at its location in
// each of the list's rows. See ColumnTypes.h for particular // each of the list's rows. See ColumnTypes.h for particular
// subclasses of BField and BColumn that handle common data types. // subclasses of BField and BColumn that handle common data types.
class BColumn class BColumn {
{
public: public:
BColumn(float width, BColumn(float width, float minWidth,
float minWidth, float maxWidth,
float maxWidth, alignment align = B_ALIGN_LEFT);
alignment align = B_ALIGN_LEFT); virtual ~BColumn();
virtual ~BColumn();
float Width() const; float Width() const;
void SetWidth(float width); void SetWidth(float width);
float MinWidth() const; float MinWidth() const;
float MaxWidth() const; float MaxWidth() const;
virtual void DrawTitle(BRect rect, BView *targetView); virtual void DrawTitle(BRect rect, BView* targetView);
virtual void DrawField(BField *field, BRect rect, BView *targetView); virtual void DrawField(BField* field, BRect rect,
virtual int CompareFields(BField *field1, BField *field2); BView* targetView);
virtual int CompareFields(BField* field1, BField* field2);
virtual void MouseMoved(BColumnListView *parent, BRow *row, BField *field, virtual void MouseMoved(BColumnListView* parent, BRow* row,
BRect field_rect, BPoint point, uint32 buttons, int32 code); BField* field, BRect fieldRect,
virtual void MouseDown(BColumnListView *parent, BRow *row, BField *field, BPoint point, uint32 buttons, int32 code);
BRect field_rect, BPoint point, uint32 buttons); virtual void MouseDown(BColumnListView* parent, BRow* row,
virtual void MouseUp(BColumnListView *parent, BRow *row, BField *field); BField* field, BRect fieldRect,
BPoint point, uint32 buttons);
virtual void MouseUp(BColumnListView* parent, BRow* row,
BField* field);
virtual void GetColumnName(BString* into) const; virtual void GetColumnName(BString* into) const;
virtual float GetPreferredWidth(BField *field, BView *parent) const; virtual float GetPreferredWidth(BField* field,
BView* parent) const;
bool IsVisible() const; bool IsVisible() const;
void SetVisible(bool); void SetVisible(bool);
bool WantsEvents() const; bool WantsEvents() const;
void SetWantsEvents(bool); void SetWantsEvents(bool);
bool ShowHeading() const; bool ShowHeading() const;
void SetShowHeading(bool); void SetShowHeading(bool);
alignment Alignment() const; alignment Alignment() const;
void SetAlignment(alignment); void SetAlignment(alignment);
int32 LogicalFieldNum() const; int32 LogicalFieldNum() const;
/*! /*!
\param field The BField derivative to validate. \param field The BField derivative to validate.
Implement this function on your BColumn derivatives to validate BField derivatives Implement this function on your BColumn derivatives to validate
that your BColumn will be drawing/manipulating. BField derivatives that your BColumn will be drawing/manipulating.
This function will be called when BFields are added to the Column, use dynamic_cast<> to This function will be called when BFields are added to the Column,
determine if it is of a kind that your BColumn know how ot handle. return false if it is not. use dynamic_cast<> to determine if it is of a kind that your
BColumn know how ot handle. return false if it is not.
\note The debugger will be called if you return false from here with information about
what type of BField and BColumn and the logical field index where it occured. \note The debugger will be called if you return false from here
with information about what type of BField and BColumn and the
\note Do not call the inherited version of this, it just returns true; logical field index where it occured.
\note Do not call the inherited version of this, it just returns
true;
*/ */
virtual bool AcceptsField(const BField* field) const; virtual bool AcceptsField(const BField* field) const;
private: private:
float fWidth; float fWidth;
float fMinWidth; float fMinWidth;
float fMaxWidth; float fMaxWidth;
bool fVisible; bool fVisible;
int32 fFieldID; int32 fFieldID;
BColumnListView *fList; BColumnListView* fList;
bool fSortAscending; bool fSortAscending;
bool fWantsEvents; bool fWantsEvents;
bool fShowHeading; bool fShowHeading;
alignment fAlignment; alignment fAlignment;
friend class BPrivate::OutlineView; friend class BPrivate::OutlineView;
friend class BColumnListView; friend class BColumnListView;
friend class BPrivate::TitleView; friend class BPrivate::TitleView;
}; };
// The column list view class. // The column list view class.
class BColumnListView : public BView, public BInvoker class BColumnListView : public BView, public BInvoker {
{
public: public:
BColumnListView(BRect rect, BColumnListView(BRect rect,
const char *name, const char* name,
uint32 resizingMode, uint32 resizingMode,
uint32 drawFlags, uint32 drawFlags,
border_style = B_NO_BORDER, border_style = B_NO_BORDER,
bool showHorizontalScrollbar = true); bool showHorizontalScrollbar = true);
virtual ~BColumnListView(); virtual ~BColumnListView();
// Interaction // Interaction
virtual bool InitiateDrag(BPoint, bool wasSelected); virtual bool InitiateDrag(BPoint, bool wasSelected);
virtual void MessageDropped(BMessage*, BPoint point); virtual void MessageDropped(BMessage*, BPoint point);
virtual void ExpandOrCollapse(BRow *row, bool expand); virtual void ExpandOrCollapse(BRow* row, bool expand);
virtual status_t Invoke(BMessage *message = NULL); virtual status_t Invoke(BMessage* message = NULL);
virtual void ItemInvoked(); virtual void ItemInvoked();
virtual void SetInvocationMessage(BMessage*); virtual void SetInvocationMessage(BMessage* message);
BMessage* InvocationMessage() const; BMessage* InvocationMessage() const;
uint32 InvocationCommand() const; uint32 InvocationCommand() const;
BRow* FocusRow() const; BRow* FocusRow() const;
void SetFocusRow(int32 index, bool select=false); void SetFocusRow(int32 index, bool select = false);
void SetFocusRow(BRow *row, bool select=false); void SetFocusRow(BRow* row, bool select = false);
void SetMouseTrackingEnabled(bool); void SetMouseTrackingEnabled(bool);
// Selection // Selection
list_view_type SelectionMode() const; list_view_type SelectionMode() const;
void Deselect(BRow *row); void Deselect(BRow* row);
void AddToSelection(BRow *row); void AddToSelection(BRow* row);
void DeselectAll(); void DeselectAll();
BRow* CurrentSelection(BRow *lastSelected = 0) const; BRow* CurrentSelection(BRow* lastSelected = 0) const;
virtual void SelectionChanged(); virtual void SelectionChanged();
virtual void SetSelectionMessage(BMessage *); virtual void SetSelectionMessage(BMessage* message);
BMessage* SelectionMessage(); BMessage* SelectionMessage();
uint32 SelectionCommand() const; uint32 SelectionCommand() const;
void SetSelectionMode(list_view_type); // list_view_type is defined in ListView.h. void SetSelectionMode(list_view_type type);
// list_view_type is defined in ListView.h.
// Sorting // Sorting
void SetSortingEnabled(bool); void SetSortingEnabled(bool);
bool SortingEnabled() const; bool SortingEnabled() const;
void SetSortColumn(BColumn *column, bool add, bool ascending); void SetSortColumn(BColumn* column, bool add,
void ClearSortColumns(); bool ascending);
void ClearSortColumns();
// The status view is a little area in the lower left hand corner. // The status view is a little area in the lower left hand corner.
void AddStatusView(BView *view); void AddStatusView(BView* view);
BView* RemoveStatusView(); BView* RemoveStatusView();
// Column Manipulation // Column Manipulation
void AddColumn(BColumn*, int32 logicalFieldIndex); void AddColumn(BColumn* column,
void MoveColumn(BColumn*, int32 index); int32 logicalFieldIndex);
void RemoveColumn(BColumn*); void MoveColumn(BColumn* column, int32 index);
int32 CountColumns() const; void RemoveColumn(BColumn* column);
BColumn* ColumnAt(int32 index) const; int32 CountColumns() const;
void SetColumnVisible(BColumn*, bool isVisible); BColumn* ColumnAt(int32 index) const;
void SetColumnVisible(int32, bool); void SetColumnVisible(BColumn* column,
bool IsColumnVisible(int32) const; bool isVisible);
void SetColumnFlags(column_flags flags); void SetColumnVisible(int32, bool);
bool IsColumnVisible(int32) const;
void SetColumnFlags(column_flags flags);
// Row manipulation // Row manipulation
const BRow* RowAt(int32 index, BRow *parent = 0) const; const BRow* RowAt(int32 index, BRow *parent = 0) const;
BRow* RowAt(int32 index, BRow *parent = 0); BRow* RowAt(int32 index, BRow *parent = 0);
const BRow* RowAt(BPoint) const; const BRow* RowAt(BPoint) const;
BRow* RowAt(BPoint); BRow* RowAt(BPoint);
bool GetRowRect(const BRow *row, BRect *outRect) const; bool GetRowRect(const BRow* row, BRect* _rect) const;
bool FindParent(BRow *row, BRow **outs_parent, bool *out_isVisible) const; bool FindParent(BRow* row, BRow** _parent,
int32 IndexOf(BRow *row); bool *_isVisible) const;
int32 CountRows(BRow *parent = 0) const; int32 IndexOf(BRow* row);
void AddRow(BRow*, BRow *parent = 0); int32 CountRows(BRow* parent = 0) const;
void AddRow(BRow*, int32 index, BRow *parent = 0); void AddRow(BRow* row, BRow* parent = NULL);
void AddRow(BRow* row, int32 index,
void ScrollTo(const BRow* Row); BRow* parent = NULL);
void ScrollTo(BPoint point);
void ScrollTo(const BRow* Row);
void ScrollTo(BPoint point);
// Does not delete row or children at this time. // Does not delete row or children at this time.
// todo: Make delete row and children // todo: Make delete row and children
void RemoveRow(BRow*); void RemoveRow(BRow* row);
void UpdateRow(BRow*); void UpdateRow(BRow* row);
void Clear(); void Clear();
// Appearance (DEPRECATED) // Appearance (DEPRECATED)
void GetFont(BFont* font) const {BView::GetFont(font);} void GetFont(BFont* font) const
virtual void SetFont(const BFont *font, uint32 mask = B_FONT_ALL); { BView::GetFont(font); }
virtual void SetHighColor(rgb_color); virtual void SetFont(const BFont* font,
void SetSelectionColor(rgb_color); uint32 mask = B_FONT_ALL);
void SetBackgroundColor(rgb_color); virtual void SetHighColor(rgb_color);
void SetEditColor(rgb_color); void SetSelectionColor(rgb_color);
const rgb_color SelectionColor() const; void SetBackgroundColor(rgb_color);
const rgb_color BackgroundColor() const; void SetEditColor(rgb_color);
const rgb_color EditColor() const; const rgb_color SelectionColor() const;
const rgb_color BackgroundColor() const;
const rgb_color EditColor() const;
// Appearance (NEW STYLE) // Appearance (NEW STYLE)
void SetColor(ColumnListViewColor color_num, rgb_color color); void SetColor(ColumnListViewColor colorIndex,
void SetFont(ColumnListViewFont font_num, const BFont* font, uint32 mask = B_FONT_ALL); rgb_color color);
rgb_color Color(ColumnListViewColor color_num) const; void SetFont(ColumnListViewFont fontIndex,
void GetFont(ColumnListViewFont font_num, BFont* font) const; const BFont* font,
uint32 mask = B_FONT_ALL);
rgb_color Color(ColumnListViewColor colorIndex) const;
void GetFont(ColumnListViewFont fontIndex,
BFont* font) const;
BPoint SuggestTextPosition(const BRow* row, const BColumn* column=NULL) const; BPoint SuggestTextPosition(const BRow* row,
const BColumn* column = NULL) const;
void SetLatchWidth(float width); void SetLatchWidth(float width);
float LatchWidth() const; float LatchWidth() const;
virtual void DrawLatch(BView*, BRect, LatchType, BRow*); virtual void DrawLatch(BView* view, BRect frame,
virtual void MakeFocus(bool isfocus = true); LatchType type, BRow* row);
void SaveState(BMessage *msg); virtual void MakeFocus(bool isfocus = true);
void LoadState(BMessage *msg); void SaveState(BMessage* archive);
void LoadState(BMessage* archive);
BView* ScrollView() const { return (BView *)fOutlineView; } BView* ScrollView() const
void SetEditMode(bool state); { return (BView*)fOutlineView; }
void Refresh(); void SetEditMode(bool state);
void Refresh();
protected: protected:
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage* message);
virtual void KeyDown(const char *bytes, int32 numBytes); virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
virtual void WindowActivated(bool active); virtual void WindowActivated(bool active);
virtual void Draw(BRect); virtual void Draw(BRect updateRect);
private: private:
rgb_color fColorList[B_COLOR_TOTAL]; rgb_color fColorList[B_COLOR_TOTAL];
BPrivate::TitleView* fTitleView; BPrivate::TitleView* fTitleView;
BPrivate::OutlineView* fOutlineView; BPrivate::OutlineView* fOutlineView;
BList fColumns; BList fColumns;
BScrollBar* fHorizontalScrollBar; BScrollBar* fHorizontalScrollBar;
BScrollBar* fVerticalScrollBar; BScrollBar* fVerticalScrollBar;
BList fSortColumns; BList fSortColumns;
BView* fStatusView; BView* fStatusView;
BMessage* fSelectionMessage; BMessage* fSelectionMessage;
bool fSortingEnabled; bool fSortingEnabled;
float fLatchWidth; float fLatchWidth;
border_style fBorderStyle; border_style fBorderStyle;
}; };
#endif #endif // _COLUMN_LIST_VIEW_H