libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ElementDataGrid.h
Go to the documentation of this file.
1 /*
2  * This source file is part of libRocket, the HTML/CSS Interface Middleware
3  *
4  * For the latest information, see http://www.librocket.com
5  *
6  * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROCKETCONTROLSELEMENTDATAGRID_H
29 #define ROCKETCONTROLSELEMENTDATAGRID_H
30 
31 #include "Header.h"
32 #include "DataSourceListener.h"
33 #include "../Core/Element.h"
34 
35 namespace Rocket {
36 namespace Controls {
37 
38 class DataFormatter;
39 class ElementDataGridRow;
40 
48 {
49 public:
51  virtual ~ElementDataGrid();
52 
55  void SetDataSource(const Rocket::Core::String& data_source_name);
56 
62  struct Column
63  {
67 
74 
77 
82  };
83 
90  bool AddColumn(const Rocket::Core::String& fields, const Rocket::Core::String& formatter, float initial_width, const Rocket::Core::String& header_rml);
96  void AddColumn(const Rocket::Core::String& fields, const Rocket::Core::String& formatter, float initial_width, Core::Element* header_element);
98  int GetNumColumns();
100  const Column* GetColumn(int column_index);
102  const Rocket::Core::String& GetAllColumnFields();
103 
108  ElementDataGridRow* AddRow(ElementDataGridRow* parent, int index);
112  void RemoveRows(int index, int num_rows = 1);
113 
115  int GetNumRows() const;
118  ElementDataGridRow* GetRow(int index) const;
119 
120 protected:
121  virtual void OnUpdate();
122 
123  virtual void ProcessEvent(Core::Event& event);
124 
127  virtual void GetInnerRML(Rocket::Core::String& content) const;
128 
129 private:
130  typedef std::vector< Column > ColumnList;
131  typedef std::vector< ElementDataGridRow* > RowList;
132 
133  ColumnList columns;
134  Rocket::Core::String column_fields;
135 
136  // The row that contains the header elements of the table.
137  ElementDataGridRow* header;
138 
139  // The root row, all the top level rows are children under this. Not
140  // actually rendered, has "display: none".
141  ElementDataGridRow* root;
142  // If this is non-empty, then in the previous update the data source was set
143  // and we must set it this update.
144  Rocket::Core::String new_data_source;
145 
146  // The block element that contains all our rows. Only used for applying styles.
147  Core::Element* body;
148  // Stores if the body has already been made visible by having enough rows added.
149  bool body_visible;
150 };
151 
152 }
153 }
154 
155 #endif
Definition: Event.h:48
bool refresh_on_child_change
Definition: ElementDataGrid.h:81
Definition: ElementDataGrid.h:62
Definition: Clipboard.h:33
Definition: ElementDataGridRow.h:48
Definition: ElementDataGrid.h:47
Rocket::Core::StringList fields
Definition: ElementDataGrid.h:66
std::vector< String > StringList
Definition: String.h:41
DataFormatter * formatter
Definition: ElementDataGrid.h:70
Definition: DataFormatter.h:48
Core::Element * header
Definition: ElementDataGrid.h:73
#define ROCKETCONTROLS_API
Definition: Header.h:41
Definition: Element.h:71
float current_width
The width of this column.
Definition: ElementDataGrid.h:76
Definition: DataSourceListener.h:46