nux-1.14.0
HScrollBar.h
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 HSCROLLBAR_H
00024 #define HSCROLLBAR_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 HScrollBar : public ScrollBar //public ValuatorAbstraction
00037   {
00038   public:
00039     HScrollBar (NUX_FILE_LINE_PROTO);
00040     ~HScrollBar();
00041 
00042     virtual long ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo);
00043     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00044     void DrawLeftTriangle (GraphicsEngine &GfxContext, int width, int height, const Geometry &geo, BasePainter &painter);
00045     void DrawRightTriangle (GraphicsEngine &GfxContext, int width, int height, const Geometry &geo, BasePainter &painter);
00046 
00047     virtual void Draw (GraphicsEngine &GfxContext, bool force_draw);
00048   private:
00049     virtual void DrawContent (GraphicsEngine &GfxContext, bool force_draw) {};
00050     virtual void PostDraw (GraphicsEngine &GfxContext, bool force_draw) {};
00051 
00052     void HScrollBarHandler (void *v);
00053     void ScrollRight (void *v);
00054     void ScrollLeft (void *v);
00055     void TrackLeft (void *v);
00056     void TrackRight (void *v);
00057 
00058   public:
00059     void SetContainerSize (int x, int y, int w, int h);
00060     void SetContentSize (int x, int y, int w, int h);
00061     void SetContentOffset (float dx, float dy);
00062     void ComputeScrolling();
00063 
00065     //  RECEIVERS  //
00067     void SetValue (float value);
00068     void SetParameterName (const char *parameter_name);
00070     //  EMITTERS  //
00072     void RecvStartScrollRight (int x, int y, unsigned long button_flags, unsigned long key_flags);
00073     void RecvStartScrollLeft (int x, int y, unsigned long button_flags, unsigned long key_flags);
00074     void RecvEndScrollRight (int x, int y, unsigned long button_flags, unsigned long key_flags);
00075     void RecvEndScrollLeft (int x, int y, unsigned long button_flags, unsigned long key_flags);
00076 
00077     void RecvTrackMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00078     void RecvTrackMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00079     void RecvTrackMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00080 
00081     void OnSliderMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags);
00082     void OnSliderMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags);
00083     void OnSliderMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
00084 
00086     //  SIGNALS  //
00088     sigc::signal<void> sigClick;
00089     sigc::signal<void, float, int> OnScrollLeft;
00090     sigc::signal<void, float, int> OnScrollRight;
00091     sigc::signal<void> sigHScrollBarSliderMouseDown;
00092 
00093     bool b_MouseDownTimer;
00094     bool b_MouseUpTimer;
00095     float m_color_factor;
00096 
00097   protected:
00098     // When the Scrollbar is used standalone, it is necessary to call ComputeScrolling at the end of the layout.
00099     virtual long PostLayoutManagement (long LayoutResult);
00100 
00101     bool AtMinimum();
00102     bool AtMaximum();
00103 
00104     HLayout *hlayout;
00105     InputArea *_slider;
00106     InputArea *_scroll_left_button;
00107     InputArea *_scroll_right_button;
00108     InputArea *_track;
00109 
00110     int content_width_;
00111     int content_height_;
00112     float content_offset_x_;
00113     float content_offset_y_;
00114 
00115     int container_width_;
00116     int container_height_;
00117 
00118     int m_TrackWidth;
00119     int m_TrackHeight;
00120 
00121     int m_SlideBarOffsetX;
00122     int m_SlideBarOffsetY;
00123 
00124     float stepX;
00125     float stepY;
00126 
00127     int m_SliderDragPositionX;
00128     int m_SliderDragPositionY;
00129 
00130     TimerFunctor *callback;
00131     TimerFunctor *left_callback;
00132     TimerFunctor *right_callback;
00133     TimerFunctor *trackleft_callback;
00134     TimerFunctor *trackright_callback;
00135     TimerHandle m_LeftTimerHandler;
00136     TimerHandle m_RightTimerHandler;
00137     TimerHandle m_TrackLeftTimerHandler;
00138     TimerHandle m_TrackRightTimerHandler;
00139 
00140     Point m_TrackMouseCoord;
00141     friend class HLayout;
00142     friend class VLayout;
00143     friend class Layout;
00144   };
00145 
00146 }
00147 
00148 #endif // HSCROLLBAR_H
00149 
00150 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends