1 // -*- C++ -*-
2 /* GG is a GUI for OpenGL.
3    Copyright (C) 2003-2008 T. Zachary Laine
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public License
7    as published by the Free Software Foundation; either version 2.1
8    of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with this library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA
19 
20    If you do not wish to comply with the terms of the LGPL please
21    contact the author as other terms are available for a fee.
22 
23    Zach Laine
24    whatwasthataddress@gmail.com */
25 
26 /** \file GroupBox.h \brief Contains the GroupBox class, a simple,
27     noninteractive box with an optional label. */
28 
29 #ifndef _GG_GroupBox_h_
30 #define _GG_GroupBox_h_
31 
32 #include <GG/ClrConstants.h>
33 #include <GG/Wnd.h>
34 
35 
36 namespace GG {
37 
38 class Font;
39 class TextControl;
40 
41 /** \brief This is a noninteractive box with an optional label. */
42 class GG_API GroupBox : public Wnd
43 {
44 public:
45     /** \name Structors */ ///@{
46     /** Height is determined from the font and point size used. */
47     GroupBox(X x, Y y, X w, Y h, const std::string& label, const std::shared_ptr<Font>& font, Clr color,
48              Clr text_color = CLR_BLACK, Clr interior = CLR_ZERO, Flags<WndFlag> flags = NO_WND_FLAGS);
49     //@}
50     void CompleteConstruction() override;
51 
52     /** \name Accessors */ ///@{
53     Pt ClientUpperLeft() const override;
54     Pt ClientLowerRight() const override;
55     //@}
56 
57     /** \name Mutators */ ///@{
58     void Render() override;
59 
60     /** Sets the color of the group box. */
61     void SetColor(Clr c);
62 
63     /** Sets the color of the label's text. */
64     void SetTextColor(Clr c);
65 
66     /** Sets the interior color of the box. */
67     void SetInteriorColor(Clr c);
68 
69     /** Setting this to true causes ClientUpperLeft() and ClientLowerRight()
70         to return UpperLeft() and LowerRight(), respectively.  This is a
71         horrible hack that is designed to allow the Eve layout engine to set
72         this box's children at their desired locations without knowing
73         anything about how GG Wnd client areas work. */
74     void SetClientCornersEqualToBoxCorners(bool b);
75 
76     virtual void SetText(const std::string& str);
77     //@}
78 
79 protected:
80     /** \name Structors */ ///@{
81     GroupBox();
82     //@}
83 
84     /** The thickness with which to render the frame. */
85     static const int FRAME_THICK;
86 
87     /** The number of pixels to leave between the client area and the
88         frame. */
89     static const int PIXEL_MARGIN;
90 
91 private:
92     Clr                             m_color;      ///< Color of box frame
93     Clr                             m_text_color; ///< Color of label text
94     Clr                             m_int_color;  ///< Color of background inside box
95     std::shared_ptr<Font>           m_font;
96     std::shared_ptr<TextControl>    m_label;
97     bool                            m_set_client_corners_equal_to_box_corners = false;
98 };
99 
100 } // namespace GG
101 
102 #endif
103