OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
groupbox.cpp
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/// Implementation of class TGroupBox. This defines the basic behavior for all
7/// group boxes.
8//----------------------------------------------------------------------------
9#include <owl/pch.h>
10#include <owl/groupbox.h>
11#include <owl/applicat.h>
12
13#if defined(OWL_SUPPORT_BWCC)
14# include <owl/private/bwcc.h>
15#endif
16
17namespace owl {
18
20
21
22//
23/// Constructs a group box object with the supplied parent window (Parent), control
24/// ID (Id), associated text (text), position (x, y) relative to the origin of the
25/// parent window's client area, width (w), and height (h). Invokes the TControl
26/// constructor with similar parameters, then modifies Attr.Style, adding
27/// BS_GROUPBOX and removing WS_TABSTOP. NotifyParent is set to true; by default,
28/// the group box's parent is notified when a selection change occurs in any of the
29/// group box's controls.
30//
32 int id,
34 int x, int y, int w, int h,
35 TModule* module)
36:
37 TControl(parent, id, text, x, y, w, h, module)
38{
39 NotifyParent = true;
40 Attr.Style = (Attr.Style | BS_GROUPBOX) & ~WS_TABSTOP;
41}
42
43//
44/// Constructs a group box object with the supplied parent window (Parent), control
45/// ID (Id), associated text (text), position (x, y) relative to the origin of the
46/// parent window's client area, width (w), and height (h). Invokes the TControl
47/// constructor with similar parameters, then modifies Attr.Style, adding
48/// BS_GROUPBOX and removing WS_TABSTOP. NotifyParent is set to true; by default,
49/// the group box's parent is notified when a selection change occurs in any of the
50/// group box's controls.
51//
53 int id,
54 const tstring& text,
55 int x, int y, int w, int h,
56 TModule* module)
57:
58 TControl(parent, id, text, x, y, w, h, module)
59{
60 NotifyParent = true;
61 Attr.Style = (Attr.Style | BS_GROUPBOX) & ~WS_TABSTOP;
62}
63
64//
65/// Returns the name of TGroupBox's Windows registration class, "BUTTON"
66//
68{
69#if defined(OWL_SUPPORT_BWCC)
70 if (GetApplication()->BWCCEnabled())
72 else
73#endif
74 return TWindowClassName{_T("BUTTON")};
75}
76
77//
78/// Constructs a TGroupBox object to be associated with a group box control of a
79/// TDialog. object. Invokes the TControl constructor with identical parameters.
80/// resourceID must correspond to a group box resource that you define.
81///
82/// By default, the parent window is notified when the state of the group box's
83/// selection boxes has changed
84///
85/// Disables transfer of state data for the TGroupBox
86//
88 int resourceId,
89 TModule* module)
90:
91 TControl(parent, resourceId, module)
92{
93 NotifyParent = true;
95}
96
97//
98/// If NotifyParent is true, SelectionChanged notifies the parent window of the
99/// group box that one of its selections has changed by sending it a child-ID-based
100/// message. This member function can be redefined to allow the group box to handle
101/// selection changes in its group of controls.
102//
103void
105{
106 if (NotifyParent)
108 TParam2(GetHandle()));
109}
110
111struct TGroupBoxGetText
112{
113 TGroupBox& groupbox;
114 TGroupBoxGetText(TGroupBox& g) : groupbox(g) {}
115
116 int operator()(LPTSTR buf, int buf_size)
117 {return groupbox.GetText(buf, buf_size);}
118};
119
120//
121/// String-aware overload
122//
124{
125 return CopyText(GetTextLen(), TGroupBoxGetText(*this));
126}
127
128
129
130
132
133#if OWL_PERSISTENT_STREAMS
134
135//
136// reads an instance of TGroupBox from the passed ipstream
137//
138void*
139TGroupBox::Streamer::Read(ipstream& is, uint32 /*version*/) const
140{
141 ReadBaseObject((TControl*)GetObject(), is);
142 is >> GetObject()->NotifyParent;
143 return GetObject();
144}
145
146//
147// writes the TGroupBox to the passed opstream
148//
149void
150TGroupBox::Streamer::Write(opstream& os) const
151{
152 WriteBaseObject((TControl*)GetObject(), os);
153 os << GetObject()->NotifyParent;
154}
155#endif
156
157} // OWL namespace
158/* ========================================================================== */
159
Definition of class TApplication.
Legacy support for Borland Windows Custom Controls (BWCC)
TControl unifies its derived control classes, such as TScrollBar, TControlGadget, and TButton.
Definition control.h:38
An instance of a TGroupBox is an interface object that represents a corresponding group box element.
Definition groupbox.h:50
tstring GetText()
String-aware overload.
Definition groupbox.cpp:123
int GetTextLen()
Returns the length of the control's text.
Definition groupbox.h:109
virtual auto GetWindowClassName() -> TWindowClassName
Returns the name of TGroupBox's Windows registration class, "BUTTON".
Definition groupbox.cpp:67
TGroupBox(TWindow *parent, int id, LPCTSTR text, int X, int Y, int W, int H, TModule *module=0)
Constructs a group box object with the supplied parent window (Parent), control ID (Id),...
Definition groupbox.cpp:31
int GetText(TCHAR *str, int maxChars)
Fills the given string with the text of the control.
Definition groupbox.h:114
virtual void SelectionChanged(int controlId)
If NotifyParent is true, SelectionChanged notifies the parent window of the group box that one of its...
Definition groupbox.cpp:104
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
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
void DisableTransfer()
Disables (for the interface object) the transfer mechanism, which allows state data to be transferred...
Definition window.h:1835
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
Definition window.h:2103
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
#define _T(x)
Definition cygwin.h:51
void ReadBaseObject(Base *base, ipstream &in)
Definition objstrm.h:1159
#define IMPLEMENT_STREAMABLE1(cls, base1)
Definition objstrm.h:1725
void WriteBaseObject(Base *base, opstream &out)
Definition objstrm.h:1150
Definition of class TGroupBox.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
unsigned long uint32
Definition number.h:34
tstring CopyText(int size, TGetText get_text)
Copies text from a C-string (null-terminated character array) into a string object,...
Definition defs.h:317
OWL_DIAGINFO
Definition animctrl.cpp:14
TParam1 MkParam1(uint lo, uint hi)
Definition dispatch.h:68
std::string tstring
Definition defs.h:79