OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
slider.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of classes TSlider & TVSlider. This defines the basic behavior
7/// of slider controls.
8//----------------------------------------------------------------------------
9
10#if !defined(OWL_SLIDER_H)
11#define OWL_SLIDER_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18#include <owl/scrollba.h>
19#include <owl/color.h>
20#include <owl/commctrl.h>
21#include <owl/slider.rh>
22
23namespace owl {
24
25#include <owl/preclass.h>
26
27class _OWLCLASS TDC;
28class _OWLCLASS TRegion;
29class _OWLCLASS TBrush;
30
31//
32/// \class TSlider
33/// An abstract base class derived from TScrollBar, TSlider defines the basic
34/// behavior of sliders (controls that are used for providing nonscrolling, position
35/// information). Like scroll bars, sliders have minimum and maximum positions as
36/// well as line and page magnitude. Sliders can be moved using either the mouse or
37/// the keyboard. If you use a mouse to move the slider, you can drag the thumb
38/// position, click on the slot on either side of the thumb position to move the
39/// thumb by a specified amount (PageMagnitude), or click on the ruler to position
40/// the thumb at a specific spot on the slider. The keyboard's Home and End keys
41/// move the thumb position to the minimum (Min) and maximum (Max) positions on the
42/// slider.
43///
44/// You can use TSlider 's member functions to cause the thumb positions to
45/// automatically align with the nearest tick positions. (This is referred to as
46/// snapping.) You can also specify the tick gaps (the space between the lines that
47/// separate the major divisions of the X- or Y-axis).
48///
49/// The sample program SLIDER.CPP on BC5.0x distribution disk displays a
50/// thermostat that uses sliders:
51/// \image html bm257.BMP
52//
54 : public TScrollBar
55{
56 public:
57
58 TSlider(TWindow* parent, int id, int x, int y, int w, int h, TResId thumbResId, TModule* module = 0);
59 TSlider(TWindow* parent, int resId, TResId thumbResId, TModule* module = 0);
60 TSlider(THandle hWnd, TModule* module = 0);
61
62 ~TSlider() override;
63
64 /// \name Overload TScrollBar virtual functions
65 /// @{
66 void GetRange(int& minValue, int& maxValue) const override;
67 auto GetPosition() const -> int override;
68 void SetRange(int minValue, int maxValue, bool redraw = true) override;
69 void SetPosition(int thumbPos);
70 void SetPosition(int thumbPos, bool redraw) override;
71 /// @}
72
73 /// \name New settings introduced by sliders
74 /// @{
75 void SetRuler(int ticGap, bool snap = false);
76 void SetRuler(int tics[], int ticCount, bool snap = false);
77 void SetSel(int start, int end, bool redraw = true);
78 void GetSel(int& start, int& end);
79 /// @}
80
81 /// \name New messages (version 4.70)
82 /// @{
83 HWND GetBuddy(bool loc=true) const;
84 void SetBuddy(HWND buddy, bool loc=true);
85 HWND GetTooltips() const;
86 void SetTooltips(HWND tooltip);
87 void SetTipSide(int loc);
88 /// @}
89
90 protected:
91
92 // Override TWindow virtual member functions
93 //
94 auto GetWindowClassName() -> TWindowClassName override;
95 void SetupWindow() override;
96
97 int SnapPos(int pos);
98
99 /// \name Event handlers
100 /// @{
101 void EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
102 void EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
103 /// @}
104
106
107 int Min; ///< Minimum position value
108 int Max; ///< Maximum position value
109 uint Range; ///< Positive range
110 int Pos; ///< Current position value
111 TResId ThumbResId; ///< Bitmap res id for thumb knob
112 TRect ThumbRect; ///< Bounding rect of Thumb in pixels
113 TRegion* ThumbRgn; ///< Optional clipping/hit test region
114 TRect CaretRect; ///< Bounding rect of Thumb's blink caret
115 int SlotThick; ///< Thickness(width or height) of slot
116 int TicGap; ///< Gap between tics in pos units
117 int* Tics; ///< Array of specific tics
118 int TicCount; ///< Size of the array of specific tics
119 bool Snap; ///< Snap Thumb to tics
120 int SelStart; ///< Selection start & end
121 int SelEnd;
122
123 bool Sliding; ///< True if the thumb is sliding. Otherwise, false.
124 TColor BkColor; ///< Color to use to paint background
125
128};
129
131
132//
133/// \class THSlider
134/// Derived from TSlider, THSlider provides implementation details for horizontal sliders.
135/// The sample program SLIDER.CPP on BC5.0x distribution disk displays a
136/// thermostat that uses a horizontal slider.
137//
139 : public TSlider
140{
141 public:
142
143 THSlider(TWindow* parent, int id, int x, int y, int w, int h, TResId thumbResId = IDB_HSLIDERTHUMB, TModule* = 0);
146
147 private:
148
149 // Hidden to prevent accidental copying or assignment
150 //
151 THSlider(const THSlider&);
153
155};
156
158
159//
160/// \class TVSlider
161/// Derived from TSlider, TVSlider provides implementation details for vertical
162/// sliders. See TSlider for an illustration of a vertical slider.
163//
165 : public TSlider
166{
167 public:
168
169 TVSlider(TWindow* parent, int id, int x, int y, int w, int h, TResId thumbResId = IDB_VSLIDERTHUMB, TModule* = 0);
172
173 protected:
174
175 private:
176 TVSlider(const TVSlider&);
178
180};
181
183
184#include <owl/posclass.h>
185
186//----------------------------------------------------------------------------
187// Inline implementations
188//
189
190//
191/// Returns the end values of the present range of slider thumb positions in minValue and
192/// maxValue. Overloads TScrollBar's virtual function.
193inline void TSlider::GetRange(int& minValue, int& maxValue) const
194{
195 minValue = Min; maxValue = Max;
196}
197
198//
199/// Returns the slider's current thumb position. Overloads TScrollBar's virtual
200/// function.
201inline int TSlider::GetPosition() const
202{
203 return Pos;
204}
205
206
207//
208// Version 4.70
209//
210inline HWND TSlider::GetBuddy(bool loc) const
211{
213}
214
215//
216// Version 4.70
217//
222
223//
224// Version 4.70
225//
227{
229}
230
231//
232// Version 4.70
233//
238
239//
240// Version 4.70
241//
242inline void TSlider::SetTipSide(int loc)
243{
245}
246
247} // OWL namespace
248
249
250#endif // OWL_SLIDER_H
Class wrapper for management of color values.
Definition color.h:245
Derived from TSlider, THSlider provides implementation details for horizontal sliders.
Definition slider.h:140
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TRegion, derived from TGdiObject, represents GDI abstract shapes or regions.
Definition gdiobjec.h:581
TScrollBar objects represent standalone vertical and horizontal scroll bar controls.
Definition scrollba.h:41
An abstract base class derived from TScrollBar, TSlider defines the basic behavior of sliders (contro...
Definition slider.h:55
void SetBuddy(HWND buddy, bool loc=true)
Definition slider.h:218
HWND GetBuddy(bool loc=true) const
Definition slider.h:210
void SetTipSide(int loc)
Definition slider.h:242
auto GetPosition() const -> int override
Returns the slider's current thumb position.
Definition slider.h:201
void GetRange(int &minValue, int &maxValue) const override
Returns the end values of the present range of slider thumb positions in minValue and maxValue.
Definition slider.h:193
HWND GetTooltips() const
Definition slider.h:226
void SetTooltips(HWND tooltip)
Definition slider.h:234
Derived from TSlider, TVSlider provides implementation details for vertical sliders.
Definition slider.h:166
Type-safe encapsulation of a Windows class name, a union between ATOM and LPCTSTR.
Definition module.h:47
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
Definition of windowing system color classes.
Definition of classes for CommonControl encapsulation.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_ABSTRACT_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1535
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define _OWLCLASS
Definition defs.h:338
Definition of class TScrollBar.