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/auxiliary/window_builder/scrollbar_panel.hpp"
00019
00020 #include "config.hpp"
00021 #include "gettext.hpp"
00022 #include "gui/auxiliary/log.hpp"
00023 #include "gui/auxiliary/widget_definition/scrollbar_panel.hpp"
00024 #include "gui/auxiliary/window_builder/helper.hpp"
00025 #include "gui/widgets/scrollbar_panel.hpp"
00026 #include "wml_exception.hpp"
00027
00028 namespace gui2 {
00029
00030 namespace implementation {
00031
00032 tbuilder_scrollbar_panel::tbuilder_scrollbar_panel(const config& cfg)
00033 : tbuilder_control(cfg)
00034 , vertical_scrollbar_mode(
00035 get_scrollbar_mode(cfg["vertical_scrollbar_mode"]))
00036 , horizontal_scrollbar_mode(
00037 get_scrollbar_mode(cfg["horizontal_scrollbar_mode"]))
00038 , grid(NULL)
00039 {
00040 const config &definition = cfg.child("definition");
00041
00042 VALIDATE(definition, _("No list defined."));
00043 grid = new tbuilder_grid(definition);
00044 assert(grid);
00045 }
00046
00047 twidget* tbuilder_scrollbar_panel::build() const
00048 {
00049 tscrollbar_panel *widget = new tscrollbar_panel();
00050
00051 init_control(widget);
00052
00053 widget->set_vertical_scrollbar_mode(vertical_scrollbar_mode);
00054 widget->set_horizontal_scrollbar_mode(horizontal_scrollbar_mode);
00055
00056 DBG_GUI_G << "Window builder: placed scrollbar_panel '"
00057 << id << "' with definition '"
00058 << definition << "'.\n";
00059
00060 boost::intrusive_ptr<
00061 const tscrollbar_panel_definition::tresolution> conf =
00062 boost::dynamic_pointer_cast
00063 <const tscrollbar_panel_definition::tresolution>
00064 (widget->config());
00065 assert(conf);
00066
00067 widget->init_grid(conf->grid);
00068 widget->finalize_setup();
00069
00070
00071 tgrid* content_grid = widget->content_grid();
00072 assert(content_grid);
00073
00074 const unsigned rows = grid->rows;
00075 const unsigned cols = grid->cols;
00076
00077 content_grid->set_rows_cols(rows, cols);
00078
00079 for(unsigned x = 0; x < rows; ++x) {
00080 content_grid->set_row_grow_factor(x, grid->row_grow_factor[x]);
00081 for(unsigned y = 0; y < cols; ++y) {
00082
00083 if(x == 0) {
00084 content_grid->set_column_grow_factor(y
00085 , grid->col_grow_factor[y]);
00086 }
00087
00088 twidget* widget = grid->widgets[x * cols + y]->build();
00089 content_grid->set_child(widget
00090 , x
00091 , y
00092 , grid->flags[x * cols + y]
00093 , grid->border_size[x * cols + y]);
00094 }
00095 }
00096
00097 return widget;
00098 }
00099
00100 }
00101
00102 }
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132