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/is_abstract.hpp>
00037 #include <boost/serialization/version.hpp>
00038
00039
00040 namespace GG {
00041
00042 class Font;
00043 class TextControl;
00044
00049 class GG_API BrowseInfoWnd : public Wnd
00050 {
00051 public:
00053
00056 virtual bool WndHasBrowseInfo(const Wnd* wnd, int mode) const = 0;
00058
00060 virtual void Render() = 0;
00061
00066 void Update(int mode, const Wnd* target);
00067
00069 void SetCursorPosition(const Pt& cursor_pos);
00071
00072 protected:
00074 BrowseInfoWnd();
00075 BrowseInfoWnd(int x, int y, int w, int h);
00076
00077
00078 private:
00079 Pt m_cursor_pos;
00080
00081 virtual void UpdateImpl(int mode, const Wnd* target);
00082
00083 friend class boost::serialization::access;
00084 template <class Archive>
00085 void serialize(Archive& ar, const unsigned int version);
00086 };
00087
00088
00093 class GG_API TextBoxBrowseInfoWnd : public BrowseInfoWnd
00094 {
00095 public:
00097
00098 TextBoxBrowseInfoWnd(int w, const boost::shared_ptr<Font>& font, Clr color, Clr border_color, Clr text_color,
00099 Flags<TextFormat> format = FORMAT_LEFT | FORMAT_WORDBREAK, int border_width = 2, int text_margin = 4);
00101
00103 virtual bool WndHasBrowseInfo(const Wnd* wnd, int mode) const;
00104
00105 bool TextFromTarget() const;
00106 const std::string& Text () const;
00107 const boost::shared_ptr<Font>& GetFont() const;
00108 Clr Color() const;
00109 Clr BorderColor() const;
00110 Clr TextColor() const;
00111 Flags<TextFormat> GetTextFormat() const;
00112 int BorderWidth() const;
00113 int TextMargin() const;
00114
00115
00117 void SetText (const std::string& str);
00118 virtual void Render();
00119
00120 void SetTextFromTarget(bool b);
00121 void SetFont(const boost::shared_ptr<Font>& font);
00122 void SetColor(Clr color);
00123 void SetBorderColor(Clr border_color);
00124 void SetTextColor(Clr text_color);
00125 void SetTextFormat(Flags<TextFormat> format);
00126 void SetBorderWidth(int border_width);
00127 void SetTextMargin(int text_margin);
00128
00129
00130 protected:
00132 TextBoxBrowseInfoWnd();
00133
00134
00135 private:
00136 virtual void UpdateImpl(int mode, const Wnd* target);
00137
00138 bool m_text_from_target;
00139 boost::shared_ptr<Font> m_font;
00140 Clr m_color;
00141 Clr m_border_color;
00142 int m_border_width;
00143 int m_preferred_width;
00144 TextControl* m_text_control;
00145
00146 friend class boost::serialization::access;
00147 template <class Archive>
00148 void serialize(Archive& ar, const unsigned int version);
00149 };
00150
00151 }
00152
00153 BOOST_IS_ABSTRACT(GG::BrowseInfoWnd);
00154 BOOST_CLASS_VERSION(GG::BrowseInfoWnd, 1);
00155 BOOST_CLASS_VERSION(GG::TextBoxBrowseInfoWnd, 1);
00156
00157
00158 template <class Archive>
00159 void GG::BrowseInfoWnd::serialize(Archive& ar, const unsigned int version)
00160 {
00161 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Wnd);
00162 if (1 <= version)
00163 ar & BOOST_SERIALIZATION_NVP(m_cursor_pos);
00164 }
00165
00166 template <class Archive>
00167 void GG::TextBoxBrowseInfoWnd::serialize(Archive& ar, const unsigned int version)
00168 {
00169 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(BrowseInfoWnd)
00170 & BOOST_SERIALIZATION_NVP(m_text_from_target)
00171 & BOOST_SERIALIZATION_NVP(m_font)
00172 & BOOST_SERIALIZATION_NVP(m_color)
00173 & BOOST_SERIALIZATION_NVP(m_border_color)
00174 & BOOST_SERIALIZATION_NVP(m_border_width)
00175 & BOOST_SERIALIZATION_NVP(m_text_control);
00176 if (1 <= version)
00177 ar & BOOST_SERIALIZATION_NVP(m_preferred_width);
00178 }
00179
00180 #endif // _GG_BrowseInfoWnd_h_