gui/widgets/spacer.hpp

Go to the documentation of this file.
00001 /* $Id: spacer.hpp 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 #ifndef GUI_WIDGETS_SPACER_HPP_INCLUDED
00017 #define GUI_WIDGETS_SPACER_HPP_INCLUDED
00018 
00019 #include "gui/widgets/control.hpp"
00020 
00021 namespace gui2 {
00022 
00023 /**
00024  * An empty widget.
00025  *
00026  * Since every grid cell needs a widget this is a blank widget. This widget can
00027  * also be used to 'force' sizes.
00028  *
00029  * Since we're a kind of dummy class we're always active, our drawing does
00030  * nothing.
00031  */
00032 class tspacer : public tcontrol
00033 {
00034 public:
00035     tspacer() :
00036         tcontrol(0),
00037         best_size_(0, 0)
00038     {
00039     }
00040 
00041     /***** ***** ***** ***** layout functions ***** ***** ***** *****/
00042 
00043 private:
00044     /** Inherited from tcontrol. */
00045     tpoint calculate_best_size() const
00046     {
00047         return best_size_ != tpoint(0, 0)
00048             ? best_size_ : tcontrol::calculate_best_size();
00049     }
00050 public:
00051 
00052     /***** ***** ***** ***** Inherited ***** ***** ***** *****/
00053 
00054     /** Inherited from tcontrol. */
00055     void set_active(const bool) {}
00056 
00057     /** Inherited from tcontrol. */
00058     bool get_active() const { return true; }
00059 
00060     /** Inherited from tcontrol. */
00061     unsigned get_state() const { return 0; }
00062 
00063     /** Inherited from tcontrol. */
00064     bool disable_click_dismiss() const { return false; }
00065 
00066     /***** ***** ***** setters / getters for members ***** ****** *****/
00067 
00068     void set_best_size(const tpoint& best_size) { best_size_ = best_size; }
00069 
00070 private:
00071 
00072     /** When we're used as a fixed size item, this holds the best size. */
00073     tpoint best_size_;
00074 
00075     /**
00076      * Inherited from tcontrol.
00077      *
00078      * Since we're always empty the draw does nothing.
00079      */
00080     void impl_draw_background(surface& /*frame_buffer*/) {}
00081     void impl_draw_background(
00082               surface& /*frame_buffer*/
00083             , int /*x_offset*/
00084             , int /*y_offset*/) {}
00085 
00086     /** Inherited from tcontrol. */
00087     const std::string& get_control_type() const;
00088 };
00089 
00090 
00091 } // namespace gui2
00092 
00093 #endif
00094 
00095 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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