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_Slider_h_
00031 #define _GG_Slider_h_
00032
00033 #include <GG/Control.h>
00034
00035 #include <boost/serialization/version.hpp>
00036
00037
00038 namespace GG {
00039
00040 class Button;
00041 class WndEvent;
00042
00047 class GG_API Slider : public Control
00048 {
00049 public:
00051 typedef boost::signal<void (int, int, int)> SlidSignalType;
00052 typedef boost::signal<void (int, int, int)> SlidAndStoppedSignalType;
00053
00054
00056 typedef SlidSignalType::slot_type SlidSlotType;
00057 typedef SlidSignalType::slot_type SlidAndStoppedSlotType;
00058
00059
00061 Slider(int x, int y, int w, int h, int min, int max, Orientation orientation, SliderLineStyle style, Clr color, int tab_width, int line_width = 5, Flags<WndFlag> flags = CLICKABLE);
00062
00063
00065 virtual Pt MinUsableSize() const;
00066
00067 int Posn() const;
00068 std::pair<int, int> SliderRange() const;
00069
00072 int PageSize() const;
00073
00074 Orientation GetOrientation() const;
00075 int TabWidth() const;
00076 int LineWidth() const;
00077 SliderLineStyle LineStyle() const;
00078
00079 mutable SlidSignalType SlidSignal;
00080 mutable SlidAndStoppedSignalType SlidAndStoppedSignal;
00081
00082
00084 virtual void Render();
00085 virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys);
00086 virtual void KeyPress(Key key, Flags<ModKey> mod_keys);
00087 virtual void SizeMove(const Pt& ul, const Pt& lr);
00088 virtual void Disable(bool b = true);
00089 virtual void SetColor(Clr c);
00090
00091 void SizeSlider(int min, int max);
00092 void SetMax(int max);
00093 void SetMin(int min);
00094 void SlideTo(int p);
00095
00099 void SetPageSize(int size);
00100
00101 void SetLineStyle(SliderLineStyle style);
00102
00103 virtual void DefineAttributes(WndEditor* editor);
00105
00106 protected:
00108 Slider();
00109
00110
00112 Button* Tab() const;
00113 int PtToPosn(const Pt& pt) const;
00114
00115
00117 virtual bool EventFilter(Wnd* w, const WndEvent& event);
00118
00119 void MoveTabToPosn();
00120
00121
00122 private:
00123 void UpdatePosn();
00124
00125 int m_posn;
00126 int m_range_min;
00127 int m_range_max;
00128 int m_page_sz;
00129 Orientation m_orientation;
00130 int m_line_width;
00131 int m_tab_width;
00132 SliderLineStyle m_line_style;
00133 int m_tab_drag_offset;
00134 Button* m_tab;
00135
00136 friend class boost::serialization::access;
00137 template <class Archive>
00138 void serialize(Archive& ar, const unsigned int version);
00139 };
00140
00141 }
00142
00143 BOOST_CLASS_VERSION(GG::Slider, 1)
00144
00145
00146 template <class Archive>
00147 void GG::Slider::serialize(Archive& ar, const unsigned int version)
00148 {
00149 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Control)
00150 & BOOST_SERIALIZATION_NVP(m_posn)
00151 & BOOST_SERIALIZATION_NVP(m_range_min)
00152 & BOOST_SERIALIZATION_NVP(m_range_max)
00153 & BOOST_SERIALIZATION_NVP(m_orientation)
00154 & BOOST_SERIALIZATION_NVP(m_line_width)
00155 & BOOST_SERIALIZATION_NVP(m_tab_width)
00156 & BOOST_SERIALIZATION_NVP(m_line_style)
00157 & BOOST_SERIALIZATION_NVP(m_tab_drag_offset)
00158 & BOOST_SERIALIZATION_NVP(m_tab);
00159
00160 if (1 <= version)
00161 ar & BOOST_SERIALIZATION_NVP(m_page_sz);
00162 }
00163
00164 #endif // _GG_Slider_h_