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/scroll_label.hpp"
00019
00020 #include "gui/widgets/label.hpp"
00021 #include "gui/auxiliary/log.hpp"
00022 #include "gui/auxiliary/widget_definition/scroll_label.hpp"
00023 #include "gui/auxiliary/window_builder/scroll_label.hpp"
00024 #include "gui/widgets/settings.hpp"
00025 #include "gui/widgets/scrollbar.hpp"
00026 #include "gui/widgets/spacer.hpp"
00027 #include "gui/widgets/window.hpp"
00028
00029 #include <boost/bind.hpp>
00030
00031 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
00032 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
00033
00034 namespace gui2 {
00035
00036 REGISTER_WIDGET(scroll_label)
00037
00038 tscroll_label::tscroll_label()
00039 : tscrollbar_container(COUNT)
00040 , state_(ENABLED)
00041 {
00042 connect_signal<event::LEFT_BUTTON_DOWN>(
00043 boost::bind(
00044 &tscroll_label::signal_handler_left_button_down
00045 , this
00046 , _2)
00047 , event::tdispatcher::back_pre_child);
00048 }
00049
00050 void tscroll_label::set_label(const t_string& label)
00051 {
00052
00053 tcontrol::set_label(label);
00054
00055 if(content_grid()) {
00056 tlabel* widget =
00057 find_widget<tlabel>(content_grid(), "_label", false, true);
00058 widget->set_label(label);
00059
00060 content_resize_request();
00061 }
00062 }
00063
00064 void tscroll_label::set_use_markup(bool use_markup)
00065 {
00066
00067 tcontrol::set_use_markup(use_markup);
00068
00069 if(content_grid()) {
00070 tlabel* widget =
00071 find_widget<tlabel>(content_grid(), "_label", false, true);
00072 widget->set_use_markup(use_markup);
00073 }
00074 }
00075
00076 void tscroll_label::finalize_subclass()
00077 {
00078 assert(content_grid());
00079 tlabel* lbl = dynamic_cast<tlabel*>(
00080 content_grid()->find("_label", false));
00081
00082 assert(lbl);
00083 lbl->set_label(label());
00084
00085
00086
00087
00088
00089
00090 lbl->set_can_wrap(true);
00091 }
00092
00093 const std::string& tscroll_label::get_control_type() const
00094 {
00095 static const std::string type = "scroll_label";
00096 return type;
00097 }
00098
00099 void tscroll_label::signal_handler_left_button_down(const event::tevent event)
00100 {
00101 DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
00102
00103 get_window()->keyboard_capture(this);
00104 }
00105
00106 }
00107