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,2017 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=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 
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

Copyright © 1997-2016 Jeroen van der Zijp