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

FXSlider.h
1 /********************************************************************************
2 * *
3 * S l i d e r W i d g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1997,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (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 *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXSLIDER_H
22 #define FXSLIDER_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  SLIDER_HORIZONTAL = 0,
34  SLIDER_VERTICAL = 0x00008000,
35  SLIDER_ARROW_UP = 0x00010000,
36  SLIDER_ARROW_DOWN = 0x00020000,
37  SLIDER_ARROW_LEFT = SLIDER_ARROW_UP,
38  SLIDER_ARROW_RIGHT = SLIDER_ARROW_DOWN,
39  SLIDER_INSIDE_BAR = 0x00040000,
40  SLIDER_TICKS_TOP = 0x00080000,
41  SLIDER_TICKS_BOTTOM = 0x00100000,
42  SLIDER_TICKS_LEFT = SLIDER_TICKS_TOP,
43  SLIDER_TICKS_RIGHT = SLIDER_TICKS_BOTTOM,
44  SLIDER_NORMAL = SLIDER_HORIZONTAL
45  };
46 
47 
57 class FXAPI FXSlider : public FXFrame {
58  FXDECLARE(FXSlider)
59 protected:
60  FXint headPos; // Head position
61  FXint headSize; // Head size
62  FXint slotSize; // Slot size
63  FXColor slotColor; // Color of slot the head moves in
64  FXint dragPoint; // Where the head is grabbed
65  FXint range[2]; // Reported data range
66  FXint delta; // Interval between ticks
67  FXint incr; // Increment when auto-sliding
68  FXint pos; // Reported data position
69  FXString help; // Help string
70  FXString tip; // Tip string
71 protected:
72  FXSlider();
73  void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
74  void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
75  void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
76 private:
77  FXSlider(const FXSlider&);
78  FXSlider &operator=(const FXSlider&);
79 public:
80  long onPaint(FXObject*,FXSelector,void*);
81  long onMotion(FXObject*,FXSelector,void*);
82  long onMouseWheel(FXObject*,FXSelector,void*);
83  long onLeftBtnPress(FXObject*,FXSelector,void*);
84  long onLeftBtnRelease(FXObject*,FXSelector,void*);
85  long onMiddleBtnPress(FXObject*,FXSelector,void*);
86  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
87  long onKeyPress(FXObject*,FXSelector,void*);
88  long onKeyRelease(FXObject*,FXSelector,void*);
89  long onUngrabbed(FXObject*,FXSelector,void*);
90  long onAutoSlide(FXObject*,FXSelector,void*);
91  long onCmdSetValue(FXObject*,FXSelector,void*);
92  long onCmdSetIntValue(FXObject*,FXSelector,void*);
93  long onCmdGetIntValue(FXObject*,FXSelector,void*);
94  long onCmdSetLongValue(FXObject*,FXSelector,void*);
95  long onCmdGetLongValue(FXObject*,FXSelector,void*);
96  long onCmdSetRealValue(FXObject*,FXSelector,void*);
97  long onCmdGetRealValue(FXObject*,FXSelector,void*);
98  long onCmdSetIntRange(FXObject*,FXSelector,void*);
99  long onCmdGetIntRange(FXObject*,FXSelector,void*);
100  long onCmdSetRealRange(FXObject*,FXSelector,void*);
101  long onCmdGetRealRange(FXObject*,FXSelector,void*);
102  long onCmdSetHelp(FXObject*,FXSelector,void*);
103  long onCmdGetHelp(FXObject*,FXSelector,void*);
104  long onCmdSetTip(FXObject*,FXSelector,void*);
105  long onCmdGetTip(FXObject*,FXSelector,void*);
106  long onQueryHelp(FXObject*,FXSelector,void*);
107  long onQueryTip(FXObject*,FXSelector,void*);
108 public:
109  enum{
110  ID_AUTOSLIDE=FXFrame::ID_LAST,
111  ID_LAST
112  };
113 public:
114 
116  FXSlider(FXComposite* p,FXObject* tgt=nullptr,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);
117 
119  virtual FXint getDefaultWidth();
120 
122  virtual FXint getDefaultHeight();
123 
125  virtual FXbool canFocus() const;
126 
128  virtual void layout();
129 
131  virtual void enable();
132 
134  virtual void disable();
135 
137  void setValue(FXint value,FXbool notify=false);
138 
140  FXint getValue() const { return pos; }
141 
143  void setRange(FXint lo,FXint hi,FXbool notify=false);
144 
146  void getRange(FXint& lo,FXint& hi) const { lo=range[0]; hi=range[1]; }
147 
149  FXuint getSliderStyle() const;
150 
152  void setSliderStyle(FXuint style);
153 
155  FXint getHeadSize() const { return headSize; }
156 
158  void setHeadSize(FXint hs);
159 
161  FXint getSlotSize() const { return slotSize; }
162 
164  void setSlotSize(FXint bs);
165 
167  FXint getIncrement() const { return incr; }
168 
170  void setIncrement(FXint inc);
171 
173  void setTickDelta(FXint dist);
174 
176  FXint getTickDelta() const { return delta; }
177 
179  void setSlotColor(FXColor clr);
180 
182  FXColor getSlotColor() const { return slotColor; }
183 
185  void setHelpText(const FXString& text){ help=text; }
186 
188  const FXString& getHelpText() const { return help; }
189 
191  void setTipText(const FXString& text){ tip=text; }
192 
194  const FXString& getTipText() const { return tip; }
195 
197  virtual void save(FXStream& store) const;
198 
200  virtual void load(FXStream& store);
201 
203  virtual ~FXSlider();
204  };
205 
206 }
207 
208 #endif
FXint getHeadSize() const
Get the slider&#39;s head size.
Definition: FXSlider.h:155
The Frame widget provides borders around some contents.
Definition: FXFrame.h:58
The slider widget is a valuator widget which provides simple linear value range.
Definition: FXSlider.h:57
Base composite.
Definition: FXComposite.h:32
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
void getRange(FXint &lo, FXint &hi) const
Get the slider&#39;s current range.
Definition: FXSlider.h:146
FXint getIncrement() const
Get the slider&#39;s auto-increment/decrement value.
Definition: FXSlider.h:167
FXint getSlotSize() const
Get the slider&#39;s current slot size.
Definition: FXSlider.h:161
Definition: FX4Splitter.h:28
void setHelpText(const FXString &text)
Set the help text to be displayed on the status line.
Definition: FXSlider.h:185
FXColor getSlotColor() const
Get the current slot color.
Definition: FXSlider.h:182
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:138
Window Device Context.
Definition: FXDCWindow.h:48
const FXString & getHelpText() const
Get the current help text.
Definition: FXSlider.h:188
FXint getValue() const
Return slider value.
Definition: FXSlider.h:140
const FXString & getTipText() const
Get the current tooltip text value.
Definition: FXSlider.h:194
FXint getTickDelta() const
Get delta between ticks.
Definition: FXSlider.h:176
void setTipText(const FXString &text)
Set the tip text to be displayed in the tooltip.
Definition: FXSlider.h:191
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp