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
tinycapt.cpp
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/// Implementation of TTinyCaption
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9#include <owl/tinycapt.h>
10#include <owl/gdiobjec.h>
11#include <owl/uimetric.h>
12
13#if !defined(WS_EX_TOOLWINDOW)
14# define WS_EX_TOOLWINDOW 0x00000080L
15#endif
16
17namespace owl {
18
20
21
22//
23// We only want to search this mixin for events, so don't include any base
24// classes in Find()
25//
26DEFINE_RESPONSE_TABLE(TTinyCaption)
36
37//
38/// Constructs a TTinyCaption object attached to the given parent window.
39/// Initializes the caption font to 0 and TCEnabled to false so that the tiny
40/// caption bar is not displayed automatically.
41///
42/// Rely on TWindow's default ctor since we will always be mixed-in and another
43/// window will perform Init()
44//
46{
47 TCEnabled = false;
48 CaptionFont = nullptr;
49}
50
51//
52/// Destroys a TTinyCaption object and deletes the caption font.
53//
55{
56 delete CaptionFont;
57}
58
59//
60/// Activates the tiny caption bar. By default, EnableTinyCaption replaces the
61/// system window with a tiny caption window that does not close when the system
62/// window is clicked. If the closeBox argument is true, clicking on the system menu
63/// will close the window instead of bringing up the menu. You can use
64/// EnableTinyCaption to hide the window if you are using a tiny caption in a
65/// derived class. To diminish the tiny caption bar, try the following values:
66/// \code
67/// EnableTinyCaption(30, true);
68/// \endcode
69/// To maximize the tiny caption bar, use these values:
70/// \code
71/// EnableTinyCaption(48, true);
72/// \endcode
73//
74void
76{
77 Border.cx = TUIMetric::CxBorder;
78 Border.cy = TUIMetric::CyBorder;
79
80 // Get width of window borders, these will vary with type of window
81 // Really 3 styles are supported:
82 // Fixed frame - WS_DLGFRAME, no WS_BORDER, WS_THICKFRAME optional and
83 // only affects sizability, not look
84 // Thick frame - WS_BORDER + WS_THICKFRAME, visible thick frame for sizing
85 // Thin frame - WS_BORDER only. No sizing.
86 //
87 if ((Attr.Style & WS_CAPTION) == WS_DLGFRAME) {
88 Frame.cx = TUIMetric::CxFixedFrame;
89 Frame.cy = TUIMetric::CyFixedFrame;
90 }
91 else {
92 Attr.Style |= WS_BORDER; // must have at least a border
93 Attr.Style &= ~WS_DLGFRAME; // but never a caption (WS_BORDER+WS_DLGFRAME)
94 if (Attr.Style & WS_THICKFRAME) {
95 Frame.cx = TUIMetric::CxSizeFrame;
96 Frame.cy = TUIMetric::CySizeFrame;
97 }
98 else {
99 Frame = Border;
100 }
101 }
102
103 CloseBox = closeBox;
104
105 // If running under Win95 or NT NewShell, then use its extended style to
106 // become a tiny caption
107 //
108 Attr.Style |= WS_CAPTION;
109 Attr.ExStyle |= WS_EX_TOOLWINDOW;
110 if (closeBox)
111 Attr.Style |= WS_SYSMENU;
112 CaptionHeight = captionHeight ? captionHeight : TUIMetric::CySmCaption.Get();
113 // !CQ Need to keep CaptionHeight sync'd on sys changes?
114 return;
115}
116
117//
118/// Return where in the non client area we are. We only handle caption
119/// bar area
120//
121/// Responds to a cursor move or press of a mouse button by calling DoNCHitTest. If
122/// DoNCHitTest does not return esComplete, EvNCHitTest calls TWindow::EvNCHitTest.
123//
124uint
126{
127 uint er = 0;
129 return er;
131}
132
133//
134/// If the caption bar is not enabled, returns esPartial. Otherwise, sends a message
135/// to the caption bar that the mouse or the cursor has moved, and returns
136/// esComplete.
137//
140{
141 if (!TCEnabled)
142 return esPartial;
143
144 // Check style bits to see what to paint
145 //
146 long style = GetStyle();
149 if (style & WS_SYSMENU)
150 hasSysMenu = true;
151 if (style & WS_MAXIMIZEBOX)
152 hasMaximize = true;
153 if (style & WS_MINIMIZEBOX)
154 hasMinimize = true;
155
156 // Convert to window coordinates
157 //
159
160 if ((hasSysMenu || CloseBox) && GetSysBoxRect().Contains(winPt)) {
162 return esComplete;
163 }
164 else if (hasMinimize && GetMinBoxRect().Contains(winPt)) {
166 return esComplete;
167 }
168 else if (hasMaximize && GetMaxBoxRect().Contains(winPt)) {
170 return esComplete;
171 }
172
173 // CaptionRect includes buttons so make sure it's last checked
174 // Should modify this one to allow clicking in left, top, right thin
175 // borders of caption
176 //
177 else if (GetCaptionRect().Contains(winPt)) {
179 return esComplete;
180 }
181 else {
182 return esPartial;
183 }
184}
185
186//
187/// Responds to a request to change a title bar or icon. Paints the indicated device
188/// context or display screen and does any special painting required for the caption.
189///
190/// We only need to paint the caption. Someone else will paint the borders
191//
193{
194 DefaultProcessing(); // Default border painting
195 DoNCPaint(); // Then our special caption painting
196}
197
198//
199/// If the caption bar is not enabled or is iconized, returns esPartial. Otherwise,
200/// gets the focus, paints the caption, and returns esPartial, thus indicating that
201/// a separate paint function must be called to paint the borders of the caption.
202//
205{
206 if (!TCEnabled || IsIconic())
207 return esPartial; // We don't do anything special for an Icon
208
209 // If we have focus or our children have focus, then we're active
210 // Note: We can't rely only on GetFocus here because when we're being
211 // restored from an icon, we're active, but don't yet have focus!
212 //
215 return esPartial; // Caller must call function to paint borders
216}
217
218//
219/// Calculates the size of the command window including the caption and border so
220/// that it can fit within the window.
221//
222uint
229
230//
231/// Return the size of our client area, leaving room for caption bar
232//
233/// If the caption bar is not enabled or is iconic, returns esPartial. Otherwise,
234/// calculates the dimensions of the caption and returns esComplete.
235//
237TTinyCaption::DoNCCalcSize(bool /*calcValidRects*/,
238 NCCALCSIZE_PARAMS & calcSize, uint& /*evRes*/)
239{
240 if (!TCEnabled || IsIconic())
241 return esPartial;
242
243 calcSize.rgrc[0].top += GetCaptionRect().Height();
244
245 return esComplete;
246}
247
248//
249/// Responds to a press of the left mouse button while the cursor is within the
250/// nonclient area of the caption bar by calling DoNCLButtonDown. If DoNCLButtonDown
251/// does not return esComplete, EvNCLButtonDown calls TWindow::EvNCLButtonDown.
252//
253void
255{
256 // Display system menu, invert min/max icons (not), etc
257 //
260}
261
262//
263/// If the caption bar is not enabled, returns esPartial. Otherwise, determines if
264/// the user released the button outside or inside a menu, and returns esComplete.
265//
268{
269 if (!TCEnabled)
270 return esPartial;
271
272 TWindowDC wdc(*this);
273 switch (hitTest) {
274 case HTSYSMENU:
275 DownHit = HTSYSMENU;
276 if (CloseBox) {
277 IsPressed = true;
278 SetCapture();
280 PaintCloseBox(wdc, rect, IsPressed);
281 }
282 else {
284 sysBoxRect.right += 1;
285
286 wdc.PatBlt(sysBoxRect, PATINVERT);
287
288 // Display sys menu on button down
289 // Need to lock sys menu until user clicks outside
290
291 // Set flag to indicate we're expecting a sys command, & then send
292 // message to popup sys menu
293 //
294 WaitingForSysCmd = true;
297
298 // If we didn't execute a command, user released btn outside of menu
299 // If it was released in sys menu box, then redisplay menu as if it
300 // were brought up with a keystroke
301 //
302 if (WaitingForSysCmd) {
304 TPoint pt;
307 if (hitTest == HTSYSMENU)
309 }
310 if (GetHandle())
311 wdc.PatBlt(sysBoxRect, PATINVERT);
312 }
313 return esComplete;
314
315 case HTMINBUTTON: {
316 DownHit = HTMINBUTTON;
317 IsPressed = true;
318 SetCapture();
320 PaintMinBox(wdc, rect, IsPressed);
321 return esComplete;
322 }
323
324 case HTMAXBUTTON:{
325 DownHit = HTMAXBUTTON;
326 IsPressed = true;
327 SetCapture();
329 PaintMaxBox(wdc, rect, IsPressed);
330 return esComplete;
331 }
332 }
333 DownHit = HTNOWHERE;
334 return esPartial;
335}
336
337//
338/// Responds to a mouse-move message by calling DoMouseMove. If DoMouseMove does not
339/// return IsComplete, EvMouseMove calls TWindow::EvMouseMove.
340//
341void
347
348//
349/// Returns TEventStatus.
350//
353{
354 if (TCEnabled && DownHit != HTNOWHERE) {
357 ClientToScreen(screenPt); // Cvt to screen coord
359 bool isNowPressed = hitTest == DownHit;
360
361 if (isNowPressed != IsPressed) {
362 IsPressed = isNowPressed;
363 TWindowDC wdc(*this);
364 switch (DownHit) {
365 case HTSYSMENU:
366 if (CloseBox){
368 PaintCloseBox(wdc, rect, IsPressed);
369 }
370 return esComplete;
371 case HTMINBUTTON:{
373 PaintMinBox(wdc, rect, IsPressed);
374 }
375 return esComplete;
376 case HTMAXBUTTON:{
378 PaintMaxBox(wdc, rect, IsPressed);
379 }
380 return esComplete;
381 }
382 }
383 }
384 return esPartial;
385}
386
387//
388/// Responds to a mouse button-up message by calling DoLButtonUp. If DoLButtonUp
389/// does not return IsComplete, EvLButtonUp calls TWindow::EvLButtonUp.
390//
391void
393{
394 // If we're still in area where buton went down, then do it
395 //
398}
399
400//
401/// Releases the mouse capture if the caption bar is enabled and a mouse button is
402/// pressed. Sets hitTest, indicating the mouse button has been pressed. Captures
403/// the mouse message and repaints the smaller buttons before returning esComplete.
404//
407{
408 if (TCEnabled && DownHit != HTNOWHERE) {
411
414 ClientToScreen(screenPt); // Cvt to screen coord
416
417 if (hitTest == DownHit) {
418 DownHit = HTNOWHERE;
419 switch (hitTest) {
420 case HTSYSMENU:
421 if (CloseBox)
423 return esComplete;
424
425 // We have to handle these buttons also to prevent defproc from
426 // painting the standard big min/max buttons when left mouse button is
427 // pressed
428 //
429 case HTMINBUTTON:
431 return esComplete;
432
433 case HTMAXBUTTON:
435 return esComplete;
436 }
437 }
438 DownHit = HTNOWHERE;
439 }
440 return esPartial;
441}
442
443//
444/// Responds to a request to change a title bar or icon by calling DoNCActivate. If
445/// DoNCActivate does not return esComplete, EvNCActivate calls
446/// TWindow::EvNCActivate.
447//
448bool
450{
451 bool er;
454 return er;
455}
456
457//
458/// If the tiny caption is not enabled or is iconic, returns esPartial. Otherwise,
459/// repaints the caption as an active caption and returns esComplete.
460//
463{
464 if (!TCEnabled || IsIconic())
465 return esPartial; // Let default do it's thing
466
468 evRes = true;
469 return esComplete;
470}
471
472//
473/// EvCommand provides extra processing for commands, but lets the focus window and
474/// its parent windows handle the command first.
475//
484
485//
486/// Displays the system menu using ::TrackPopup so that TTinyCaption sends
487/// WM_COMMAND instead of WM_SYSCOMMAND messages. If a system menu command is
488/// received, it's then transformed into a WM_SYSCOMMAND message. If the tiny
489/// caption bar is false, DoCommand returns esPartial.
490//
493{
494 // We're displaying system menu using TrackPopup...
495 // This will send us WM_COMMAND messages instead of WM_SYSCOMMAND msgs
496 // If we get a system menu command then transform it into a WM_SYSCOMMAND
497 //
498 if (!TCEnabled)
499 return esPartial;
500
501 if (id >= 0xF000) {
502 WaitingForSysCmd = false; // Let LButtonDown handler know that a command was sent
504 return esComplete;
505 }
506 else {
507 evRes = 0;
508 return esPartial;
509 }
510}
511
512//
513/// Responds to a WM_SYSCOMMAND message by calling DoSysCommand. If DoSysCommand
514/// returns esPartial, EvSysCommand calls TWindow::EvSysCommand.
515//
516void
522
523//
524/// Handle WM_SYSCOMMAND to make sure that SC_KEYMENU and SC_MOUSEMENU bring up
525/// our sys menu at the right coord w/ respect to the tiny sys box.
526//
527/// If iconic, then let default windows processing deal with the menu
528//
529/// If the caption bar is not enabled, returns esPartial. If the caption bar is
530/// iconized and the user clicks the icon, calls DoSysMenu to display the menu in
531/// its normal mode and returns esComplete.
532//
535{
536 if (!TCEnabled)
537 return esPartial;
538
539 cmdType &= 0xFFF0;
540 if ((cmdType == SC_KEYMENU || cmdType == SC_MOUSEMENU) && !IsIconic()) {
541 DoSysMenu();
542 return esComplete;
543 }
544 return esPartial;
545}
546
547//
548/// Paints a blank button.
549//
550void
552{
554// dc.OWLFastWindowFrame(winFrameBr, r, 1, 1);
556
557 r.Inflate(-1,-1);
559 if (r.Width() > 4 && r.Height() > 4) {
560 if (pressed) {
561 dc.TextRect(r.left, r.top, r.right, r.top+1, TColor::Sys3dShadow);
562 dc.TextRect(r.left, r.top+1, r.left+1, r.bottom, TColor::Sys3dShadow);
563 }
564 else {
565 dc.TextRect(r.left, r.top, r.right-1, r.top+1, TColor::Sys3dHilight);
566 dc.TextRect(r.left, r.top+1, r.left+1, r.bottom-1, TColor::Sys3dHilight);
567 dc.TextRect(r.right-1, r.top+1, r.right, r.bottom, TColor::Sys3dShadow);
568 dc.TextRect(r.left+1, r.bottom-1, r.right-1, r.bottom, TColor::Sys3dShadow);
569 }
570 }
571}
572
573//
574/// Paints a close box on the tiny caption bar. You can override the default box if
575/// you want to design your own close box.
576//
577void
579{
580 // Fill the box with light gray & draw bevel if possible
581 //
583
584 if (pressed)
585 boxRect.Offset(1,1);
586
587 // Do something different to differentiate from standard system menu--
588 // draw a recessed black box glyph about half the button size, centered
589 //
590 int glyphWidth = boxRect.Width() > 7 ?
591 boxRect.Width()-boxRect.Width()/2-1 : boxRect.Width()-3;
592 int glyphHeight = boxRect.Height() > 7 ?
593 boxRect.Height()-boxRect.Height()/2-1 : boxRect.Height()-3;
594 if (glyphWidth > 1 && glyphHeight > 1) {
596 glyphRect.Offset(boxRect.left + (boxRect.Width()-glyphWidth-1)/2,
597 boxRect.top + (boxRect.Height()-glyphHeight-1)/2);
598
600 glyphRect.Offset(1,1);
602 glyphRect.BottomRight().Offset(-1,-1);
604 }
605}
606
607//
608/// Paints the system box.
609//
610void
612{
613 // Dont paint over the left & top borders
614 //
615 boxRect.left++;
616 boxRect.top++;
617
618 // Fill the box with 3d face
619 //
621
622 // Draw the ventilator (sysmenu) box, with shadow
623 //
624 TPoint begPt = boxRect.TopLeft().OffsetBy(2, (boxRect.Height()-3)/2);
625 TRect ventRect(begPt, TSize(boxRect.Width()-5, 3));
626
627 // Draw shadow down and right 1
628 //
629 dc.TextRect(ventRect.left+1, ventRect.top+1,
630 ventRect.right+1, ventRect.bottom+1, TColor::Sys3dShadow);
631
632 // Draw ventilator rectangle
633 //
636
637 // Draw white interior of ventilator
638 //
639 dc.TextRect(ventRect.left+1, ventRect.top+1,
640 ventRect.right-1, ventRect.top+2, TColor::Sys3dHilight);
641
642 dc.TextRect(boxRect.right, boxRect.top,
643 boxRect.right+1, boxRect.bottom, TColor::SysBtnText);
644}
645
646//
647/// Paints a minimize box on the tiny caption bar.
648//
649void
651{
652 // Fill the box with light gray & draw bevel if possible
653 //
655
656 if (pressed)
657 boxRect.Offset(1,1);
658
659 int bh = boxRect.Height();
660 int bw = boxRect.Width();
661
662 TPoint begPt = boxRect.TopLeft().OffsetBy((bw+1)/4, (bh+2)/3);
663 TPoint endPt = begPt.OffsetBy((bw+1)/2,0);
664 while (begPt.x < endPt.x) {
665 dc.MoveTo(begPt);
666 dc.LineTo(endPt);
667 begPt.Offset(1,1);
668 endPt.Offset(-1,1);
669 }
670}
671
672//
673/// Paints a maximize box on the tiny caption bar.
674//
675void
677{
678 // Fill the box with light gray & draw bevel if possible
679 //
681
682 if (pressed)
683 boxRect.Offset(1,1);
684
685 // Down triangle
686 //
687 int bh = boxRect.Height();
688 int bw = boxRect.Width();
689
690 if (IsZoomed()) {
691 TPoint begPt = boxRect.BottomLeft().OffsetBy((bw+1)/4, -bh*3/8);
692 TPoint endPt = begPt.OffsetBy((bw+1)/2, 0);
693 while (begPt.x < endPt.x) {
694 dc.MoveTo(begPt);
695 dc.LineTo(endPt);
696 begPt.Offset(1,1);
697 endPt.Offset(-1,1);
698 }
699 }
700
701 // Up triangle
702 //
703 {
704 TPoint begPt = boxRect.TopLeft().OffsetBy((bw+1)/4, IsZoomed() ? bh*3/8 : bh*2/3);
705 TPoint endPt = begPt.OffsetBy((bw+1)/2, 0);
706 while (begPt.x < endPt.x) {
707 dc.MoveTo(begPt);
708 dc.LineTo(endPt);
709 begPt.Offset(1, -1);
710 endPt.Offset(-1, -1);
711 }
712 }
713}
714
715//
716/// Calls dc.SelectObject() to select the given rectangle and dc.PatBlt() to paint the
717/// tiny caption bar using the currently selected brush for this device context.
718//
719void
721{
722 // Paint caption background and caption text if any.
723 //
724 TWindowDC dc(*this);
726
729
730 // Could use a TBrush and PatBlt instead, but text backgrounds are always
731 // solid so this works well.
732 //
735
736 CHECK(CaptionFont);
737 dc.SelectObject(*CaptionFont);
739 LPCTSTR c = GetCaption() ? GetCaption() : _T("");
740 TSize textSize = dc.GetTextExtent(c, static_cast<int>(::_tcslen(c)));
741
742 // Calc x coord for text, so that text is centered between caption buttons
743 //
744 int xOrg = captRect.right - captRect.left;
745 long style = GetWindowLong(GWL_STYLE);
746
747 if (style & WS_MINIMIZEBOX)
748 xOrg -= GetMinBoxRect().Width();
749
750 if (style & WS_MAXIMIZEBOX)
751 xOrg -= GetMaxBoxRect().Width();
752
753 if ((style & WS_SYSMENU) || CloseBox)
754 xOrg -= GetSysBoxRect().Width();
755
756 xOrg -= textSize.cx;
757 if (xOrg<0)
758 xOrg = 0;
759 else
760 xOrg = xOrg/2;
761
762 xOrg += captRect.left;
763
764 if ((style & WS_SYSMENU) || CloseBox)
765 xOrg += GetSysBoxRect().Width();
766
767 dc.ExtTextOut(xOrg, captRect.top-Border.cy,
769 &captRect,
770 c,
771 static_cast<int>(::_tcslen(c))
772 );
773 dc.RestoreFont();
774
775 // Paint widgets: sysmenu or close button, minimize button, maximize button
776 // They currently all use a black pen
777 //
779
780 // Paint system menu or close button
781 //
782 if (CloseBox){
784 PaintCloseBox(dc, rect, false);
785 }
786 else if (style & WS_SYSMENU){
788 PaintSysBox(dc, rect, false);
789 }
790
791 // Paint minimize button
792 //
793 if (style & WS_MINIMIZEBOX){
795 PaintMinBox(dc, rect, false);
796 }
797
798 // Paint maximize button
799 //
800 if (style & WS_MAXIMIZEBOX){
802 PaintMaxBox(dc, rect, false);
803 }
804
805 // Draw window-frame color line under caption
806 //
808 dc.FrameRect(captRect.left, captRect.bottom-1, captRect.right, captRect.bottom,
809 winFrameBr);
810}
811
812//
813/// Gets the area of the caption for changing or repainting.
814/// \note GetCaptionRect and GetSysBoxRect must be kept in sync!
815//
816TRect
818{
819 // Get caption rect converted to window relative coordinates
820 //
822 captRect -= captRect.TopLeft();
823
824 captRect.left += Frame.cx;
825 captRect.top += Frame.cy;
826 captRect.right -= Frame.cx;
827 captRect.bottom = captRect.top + CaptionHeight;
828
829 return captRect;
830}
831
832//
833/// Returns the size of the system box rectangle.
834//
835TRect
837{
839 boxRect.right = boxRect.left + CaptionHeight;
840 boxRect.left -= 1;
841 boxRect.top -= 1;
842 return boxRect;
843}
844
845//
846/// Returns the size of the minimize box rectangle.
847//
848TRect
850{
851 // Far right on caption if no max box, else next to max box
852 //
855 boxRect.Offset(-CaptionHeight, 0);
856 return boxRect;
857}
858
859//
860/// Returns the size of the maximize box rectangle.
861//
862TRect
864{
866 boxRect.left = boxRect.right - CaptionHeight;
867 boxRect.top -= 1;
868 boxRect.right += 1;
869 return boxRect;
870}
871
872//
873/// Gets the system menu and sets up menu items. DoSysMenu is also responsible for
874/// displaying and tracking the status of the menu.
875//
876void
878{
880 if (hSysMenu) {
882 EnableMenuItem(hSysMenu, SC_RESTORE, (IsIconic() || IsZoomed()) ? MF_ENABLED : MF_GRAYED);
883 EnableMenuItem(hSysMenu, SC_MOVE, (1/*style & WS_CAPTION*/) ? MF_ENABLED : MF_GRAYED);
884 EnableMenuItem(hSysMenu, SC_SIZE, (style & WS_THICKFRAME) ? MF_ENABLED : MF_GRAYED);
885 EnableMenuItem(hSysMenu, SC_MINIMIZE, ((style&WS_MINIMIZEBOX) && !IsIconic()) ? MF_ENABLED : MF_GRAYED);
886 EnableMenuItem(hSysMenu, SC_MAXIMIZE, ((style&WS_MAXIMIZEBOX) && !IsZoomed()) ? MF_ENABLED : MF_GRAYED);
888 ClientToScreen(r.TopLeft()); // Cvt pt to screen coord
889 ClientToScreen(r.BottomRight());
890 TrackPopupMenu(hSysMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON,
891 r.left-Frame.cx, r.top-Frame.cy, 0, GetHandle(), &r);
892 }
893}
894
895
896#if OWL_PERSISTENT_STREAMS
897
899
900//
901// Reads an instance of TTinyCaption from the given ipstream
902//
903void*
904TTinyCaption::Streamer::Read(ipstream& is, uint32 /*version*/) const
905{
906 TTinyCaption* o = GetObject();
907
908 o->CaptionFont = 0;
909 is >> o->TCEnabled;
910 if (o->TCEnabled) {
911 int captionHeight;
912 is >> captionHeight >> o->CloseBox;;
913 o->EnableTinyCaption(captionHeight, o->CloseBox);
914 }
915 return o;
916}
917
918//
919// Writes the TTinyCaption to the given opstream
920//
921void
922TTinyCaption::Streamer::Write(opstream& os) const
923{
924 TTinyCaption* o = GetObject();
925
926 os << o->TCEnabled;
927 if (o->TCEnabled) {
928 int captionHeight = (100*o->CaptionHeight) /
929 (o->Border.cy+TUIMetric::CyCaption);
930 os << captionHeight << o->CloseBox;
931 }
932}
933
934#endif
935
936} // OWL namespace
937/* ========================================================================== */
938
939
#define CHECK(condition)
Definition checks.h:239
The GDI Brush class is derived from TGdiObject.
Definition gdiobjec.h:180
static const TColor SysBtnText
The symbolic system color value for the text on buttons.
Definition color.h:342
static const TColor SysActiveCaption
The symbolic system color value for the caption of the active window.
Definition color.h:326
static const TColor Sys3dHilight
The symbolic system color value for highlighted 3-dimensional display elements (for edges facing the ...
Definition color.h:344
static const TColor SysCaptionText
The symbolic system color value for text in captions and size boxes, and for the arrow boxes on scrol...
Definition color.h:333
static const TColor SysInactiveCaption
The symbolic system color value for the caption background of every inactive window.
Definition color.h:327
static const TColor SysInactiveCaptionText
The symbolic system color value for the caption text of every inactive window.
Definition color.h:343
static const TColor SysWindowFrame
The symbolic system color value for the frame around each window.
Definition color.h:330
static const TColor Sys3dShadow
The symbolic system color value for the shadow regions of 3-dimensional display elements (for edges f...
Definition color.h:340
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
Definition color.h:339
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
bool FrameRect(int x1, int y1, int x2, int y2, const TBrush &brush)
Draws a border on this DC around the given rectangle, rect, using the given brush,...
Definition dc.h:1781
bool MoveTo(int x, int y)
Moves the current position of this DC to the given x- and y-coordinates or to the given point.
Definition dc.h:1690
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
Definition dc.cpp:113
bool GetTextExtent(const tstring &str, int stringLen, TSize &size) const
Computes the extent (width and height) in logical units of the text line consisting of stringLen char...
Definition dc.h:2968
virtual bool ExtTextOut(int x, int y, uint16 options, const TRect *r, const tstring &str, int count=-1, const int *dx=nullptr)
Draws up to count characters of the given null-terminated string in the current font on this DC.
Definition dc.cpp:603
bool TextRect(int x1, int y1, int x2, int y2)
Fills the given rectangle, clipping any text to the rectangle.
Definition dc.h:1878
virtual void RestoreFont()
Restores the original GDI font object to this DC.
Definition dc.cpp:246
bool LineTo(int x, int y)
Draws a line on this DC using the current pen object.
Definition dc.h:2148
virtual void SelectStockObject(int index)
Selects into the DC a predefined stock pen, brush, font, or palette.
Definition dc.cpp:206
virtual TColor SetTextColor(const TColor &color)
Sets the current text color of this DC to the given color value.
Definition dc.cpp:417
int SetBkMode(int mode)
Sets the background mode to the given mode argument, which can be either OPAQUE or TRANSPARENT.
Definition dc.h:1116
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
int Height() const
Returns the height of this rectangle (bottom - top).
Definition geometry.h:1048
TRect InflatedBy(int dx, int dy) const
Returns a rectangle inflated by the given delta arguments.
Definition geometry.h:1281
const TPoint & TopLeft() const
Returns the upperleft point.
Definition geometry.h:983
int Width() const
Returns the width of this rectangle (right - left).
Definition geometry.h:1039
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
~TTinyCaption() override
Destroys a TTinyCaption object and deletes the caption font.
Definition tinycapt.cpp:54
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_SYSCO...
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
static const TUIMetric CyBorder
Definition uimetric.h:40
static const TUIMetric CyCaption
Definition uimetric.h:38
static const TUIMetric CyFixedFrame
Definition uimetric.h:42
static const TUIMetric CxBorder
Definition uimetric.h:39
static const TUIMetric CySizeFrame
Definition uimetric.h:67
static const TUIMetric CxFixedFrame
Definition uimetric.h:41
static const TUIMetric CySmCaption
Definition uimetric.h:85
static const TUIMetric CxSizeFrame
Definition uimetric.h:66
Derived from TDC, TWindowDC is a device context (DC) class that provides access to the entire area ow...
Definition dc.h:588
static TPoint GetCursorPos()
Definition window.h:1212
static HWND GetActiveWindow()
Retrieves the handle of the active window.
Definition window.h:2702
HWND SetCapture()
Sets the mouse capture to the current window.
Definition window.h:2121
void EvNCLButtonDown(uint codeHitTest, const TPoint &)
The default message handler for WM_NCLBUTTONDOWN.
Definition window.h:3883
void EvLButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_LBUTTONUP.
Definition window.h:3792
TRect GetWindowRect() const
Gets the screen coordinates of the window's rectangle.
Definition window.h:2257
long GetWindowLong(int index) const
Retrieves information about the window depending on the value stored in index.
Definition window.h:2388
static void ReleaseCapture()
Releases the mouse capture from this window.
Definition window.h:2130
bool IsIconic() const
Returns true if window is iconic or minimized.
Definition window.h:2628
void ClientToScreen(TPoint &point) const
Converts the client coordinates specified in point to screen coordinates for the new window.
Definition window.h:2248
bool IsChild(HWND hWnd) const
Returns true if the window is a child window or a descendant window of this window.
Definition window.h:3176
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
Definition window.cpp:1392
uint32 GetStyle() const
Gets the style bits of the underlying window or the 'Style' member of the attribute structure associa...
Definition window.cpp:3558
LPCTSTR GetCaption() const
Returns the Title member of TWindow.
Definition window.h:1900
bool EvNCActivate(bool active)
The default message handler for WM_NCACTIVATE.
Definition window.h:3848
uint EvNCHitTest(const TPoint &)
The default message handler for WM_NCHITTEST.
Definition window.h:3869
TResult DefaultProcessing()
Handles default processing of events, which includes continued processing of menu/accelerators comman...
Definition window.cpp:852
void EvSysCommand(uint cmdType, const TPoint &point)
Responds to a user-selected command from the System menu or when the user selects the maximize or min...
Definition window.h:4014
virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode)
WindowProc calls EvCommand to handle WM_COMMAND messages.
Definition window.cpp:999
bool IsZoomed() const
Returns true if window is zoomed or maximized.
Definition window.h:2617
HMENU GetSystemMenu(bool revert=false) const
Returns a handle to the system menu so that an application can access the system menu.
Definition window.h:3256
bool PostMessage(TMsgId, TParam1=0, TParam2=0)
Posts a message (msg) to the window in the application's message queue.
Definition window.h:2103
void EvMouseMove(uint modKeys, const TPoint &point)
The default message handler for WM_MOUSEMOVE.
Definition window.h:3841
TResult SendMessage(TMsgId, TParam1=0, TParam2=0) const
Sends a message (msg) to a specified window or windows.
Definition window.cpp:3288
static HWND GetFocus()
Gets a handle to the window that has the focus.
Definition window.h:2139
uint EvNCCalcSize(bool calcValidRects, NCCALCSIZE_PARAMS &)
The default message handler for WM_NCCALCSIZE.
Definition window.h:3855
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 _tcslen
Definition cygwin.h:74
#define _T(x)
Definition cygwin.h:51
#define DEFINE_RESPONSE_TABLE(cls)
Macro to define a response table for a class with no base response tables.
Definition eventhan.h:479
Definition of abstract GDI object class and derived classes.
#define IMPLEMENT_STREAMABLE(cls)
Definition objstrm.h:1724
TEventStatus
Mixin window event implementation return status.
Definition window.h:107
@ esPartial
Additional handlers may be invoked.
Definition window.h:108
@ esComplete
No additional handlers are needed.
Definition window.h:109
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
EV_WM_NCCALCSIZE
Definition docking.cpp:963
EV_WM_LBUTTONUP
Definition docking.cpp:2056
EV_WM_NCHITTEST
Definition floatfra.cpp:29
EV_WM_MOUSEMOVE
Definition docking.cpp:2054
EV_WM_SYSCOMMAND
Definition floatfra.cpp:26
unsigned long uint32
Definition number.h:34
EV_WM_NCACTIVATE
Definition floatfra.cpp:31
TParam2 MkParam2(const T1 &lo, const T2 &hi)
Definition dispatch.h:65
OWL_DIAGINFO
Definition animctrl.cpp:14
EV_WM_NCPAINT
Definition docking.cpp:964
END_RESPONSE_TABLE
Definition button.cpp:26
EV_WM_NCLBUTTONDOWN
Definition docking.cpp:541
LRESULT TResult
Result type.
Definition dispatch.h:52
unsigned int uint
Definition number.h:25
Definition of TUIMetric, a UI metrics provider class.
#define WS_EX_TOOLWINDOW
Definition wsysinc.h:27