Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
Thumb.h
1/***********************************************************************
2 created: 25/4/2004
3 author: Paul D Turner
4
5 purpose: Interface for a 'Thumb' widget. Intended to be used as
6 part of other widgets such as scrollers and sliders.
7*************************************************************************/
8/***************************************************************************
9 * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files (the
13 * "Software"), to deal in the Software without restriction, including
14 * without limitation the rights to use, copy, modify, merge, publish,
15 * distribute, sublicense, and/or sell copies of the Software, and to
16 * permit persons to whom the Software is furnished to do so, subject to
17 * the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28 * OTHER DEALINGS IN THE SOFTWARE.
29 ***************************************************************************/
30#ifndef _CEGUIThumb_h_
31#define _CEGUIThumb_h_
32
33#include "./PushButton.h"
34#include <utility>
35
36
37#if defined(_MSC_VER)
38# pragma warning(push)
39# pragma warning(disable : 4251)
40# pragma warning(disable : 4996)
41#endif
42
43
44// Start of CEGUI namespace section
45namespace CEGUI
46{
47
55class CEGUIEXPORT Thumb : public PushButton
56{
57public:
58 static const String EventNamespace;
59 static const String WidgetTypeName;
60
61 /*************************************************************************
62 Event name constants
63 *************************************************************************/
64 // generated internally by Window
82
83
84 /*************************************************************************
85 Accessor Functions
86 *************************************************************************/
94 bool isHotTracked(void) const {return d_hotTrack;}
95
104 bool isVertFree(void) const {return d_vertFree;}
105
114 bool isHorzFree(void) const {return d_horzFree;}
115
116
125 std::pair<float, float> getVertRange(void) const;
126
127
136 std::pair<float, float> getHorzRange(void) const;
137
138
139 /*************************************************************************
140 Manipulator Functions
141 *************************************************************************/
152 void setHotTracked(bool setting) {d_hotTrack = setting;}
153
154
165 void setVertFree(bool setting) {d_vertFree = setting;}
166
167
178 void setHorzFree(bool setting) {d_horzFree = setting;}
179
180
197 void setVertRange(float min, float max);
198
212 void setVertRange(const std::pair<float, float> &range);
213
214
231 void setHorzRange(float min, float max);
245 void setHorzRange(const std::pair<float, float> &range);
246
247
248 /*************************************************************************
249 Construction / Destruction
250 *************************************************************************/
255 Thumb(const String& type, const String& name);
256
257
262 virtual ~Thumb(void);
263
264
265protected:
266 // overridden from base class
267 void banPropertiesForAutoWindow();
268
269 /*************************************************************************
270 New Thumb Events
271 *************************************************************************/
277
278
284
285
291
292
293
294 /*************************************************************************
295 Overridden event handling routines
296 *************************************************************************/
300
301
302 /*************************************************************************
303 Implementation Data
304 *************************************************************************/
305 // general settings
309
310 // operational limits
311 float d_vertMin, d_vertMax;
312 float d_horzMin, d_horzMax;
313
314 // internal state
317
318
319private:
320 /*************************************************************************
321 Private methods
322 *************************************************************************/
323 void addThumbProperties(void);
324};
325
326/*
327TODO: This is horrible, PropertyHelper for std::pair<float, float> would be fine but enforcing min: %f max: %f is just horrible
328*/
329template<>
330class PropertyHelper<std::pair<float,float> >
331{
332public:
333 typedef std::pair<float,float> return_type;
334 typedef return_type safe_method_return_type;
335 typedef const std::pair<float,float>& pass_type;
337
338 static const String& getDataTypeName()
339 {
340 static String type("std::pair<float,float>");
341
342 return type;
343 }
344
345 static return_type fromString(const String& str)
346 {
347 float rangeMin = 0, rangeMax = 0;
348 sscanf(str.c_str(), " min:%f max:%f", &rangeMin, &rangeMax);
349 return std::pair<float,float>(rangeMin,rangeMax);
350 }
351
352 static string_return_type toString(pass_type val)
353 {
354 char buff[64];
355 sprintf(buff, "min:%f max:%f", val.first, val.second);
356 return buff;
357 }
358};
359
360} // End of CEGUI namespace section
361
362#if defined(_MSC_VER)
363# pragma warning(pop)
364#endif
365
366#endif // end of guard _CEGUIThumb_h_
EventArgs based class that is used for objects passed to input event handlers concerning mouse input.
Definition InputEvent.h:281
Helper class used to convert various data types to and from the format expected in Property strings.
Definition ForwardRefs.h:84
Base class to provide logic for push button type widgets.
Definition PushButton.h:48
String class used within the GUI system.
Definition String.h:64
Base class for Thumb widget.
Definition Thumb.h:56
bool d_beingDragged
true if thumb is being dragged
Definition Thumb.h:315
bool isHorzFree(void) const
return whether the thumb is movable on the horizontal axis.
Definition Thumb.h:114
static const String EventNamespace
Namespace for global events.
Definition Thumb.h:58
virtual void onThumbPositionChanged(WindowEventArgs &e)
event triggered internally when the position of the thumb
void setVertFree(bool setting)
set whether thumb is movable on the vertical axis.
Definition Thumb.h:165
void setHorzFree(bool setting)
set whether thumb is movable on the horizontal axis.
Definition Thumb.h:178
virtual void onThumbTrackStarted(WindowEventArgs &e)
Handler triggered when the user begins to drag the thumb.
bool isVertFree(void) const
return whether the thumb is movable on the vertical axis.
Definition Thumb.h:104
std::pair< float, float > getVertRange(void) const
Return a std::pair that describes the current range set for the vertical movement.
static const String EventThumbTrackStarted
Definition Thumb.h:76
Thumb(const String &type, const String &name)
Constructor for Thumb objects.
Vector2f d_dragPoint
point where we are being dragged at.
Definition Thumb.h:316
virtual ~Thumb(void)
Destructor for Thumb objects.
float d_horzMax
horizontal range
Definition Thumb.h:312
bool d_hotTrack
true if events are to be sent real-time, else just when thumb is released
Definition Thumb.h:306
virtual void onThumbTrackEnded(WindowEventArgs &e)
Handler triggered when the thumb is released.
void setHotTracked(bool setting)
set whether the thumb uses hot-tracking.
Definition Thumb.h:152
void setHorzRange(const std::pair< float, float > &range)
set the movement range of the thumb for the horizontal axis.
virtual void onMouseButtonDown(MouseEventArgs &e)
Handler called when a mouse button has been depressed within this window's area.
virtual void onCaptureLost(WindowEventArgs &e)
Handler called when this window loses capture of mouse inputs.
void setVertRange(float min, float max)
set the movement range of the thumb for the vertical axis.
void setHorzRange(float min, float max)
set the movement range of the thumb for the horizontal axis.
bool d_horzFree
true if thumb is movable horizontally
Definition Thumb.h:308
bool isHotTracked(void) const
return whether hot-tracking is enabled or not.
Definition Thumb.h:94
static const String WidgetTypeName
Window factory name.
Definition Thumb.h:59
float d_vertMax
vertical range
Definition Thumb.h:311
bool d_vertFree
true if thumb is movable vertically
Definition Thumb.h:307
static const String EventThumbPositionChanged
Definition Thumb.h:70
std::pair< float, float > getHorzRange(void) const
Return a std::pair that describes the current range set for the horizontal movement.
void setVertRange(const std::pair< float, float > &range)
set the movement range of the thumb for the vertical axis.
static const String EventThumbTrackEnded
Definition Thumb.h:81
virtual void onMouseMove(MouseEventArgs &e)
Handler called when the mouse cursor has been moved within this window's area.
base class for properties able to do native set/get
Definition TypedProperty.h:50
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition InputEvent.h:252
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1