BrowseInfoWnd.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00030 #ifndef _GG_BrowseInfoWnd_h_
00031 #define _GG_BrowseInfoWnd_h_
00032
00033 #include <GG/Wnd.h>
00034 #include <GG/Font.h>
00035
00036 #include <boost/serialization/version.hpp>
00037
00038
00039 namespace GG {
00040
00041 class Font;
00042 class TextControl;
00043
00051 class GG_API BrowseInfoWnd : public Wnd
00052 {
00053 public:
00055
00059 virtual bool WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const = 0;
00061
00063 virtual void Render() = 0;
00064
00071 void Update(std::size_t mode, const Wnd* target);
00072
00074 void SetCursorPosition(const Pt& cursor_pos);
00076
00077 protected:
00079 BrowseInfoWnd();
00080 BrowseInfoWnd(X x, Y y, X w, Y h);
00081
00082
00083 private:
00084 Pt m_cursor_pos;
00085
00086 virtual void UpdateImpl(std::size_t mode, const Wnd* target);
00087
00088 friend class boost::serialization::access;
00089 template <class Archive>
00090 void serialize(Archive& ar, const unsigned int version);
00091 };
00092
00093
00101 class GG_API TextBoxBrowseInfoWnd : public BrowseInfoWnd
00102 {
00103 public:
00105
00106 TextBoxBrowseInfoWnd(X w, const boost::shared_ptr<Font>& font, Clr color, Clr border_color, Clr text_color,
00107 Flags<TextFormat> format = FORMAT_LEFT | FORMAT_WORDBREAK,
00108 unsigned int border_width = 2, unsigned int text_margin = 4);
00110
00112 virtual bool WndHasBrowseInfo(const Wnd* wnd, std::size_t mode) const;
00113
00114 bool TextFromTarget() const;
00115 const std::string& Text () const;
00116 const boost::shared_ptr<Font>& GetFont() const;
00117 Clr Color() const;
00118 Clr BorderColor() const;
00119 Clr TextColor() const;
00120 Flags<TextFormat> GetTextFormat() const;
00121 unsigned int BorderWidth() const;
00122 unsigned int TextMargin() const;
00123
00124
00126 void SetText (const std::string& str);
00127 virtual void Render();
00128
00129 void SetTextFromTarget(bool b);
00130 void SetFont(const boost::shared_ptr<Font>& font);
00131 void SetColor(Clr color);
00132 void SetBorderColor(Clr border_color);
00133 void SetTextColor(Clr text_color);
00134 void SetTextFormat(Flags<TextFormat> format);
00135 void SetBorderWidth(unsigned int border_width);
00136 void SetTextMargin(unsigned int text_margin);
00137
00138
00139 protected:
00141 TextBoxBrowseInfoWnd();
00142
00143
00144 private:
00145 virtual void UpdateImpl(std::size_t mode, const Wnd* target);
00146
00147 bool m_text_from_target;
00148 boost::shared_ptr<Font> m_font;
00149 Clr m_color;
00150 Clr m_border_color;
00151 unsigned int m_border_width;
00152 X m_preferred_width;
00153 TextControl* m_text_control;
00154
00155 friend class boost::serialization::access;
00156 template <class Archive>
00157 void serialize(Archive& ar, const unsigned int version);
00158 };
00159
00160 }
00161
00162
00163
00164 template <class Archive>
00165 void GG::BrowseInfoWnd::serialize(Archive& ar, const unsigned int version)
00166 {
00167 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Wnd)
00168 & BOOST_SERIALIZATION_NVP(m_cursor_pos);
00169 }
00170
00171 template <class Archive>
00172 void GG::TextBoxBrowseInfoWnd::serialize(Archive& ar, const unsigned int version)
00173 {
00174 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BrowseInfoWnd)
00175 & BOOST_SERIALIZATION_NVP(m_text_from_target)
00176 & BOOST_SERIALIZATION_NVP(m_font)
00177 & BOOST_SERIALIZATION_NVP(m_color)
00178 & BOOST_SERIALIZATION_NVP(m_border_color)
00179 & BOOST_SERIALIZATION_NVP(m_border_width)
00180 & BOOST_SERIALIZATION_NVP(m_text_control)
00181 & BOOST_SERIALIZATION_NVP(m_preferred_width);
00182 }
00183
00184 #endif // _GG_BrowseInfoWnd_h_