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

FXSlider.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * 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: FXSlider.h,v 1.44 2006/01/22 17:58:09 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXSLIDER_H
25 #define FXSLIDER_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  SLIDER_HORIZONTAL = 0, /// Slider shown horizontally
37  SLIDER_VERTICAL = 0x00008000, /// Slider shown vertically
38  SLIDER_ARROW_UP = 0x00010000, /// Slider has arrow head pointing up
39  SLIDER_ARROW_DOWN = 0x00020000, /// Slider has arrow head pointing down
40  SLIDER_ARROW_LEFT = SLIDER_ARROW_UP, /// Slider has arrow head pointing left
41  SLIDER_ARROW_RIGHT = SLIDER_ARROW_DOWN, /// Slider has arrow head pointing right
42  SLIDER_INSIDE_BAR = 0x00040000, /// Slider is inside the slot rather than overhanging
43  SLIDER_TICKS_TOP = 0x00080000, /// Ticks on the top of horizontal slider
44  SLIDER_TICKS_BOTTOM = 0x00100000, /// Ticks on the bottom of horizontal slider
45  SLIDER_TICKS_LEFT = SLIDER_TICKS_TOP, /// Ticks on the left of vertical slider
46  SLIDER_TICKS_RIGHT = SLIDER_TICKS_BOTTOM, /// Ticks on the right of vertical slider
48  };
49 
50 
51 /**
52 * The 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 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 FXint.
59 */
60 class FXAPI FXSlider : public FXFrame {
62 protected:
63  FXint range[2]; // Reported data range
64  FXint pos; // Reported data position
65  FXint incr; // Increment when auto-sliding
66  FXint 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 the head is grabbed
72  FXString help; // Help string
73  FXString tip; // Tip string
74 protected:
75  FXSlider();
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  FXSlider(const FXSlider&);
81  FXSlider &operator=(const FXSlider&);
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  FXSlider(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=SLIDER_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(FXint value,FXbool notify=FALSE);
139 
140  /// Return slider value
141  FXint getValue() const { return pos; }
142 
143  /// Change the slider's range
144  void setRange(FXint lo,FXint hi,FXbool notify=FALSE);
145 
146  /// Get the slider's current range
147  void getRange(FXint& lo,FXint& 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  FXint getIncrement() const { return incr; }
169 
170  /// Change the slider's auto-increment/decrement value
171  void setIncrement(FXint inc);
172 
173  /// Change the delta between ticks
174  void setTickDelta(FXint dist);
175 
176  /// Get delta between ticks
177  FXint 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 ~FXSlider();
205  };
206 
207 }
208 
209 #endif
FXVec2d lo(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:174
Ticks on the top of horizontal slider.
Definition: FXSlider.h:46
Slider has arrow head pointing right.
Definition: FXSlider.h:44
The Frame widget provides borders around some contents.
Definition: FXFrame.h:73
Definition: FXWindow.h:241
unsigned int FXuint
Definition: fxdefs.h:389
FXuint FXSelector
Association key.
Definition: FXObject.h:53
Slider is inside the slot rather than overhanging.
Definition: FXSlider.h:45
#define FXAPI
Definition: fxdefs.h:122
The slider widget is a valuator widget which provides simple linear value range.
Definition: FXSlider.h:67
FXuchar FXbool
Definition: fxdefs.h:386
Ticks on the right of vertical slider.
Definition: FXSlider.h:49
Base composite.
Definition: FXComposite.h:35
Slider has arrow head pointing up.
Definition: FXSlider.h:41
#define NULL
Definition: fxdefs.h:41
FXuint FXColor
Definition: fxdefs.h:447
Definition: FXSlider.h:50
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:390
Ticks on the left of vertical slider.
Definition: FXSlider.h:48
FXVec2d hi(const FXVec2d &a, const FXVec2d &b)
Definition: FXVec2d.h:175
Ticks on the bottom of horizontal slider.
Definition: FXSlider.h:47
Slider shown vertically.
Definition: FXSlider.h:40
Slider has arrow head pointing left.
Definition: FXSlider.h:43
#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 shown horizontally.
Definition: FXSlider.h:39
Slider has arrow head pointing down.
Definition: FXSlider.h:42
#define FXDECLARE(classname)
Macro to set up class declaration.
Definition: FXObject.h:92
FXString provides essential string manipulation capabilities.
Definition: FXString.h:33

Copyright © 1997-2005 Jeroen van der Zijp