Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXRealSlider.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * R e a l S l i d e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXRealSlider.h,v 1.11 2006/01/22 17:58:08 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXREALSLIDER_H
25 #define FXREALSLIDER_H
26 
27 #ifndef FXFRAME_H
28 #include "FXFrame.h"
29 #endif
30 
31 namespace FX {
32 
33 
34 /// Slider Control styles
35 enum {
36  REALSLIDER_HORIZONTAL = 0, /// Slider shown horizontally
37  REALSLIDER_VERTICAL = 0x00008000, /// Slider shown vertically
38  REALSLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up
39  REALSLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down
40  REALSLIDER_ARROW_LEFT = REALSLIDER_ARROW_UP, /// Slider has arrow head pointing left
41  REALSLIDER_ARROW_RIGHT = REALSLIDER_ARROW_DOWN, /// Slider has arrow head pointing right
42  REALSLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging
43  REALSLIDER_TICKS_TOP = 0x00080000, /// Ticks on the top of horizontal slider
44  REALSLIDER_TICKS_BOTTOM = 0x00100000, /// Ticks on the bottom of horizontal slider
45  REALSLIDER_TICKS_LEFT = REALSLIDER_TICKS_TOP, /// Ticks on the left of vertical slider
46  REALSLIDER_TICKS_RIGHT = REALSLIDER_TICKS_BOTTOM, /// Ticks on the right of vertical slider
48  };
49 
50 
51 /**
52 * The real slider widget is a valuator widget which provides simple linear value range.
53 * Two visual appearances are supported:- the sunken look, which is enabled with
54 * the SLIDER_INSIDE_BAR option and the regular look. The latter may have optional
55 * arrows on the slider thumb.
56 * While being moved, the real slider sends a SEL_CHANGED message to its target;
57 * at the end of the interaction, a SEL_COMMAND message is sent.
58 * The message data represents the current slider value, of type pointer to FXdouble.
59 */
60 class FXAPI FXRealSlider : public FXFrame {
62 protected:
63  FXdouble range[2]; // Reported data range
64  FXdouble pos; // Reported data position
65  FXdouble incr; // Increment when auto-sliding
66  FXdouble delta; // Interval between ticks
67  FXint headpos; // Head position
68  FXint headsize; // Head size
69  FXint slotsize; // Slot size
70  FXColor slotColor; // Color of slot the head moves in
71  FXint dragpoint; // Where on the head is grabbed
72  FXString help; // Help string
73  FXString tip; // Tip string
74 protected:
75  FXRealSlider();
76  void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
77  void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
78  void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
79 private:
80  FXRealSlider(const FXRealSlider&);
81  FXRealSlider &operator=(const FXRealSlider&);
82 public:
83  long onPaint(FXObject*,FXSelector,void*);
84  long onMotion(FXObject*,FXSelector,void*);
85  long onMouseWheel(FXObject*,FXSelector,void*);
86  long onLeftBtnPress(FXObject*,FXSelector,void*);
87  long onLeftBtnRelease(FXObject*,FXSelector,void*);
88  long onMiddleBtnPress(FXObject*,FXSelector,void*);
89  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
90  long onKeyPress(FXObject*,FXSelector,void*);
91  long onKeyRelease(FXObject*,FXSelector,void*);
92  long onUngrabbed(FXObject*,FXSelector,void*);
93  long onAutoSlide(FXObject*,FXSelector,void*);
94  long onCmdSetValue(FXObject*,FXSelector,void*);
95  long onCmdSetIntValue(FXObject*,FXSelector,void*);
96  long onCmdGetIntValue(FXObject*,FXSelector,void*);
97  long onCmdSetRealValue(FXObject*,FXSelector,void*);
98  long onCmdGetRealValue(FXObject*,FXSelector,void*);
99  long onCmdSetIntRange(FXObject*,FXSelector,void*);
100  long onCmdGetIntRange(FXObject*,FXSelector,void*);
101  long onCmdSetRealRange(FXObject*,FXSelector,void*);
102  long onCmdGetRealRange(FXObject*,FXSelector,void*);
103  long onCmdSetHelp(FXObject*,FXSelector,void*);
104  long onCmdGetHelp(FXObject*,FXSelector,void*);
105  long onCmdSetTip(FXObject*,FXSelector,void*);
106  long onCmdGetTip(FXObject*,FXSelector,void*);
107  long onQueryHelp(FXObject*,FXSelector,void*);
108  long onQueryTip(FXObject*,FXSelector,void*);
109 public:
110  enum{
111  ID_AUTOSLIDE=FXFrame::ID_LAST,
112  ID_LAST
113  };
114 public:
115 
116  /// Construct a slider widget
117  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);
118 
119  /// Return default width
120  virtual FXint getDefaultWidth();
121 
122  /// Return default height
123  virtual FXint getDefaultHeight();
124 
125  /// Returns true because a slider can receive focus
126  virtual bool canFocus() const;
127 
128  /// Perform layout
129  virtual void layout();
130 
131  /// Enable the slider
132  virtual void enable();
133 
134  /// Disable the slider
135  virtual void disable();
136 
137  /// Change slider value
138  void setValue(FXdouble value,FXbool notify=FALSE);
139 
140  /// Return slider value
141  FXdouble getValue() const { return pos; }
142 
143  /// Change the slider's range
144  void setRange(FXdouble lo,FXdouble hi,FXbool notify=FALSE);
145 
146  /// Get the slider's current range
147  void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
148 
149  /// Change the slider style
150  FXuint getSliderStyle() const;
151 
152  /// Get the current slider style
153  void setSliderStyle(FXuint style);
154 
155  /// Get the slider's head size
156  FXint getHeadSize() const { return headsize; }
157 
158  /// Change the slider's head size
159  void setHeadSize(FXint hs);
160 
161  /// Get the slider's current slot size
162  FXint getSlotSize() const { return slotsize; }
163 
164  /// Change the slider's slot size
165  void setSlotSize(FXint bs);
166 
167  /// Get the slider's auto-increment/decrement value
168  FXdouble getIncrement() const { return incr; }
169 
170  /// Change the slider's auto-increment/decrement value
171  void setIncrement(FXdouble inc);
172 
173  /// Change the delta between ticks
174  void setTickDelta(FXdouble dist);
175 
176  /// Get delta between ticks
177  FXdouble getTickDelta() const { return delta; }
178 
179  /// Change the color of the slot the slider head moves in
180  void setSlotColor(FXColor clr);
181 
182  /// Get the current slot color
183  FXColor getSlotColor() const { return slotColor; }
184 
185  /// Set the help text to be displayed on the status line
186  void setHelpText(const FXString& text){ help=text; }
187 
188  /// Get the current help text
189  const FXString& getHelpText() const { return help; }
190 
191  /// Set the tip text to be displayed in the tooltip
192  void setTipText(const FXString& text){ tip=text; }
193 
194  /// Get the current tooltip text value
195  const FXString& getTipText() const { return tip; }
196 
197  /// Save to stream
198  virtual void save(FXStream& store) const;
199 
200  /// Load from stream
201  virtual void load(FXStream& store);
202 
203  /// Destroy the slider
204  virtual ~FXRealSlider();
205  };
206 
207 }
208 
209 #endif
FXVec2d lo(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:174
Slider has arrow head pointing down.
Definition: FXRealSlider.h:42
The real slider widget is a valuator widget which provides simple linear value range.
Definition: FXRealSlider.h:67
Slider has arrow head pointing left.
Definition: FXRealSlider.h:43
Slider shown vertically.
Definition: FXRealSlider.h:40
The Frame widget provides borders around some contents.
Definition: FXFrame.h:73
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:396
Ticks on the bottom of horizontal slider.
Definition: FXRealSlider.h:47
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Ticks on the left of vertical slider.
Definition: FXRealSlider.h:48
#define FXAPI
Definition: fxdefs.h:122
FXuchar FXbool
Definition: fxdefs.h:393
Slider shown horizontally.
Definition: FXRealSlider.h:39
Base composite.
Definition: FXComposite.h:35
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:454
Slider has arrow head pointing right.
Definition: FXRealSlider.h:44
double FXdouble
Definition: fxdefs.h:399
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
FXVec2d hi(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:175
Slider is inside the slot rather than overhanging.
Definition: FXRealSlider.h:45
#define FALSE
Definition: fxdefs.h:35
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:166
Window Device Context.
Definition: FXDCWindow.h:52
Slider has arrow head pointing up.
Definition: FXRealSlider.h:41
Definition: FXRealSlider.h:50
Ticks on the top of horizontal slider.
Definition: FXRealSlider.h:46
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33
Ticks on the right of vertical slider.
Definition: FXRealSlider.h:49

Copyright © 1997-2005 Jeroen van der Zijp