panel.cpp

Go to the documentation of this file.
00001 /* $Id: panel.cpp 26774 2008-05-22 16:30:51Z mordante $ */
00002 /*
00003    copyright (C) 2008 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 version 2
00008    or at your option any later version.
00009    this program is distributed in the hope that it will be useful,
00010    but without any warranty.
00011 
00012    see the copying file for more details.
00013 */
00014 
00015 #include "gui/widgets/panel.hpp"
00016 
00017 #include "log.hpp"
00018 
00019 #define DBG_G LOG_STREAM_INDENT(debug, gui)
00020 #define LOG_G LOG_STREAM_INDENT(info, gui)
00021 #define WRN_G LOG_STREAM_INDENT(warn, gui)
00022 #define ERR_G LOG_STREAM_INDENT(err, gui)
00023 
00024 #define DBG_G_D LOG_STREAM_INDENT(debug, gui_draw)
00025 #define LOG_G_D LOG_STREAM_INDENT(info, gui_draw)
00026 #define WRN_G_D LOG_STREAM_INDENT(warn, gui_draw)
00027 #define ERR_G_D LOG_STREAM_INDENT(err, gui_draw)
00028 
00029 #define DBG_G_E LOG_STREAM_INDENT(debug, gui_event)
00030 #define LOG_G_E LOG_STREAM_INDENT(info, gui_event)
00031 #define WRN_G_E LOG_STREAM_INDENT(warn, gui_event)
00032 #define ERR_G_E LOG_STREAM_INDENT(err, gui_event)
00033 
00034 #define DBG_G_P LOG_STREAM_INDENT(debug, gui_parse)
00035 #define LOG_G_P LOG_STREAM_INDENT(info, gui_parse)
00036 #define WRN_G_P LOG_STREAM_INDENT(warn, gui_parse)
00037 #define ERR_G_P LOG_STREAM_INDENT(err, gui_parse)
00038 
00039 namespace gui2 {
00040 
00041 void tpanel::draw(surface& surface)
00042 {
00043     // Need to preserve the state and inherited draw clear the flag.
00044     const bool is_dirty = dirty();
00045 
00046     tcontainer_::draw(surface);
00047 
00048     // foreground
00049     if(is_dirty) {
00050         SDL_Rect rect = get_rect();
00051         canvas(1).draw(true);
00052         blit_surface(canvas(1).surf(), 0, surface, &rect);
00053     }
00054 }
00055 
00056 SDL_Rect tpanel::get_client_rect() const
00057 {
00058     const tpanel_definition::tresolution* conf = 
00059         dynamic_cast<const tpanel_definition::tresolution*>(config());
00060     assert(conf);
00061 
00062     SDL_Rect result = get_rect();
00063     result.x += conf->left_border;
00064     result.y += conf->top_border;
00065     result.w -= conf->left_border + conf->right_border;
00066     result.h -= conf->top_border + conf->bottom_border;
00067 
00068     return result;
00069 }
00070 
00071 tpoint tpanel::border_space() const
00072 {
00073     const tpanel_definition::tresolution* conf = 
00074         dynamic_cast<const tpanel_definition::tresolution*>(config());
00075     assert(conf);
00076 
00077     return tpoint(conf->left_border + conf->right_border,
00078         conf->top_border + conf->bottom_border);
00079 }
00080 
00081 } // namespace gui2
00082 

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs