Back to index

nux  3.0.0
VScrollBar.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef VSCROLLBAR_H
00024 #define VSCROLLBAR_H
00025 
00026 #include "TimerProc.h"
00027 #include "ScrollBar.h"
00028 
00029 namespace nux
00030 {
00031   class VLayout;
00032 
00033   class VScrollBar: public ScrollBar
00034   {
00035   public:
00036     VScrollBar(NUX_FILE_LINE_PROTO);
00037     ~VScrollBar();
00038 
00039     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00040     void DrawDownTriangle(GraphicsEngine &graphics_engine, int width, int height, const Geometry &geo, BasePainter &painter);
00041     void DrawUpTriangle(GraphicsEngine &graphics_engine, int width, int height, const Geometry &geo, BasePainter &painter);
00042 
00043     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00044   private:
00045     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw) {};
00046     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw) {};
00047 
00048     void VScrollBarHandler(void *v);
00049     void ScrollDown(void *v);
00050     void ScrollUp(void *v);
00051     void TrackUp(void *v);
00052     void TrackDown(void *v);
00053   public:
00054     void SetContainerSize(int x, int y, int w, int h);
00055     void SetContentSize(int x, int y, int w, int h);
00056     void SetContentOffset(float dx, float dy);
00057     void ComputeScrolling();
00058 
00060     //  RECEIVERS  //
00062     void SetValue(float value);
00063     void SetParameterName(const char *parameter_name);
00065     //  EMITTERS  //
00067     void RecvStartScrollDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00068     void RecvStartScrollUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00069     void RecvEndScrollDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00070     void RecvEndScrollUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00071 
00072     void RecvTrackMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00073     void RecvTrackMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00074     void RecvTrackMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00075 
00076     void OnSliderMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
00077     void OnSliderMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
00078     void OnSliderMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00079 
00081     //  SIGNALS  //
00083     sigc::signal<void> sigClick;
00084     sigc::signal<void, float, int> OnScrollUp;
00085     sigc::signal<void, float, int> OnScrollDown;
00086     sigc::signal<void> sigVScrollBarSliderMouseDown;
00087     
00088 
00089     bool b_MouseDownTimer;
00090     bool b_MouseUpTimer;
00091     float m_color_factor;
00092 
00093   protected:
00094     // When the Scrollbar is used standalone, it is necessary to call ComputeScrolling at the end of the layout.
00095     virtual long PostLayoutManagement(long LayoutResult);
00096 
00097     bool AtMinimum();
00098     bool AtMaximum();
00099 
00100     VLayout *vlayout;
00101     InputArea *_slider;
00102     InputArea *_scroll_up_button;
00103     InputArea *_scroll_down_button;
00104     InputArea *_track;
00105 
00106     int content_width_;
00107     int content_height_;
00108     float content_offset_x_;
00109     float content_offset_y_;
00110 
00111     int container_width_;
00112     int container_height_;
00113 
00114     int m_TrackWidth;
00115     int m_TrackHeight;
00116 
00117     int m_SlideBarOffsetX;
00118     int m_SlideBarOffsetY;
00119 
00120     float stepX;
00121     float stepY;
00122 
00123     int m_SliderDragPositionX;
00124     int m_SliderDragPositionY;
00125 
00126     TimerFunctor *callback;
00127     TimerFunctor *up_callback;
00128     TimerFunctor *down_callback;
00129     TimerFunctor *trackup_callback;
00130     TimerFunctor *trackdown_callback;
00131     TimerHandle m_UpTimerHandler;
00132     TimerHandle m_DownTimerHandler;
00133     TimerHandle m_TrackUpTimerHandler;
00134     TimerHandle m_TrackDownTimerHandler;
00135 
00136     Point m_TrackMouseCoord;
00137     friend class VLayout;
00138     friend class ScrollView;
00139   };
00140 
00141 
00142 }
00143 
00144 #endif // HSCROLLBAR_H
00145 
00146