2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef ABSTRACT_TABLE_H
6 #define ABSTRACT_TABLE_H
8 #include <ObjectList.h>
9 #include <ColumnListView.h>
15 class AbstractTableModelBase
{
17 virtual ~AbstractTableModelBase();
19 virtual int32
CountColumns() const = 0;
23 // NOTE: Intention is to inherit from "protected BColumnListView", but GCC2
24 // has problems dynamic_casting a BHandler pointer to a BView then...
25 class AbstractTable
: public BColumnListView
{
27 AbstractTable(const char* name
, uint32 flags
,
28 border_style borderStyle
= B_NO_BORDER
,
29 bool showHorizontalScrollbar
= true);
30 virtual ~AbstractTable();
32 BView
* ToView() { return this; }
34 virtual void AddColumn(TableColumn
* column
);
35 void ResizeColumnToPreferred(int32 index
);
36 void ResizeAllColumnsToPreferred();
38 list_view_type
SelectionMode() const;
39 void SetSelectionMode(list_view_type type
);
42 void SetSortingEnabled(bool enabled
);
43 bool SortingEnabled() const;
44 void SetSortColumn(TableColumn
* column
, bool add
,
46 void ClearSortColumns();
50 friend class AbstractColumn
;
52 typedef BObjectList
<AbstractColumn
> ColumnList
;
55 virtual AbstractColumn
* CreateColumn(TableColumn
* column
) = 0;
57 virtual void ColumnMouseDown(AbstractColumn
* column
,
58 BRow
* row
, BField
* field
, BPoint point
,
60 virtual void ColumnMouseUp(AbstractColumn
* column
,
61 BRow
* row
, BField
* field
, BPoint point
,
64 AbstractColumn
* GetColumn(TableColumn
* column
) const;
71 // implementation private
73 class AbstractTable::AbstractColumn
: public BColumn
{
75 AbstractColumn(TableColumn
* tableColumn
);
76 virtual ~AbstractColumn();
78 void SetTable(AbstractTable
* table
);
80 virtual void SetModel(AbstractTableModelBase
* model
) = 0;
82 TableColumn
* GetTableColumn() const { return fTableColumn
; }
84 virtual void MouseDown(BColumnListView
* parent
, BRow
* row
,
85 BField
* field
, BRect fieldRect
,
86 BPoint point
, uint32 buttons
);
87 virtual void MouseUp(BColumnListView
* parent
, BRow
* row
,
91 TableColumn
* fTableColumn
;
92 AbstractTable
* fTable
;
96 #endif // ABSTRACT_TABLE_H