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

FXRealSlider.h
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,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 FXREALSLIDER_H
22 #define FXREALSLIDER_H
23 
24 #ifndef FXFRAME_H
25 #include "FXFrame.h"
26 #endif
27 
28 namespace FX {
29 
30 
32 enum {
33  REALSLIDER_HORIZONTAL = 0,
34  REALSLIDER_VERTICAL = 0x00008000,
35  REALSLIDER_ARROW_UP = 0x00010000,
36  REALSLIDER_ARROW_DOWN = 0x00020000,
37  REALSLIDER_ARROW_LEFT = REALSLIDER_ARROW_UP,
38  REALSLIDER_ARROW_RIGHT = REALSLIDER_ARROW_DOWN,
39  REALSLIDER_INSIDE_BAR = 0x00040000,
40  REALSLIDER_TICKS_TOP = 0x00080000,
41  REALSLIDER_TICKS_BOTTOM = 0x00100000,
42  REALSLIDER_TICKS_LEFT = REALSLIDER_TICKS_TOP,
43  REALSLIDER_TICKS_RIGHT = REALSLIDER_TICKS_BOTTOM,
44  REALSLIDER_NORMAL = REALSLIDER_HORIZONTAL
45  };
46 
47 
57 class FXAPI FXRealSlider : public FXFrame {
58  FXDECLARE(FXRealSlider)
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 on the head is grabbed
65  FXdouble range[2]; // Reported data range
66  FXdouble delta; // Interval between ticks
67  FXdouble incr; // Increment when auto-sliding
68  FXdouble gran; // Granularity
69  FXdouble pos; // Reported data position
70  FXString help; // Help string
71  FXString tip; // Tip string
72 protected:
73  FXRealSlider();
74  void drawSliderHead(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
75  void drawHorzTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
76  void drawVertTicks(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
77 private:
78  FXRealSlider(const FXRealSlider&);
79  FXRealSlider &operator=(const FXRealSlider&);
80 public:
81  long onPaint(FXObject*,FXSelector,void*);
82  long onMotion(FXObject*,FXSelector,void*);
83  long onMouseWheel(FXObject*,FXSelector,void*);
84  long onLeftBtnPress(FXObject*,FXSelector,void*);
85  long onLeftBtnRelease(FXObject*,FXSelector,void*);
86  long onMiddleBtnPress(FXObject*,FXSelector,void*);
87  long onMiddleBtnRelease(FXObject*,FXSelector,void*);
88  long onKeyPress(FXObject*,FXSelector,void*);
89  long onKeyRelease(FXObject*,FXSelector,void*);
90  long onUngrabbed(FXObject*,FXSelector,void*);
91  long onAutoSlide(FXObject*,FXSelector,void*);
92  long onCmdSetValue(FXObject*,FXSelector,void*);
93  long onCmdSetIntValue(FXObject*,FXSelector,void*);
94  long onCmdGetIntValue(FXObject*,FXSelector,void*);
95  long onCmdSetLongValue(FXObject*,FXSelector,void*);
96  long onCmdGetLongValue(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 
117  FXRealSlider(FXComposite* p,FXObject* tgt=nullptr,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 
120  virtual FXint getDefaultWidth();
121 
123  virtual FXint getDefaultHeight();
124 
126  virtual FXbool canFocus() const;
127 
129  virtual void layout();
130 
132  virtual void enable();
133 
135  virtual void disable();
136 
138  void setValue(FXdouble value,FXbool notify=false);
139 
141  FXdouble getValue() const { return pos; }
142 
144  void setRange(FXdouble lo,FXdouble hi,FXbool notify=false);
145 
147  void getRange(FXdouble& lo,FXdouble& hi) const { lo=range[0]; hi=range[1]; }
148 
150  FXuint getSliderStyle() const;
151 
153  void setSliderStyle(FXuint style);
154 
156  FXint getHeadSize() const { return headSize; }
157 
159  void setHeadSize(FXint hs);
160 
162  FXint getSlotSize() const { return slotSize; }
163 
165  void setSlotSize(FXint bs);
166 
168  FXdouble getIncrement() const { return incr; }
169 
171  void setIncrement(FXdouble inc);
172 
174  void setGranularity(FXdouble gr);
175 
177  FXdouble getGranularity() const { return gran; }
178 
180  void setTickDelta(FXdouble dist);
181 
183  FXdouble getTickDelta() const { return delta; }
184 
186  void setSlotColor(FXColor clr);
187 
189  FXColor getSlotColor() const { return slotColor; }
190 
192  void setHelpText(const FXString& text){ help=text; }
193 
195  const FXString& getHelpText() const { return help; }
196 
198  void setTipText(const FXString& text){ tip=text; }
199 
201  const FXString& getTipText() const { return tip; }
202 
204  virtual void save(FXStream& store) const;
205 
207  virtual void load(FXStream& store);
208 
210  virtual ~FXRealSlider();
211  };
212 
213 }
214 
215 #endif
FXint getSlotSize() const
Get the slider&#39;s current slot size.
Definition: FXRealSlider.h:162
The real slider widget is a valuator widget which provides simple linear value range.
Definition: FXRealSlider.h:57
The Frame widget provides borders around some contents.
Definition: FXFrame.h:58
Base composite.
Definition: FXComposite.h:32
A stream is a way to serialize data and objects into a byte stream.
Definition: FXStream.h:81
FXColor getSlotColor() const
Get the current slot color.
Definition: FXRealSlider.h:189
FXdouble getIncrement() const
Get the slider&#39;s auto-increment/decrement value.
Definition: FXRealSlider.h:168
void getRange(FXdouble &lo, FXdouble &hi) const
Get the slider&#39;s current range.
Definition: FXRealSlider.h:147
Definition: FX4Splitter.h:28
FXint getHeadSize() const
Get the slider&#39;s head size.
Definition: FXRealSlider.h:156
const FXString & getHelpText() const
Get the current help text.
Definition: FXRealSlider.h:195
void setHelpText(const FXString &text)
Set the help text to be displayed on the status line.
Definition: FXRealSlider.h:192
void setTipText(const FXString &text)
Set the tip text to be displayed in the tooltip.
Definition: FXRealSlider.h:198
FXdouble getGranularity() const
Return slider&#39;s granularity.
Definition: FXRealSlider.h:177
Object is the base class for all objects in FOX; in order to receive messages from the user interface...
Definition: FXObject.h:134
Window Device Context.
Definition: FXDCWindow.h:48
FXdouble getValue() const
Return slider value.
Definition: FXRealSlider.h:141
FXdouble getTickDelta() const
Get delta between ticks.
Definition: FXRealSlider.h:183
const FXString & getTipText() const
Get the current tooltip text value.
Definition: FXRealSlider.h:201
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp