From: <ane...@us...> - 2013-07-28 14:21:31
|
Revision: 945 http://sourceforge.net/p/vision/code/945 Author: anevilyak Date: 2013-07-28 14:21:27 +0000 (Sun, 28 Jul 2013) Log Message: ----------- - Update to latest Haiku version of BColumnListView. - 64-bit fixes. Modified Paths: -------------- branches/0.9.7/Makefile branches/0.9.7/src/ChannelAgent.h branches/0.9.7/src/ClientAgentInputFilter.cpp branches/0.9.7/src/ColorSelector.cpp branches/0.9.7/src/ColumnListView.cpp branches/0.9.7/src/ColumnListView.h branches/0.9.7/src/ColumnTypes.cpp branches/0.9.7/src/ColumnTypes.h branches/0.9.7/src/NamesView.cpp branches/0.9.7/src/NetPrefsServerView.cpp branches/0.9.7/src/NetworkMenu.cpp branches/0.9.7/src/NetworkPrefsView.cpp branches/0.9.7/src/NotifyList.cpp branches/0.9.7/src/PrefGeneral.cpp branches/0.9.7/src/ServerAgent.cpp branches/0.9.7/src/ServerAgent.h branches/0.9.7/src/StatusView.cpp branches/0.9.7/src/Vision.cpp branches/0.9.7/src/WindowList.cpp Added Paths: ----------- branches/0.9.7/src/ObjectListPrivate.h Removed Paths: ------------- branches/0.9.7/src/ObjectList.h Modified: branches/0.9.7/Makefile =================================================================== --- branches/0.9.7/Makefile 2013-06-05 00:25:23 UTC (rev 944) +++ branches/0.9.7/Makefile 2013-07-28 14:21:27 UTC (rev 945) @@ -16,7 +16,7 @@ # the file name, ... BINARY := Vision -VERSION := 0.9.7-H-130604 +VERSION := 0.9.7-H-280704 BUILDDATE := $(shell date +%b_%d_%Y) BUILD_TYPE := Release @@ -69,9 +69,8 @@ CFLAGS += -DBEOS_BUILD CFLAGS += -DBUILD_DATE=\"$(BUILDDATE)\" -CFLAGS += -fno-pic +CFLAGS += -fPIC CFLAGS += -ffast-math -CFLAGS += -march=pentium -mcpu=pentiumpro CFLAGS += -Wall -W -Wno-multichar -Wpointer-arith CFLAGS += -Wwrite-strings -Woverloaded-virtual CFLAGS += -Wconversion -Wpointer-arith Modified: branches/0.9.7/src/ChannelAgent.h =================================================================== --- branches/0.9.7/src/ChannelAgent.h 2013-06-05 00:25:23 UTC (rev 944) +++ branches/0.9.7/src/ChannelAgent.h 2013-07-28 14:21:27 UTC (rev 945) @@ -29,7 +29,7 @@ #include <Rect.h> #include <String.h> #include "ClientAgent.h" -#include "ObjectList.h" +#include <ObjectList.h> class ChannelOptions; class BScrollView; Modified: branches/0.9.7/src/ClientAgentInputFilter.cpp =================================================================== --- branches/0.9.7/src/ClientAgentInputFilter.cpp 2013-06-05 00:25:23 UTC (rev 944) +++ branches/0.9.7/src/ClientAgentInputFilter.cpp 2013-07-28 14:21:27 UTC (rev 945) @@ -165,7 +165,7 @@ // we have our own pasting code so we can catch multiple lines BClipboard clipboard ("system"); const char *fText; - int32 textLen; + ssize_t textLen; BMessage *clip ((BMessage *)NULL); if (clipboard.Lock()) Modified: branches/0.9.7/src/ColorSelector.cpp =================================================================== --- branches/0.9.7/src/ColorSelector.cpp 2013-06-05 00:25:23 UTC (rev 944) +++ branches/0.9.7/src/ColorSelector.cpp 2013-07-28 14:21:27 UTC (rev 945) @@ -243,7 +243,7 @@ fColorPalette->SetDoubleBuffering (B_UPDATE_INVALIDATED | B_UPDATE_RESIZED | B_UPDATE_EXPOSED); #else rgb_color *color (NULL); - int32 size (0); + ssize_t size (0); fColors.FindData ("color", B_RGB_COLOR_TYPE, 0, (const void **)(&color), &size); swatch = new ColorSwatch (dummyRect, "swatch", *color); AddChild (swatch); @@ -332,7 +332,7 @@ { if (msg->WasDropped()) { rgb_color *color; - int32 size; + ssize_t size; if (msg->FindData ("RGBColor", B_RGB_COLOR_TYPE, (const void **)&color, &size) == B_OK) { if (fColorPalette) { @@ -352,7 +352,7 @@ case CMD_CHOOSE_UI_COLOR: { const char* field; int32 index (0); - int32 size; + ssize_t size; if (msg->FindString("field", &field) == B_OK) { msg->FindInt32 ("index", &index); fCurrentField = field; @@ -449,7 +449,7 @@ void ColorSelector::Update(const BMessage& changes) { int32 index (0); - int32 size (0); + ssize_t size (0); rgb_color *color; changes.FindInt32 ("index", &index); changes.FindData ("color", B_RGB_COLOR_TYPE, (const void **)(&color), &size); @@ -477,7 +477,7 @@ BMessage OriginalColors = fInitColors; SetTo (OriginalColors); rgb_color *color; - int32 size (0); + ssize_t size (0); for (int32 i = 0; i < MAX_COLORS; i++) if (fInitColors.FindData ("color", B_RGB_COLOR_TYPE, i, (const void **)(&color), &size) == B_OK) Modified: branches/0.9.7/src/ColumnListView.cpp =================================================================== --- branches/0.9.7/src/ColumnListView.cpp 2013-06-05 00:25:23 UTC (rev 944) +++ branches/0.9.7/src/ColumnListView.cpp 2013-07-28 14:21:27 UTC (rev 945) @@ -43,6 +43,8 @@ / *******************************************************************************/ +#include "ColumnListView.h" + #include <typeinfo> #include <stdio.h> @@ -50,85 +52,33 @@ #include <Application.h> #include <Bitmap.h> +#include <ControlLook.h> #include <Cursor.h> #include <Debug.h> #include <GraphicsDefs.h> +#include <LayoutUtils.h> #include <MenuItem.h> #include <PopUpMenu.h> #include <Region.h> #include <ScrollBar.h> #include <String.h> +#include <SupportDefs.h> #include <Window.h> +#include "ObjectListPrivate.h" + +#include "ColorTools.h" #include "ObjectList.h" -#include "ColumnListView.h" -#include "ColorTools.h" -/* -#ifndef _ARCHIVE_DEFS_H -#include <archive_defs.h> -#endif -*/ + #define DOUBLE_BUFFERED_COLUMN_RESIZE 1 #define SMART_REDRAW 1 #define DRAG_TITLE_OUTLINE 1 #define CONSTRAIN_CLIPPING_REGION 1 -#define LOWER_SCROLLBAR 1 +#define LOWER_SCROLLBAR 0 namespace BPrivate { -static const unsigned char kResizeCursorData[] = { - 16, 1, 8, 8, - 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, - 0x1a, 0x58, 0x2a, 0x54, 0x4a, 0x52, 0x8a, 0x51, - 0x8a, 0x51, 0x4a, 0x52, 0x2a, 0x54, 0x1a, 0x58, - 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, - - 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, - 0x1b, 0xd8, 0x3b, 0xdc, 0x7b, 0xde, 0xfb, 0xdf, - 0xfb, 0xdf, 0x7b, 0xde, 0x3b, 0xdc, 0x1b, 0xd8, - 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 -}; - -static const unsigned char kMaxResizeCursorData[] = { - 16, 1, 8, 8, - 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, - 0x1a, 0x40, 0x2a, 0x40, 0x4a, 0x40, 0x8a, 0x40, - 0x8a, 0x40, 0x4a, 0x40, 0x2a, 0x40, 0x1a, 0x40, - 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, - - 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, - 0x1b, 0xc0, 0x3b, 0xc0, 0x7b, 0xc0, 0xfb, 0xc0, - 0xfb, 0xc0, 0x7b, 0xc0, 0x3b, 0xc0, 0x1b, 0xc0, - 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 -}; - -static const unsigned char kMinResizeCursorData[] = { - 16, 1, 8, 8, - 0x03, 0xc0, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, - 0x02, 0x58, 0x02, 0x54, 0x02, 0x52, 0x02, 0x51, - 0x02, 0x51, 0x02, 0x52, 0x02, 0x54, 0x02, 0x58, - 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x03, 0xc0, - - 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, - 0x03, 0xd8, 0x03, 0xdc, 0x03, 0xde, 0x03, 0xdf, - 0x03, 0xdf, 0x03, 0xde, 0x03, 0xdc, 0x03, 0xd8, - 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0 -}; - -static const unsigned char kColumnMoveCursorData[] = { - 16, 1, 8, 8, - 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, - 0x1e, 0x78, 0x2a, 0x54, 0x4e, 0x72, 0x80, 0x01, - 0x80, 0x01, 0x4e, 0x72, 0x2a, 0x54, 0x1e, 0x78, - 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, - - 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, - 0x1f, 0xf8, 0x3b, 0xdc, 0x7f, 0xfe, 0xff, 0xff, - 0xff, 0xff, 0x7f, 0xfe, 0x3b, 0xdc, 0x1f, 0xf8, - 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80 -}; - -static const unsigned char kUpSortArrow8x8[] = { +static const unsigned char kDownSortArrow8x8[] = { 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, @@ -139,7 +89,7 @@ 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff }; -static const unsigned char kDownSortArrow8x8[] = { +static const unsigned char kUpSortArrow8x8[] = { 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, @@ -150,7 +100,7 @@ 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff }; -static const unsigned char kUpSortArrow8x8Invert[] = { +static const unsigned char kDownSortArrow8x8Invert[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -161,7 +111,7 @@ 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff }; -static const unsigned char kDownSortArrow8x8Invert[] = { +static const unsigned char kUpSortArrow8x8Invert[] = { 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x1f, 0x1f, 0xff, 0xff, 0xff, @@ -172,15 +122,15 @@ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; -static const float kTintedLineTint = 0.7 * B_NO_TINT + 0.3 * B_DARKEN_1_TINT; +static const float kTintedLineTint = 1.04; -static const float kTitleHeight = 17.0; +static const float kTitleHeight = 16.0; static const float kLatchWidth = 15.0; static const rgb_color kColor[B_COLOR_TOTAL] = { - {236, 236, 236, 255}, // B_COLOR_BACKGROUND + {255, 255, 255, 255}, // B_COLOR_BACKGROUND { 0, 0, 0, 255}, // B_COLOR_TEXT {148, 148, 148, 255}, // B_COLOR_ROW_DIVIDER {190, 190, 190, 255}, // B_COLOR_SELECTION @@ -196,7 +146,7 @@ static const int32 kMaxDepth = 1024; static const float kLeftMargin = kLatchWidth; -static const float kRightMargin = kLatchWidth; +static const float kRightMargin = 8; static const float kOutlineLevelIndent = kLatchWidth; static const float kColumnResizeAreaWidth = 10.0; static const float kRowDragSensitivity = 5.0; @@ -211,352 +161,408 @@ }; class TitleView : public BView { + typedef BView _inherited; public: - TitleView(BRect, OutlineView*, BList *visibleColumns, BList *sortColumns, - BColumnListView *masterView, uint32 resizingMode); - ~TitleView(); - void ColumnAdded(BColumn*); - void SetColumnVisible(BColumn*, bool); + TitleView(BRect frame, OutlineView* outlineView, + BList* visibleColumns, BList* sortColumns, + BColumnListView* masterView, + uint32 resizingMode); + virtual ~TitleView(); - virtual void Draw(BRect rect); - virtual void ScrollTo(BPoint); - virtual void MessageReceived(BMessage*); - virtual void MouseDown(BPoint); - virtual void MouseMoved(BPoint, uint32, const BMessage*); - virtual void MouseUp(BPoint position); - virtual void FrameResized(float width, float height); - - void MoveColumn(BColumn *column, int32 index); - void SetColumnFlags(column_flags flags); + void ColumnAdded(BColumn* column); + void ColumnResized(BColumn* column, float oldWidth); + void SetColumnVisible(BColumn* column, bool visible); - void SetEditMode(bool state) { fEditMode = state; } + virtual void Draw(BRect updateRect); + virtual void ScrollTo(BPoint where); + virtual void MessageReceived(BMessage* message); + virtual void MouseDown(BPoint where); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage); + virtual void MouseUp(BPoint where); + virtual void FrameResized(float width, float height); + void MoveColumn(BColumn* column, int32 index); + void SetColumnFlags(column_flags flags); + + void SetEditMode(bool state) + { fEditMode = state; } + + float MarginWidth() const; + private: - void GetTitleRect(BColumn*, BRect *out_rect); - int32 FindColumn(BPoint, float *out_leftEdge); - void FixScrollBar(bool scrollToFit); - void DragSelectedColumn(BPoint); - void ResizeSelectedColumn(BPoint, bool = false); - void ComputeDragBoundries(BColumn*, BPoint); - void DrawTitle(BView*, BRect, BColumn*, bool depressed); + void GetTitleRect(BColumn* column, BRect* _rect); + int32 FindColumn(BPoint where, float* _leftEdge); + void FixScrollBar(bool scrollToFit); + void DragSelectedColumn(BPoint where); + void ResizeSelectedColumn(BPoint where, + bool preferred = false); + void ComputeDragBoundries(BColumn* column, + BPoint where); + void DrawTitle(BView* view, BRect frame, + BColumn* column, bool depressed); - OutlineView *fOutlineView; - BList *fColumns; - BList *fSortColumns; - float fColumnsWidth; - BRect fVisibleRect; - + float _VirtualWidth() const; + + OutlineView* fOutlineView; + BList* fColumns; + BList* fSortColumns; +// float fColumnsWidth; + BRect fVisibleRect; + #if DOUBLE_BUFFERED_COLUMN_RESIZE - BBitmap *fDrawBuffer; - BView *fDrawBufferView; + BBitmap* fDrawBuffer; + BView* fDrawBufferView; #endif - enum { - INACTIVE, - RESIZING_COLUMN, - PRESSING_COLUMN, - DRAG_COLUMN_INSIDE_TITLE, - DRAG_COLUMN_OUTSIDE_TITLE - } fCurrentState; + enum { + INACTIVE, + RESIZING_COLUMN, + PRESSING_COLUMN, + DRAG_COLUMN_INSIDE_TITLE, + DRAG_COLUMN_OUTSIDE_TITLE + } fCurrentState; - BPopUpMenu *fColumnPop; - BColumnListView *fMasterView; - bool fEditMode; - int32 fColumnFlags; + BPopUpMenu* fColumnPop; + BColumnListView* fMasterView; + bool fEditMode; + int32 fColumnFlags; // State information for resizing/dragging - BColumn *fSelectedColumn; - BRect fSelectedColumnRect; - bool fResizingFirstColumn; - BPoint fClickPoint; // offset within cell - float fLeftDragBoundry; - float fRightDragBoundry; - BPoint fCurrentDragPosition; + BColumn* fSelectedColumn; + BRect fSelectedColumnRect; + bool fResizingFirstColumn; + BPoint fClickPoint; // offset within cell + float fLeftDragBoundry; + float fRightDragBoundry; + BPoint fCurrentDragPosition; - - BBitmap *fUpSortArrow; - BBitmap *fDownSortArrow; - BCursor *fResizeCursor; - BCursor *fMinResizeCursor; - BCursor *fMaxResizeCursor; - BCursor *fColumnMoveCursor; - - typedef BView _inherited; + BBitmap* fUpSortArrow; + BBitmap* fDownSortArrow; + + BCursor* fResizeCursor; + BCursor* fMinResizeCursor; + BCursor* fMaxResizeCursor; + BCursor* fColumnMoveCursor; }; class OutlineView : public BView { + typedef BView _inherited; public: - OutlineView(BRect, BList *visibleColumns, BList *sortColumns, BColumnListView *listView); - ~OutlineView(); + OutlineView(BRect, BList* visibleColumns, + BList* sortColumns, + BColumnListView* listView); + virtual ~OutlineView(); virtual void Draw(BRect); const BRect& VisibleRect() const; - void RedrawColumn(BColumn *column, float leftEdge, bool isFirstColumn); + void RedrawColumn(BColumn* column, float leftEdge, + bool isFirstColumn); void StartSorting(); - float GetColumnPreferredWidth(BColumn *column); - - void AddRow(BRow*, int32 index, BRow *TheRow); - BRow* CurrentSelection(BRow *lastSelected) const; + float GetColumnPreferredWidth(BColumn* column); + + void AddRow(BRow*, int32 index, BRow* TheRow); + BRow* CurrentSelection(BRow* lastSelected) const; void ToggleFocusRowSelection(bool selectRange); void ToggleFocusRowOpen(); - void ChangeFocusRow(bool up, bool updateSelection, bool addToCurrentSelection); + void ChangeFocusRow(bool up, bool updateSelection, + bool addToCurrentSelection); void MoveFocusToVisibleRect(); - void ExpandOrCollapse(BRow *parent, bool expand); + void ExpandOrCollapse(BRow* parent, bool expand); void RemoveRow(BRow*); BRowContainer* RowList(); void UpdateRow(BRow*); - bool FindParent(BRow *row, BRow **out_parent, bool *out_isVisible); - int32 IndexOf(BRow *row); + bool FindParent(BRow* row, BRow** _parent, + bool* _isVisible); + int32 IndexOf(BRow* row); void Deselect(BRow*); void AddToSelection(BRow*); void DeselectAll(); BRow* FocusRow() const; - void SetFocusRow(BRow *row, bool select); - BRow* FindRow(float ypos, int32 *out_indent, float *out_top); - bool FindRect(const BRow *row, BRect *out_rect); - void ScrollTo(const BRow* Row); + void SetFocusRow(BRow* row, bool select); + BRow* FindRow(float ypos, int32* _indent, + float* _top); + bool FindRect(const BRow* row, BRect* _rect); + void ScrollTo(const BRow* row); void Clear(); - void SetSelectionMode(list_view_type); + void SetSelectionMode(list_view_type type); list_view_type SelectionMode() const; void SetMouseTrackingEnabled(bool); void FixScrollBar(bool scrollToFit); - void SetEditMode(bool state) { fEditMode = state; } + void SetEditMode(bool state) + { fEditMode = state; } virtual void FrameResized(float width, float height); - virtual void ScrollTo(BPoint pt); - virtual void MouseDown(BPoint); - virtual void MouseMoved(BPoint, uint32, const BMessage*); - virtual void MouseUp(BPoint); - virtual void MessageReceived(BMessage*); + virtual void ScrollTo(BPoint where); + virtual void MouseDown(BPoint where); + virtual void MouseMoved(BPoint where, uint32 transit, + const BMessage* dragMessage); + virtual void MouseUp(BPoint where); + virtual void MessageReceived(BMessage* message); private: - bool SortList(BRowContainer *list, bool isVisible); - static int32 DeepSortThreadEntry(void *outlineView); + bool SortList(BRowContainer* list, bool isVisible); + static int32 DeepSortThreadEntry(void* outlineView); void DeepSort(); - void SelectRange(BRow *start, BRow *end); - int32 CompareRows(BRow *row1, BRow *row2); - void AddSorted(BRowContainer *list, BRow *row); - void RecursiveDeleteRows(BRowContainer *list, bool owner); + void SelectRange(BRow* start, BRow* end); + int32 CompareRows(BRow* row1, BRow* row2); + void AddSorted(BRowContainer* list, BRow* row); + void RecursiveDeleteRows(BRowContainer* list, + bool owner); void InvalidateCachedPositions(); - bool FindVisibleRect(BRow *row, BRect *out_rect); + bool FindVisibleRect(BRow* row, BRect* _rect); - BList* fColumns; - BList* fSortColumns; - float fItemsHeight; - BRowContainer fRows; - BRect fVisibleRect; + BList* fColumns; + BList* fSortColumns; + float fItemsHeight; + BRowContainer fRows; + BRect fVisibleRect; #if DOUBLE_BUFFERED_COLUMN_RESIZE - BBitmap* fDrawBuffer; - BView* fDrawBufferView; + BBitmap* fDrawBuffer; + BView* fDrawBufferView; #endif - BRow* fFocusRow; - BRect fFocusRowRect; - BRow* fRollOverRow; + BRow* fFocusRow; + BRect fFocusRowRect; + BRow* fRollOverRow; - BRow fSelectionListDummyHead; - BRow* fLastSelectedItem; - BRow* fFirstSelectedItem; + BRow fSelectionListDummyHead; + BRow* fLastSelectedItem; + BRow* fFirstSelectedItem; - thread_id fSortThread; - int32 fNumSorted; - bool fSortCancelled; + thread_id fSortThread; + int32 fNumSorted; + bool fSortCancelled; - enum CurrentState - { - INACTIVE, - LATCH_CLICKED, - ROW_CLICKED, - DRAGGING_ROWS - }; - - CurrentState fCurrentState; - + enum CurrentState { + INACTIVE, + LATCH_CLICKED, + ROW_CLICKED, + DRAGGING_ROWS + }; - BColumnListView* fMasterView; - list_view_type fSelectionMode; - bool fTrackMouse; - BField* fCurrentField; - BRow* fCurrentRow; - BColumn* fCurrentColumn; - bool fMouseDown; - BRect fFieldRect; - int32 fCurrentCode; - bool fEditMode; + CurrentState fCurrentState; + + BColumnListView* fMasterView; + list_view_type fSelectionMode; + bool fTrackMouse; + BField* fCurrentField; + BRow* fCurrentRow; + BColumn* fCurrentColumn; + bool fMouseDown; + BRect fFieldRect; + int32 fCurrentCode; + bool fEditMode; + // State information for mouse/keyboard interaction - BPoint fClickPoint; - bool fDragging; - int32 fClickCount; - BRow *fTargetRow; - float fTargetRowTop; - BRect fLatchRect; - float fDropHighlightY; + BPoint fClickPoint; + bool fDragging; + int32 fClickCount; + BRow* fTargetRow; + float fTargetRowTop; + BRect fLatchRect; + float fDropHighlightY; friend class RecursiveOutlineIterator; - typedef BView _inherited; }; class RecursiveOutlineIterator { public: - RecursiveOutlineIterator(BRowContainer*, bool openBranchesOnly = true); - BRow *CurrentRow() const; - int32 CurrentLevel() const; - void GoToNext(); + RecursiveOutlineIterator( + BRowContainer* container, + bool openBranchesOnly = true); + BRow* CurrentRow() const; + int32 CurrentLevel() const; + void GoToNext(); + private: - struct { - BRowContainer *fRowSet; - int32 fIndex; - int32 fDepth; - } fStack[kMaxDepth]; + struct { + BRowContainer* fRowSet; + int32 fIndex; + int32 fDepth; + } fStack[kMaxDepth]; - int32 fStackIndex; - BRowContainer *fCurrentList; - int32 fCurrentListIndex; - int32 fCurrentListDepth; - bool fOpenBranchesOnly; + int32 fStackIndex; + BRowContainer* fCurrentList; + int32 fCurrentListIndex; + int32 fCurrentListDepth; + bool fOpenBranchesOnly; }; } // namespace BPrivate + using namespace BPrivate; + BField::BField() { } + BField::~BField() { } + // #pragma mark - -void BColumn::MouseMoved(BColumnListView */*parent*/, BRow */*row*/, BField */*field*/, - BRect /*field_rect*/, BPoint/*point*/, uint32 /*buttons*/, int32 /*code*/) + +void +BColumn::MouseMoved(BColumnListView* /*parent*/, BRow* /*row*/, + BField* /*field*/, BRect /*field_rect*/, BPoint/*point*/, + uint32 /*buttons*/, int32 /*code*/) { } -void BColumn::MouseDown( BColumnListView */*parent*/, BRow */*row*/, BField */*field*/, - BRect /*field_rect*/, BPoint /*point*/, uint32 /*buttons*/) + +void +BColumn::MouseDown(BColumnListView* /*parent*/, BRow* /*row*/, + BField* /*field*/, BRect /*field_rect*/, BPoint /*point*/, + uint32 /*buttons*/) { } -void BColumn::MouseUp(BColumnListView */*parent*/, BRow */*row*/, BField */*field*/) + +void +BColumn::MouseUp(BColumnListView* /*parent*/, BRow* /*row*/, BField* /*field*/) { } + // #pragma mark - + BRow::BRow(float height) - : fChildList(NULL), - fIsExpanded(false), - fHeight(height), - fNextSelected(NULL), - fPrevSelected(NULL), - fParent(NULL), - fList(NULL) + : + fChildList(NULL), + fIsExpanded(false), + fHeight(height), + fNextSelected(NULL), + fPrevSelected(NULL), + fParent(NULL), + fList(NULL) { } + BRow::~BRow() { while (true) { - BField *field = (BField*) fFields.RemoveItem(0L); + BField* field = (BField*) fFields.RemoveItem((int32)0); if (field == 0) break; - + delete field; - } + } } -bool BRow::HasLatch() const + +bool +BRow::HasLatch() const { return fChildList != 0; } -int32 BRow::CountFields() const + +int32 +BRow::CountFields() const { return fFields.CountItems(); } -BField* BRow::GetField(int32 index) + +BField* +BRow::GetField(int32 index) { - return (BField*) fFields.ItemAt(index); + return (BField*)fFields.ItemAt(index); } -const BField* BRow::GetField(int32 index) const + +const BField* +BRow::GetField(int32 index) const { - return (const BField*) fFields.ItemAt(index); + return (const BField*)fFields.ItemAt(index); } -void BRow::SetField(BField *field, int32 logicalFieldIndex) + +void +BRow::SetField(BField* field, int32 logicalFieldIndex) { if (fFields.ItemAt(logicalFieldIndex) != 0) - delete (BField*) fFields.RemoveItem(logicalFieldIndex); - - if( NULL != fList ) { + delete (BField*)fFields.RemoveItem(logicalFieldIndex); + + if (NULL != fList) { ValidateField(field, logicalFieldIndex); BRect inv; fList->GetRowRect(this, &inv); fList->Invalidate(inv); } - + fFields.AddItem(field, logicalFieldIndex); } -float BRow::Height() const + +float +BRow::Height() const { return fHeight; } -bool BRow::IsExpanded() const + +bool +BRow::IsExpanded() const { return fIsExpanded; } -void + +bool +BRow::IsSelected() const +{ + return fPrevSelected != NULL; +} + + +void BRow::ValidateFields() const { - for( int32 i = 0; i < CountFields(); i++ ) - { + for (int32 i = 0; i < CountFields(); i++) ValidateField(GetField(i), i); - } } -void -BRow::ValidateField(const BField *field, int32 logicalFieldIndex) const + +void +BRow::ValidateField(const BField* field, int32 logicalFieldIndex) const { // The Fields may be moved by the user, but the logicalFieldIndexes // do not change, so we need to map them over when checking the // Field types. BColumn* col = NULL; int32 items = fList->CountColumns(); - for( int32 i = 0 ; i < items; ++i ) - { + for (int32 i = 0 ; i < items; ++i) { col = fList->ColumnAt(i); if( col->LogicalFieldNum() == logicalFieldIndex ) break; } - - if( NULL == col ) - { + + if (NULL == col) { BString dbmessage("\n\n\tThe parent BColumnListView does not have " "\n\ta BColumn at the logical field index "); dbmessage << logicalFieldIndex << ".\n\n"; printf(dbmessage.String()); - } - else - { - if( false == col->AcceptsField(field) ) - { + } else { + if (!col->AcceptsField(field)) { BString dbmessage("\n\n\tThe BColumn of type "); dbmessage << typeid(*col).name() << "\n\tat logical field index " - << logicalFieldIndex << "\n\tdoes not support the field type " + << logicalFieldIndex << "\n\tdoes not support the " + "field type " << typeid(*field).name() << ".\n\n"; debugger(dbmessage.String()); } @@ -566,111 +572,151 @@ // #pragma mark - + BColumn::BColumn(float width, float minWidth, float maxWidth, alignment align) - : fWidth(width), - fMinWidth(minWidth), - fMaxWidth(maxWidth), - fVisible(true), - fList(0), - fShowHeading(true), - fAlignment(align) + : + fWidth(width), + fMinWidth(minWidth), + fMaxWidth(maxWidth), + fVisible(true), + fList(0), + fShowHeading(true), + fAlignment(align) { } + BColumn::~BColumn() { } -float BColumn::Width() const + +float +BColumn::Width() const { return fWidth; } -void BColumn::SetWidth(float width) + +void +BColumn::SetWidth(float width) { fWidth = width; } -float BColumn::MinWidth() const + +float +BColumn::MinWidth() const { return fMinWidth; } -float BColumn::MaxWidth() const + +float +BColumn::MaxWidth() const { return fMaxWidth; } -void BColumn::DrawTitle(BRect, BView*) + +void +BColumn::DrawTitle(BRect, BView*) { } -void BColumn::DrawField(BField*, BRect, BView*) + +void +BColumn::DrawField(BField*, BRect, BView*) { } -int BColumn::CompareFields(BField *, BField *) + +int +BColumn::CompareFields(BField*, BField*) { return 0; } -void BColumn::GetColumnName(BString* into) const + +void +BColumn::GetColumnName(BString* into) const { *into = "(Unnamed)"; } -float BColumn::GetPreferredWidth(BField *field, BView *parent) const + +float +BColumn::GetPreferredWidth(BField* field, BView* parent) const { return fWidth; } -bool BColumn::IsVisible() const + +bool +BColumn::IsVisible() const { return fVisible; } -void BColumn::SetVisible(bool visible) + +void +BColumn::SetVisible(bool visible) { if (fList && (fVisible != visible)) fList->SetColumnVisible(this, visible); } -bool BColumn::ShowHeading() const + +bool +BColumn::ShowHeading() const { return fShowHeading; } -void BColumn::SetShowHeading(bool state) + +void +BColumn::SetShowHeading(bool state) { fShowHeading = state; } -alignment BColumn::Alignment() const + +alignment +BColumn::Alignment() const { return fAlignment; } -void BColumn::SetAlignment(alignment align) + +void +BColumn::SetAlignment(alignment align) { fAlignment = align; } -bool BColumn::WantsEvents() const + +bool +BColumn::WantsEvents() const { return fWantsEvents; } -void BColumn::SetWantsEvents(bool state) + +void +BColumn::SetWantsEvents(bool state) { fWantsEvents = state; } -int32 BColumn::LogicalFieldNum() const + +int32 +BColumn::LogicalFieldNum() const { return fFieldID; } -bool + +bool BColumn::AcceptsField(const BField*) const { return true; @@ -679,128 +725,68 @@ // #pragma mark - -BColumnListView::BColumnListView(BRect rect, const char *name, uint32 resizingMode, - uint32 drawFlags, border_style border, bool showHorizontalScrollbar) - : BView(rect, name, resizingMode, drawFlags | B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE), - fStatusView(0), - fSelectionMessage(0), - fSortingEnabled(true), - fLatchWidth(kLatchWidth), - fBorderStyle(border) + +BColumnListView::BColumnListView(BRect rect, const char* name, + uint32 resizingMode, uint32 flags, border_style border, + bool showHorizontalScrollbar) + : + BView(rect, name, resizingMode, + flags | B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE), + fStatusView(NULL), + fSelectionMessage(NULL), + fSortingEnabled(true), + fLatchWidth(kLatchWidth), + fBorderStyle(border), + fShowingHorizontalScrollBar(showHorizontalScrollbar) { - SetViewColor(B_TRANSPARENT_32_BIT); + _Init(); +} - BRect bounds(rect); - bounds.OffsetTo(0, 0); - - for (int i = 0; i < (int)B_COLOR_TOTAL; i++) - fColorList[i] = kColor[i]; - - BRect titleRect(bounds); - titleRect.bottom = titleRect.top + kTitleHeight; -#if !LOWER_SCROLLBAR - titleRect.right -= B_V_SCROLL_BAR_WIDTH + 1; -#endif - BRect outlineRect(bounds); - outlineRect.top = titleRect.bottom + 1.0; - outlineRect.right -= B_V_SCROLL_BAR_WIDTH + 1; - if(showHorizontalScrollbar) - outlineRect.bottom -= B_H_SCROLL_BAR_HEIGHT + 1; +BColumnListView::BColumnListView(const char* name, uint32 flags, + border_style border, bool showHorizontalScrollbar) + : + BView(name, flags | B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE), + fStatusView(NULL), + fSelectionMessage(NULL), + fSortingEnabled(true), + fLatchWidth(kLatchWidth), + fBorderStyle(border), + fShowingHorizontalScrollBar(showHorizontalScrollbar) +{ + _Init(); +} - BRect vScrollBarRect(bounds); -#if LOWER_SCROLLBAR - vScrollBarRect.top += kTitleHeight; -#endif - vScrollBarRect.left = vScrollBarRect.right - B_V_SCROLL_BAR_WIDTH; - if(showHorizontalScrollbar) - vScrollBarRect.bottom -= B_H_SCROLL_BAR_HEIGHT; - - BRect hScrollBarRect(bounds); - hScrollBarRect.top = hScrollBarRect.bottom - B_H_SCROLL_BAR_HEIGHT; - hScrollBarRect.right -= B_V_SCROLL_BAR_WIDTH; - - // Adjust stuff so the border will fit. - if (fBorderStyle == B_PLAIN_BORDER) { - titleRect.InsetBy(1, 0); - titleRect.top++; - outlineRect.InsetBy(1, 0); - outlineRect.bottom--; - - vScrollBarRect.OffsetBy(-1, 0); - vScrollBarRect.InsetBy(0, 1); - hScrollBarRect.OffsetBy(0, -1); - hScrollBarRect.InsetBy(1, 0); - } else if (fBorderStyle == B_FANCY_BORDER) { - titleRect.InsetBy(2, 0); - titleRect.top += 2; - outlineRect.InsetBy(2, 0); - outlineRect.bottom -= 2; - - vScrollBarRect.OffsetBy(-2, 0); - vScrollBarRect.InsetBy(0, 2); - hScrollBarRect.OffsetBy(0, -2); - hScrollBarRect.InsetBy(2, 0); - } - - fOutlineView = new OutlineView(outlineRect, &fColumns, &fSortColumns, this); - AddChild(fOutlineView); - - - // Adapt to correct resizing mode - uint32 fParentFlags = resizingMode; - // Always follow LEFT_RIGHT - uint32 fTitleFlags = B_FOLLOW_LEFT_RIGHT; - - if ((fParentFlags & B_FOLLOW_TOP) && (fParentFlags & ~B_FOLLOW_BOTTOM)) { - fTitleFlags |= B_FOLLOW_TOP; - } - else if ((fParentFlags & B_FOLLOW_BOTTOM) && (fParentFlags & ~B_FOLLOW_TOP)) { - fTitleFlags |= B_FOLLOW_BOTTOM; - } - - fTitleView = new TitleView(titleRect, fOutlineView, &fColumns, &fSortColumns, this, fTitleFlags); - - - AddChild(fTitleView); - fVerticalScrollBar = new BScrollBar(vScrollBarRect, "vertical_scroll_bar", - fOutlineView, 0.0, bounds.Height(), B_VERTICAL); - AddChild(fVerticalScrollBar); - fHorizontalScrollBar = new BScrollBar(hScrollBarRect, "horizontal_scroll_bar", - fTitleView, 0.0, bounds.Width(), B_HORIZONTAL); - AddChild(fHorizontalScrollBar); - if(!showHorizontalScrollbar) - fHorizontalScrollBar->Hide(); - fOutlineView->FixScrollBar(true); -} - BColumnListView::~BColumnListView() { - while (true) { - BColumn *column = (BColumn*) fColumns.RemoveItem(0L); - if (column == 0) - break; - + while (BColumn* column = (BColumn*)fColumns.RemoveItem((int32)0)) delete column; - } } -bool BColumnListView::InitiateDrag(BPoint, bool) + +bool +BColumnListView::InitiateDrag(BPoint, bool) { return false; } -void BColumnListView::MessageDropped(BMessage*, BPoint) + +void +BColumnListView::MessageDropped(BMessage*, BPoint) { } -void BColumnListView::ExpandOrCollapse(BRow* Row, bool Open) + +void +BColumnListView::ExpandOrCollapse(BRow* row, bool Open) { - fOutlineView->ExpandOrCollapse(Row, Open); + fOutlineView->ExpandOrCollapse(row, Open); } -status_t BColumnListView::Invoke(BMessage *message) + +status_t +BColumnListView::Invoke(BMessage* message) { if (message == 0) message = Message(); @@ -808,117 +794,159 @@ return BInvoker::Invoke(message); } -void BColumnListView::ItemInvoked() + +void +BColumnListView::ItemInvoked() { Invoke(); } -void BColumnListView::SetInvocationMessage(BMessage *message) + +void +BColumnListView::SetInvocationMessage(BMessage* message) { SetMessage(message); } -BMessage* BColumnListView::InvocationMessage() const + +BMessage* +BColumnListView::InvocationMessage() const { return Message(); } -uint32 BColumnListView::InvocationCommand() const + +uint32 +BColumnListView::InvocationCommand() const { return Command(); } -BRow* BColumnListView::FocusRow() const + +BRow* +BColumnListView::FocusRow() const { return fOutlineView->FocusRow(); } -void BColumnListView::SetFocusRow(int32 Index, bool Select) + +void +BColumnListView::SetFocusRow(int32 Index, bool Select) { SetFocusRow(RowAt(Index), Select); } -void BColumnListView::SetFocusRow(BRow* Row, bool Select) + +void +BColumnListView::SetFocusRow(BRow* row, bool Select) { - fOutlineView->SetFocusRow(Row, Select); + fOutlineView->SetFocusRow(row, Select); } -void BColumnListView::SetMouseTrackingEnabled(bool Enabled) + +void +BColumnListView::SetMouseTrackingEnabled(bool Enabled) { - fOutlineView->SetMouseTrackingEnabled(Enabled); + fOutlineView->SetMouseTrackingEnabled(Enabled); } -list_view_type BColumnListView::SelectionMode() const + +list_view_type +BColumnListView::SelectionMode() const { return fOutlineView->SelectionMode(); } -void BColumnListView::Deselect(BRow *row) + +void +BColumnListView::Deselect(BRow* row) { fOutlineView->Deselect(row); } -void BColumnListView::AddToSelection(BRow *row) + +void +BColumnListView::AddToSelection(BRow* row) { fOutlineView->AddToSelection(row); } -void BColumnListView::DeselectAll() + +void +BColumnListView::DeselectAll() { fOutlineView->DeselectAll(); } -BRow* BColumnListView::CurrentSelection(BRow *lastSelected) const + +BRow* +BColumnListView::CurrentSelection(BRow* lastSelected) const { return fOutlineView->CurrentSelection(lastSelected); } -void BColumnListView::SelectionChanged() + +void +BColumnListView::SelectionChanged() { if (fSelectionMessage) Invoke(fSelectionMessage); } -void BColumnListView::SetSelectionMessage(BMessage *message) + +void +BColumnListView::SetSelectionMessage(BMessage* message) { if (fSelectionMessage == message) return; - + delete fSelectionMessage; fSelectionMessage = message; } -BMessage* BColumnListView::SelectionMessage() + +BMessage* +BColumnListView::SelectionMessage() { return fSelectionMessage; } -uint32 BColumnListView::SelectionCommand() const + +uint32 +BColumnListView::SelectionCommand() const { if (fSelectionMessage) return fSelectionMessage->what; - + return 0; } -void BColumnListView::SetSelectionMode(list_view_type mode) + +void +BColumnListView::SetSelectionMode(list_view_type mode) { fOutlineView->SetSelectionMode(mode); } -void BColumnListView::SetSortingEnabled(bool enabled) + +void +BColumnListView::SetSortingEnabled(bool enabled) { fSortingEnabled = enabled; fSortColumns.MakeEmpty(); fTitleView->Invalidate(); // Erase sort indicators } -bool BColumnListView::SortingEnabled() const + +bool +BColumnListView::SortingEnabled() const { return fSortingEnabled; } -void BColumnListView::SetSortColumn(BColumn *column, bool add, bool ascending) + +void +BColumnListView::SetSortColumn(BColumn* column, bool add, bool ascending) { if (!SortingEnabled()) return; @@ -930,17 +958,21 @@ fSortColumns.AddItem(column); column->fSortAscending = ascending; - fTitleView->Invalidate(); + fTitleView->Invalidate(); fOutlineView->StartSorting(); } -void BColumnListView::ClearSortColumns() + +void +BColumnListView::ClearSortColumns() { fSortColumns.MakeEmpty(); fTitleView->Invalidate(); // Erase sort indicators } -void BColumnListView::AddStatusView(BView *view) + +void +BColumnListView::AddStatusView(BView* view) { BRect bounds = Bounds(); float width = view->Bounds().Width(); @@ -961,14 +993,16 @@ viewRect.OffsetBy(1, -1); else if (fBorderStyle == B_FANCY_BORDER) viewRect.OffsetBy(2, -2); - + view->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); view->ResizeTo(viewRect.Width(), viewRect.Height()); view->MoveTo(viewRect.left, viewRect.top); Window()->EndViewTransaction(); } -BView* BColumnListView::RemoveStatusView() + +BView* +BColumnListView::RemoveStatusView() { if (fStatusView) { float width = fStatusView->Bounds().Width(); @@ -979,20 +1013,23 @@ Window()->EndViewTransaction(); } - BView *view = fStatusView; + BView* view = fStatusView; fStatusView = 0; return view; } -void BColumnListView::AddColumn(BColumn *column, int32 logicalFieldIndex) + + +void +BColumnListView::AddColumn(BColumn* column, int32 logicalFieldIndex) { - ASSERT(column != 0); + ASSERT(column != NULL); column->fList = this; column->fFieldID = logicalFieldIndex; // sanity check. If there is already a field with this ID, remove it. for (int32 index = 0; index < fColumns.CountItems(); index++) { - BColumn *existingColumn = (BColumn*) fColumns.ItemAt(index); + BColumn* existingColumn = (BColumn*) fColumns.ItemAt(index); if (existingColumn && existingColumn->fFieldID == logicalFieldIndex) { RemoveColumn(existingColumn); break; @@ -1008,227 +1045,385 @@ fTitleView->ColumnAdded(column); } -void BColumnListView::MoveColumn(BColumn *column, int32 index) + +void +BColumnListView::MoveColumn(BColumn* column, int32 index) { - ASSERT(column != 0); + ASSERT(column != NULL); fTitleView->MoveColumn(column, index); } -void BColumnListView::RemoveColumn(BColumn *column) + +void +BColumnListView::RemoveColumn(BColumn* column) { if (fColumns.HasItem(column)) { SetColumnVisible(column, false); - Window()->UpdateIfNeeded(); + if (Window() != NULL) + Window()->UpdateIfNeeded(); fColumns.RemoveItem(column); } } -int32 BColumnListView::CountColumns() const + +int32 +BColumnListView::CountColumns() const { return fColumns.CountItems(); } -BColumn* BColumnListView::ColumnAt(int32 field) const + +BColumn* +BColumnListView::ColumnAt(int32 field) const { return (BColumn*) fColumns.ItemAt(field); } -void BColumnListView::SetColumnVisible(BColumn *column, bool visible) + +BColumn* +BColumnListView::ColumnAt(BPoint point) const { + float left = MAX(kLeftMargin, LatchWidth()); + + for (int i = 0; BColumn* column = (BColumn*)fColumns.ItemAt(i); i++) { + if (!column->IsVisible()) + continue; + + float right = left + column->Width(); + if (point.x >= left && point.x <= right) + return column; + + left = right + 1; + } + + return NULL; +} + + +void +BColumnListView::SetColumnVisible(BColumn* column, bool visible) +{ fTitleView->SetColumnVisible(column, visible); } -void BColumnListView::SetColumnVisible(int32 index, bool isVisible) + +void +BColumnListView::SetColumnVisible(int32 index, bool isVisible) { - BColumn *column = ColumnAt(index); + BColumn* column = ColumnAt(index); if (column) column->SetVisible(isVisible); } -bool BColumnListView::IsColumnVisible(int32 index) const + +bool +BColumnListView::IsColumnVisible(int32 index) const { - BColumn *column = ColumnAt(index); + BColumn* column = ColumnAt(index); if (column) return column->IsVisible(); return false; } -void BColumnListView::SetColumnFlags(column_flags flags) + +void +BColumnListView::SetColumnFlags(column_flags flags) { fTitleView->SetColumnFlags(flags); } -const BRow* BColumnListView::RowAt(int32 Index, BRow* ParentRow) const + +void +BColumnListView::ResizeColumnToPreferred(int32 index) { - if (ParentRow == 0) - return fOutlineView->RowList()->ItemAt(Index); + BColumn* column = ColumnAt(index); + if (column == NULL) + return; - return ParentRow->fChildList ? ParentRow->fChildList->ItemAt(Index) : NULL; + // get the preferred column width + float width = fOutlineView->GetColumnPreferredWidth(column); + + // set it + float oldWidth = column->Width(); + column->SetWidth(width); + + fTitleView->ColumnResized(column, oldWidth); + fOutlineView->Invalidate(); } -BRow* BColumnListView::RowAt(int32 Index, BRow* ParentRow) + +void +BColumnListView::ResizeAllColumnsToPreferred() { - if (ParentRow == 0) - return fOutlineView->RowList()->ItemAt(Index); + int32 count = CountColumns(); + for (int32 i = 0; i < count; i++) + ResizeColumnToPreferred(i); +} - return ParentRow->fChildList ? ParentRow->fChildList->ItemAt(Index) : 0; + +const BRow* +BColumnListView::RowAt(int32 Index, BRow* parentRow) const +{ + if (parentRow == 0) + return fOutlineView->RowList()->ItemAt(Index); + + return parentRow->fChildList ? parentRow->fChildList->ItemAt(Index) : NULL; } -const BRow* BColumnListView::RowAt(BPoint point) const + +BRow* +BColumnListView::RowAt(int32 Index, BRow* parentRow) { + if (parentRow == 0) + return fOutlineView->RowList()->ItemAt(Index); + + return parentRow->fChildList ? parentRow->fChildList->ItemAt(Index) : 0; +} + + +const BRow* +BColumnListView::RowAt(BPoint point) const +{ float top; int32 indent; return fOutlineView->FindRow(point.y, &indent, &top); } -BRow* BColumnListView::RowAt(BPoint point) + +BRow* +BColumnListView::RowAt(BPoint point) { float top; int32 indent; return fOutlineView->FindRow(point.y, &indent, &top); } -bool BColumnListView::GetRowRect(const BRow *row, BRect *outRect) const + +bool +BColumnListView::GetRowRect(const BRow* row, BRect* outRect) const { return fOutlineView->FindRect(row, outRect); } -bool BColumnListView::FindParent(BRow *row, BRow **out_parent, bool *out_isVisible) const + +bool +BColumnListView::FindParent(BRow* row, BRow** _parent, bool* _isVisible) const { - return fOutlineView->FindParent(row, out_parent, out_isVisible); + return fOutlineView->FindParent(row, _parent, _isVisible); } -int32 BColumnListView::IndexOf(BRow *row) + +int32 +BColumnListView::IndexOf(BRow* row) { return fOutlineView->IndexOf(row); } -int32 BColumnListView::CountRows(BRow* ParentRow) const + +int32 +BColumnListView::CountRows(BRow* parentRow) const { - if (ParentRow == 0) - return fOutlineView->RowList()->CountItems(); - if (ParentRow->fChildList) - return ParentRow->fChildList->CountItems(); + if (parentRow == 0) + return fOutlineView->RowList()->CountItems(); + if (parentRow->fChildList) + return parentRow->fChildList->CountItems(); else return 0; } -void BColumnListView::AddRow(BRow *row, BRow* ParentRow) + +void +BColumnListView::AddRow(BRow* row, BRow* parentRow) { - AddRow(row, -1, ParentRow); + AddRow(row, -1, parentRow); } -void BColumnListView::AddRow(BRow *row, int32 index, BRow* ParentRow) + +void +BColumnListView::AddRow(BRow* row, int32 index, BRow* parentRow) { row->fChildList = 0; row->fList = this; row->ValidateFields(); - fOutlineView->AddRow(row, index, ParentRow); + fOutlineView->AddRow(row, index, parentRow); } -void BColumnListView::RemoveRow(BRow *row) + +void +BColumnListView::RemoveRow(BRow* row) { fOutlineView->RemoveRow(row); row->fList = NULL; } -void BColumnListView::UpdateRow(BRow *row) + +void +BColumnListView::UpdateRow(BRow* row) { fOutlineView->UpdateRow(row); } -void BColumnListView::ScrollTo(const BRow* Row) + +bool +BColumnListView::SwapRows(int32 index1, int32 index2, BRow* parentRow1, + BRow* parentRow2) { - fOutlineView->ScrollTo(Row); + BRow* row1 = NULL; + BRow* row2 = NULL; + + BRowContainer* container1 = NULL; + BRowContainer* container2 = NULL; + + if (parentRow1 == NULL) + container1 = fOutlineView->RowList(); + else + container1 = parentRow1->fChildList; + + if (container1 == NULL) + return false; + + if (parentRow2 == NULL) + container2 = fOutlineView->RowList(); + else + container2 = parentRow1->fChildList; + + if (container2 == NULL) + return false; + + row1 = container1->ItemAt(index1); + + if (row1 == NULL) + return false; + + row2 = container2->ItemAt(index2); + + if (row2 == NULL) + return false; + + container1->ReplaceItem(index2, row1); + container2->ReplaceItem(index1, row2); + + BRect rect1; + BRect rect2; + BRect rect; + + fOutlineView->FindRect(row1, &rect1); + fOutlineView->FindRect(row2, &rect2); + + rect = rect1 | rect2; + + fOutlineView->Invalidate(rect); + + return true; } -void BColumnListView::ScrollTo(BPoint point) + +void +BColumnListView::ScrollTo(const BRow* row) { + fOutlineView->ScrollTo(row); +} + + +void +BColumnListView::ScrollTo(BPoint point) +{ fOutlineView->ScrollTo(point); } -void BColumnListView::Clear() + +void +BColumnListView::Clear() { fOutlineView->Clear(); } -void BColumnListView::SetFont(const BFont *font, uint32 mask) + +void +BColumnListView::SetFont(const BFont* font, uint32 mask) { // This method is deprecated. fOutlineView->SetFont(font, mask); fTitleView->SetFont(font, mask); } -void BColumnListView::SetFont(ColumnListViewFont font_num, const BFont* font, uint32 mask) + +void +BColumnListView::SetFont(ColumnListViewFont font_num, const BFont* font, + uint32 mask) { switch (font_num) { case B_FONT_ROW: fOutlineView->SetFont(font, mask); break; - + case B_FONT_HEADER: fTitleView->SetFont(font, mask); break; - + default: ASSERT(false); - break; - }; + break; + } } -void BColumnListView::GetFont(ColumnListViewFont font_num, BFont* font) const + +void +BColumnListView::GetFont(ColumnListViewFont font_num, BFont* font) const { switch (font_num) { case B_FONT_ROW: fOutlineView->GetFont(font); break; - + case B_FONT_HEADER: fTitleView->GetFont(font); break; - + default: ASSERT(false); - break; - }; + break; + } } -void BColumnListView::SetColor(ColumnListViewColor color_num, const rgb_color color) + +void +BColumnListView::SetColor(ColumnListViewColor color_num, const rgb_color color) { - if ((int)color_num < 0) - { + if ((int)color_num < 0) { ASSERT(false); color_num = (ColumnListViewColor) 0; - } - - if ((int)color_num >= (int)B_COLOR_TOTAL) - { + } + + if ((int)color_num >= (int)B_COLOR_TOTAL) { ASSERT(false); color_num = (ColumnListViewColor) (B_COLOR_TOTAL - 1); } - + fColorList[color_num] = color; } -rgb_color BColumnListView::Color(ColumnListViewColor color_num) const + +rgb_color +BColumnListView::Color(ColumnListViewColor color_num) const { - if ((int)color_num < 0) - { + if ((int)color_num < 0) { ASSERT(false); color_num = (ColumnListViewColor) 0; - } - - if ((int)color_num >= (int)B_COLOR_TOTAL) - { + } + + if ((int)color_num >= (int)B_COLOR_TOTAL) { ASSERT(false); color_num = (ColumnListViewColor) (B_COLOR_TOTAL - 1); } - + return fColorList[color_num]; } -void BColumnListView::SetHighColor(rgb_color color) + +void +BColumnListView::SetHighColor(rgb_color color) { BView::SetHighColor(color); // fOutlineView->Invalidate(); // Redraw things with the new color @@ -1237,58 +1432,73 @@ // A better solution is needed. } -void BColumnListView::SetSelectionColor(rgb_color color) + +void +BColumnListView::SetSelectionColor(rgb_color color) { fColorList[B_COLOR_SELECTION] = color; } -void BColumnListView::SetBackgroundColor(rgb_color color) + +void +BColumnListView::SetBackgroundColor(rgb_color color) { fColorList[B_COLOR_BACKGROUND] = color; fOutlineView->Invalidate(); // Repaint with new color } -void BColumnListView::SetEditColor(rgb_color color) + +void +BColumnListView::SetEditColor(rgb_color color) { fColorList[B_COLOR_EDIT_BACKGROUND] = color; } -const rgb_color BColumnListView::SelectionColor() const + +const rgb_color +BColumnListView::SelectionColor() const { return fColorList[B_COLOR_SELECTION]; } -const rgb_color BColumnListView::BackgroundColor() const + +const rgb_color +BColumnListView::BackgroundColor() const { return fColorList[B_COLOR_BACKGROUND]; } -const rgb_color BColumnListView::EditColor() const + +const rgb_color +BColumnListView::EditColor() const { return fColorList[B_COLOR_EDIT_BACKGROUND]; } -BPoint BColumnListView::SuggestTextPosition(const BRow* row, const BColumn* inColumn) const + +BPoint +BColumnListView::SuggestTextPosition(const BRow* row, + const BColumn* inColumn) const { BRect rect; GetRowRect(row, &rect); if (inColumn) { float leftEdge = MAX(kLeftMargin, LatchWidth()); for (int index = 0; index < fColumns.CountItems(); index++) { - BColumn *column = (BColumn*) fColumns.ItemAt(index); + BColumn* column = (BColumn*) fColumns.ItemAt(index); if (!column->IsVisible()) continue; - + if (column == inColumn) { rect.left = leftEdge; rect.right = rect.left + column->Width(); break; } - + leftEdge += column->Width() + 1; } } - + font_height fh; fOutlineView->GetFontHeight(&fh); float baseline = floor(rect.top + fh.ascent @@ -1296,89 +1506,116 @@ return BPoint(rect.left + 8, baseline); } -void BColumnListView::SetLatchWidth(float width) + +void +BColumnListView::SetLatchWidth(float width) { fLatchWidth = width; Invalidate(); } -float BColumnListView::LatchWidth() const + +float +BColumnListView::LatchWidth() const { return fLatchWidth; } -void BColumnListView::DrawLatch(BView *view, BRect rect, LatchType position, BRow *) +void +BColumnListView::DrawLatch(BView* view, BRect rect, LatchType position, BRow*) { const int32 rectInset = 4; - + view->SetHighColor(0, 0, 0); - + // Make Square int32 sideLen = rect.IntegerWidth(); - if( sideLen > rect.IntegerHeight() ) - { + if (sideLen > rect.IntegerHeight()) sideLen = rect.IntegerHeight(); - } - + // Make Center int32 halfWidth = rect.IntegerWidth() / 2; int32 halfHeight = rect.IntegerHeight() / 2; int32 halfSide = sideLen / 2; - + float left = rect.left + halfWidth - halfSide; float top = rect.top + halfHeight - halfSide; - + BRect itemRect(left, top, left + sideLen, top + sideLen); - + // Why it is a pixel high? I don't know. itemRect.OffsetBy(0, -1); - + itemRect.InsetBy(rectInset, rectInset); // Make it an odd number of pixels wide, the latch looks better this way - if (1 == (itemRect.IntegerWidth() % 2)) - { - itemRect.right += 1; + if ((itemRect.IntegerWidth() % 2) == 1) { + itemRect.right += 1; itemRect.bottom += 1; } - + switch (position) { case B_OPEN_LATCH: view->StrokeRect(itemRect); - view->StrokeLine(BPoint(itemRect.left + 2, (itemRect.top + itemRect.bottom) / 2), - BPoint(itemRect.right - 2, (itemRect.top + itemRect.bottom) / 2)); + view->StrokeLine( + BPoint(itemRect.left + 2, + (itemRect.top + itemRect.bottom) / 2), + BPoint(itemRect.right - 2, + (itemRect.top + itemRect.bottom) / 2)); break; - + case B_PRESSED_LATCH: view->StrokeRect(itemRect); - view->StrokeLine(BPoint(itemRect.left + 2, (itemRect.top + itemRect.bottom) / 2), - BPoint(itemRect.right - 2, (itemRect.top + itemRect.bottom) / 2)); - view->StrokeLine(BPoint((itemRect.left + itemRect.right) / 2, itemRect.top + 2), - BPoint((itemRect.left + itemRect.right) / 2, itemRect.bottom - 2)); + view->StrokeLine( + BPoint(itemRect.left + 2, + (itemRect.top + itemRect.bottom) / 2), + BPoint(itemRect.right - 2, + (itemRect.top + itemRect.bottom) / 2)); + view->StrokeLine( + BPoint((itemRect.left + itemRect.right) / 2, + itemRect.top + 2), + BPoint((itemRect.left + itemRect.right) / 2, + itemRect.bottom - 2)); view->InvertRect(itemRect); break; - + case B_CLOSED_LATCH: view->StrokeRect(itemRect); - view->StrokeLine(BPoint(itemRect.left + 2, (itemRect.top + itemRect.bottom) / 2), - BPoint(itemRect.right - 2, (itemRect.top + itemRect.bottom) / 2)); - view->StrokeLine(BPoint((itemRect.left + itemRect.right) / 2, itemRect.top + 2), - BPoint((itemRect.left + itemRect.right) / 2, itemRect.bottom - 2)); + view->StrokeLine( + BPoint(itemRect.left + 2, + (itemRect.top + itemRect.bottom) / 2), + BPoint(itemRect.right - 2, + (itemRect.top + itemRect.bottom) / 2)); + view->StrokeLine( + BPoint((itemRect.left + itemRect.right) / 2, + itemRect.top + 2), + BPoint((itemRect.left + itemRect.right) / 2, + itemRect.bottom - 2)); break; - + case B_NO_LATCH: // No drawing break; } } -void BColumnListView::MakeFocus(bool isFocus) + +void +BColumnListView::MakeFocus(bool isFocus) { - Invalidate(); // Redraw focus marks around view + if (fBorderStyle != B_NO_BORDER) { + // Redraw focus marks around view + Invalidate(); + fHorizontalScrollBar->SetBorderHighlighted(isFocus); + fVerticalScrollBar->SetBorderHighlighted(isFocus); + } + BView::MakeFocus(isFocus); } -void BColumnListView::MessageReceived(BMessage *message) + +void +BColumnListView::MessageReceived(BMessage* message) { // Propagate mouse wheel messages down to child, so that it can // scroll. Note we have done so, so we don't go into infinite @@ -1391,15 +1628,19 @@ return; } } + BView::MessageReceived(message); } -void BColumnListView::KeyDown(const char *bytes, int32 numBytes) + +void +BColumnListView::KeyDown(const char* bytes, int32 numBytes) { char c = bytes[0]; switch (c) { - case B_RIGHT_ARROW: - case B_LEFT_ARROW: { + case B_RIGHT_ARROW: + case B_LEFT_ARROW: + { float minVal, maxVal; fHorizontalScrollBar->GetRange(&minVal, &maxVal); float smallStep, largeStep; @@ -1422,53 +1663,57 @@ } case B_DOWN_ARROW: - fOutlineView->ChangeFocusRow(false, (modifiers() & B_CONTROL_KEY) == 0, + fOutlineView->ChangeFocusRow(false, + (modifiers() & B_CONTROL_KEY) == 0, (modifiers() & B_SHIFT_KEY) != 0); break; case B_UP_ARROW: - fOutlineView->ChangeFocusRow(true, (modifiers() & B_CONTROL_KEY) == 0, + fOutlineView->ChangeFocusRow(true, + (modifiers() & B_CONTROL_KEY) == 0, (modifiers() & B_SHIFT_KEY) != 0); break; - + case B_PAGE_UP: - case B_PAGE_DOWN: { + case B_PAGE_DOWN: + { float minValue, maxValue; fVerticalScrollBar->GetRange(&minValue, &maxValue); float smallStep, largeStep; fVerticalScrollBar->GetSteps(&smallStep, &largeStep); float currentValue = fVerticalScrollBar->Value(); float newValue = currentValue; - + if (c == B_PAGE_UP) newValue -= largeStep; else newValue += largeStep; - + if (newValue > maxValue) newValue = maxValue; else if (newValue < minValue) newValue = minValue; - + fVerticalScrollBar->SetValue(newValue); // Option + pgup or pgdn scrolls and changes the selection. if (modifiers() & B_OPTION_KEY) fOutlineView->MoveFocusToVisibleRect(); - + break; } - + case B_ENTER: Invoke(); break; case B_SPACE: - fOutlineView->ToggleFocusRowSelection((modifiers() & B_SHIFT_KEY) != 0); + fOutlineView->ToggleFocusRowSelection( + (modifiers() & B_SHIFT_KEY) != 0); break; case '+': - fOutlineView->ToggleFocusRowOpen(); + fOutlineView->ToggleFocusRowOpen(); break; default: @@ -1476,15 +1721,19 @@ } } -void BColumnListView::AttachedToWindow() + +void +BColumnListView::AttachedToWindow() { if (!Messenger().IsValid()) SetTarget(Window()); - - if (SortingEnabled()) fOutlineView->StartSorting(); + + if (SortingEnabled()) fOutlineView->StartSorting(); } -void BColumnListView::WindowActivated(bool active) + +void +BColumnListView::WindowActivated(bool active) { fOutlineView->Invalidate(); // Focus and selection appearance changes with focus @@ -1493,23 +1742,59 @@ BView::WindowActivated(active); } -void BColumnListView::Draw(BRect) + +void +BColumnListView::Draw(BRect updateRect) { BRect rect = Bounds(); - PushState(); - BRect cornerRect(rect.right - B_V_SCROLL_BAR_WIDTH, rect.bottom - B_H_SCROLL_BAR_HEIGHT, - rect.right, rect.bottom); + if (be_control_look != NULL) { + uint32 flags = 0; + if (IsFocus() && Window()->IsActive()) + flags |= BControlLook::B_FOCUSED; + + rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR); + + BRect verticalScrollBarFrame; + if (!fVerticalScrollBar->IsHidden()) + verticalScrollBarFrame = fVerticalScrollBar->Frame(); + BRect horizontalScrollBarFrame; + if (!fHorizontalScrollBar->IsHidden()) + horizontalScrollBarFrame = fHorizontalScrollBar->Frame(); + + if (fBorderStyle == B_NO_BORDER) { + // We still draw the left/top border, but not focused. + // The scrollbars cannot be displayed without frame and + // it looks bad to have no frame only along the left/top + // side. + rgb_color borderColor = tint_color(base, B_DARKEN_2_TINT); + SetHighColor(borderColor); + StrokeLine(BPoint(rect.left, rect.bottom), + BPoint(rect.left, rect.top)); + StrokeLine(BPoint(rect.left + 1, rect.top), + BPoint(rect.right, rect.top)); + } + + be_control_look->DrawScrollViewFrame(this, rect, updateRect, + verticalScrollBarFrame, horizontalScrollBarFrame, + base, fBorderStyle, flags); + + return; + } + + BRect cornerRect(rect.right - B_V_SCROLL_BAR_WIDTH, + rect.bottom - B_H_SCROLL_BAR_HEIGHT, rect.right, rect.bottom); if (fBorderStyle == B_PLAIN_BORDER) { - BView::SetHighColor(0, 0, 0); + BView::SetHighColor(0, 0, 0); StrokeRect(rect); - cornerRect.OffsetBy(-1, -1); + cornerRect.OffsetBy(-1, -1); } else if (fBorderStyle == B_FANCY_BORDER) { bool isFocus = IsFocus() && Window()->IsActive(); - if (isFocus) - BView::SetHighColor(0, 0, 190); // Need to find focus color programatically - else + if (isFocus) { + // TODO: Need to find focus color programatically + BView::SetHighColor(0, 0, 190); + } else BView::SetHighColor(255, 255, 255); StrokeRect(rect); @@ -1517,22 +1802,24 @@ BView::SetHighColor(184, 184, 184); else BView::SetHighColor(152, 152, 152); - + rect.InsetBy(1,1); StrokeRect(rect); cornerRect.OffsetBy(-2, -2); } - - BView::SetHighColor(215, 215, 215); // fills lower right rect between scroll bars + + BView::SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + // fills lower right rect between scroll bars FillRect(cornerRect); - PopState(); } -void BColumnListView::SaveState(BMessage *msg) + +void +BColumnListView::SaveState(BMessage* msg) { msg->MakeEmpty(); - for (int32 i = 0; BColumn *col = (BColumn*)fColumns.ItemAt(i); i++) { + for (int32 i = 0; BColumn* col = (BColumn*)fColumns.ItemAt(i); i++) { msg->AddInt32("ID",col->fFieldID); msg->AddFloat("width", col->fWidth); msg->AddBool("visible", col->fVisible); @@ -1541,7 +1828,7 @@ msg->AddBool("sortingenabled", fSortingEnabled); if (fSortingEnabled) { - for (int32 i = 0; BColumn *col = (BColumn*)fSortColumns.ItemAt(i); + for (int32 i = 0; BColumn* col = (BColumn*)fSortColumns.ItemAt(i); i++) { msg->AddInt32("sortID", col->fFieldID); msg->AddBool("sortascending", col->fSortAscending); @@ -1549,7 +1836,9 @@ } } -void BColumnListView::LoadState(BMessage *msg) + +void +BColumnListView::LoadState(BMessage* msg) { int32 id; for (int i = 0; msg->FindInt32("ID", i, &id) == B_OK; i++) { @@ -1583,13 +1872,17 @@ } } -void BColumnListView::SetEditMode(bool state) + +void +BColumnListView::SetEditMode(bool state) { fOutlineView->SetEditMode(state); fTitleView->SetEditMode(state); } -void BColumnListView::Refresh() + +void +BColumnListView::Refresh() { if (L... [truncated message content] |