OWLNext 6.32
Protected Member Functions
owl::TTinyCaption Class Reference

#include <tinycapt.h>

Inheritance diagram for owl::TTinyCaption:
owl::TWindow owl::TEventHandler owl::TStreamableBase owl::TFloatingFrame owl::TFloatingSlip

List of all members.

Protected Member Functions

 TTinyCaption ()
 ~TTinyCaption ()
void EnableTinyCaption (int ch=0, bool closeBox=false)
TEventStatus DoNCHitTest (TPoint &screenPt, uint &evRes)
TEventStatus DoNCPaint ()
TEventStatus DoNCCalcSize (bool calcValidRects, NCCALCSIZE_PARAMS &calcSize, uint &evRes)
TEventStatus DoNCLButtonDown (uint hitTest, TPoint &screenPt)
TEventStatus DoMouseMove (uint hitTest, TPoint &screenPt)
TEventStatus DoLButtonUp (uint hitTest, TPoint &screenPt)
TEventStatus DoNCActivate (bool active, bool &evRes)
TEventStatus DoCommand (uint id, HWND hWndCtl, uint notifyCode, TResult &evRes)
TEventStatus DoSysCommand (uint cmdType, TPoint &p)
void PaintButton (TDC &dc, TRect &boxRect, bool pressed)
void PaintCloseBox (TDC &dc, TRect &boxRect, bool pressed)
void PaintSysBox (TDC &dc, TRect &boxRect, bool pressed)
void PaintMinBox (TDC &dc, TRect &boxRect, bool pressed)
void PaintMaxBox (TDC &dc, TRect &boxRect, bool pressed)
void PaintCaption (bool active)
void DoSysMenu ()
TRect GetCaptionRect ()
TRect GetSysBoxRect ()
TRect GetMinBoxRect ()
TRect GetMaxBoxRect ()
uint EvNCHitTest (TPoint &screenPt)
void EvNCPaint (HRGN)
uint EvNCCalcSize (bool calcValidRects, NCCALCSIZE_PARAMS &calcSize)
void EvNCLButtonDown (uint hitTest, TPoint &screenPt)
void EvMouseMove (uint hitTest, TPoint &screenPt)
void EvLButtonUp (uint hitTest, TPoint &screenPt)
bool EvNCActivate (bool active)
TResult EvCommand (uint id, HWND hWndCtl, uint notifyCode)
void EvSysCommand (uint cmdType, TPoint &p)

Detailed Description

Derived from TWindow, TTinyCaption is a mix-in class that handles a set of non-client events to produce a smaller caption bar for a window. Whenever it displays the caption bar, TTinyCaption checks the window style and handles the WS_SYSMENU, WS_MINIMIZEBOX, WS_MAXIMIZEBOX display attributes. Thus, you can use TTinyCaption to set the attributes of the tiny caption bar before enabling the caption. For example,

 Attr.Style = WS_POPUP | WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX |
 WS_MAXIMIZEBOX;

TTinyCaption provides functions that let you manipulate frame types, border styles, and menus. You can adjust the height of the caption bar or accept the default height, which is about one-half the height of a standard caption bar. If you set CloseBox to true, then the window will close when you click the close box instead of displaying the system menu. The sample program OWLCMD.CPP on BC5.02 distribution disk displays the following tiny caption bar:

bm263.BMP

