GG
BrowseInfoWnd.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /* GG is a GUI for SDL and 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 
30 #ifndef _GG_BrowseInfoWnd_h_
31 #define _GG_BrowseInfoWnd_h_
32 
33 #include <GG/Wnd.h>
34 #include <GG/Font.h>
35 
36 
37 namespace GG {
38 
39 class Cursor;
40 class Font;
41 class TextControl;
42 
50 class GG_API BrowseInfoWnd : public Wnd
51 {
52 public:
54 
58  virtual bool WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const = 0;
60 
62  virtual void Render() = 0;
63 
70  void Update(std::size_t mode, const Wnd* target);
71 
73  void SetCursorPosition(const Pt& cursor_pos);
75 
81  mutable boost::function<
82  Pt (const Pt&, const boost::shared_ptr<Cursor>&, const BrowseInfoWnd&, const Wnd&)
84 
85 protected:
87  BrowseInfoWnd();
88  BrowseInfoWnd(X x, Y y, X w, Y h);
89 
90 
91 private:
92  Pt m_cursor_pos;
93 
94  virtual void UpdateImpl(std::size_t mode, const Wnd* target);
95 };
96 
97 
105 class GG_API TextBoxBrowseInfoWnd : public BrowseInfoWnd
106 {
107 public:
109 
110  TextBoxBrowseInfoWnd(X w, const boost::shared_ptr<Font>& font, Clr color, Clr border_color, Clr text_color,
112  unsigned int border_width = 2, unsigned int text_margin = 4);
114 
116  virtual bool WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const;
117 
118  bool TextFromTarget() const;
119  const std::string& Text () const;
120  const boost::shared_ptr<Font>& GetFont() const;
121  Clr Color() const;
122  Clr BorderColor() const;
123  Clr TextColor() const;
124  Flags<TextFormat> GetTextFormat() const;
125  unsigned int BorderWidth() const;
126  unsigned int TextMargin() const;
127 
128 
130  void SetText(const std::string& str);
131  virtual void Render();
132 
133  void SetTextFromTarget(bool b);
134  void SetFont(const boost::shared_ptr<Font>& font);
135  void SetColor(Clr color);
136  void SetBorderColor(Clr border_color);
137  void SetTextColor(Clr text_color);
138  void SetTextFormat(Flags<TextFormat> format);
139  void SetBorderWidth(unsigned int border_width);
140  void SetTextMargin(unsigned int text_margin);
141 
142 
143 protected:
146 
147 
148 private:
149  virtual void UpdateImpl(std::size_t mode, const Wnd* target);
150 
151  bool m_text_from_target;
152  boost::shared_ptr<Font> m_font;
153  Clr m_color;
154  Clr m_border_color;
155  unsigned int m_border_width;
156  X m_preferred_width;
157  TextControl* m_text_control;
158 };
159 
160 } // namespace GG
161 
162 #endif