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
checkbox.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4//
5///\file
6/// Definition of class TCheckBox. This defines the basic behavior for all check
7/// boxes.
8//----------------------------------------------------------------------------
9
10#if !defined(OWL_CHECKBOX_H)
11#define OWL_CHECKBOX_H
12
13#include <owl/private/defs.h>
14#if defined(BI_HAS_PRAGMA_ONCE)
15# pragma once
16#endif
17
18#include <owl/button.h>
19
20namespace owl {
21
22class _OWLCLASS TGroupBox;
23
24//
25/// Check box and radio button objects use the button flag constants to indicate the
26/// state of a selection box.
27//
28enum {
29 BF_CHECKED = 0x01, ///< Item is checked
30 BF_GRAYED = 0x02, ///< Item is grayed
31 BF_UNCHECKED = 0x00, ///< Item is unchecked
32};
33
34#include <owl/preclass.h>
35
36//
37/// \addtogroup ctrl
38/// @{
39
40//
41/// \class TCheckBox
42/// TCheckBox is a streamable interface class that represents a check box control.
43/// Use TCheckBox to create a check box control in a parent window. You can also use
44/// TCheckBox objects to more easily manipulate check boxes you created in a dialog
45/// box resource.
46/// Two-state check boxes can be checked or unchecked; three-state check boxes have
47/// an additional grayed state. TCheckBox member functions let you easily control
48/// the check box's state. A check box can be in a group box (a TGroupBox object)
49/// that groups related controls.
50//
52 : public TButton
53{
54 public:
55
56 TCheckBox(TWindow* parent, int id, LPCTSTR title, int x, int y, int w, int h, TGroupBox* = 0, TModule* = 0);
57 TCheckBox(TWindow* parent, int id, const tstring& title, int x, int y, int w, int h, TGroupBox* = 0, TModule* = 0);
58 TCheckBox(TWindow* parent, int resId, TGroupBox* = 0, TModule* = 0);
60
61 ~TCheckBox() override;
62
63 void Check(bool check = true);
64 void Uncheck();
65 void Toggle();
66
67 bool IsChecked() const {return GetCheck() == BST_CHECKED;}
68 bool IsUnchecked() const {return GetCheck() == BST_UNCHECKED;}
69 bool IsIndeterminate() const {return GetCheck() == BST_INDETERMINATE;}
70
71 uint GetCheck() const;
72 void SetCheck(uint check);
73
74 TGroupBox* GetGroup() const;
75 void SetGroup(TGroupBox* group);
76
77 /// Safe overload
78 //
80
81 protected:
82
83 /// Override TButton's processing so drawable check boxes and radio
84 /// buttons work properly
85 //
86 uint EvGetDlgCode(const MSG*);
87
88 // Child id notification
89 //
90 void BNClicked(); // BN_CLICKED
91
92 // Override TWindow virtual member functions
93 //
94 auto Transfer(void* buffer, TTransferDirection) -> uint override;
95 auto GetWindowClassName() -> TWindowClassName override;
96
98
99 /// If the check box belongs to a group box (a TGroupBox object), Group points to
100 /// that object. If the check box is not part of a group, Group is zero.
101 //
102 TGroupBox* Group;
103
104 private:
105
106 // Hidden to prevent accidental copying or assignment
107 //
108 TCheckBox(const TCheckBox&);
110
113};
114
115/// @}
116
118
119#include <owl/posclass.h>
120
121//
122/// Forces the check box to be checked or unchecked by calling SetCheck() with
123/// the value BF_CHECKED or BF_UNCHECKED based on the value of `check`, which
124/// defaults to true. Notifies the associated group box, if there is one, that
125/// the state was changed.
126//
127inline void TCheckBox::Check(bool check) {
129}
130
131//
132/// Forces the check box to be unchecked by calling SetCheck() with a value of
133/// BF_UNCHECKED. Notifies the associated group box, if there is one, that the state
134/// has changed.
135//
136inline void TCheckBox::Uncheck() {
138}
139
140//
141/// Returns the group with which the checkbox is associated.
142//
144 return Group;
145}
146
147//
148/// Sets the group with which the checkbox is associated.
149//
151 Group = group;
152}
153
154//
155/// Overrides TButton's response to the WM_GETDLGCODE message, an input procedure
156/// associated with a control that is not a check box, by calling DefaultProcessing.
157/// The msg parameter indicates the kind of message sent to the dialog box manager,
158/// such as a control message, a command message, or a check box message.
159/// EvGetDlgCode returns a code that indicates how the check box is to be treated.
160//
162 return static_cast<uint>(DefaultProcessing());
163}
164
165//
166/// Returns the state of the check box.
167//
168inline uint TCheckBox::GetCheck() const {
170 return static_cast<uint>(CONST_CAST(TCheckBox*, this)->SendMessage(BM_GETCHECK));
171}
172
173
174} // OWL namespace
175
176
177#endif // OWL_CHECKBOX_H
Definition of class TButton.
#define PRECONDITION(condition)
Definition checks.h:227
TButton is an interface class derived from TControl that represents a pushbutton interface element.
Definition button.h:41
TCheckBox is a streamable interface class that represents a check box control.
Definition checkbox.h:53
bool IsIndeterminate() const
Definition checkbox.h:69
uint GetCheck() const
Returns the state of the check box.
Definition checkbox.h:168
bool IsUnchecked() const
Definition checkbox.h:68
void SetGroup(TGroupBox *group)
Sets the group with which the checkbox is associated.
Definition checkbox.h:150
void Uncheck()
Forces the check box to be unchecked by calling SetCheck() with a value of BF_UNCHECKED.
Definition checkbox.h:136
TGroupBox * GetGroup() const
Returns the group with which the checkbox is associated.
Definition checkbox.h:143
void Check(bool check=true)
Forces the check box to be checked or unchecked by calling SetCheck() with the value BF_CHECKED or BF...
Definition checkbox.h:127
bool IsChecked() const
Definition checkbox.h:67
uint EvGetDlgCode(const MSG *)
Override TButton's processing so drawable check boxes and radio buttons work properly.
Definition checkbox.h:161
void Transfer(WORD &state, TTransferDirection direction)
Safe overload.
Definition checkbox.h:79
void SetCheck(uint check)
Forces the check box into the state specified by check.
Definition checkbox.cpp:160
An instance of a TGroupBox is an interface object that represents a corresponding group box element.
Definition groupbox.h:50
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
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 DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
Definition window.cpp:852
HWND THandle
TWindow encapsulates an HWND.
Definition window.h:418
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
TTransferDirection
The TTransferDirection enum describes the constants that the transfer function uses to determine how ...
Definition window.h:92
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
@ BF_UNCHECKED
Item is unchecked.
Definition checkbox.h:31
@ BF_GRAYED
Item is grayed.
Definition checkbox.h:30
@ BF_CHECKED
Item is checked.
Definition checkbox.h:29
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
#define public_data
Definition defs.h:207
#define CONST_CAST(targetType, object)
Definition defs.h:273
#define _OWLCLASS
Definition defs.h:338