gui/widgets/scroll_label.cpp

Go to the documentation of this file.
00001 /* $Id: scroll_label.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Mark de Wever <koraq@xs4all.nl>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
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     // Inherit.
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     // Inherit.
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      * @todo wrapping should be a label setting.
00087      * This setting shoul be mutual exclusive with the horizontal scrollbar.
00088      * Also the scroll_grid needs to set the status for the scrollbars.
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 } // namespace gui2
00107 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:55 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs