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
framewin.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 class TFrameWindow.
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_FRAMEWIN_H)
10#define OWL_FRAMEWIN_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/window.h>
18#include <owl/menu.h>
19#include <memory>
20
21namespace owl {
22
23#include <owl/preclass.h>
24
25//
26// MDI window IDs
27//
28const unsigned int IDW_MDICLIENT = 32000; ///< ID of MDI client window
29const unsigned int IDW_FIRSTMDICHILD = 32001; ///< child window IDs, 32 max to 32032
30
31/// \addtogroup enabler
32/// @{
33/// \class TMenuItemEnabler
34// ~~~~~ ~~~~~~~~~~~~~~~~
35/// Derived from TCommandEnabler, TMenuItemEnabler is a command enabler for menu
36/// items. The functions in this class modify the text, check state, and appearance
37/// of a menu item.
38//
40 public:
42
43 // Override member functions of TCommandEnabler
44 //
45 void Enable(bool enable);
46 void SetText(LPCTSTR text);
47 using TCommandEnabler::SetText; ///< String-aware overload
48 void SetCheck(int check);
49
50 // Menu specific member functions
51 //
52 HMENU GetMenu();
53 int GetPosition();
54
56
57/// The menu that holds the item being enabled or disabled.
58 HMENU HMenu;
59
60/// The position of the menu item.
61 int Position;
62};
63/// @}
64
65/// \addtogroup frame
66/// @{
67
69//
70/// \class TFrameWindow
71// ~~~~~ ~~~~~~~~~~~~
72/// Derived from TWindow, TFrameWindow controls such window-specific behavior as
73/// keyboard navigation and command processing for client windows. For example, when
74/// a window is reactivated, TFrameWindow is responsible for restoring a window's
75/// input focus and for adding menu bar and icon support. TFrameWindow is a
76/// streamable class.
77///
78/// In terms of window areas, the frame area consists of the border, system menus,
79/// toolbars and status bars whereas the client area excludes these areas. Although
80/// frame windows can support a client window, the frame window remains separate
81/// from the client window so that you can change the client window without
82/// affecting the frame window.
83///
84/// ObjectWindows uses this frame and client structure for both TFrameWindow and
85/// TMDIChild classes. Both these classes can hold a client class. Having a separate
86/// class for the client area of the window adds more flexibility to your program.
87/// For example, this separate client area, which might be a dialog box, can be
88/// moved into another frame window, either a main window or an MDI child window.
89///
90/// TFrameWindow adds the notion of a client window, keyboard navigation, and special
91/// processing for commands (see member function EvCommand() )
92///
93/// See TFloatingFrame for a description of a floating frame with the same default
94/// functionality as a frame window.
95//
96class _OWLCLASS TFrameWindow : virtual public TWindow {
97 public:
98 TFrameWindow(TWindow* parent,
99 LPCTSTR title = nullptr,
100 TWindow* clientWnd = nullptr,
101 bool shrinkToClient = false,
102 TModule* module = nullptr);
103
105 TWindow* parent,
106 const tstring& title,
107 TWindow* client = nullptr,
108 bool shrinkToClient = false,
109 TModule* = nullptr);
110
112 TWindow* parent,
113 const tstring& title,
114 std::unique_ptr<TWindow> client = nullptr,
115 bool shrinkToClient = false,
116 TModule* = nullptr);
117
118 TFrameWindow(HWND hWnd, TModule* module = nullptr);
119 ~TFrameWindow() override;
120
121 // Menubar manipulating functions
122 //
123 virtual bool AssignMenu(TResId menuResId);
124 virtual bool SetMenu(HMENU newMenu);
125
126 void SetMenuDescr(const TMenuDescr& menuDescr);
127 const TMenuDescr* GetMenuDescr() const;
128 virtual bool MergeMenu(const TMenuDescr& childMenuDescr);
129 bool RestoreMenu();
130
131 void SetBarDescr(TBarDescr* barDescr, TAutoDelete = AutoDelete);
132 const TBarDescr* GetBarDescr() const;
133 virtual bool MergeBar(const TBarDescr& childBarDescr);
134 virtual bool RestoreBar();
135
136 TModule* GetMergeModule();
137
138 HICON GetIcon() const;
139 HICON GetIconSm() const;
140 bool SetIcon(TModule* iconModule, TResId iconResId);
141 bool SetIconSm(TModule* iconModule, TResId iconResIdSm);
142
143 // Client and child window manipulation
144 //
145 virtual TWindow* GetClientWindow();
146 virtual TWindow* SetClientWindow(TWindow* clientWnd);
147 auto SetClientWindow(std::unique_ptr<TWindow>) -> std::unique_ptr<TWindow>;
148 void RemoveChild(TWindow*) override;
149 virtual HWND GetCommandTarget();
150
151 // Sets flag indicating that the receiver has requested "keyboard
152 // handling" (translation of keyboard input into control selections)
153 //
154 bool GetKeyboardHandling() const;
155 void SetKeyboardHandling(bool kh=true);
156 void EnableKBHandler();
157
158 // Override virtual functions defined by TWindow
159 //
160 auto PreProcessMsg(MSG&) -> bool override;
161 auto IdleAction(long idleCount) -> bool override;
162 auto HoldFocusHWnd(HWND hWndLose, HWND hWndGain) -> bool override;
163 auto SetDocTitle(LPCTSTR docname, int index) -> bool override;
164 using TWindow::SetDocTitle; ///< String-aware overload
165
166 protected:
167 // Constructor & subsequent initializer for use with virtual derivations
168 // Immediate derivitives must call Init() before constructions are done.
169 //
170 TFrameWindow();
171 void Init(TWindow* clientWnd, bool shrinkToClient);
172
173 // The event handler functions that are virtual, and not dispatched thru
174 // response tables
175 //
176 // Extra processing for commands: starts with the focus window and gives
177 // it and its parent windows an opportunity to handle the command.
178 //
179 auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override;
180 void EvCommandEnable(TCommandEnabler&) override;
181
182 // Tell child windows frame has minimized/maximized/restored
183 //
184 void BroadcastResizeToChildren(uint sizeType, const TSize& size);
185
186 // Message response functions
187 //
188 void EvInitMenuPopup(HMENU hPopupMenu, uint index, bool isSysMenu);
189 HICON EvQueryDragIcon();
190 void EvSetFocus(HWND hWndLostFocus);
191 void EvSize(uint sizeType, const TSize& size);
192 void EvParentNotify(const TParentNotify&);
193 void EvPaletteChanged(HWND hWndPalChg);
194 bool EvQueryNewPalette();
195
196 // Override virtual functions defined by TWindow
197 //
198 void SetupWindow() override;
199 void CleanupWindow() override;
200
201 // Accesors to data members
202 //
203 HWND GetHWndRestoreFocus();
204 void SetHWndRestoreFocus(HWND hwndRestoreFocus);
205 int GetDocTitleIndex() const;
206 void SetDocTitleIndex(int index);
207 void SetMergeModule(TModule* module);
208
210/// Indicates if keyboard navigation is required.
211 bool KeyboardHandling;
212
214/// Stores the handle of the child window whose focus gets restored.
215 THandle HWndRestoreFocus;
216
217/// ClientWnd points to the frame's client window.
218 TWindow* ClientWnd;
219
220/// Holds the index number for the document title.
221 int DocTitleIndex;
222
223/// Tells the frame window which module the menu comes from. TDecoratedFrame uses
224/// this member to get the menu hints it displays at the bottom of the screen. It
225/// assumes that the menu hints come from the same place the menu came from.
226 TModule* MergeModule;
227
228 private:
229 TMenuDescr* MenuDescr;
230 TBarDescr* BarDescr;
231 bool DeleteBar;
232 TModule* IconModule;
233 TResId IconResId;
234 TModule* IconSmModule;
235 TResId IconSmResId;
236 TPoint MinimizedPos;
237 HICON CurIcon;
238 HICON CurIconSm;
239
240 void Init(TWindow* clientWnd);
241 bool ResizeClientWindow(bool redraw = true);
242 TWindow* FirstChildWithTab();
243
244 // Hidden to prevent accidental copying or assignment
245 //
248
251};
252/// @}
253
255
256#include <owl/posclass.h>
257
258//----------------------------------------------------------------------------
259// Inline implementations
260//
261
262//
263/// Constructs a TMenuItemEnabler with the specified command ID for the menu item,
264/// message responder (hWndReceiver), and position on the menu.
265//
268:
270 HMenu(hMenu),
271 Position(position)
272{
273 if (::GetMenuItemID(HMenu, Position) == uint(-1))
275}
276
277//
278/// Returns the menu that holds the item being enabled or disabled.
279//
281{
282 return HMenu;
283}
284
285//
286/// Returns the position of the menu item.
287//
289{
290 return Position;
291}
292
293//
294/// Retrieve handle of icon of frame window
295/// \note Only retrieves icon set via the 'SetIcon' API - does not retrieve
296/// the small HICON associated with the HWND.
297//
299{
300 return CurIcon;
301}
302
303//
304/// Retrieve handle of icon of frame window
305/// \note Only retrieves icon set via the 'SetIconSm' API - does not retrieve
306/// the HICON associated with the HWND.
307//
309{
310 return CurIconSm;
311}
312
313//
314/// Returns a pointer to the menu descriptor for the frame window.
315//
317{
318 return MenuDescr;
319}
320
321//
322/// Returns a pointer to the control bar descriptor.
323//
325{
326 return BarDescr;
327}
328
329
330//
331/// Do nothing. Return false. Overriden in TDecoratedFrame
332//
333inline bool TFrameWindow::MergeBar(const TBarDescr& /*childBarDescr*/)
334{
335 return false;
336}
337
338//
339/// Do nothing in TFrameWindow. Overriden in TDecoratedFrame.
340//
342{
343 return false;
344}
345
346//
347/// Returns flag indicating that the receiver has requested "keyboard handling"
348/// (translation of keyboard input into control selections).
349//
351{
352 return KeyboardHandling;
353}
354
355//
356/// Sets flag indicating that the receiver has requested "keyboard handling"
357/// (translation of keyboard input into control selections).
358//
360{
361 KeyboardHandling = kh;
362}
363
364//
365/// Sets the keyboard handling flag to true.
366//
367/// Sets a flag indicating that the receiver has requested keyboard navigation
368/// (translation of keyboard input into control selections). By default, the
369/// keyboard interface, which lets users use the tab and arrow keys to move between
370/// the controls, is disabled for windows and dialog boxes.
371//
373{
375}
376
377//
378/// Returns the handle of the window to restore the focus to.
379//
381{
382 return HWndRestoreFocus;
383}
384
385//
386/// Sets the remembered focused window.
387//
389{
390 HWndRestoreFocus = hwndrestorefocus;
391}
392
393//
394/// Returns the document title index.
395//
397{
398 return DocTitleIndex;
399}
400
401//
402/// Sets the current document's title index.
403//
404inline void TFrameWindow::SetDocTitleIndex(int index)
405{
406 DocTitleIndex = index;
407}
408
409//
410/// Returns the module of the merge menu.
411//
413{
414 return MergeModule;
415}
416
417//
418/// Remembers where the merged menu came from.
419//
421{
422 MergeModule = module;
423}
424
425} // OWL namespace
426
427
428#endif // OWL_FRAMEWIN_H
Descriptor of Bar Implementation.
Definition bardescr.h:71
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
uint Flags
TCommandStatus flags Is TCommandStatus::WasHandled if the command enabler has been handled.
Definition window.h:275
@ NonSender
Command does not generate WM_COMMAND messages.
Definition window.h:269
Derived from TWindow, TFrameWindow controls such window-specific behavior as keyboard navigation and ...
Definition framewin.h:96
void SetDocTitleIndex(int index)
Sets the current document's title index.
Definition framewin.h:404
void EnableKBHandler()
Sets the keyboard handling flag to true.
Definition framewin.h:372
HICON GetIconSm() const
Retrieve handle of icon of frame window.
Definition framewin.h:308
virtual bool MergeBar(const TBarDescr &childBarDescr)
Do nothing. Return false. Overriden in TDecoratedFrame.
Definition framewin.h:333
virtual bool RestoreBar()
Do nothing in TFrameWindow. Overriden in TDecoratedFrame.
Definition framewin.h:341
HWND GetHWndRestoreFocus()
Returns the handle of the window to restore the focus to.
Definition framewin.h:380
int GetDocTitleIndex() const
Returns the document title index.
Definition framewin.h:396
void SetKeyboardHandling(bool kh=true)
Sets flag indicating that the receiver has requested "keyboard handling" (translation of keyboard inp...
Definition framewin.h:359
void SetHWndRestoreFocus(HWND hwndRestoreFocus)
Sets the remembered focused window.
Definition framewin.h:388
const TMenuDescr * GetMenuDescr() const
Returns a pointer to the menu descriptor for the frame window.
Definition framewin.h:316
void SetMergeModule(TModule *module)
Remembers where the merged menu came from.
Definition framewin.h:420
const TBarDescr * GetBarDescr() const
Returns a pointer to the control bar descriptor.
Definition framewin.h:324
bool GetKeyboardHandling() const
Returns flag indicating that the receiver has requested "keyboard handling" (translation of keyboard ...
Definition framewin.h:350
TModule * GetMergeModule()
Returns the module of the merge menu.
Definition framewin.h:412
HICON GetIcon() const
Retrieve handle of icon of frame window.
Definition framewin.h:298
Menu with information used to allow merging.
Definition menu.h:206
Derived from TCommandEnabler, TMenuItemEnabler is a command enabler for menu items.
Definition framewin.h:39
int GetPosition()
Returns the position of the menu item.
Definition framewin.h:288
TMenuItemEnabler(HMENU hMenu, uint id, HWND hWndReceiver, int position)
Constructs a TMenuItemEnabler with the specified command ID for the menu item, message responder (hWn...
Definition framewin.h:266
HMENU GetMenu()
Returns the menu that holds the item being enabled or disabled.
Definition framewin.h:280
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
The tagSIZE struct is defined as.
Definition geometry.h:234
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
#define DECLARE_RESPONSE_TABLE(cls)
Definition eventhan.h:436
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Definition gdibase.h:70
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
@ AutoDelete
Definition gdibase.h:70
Definition of Window Menu encapsulation class.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
const unsigned int IDW_MDICLIENT
ID of MDI client window.
Definition framewin.h:28
TDispatch< WM_PARENTNOTIFY >::TArgs TParentNotify
Alias for convenience.
Definition dispatch.h:2894
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
const unsigned int IDW_FIRSTMDICHILD
child window IDs, 32 max to 32032
Definition framewin.h:29
#define protected_data
Definition defs.h:208
#define public_data
Definition defs.h:207
#define _OWLCLASS
Definition defs.h:338
Base window class TWindow definition, including HWND encapsulation.