OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
tinycapt.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1996 by Borland International, All Rights Reserved
4//
5//----------------------------------------------------------------------------
6
7#if !defined(OWL_TINYCAPT_H)
8#define OWL_TINYCAPT_H
9
10#include <owl/private/defs.h>
11#if defined(BI_HAS_PRAGMA_ONCE)
12# pragma once
13#endif
14
15#include <owl/window.h>
16
17
18namespace owl {
19
20class _OWLCLASS TFont;
21
22#include <owl/preclass.h>
23
24/// \addtogroup mixin
25/// @{
26//
27/// \class TTinyCaption
28// ~~~~~ ~~~~~~~~~~~~
29/// Derived from TWindow, TTinyCaption is a mix-in class that handles a set of
30/// non-client events to produce a smaller caption bar for a window. Whenever it
31/// displays the caption bar, TTinyCaption checks the window style and handles the
32/// WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX display attributes. Thus, you can use
33/// TTinyCaption to set the attributes of the tiny caption bar before enabling the
34/// caption. For example,
35/// \code
36/// Attr.Style = WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX |
37/// WS_MAXIMIZEBOX;
38/// \endcode
39/// TTinyCaption provides functions that let you manipulate frame types, border
40/// styles, and menus. You can adjust the height of the caption bar or accept the
41/// default height, which is about one-half the height of a standard caption bar. If
42/// you set CloseBox to true, then the window will close when you click the close
43/// box instead of displaying the system menu.
44/// The sample program OWLCMD.CPP on BC5.02 distribution disk displays the following
45/// tiny caption bar:
46/// \image html bm263.BMP
47///
48/// If you are using TTinyCaption as a mix-in class that does partial event
49/// handling, call the DoXxxx function in the mix-in class (instead of the EvXxxx
50/// function) to avoid duplicating default processing. The following example from
51/// OWLCMD.CPP (a sample program on your distribution disk) illustrates this
52/// process:
53/// \code
54/// void TMyFrame::EvSysCommand(uint cmdType,TPoint& p)
55/// {
56/// if (TTinyCaption::DoSysCommand(cmdType, p) == esPartial)
57/// FrameWindow::EvSysCommand(cmdType, p);
58/// \endcode
59/// The TFLoatingFrame class can be used with TTinyCaption to produce a close box.
60/// See the sample programs OWLCMD.CPP and MDIFILE.CPP on BC5.0x distribution disk for
61/// examples of how to use TTinyCaption.
62//
63class _OWLCLASS TTinyCaption : public virtual TWindow {
64 protected:
66 ~TTinyCaption() override;
67
68 /// Pass closeBox=true to replace SystemMenu box with a box that will
69 /// close window when clicked
70 /// Used for floating palettes, etc.
71 //
72 void EnableTinyCaption(int ch=0, bool closeBox=false);
73
74 // Controller class must handle events that call these mixin handlers
75 //
76 TEventStatus DoNCHitTest(const TPoint& screenPt, uint& evRes);
78 TEventStatus DoNCCalcSize(bool calcValidRects,
79 NCCALCSIZE_PARAMS & calcSize, uint& evRes);
80 TEventStatus DoNCLButtonDown(uint hitTest, const TPoint& screenPt);
81 TEventStatus DoMouseMove(uint hitTest, const TPoint& screenPt);
82 TEventStatus DoLButtonUp(uint hitTest, const TPoint& screenPt);
83 TEventStatus DoNCActivate(bool active, bool& evRes);
84 TEventStatus DoCommand(uint id, HWND hWndCtl, uint notifyCode, TResult& evRes);
85 TEventStatus DoSysCommand(uint cmdType, const TPoint& p);
86
87 void PaintButton(TDC& dc, TRect& boxRect, bool pressed);
88 void PaintCloseBox(TDC& dc, TRect& boxRect, bool pressed);
89 void PaintSysBox(TDC& dc, TRect& boxRect, bool pressed);
90 void PaintMinBox(TDC& dc, TRect& boxRect, bool pressed);
91 void PaintMaxBox(TDC& dc, TRect& boxRect, bool pressed);
92 void PaintCaption(bool active);
93 void DoSysMenu();
94
95 TRect GetCaptionRect(); // Get caption area for hit test or paint
96 TRect GetSysBoxRect(); // Same for close box
99
100 uint EvNCHitTest(const TPoint& screenPt);
101 void EvNCPaint(HRGN);
102 uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS & calcSize);
103 void EvNCLButtonDown(uint hitTest, const TPoint& screenPt);
104 void EvMouseMove(uint hitTest, const TPoint& screenPt);
105 void EvLButtonUp(uint hitTest, const TPoint& screenPt);
106 bool EvNCActivate(bool active);
107 auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override;
108 void EvSysCommand(uint cmdType, const TPoint& p);
109
111 // Cache system metrics
112 //
113 TSize Border; ///< Thin frame border size for dividers
114 TSize Frame; ///< Actual Left and Right, Top and Bottom frame size
115
116 bool CloseBox; ///< True for special close box
117 bool TCEnabled; ///< Is true if the tiny caption bar is displayed.
118 int CaptionHeight; ///< Height of the caption bar.
119 TFont* CaptionFont; ///< Tiny font for caption bar
120 uint DownHit; ///< Mouse down hit test result
121 bool IsPressed; ///< Is a button currently pressed
122 bool WaitingForSysCmd; ///< Is true if TTinyCaption is ready to receive system messages.
123
124 private:
125 // Hidden to prevent accidental copying or assignment
126 //
128 TTinyCaption& operator =(const TTinyCaption&);
129
130 DECLARE_RESPONSE_TABLE(TTinyCaption);
132};
133
135
136/// @}
137
138#include <owl/posclass.h>
139
140
141} // OWL namespace
142
143
144#endif // OWL_TINYCAPT_H
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
Derived from TWindow, TTinyCaption is a mix-in class that handles a set of non-client events to produ...
Definition tinycapt.h:63
TEventStatus DoNCLButtonDown(uint hitTest, const TPoint &screenPt)
If the caption bar is not enabled, returns esPartial.
Definition tinycapt.cpp:267
void PaintCaption(bool active)
Calls dc.SelectObject() to select the given rectangle and dc.PatBlt() to paint the tiny caption bar u...
Definition tinycapt.cpp:720
TRect GetMinBoxRect()
Returns the size of the minimize box rectangle.
Definition tinycapt.cpp:849
void EvLButtonUp(uint hitTest, const TPoint &screenPt)
Responds to a mouse button-up message by calling DoLButtonUp.
Definition tinycapt.cpp:392
void PaintSysBox(TDC &dc, TRect &boxRect, bool pressed)
Paints the system box.
Definition tinycapt.cpp:611
void EvSysCommand(uint cmdType, const TPoint &p)
Responds to a WM_SYSCOMMAND message by calling DoSysCommand.
Definition tinycapt.cpp:517
TEventStatus DoSysCommand(uint cmdType, const TPoint &p)
Handle WM_SYSCOMMAND to make sure that SC_KEYMENU and SC_MOUSEMENU bring up our sys menu at the right...
Definition tinycapt.cpp:534
TTinyCaption()
Constructs a TTinyCaption object attached to the given parent window.
Definition tinycapt.cpp:45
void EvMouseMove(uint hitTest, const TPoint &screenPt)
Responds to a mouse-move message by calling DoMouseMove.
Definition tinycapt.cpp:342
TEventStatus DoNCPaint()
If the caption bar is not enabled or is iconized, returns esPartial.
Definition tinycapt.cpp:204
TEventStatus DoMouseMove(uint hitTest, const TPoint &screenPt)
Returns TEventStatus.
Definition tinycapt.cpp:352
void EnableTinyCaption(int ch=0, bool closeBox=false)
Pass closeBox=true to replace SystemMenu box with a box that will close window when clicked Used for ...
Definition tinycapt.cpp:75
void PaintMaxBox(TDC &dc, TRect &boxRect, bool pressed)
Paints a maximize box on the tiny caption bar.
Definition tinycapt.cpp:676
TEventStatus DoLButtonUp(uint hitTest, const TPoint &screenPt)
Releases the mouse capture if the caption bar is enabled and a mouse button is pressed.
Definition tinycapt.cpp:406
TEventStatus DoNCHitTest(const TPoint &screenPt, uint &evRes)
If the caption bar is not enabled, returns esPartial.
Definition tinycapt.cpp:139
TRect GetCaptionRect()
Gets the area of the caption for changing or repainting.
Definition tinycapt.cpp:817
uint EvNCHitTest(const TPoint &screenPt)
Return where in the non client area we are.
Definition tinycapt.cpp:125
TEventStatus DoCommand(uint id, HWND hWndCtl, uint notifyCode, TResult &evRes)
Displays the system menu using TrackPopup so that TTinyCaption sends WM_COMMAND instead of WM_SYSCOMM...
Definition tinycapt.cpp:492
void EvNCLButtonDown(uint hitTest, const TPoint &screenPt)
Responds to a press of the left mouse button while the cursor is within the nonclient area of the cap...
Definition tinycapt.cpp:254
TRect GetSysBoxRect()
Returns the size of the system box rectangle.
Definition tinycapt.cpp:836
TEventStatus DoNCActivate(bool active, bool &evRes)
If the tiny caption is not enabled or is iconic, returns esPartial.
Definition tinycapt.cpp:462
void PaintCloseBox(TDC &dc, TRect &boxRect, bool pressed)
Paints a close box on the tiny caption bar.
Definition tinycapt.cpp:578
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
EvCommand provides extra processing for commands, but lets the focus window and its parent windows ha...
Definition tinycapt.cpp:477
void DoSysMenu()
Gets the system menu and sets up menu items.
Definition tinycapt.cpp:877
void PaintMinBox(TDC &dc, TRect &boxRect, bool pressed)
Paints a minimize box on the tiny caption bar.
Definition tinycapt.cpp:650
TEventStatus DoNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &calcSize, uint &evRes)
Return the size of our client area, leaving room for caption bar.
Definition tinycapt.cpp:237
TRect GetMaxBoxRect()
Returns the size of the maximize box rectangle.
Definition tinycapt.cpp:863
void PaintButton(TDC &dc, TRect &boxRect, bool pressed)
Paints a blank button.
Definition tinycapt.cpp:551
void EvNCPaint(HRGN)
Responds to a request to change a title bar or icon.
Definition tinycapt.cpp:192
bool EvNCActivate(bool active)
Responds to a request to change a title bar or icon by calling DoNCActivate.
Definition tinycapt.cpp:449
uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &calcSize)
Calculates the size of the command window including the caption and border so that it can fit within ...
Definition tinycapt.cpp:223
TWindow(TWindow *parent, LPCTSTR title=nullptr, TModule *module=nullptr)
Adds this to the child list of parent if nonzero, and calls EnableAutoCreate so that this will be cre...
Definition window.cpp:341
#define DECLARE_STREAMABLE_OWL(cls, ver)
Definition objstrm.h:1529
#define DECLARE_STREAMABLE_INLINES(cls)
Definition objstrm.h:1538
TEventStatus
Mixin window event implementation return status.
Definition window.h:107
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
LRESULT TResult
Result type.
Definition dispatch.h:52
unsigned int uint
Definition number.h:25
#define protected_data
Definition defs.h:208
#define _OWLCLASS
Definition defs.h:338
Base window class TWindow definition, including HWND encapsulation.