Scroll.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
00028 #ifndef _GG_Scroll_h_
00029 #define _GG_Scroll_h_
00030
00031 #include <GG/Control.h>
00032
00033
00034 namespace GG {
00035
00036 class Button;
00037
00056 class GG_API Scroll : public Control
00057 {
00058 public:
00060 enum ScrollRegion {
00061 SBR_NONE,
00062 SBR_PAGE_DN,
00063 SBR_PAGE_UP
00064 };
00065
00067 typedef boost::signal<void (int, int, int, int)> ScrolledSignalType;
00068 typedef boost::signal<void (int, int, int, int)> ScrolledAndStoppedSignalType;
00069
00070
00072
00073 Scroll(X x, Y y, X w, Y h, Orientation orientation, Clr color, Clr interior,
00074 Flags<WndFlag> flags = INTERACTIVE | REPEAT_BUTTON_DOWN);
00076
00078 virtual Pt MinUsableSize() const;
00079
00080 std::pair<int, int> PosnRange() const;
00081 std::pair<int, int> ScrollRange() const;
00082 unsigned int LineSize() const;
00083 unsigned int PageSize() const;
00084
00085 Clr InteriorColor() const;
00086 Orientation ScrollOrientation() const;
00087
00088 mutable ScrolledSignalType ScrolledSignal;
00089 mutable ScrolledAndStoppedSignalType ScrolledAndStoppedSignal;
00090
00091
00093 virtual void Render();
00094
00095 virtual void SizeMove(const Pt& ul, const Pt& lr);
00096
00097 virtual void Disable(bool b = true);
00098 virtual void SetColor(Clr c);
00099
00100 void SetInteriorColor(Clr c);
00101 void SizeScroll(int min, int max, unsigned int line, unsigned int page);
00102 void SetMax(int max);
00103 void SetMin(int min);
00104 void SetLineSize(unsigned int line);
00105 void SetPageSize(unsigned int page);
00106
00107 void ScrollTo(int p);
00108 void ScrollLineIncr();
00109 void ScrollLineDecr();
00110 void ScrollPageIncr();
00111 void ScrollPageDecr();
00112
00113 virtual void DefineAttributes(WndEditor* editor);
00115
00116 protected:
00118 Scroll();
00119
00120
00122 unsigned int TabSpace() const;
00123 unsigned int TabWidth() const;
00124 ScrollRegion RegionUnder(const Pt& pt);
00125
00126 Button* TabButton() const;
00127 Button* IncrButton() const;
00128 Button* DecrButton() const;
00129
00130
00132 virtual void LButtonDown(const Pt& pt, Flags<ModKey> mod_keys);
00133 virtual void LButtonUp(const Pt& pt, Flags<ModKey> mod_keys);
00134 virtual void LClick(const Pt& pt, Flags<ModKey> mod_keys);
00135 virtual void MouseHere(const Pt& pt, Flags<ModKey> mod_keys);
00136
00137 virtual bool EventFilter(Wnd* w, const WndEvent& event);
00139
00140 private:
00141 void UpdatePosn();
00142 void MoveTabToPosn();
00143 void ScrollLineIncrImpl(bool signal);
00144 void ScrollLineDecrImpl(bool signal);
00145
00146 Clr m_int_color;
00147 const Orientation m_orientation;
00148 int m_posn;
00149 int m_range_min;
00150 int m_range_max;
00151 unsigned int m_line_sz;
00152 unsigned int m_page_sz;
00153 Button* m_tab;
00154 Button* m_incr;
00155 Button* m_decr;
00156 ScrollRegion m_initial_depressed_region;
00157 ScrollRegion m_depressed_region;
00158 bool m_dragging_tab;
00159 bool m_tab_dragged;
00160
00161 friend class boost::serialization::access;
00162 template <class Archive>
00163 void serialize(Archive& ar, const unsigned int version);
00164 };
00165
00166
00167 GG_ENUM_MAP_BEGIN(Scroll::ScrollRegion)
00168 GG_ENUM_MAP_INSERT(Scroll::SBR_NONE)
00169 GG_ENUM_MAP_INSERT(Scroll::SBR_PAGE_DN)
00170 GG_ENUM_MAP_INSERT(Scroll::SBR_PAGE_UP)
00171 GG_ENUM_MAP_END
00172
00173 GG_ENUM_STREAM_IN(Scroll::ScrollRegion)
00174 GG_ENUM_STREAM_OUT(Scroll::ScrollRegion)
00175
00179 GG_API void SignalScroll(const Scroll& scroll, bool stopped);
00180
00181 }
00182
00183
00184 template <class Archive>
00185 void GG::Scroll::serialize(Archive& ar, const unsigned int version)
00186 {
00187 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Control)
00188 & BOOST_SERIALIZATION_NVP(m_int_color)
00189 & boost::serialization::make_nvp("m_orientation", const_cast<Orientation&>(m_orientation))
00190 & BOOST_SERIALIZATION_NVP(m_posn)
00191 & BOOST_SERIALIZATION_NVP(m_range_min)
00192 & BOOST_SERIALIZATION_NVP(m_range_max)
00193 & BOOST_SERIALIZATION_NVP(m_line_sz)
00194 & BOOST_SERIALIZATION_NVP(m_page_sz)
00195 & BOOST_SERIALIZATION_NVP(m_tab)
00196 & BOOST_SERIALIZATION_NVP(m_incr)
00197 & BOOST_SERIALIZATION_NVP(m_decr);
00198 }
00199
00200 #endif // _GG_Scroll_h_