GG

GroupBox.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* GG is a GUI for SDL and OpenGL.
00003    Copyright (C) 2003-2008 T. Zachary Laine
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License
00007    as published by the Free Software Foundation; either version 2.1
00008    of the License, or (at your option) any later version.
00009    
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014     
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA
00019 
00020    If you do not wish to comply with the terms of the LGPL please
00021    contact the author as other terms are available for a fee.
00022     
00023    Zach Laine
00024    whatwasthataddress@gmail.com */
00025 
00029 #ifndef _GG_GroupBox_h_
00030 #define _GG_GroupBox_h_
00031 
00032 #include <GG/ClrConstants.h>
00033 #include <GG/Wnd.h>
00034 
00035 
00036 namespace GG {
00037 
00038 class Font;
00039 class TextControl;
00040 
00042 class GG_API GroupBox : public Wnd
00043 {
00044 public: 
00046 
00047     GroupBox(X x, Y y, X w, Y h, const std::string& label, const boost::shared_ptr<Font>& font, Clr color,
00048              Clr text_color = CLR_BLACK, Clr interior = CLR_ZERO, Flags<WndFlag> flags = Flags<WndFlag>());
00050  
00052     virtual Pt ClientUpperLeft() const;
00053     virtual Pt ClientLowerRight() const;
00055  
00057     virtual void Render();
00058 
00060     void SetColor(Clr c);
00061 
00063     void SetTextColor(Clr c);
00064 
00066     void SetInteriorColor(Clr c);
00067 
00073     void SetClientCornersEqualToBoxCorners(bool b);
00074 
00075     virtual void SetText(const std::string& str);
00077 
00078 protected: 
00080     GroupBox(); 
00081 
00082 
00084     static const int FRAME_THICK;
00085 
00088     static const int PIXEL_MARGIN;
00089 
00090 private:
00091     Clr                     m_color;      
00092     Clr                     m_text_color; 
00093     Clr                     m_int_color;  
00094     boost::shared_ptr<Font> m_font;
00095     TextControl*            m_label;
00096     bool                    m_set_client_corners_equal_to_box_corners;
00097 
00098     friend class boost::serialization::access;
00099     template <class Archive>
00100     void serialize(Archive& ar, const unsigned int version);
00101 };
00102 
00103 } // namespace GG
00104 
00105 // template implementations
00106 template <class Archive>
00107 void GG::GroupBox::serialize(Archive& ar, const unsigned int version)
00108 {
00109     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Wnd)
00110         & BOOST_SERIALIZATION_NVP(m_color)
00111         & BOOST_SERIALIZATION_NVP(m_text_color)
00112         & BOOST_SERIALIZATION_NVP(m_int_color)
00113         & BOOST_SERIALIZATION_NVP(m_label);
00114 }
00115 
00116 #endif // _GG_GroupBox_h_