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
updown.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1995, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of class TUpDown.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_UPDOWN_H)
10#define OWL_UPDOWN_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/control.h>
18#include <owl/commctrl.h>
19
20namespace owl {
21
22#include <owl/preclass.h>
23
24//
25/// \class TUDAccel
26// ~~~~~ ~~~~~~~~
27/// TUDAccel is a very thin wrapper for the UDACCEL structure which contains
28/// information about updown accelarators. The main purpose of this class is to have
29/// a place-holder for future abstraction/encapsulation.
30//
31class TUDAccel : public UDACCEL {
32};
33
34//
35/// \class TUpDown
36// ~~~~~ ~~~~~~~
37/// TUpDown encapsulates an up-down control, which is a window with a pair of arrow
38/// buttons that the user can click to increment or decrement a value.
39//
40class _OWLCLASS TUpDown : public TControl {
41 public:
42 TUpDown(TWindow* parent,
43 int id,
44 int x, int y, int w, int h,
45 TWindow* buddy = 0,
46 TModule* module = 0);
47
48 TUpDown(TWindow* parent, int resourceId, TWindow* buddy = 0, TModule* module = 0);
49
50 int GetAccel(int count, TUDAccel * accels) const;
51 int GetBase() const;
52 HWND GetBuddy() const;
53 int32 GetPos() const;
54 uint32 GetRange() const;
55 void GetRange(int& lower, int& upper) const;
56
57 bool SetAccel(int count, const TUDAccel * accels);
58 int SetBase(int base);
59 HWND SetBuddy(HWND hBuddy);
60 TResult SetPos(int pos);
61 void SetRange(int lower, int upper);
62
63 protected:
64 // Override TWindow virtual member functions
65 //
66 auto GetWindowClassName() -> TWindowClassName override;
67 auto PerformCreate() -> THandle override;
68 void EvVScroll(uint, uint, HWND);
69 void EvHScroll(uint, uint, HWND);
70
71
72 private:
73 // Hidden to prevent accidental copying or assignment
74 //
75 TUpDown(const TUpDown&);
76 TUpDown& operator =(const TUpDown&);
77
78 // Data members used to hold creation attributes of control
79 // NOTE: These variables are not kept in sync with the actual
80 // state of the control when the class makes use of the
81 // CommonControl implementation of 'UPDOWN'
82 //
83 TWindow* Buddy; ///< Pointer to buddy window
84 int Lower; ///< Low end of range
85 int Upper; ///< High end of range
86 int Pos; ///< Current/Staring posotion
87
89};
90
91#include <owl/posclass.h>
92
93//----------------------------------------------------------------------------
94// Inlines
95//
96
97/// Retrieves acceleration information for the underlying up-down control
98//
99inline int TUpDown::GetAccel(int count, TUDAccel * accels) const {
100 return static_cast<int>(CONST_CAST(TUpDown*,this)->SendMessage(UDM_GETACCEL, count, TParam2(accels)));
101}
102
103/// Retrieves the current radix base of the underlying up-down control.
104/// Return value is either 10 or 16.
105//
106inline int TUpDown::GetBase() const {
107 return static_cast<int>(CONST_CAST(TUpDown*,this)->SendMessage(UDM_GETBASE));
108}
109
110/// Retrieves handle of buddy window of underlying up-down control
111//
112inline HWND TUpDown::GetBuddy() const {
113 return reinterpret_cast<HWND>(CONST_CAST(TUpDown*,this)->SendMessage(UDM_GETBUDDY));
114}
115
116/// Returns current position of underlying up-down control. The high-order
117/// word in non-zero in case of an error. The current position is in the
118/// low-order word.
119//
120inline int32 TUpDown::GetPos() const {
121 return static_cast<int32>(LoUint16(CONST_CAST(TUpDown*,this)->SendMessage(UDM_GETPOS)));
122}
123
124/// Retrieves the minimum and maximum range of the underlying up-down control.
125/// The low-order word contains the maximum position while the high-order
126/// word contains the minimum position.
127//
128inline uint32 TUpDown::GetRange() const {
129 return static_cast<uint32>(CONST_CAST(TUpDown*,this)->SendMessage(UDM_GETRANGE));
130}
131
132/// Retrieves the minimum and maximum range of the underlying up-down control
133/// into the specified 'lower' and 'upper' variables respectively.
134//
135inline void TUpDown::GetRange(int& lower, int& upper) const {
136 TResult ret = CONST_CAST(TUpDown*,this)->SendMessage(UDM_GETRANGE);
137 lower = HiUint16(ret);
138 upper = LoUint16(ret);
139}
140
141/// Set the acceleration of the underlying up-down control. 'count'
142/// specifies the number of structures specified in 'accels' while the
143/// latter is the address of an array of TUDAccel structures.
144//
145inline bool TUpDown::SetAccel(int count, const TUDAccel * accels) {
146 return ToBool(SendMessage(UDM_SETACCEL, count, TParam2(accels)));
147}
148
149/// Sets the radix of the underlying up-down control. The 'base' parameter
150/// should be either '10' or '16' for decimal and hexadecimal respectively.
151//
152inline int TUpDown::SetBase(int base) {
153 return int(SendMessage(UDM_SETBASE, base));
154}
155
156/// Sets the buddy window of the underlying up-down control.
157//
161
162/// Sets the current position of the underlying up-down control. The
163/// return value is the previous position.
164//
166 return SendMessage(UDM_SETPOS, 0, MkParam2(pos, 0));
167}
168
169/// Sets the minimum and maximum positions of the up-down control.
170/// \note Neither 'lower' nor 'upper' can be greater than UD_MAXVAL or
171/// less than UD_MINVAL. Futhermore, the difference between the two
172/// positions must not exceed UD_MAXVAL;
173//
182
183
184
185} // OWL namespace
186
187
188#endif // OWL_UPDOWN_H
#define PRECONDITION(condition)
Definition checks.h:227
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TUDAccel is a very thin wrapper for the UDACCEL structure which contains information about updown acc...
Definition updown.h:31
TUpDown encapsulates an up-down control, which is a window with a pair of arrow buttons that the user...
Definition updown.h:40
uint32 GetRange() const
Retrieves the minimum and maximum range of the underlying up-down control.
Definition updown.h:128
int GetBase() const
Retrieves the current radix base of the underlying up-down control.
Definition updown.h:106
HWND SetBuddy(HWND hBuddy)
Sets the buddy window of the underlying up-down control.
Definition updown.h:158
void SetRange(int lower, int upper)
Sets the minimum and maximum positions of the up-down control.
Definition updown.h:174
int SetBase(int base)
Sets the radix of the underlying up-down control.
Definition updown.h:152
TResult SetPos(int pos)
Sets the current position of the underlying up-down control.
Definition updown.h:165
HWND GetBuddy() const
Retrieves handle of buddy window of underlying up-down control.
Definition updown.h:112
int GetAccel(int count, TUDAccel *accels) const
Retrieves acceleration information for the underlying up-down control.
Definition updown.h:99
bool SetAccel(int count, const TUDAccel *accels)
Set the acceleration of the underlying up-down control.
Definition updown.h:145
int32 GetPos() const
Returns current position of underlying up-down control.
Definition updown.h:120
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 classes for CommonControl encapsulation.
Definition of class TControl.
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
uint16 HiUint16(LRESULT r)
Definition defs.h:270
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
bool ToBool(const T &t)
Definition defs.h:291
WPARAM TParam1
First parameter type.
Definition dispatch.h:54
uint16 LoUint16(LRESULT r)
Definition defs.h:264
TParam2 MkParam2(const T1 &lo, const T2 &hi)
Definition dispatch.h:65
unsigned int uint
Definition number.h:25
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define _OWLCLASS
Definition defs.h:338