![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * R e a l S l i d e r W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 1997,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (at your option) any later version. * 00012 * * 00013 * This library is distributed in the hope that it will be useful, * 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXRealSlider.h,v 1.20 2009/01/06 13:07:26 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXREALSLIDER_H 00024 #define FXREALSLIDER_H 00025 00026 #ifndef FXFRAME_H 00027 #include "FXFrame.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Slider Control styles 00034 enum { 00035 REALSLIDER_HORIZONTAL = 0, /// Slider shown horizontally 00036 REALSLIDER_VERTICAL = 0x00008000, /// Slider shown vertically 00037 REALSLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up 00038 REALSLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down 00039 REALSLIDER_ARROW_LEFT = REALSLIDER_ARROW_UP, /// Slider has arrow head pointing left 00040 REALSLIDER_ARROW_RIGHT = REALSLIDER_ARROW_DOWN, /// Slider has arrow head pointing right 00041 REALSLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging 00042 REALSLIDER_TICKS_TOP = 0x00080000, /// Ticks on the top of horizontal slider 00043 REALSLIDER_TICKS_BOTTOM = 0x00100000, /// Ticks on the bottom of horizontal slider 00044 REALSLIDER_TICKS_LEFT = REALSLIDER_TICKS_TOP, /// Ticks on the left of vertical slider 00045 REALSLIDER_TICKS_RIGHT = REALSLIDER_TICKS_BOTTOM, /// Ticks on the right of vertical slider 00046 REALSLIDER_NORMAL = REALSLIDER_HORIZONTAL 00047 }; 00048 00049 00050 /** 00051 * The real slider widget is a valuator widget which provides simple linear value range. 00052 * Two visual appearances are supported:- the sunken look, which is enabled with 00053 * the SLIDER_INSIDE_BAR option and the regular look. The latter may have optional 00054 * arrows on the slider thumb. 00055 * While being moved, the real slider sends a SEL_CHANGED message to its target; 00056 * at the end of the interaction, a SEL_COMMAND message is sent. 00057 * The message data represents the current slider value, of type pointer to FXdouble. 00058 */ 00059 class FXAPI FXRealSlider : public FXFrame { 00060 FXDECLARE(FXRealSlider) 00061 protected: 00062 FXint headPos; // Head position 00063 FXint headSize; // Head size 00064 FXint slotSize; // Slot size 00065 FXColor slotColor; // Color of slot the head moves in 00066 FXint dragPoint; // Where on the head is grabbed 00067 FXdouble range[2]; // Reported data range 00068 FXdouble delta; // Interval between ticks 00069 FXdouble incr; // Increment when auto-sliding 00070 FXdouble gran; // Granularity 00071 FXdouble pos; // Reported data position 00072 FXString help; // Help string 00073 FXString tip; // Tip string 00074 protected: 00075 FXRealSlider(); 00076 void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); 00077 void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); 00078 void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); 00079 private: 00080 FXRealSlider(const FXRealSlider&); 00081 FXRealSlider &operator=(const FXRealSlider&); 00082 public: 00083 long onPaint(FXObject*,FXSelector,void*); 00084 long onMotion(FXObject*,FXSelector,void*); 00085 long onMouseWheel(FXObject*,FXSelector,void*); 00086 long onLeftBtnPress(FXObject*,FXSelector,void*); 00087 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00088 long onMiddleBtnPress(FXObject*,FXSelector,void*); 00089 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 00090 long onKeyPress(FXObject*,FXSelector,void*); 00091 long onKeyRelease(FXObject*,FXSelector,void*); 00092 long onUngrabbed(FXObject*,FXSelector,void*); 00093 long onAutoSlide(FXObject*,FXSelector,void*); 00094 long onCmdSetValue(FXObject*,FXSelector,void*); 00095 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00096 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00097 long onCmdSetLongValue(FXObject*,FXSelector,void*); 00098 long onCmdGetLongValue(FXObject*,FXSelector,void*); 00099 long onCmdSetRealValue(FXObject*,FXSelector,void*); 00100 long onCmdGetRealValue(FXObject*,FXSelector,void*); 00101 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00102 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00103 long onCmdSetRealRange(FXObject*,FXSelector,void*); 00104 long onCmdGetRealRange(FXObject*,FXSelector,void*); 00105 long onCmdSetHelp(FXObject*,FXSelector,void*); 00106 long onCmdGetHelp(FXObject*,FXSelector,void*); 00107 long onCmdSetTip(FXObject*,FXSelector,void*); 00108 long onCmdGetTip(FXObject*,FXSelector,void*); 00109 long onQueryHelp(FXObject*,FXSelector,void*); 00110 long onQueryTip(FXObject*,FXSelector,void*); 00111 public: 00112 enum{ 00113 ID_AUTOSLIDE=FXFrame::ID_LAST, 00114 ID_LAST 00115 }; 00116 public: 00117 00118 /// Construct a slider widget 00119 FXRealSlider(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=REALSLIDER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=0,FXint pr=0,FXint pt=0,FXint pb=0); 00120 00121 /// Return default width 00122 virtual FXint getDefaultWidth(); 00123 00124 /// Return default height 00125 virtual FXint getDefaultHeight(); 00126 00127 /// Returns true because a slider can receive focus 00128 virtual FXbool canFocus() const; 00129 00130 /// Perform layout 00131 virtual void layout(); 00132 00133 /// Enable the slider 00134 virtual void enable(); 00135 00136 /// Disable the slider 00137 virtual void disable(); 00138 00139 /// Change slider value 00140 void setValue(FXdouble value,FXbool notify=false); 00141 00142 /// Return slider value 00143 FXdouble getValue() const { return pos; } 00144 00145 /// Change the slider's range 00146 void setRange(FXdouble lo,FXdouble hi,FXbool notify=false); 00147 00148 /// Get the slider's current range 00149 void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; } 00150 00151 /// Change the slider style 00152 FXuint getSliderStyle() const; 00153 00154 /// Get the current slider style 00155 void setSliderStyle(FXuint style); 00156 00157 /// Get the slider's head size 00158 FXint getHeadSize() const { return headSize; } 00159 00160 /// Change the slider's head size 00161 void setHeadSize(FXint hs); 00162 00163 /// Get the slider's current slot size 00164 FXint getSlotSize() const { return slotSize; } 00165 00166 /// Change the slider's slot size 00167 void setSlotSize(FXint bs); 00168 00169 /// Get the slider's auto-increment/decrement value 00170 FXdouble getIncrement() const { return incr; } 00171 00172 /// Change the slider's auto-increment/decrement value 00173 void setIncrement(FXdouble inc); 00174 00175 /// Change slider's granularity 00176 void setGranularity(FXdouble gr); 00177 00178 /// Return slider's granularity 00179 FXdouble getGranularity() const { return gran; } 00180 00181 /// Change the delta between ticks 00182 void setTickDelta(FXdouble dist); 00183 00184 /// Get delta between ticks 00185 FXdouble getTickDelta() const { return delta; } 00186 00187 /// Change the color of the slot the slider head moves in 00188 void setSlotColor(FXColor clr); 00189 00190 /// Get the current slot color 00191 FXColor getSlotColor() const { return slotColor; } 00192 00193 /// Set the help text to be displayed on the status line 00194 void setHelpText(const FXString& text){ help=text; } 00195 00196 /// Get the current help text 00197 const FXString& getHelpText() const { return help; } 00198 00199 /// Set the tip text to be displayed in the tooltip 00200 void setTipText(const FXString& text){ tip=text; } 00201 00202 /// Get the current tooltip text value 00203 const FXString& getTipText() const { return tip; } 00204 00205 /// Save to stream 00206 virtual void save(FXStream& store) const; 00207 00208 /// Load from stream 00209 virtual void load(FXStream& store); 00210 00211 /// Destroy the slider 00212 virtual ~FXRealSlider(); 00213 }; 00214 00215 } 00216 00217 #endif
![]() |