nux-0.9.48

Nux/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 
00032   class HLayout;
00033   class VLayout;
00034   class Layout;
00035 
00036   class VScrollBar: public ScrollBar //public ValuatorAbstraction
00037   {
00038   public:
00039     VScrollBar (NUX_FILE_LINE_PROTO);
00040     ~VScrollBar();
00041 
00042     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00043     void DrawDownTriangle (GraphicsEngine &GfxContext, int width, int height, const Geometry &geo, BasePainter &painter);
00044     void DrawUpTriangle (GraphicsEngine &GfxContext, int width, int height, const Geometry &geo, BasePainter &painter);
00045 
00046     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00047   private:
00048     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw) {};
00049     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw) {};
00050 
00051     void VScrollBarHandler (void *v);
00052     void ScrollDown (void *v);
00053     void ScrollUp (void *v);
00054     void TrackUp (void *v);
00055     void TrackDown (void *v);
00056   public:
00057     void SetContainerSize (int x, int y, int w, int h);
00058     void SetContentSize (int x, int y, int w, int h);
00059     void SetContentOffset (float dx, float dy);
00060     void ComputeScrolling();
00061 
00063     //  RECEIVERS  //
00065     void SetValue (float value);
00066     void SetParameterName (const char *parameter_name);
00068     //  EMITTERS  //
00070     void RecvStartScrollDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00071     void RecvStartScrollUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00072     void RecvEndScrollDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00073     void RecvEndScrollUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00074 
00075     void RecvTrackMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00076     void RecvTrackMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00077     void RecvTrackMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00078 
00079     void OnSliderMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00080     void OnSliderMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00081     void OnSliderMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00082 
00084     //  SIGNALS  //
00086     sigc::signal<void> sigClick;
00087     sigc::signal<void, float, int> OnScrollUp;
00088     sigc::signal<void, float, int> OnScrollDown;
00089     sigc::signal<void> sigVScrollBarSliderMouseDown;
00090 
00091     bool b_MouseDownTimer;
00092     bool b_MouseUpTimer;
00093     float m_color_factor;
00094 
00095   protected:
00096     // When the Scrollbar is used standalone, it is necessary to call ComputeScrolling at the end of the layout.
00097     virtual long PostLayoutManagement (long LayoutResult);
00098 
00099     bool AtMinimum();
00100     bool AtMaximum();
00101 
00102     VLayout *vlayout;
00103     InputArea *m_SlideBar;
00104     InputArea *m_TopThumb;
00105     InputArea *m_BottomThumb;
00106     InputArea *m_Track;
00107 
00108     int m_contentWidth;
00109     int m_contentHeight;
00110     float m_contentOffsetX;
00111     float m_contentOffsetY;
00112 
00113     int m_containerWidth;
00114     int m_containerHeight;
00115 
00116     int m_TrackWidth;
00117     int m_TrackHeight;
00118 
00119     int m_SlideBarOffsetX;
00120     int m_SlideBarOffsetY;
00121 
00122     float stepX;
00123     float stepY;
00124 
00125     int m_SliderDragPositionX;
00126     int m_SliderDragPositionY;
00127 
00128     TimerFunctor *callback;
00129     TimerFunctor *up_callback;
00130     TimerFunctor *down_callback;
00131     TimerFunctor *trackup_callback;
00132     TimerFunctor *trackdown_callback;
00133     TimerHandle m_UpTimerHandler;
00134     TimerHandle m_DownTimerHandler;
00135     TimerHandle m_TrackUpTimerHandler;
00136     TimerHandle m_TrackDownTimerHandler;
00137 
00138     Point m_TrackMouseCoord;
00139     friend class HLayout;
00140     friend class VLayout;
00141     friend class Layout;
00142   };
00143 
00144 
00145 }
00146 
00147 #endif // HSCROLLBAR_H
00148 
00149