ElementDataGridRow.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ROCKETCONTROLSELEMENTDATAGRIDROW_H
00029 #define ROCKETCONTROLSELEMENTDATAGRIDROW_H
00030
00031 #include <Rocket/Controls/Header.h>
00032 #include <Rocket/Controls/DataSourceListener.h>
00033 #include <Rocket/Controls/DataQuery.h>
00034 #include <Rocket/Core/Element.h>
00035 #include <queue>
00036
00037 namespace Rocket {
00038 namespace Controls {
00039
00040 class ElementDataGrid;
00041
00048 class ROCKETCONTROLS_API ElementDataGridRow : public Core::Element, public DataSourceListener
00049 {
00050 friend class ElementDataGrid;
00051
00052 public:
00053 ElementDataGridRow(const Rocket::Core::String& tag);
00054 virtual ~ElementDataGridRow();
00055
00056 void Initialise(ElementDataGrid* parent_grid, ElementDataGridRow* parent_row = NULL, int child_index = -1, ElementDataGridRow* header_row = NULL, int depth = -1);
00057 void SetChildIndex(int child_index);
00058 int GetDepth();
00059
00060 void SetDataSource(const Rocket::Core::String& data_source_name);
00061
00064 bool UpdateChildren();
00065
00067 int GetNumLoadedChildren();
00068
00069
00070
00071 void RefreshRows();
00072
00074 bool IsRowExpanded();
00076 void ExpandRow();
00078 void CollapseRow();
00080 void ToggleRow();
00081
00083 int GetParentRelativeIndex();
00085 int GetTableRelativeIndex();
00087 ElementDataGridRow* GetParentRow();
00089 ElementDataGrid* GetParentGrid();
00090
00091 protected:
00092 virtual void OnDataSourceDestroy(DataSource* data_source);
00093 virtual void OnRowAdd(DataSource* data_source, const Rocket::Core::String& table, int first_row_added, int num_rows_added);
00094 virtual void OnRowRemove(DataSource* data_source, const Rocket::Core::String& table, int first_row_removed, int num_rows_removed);
00095 virtual void OnRowChange(DataSource* data_source, const Rocket::Core::String& table, int first_row_changed, int num_rows_changed);
00096 virtual void OnRowChange(DataSource* data_source, const Rocket::Core::String& table);
00097
00098 private:
00099 typedef std::queue< ElementDataGridRow* > RowQueue;
00100 typedef std::vector< ElementDataGridRow* > RowList;
00101
00102
00103
00104
00105 void ChildChanged(int child_index);
00106
00107
00108 void RefreshChildDependentCells();
00109
00110
00111
00112 void DirtyTableRelativeIndex();
00113
00114 int GetChildTableRelativeIndex(int child_index);
00115
00116
00117
00118
00119 void AddChildren(int first_row_added = -1, int num_rows_added = 1);
00120
00121
00122
00123 void RemoveChildren(int first_row_removed = 0, int num_rows_removed = -1);
00124
00125 int GetNumDescendants();
00126
00127
00128 void Load(const Rocket::Controls::DataQuery& row_information);
00129
00130
00131 void LoadChildren(float time_slice);
00132
00133 void LoadChildren(int first_row_to_load, int num_rows_to_load, Rocket::Core::Time time_slice);
00134
00135
00136
00137 void UpdateCellsAndChildren(RowQueue& dirty_rows);
00138
00139
00140 void DirtyCells();
00141
00142 void DirtyRow();
00143
00144 bool dirty_cells;
00145
00146 bool dirty_children;
00147
00148
00149 void Show();
00150
00151 void Hide();
00152 bool row_expanded;
00153
00154 int table_relative_index;
00155 bool table_relative_index_dirty;
00156
00157 ElementDataGrid* parent_grid;
00158
00159 ElementDataGridRow* parent_row;
00160 int child_index;
00161 int depth;
00162
00163 RowList children;
00164
00165
00166 DataSource* data_source;
00167 Rocket::Core::String data_table;
00168 };
00169
00170 }
00171 }
00172
00173 #endif