gui/widgets/panel.cpp

Go to the documentation of this file.
00001 /* $Id: panel.cpp 54007 2012-04-28 19:16:10Z mordante $ */
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/panel.hpp"
00019 
00020 #include "gui/auxiliary/log.hpp"
00021 #include "gui/auxiliary/widget_definition/panel.hpp"
00022 #include "gui/auxiliary/window_builder/panel.hpp"
00023 #include "gui/widgets/settings.hpp"
00024 
00025 #include <boost/bind.hpp>
00026 
00027 #define LOG_SCOPE_HEADER get_control_type() + " [" + id() + "] " + __func__
00028 #define LOG_HEADER LOG_SCOPE_HEADER + ':'
00029 
00030 namespace gui2 {
00031 
00032 REGISTER_WIDGET(panel)
00033 
00034 SDL_Rect tpanel::get_client_rect() const
00035 {
00036     boost::intrusive_ptr<const tpanel_definition::tresolution> conf =
00037         boost::dynamic_pointer_cast<const tpanel_definition::tresolution>(config());
00038     assert(conf);
00039 
00040     SDL_Rect result = get_rect();
00041     result.x += conf->left_border;
00042     result.y += conf->top_border;
00043     result.w -= conf->left_border + conf->right_border;
00044     result.h -= conf->top_border + conf->bottom_border;
00045 
00046     return result;
00047 }
00048 
00049 void tpanel::impl_draw_background(surface& frame_buffer)
00050 {
00051     DBG_GUI_D << LOG_HEADER
00052             << " size " << get_rect()
00053             << ".\n";
00054 
00055     canvas(0).blit(frame_buffer, get_rect());
00056 }
00057 
00058 void tpanel::impl_draw_background(
00059           surface& frame_buffer
00060         , int x_offset
00061         , int y_offset)
00062 {
00063     DBG_GUI_D << LOG_HEADER
00064             << " size " << get_rect()
00065             << ".\n";
00066 
00067     canvas(0).blit(
00068               frame_buffer
00069             , calculate_blitting_rectangle(x_offset, y_offset));
00070 }
00071 
00072 void tpanel::impl_draw_foreground(surface& frame_buffer)
00073 {
00074     canvas(1).blit(frame_buffer, get_rect());
00075 }
00076 
00077 void tpanel::impl_draw_foreground(
00078           surface& frame_buffer
00079         , int x_offset
00080         , int y_offset)
00081 {
00082     canvas(1).blit(
00083               frame_buffer
00084             , calculate_blitting_rectangle(x_offset, y_offset));
00085 }
00086 
00087 tpoint tpanel::border_space() const
00088 {
00089     boost::intrusive_ptr<const tpanel_definition::tresolution> conf =
00090         boost::dynamic_pointer_cast<const tpanel_definition::tresolution>(config());
00091     assert(conf);
00092 
00093     return tpoint(conf->left_border + conf->right_border,
00094         conf->top_border + conf->bottom_border);
00095 }
00096 
00097 const std::string& tpanel::get_control_type() const
00098 {
00099     static const std::string type = "panel";
00100     return type;
00101 }
00102 
00103 } // namespace gui2
00104 
 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