If you are using TTinyCaption as a mix-in class that does partial event handling, call the DoXxxx function in the mix-in class (instead of the EvXxxx function) to avoid duplicating default processing. The following example from OWLCMD.CPP (a sample program on your distribution disk) illustrates this process:

 void TMyFrame::EvSysCommand(uint cmdType,TPoint& p)
 { 
        if (TTinyCaption::DoSysCommand(cmdType, p) == esPartial)
        FrameWindow::EvSysCommand(cmdType, p);

The TFLoatingFrame class can be used with TTinyCaption to produce a close box. See the sample programs OWLCMD.CPP and MDIFILE.CPP on BC5.0x distribution disk for examples of how to use TTinyCaption.


Constructor & Destructor Documentation

owl::TTinyCaption::TTinyCaption ( ) [protected]

Constructs a TTinyCaption object attached to the given parent window. Initializes the caption font to 0 and TCEnabled to false so that the tiny caption bar is not displayed automatically.

Rely on TWindow's default ctor since we will always be mixed-in and another window will perform Init()

owl::TTinyCaption::~TTinyCaption ( ) [protected]

Destroys a TTinyCaption object and deletes the caption font.


Member Function Documentation

TEventStatus owl::TTinyCaption::DoCommand ( uint  id,
HWND  hWndCtl,
uint  notifyCode,
TResult evRes 
) [protected]

Displays the system menu using ::TrackPopup so that TTinyCaption sends WM_COMMAND instead of WM_SYSCOMMAND messages. If a system menu command is received, it's then transformed into a WM_SYSCOMMAND message. If the tiny caption bar is false, DoCommand returns esPartial.

References owl::esComplete, and owl::esPartial.

TEventStatus owl::TTinyCaption::DoLButtonUp ( uint  modKeys,
TPoint pt 
) [protected]

Releases the mouse capture if the caption bar is enabled and a mouse button is pressed. Sets hitTest, indicating the mouse button has been pressed. Captures the mouse message and repaints the smaller buttons before returning esComplete.

References owl::TWindow::ClientToScreen(), DoMouseMove(), DoNCHitTest(), owl::esComplete, owl::esPartial, owl::TWindow::IsZoomed(), owl::TWindow::PostMessage(), and owl::TWindow::ReleaseCapture().

TEventStatus owl::TTinyCaption::DoMouseMove ( uint  hitTest,
TPoint screenPt 
) [protected]
TEventStatus owl::TTinyCaption::DoNCActivate ( bool  active,
bool &  evRes 
) [protected]

If the tiny caption is not enabled or is iconic, returns esPartial. Otherwise, repaints the caption as an active caption and returns esComplete.

References owl::esComplete, owl::esPartial, owl::TWindow::IsIconic(), and PaintCaption().

TEventStatus owl::TTinyCaption::DoNCCalcSize ( bool  calcValidRects,
NCCALCSIZE_PARAMS &  calcSize,
uint &  evRes 
) [protected]

Return the size of our client area, leaving room for caption bar.

If the caption bar is not enabled or is iconic, returns esPartial. Otherwise, calculates the dimensions of the caption and returns esComplete.

References owl::esComplete, owl::esPartial, GetCaptionRect(), owl::TRect::Height(), and owl::TWindow::IsIconic().

TEventStatus owl::TTinyCaption::DoNCHitTest ( TPoint screenPt,
uint &  evRes 
) [protected]

If the caption bar is not enabled, returns esPartial. Otherwise, sends a message to the caption bar that the mouse or the cursor has moved, and returns esComplete.

Reimplemented in owl::TFloatingFrame.

References owl::esComplete, owl::esPartial, GetCaptionRect(), GetMaxBoxRect(), GetMinBoxRect(), owl::TWindow::GetStyle(), GetSysBoxRect(), owl::TWindow::GetWindowRect(), and owl::TRect::TopLeft().

TEventStatus owl::TTinyCaption::DoNCLButtonDown ( uint  hitTest,
TPoint screenPt 
) [protected]

If the caption bar is not enabled, returns esPartial. Otherwise, determines if the user released the button outside or inside a menu, and returns esComplete.

References DoNCHitTest(), owl::esComplete, owl::esPartial, owl::TWindow::GetCursorPos(), owl::TWindow::GetHandle(), GetMaxBoxRect(), GetMinBoxRect(), GetSysBoxRect(), owl::TRect::InflatedBy(), PaintCloseBox(), PaintMaxBox(), PaintMinBox(), owl::TWindow::SendMessage(), and owl::TWindow::SetCapture().

TEventStatus owl::TTinyCaption::DoNCPaint ( ) [protected]

If the caption bar is not enabled or is iconized, returns esPartial. Otherwise, gets the focus, paints the caption, and returns esPartial, thus indicating that a separate paint function must be called to paint the borders of the caption.

References owl::esPartial, owl::TWindow::GetActiveWindow(), owl::TWindow::GetFocus(), owl::TWindow::GetHandle(), owl::TWindow::IsChild(), owl::TWindow::IsIconic(), and PaintCaption().

TEventStatus owl::TTinyCaption::DoSysCommand ( uint  cmdType,
TPoint p 
) [protected]

If iconic, then let default windows processing deal with the menu.

Handle WM_SYSCOMMAND to make sure that SC_KEYMENU and SC_MOUSEMENU bring up our sys menu at the right coord w/ respect to the tiny sys box. If the caption bar is not enabled, returns esPartial. If the caption bar is iconized and the user clicks the icon, calls DoSysMenu to display the menu in its normal mode and returns esComplete.

References DoSysMenu(), owl::esComplete, owl::esPartial, and owl::TWindow::IsIconic().

void owl::TTinyCaption::DoSysMenu ( ) [protected]

Gets the system menu and sets up menu items. DoSysMenu is also responsible for displaying and tracking the status of the menu.

References owl::TRect::BottomRight(), owl::TWindow::ClientToScreen(), owl::TWindow::GetHandle(), GetSysBoxRect(), owl::TWindow::GetSystemMenu(), owl::TWindow::GetWindowLong(), owl::TWindow::IsIconic(), owl::TWindow::IsZoomed(), and owl::TRect::TopLeft().

void owl::TTinyCaption::EnableTinyCaption ( int  captionHeight = 0,
bool  closeBox = false 
) [protected]

Pass closeBox=true to replace SystemMenu box with a box that will close window when clicked Used for floating palettes, etc.

Activates the tiny caption bar. By default, EnableTinyCaption replaces the system window with a tiny caption window that does not close when the system window is clicked. If the closeBox argument is true, clicking on the system menu will close the window instead of bringing up the menu. You can use EnableTinyCaption to hide the window if you are using a tiny caption in a derived class. To diminish the tiny caption bar, try the following values:

 EnableTinyCaption(30, true);

To maximize the tiny caption bar, use these values:

 EnableTinyCaption(48, true);
TResult owl::TTinyCaption::EvCommand ( uint  id,
HWND  hWndCtl,
uint  notifyCode 
) [protected, virtual]

EvCommand provides extra processing for commands, but lets the focus window and its parent windows handle the command first.

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingFrame.

References DoCommand(), and owl::esComplete.

void owl::TTinyCaption::EvLButtonUp ( uint  modKeys,
TPoint pt 
) [protected]

Responds to a mouse button-up message by calling DoLButtonUp. If DoLButtonUp does not return IsComplete, EvLButtonUp calls TWindow::EvLButtonUp.

Reimplemented from owl::TWindow.

References DoLButtonUp(), and owl::esPartial.

void owl::TTinyCaption::EvMouseMove ( uint  modKeys,
TPoint pt 
) [protected]

Responds to a mouse-move message by calling DoMouseMove. If DoMouseMove does not return IsComplete, EvMouseMove calls TWindow::EvMouseMove.

Reimplemented from owl::TWindow.

References DoMouseMove(), and owl::esPartial.

bool owl::TTinyCaption::EvNCActivate ( bool  active) [protected]

Responds to a request to change a title bar or icon by calling DoNCActivate. If DoNCActivate does not return esComplete, EvNCActivate calls TWindow::EvNCActivate.

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingFrame.

References DoNCActivate(), and owl::esPartial.

uint owl::TTinyCaption::EvNCCalcSize ( bool  calcValidRects,
NCCALCSIZE_PARAMS &  calcSize 
) [protected]

Calculates the size of the command window including the caption and border so that it can fit within the window.

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingFrame.

References DoNCCalcSize().

uint owl::TTinyCaption::EvNCHitTest ( TPoint screenPt) [protected]

Return where in the non client area we are. We only handle caption bar area Responds to a cursor move or press of a mouse button by calling DoNCHitTest. If DoNCHitTest does not return esComplete, EvNCHitTest calls TWindow::EvNCHitTest.

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingFrame.

References DoNCHitTest(), and owl::esComplete.

void owl::TTinyCaption::EvNCLButtonDown ( uint  hitTest,
TPoint screenPt 
) [protected]

Responds to a press of the left mouse button while the cursor is within the nonclient area of the caption bar by calling DoNCLButtonDown. If DoNCLButtonDown does not return esComplete, EvNCLButtonDown calls TWindow::EvNCLButtonDown.

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingSlip.

References DoNCLButtonDown(), and owl::esPartial.

void owl::TTinyCaption::EvNCPaint ( HRGN  ) [protected]

Responds to a request to change a title bar or icon. Paints the indicated device context or display screen and does any special painting required for the caption.

We only need to paint the caption. Someone else will paint the borders

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingFrame.

References owl::TWindow::DefaultProcessing(), and DoNCPaint().

void owl::TTinyCaption::EvSysCommand ( uint  cmdType,
TPoint p 
) [protected]

Responds to a WM_SYSCOMMAND message by calling DoSysCommand. If DoSysCommand returns esPartial, EvSysCommand calls TWindow::EvSysCommand.

Reimplemented from owl::TWindow.

Reimplemented in owl::TFloatingFrame.

References DoSysCommand(), and owl::esPartial.

TRect owl::TTinyCaption::GetCaptionRect ( ) [protected]

Gets the area of the caption for changing or repainting.

Note:
GetCaptionRect and GetSysBoxRect must be kept in sync!

References owl::TWindow::GetWindowRect(), and owl::TRect::TopLeft().

TRect owl::TTinyCaption::GetMaxBoxRect ( ) [protected]

Returns the size of the maximize box rectangle.

References GetCaptionRect().

TRect owl::TTinyCaption::GetMinBoxRect ( ) [protected]

Returns the size of the minimize box rectangle.

References GetMaxBoxRect(), owl::TWindow::GetWindowLong(), and owl::TRect::Offset().

TRect owl::TTinyCaption::GetSysBoxRect ( ) [protected]

Returns the size of the system box rectangle.

References GetCaptionRect().

void owl::TTinyCaption::PaintButton ( TDC dc,
TRect boxRect,
bool  pressed 
) [protected]
void owl::TTinyCaption::PaintCaption ( bool  active) [protected]
void owl::TTinyCaption::PaintCloseBox ( TDC dc,
TRect boxRect,
bool  pressed 
) [protected]

Paints a close box on the tiny caption bar. You can override the default box if you want to design your own close box.

References owl::TRect::BottomRight(), owl::TRect::Height(), owl::TPoint::Offset(), owl::TRect::Offset(), PaintButton(), owl::TColor::Sys3dHilight, owl::TColor::Sys3dShadow, owl::TColor::SysBtnText, owl::TDC::TextRect(), and owl::TRect::Width().

void owl::TTinyCaption::PaintMaxBox ( TDC dc,
TRect boxRect,
bool  pressed 
) [protected]
void owl::TTinyCaption::PaintMinBox ( TDC dc,
TRect boxRect,
bool  pressed 
) [protected]
void owl::TTinyCaption::PaintSysBox ( TDC dc,
TRect boxRect,
bool  pressed 
) [protected]

The documentation for this class was generated from the following files: