Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #define GETTEXT_DOMAIN "wesnoth-lib"
00017
00018 #include "gui/widgets/container.hpp"
00019
00020 #include "gui/auxiliary/log.hpp"
00021
00022 #define LOG_SCOPE_HEADER "tcontainer(" + get_control_type() + ") [" \
00023 + id() + "] " + __func__
00024 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
00025
00026 namespace gui2 {
00027
00028 void tcontainer_::layout_init(const bool full_initialization)
00029 {
00030
00031 tcontrol::layout_init(full_initialization);
00032
00033 grid_.layout_init(full_initialization);
00034 }
00035
00036 void tcontainer_::reduce_width(const unsigned maximum_width)
00037 {
00038 grid_.reduce_width(maximum_width - border_space().x);
00039 }
00040
00041 void tcontainer_::request_reduce_width(const unsigned maximum_width)
00042 {
00043 grid_.request_reduce_width(maximum_width - border_space().x);
00044 }
00045
00046 void tcontainer_::demand_reduce_width(const unsigned maximum_width)
00047 {
00048 grid_.demand_reduce_width(maximum_width - border_space().x);
00049 }
00050
00051 void tcontainer_::reduce_height(const unsigned maximum_height)
00052 {
00053 grid_.reduce_height(maximum_height - border_space().y);
00054 }
00055
00056 void tcontainer_::request_reduce_height(const unsigned maximum_height)
00057 {
00058 grid_.request_reduce_height(maximum_height - border_space().y);
00059 }
00060
00061 void tcontainer_::demand_reduce_height(const unsigned maximum_height)
00062 {
00063 grid_.demand_reduce_height(maximum_height - border_space().y);
00064 }
00065
00066 void tcontainer_::place(const tpoint& origin, const tpoint& size)
00067 {
00068 tcontrol::place(origin, size);
00069
00070 const SDL_Rect rect = get_client_rect();
00071 const tpoint client_size(rect.w, rect.h);
00072 const tpoint client_position(rect.x, rect.y);
00073 grid_.place(client_position, client_size);
00074 }
00075
00076 tpoint tcontainer_::calculate_best_size() const
00077 {
00078 log_scope2(log_gui_layout, LOG_SCOPE_HEADER);
00079
00080 tpoint result(grid_.get_best_size());
00081 const tpoint border_size = border_space();
00082
00083
00084
00085 if(result.x) {
00086 result.x += border_size.x;
00087 }
00088
00089 if(result.y) {
00090 result.y += border_size.y;
00091 }
00092
00093 DBG_GUI_L << LOG_HEADER
00094 << " border size " << border_size
00095 << " returning " << result
00096 << ".\n";
00097
00098 return result;
00099 }
00100
00101 void tcontainer_::set_origin(const tpoint& origin)
00102 {
00103
00104 twidget::set_origin(origin);
00105
00106 const SDL_Rect rect = get_client_rect();
00107 const tpoint client_position(rect.x, rect.y);
00108 grid_.set_origin(client_position);
00109 }
00110
00111 void tcontainer_::set_visible_area(const SDL_Rect& area)
00112 {
00113
00114 twidget::set_visible_area(area);
00115
00116 grid_.set_visible_area(area);
00117 }
00118
00119 void tcontainer_::impl_draw_children(surface& frame_buffer)
00120 {
00121 assert(get_visible() == twidget::VISIBLE
00122 && grid_.get_visible() == twidget::VISIBLE);
00123
00124 grid_.draw_children(frame_buffer);
00125 }
00126
00127 void tcontainer_::impl_draw_children(
00128 surface& frame_buffer
00129 , int x_offset
00130 , int y_offset)
00131 {
00132 assert(get_visible() == twidget::VISIBLE
00133 && grid_.get_visible() == twidget::VISIBLE);
00134
00135 grid_.draw_children(frame_buffer, x_offset, y_offset);
00136 }
00137
00138 void tcontainer_::layout_children()
00139 {
00140 grid_.layout_children();
00141 }
00142
00143 void tcontainer_::child_populate_dirty_list(twindow& caller,
00144 const std::vector<twidget*>& call_stack)
00145 {
00146 std::vector<twidget*> child_call_stack = call_stack;
00147 grid_.populate_dirty_list(caller, child_call_stack);
00148 }
00149
00150 void tcontainer_::set_active(const bool active)
00151 {
00152
00153
00154 grid_.set_active(active);
00155
00156 if(active == get_active()) {
00157 return;
00158 }
00159
00160 set_dirty();
00161
00162 set_self_active(active);
00163 }
00164
00165 bool tcontainer_::disable_click_dismiss() const
00166 {
00167 return tcontrol::disable_click_dismiss() && grid_.disable_click_dismiss();
00168 }
00169
00170 void tcontainer_::init_grid(
00171 const boost::intrusive_ptr<tbuilder_grid>& grid_builder)
00172 {
00173 log_scope2(log_gui_general, LOG_SCOPE_HEADER);
00174
00175 assert(initial_grid().get_rows() == 0 && initial_grid().get_cols() == 0);
00176
00177 grid_builder->build(&initial_grid());
00178 }
00179
00180 }
00181