Back to index

nux  3.0.0
HScrollBar.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 HSCROLLBAR_H
00024 #define HSCROLLBAR_H
00025 
00026 #include "TimerProc.h"
00027 #include "ScrollBar.h"
00028 
00029 namespace nux
00030 {
00031   class HLayout;
00032 
00033   class HScrollBar : public ScrollBar
00034   {
00035   public:
00036     HScrollBar(NUX_FILE_LINE_PROTO);
00037     ~HScrollBar();
00038 
00039     void DrawLeftTriangle(GraphicsEngine &graphics_engine, int width, int height, const Geometry &geo, BasePainter &painter);
00040     void DrawRightTriangle(GraphicsEngine &graphics_engine, int width, int height, const Geometry &geo, BasePainter &painter);
00041 
00042     virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
00043   private:
00044     virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw) {};
00045     virtual void PostDraw(GraphicsEngine &graphics_engine, bool force_draw) {};
00046 
00047     void HScrollBarHandler(void *v);
00048     void ScrollRight(void *v);
00049     void ScrollLeft(void *v);
00050     void TrackLeft(void *v);
00051     void TrackRight(void *v);
00052 
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 RecvStartScrollRight(int x, int y, unsigned long button_flags, unsigned long key_flags);
00068     void RecvStartScrollLeft(int x, int y, unsigned long button_flags, unsigned long key_flags);
00069     void RecvEndScrollRight(int x, int y, unsigned long button_flags, unsigned long key_flags);
00070     void RecvEndScrollLeft(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> OnScrollLeft;
00085     sigc::signal<void, float, int> OnScrollRight;
00086     sigc::signal<void> sigHScrollBarSliderMouseDown;
00087 
00088     bool b_MouseDownTimer;
00089     bool b_MouseUpTimer;
00090     float m_color_factor;
00091 
00092   protected:
00093     // When the Scrollbar is used standalone, it is necessary to call ComputeScrolling at the end of the layout.
00094     virtual long PostLayoutManagement(long LayoutResult);
00095 
00096     virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type);
00097 
00098     bool AtMinimum();
00099     bool AtMaximum();
00100 
00101     HLayout *hlayout;
00102     InputArea *_slider;
00103     InputArea *_scroll_left_button;
00104     InputArea *_scroll_right_button;
00105     InputArea *_track;
00106 
00107     int content_width_;
00108     int content_height_;
00109     float content_offset_x_;
00110     float content_offset_y_;
00111 
00112     int container_width_;
00113     int container_height_;
00114 
00115     int m_TrackWidth;
00116     int m_TrackHeight;
00117 
00118     int m_SlideBarOffsetX;
00119     int m_SlideBarOffsetY;
00120 
00121     float stepX;
00122     float stepY;
00123 
00124     int m_SliderDragPositionX;
00125     int m_SliderDragPositionY;
00126 
00127     TimerFunctor *callback;
00128     TimerFunctor *left_callback;
00129     TimerFunctor *right_callback;
00130     TimerFunctor *trackleft_callback;
00131     TimerFunctor *trackright_callback;
00132     TimerHandle m_LeftTimerHandler;
00133     TimerHandle m_RightTimerHandler;
00134     TimerHandle m_TrackLeftTimerHandler;
00135     TimerHandle m_TrackRightTimerHandler;
00136 
00137     Point m_TrackMouseCoord;
00138     friend class HLayout;
00139     friend class ScrollView;
00140   };
00141 
00142 }
00143 
00144 #endif // HSCROLLBAR_H
00145 
00146