nux-1.14.0
|
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 virtual Area* FindAreaUnderMouse(const Point& mouse_position, NuxEventType event_type); 00044 void DrawDownTriangle (GraphicsEngine &GfxContext, int width, int height, const Geometry &geo, BasePainter &painter); 00045 void DrawUpTriangle (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 VScrollBarHandler (void *v); 00053 void ScrollDown (void *v); 00054 void ScrollUp (void *v); 00055 void TrackUp (void *v); 00056 void TrackDown (void *v); 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 RecvStartScrollDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00072 void RecvStartScrollUp (int x, int y, unsigned long button_flags, unsigned long key_flags); 00073 void RecvEndScrollDown (int x, int y, unsigned long button_flags, unsigned long key_flags); 00074 void RecvEndScrollUp (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> OnScrollUp; 00089 sigc::signal<void, float, int> OnScrollDown; 00090 sigc::signal<void> sigVScrollBarSliderMouseDown; 00091 00092 00093 bool b_MouseDownTimer; 00094 bool b_MouseUpTimer; 00095 float m_color_factor; 00096 00097 protected: 00098 void RecvMouseWheel(int x, int y, int wheel_delta, long button_flags, unsigned long key_flags); 00099 00100 // When the Scrollbar is used standalone, it is necessary to call ComputeScrolling at the end of the layout. 00101 virtual long PostLayoutManagement (long LayoutResult); 00102 00103 bool AtMinimum(); 00104 bool AtMaximum(); 00105 00106 VLayout *vlayout; 00107 InputArea *_slider; 00108 InputArea *_scroll_up_button; 00109 InputArea *_scroll_down_button; 00110 InputArea *_track; 00111 00112 int content_width_; 00113 int content_height_; 00114 float content_offset_x_; 00115 float content_offset_y_; 00116 00117 int container_width_; 00118 int container_height_; 00119 00120 int m_TrackWidth; 00121 int m_TrackHeight; 00122 00123 int m_SlideBarOffsetX; 00124 int m_SlideBarOffsetY; 00125 00126 float stepX; 00127 float stepY; 00128 00129 int m_SliderDragPositionX; 00130 int m_SliderDragPositionY; 00131 00132 TimerFunctor *callback; 00133 TimerFunctor *up_callback; 00134 TimerFunctor *down_callback; 00135 TimerFunctor *trackup_callback; 00136 TimerFunctor *trackdown_callback; 00137 TimerHandle m_UpTimerHandler; 00138 TimerHandle m_DownTimerHandler; 00139 TimerHandle m_TrackUpTimerHandler; 00140 TimerHandle m_TrackDownTimerHandler; 00141 00142 Point m_TrackMouseCoord; 00143 friend class HLayout; 00144 friend class VLayout; 00145 friend class Layout; 00146 }; 00147 00148 00149 } 00150 00151 #endif // HSCROLLBAR_H 00152 00153