![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * 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: FXRangeSlider.h,v 1.12 2009/01/06 13:07:26 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXRANGERANGESLIDER_H 00024 #define FXRANGERANGESLIDER_H 00025 00026 #ifndef FXFRAME_H 00027 #include "FXFrame.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Range Slider Control styles 00034 enum { 00035 RANGESLIDER_HORIZONTAL = 0, /// Slider shown horizontally 00036 RANGESLIDER_VERTICAL = 0x00008000, /// Slider shown vertically 00037 RANGESLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up 00038 RANGESLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down 00039 RANGESLIDER_ARROW_LEFT = RANGESLIDER_ARROW_UP, /// Slider has arrow head pointing left 00040 RANGESLIDER_ARROW_RIGHT = RANGESLIDER_ARROW_DOWN, /// Slider has arrow head pointing right 00041 RANGESLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging 00042 RANGESLIDER_NORMAL = RANGESLIDER_HORIZONTAL 00043 }; 00044 00045 00046 /** 00047 * The range slider widget is a valuator widget which determines a subrange of the 00048 * given range. It has two heads, one for the lower and one for the upper range. 00049 * Two visual appearances are supported:- the sunken look, which is enabled with 00050 * the RANGESLIDER_INSIDE_BAR option and the regular look. The latter may have optional 00051 * arrows on the slider thumb. 00052 * While being moved, the slider sends a SEL_CHANGED message to its target; 00053 * at the end of the interaction, a SEL_COMMAND message is sent. 00054 * The message data represents the current slider value, a pointer to an array 00055 * of two FXint's, representing the values of the lower and upper positions. 00056 */ 00057 class FXAPI FXRangeSlider : public FXFrame { 00058 FXDECLARE(FXRangeSlider) 00059 protected: 00060 FXint headPos[2]; // Head position 00061 FXint headSize; // Head size 00062 FXint slotSize; // Slot size 00063 FXColor slotColor; // Color of slot the head moves in 00064 FXint dragPoint; // Where the head is grabbed 00065 FXint values[4]; // Slider values 00066 FXint active; // Which head is being manipulated 00067 FXint incr; // Increment when auto-sliding 00068 FXString help; // Help string 00069 FXString tip; // Tip string 00070 protected: 00071 FXRangeSlider(); 00072 void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h); 00073 private: 00074 FXRangeSlider(const FXRangeSlider&); 00075 FXRangeSlider &operator=(const FXRangeSlider&); 00076 public: 00077 long onPaint(FXObject*,FXSelector,void*); 00078 long onMotion(FXObject*,FXSelector,void*); 00079 long onMouseWheel(FXObject*,FXSelector,void*); 00080 long onLeftBtnPress(FXObject*,FXSelector,void*); 00081 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00082 long onMiddleBtnPress(FXObject*,FXSelector,void*); 00083 long onMiddleBtnRelease(FXObject*,FXSelector,void*); 00084 long onKeyPress(FXObject*,FXSelector,void*); 00085 long onKeyRelease(FXObject*,FXSelector,void*); 00086 long onUngrabbed(FXObject*,FXSelector,void*); 00087 long onAutoSlide(FXObject*,FXSelector,void*); 00088 long onCmdSetIntRange(FXObject*,FXSelector,void*); 00089 long onCmdGetIntRange(FXObject*,FXSelector,void*); 00090 long onCmdSetRealRange(FXObject*,FXSelector,void*); 00091 long onCmdGetRealRange(FXObject*,FXSelector,void*); 00092 long onCmdSetHelp(FXObject*,FXSelector,void*); 00093 long onCmdGetHelp(FXObject*,FXSelector,void*); 00094 long onCmdSetTip(FXObject*,FXSelector,void*); 00095 long onCmdGetTip(FXObject*,FXSelector,void*); 00096 long onQueryHelp(FXObject*,FXSelector,void*); 00097 long onQueryTip(FXObject*,FXSelector,void*); 00098 public: 00099 enum{ 00100 ID_AUTOSLIDE=FXFrame::ID_LAST, 00101 ID_LAST 00102 }; 00103 public: 00104 00105 /// Construct a slider widget 00106 FXRangeSlider(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=RANGESLIDER_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); 00107 00108 /// Return default width 00109 virtual FXint getDefaultWidth(); 00110 00111 /// Return default height 00112 virtual FXint getDefaultHeight(); 00113 00114 /// Returns true because a slider can receive focus 00115 virtual FXbool canFocus() const; 00116 00117 /// Perform layout 00118 virtual void layout(); 00119 00120 /// Enable the slider 00121 virtual void enable(); 00122 00123 /// Disable the slider 00124 virtual void disable(); 00125 00126 /// Change slider values 00127 void setValue(FXint head,FXint value,FXbool notify=false); 00128 00129 /// Return slider value 00130 FXint getValue(FXint head) const { return values[1+head]; } 00131 00132 /// Change the slider's range 00133 void setRange(FXint lo,FXint hi,FXbool notify=false); 00134 00135 /// Get the slider's current range 00136 void getRange(FXint& lo,FXint& hi) const { lo=values[0]; hi=values[3]; } 00137 00138 /// Change the slider style 00139 FXuint getSliderStyle() const; 00140 00141 /// Get the current slider style 00142 void setSliderStyle(FXuint style); 00143 00144 /// Get the slider's head size 00145 FXint getHeadSize() const { return headSize; } 00146 00147 /// Change the slider's head size 00148 void setHeadSize(FXint hs); 00149 00150 /// Get the slider's current slot size 00151 FXint getSlotSize() const { return slotSize; } 00152 00153 /// Change the slider's slot size 00154 void setSlotSize(FXint bs); 00155 00156 /// Get the slider's auto-increment/decrement value 00157 FXint getIncrement() const { return incr; } 00158 00159 /// Change the slider's auto-increment/decrement value 00160 void setIncrement(FXint inc); 00161 00162 /// Change the color of the slot the slider head moves in 00163 void setSlotColor(FXColor clr); 00164 00165 /// Get the current slot color 00166 FXColor getSlotColor() const { return slotColor; } 00167 00168 /// Set the help text to be displayed on the status line 00169 void setHelpText(const FXString& text){ help=text; } 00170 00171 /// Get the current help text 00172 const FXString& getHelpText() const { return help; } 00173 00174 /// Set the tip text to be displayed in the tooltip 00175 void setTipText(const FXString& text){ tip=text; } 00176 00177 /// Get the current tooltip text value 00178 const FXString& getTipText() const { return tip; } 00179 00180 /// Save to stream 00181 virtual void save(FXStream& store) const; 00182 00183 /// Load from stream 00184 virtual void load(FXStream& store); 00185 00186 /// Destroy the slider 00187 virtual ~FXRangeSlider(); 00188 }; 00189 00190 } 00191 00192 #endif
![]() |