Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GUI_WIDGETS_CONTAINER_HPP_INCLUDED
00017 #define GUI_WIDGETS_CONTAINER_HPP_INCLUDED
00018
00019 #include "gui/widgets/grid.hpp"
00020 #include "gui/widgets/control.hpp"
00021 #include "gui/auxiliary/window_builder.hpp"
00022
00023 namespace gui2 {
00024
00025
00026
00027
00028
00029
00030
00031
00032 class tcontainer_ : public tcontrol
00033 {
00034 friend class tdebug_layout_graph;
00035 public:
00036 explicit tcontainer_(const unsigned canvas_count) :
00037 tcontrol(canvas_count),
00038 grid_()
00039 {
00040 grid_.set_parent(this);
00041 }
00042
00043
00044
00045
00046
00047
00048 virtual SDL_Rect get_client_rect() const { return get_rect(); }
00049
00050
00051
00052
00053 void layout_init(const bool full_initialization);
00054
00055
00056
00057
00058
00059
00060
00061
00062 void reduce_width(const unsigned maximum_width);
00063
00064
00065 void request_reduce_width(const unsigned maximum_width);
00066
00067
00068 void demand_reduce_width(const unsigned maximum_width);
00069
00070
00071
00072
00073
00074
00075
00076
00077 void reduce_height(const unsigned maximum_height);
00078
00079
00080 void request_reduce_height(const unsigned maximum_height);
00081
00082
00083 void demand_reduce_height(const unsigned maximum_height);
00084
00085 private:
00086
00087 tpoint calculate_best_size() const;
00088 public:
00089
00090
00091 bool can_wrap() const { return grid_.can_wrap() || twidget::can_wrap(); }
00092
00093
00094 void place(const tpoint& origin, const tpoint& size);
00095
00096
00097
00098
00099 bool has_widget(const twidget* widget) const
00100 { return twidget::has_widget(widget) || grid_.has_widget(widget); }
00101
00102
00103 void set_origin(const tpoint& origin);
00104
00105
00106 void set_visible_area(const SDL_Rect& area);
00107
00108
00109 void impl_draw_children(surface& frame_buffer);
00110 void impl_draw_children(surface& frame_buffer, int x_offset, int y_offset);
00111
00112 protected:
00113
00114
00115 void layout_children();
00116
00117
00118 void child_populate_dirty_list(twindow& caller,
00119 const std::vector<twidget*>& call_stack);
00120
00121 public:
00122
00123
00124 twidget* find_at(const tpoint& coordinate, const bool must_be_active)
00125 { return grid_.find_at(coordinate, must_be_active); }
00126
00127
00128 const twidget* find_at(const tpoint& coordinate,
00129 const bool must_be_active) const
00130 { return grid_.find_at(coordinate, must_be_active); }
00131
00132
00133 twidget* find(const std::string& id, const bool must_be_active)
00134 {
00135 twidget* result = tcontrol::find(id, must_be_active);
00136 return result ? result : grid_.find(id, must_be_active);
00137 }
00138
00139
00140 const twidget* find(const std::string& id, const bool must_be_active) const
00141 {
00142 const twidget* result = tcontrol::find(id, must_be_active);
00143 return result ? result : grid_.find(id, must_be_active);
00144 }
00145
00146
00147 void set_active(const bool active);
00148
00149
00150 bool disable_click_dismiss() const;
00151
00152
00153
00154
00155
00156
00157 virtual iterator::twalker_* create_walker() { return NULL; }
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 void init_grid(const boost::intrusive_ptr<tbuilder_grid>& grid_builder);
00168
00169
00170
00171 tgrid::iterator begin() { return grid_.begin(); }
00172 tgrid::iterator end() { return grid_.end(); }
00173
00174 unsigned add_row(const unsigned count = 1)
00175 { return grid_.add_row(count); }
00176
00177 void set_rows(const unsigned rows) { grid_.set_rows(rows); }
00178 unsigned int get_rows() const { return grid_.get_rows(); }
00179
00180 void set_cols(const unsigned cols) { grid_.set_cols(cols); }
00181 unsigned int get_cols() const { return grid_.get_cols(); }
00182
00183 void set_rows_cols(const unsigned rows, const unsigned cols)
00184 { grid_.set_rows_cols(rows, cols); }
00185
00186 void set_child(twidget* widget, const unsigned row,
00187 const unsigned col, const unsigned flags, const unsigned border_size)
00188 { grid_.set_child(widget, row, col, flags, border_size); }
00189
00190 void set_row_grow_factor(const unsigned row, const unsigned factor)
00191 { grid_.set_row_grow_factor(row, factor); }
00192
00193 void set_column_grow_factor(const unsigned column, const unsigned factor)
00194 { grid_.set_column_grow_factor(column, factor); }
00195
00196 public:
00197
00198
00199
00200
00201 const tgrid& grid() const { return grid_; }
00202 tgrid& grid() { return grid_; }
00203
00204 private:
00205
00206
00207 tgrid grid_;
00208
00209
00210
00211
00212
00213
00214 virtual tgrid& initial_grid() { return grid_; }
00215
00216
00217 virtual tpoint border_space() const { return tpoint(0, 0); }
00218
00219
00220
00221
00222
00223
00224
00225
00226 virtual void set_self_active(const bool active) = 0;
00227 };
00228
00229 }
00230
00231 #endif
00232