gui/widgets/drawing.hpp

Go to the documentation of this file.
00001 /* $Id: drawing.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2010 - 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_DRAWING_HPP_INCLUDED
00017 #define GUI_WIDGETS_DRAWING_HPP_INCLUDED
00018 
00019 #include "gui/widgets/control.hpp"
00020 
00021 namespace gui2 {
00022 
00023 /**
00024  * A widget to draw upon.
00025  *
00026  * This widget has a fixed size like the spacer, but allows the user to
00027  * manual draw items. The widget is display only.
00028  */
00029 class tdrawing
00030     : public tcontrol
00031 {
00032 public:
00033     tdrawing()
00034         : tcontrol(COUNT)
00035         , best_size_(0, 0)
00036     {
00037     }
00038 
00039     /***** ***** ***** ***** layout functions ***** ***** ***** *****/
00040 
00041 private:
00042     /** Inherited from tcontrol. */
00043     tpoint calculate_best_size() const
00044     {
00045         return best_size_ != tpoint(0, 0)
00046             ? best_size_ : tcontrol::calculate_best_size();
00047     }
00048 public:
00049 
00050     /***** ***** ***** ***** Inherited ***** ***** ***** *****/
00051 
00052     /** Inherited from tcontrol. */
00053     void set_active(const bool) {}
00054 
00055     /** Inherited from tcontrol. */
00056     bool get_active() const { return true; }
00057 
00058     /** Inherited from tcontrol. */
00059     unsigned get_state() const { return 0; }
00060 
00061     /** Inherited from tcontrol. */
00062     bool disable_click_dismiss() const { return false; }
00063 
00064     /***** ***** ***** setters / getters for members ***** ****** *****/
00065 
00066     void set_best_size(const tpoint& best_size) { best_size_ = best_size; }
00067 
00068 private:
00069 
00070     /**
00071      * Possible states of the widget.
00072      *
00073      * Note the order of the states must be the same as defined in
00074      * settings.hpp.
00075      */
00076     enum tstate { ENABLED, COUNT };
00077 
00078     /** When we're used as a fixed size item, this holds the best size. */
00079     tpoint best_size_;
00080 
00081     /** Inherited from tcontrol. */
00082     const std::string& get_control_type() const;
00083 };
00084 
00085 
00086 } // namespace gui2
00087 
00088 #endif
00089 
00090 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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