nux-0.9.46
|
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 void DrawLeftTriangle (GraphicsEngine &GfxContext, int width, int height, const Geometry &geo, BasePainter &painter); 00044 void DrawRightTriangle (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 HScrollBarHandler (void *v); 00052 void ScrollRight (void *v); 00053 void ScrollLeft (void *v); 00054 void TrackLeft (void *v); 00055 void TrackRight (void *v); 00056 00057 public: 00058 void SetContainerSize (int x, int y, int w, int h); 00059 void SetContentSize (int x, int y, int w, int h); 00060 void SetContentOffset (float dx, float dy); 00061 void ComputeScrolling(); 00062 00064 // RECEIVERS // 00066 void SetValue (float value); 00067 void SetParameterName (const char *parameter_name); 00069 // EMITTERS // 00071 void RecvStartScrollRight (int x, int y, unsigned long button_flags, unsigned long key_flags); 00072 void RecvStartScrollLeft (int x, int y, unsigned long button_flags, unsigned long key_flags); 00073 void RecvEndScrollRight (int x, int y, unsigned long button_flags, unsigned long key_flags); 00074 void RecvEndScrollLeft (int x, int y, unsigned long button_flags, unsigned long key_flags); 00075 00076 void RecvTrackMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00077 void RecvTrackMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00078 void RecvTrackMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00079 00080 void OnSliderMouseDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00081 void OnSliderMouseUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00082 void OnSliderMouseDrag (int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags); 00083 00085 // SIGNALS // 00087 sigc::signal<void> sigClick; 00088 sigc::signal<void, float, int> OnScrollLeft; 00089 sigc::signal<void, float, int> OnScrollRight; 00090 sigc::signal<void> sigHScrollBarSliderMouseDown; 00091 00092 bool b_MouseDownTimer; 00093 bool b_MouseUpTimer; 00094 float m_color_factor; 00095 00096 protected: 00097 // When the Scrollbar is used standalone, it is necessary to call ComputeScrolling at the end of the layout. 00098 virtual long PostLayoutManagement (long LayoutResult); 00099 00100 bool AtMinimum(); 00101 bool AtMaximum(); 00102 00103 HLayout *hlayout; 00104 InputArea *m_SlideBar; 00105 InputArea *m_LeftThumb; 00106 InputArea *m_RightThumb; 00107 InputArea *m_Track; 00108 00109 int m_contentWidth; 00110 int m_contentHeight; 00111 float m_contentOffsetX; 00112 float m_contentOffsetY; 00113 00114 int m_containerWidth; 00115 int m_containerHeight; 00116 00117 int m_TrackWidth; 00118 int m_TrackHeight; 00119 00120 int m_SlideBarOffsetX; 00121 int m_SlideBarOffsetY; 00122 00123 float stepX; 00124 float stepY; 00125 00126 int m_SliderDragPositionX; 00127 int m_SliderDragPositionY; 00128 00129 TimerFunctor *callback; 00130 TimerFunctor *left_callback; 00131 TimerFunctor *right_callback; 00132 TimerFunctor *trackleft_callback; 00133 TimerFunctor *trackright_callback; 00134 TimerHandle m_LeftTimerHandler; 00135 TimerHandle m_RightTimerHandler; 00136 TimerHandle m_TrackLeftTimerHandler; 00137 TimerHandle m_TrackRightTimerHandler; 00138 00139 Point m_TrackMouseCoord; 00140 friend class HLayout; 00141 friend class VLayout; 00142 friend class Layout; 00143 }; 00144 00145 } 00146 00147 #endif // HSCROLLBAR_H 00148 00149