OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
gadgetwi.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
4//
5/// \file
6/// Implementation of class TGadgetWindow and TGadgetWindowFont.
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9
10#include <owl/gadget.h>
11#include <owl/gadgetwi.h>
12#include <owl/framewin.h>
13#include <owl/decframe.h>
14#include <owl/celarray.h>
15#include <owl/tooltip.h>
16#include <owl/uimetric.h>
17#include <owl/commctrl.h>
18#include <owl/theme.h>
19
20#if defined(__TRACE) || defined(__WARN)
21# if !defined(OWL_PROFILE_H)
22# include <owl/profile.h>
23# endif
24#endif
25
26#include <stdio.h>
27
28#include <algorithm>
29
30using namespace std;
31
32namespace owl {
33
34//
35// Diagnostic group for gadgets & gadget windows
36//
40
43
56
57uint TGadgetWindow::FlatStyle = NonFlatNormal;
58
59namespace {
60
61 //
62 // Returns a font variation based on the default TGadgetWindowFont.
63 //
65 {
68 f.lfHeight = -pointSize * TScreenDC().GetDeviceCaps(LOGPIXELSY) / 72;
69 f.lfWeight = bold ? FW_BOLD : FW_NORMAL;
70 f.lfItalic = italic ? TRUE : FALSE;
71 return f;
72 }
73
74} // namespace
75
76//
77/// Constructs a font based on TDefaultGuiFont.
78//
82
83//
84/// Constructs a font with the given size, boldness and italics style.
85/// Note that the size should be given in points, not pixels.
86/// The font is based on the system font encapsulated by TDefaultGuiFont.
87//
91
92//----------------------------------------------------------------------------
93
94//
95/// Creates a TGadgetWindow interface object with the default tile direction and
96/// font and passes module with a default value of 0.
97//
100 TFont* font,
101 TModule* module)
102:
103 WantTimer(false),TimerID(0), ThemeBackgroundMode(false)
104{
105 // Initialize virtual base, in case the derived-most used default ctor
106 //
107 TWindow::Init(parent, nullptr, module);
108
109 // Make sure we don't paint or erase over any child windows
110 //
112
113 Capture = nullptr;
114 AtMouse = nullptr;
115 Font = font ? font : new TGadgetWindowFont();
116
117 Direction = direction;
118
119 // Shrink wrap the narrow axis
120 //
121#if defined(BI_COMP_GNUC)
122 TTileDirection dir = Direction;
123 ShrinkWrapWidth = dir != Horizontal;// As narrow as possible
124 ShrinkWrapHeight = dir != Vertical; // As short as possible
125#else
126 ShrinkWrapWidth = (static_cast<int>(Direction)) != Horizontal;// As narrow as possible
127 ShrinkWrapHeight = (static_cast<int>(Direction)) != Vertical; // As short as possible
128#endif
129 HintMode = PressHints;
130
131 WideAsPossible = 0; // Number of gadgets with "WideAsPossible" set
132 DirtyLayout = true;
133
134 // Compute the font height
135 //
137 Font->GetTextMetrics(metrics);
138 FontHeight = metrics.tmHeight + metrics.tmExternalLeading;
139
140 // Choose a default height based on the height of the font plus room
141 // for a top and bottom border.
142 // !CQ Really only useful for Horizontal layout if at all...
143 //
144 Attr.H = FontHeight;
145
146 if (Attr.Style & WS_BORDER)
147 Attr.H += 2 * TUIMetric::CyBorder;
148
150
151 SharedCels = nullptr;
152 Tooltip = nullptr;
153 WantTooltip = false;
154
155 // Rectangular layout members
156 // !CQ Use Attr.W now for desired width?
157 //
158 RowWidth = 0; // Don't know yet? Set externally. Never let get smaller than widest gadget
159 RowMargin = 4;
160}
161
162//
163/// Destructs this gadget window. Deletes the gadgets, the font and the shared
164/// cel array
165//
167{
168 delete Font;
169 delete SharedCels;
170}
171
172//
173/// Responds to WM_SYSCOLORCHANGE to let the gadgets update their UI colors, and to
174/// let this gadget window update its background color.
175///
176/// \note This is an obsolete function retained for compatibility. New TWindow,
177/// TColor, and other UI support makes this unecessary.
178//
179void
181{
182 for (TGadget* g = Gadgets; g; g = g->NextGadget())
183 g->SysColorChange();
184}
185
186//
187/// During idle time, iterates over the Gadgets invoking their CommandEnable()
188/// member function. Also detects lost mouse up for fly-over hint mode.
189//
190bool
192{
193 if (idleCount == 0) {
194
195 // See if we missed a mouse move & still need to send a MouseLeave to a
196 // gadget
197 //
198 if (AtMouse) {
202 HandleMessage(WM_MOUSEMOVE, 0, MkParam2(-1,-1)); // nowhere
203 }
204 }
205
206 // Let the gadgets do command enabling if they need to
207 //
208 for (TGadget* g = Gadgets; g; g = g->NextGadget())
209 g->IdleAction(idleCount);
210
211 // Chain to base implementation
212 //
214}
215
216//
217/// Inform GadgetWindow to start a Timer notification.
218///
219/// Set timer - useful for gadgets that need regular update [Time/Date].
220///
221/// \note TGadgetWindow does not catch the WM_TIMER event. The purpose of
222/// the timer message it to cause message dispatching which eventually
223/// leads to an 'IdleAction' call.
224//
225bool
227{
228 // Set flag and let 'SetupWindow' create timer
229 //
230 if (!GetHandle()) {
231 WantTimer = true;
232 return true;
233 }
234
235 // Set a timer if one's not enabled already
236 //
237 if (!TimerID)
239
240 return TimerID != 0;
241}
242
243//
244/// Sets the width and height of the data members. By default, if the tile direction
245/// is horizontal, ShrinkWrapWidth is false and ShrinkWrapHeight is true. Also by
246/// default, if the direction is vertical, ShrinkWrapWidth is true and
247/// ShrinkWrapHeight is false.
248//
249void
251{
252 ShrinkWrapWidth = shrinkWrapWidth;
253 ShrinkWrapHeight = shrinkWrapHeight;
254}
255
256//
257/// Called by a gadget that wants to capture the mouse
258///
259/// GadgetSetCapture reserves all mouse messages for the gadget window until the
260/// capture is released. Although gadgets are always notified if a left button-down
261/// event occurs within the rectangle, the derived gadget class must call
262/// GadgetSetCapture if you want the gadget to be notified when a mouse drag and a
263/// mouse button-up event occurs.
264///
265/// Fails if already captured
266//
267bool
269{
270 if (Capture)
271 return false;
272
273 else {
274 Capture = &gadget;
275 SetCapture();
276 return true;
277 }
278}
279
280//
281/// Releases the capture so that other windows can receive mouse messages.
282///
283/// Ignores other gadgets
284//
285void
287{
288 if (&gadget == Capture) {
289 Capture = nullptr;
291 }
292}
293
294//
295/// Simulates menu selection messages so that ObjectWindows command processing can
296/// display command hints for the given command id (CM_xxxx).
297//
298void
300{
301 // Find our ancestor decorated frame [which potentially has a statusbar
302 // to show hint messages]
303 //
304 TWindow* parent= GetParentO();
305 TDecoratedFrame* frame= parent ?
306 TYPESAFE_DOWNCAST(parent, TDecoratedFrame) : nullptr;
307 while (parent && !frame) {
308 parent = parent->GetParentO();
309 if (parent)
310 frame = TYPESAFE_DOWNCAST(parent, TDecoratedFrame);
311 }
312
313 // Forward command id to frame via fake WM_MENUSELECT messages
314 //
315 if (frame) {
316 if (id > 0) {
317 frame->HandleMessage(WM_MENUSELECT, id, 0);
318 }
319 else {
320 // Send a menuselect w/ flags==0xFFFF and hMenu==0 to indicate end
321 //
322 frame->HandleMessage(WM_MENUSELECT, 0xFFFF0000, 0); // flags+item, hmenu
323 }
325 }
326}
327
328//
329/// Sets or changes the margins for the gadget window and calls LayoutSession().
330//
331void
333{
334 Margins = margins;
336}
337
338//
339/// Converts layout units to pixels. A layout unit is determined by dividing the
340/// window font height by eight.
341//
342int
344{
345 const long unitsPerEM = 8;
346
347 return int((long(units) * FontHeight + unitsPerEM / 2) / unitsPerEM);
348}
349
350//
351/// LayoutSession is typically called when a change occurs in the size of the
352/// margins or gadgets, or when gadgets are added or deleted. LayoutSession calls
353/// TileGadgets() to tile the gadgets in the specified direction and Invalidate() to
354/// mark the area as invalid (needs repainting).
355//
356void
362
363//
364/// Get the desired size for this gadget window by performing a trial layout of
365/// the gadgets without touching them.
366///
367/// If shrink-wrapping was requested, GetDesiredSize returns the size needed to
368/// accommodate the borders and the margins of the widest and highest gadget;
369/// otherwise, it returns the width and height in the window's Attr structure.
370///
371/// If you want to leave extra room for a specific look (for example, a separator
372/// line between gadgets, a raised line, and so on), you can override this function.
373/// However, if you override GetDesiredSize(), you will probably also need to override
374/// GetInnerRect() to calculate your custom inner rectangle.
375///
376/// For Rectangular layout it is assumed that the EndOfRow gadgets are already
377/// Set.
378//
379void
381{
382 TLayoutInfo layout(NumGadgets);
383 if (ShrinkWrapWidth || ShrinkWrapHeight)
384 LayoutGadgets(Direction, layout);
385
386 // Calculate the X dimension for both shrinkWrap and externally set
387 //
388 if (ShrinkWrapWidth)
389 size.cx = layout.DesiredSize.cx;
390 else
391 size.cx = Attr.W; // Not shrink wrapped, just use set size
392
393 // Calculate the Y dimension for both shrinkWrap and externally set
394 // Always shrinkwrap rectangular layout vertically
395 //
396 if (ShrinkWrapHeight) {
397 if (NumGadgets == 0)
398 size.cy = 0;
399 else
400 size.cy = layout.DesiredSize.cy;
401 }
402 else
403 size.cy = Attr.H; // Not shrink wrapped, just use set size
404}
405
406//
407/// Updates the Size in Attr.W and Attr.H to match that obtained using
408/// GetDesiredSize() for each dimension that is shrink-wrapped.
409//
410void
412{
413 if (ShrinkWrapWidth || ShrinkWrapHeight) {
414 TSize size;
415 GetDesiredSize(size);
416
417 if (ShrinkWrapWidth)
418 Attr.W = size.cx;
419 if (ShrinkWrapHeight)
420 Attr.H = size.cy;
421 }
422}
423
424//
425/// Overrides TWindow member function and chooses the initial size of the gadget if
426/// shrink-wrapping was requested.
427//
428bool
430{
432 return TWindow::Create();
433}
434
435//
436/// Sets the horizontal or vertical orientation of the gadgets. If the gadget window
437/// is already created, SetDirection readjusts the dimensions of the gadget window
438/// to fit around the gadgets.
439///
440/// The setting of the direction parameter is also related to the setting of the
441/// second parameter (TLocation) in TDecoratedFrame's Insert function,. which
442/// specifies where the decoration is added in relation to the frame window's client
443/// window. If the second parameter in TDecoratedFrame::Insert() is set to top or
444/// bottom, the direction parameter in SetDirection must be horizontal. If the
445/// second parameter in TDecoratedFrame::Insert() is set to left or right, the
446/// direction parameter in SetDirection must be vertical.
447//
448void
450{
451#if defined(BI_COMP_GNUC)
452 TTileDirection dir = Direction;
453 if (dir != direction || DirtyLayout) {
454 if (dir != direction) {
455#else
456 if ((static_cast<int>(Direction)) != direction || DirtyLayout) {
457
458 // Swap margin's and ShrinkWrap's X & Y axis
459 //
460 if ((static_cast<int>(Direction)) != direction) {
461#endif
462 // Margin swapping seems to not be used in the latest UIs
463 //
464#if 0
465 int t = Margins.Left; Margins.Left = Margins.Top; Margins.Top = t;
466 t = Margins.Right; Margins.Right = Margins.Bottom; Margins.Bottom = t;
467#endif
468 // NOTE: a limitation. Passing thru Rectangular will mess this swap up
469 //
470 bool sww = ShrinkWrapWidth;
471 ShrinkWrapWidth = ShrinkWrapHeight;
472 ShrinkWrapHeight = sww;
473
474 Direction = direction;
475 DirtyLayout = true;
476 }
477
478 // Get & use the new size & relayout if created
479 //
482 }
483}
484
485//
486/// Set flat style options, or disable it.
487//
488void
490{
491 if(style == FlatDefault)
492 {
494 static const auto v = GetCommCtrlVersion();
495 if (v >= 0x60000)
496 style |= FlatXPTheme;
497 }
498 FlatStyle = style;
499}
500
501//
502// Returns true if the application is themed (Windows XP Visual Style).
503//
504bool
506{
507 return (FlatStyle & FlatXPTheme) && TThemeModule::GetInstance().IsAppThemed();
508}
509
510//
511// Enables or disables themed background.
512//
513void
515{
516 ThemeBackgroundMode = enable;
517}
518
519//
520// Returns true if themed background is enabled.
521//
522bool
524{
525 return ThemeBackgroundMode;
526}
527
528//
529// Returns true if themed background is enabled and themes are active.
530//
531bool
536
537//
538/// Sets the maximum width for each row used for rectangular layout.
539/// LayoutSession() or SetDirection() must be called for changes to take effect
540//
541void
543{
544 if (width != RowWidth || (rowMargin >= 0 && rowMargin != RowMargin))
545 {
546 RowWidth = width;
547 if (rowMargin >= 0)
548 RowMargin = rowMargin;
549 if (Direction == Rectangular)
550 DirtyLayout = true;
551 }
552}
553
554//
555/// GetInnerRect computes the rectangle inside of the borders and margins of the
556/// gadget.
557///
558/// If you want to leave extra room for a specific look (for example, a separator
559/// line between gadgets, a raised line, and so on), you can override this function.
560/// If you override GetInnerRect, you will probably also need to override
561/// GetDesiredSize() to calculate your custom total size.
562//
563void
565{
566 int left, right, top, bottom;
567 GetMargins(Margins, left, right, top, bottom);
568
569 if (Attr.W != 0) {
570 rect.left = left;
571 rect.right = Attr.W - right;
572 if (Attr.Style & WS_BORDER)
573 rect.right -= 2 * TUIMetric::CyBorder;
574 }
575 else {
576 rect.left = 0;
577 rect.right = 0;
578 }
579 if (Attr.H != 0) {
580 rect.top = top;
581 rect.bottom = Attr.H - bottom;
582 if (Attr.Style & WS_BORDER)
583 rect.bottom -= 2 * TUIMetric::CxBorder;
584 }
585 else {
586 rect.top = 0;
587 rect.bottom = 0;
588 }
589}
590
591//
592/// Virtual called by TileGadgets() for each gadget in order to give derived
593/// classes a chance to modify the gadget positioning. Default is to overlap
594/// adjacent plain-bordered gadgets
595//
596void
598{
599 // Overlap the button borders
600 // !CQ make sure this is right for win95. Also in regular controlbar
601 //
602 if (previous->GetBorderStyle() == TGadget::Plain &&
603 next->GetBorderStyle() == TGadget::Plain)
604 {
605 if (Direction == Horizontal)
607 else
609 }
610}
611
612//
613/// Tiles the gadgets in the direction requested (horizontal or vertical). Calls
614/// PositionGadget() to give derived classes an opportunity to adjust the spacing
615/// between gadgets in their windows.
616//
617TRect
619{
620 TLayoutInfo layout(NumGadgets);
621 LayoutGadgets(Direction, layout);
622
623 TRect invalidRect(0,0,0,0);
624 int i = 0;
625 for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
626 TRect originalBounds = gadget->GetBounds();
627 TRect bounds = layout.GadgetBounds[i];
628 if (originalBounds != bounds) {
629 gadget->SetBounds(bounds);
630 if (originalBounds.TopLeft() != TPoint(0, 0))
633 }
634 }
635 DirtyLayout = false;
636 return invalidRect;
637}
638
639//
640/// Helper for LayoutGadgets() to calculate horizontal tiling
641//
642void
643TGadgetWindow::LayoutHorizontally(TLayoutInfo& layout)
644{
647
648 int leftM, rightM, topM, bottomM;
649 GetMargins(Margins, leftM, rightM, topM, bottomM);
650
651 layout.DesiredSize = TSize(0,0);
652 layout.GadgetBounds = new TRect[NumGadgets];
653
654 // First pass tally the width of all gadgets that don't have "WideAsPossible"
655 // set if any have it seet so that we can divide up the extra width
656 //
657 // NOTE: we must also take into account any adjustments to the gadget spacing
658 //
660 if (WideAsPossible) {
661 int width = 0;
662 for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
663 if (!gadget->WideAsPossible) {
664 TSize desiredSize(0, 0);
665
666 gadget->GetDesiredSize(desiredSize);
667 width += desiredSize.cx;
668 }
669
670 if (gadget->Next) {
671 TPoint spacing(0, 0);
672
674 width += spacing.x;
675 }
676 }
677 wideAsPossibleWidth = std::max(( (innerRect.Width() - width) / static_cast<int>(WideAsPossible) ), 0);
678 }
679 else
681
682 // Now tile all the gadgets
683 //
684 int x = leftM;
685 int y = topM;
686 int h = 0;
687 int i = 0;
688
689
690 // Pass 1: calculate the gadget sizes and row height
691 //
693 for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
694 TSize desiredSize(0, 0);
695 gadget->GetDesiredSize(desiredSize);
696
697 // Stash away the desiredSize for the next pass
698 //
699 layout.GadgetBounds[i].left = desiredSize.cx;
700 layout.GadgetBounds[i].top = desiredSize.cy;
701
702 h = std::max(h, static_cast<int>(desiredSize.cy));
703 }
704
705 // Pass 2: place the gadget in the row, centered vertically
706 //
707 i = 0;
708 for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
709 TRect bounds = gadget->GetBounds();
710
711 // Recover desired size from where we stashed it
712 //
713 TSize desiredSize(layout.GadgetBounds[i].left, layout.GadgetBounds[i].top);
714
715 bounds.left = x;
716 bounds.top = y + (h - desiredSize.cy) / 2; // Center vertically
717 if (gadget->WideAsPossible)
718 bounds.right = bounds.left + std::max(wideAsPossibleWidth, static_cast<int>(desiredSize.cx));
719 else
720 bounds.right = bounds.left + desiredSize.cx;
721 bounds.bottom = bounds.top + desiredSize.cy;
722
723 layout.GadgetBounds[i] = bounds;
724 x += bounds.Width();
725
726 if (gadget->Next) {
727 TPoint origin(x, 0);
728
730 x = origin.x;
731 }
732
733 // Update gadget window's cumulative desired size
734 //
735 layout.DesiredSize.cx = std::max(int(bounds.right+rightM), static_cast<int>(layout.DesiredSize.cx));
736 layout.DesiredSize.cy = std::max(int(bounds.bottom+bottomM), static_cast<int>(layout.DesiredSize.cy));
737 }
738}
739
740//
741/// Helper for LayoutGadgets() to calculate vertical tiling
742//
743void
744TGadgetWindow::LayoutVertically(TLayoutInfo& layout)
745{
746 TRect innerRect;
748
749 int leftM, rightM, topM, bottomM;
750 GetMargins(Margins, leftM, rightM, topM, bottomM);
751
752 layout.DesiredSize = TSize(0,0);
753 layout.GadgetBounds = new TRect[NumGadgets];
754
755 // Now tile all the gadgets
756 //
757 int y = topM;
758 int x = leftM;
759 int w = 0;
760 int i = 0;
761
762 // Pass 1: calculate gadget sizes and column width
763 //
765 for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
766 TSize desiredSize(0, 0);
767 gadget->GetDesiredSize(desiredSize);
768
769 // Stash away the DesiredSize for the next pass
770 //
771 layout.GadgetBounds[i].left = desiredSize.cx;
772 layout.GadgetBounds[i].top = desiredSize.cy;
773
774 w = std::max(w, static_cast<int>(desiredSize.cx));
775 }
776
777 // Pass 2: place the gadget in the column, centered horizontally
778 //
779 i = 0;
780 for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
781 TRect bounds = gadget->GetBounds();
782
783 // Recover desired size from where we stashed it
784 //
785 TSize desiredSize(layout.GadgetBounds[i].left, layout.GadgetBounds[i].top);
786
787 bounds.top = y;
788 bounds.bottom = bounds.top + desiredSize.cy;
789 bounds.left = x + (w - desiredSize.cx) / 2; // Center horizontally
790 bounds.right = bounds.left + desiredSize.cx;
791
792 layout.GadgetBounds[i] = bounds;
793
794 y += bounds.Height();
795
796 if (gadget->Next) {
797 TPoint origin(0, y);
798
800 y = origin.y;
801 }
802
803 // Update gadget window's desired size
804 //
805 layout.DesiredSize.cx = static_cast<int>(std::max(int(bounds.right+rightM), static_cast<int>(layout.DesiredSize.cx)));
806 layout.DesiredSize.cy = static_cast<int>(std::max(int(bounds.bottom+bottomM), static_cast<int>(layout.DesiredSize.cy)));
807 }
808}
809
810//
811/// Assign top & bottoms of all controls on this row (i.e. from rowStart to
812/// lastBreak). If !lastBreak, go to the end of the list.
813//
814void TGadgetWindow::FinishRow(int istart, TGadget* rowStart, TGadget* lastBreak,
815 int rowTop, TLayoutInfo& layout, int& rowHeight)
816{
817 int j;
818 TGadget* g;
819 rowHeight = 0;
820
821 for (j = istart, g = rowStart; g; g = g->Next, j++) {
822 rowHeight = std::max(rowHeight, static_cast<int>(layout.GadgetBounds[j].bottom));
823 if (g == lastBreak)
824 break;
825 }
826 for (j = istart, g = rowStart; g; g = g->Next, j++) {
827 // bounds.bottom has DesiredSize.cy
828 layout.GadgetBounds[j].top = rowTop + (rowHeight - layout.GadgetBounds[j].bottom) / 2;
829 layout.GadgetBounds[j].bottom = layout.GadgetBounds[j].top + layout.GadgetBounds[j].bottom;
830//JJH - max can compare only equal types
831#if defined(__GNUC__)
832 layout.DesiredSize.cy = max(static_cast<LONG>(layout.GadgetBounds[j].bottom), layout.DesiredSize.cy);
833#else
834 layout.DesiredSize.cy = max(layout.GadgetBounds[j].bottom, layout.DesiredSize.cy);
835#endif
836 if (g == lastBreak)
837 break;
838 }
839}
840
841//
842/// Helper for LayoutGadgets() to calculate rectangular 2D tiling
843//
844void
845TGadgetWindow::LayoutRectangularly(TLayoutInfo& layout)
846{
847 TRect innerRect;
849
850 layout.DesiredSize = TSize(0,0);
851 layout.GadgetBounds = new TRect[NumGadgets];
852// !CQ memset((void*)layout.GadgetBounds, 0, sizeof(TRect) * NumGadgets);// Debugging code
853
854 int leftM, rightM, topM, bottomM;
855 GetMargins(Margins, leftM, rightM, topM, bottomM);
856
857 // Now tile all the gadgets. Assume no wide-as-possibles.
858 //
859 int x = leftM;
860 int y = topM;
861 int right = RowWidth - rightM; // Base right margin limit on RowWidth
862
863 // If any controls are wider than right margin, push out the right margin.
864 //
866 for (gadget = Gadgets; gadget; gadget = gadget->Next) {
867 TSize desiredSize;
868 gadget->GetDesiredSize(desiredSize);
869
870 // SIR June 20th 2007 max instead of ::max
871 right = max(right, static_cast<int>(x + desiredSize.cx + rightM));
872 }
873
874 // Scan gadgets, positioning & placing all of the EndOfRow flags
875 //
876 TGadget* rowStart; // Tracks the first gadget in the row
877 TGadget* lastBreak; // Tracks the last gadget in the row
878 bool contRow = false; // Working on a group continuation row
879 bool contBreak = false; // Finished group on continuation row
880 int i = 0;
881 int istart = 0;
882 int iend = 0; // Tracks the last visible gadget in the row
883 int ibreak = 0;
884 int rowHeight;
885
886 rowStart = Gadgets;
887 lastBreak = Gadgets;
888 for (gadget = Gadgets; gadget; gadget = gadget->Next, i++) {
889 gadget->SetEndOfRow(false);
890
891 // !CQ ignore wide-as-possible gadget requests
892 //
893 TSize desiredSize;
894 gadget->GetDesiredSize(desiredSize);
895
896 TRect bounds = gadget->GetBounds();
897
898 // Do the horizontal layout of this control
899 //
900 bounds.left = x;
901 bounds.right = bounds.left + desiredSize.cx;
902
903 // Store gadget's height in bottom, so we can calculate the row height
904 // later
905 //
906 bounds.top = 0;
907 bounds.bottom = desiredSize.cy;
908
909 // If too big or a new group on a group continue row, (& is not the first
910 // & is visible) then back up to iend & reset to lastBreak+1
911 //
912 if ((bounds.right > right || contBreak) &&
913 gadget != rowStart && gadget->IsVisible()) {
914
915 lastBreak->SetEndOfRow(true);
916
917 // Update gadget window's desired size
918 //
919 layout.DesiredSize.cx =
920 std::max((layout.GadgetBounds[iend].right+rightM), layout.DesiredSize.cx);
921
922 // Do the vertical layout of this row
923 //
924 FinishRow(istart, rowStart, lastBreak, y, layout, rowHeight);
925
926 contRow = lastBreak->IsVisible(); // Next row is a group continuation
927 x = leftM;
928 y += rowHeight;
929 if (!contRow)
930 y += RowMargin;
931
932 gadget = lastBreak; // will get bumped to Next by for incr
933 i = ibreak; // so will this
934
935 rowStart = lastBreak = gadget->Next; // Begin next row
936 istart = i+1;
937 contBreak = false;
938 continue;
939 }
940
941 layout.GadgetBounds[i] = bounds;
942
943 // Advance the break and end cursors.
944 //
945 if (gadget->IsVisible()) {
946 if (lastBreak->IsVisible()) { // advance both if in the first group
947 iend = i;
949 ibreak = i;
950 }
951 else if (!gadget->Next || !gadget->Next->IsVisible()) {
952 // advance end if next is a break.
953 iend = i;
954 }
955 }
956 else { // advance last break if this gadget is a break
958 ibreak = i;
959 if (contRow) // This invisible gadget signifies end of group
960 contBreak = true;
961 }
962
963 x += bounds.Width();
964
965 if (gadget->Next) {
966 TPoint origin(x, 0);
967
969 x = origin.x;
970 }
971 }
972
973 // Update gadget window's desired size
974 //
975 layout.DesiredSize.cx =
976 static_cast<int>(std::max(int(layout.GadgetBounds[iend].right+rightM), static_cast<int>(layout.DesiredSize.cx)));
977
978 // Do the vertical layout of the last row & add in bottom margin
979 //
980 FinishRow(istart, rowStart, nullptr, y, layout, rowHeight);
981 layout.DesiredSize.cy += bottomM;
982}
983
984//
985/// Calculate the layout of the Gadgets in a given direction
986//
987void
989{
990 switch (dir) {
991 case Horizontal:
992 LayoutHorizontally(layout);
993 break;
994 case Vertical:
995 LayoutVertically(layout);
996 break;
997 default:
998 //case Rectangular:
1000 LayoutRectangularly(layout);
1001 break;
1002 }
1003}
1004
1005//
1006/// Used to notify the gadget window that a gadget has changed its size,
1007/// GadgetChangedSize calls LayoutSession() to re-layout all gadgets.
1008//
1009void
1014
1015//
1016/// Inserts a gadget before or after a sibling gadget (TPlacement). If sibling is 0,
1017/// then the new gadget is inserted at either the beginning or the end of the gadget
1018/// list. If this window has already been created, LayoutSession() needs to be called
1019/// after inserting gadgets.
1020//
1021void
1023{
1025
1026 // Compute the maxWidth and maxHeight of the gadgetwindow. Needed early when
1027 // not created if gadget window is being positioned within another window.
1028 //
1029 // !CQ is this really needed? Seems very time consuming after every insert
1030 // !CQ wait until all done inserting. Maybe only do if gadgetwindow is created
1031 // !CQ have docking slip ask (via GetDesiredSize) when it needs initial dimensions
1032 //
1034}
1035
1036//
1037/// Inserts a list of Gadgets.
1038///
1039/// The caller needs to also call LayoutSession() after inserting gadgets if
1040/// this window has already been created.
1041//
1042void
1044{
1046
1047 // Compute the maxWidth and maxHeight of the gadgetwindow. Needed early when
1048 // not created if gadget window is being positioned within another window.
1049 //
1050 // !CQ is this really needed? Seems very time consuming after every insert
1051 // !CQ wait until all done inserting. Maybe only do if gadgetwindow is created
1052 // !CQ have docking slip ask (via GetDesiredSize) when it needs initial dimensions
1053 //
1055}
1056
1057//
1058/// A gadget has been inserted into this gadget window
1059//
1060void
1062{
1063 // Let gadget know that it is now in this window
1064 //
1065 gadget.Window = this;
1066 gadget.Inserted();
1067
1068 // If the gadgetwindow was already created, inform gadget
1069 // so it may perform initialization that requires an HWND
1070 //
1071 if (GetHandle())
1072 gadget.Created();
1073
1074 if (gadget.WideAsPossible)
1075 WideAsPossible++;
1076}
1077
1078//
1079/// Removes a gadget from the gadget window. The gadget is returned but not
1080/// destroyed. Remove returns 0 if the gadget is not in the window.
1081///
1082/// If this window has already been created, the calling application must call
1083/// LayoutSession after any gadgets have been removed.
1084//
1085TGadget*
1087{
1088 if (gadget.Window != this)
1089 return nullptr;
1090
1091 // Perform actual removal from list
1092 //
1094}
1095
1096//
1097/// This indicates that a gadget has been removed from this gadget window.
1098//
1099void
1101{
1102 // Re-adjust gadget now that it doesn't live in a window
1103 //
1104 if (gadget.WideAsPossible)
1105 WideAsPossible--;
1106
1107 // Clear last know gadget as mouse location
1108 //
1109 if (&gadget == AtMouse)
1110 AtMouse = nullptr;
1111
1112 // Release caption if it has/had it
1113 //
1115
1116 // Notify gadget and reset/adjust variables to reflect new state of gadget
1117 //
1118 gadget.Removed();
1119 gadget.Window = nullptr;
1120 gadget.Next = nullptr;
1121 gadget.GetBounds() -= gadget.GetBounds().TopLeft();
1122}
1123
1124//
1125/// Sets a new Shared CelArray for this gadget window. Allows a predefined array of
1126/// images to be shared by the gadgets. This GadgetWindow assumes ownership of the
1127/// passed CelArray pointer.
1128//
1129void
1131{
1132 delete SharedCels;
1133 SharedCels = sharedCels;
1134}
1135
1136//
1137/// Gets the Shared CelArray for this gadget window. Makes an empty one "on the fly"
1138/// if needed.
1139//
1140TCelArray&
1142{
1143 if (!SharedCels) {
1144 // !CQ default??? BOGUS values here for now on purpose
1145 if (!minX)
1146 minX = 10;
1147 if (!minY)
1148 minY = 10;
1149 SharedCels = new TCelArray(TSize(minX,minY), ILC_MASK, 10, 5);
1150 }
1151
1152 return *SharedCels;
1153}
1154
1155//
1156/// Overrides TWindow::SetupWindow to create tooltips for the gadget window.
1157//
1158void
1160{
1162
1163 // if 'WantTimer' is enabled, start a timer
1164 //
1165 if (WantTimer)
1166 EnableTimer();
1167
1168 if (DirtyLayout) // !CQ latest OWL 5 was here...
1169 LayoutSession();
1170
1171 // Now that this window is created, see if any of the gadgets have changed
1172 // sizes (like control gadgets). If so, remember the size & relayout the
1173 // gadgets. Also adjust the size of this gadget window to match what we want.
1174 // !CQ should do or is done earlier? Like EvWindowPosChanging??
1175 //
1176 TSize size;
1177 GetDesiredSize(size);
1178
1179// if (DirtyLayout) // !CQ was here in old OWL 5, & Conrad's is here...
1180// LayoutSession();
1181
1182 if ((ShrinkWrapWidth && Attr.W != size.cx) || (ShrinkWrapHeight && Attr.H != size.cy))
1183 {
1184 if (ShrinkWrapWidth)
1185 Attr.W = size.cx;
1186 if (ShrinkWrapHeight)
1187 Attr.H = size.cy;
1188
1189 LayoutSession();
1190 SetWindowPos(nullptr, 0, 0, size.X(), size.Y(),
1192 }
1193
1194 // Create toolips after all other windows have been created.
1195 ///JGD This fixes problem with tooltips and dialog initially showing
1196 ///JGD up behind the main window (BTS 43768)
1197 //
1199}
1200
1201//
1202// Override TWindow's virtual to cleanup potential Timer
1203//
1204void
1206{
1207 // Cleanup pending timer
1208 //
1209 if (TimerID && KillTimer(TimerID)) {
1210 TimerID = 0;
1211 }
1212
1213 if (AtMouse)
1214 {
1215 AtMouse->MouseLeave(0, TPoint(-1, -1));
1216
1217 AtMouse = nullptr; //the window is destroyed => emulating 'mouse move at nowhere'
1218 }
1219
1220 // Chain to base class' version
1221 //
1223}
1224
1225//
1226/// Relays 'interesting' messages to the tooltip window.
1227//
1228bool
1230{
1231 // Check if this message might be worth relaying to the tooltip window
1232 //
1233 if (Tooltip && Tooltip->IsWindow()) {
1234 if (msg.hwnd == *this || IsChild(msg.hwnd)) {
1235 if (msg.message >= WM_MOUSEFIRST && msg.message <= WM_MOUSELAST) {
1236 Tooltip->RelayEvent(msg);
1237 }
1238 }
1239 }
1240
1241 // Always let event go through.
1242 //
1244}
1245
1246//
1247// Create Tooltips for GadgetWindow
1248//
1249void
1251{
1252 // If 'WantTooltip' is enabled, created the control
1253 //
1254 if (WantTooltip)
1255 EnableTooltip(true);
1256
1257 // Inform each gadget that the gadgetwindow is now created. This allows
1258 // gadgets to perform initialization [eg. registering with the tooltip] which
1259 // requires the 'HWND' to be valid
1260 //
1261 for (TGadget* g = Gadgets; g; g = g->NextGadget())
1262 g->Created();
1263
1264}
1265
1266//
1267/// Intercepts window size changes to make sure that this gadget window follows its
1268/// own sizing rules. Also gives it a chance to layout wide-as-possible gadgets.
1269//
1270bool
1272{
1274
1275 // Only process if it is a size change
1276 //
1277 if (!(windowPos.flags&SWP_NOSIZE))
1278 {
1279 // Knowing how big we might be, tile the gadgets to let them get positioned
1280 // the way they want.
1281 //
1282 Attr.W = windowPos.cx;
1283 Attr.H = windowPos.cy;
1284
1285 // Only tile if either we are dirty or have some wide-as-possible gadgets
1286 // to adjust. Dont call LayoutSession() in order to avoid a loop. Derived
1287 // versions might trigger a resize in there.
1288 //
1289 if (DirtyLayout || WideAsPossible)
1291
1292 // Find out how big we really want to be if any shrink wrap, and enforce it
1293 //
1295 if (ShrinkWrapWidth)
1296 windowPos.cx = Attr.W;
1297 if (ShrinkWrapHeight)
1298 windowPos.cy = Attr.H;
1299
1300 // Redraw all if we're using themes (could have background gradients).
1301 //
1302 if (IsBackgroundThemed())
1303 Invalidate(true);
1304 }
1305 return false;
1306}
1307
1308//
1309/// Called by Paint to repaint all of the gadgets, PaintGadgets iterates through the
1310/// list of gadgets, determines the gadget's area, and repaints each gadget.
1311///
1312/// You can override this function to implement a specific look (for example,
1313/// separator line, raised, and so on).
1314//
1315void
1317{
1319 for (TGadget* gadget = Gadgets; gadget; gadget = gadget->Next) {
1320 if (gadget->GetBounds().Touches(rect)) {
1321 dc.SetViewportOrg((TPoint&)gadget->GetBounds());
1322
1323 // If the gadget is a sloppy painter & needs clipping support, set the
1324 // clip rect before painting, otherwise just paint. Most gadgets don't
1325 // need this help
1326 //
1327 if (gadget->Clip) {
1330 dc.IntersectClipRect(gadget->GetBounds());
1331
1332 gadget->Paint(dc);
1333
1335 }
1336 else
1337 gadget->Paint(dc);
1338 }
1339 }
1341}
1342
1343bool
1345{
1346 if (IsBackgroundThemed())
1347 {
1348 TThemePart part(GetHandle(), (LPCWSTR) L"REBAR", 0, 0);
1349 const TRect r = GetClientRect();
1350 part.DrawBackground(dc, r, r);
1351 return true;
1352 }
1353 else
1354 return TWindow::EvEraseBkgnd(dc);
1355}
1356
1357//
1358/// Puts the font into the device context and calls PaintGadgets.
1359///
1360/// Respond to virtual TWindow Paint call. Call our own virtual PaintGadgets
1361/// to actually perform the painting of the gadgets
1362//
1363void
1365{
1366 dc.SelectObject(*Font);
1367 PaintGadgets(dc, erase, rect);
1368
1369#if defined(__TRACE) || defined(__WARN)
1370 // Highlight the tools of this gadgetwindow for debugging purposes.
1371 // Especially useful for docking windows which undergo internal state
1372 // changes
1373 //
1374 TProfile iniFile(_T("Diagnostics"), _T(OWL_INI));
1375
1376 bool useDiagColor = iniFile.GetInt(_T("DiagToolbarBorders")) != 0;
1377
1378 if (useDiagColor && Tooltip && Tooltip->IsWindow()) {
1379 uint count = Tooltip->GetToolCount();
1380 if (count) {
1381 TPen redPen(TColor(0xff, 0, 0));
1382 dc.SelectObject(redPen);
1383
1384 TToolInfo ti;
1385 while (count) {
1386 if (Tooltip->EnumTools(--count, ti)) {
1387 dc.MoveTo(ti.rect.left, ti.rect.top);
1388 dc.LineTo(ti.rect.right,ti.rect.top);
1389 dc.LineTo(ti.rect.right,ti.rect.bottom);
1390 dc.LineTo(ti.rect.left, ti.rect.bottom);
1391 dc.LineTo(ti.rect.left, ti.rect.top);
1392 }
1393 }
1394 dc.RestorePen();
1395 }
1396 }
1397#endif
1398}
1399
1400//
1401/// Responds to a left button-down mouse message by forwarding the event to the
1402/// gadget (if it is enabled) positioned under the mouse.
1403//
1404void
1406{
1407 TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
1408
1409 if (gadget && (gadget->GetEnabled() || Capture)) {
1410 TPoint gadgetPoint = point - *reinterpret_cast<TSize*>(&gadget->GetBounds().TopLeft());
1411 gadget->LButtonDown(modKeys, gadgetPoint);
1412 }
1413
1415}
1416
1417//
1418/// Responds to a left button-up mouse message by forwarding the event to the gadget
1419/// that has the capture or to the gadget positioned under the mouse
1420//
1421void
1423{
1424 TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
1425
1426 if (gadget && (gadget->GetEnabled() || Capture)){
1427 TPoint p(point.x - gadget->GetBounds().left, point.y - gadget->GetBounds().top);
1428 gadget->LButtonUp(modKeys, p);
1429 }
1431}
1432
1433//
1434/// Passes double clicks through as if they were just a second click; finishes the
1435/// first click, and begins the second: Dn + Dbl + Up -> Dn + Up+Dn + Up.
1436//
1437void
1443
1444//
1445/// Pass RButton messages to the gadget at the mouse location or the one
1446/// with Capture
1447///
1448/// \note The default right-mouse down handler of TGadget does
1449/// *NOT* set capture
1450//
1451void
1453{
1454 TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
1455
1456 if (gadget && (gadget->GetEnabled() || Capture)) {
1457 TPoint gadgetPoint = point - *reinterpret_cast<TSize*>(&gadget->GetBounds().TopLeft());
1458 gadget->RButtonDown(modKeys, gadgetPoint);
1459 }
1460
1462}
1463
1464//
1465/// Pass RButton messages to the gadget at the mouse location or the one with
1466/// capture.
1467///
1468/// \note The default right-mouse down handler of TGadget does
1469/// *NOT* set capture
1470//
1471void
1473{
1474 TGadget* gadget = Capture ? Capture : GadgetFromPoint(point);
1475
1476 if (gadget && (gadget->GetEnabled() || Capture)){
1477 TPoint p(point.x - gadget->GetBounds().left, point.y - gadget->GetBounds().top);
1478 gadget->RButtonUp(modKeys, p);
1479 }
1481}
1482
1483//
1484/// Forward mouse moves to the gadget that has captured the mouse, if any. Otherwise
1485/// checks for mouse entering and leaving gadgets. This could be enhanced by
1486/// delaying mouse enter messages until the mouse has been in the same area for a
1487/// while, or by looking ahead in the queue for mouse messages.
1488//
1489void
1491{
1492 struct Local
1493 {
1494 typedef void (TGadget::*MouseFun)(uint, const TPoint&);
1495 static void Notify(TGadget* g, MouseFun f, uint modKeys, TPoint p)
1496 {
1497 if (!g) return;
1498 p -= g->GetBounds().TopLeft(); // Convert to local coo.
1499 (g->*f)(modKeys, p);
1500 }
1501 };
1502
1503 if (Capture)
1504 Local::Notify(Capture, &TGadget::MouseMove, modKeys, point);
1505 else
1506 {
1508 if (gadget != AtMouse)
1509 {
1510 Local::Notify(AtMouse, &TGadget::MouseLeave, modKeys, point);
1511 AtMouse = gadget;
1512 Local::Notify(AtMouse, &TGadget::MouseEnter, modKeys, point);
1513 }
1514 }
1516}
1517
1518//
1519//
1520//
1521void
1523{
1524 if (!Tooltip) {
1525
1526 // Find a parent for the tooltip: It's attractive to make the
1527 // gadgetwindow the owner of the tooltip, a popup window. However, this
1528 // will typically fail since the gadget window is invariably a child
1529 // window. Windows seems to accomodate this situation by simply making
1530 // the tooltip's owner the gadgetwindow's owner. This works fine until
1531 // the owner of the gadgetwindow is destroyed before the gadgetwindow
1532 // is destroyed, such as in the case of a gadgetwindow initally created
1533 // as a floating docking toolbar; When it's docked, the floating slip,
1534 // it's original owner, is destroyed and the gadget window is reparented
1535 // to an edge slip. In this scenario, the tooltip is silently destroyed
1536 // along with the floating slip [it's real owner!] and the docked
1537 // gadgetwindow no longer provide tool tips!
1538 //
1539
1540 // To circumvent this scenario, we'll look for a window which is fairly
1541 // stable/rooted as owner of the tooltip. Ideally, we'll get the
1542 // application's main window.
1543 //
1544 TWindow* tipParent = this;
1545 while (tipParent->GetParentO()) {
1546 tipParent = tipParent->GetParentO();
1547 if (tipParent->IsFlagSet(wfMainWindow))
1548 break;
1549 }
1550
1551 // Create and initialize tooltip
1552 //
1554 }
1555 else {
1556 if (Tooltip->GetHandle())
1557 Tooltip->Activate(enable);
1558 }
1559}
1560
1561//
1562/// Sets the Tooltip data member equal to tooltip. If the tooltip is invalid (if
1563/// Tooltip->GetHandle() fails), a new tooltip is created by the TTooltip::Create()
1564/// function.
1565//
1566void
1568{
1569 // Cleanup; via Condemned list if tooltip was created
1570 //
1571 if (Tooltip) {
1572 if (Tooltip->GetHandle())
1573 Tooltip->SendMessage(WM_CLOSE);
1574 else
1575 delete Tooltip;
1576 }
1577
1578 // Store new tooltip and create if necessary
1579 //
1580 Tooltip = tooltip;
1581 if (Tooltip) {
1582 if(GetHandle() && !Tooltip->GetHandle()) {
1583 // Make sure tooltip is disabled so it does not take input focus
1584 Tooltip->ModifyStyle(0,WS_DISABLED);
1585 Tooltip->Create();
1586 }
1587 }
1588}
1589
1590//
1591/// When the gadget window receives a WM_COMMAND message, it is likely from a gadget
1592/// or control within a TControlGadget. This reroutes it to the command target.
1593//
1594TResult
1596{
1597 TRACEX(OwlCmd, 1, "TGadgetWindow::EvCommand - id(" << id << "), ctl("
1598 << static_cast<void*>(hWndCtl) << "), code(" << notifyCode << ")");
1599
1600 // First allow any derived class that wants to handle the command
1601 // NOTE: This search only caters for menu-style WM_COMMANDs (not those
1602 // sent by controls)
1603 //
1604 TEventInfo eventInfo(0, id);
1605 if (Find(eventInfo)) {
1606 Dispatch(eventInfo, id);
1607 return 0;
1608 }
1609
1610
1611#if 0
1612 // Prior versions of TGadgetWindow relied on TWindow's EvCommand for
1613 // dispatching WM_COMMAND events. This required that one derives from
1614 // a decoration class (eg. TControlbar, TToolbox) to handle control
1615 // notifications. The current version uses a more generalized logic
1616 // involving the CommandTarget and a frame ancestor class. This allows
1617 // a client window to handle notifications of a control in a toolbar
1618 // without using a TControlbar-derived class.
1619 // However, if you need to previous behaviour, simply invoke TWindow's
1620 // EvCommand from this handler.
1621
1623#endif
1624
1625 TWindow* target;
1626 TFrameWindow* frame;
1627
1628 // Find the frame who is our latest ancestor and make it our command target
1629 //
1630 for (target = GetParentO(); target; target = target->GetParentO()) {
1632 if (frame || !target->GetParentO())
1633 break;
1634 }
1635
1636 // Make sure the frame doesn't think we are its command target, or a BAD
1637 // loop will happen
1638 //
1639 if (target && (!frame || frame->GetCommandTarget() != GetHandle())) {
1640 CHECK(target->IsWindow());
1641 return target->EvCommand(id, hWndCtl, notifyCode);
1642 }
1643
1644 // If all command routing fails, go back to basic dispatching of TWindow
1645 //
1647}
1648
1649//
1650/// When the gadget window receives a WM_COMMAND_ENABLE message, it is likely from a
1651/// gadget or control within a TControlGadget. This reroutes it to the command
1652/// target.
1653//
1654void
1656{
1657 // If someone derived from TGadgetWindow and handles the command there,
1658 // give these handlers the first crack.
1659 //
1661 if (Find(eventInfo)) {
1663 return;
1664 }
1665
1667
1668 // Forward to command target if the enabler was really destined for us, and
1669 // not a routing from the frame.
1670 //
1671 if (target && ce.IsReceiver(*this)) {
1672 CHECK(target->IsWindow());
1673 ce.SetReceiver(*target);
1674 target->EvCommandEnable(ce);
1675 if( ce.GetHandled() )
1676 return;
1677 }
1678
1679 // Default to TWindow's implementation if the above routing fails
1680 //
1682}
1683
1684//----------------------------------------------------------------------------
1685//
1686//
1687/// Constructs a control out of a gadget.
1688//
1691 TFont* font,
1692 TModule* module)
1693:
1694 TGadgetWindow(parent, Horizontal, font, module)
1695{
1696 // Let Attr rect override
1697 //
1698 SetShrinkWrap(false, false);
1699
1700 // Let inner gadget paint everything
1701 //
1702 TMargins mar(TMargins::Pixels, 0, 0, 0, 0);
1703 SetMargins(mar);
1704
1705 if (soleGadget)
1707}
1708
1709} // OWL namespace
1710/* ========================================================================== */
1711
Definition of a bitmap Cel array class.
#define CHECK(condition)
Definition checks.h:239
#define PRECONDITION(condition)
Definition checks.h:227
#define DIAG_DECLARE_GROUP(group)
Definition checks.h:404
#define TRACEX(group, level, message)
Definition checks.h:263
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
Definition checks.h:429
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
Definition celarray.h:35
Class wrapper for management of color values.
Definition color.h:245
static const TColor Sys3dFace
The symbolic system color value for the face color of 3-dimensional display elements.
Definition color.h:339
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
TDC is the root class for GDI DC wrappers.
Definition dc.h:64
virtual bool SetViewportOrg(const TPoint &origin, TPoint *oldOrg=nullptr)
Sets this DC's viewport origin to the given origin value, and saves the previous origin in oldOrg.
Definition dc.cpp:444
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
virtual int GetDeviceCaps(int index) const
Used under WIN3.1 or later, GetDeviceCaps returns capability information about this DC.
Definition dc.cpp:373
bool GetViewportOrg(TPoint &point) const
The first version sets in the point argument the x- and y-extents (in device-units) of this DC's view...
Definition dc.h:1303
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
Definition dc.cpp:113
void RestorePen()
Restores the original GDI pen object to this DC.
Definition dc.cpp:220
int IntersectClipRect(const TRect &rect)
Creates a new clipping region for this DC's window by forming the intersection of the current region ...
Definition dc.h:1506
int SelectClipRgn(const TRegion &region)
Selects the given region as the current clipping region for this DC.
Definition dc.h:1533
int GetClipRgn(TRegion &region) const
Retrieves this DC's current clip-region and, if successful, places a copy of it in the region argumen...
Definition dc.h:1608
bool LineTo(int x, int y)
Draws a line on this DC using the current pen object.
Definition dc.h:2148
TDecoratedFrame automatically positions its client window (you must supply a client window) so that i...
Definition decframe.h:74
Encapsulates the system font used for a specific GUI element, e.g. icon, caption, menu,...
Definition gdiobjec.h:380
A nested class, TEventInfo provides specific information about the type of message sent,...
Definition eventhan.h:170
virtual bool Find(TEventInfo &info, TEqualOperator op=0)
Searches the list of response table entries looking for a match.
Definition eventhan.cpp:371
TResult Dispatch(TEventInfo &info, TParam1, TParam2=0)
Takes the message data from TEventInfo's Msg data member and dispatches it to the correct event-handl...
Definition eventhan.cpp:396
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
LOGFONT GetObject() const
Returns information about this font object.
Definition font.cpp:238
TEXTMETRIC GetTextMetrics(TDC &dc) const
Retrieves information about this font when selected in the specified dc.
Definition font.cpp:161
Derived from TWindow, TFrameWindow controls such window-specific behavior as keyboard navigation and ...
Definition framewin.h:96
virtual HWND GetCommandTarget()
Locates and returns the child window that is the target of the command and command enable messages.
Definition framewin.cpp:328
TGadgetControl(TWindow *parent=nullptr, TGadget *soleGadget=nullptr, TFont *font=nullptr, TModule *module=nullptr)
Constructs a control out of a gadget.
TGadget is the base class for the following derived gadget classes:
Definition gadget.h:120
virtual void MouseMove(uint modKeys, const TPoint &point)
Mouse is moving over this gadget.
Definition gadget.cpp:557
virtual void MouseEnter(uint modKeys, const TPoint &point)
Mouse is entering this gadget.
Definition gadget.cpp:542
virtual void MouseLeave(uint modKeys, const TPoint &point)
Mouse is leaving this gadget.
Definition gadget.cpp:566
@ Plain
Plain window frame.
Definition gadget.h:129
TGadgetList is a list of gadgets with management functions.
Definition gadgetwi.h:35
TPlacement
Enumerates the placement of a gadget.
Definition gadgetwi.h:47
TGadget * GadgetFromPoint(const TPoint &point) const
Returns the gadget that a given window-relative point is in, or 0 if none is found.
Definition gadgetli.cpp:42
virtual void Insert(TGadget &gadget, TPlacement=After, TGadget *sibling=nullptr)
Inserts a Gadget.
Definition gadgetli.cpp:89
virtual void InsertFrom(TGadgetList &list, TPlacement=After, TGadget *sibling=nullptr)
Inserts a list of gadgets.
Definition gadgetli.cpp:125
virtual TGadget * Remove(TGadget &gadget)
Removes (unlinks) a gadget.
Definition gadgetli.cpp:172
Gadget layout information used during the layout process.
Definition gadgetwi.h:272
Derived from TFont, TGadgetWindowFont is the default font used by TGadgetWindow.
Definition gadgetwi.h:92
TGadgetWindowFont()
Constructs a font based on TDefaultGuiFont.
Definition gadgetwi.cpp:79
Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a window and lets you dynam...
Definition gadgetwi.h:122
auto IdleAction(long idleCount) -> bool override
During idle time, iterates over the Gadgets invoking their CommandEnable() member function.
Definition gadgetwi.cpp:191
void EnableThemeBackground(bool enable=true)
Definition gadgetwi.cpp:514
virtual void PaintGadgets(TDC &dc, bool erase, TRect &rect)
Called by Paint to repaint all of the gadgets, PaintGadgets iterates through the list of gadgets,...
bool IsBackgroundThemed() const
Definition gadgetwi.cpp:532
~TGadgetWindow() override
Destructs this gadget window.
Definition gadgetwi.cpp:166
void Insert(TGadget &, TPlacement=After, TGadget *sibling=nullptr) override
Inserts a gadget before or after a sibling gadget (TPlacement).
void EnableTooltip(bool enable=true) override
int LayoutUnitsToPixels(int units)
Converts layout units to pixels.
Definition gadgetwi.cpp:343
void SetHintCommand(int id)
(id <= 0) to clear
Definition gadgetwi.cpp:299
void EvMouseMove(uint modKeys, const TPoint &point)
Forward mouse moves to the gadget that has captured the mouse, if any.
friend class TGadget
Definition gadgetwi.h:361
void SetupWindow() override
Overrides TWindow::SetupWindow to create tooltips for the gadget window.
auto Create() -> bool override
Overrides TWindow member function and chooses the initial size of the gadget if shrink-wrapping was r...
Definition gadgetwi.cpp:429
bool EvWindowPosChanging(WINDOWPOS &windowPos)
Intercepts window size changes to make sure that this gadget window follows its own sizing rules.
bool EnableTimer()
Inform GadgetWindow to start a Timer notification.
Definition gadgetwi.cpp:226
@ FlatDefault
System automatically select apropriated style.
Definition gadgetwi.h:199
@ FlatXPTheme
Windows XP theme styles.
Definition gadgetwi.h:198
@ FlatGrayButtons
Adds Gray buttons effect to FlatStandard.
Definition gadgetwi.h:195
@ FlatSingleDiv
Adds single divider ala IE 4.01.
Definition gadgetwi.h:197
@ FlatHotText
Adds hot text effect like.
Definition gadgetwi.h:196
@ FlatStandard
Flat style IE 3.0 - base style.
Definition gadgetwi.h:194
void EvRButtonUp(uint modKeys, const TPoint &point)
Pass RButton messages to the gadget at the mouse location or the one with capture.
void Inserted(TGadget &) override
A gadget has been inserted into this gadget window.
void CleanupWindow() override
virtual TRect TileGadgets()
Tiles the Gadgets in the current direction.
Definition gadgetwi.cpp:618
void EvSysColorChange()
Responds to WM_SYSCOLORCHANGE to let the gadgets update their UI colors, and to let this gadget windo...
Definition gadgetwi.cpp:180
void SetMargins(const TMargins &margins)
Sets or changes the margins for the gadget window and calls LayoutSession().
Definition gadgetwi.cpp:332
void EvLButtonDown(uint modKeys, const TPoint &point)
Responds to a left button-down mouse message by forwarding the event to the gadget (if it is enabled)...
void UseDesiredSize()
Updates the Size in Attr.W and Attr.H to match that obtained using GetDesiredSize() for each dimensio...
Definition gadgetwi.cpp:411
virtual void SetCelArray(TCelArray *sharedCels)
Sets a new Shared CelArray for this gadget window.
void EvCommandEnable(TCommandEnabler &) override
When the gadget window receives a WM_COMMAND_ENABLE message, it is likely from a gadget or control wi...
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
When the gadget window receives a WM_COMMAND message, it is likely from a gadget or control within a ...
void SetTooltip(TTooltip *tooltip)
Sets the Tooltip data member equal to tooltip.
void EvLButtonUp(uint modKeys, const TPoint &point)
Responds to a left button-up mouse message by forwarding the event to the gadget that has the capture...
void GadgetChangedSize(TGadget &gadget)
Used to notify the gadget window that a gadget has changed its size, GadgetChangedSize calls LayoutSe...
auto Remove(TGadget &) -> TGadget *override
Removes a gadget from the gadget window.
TMargins & GetMargins()
Definition gadgetwi.h:481
bool GadgetSetCapture(TGadget &gadget)
Called by a gadget that wants to capture the mouse.
Definition gadgetwi.cpp:268
virtual void GetDesiredSize(TSize &size)
Get the desired size for this gadget window by performing a trial layout of the gadgets without touch...
Definition gadgetwi.cpp:380
static void EnableFlatStyle(uint style=FlatDefault)
Set flat style options, or disable it.
Definition gadgetwi.cpp:489
virtual void GetInnerRect(TRect &rect)
GetInnerRect computes the rectangle inside of the borders and margins of the gadget.
Definition gadgetwi.cpp:564
bool EvEraseBkgnd(HDC)
void SetRectangularDimensions(int width, int height, int rowMargin=-1)
Sets the maximum width for each row used for rectangular layout.
Definition gadgetwi.cpp:542
void SetShrinkWrap(bool shrinkWrapWidth, bool shrinkWrapHeight)
Sets the width and height of the data members.
Definition gadgetwi.cpp:250
bool IsThemeBackgroundEnabled() const
Definition gadgetwi.cpp:523
void InsertFrom(TGadgetList &, TPlacement=After, TGadget *sibling=nullptr) override
Inserts a list of Gadgets.
void Removed(TGadget &) override
This indicates that a gadget has been removed from this gadget window.
void EvRButtonDown(uint modKeys, const TPoint &point)
Pass RButton messages to the gadget at the mouse location or the one with Capture.
void EvLButtonDblClk(uint modKeys, const TPoint &point)
Passes double clicks through as if they were just a second click; finishes the first click,...
virtual TCelArray & GetCelArray(int minX=0, int minY=0)
Gets the Shared CelArray for this gadget window.
TGadgetWindow(TWindow *parent=nullptr, TTileDirection direction=Horizontal, TFont *font=nullptr, TModule *module=nullptr)
Creates a TGadgetWindow interface object with the default tile direction and font and passes module w...
Definition gadgetwi.cpp:98
bool PreProcessMsg(MSG &msg) override
Relays 'interesting' messages to the tooltip window.
virtual void PositionGadget(TGadget *previous, TGadget *next, TPoint &point)
Virtual called by TileGadgets() for each gadget in order to give derived classes a chance to modify t...
Definition gadgetwi.cpp:597
virtual void SetDirection(TTileDirection direction)
Sets the horizontal or vertical orientation of the gadgets.
Definition gadgetwi.cpp:449
bool IsThemed() const
Definition gadgetwi.cpp:505
virtual void LayoutSession()
LayoutSession is typically called when a change occurs in the size of the margins or gadgets,...
Definition gadgetwi.cpp:357
TTileDirection
Enumeration describing how gadgets should be laid out within the gadget window.
Definition gadgetwi.h:130
@ Vertical
Arrange gadgets in a column.
Definition gadgetwi.h:132
@ Rectangular
Arrange gadgets in rows and columns (2-D grid)
Definition gadgetwi.h:133
@ Horizontal
Arrange gadgets in a row.
Definition gadgetwi.h:131
void GadgetReleaseCapture(TGadget &gadget)
Releases the capture so that other windows can receive mouse messages.
Definition gadgetwi.cpp:286
@ PressHints
Hints when a button is pressed.
Definition gadgetwi.h:184
virtual void LayoutGadgets(TTileDirection dir, TLayoutInfo &layout)
Calculate the layout of the Gadgets in a given direction.
Definition gadgetwi.cpp:988
void Paint(TDC &, bool erase, TRect &) override
Puts the font into the device context and calls PaintGadgets.
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TPen is derived from TGdiObject.
Definition gdiobjec.h:138
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
An instance of TProfile encapsulates a setting within a system file, often referred to as a profile o...
Definition profile.h:44
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
TRegion, derived from TGdiObject, represents GDI abstract shapes or regions.
Definition gdiobjec.h:581
Derived from TWindowDC, TScreenDC is a DC class that provides direct access to the screen bitmap.
Definition dc.h:610
The tagSIZE struct is defined as.
Definition geometry.h:234
int Y() const
Returns the height.
Definition geometry.h:1478
int X() const
Returns the width.
Definition geometry.h:1469
static TThemeModule & GetInstance()
Returns the module instance.
Definition theme.cpp:91
Encapsulates a themed part.
Definition theme.h:126
TToolInfo contains information about a particular tool (a tool is either a window or an application-d...
Definition tooltip.h:35
TTooltip encapsulates a tooltip window - i.e.
Definition tooltip.h:175
uint GetToolCount() const
Returns the number of tools currently registered with the tooltip control.
Definition tooltip.h:459
bool EnumTools(uint index, TToolInfo &) const
Retrieves the information that the tooltip control maintains about the specified tool.
Definition tooltip.h:428
void RelayEvent(MSG &)
Passes a mouse message to the tooltip control for processing.
Definition tooltip.h:524
void Activate(bool activate=true)
Set state of tooltip.
Definition tooltip.h:394
static const TUIMetric CyBorder
Definition uimetric.h:40
static const TUIMetric CxBorder
Definition uimetric.h:39
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
bool EvEraseBkgnd(HDC)
Handler for WM_ERASEBKGND.
Definition window.cpp:1924
static TPoint GetCursorPos()
Definition window.h:1212
HWND SetCapture()
Sets the mouse capture to the current window.
Definition window.h:2121
void EvLButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_LBUTTONUP.
Definition window.h:3792
bool KillTimer(UINT_PTR timerId)
Gets rid of the timer and removes any WM_TIMER messages from the message queue.
Definition window.h:3325
bool EvWindowPosChanging(WINDOWPOS &)
The default message handler for WM_WINDOWPOSCHANGING.
Definition window.h:4212
void SetBkgndColor(TColor color, bool shouldUpdate=true)
Sets the background color for the window.
Definition window.h:1925
void EvRButtonDown(uint modKeys, const TPoint &point)
The default message handler for WM_RBUTTONDOWN.
Definition window.h:4070
static HWND WindowFromPoint(const TPoint &point)
Returns the handle of the window in which the specified point (point) lies.
Definition window.h:2227
bool SetWindowPos(HWND hWndInsertAfter, const TRect &rect, uint flags)
Changes the size of the window pointed to by rect.
Definition window.h:2809
virtual void EvCommandEnable(TCommandEnabler &ce)
Called by WindowProc to handle WM_COMMAND_ENABLE messages, EvCommandEnable calls the CmXxxx command-h...
Definition window.cpp:1135
virtual bool PreProcessMsg(MSG &msg)
Called from TApplication::ProcessAppMsg() to give the window an opportunity to perform preprocessing ...
Definition window.cpp:644
virtual bool Create()
Creates the window interface element to be associated with this ObjectWindows interface element.
Definition window.cpp:2399
virtual void InvalidateRect(const TRect &rect, bool erase=true)
Invalidates a specified client area.
Definition window.h:2834
void Init(TWindow *parent, LPCTSTR title, TModule *module)
Normal initialization of a default constructed TWindow.
Definition window.cpp:401
void EvRButtonUp(uint modKeys, const TPoint &point)
The default message handler for WM_RBUTTONUP.
Definition window.h:4077
TWindow * GetParentO() const
Return the OWL's parent for this window.
Definition window.h:2006
static void ReleaseCapture()
Releases the mouse capture from this window.
Definition window.h:2130
bool IsWindow() const
Returns true if an HWND is being used.
Definition window.h:2040
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
virtual void CleanupWindow()
Always called immediately before the HWindow becomes invalid, CleanupWindow gives derived classes an ...
Definition window.cpp:2640
TResult HandleMessage(TMsgId, TParam1=0, TParam2=0)
Dispatches the given message using the response table.
Definition window.cpp:1392
void EvLButtonDown(uint modKeys, const TPoint &point)
Response method for an incoming WM_LBUTTONDOWN message.
Definition window.cpp:2101
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
Definition window.cpp:3591
virtual bool IdleAction(long idleCount)
Called when no messages are waiting to be processed, IdleAction performs idle processing as long as t...
Definition window.cpp:671
TRect GetClientRect() const
Gets the coordinates of the window's client area (the area in a window you can use for drawing).
Definition window.h:2217
UINT_PTR SetTimer(UINT_PTR timerId, uint timeout, TIMERPROC proc=0)
Creates a timer object associated with this window.
Definition window.h:3339
virtual TResult EvCommand(uint id, HWND hWndCtl, uint notifyCode)
WindowProc calls EvCommand to handle WM_COMMAND messages.
Definition window.cpp:999
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
virtual void SetupWindow()
Performs setup following creation of an associated MS-Windows window.
Definition window.cpp:2575
virtual void Invalidate(bool erase=true)
Invalidates (mark for painting) the entire client area of a window.
Definition window.h:2822
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
Definition of classes for CommonControl encapsulation.
#define _T(x)
Definition cygwin.h:51
Definition of class TDecoratedFrame, a TFrameWindow that can manage decorations around the client win...
#define WM_COMMAND_ENABLE
Definition dispatch.h:4103
#define WM_OWLCREATETTIP
Notify gadget window to create tooltips.
Definition dispatch.h:4117
#define DEFINE_RESPONSE_TABLE1(cls, base)
Macro to define a response table for a class with one base.
Definition eventhan.h:492
Definition of class TFrameWindow.
Base class TGadget and simple derived TSeparatorGadget.
Definition of TGadgetList, TGadgetWindow & TGadgetWindowFont A list holding gadgets,...
@ wfMainWindow
This frame window is the main window.
Definition window.h:63
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
EV_WM_LBUTTONUP
Definition docking.cpp:2056
const uint GadgetWindowTimerID
Definition gadgetwi.cpp:41
EV_WM_LBUTTONDBLCLK
Definition docking.cpp:962
EV_WM_MOUSEMOVE
Definition docking.cpp:2054
EV_WM_RBUTTONDOWN
Definition gadgetwi.cpp:49
LPARAM TParam2
Second parameter type.
Definition dispatch.h:55
auto GetCommCtrlVersion() -> DWORD
Returns the version number of the Common Control library (ComCtl32.dll).
Definition commctrl.cpp:26
TParam2 MkParam2(const T1 &lo, const T2 &hi)
Definition dispatch.h:65
OWL_DIAGINFO
Definition animctrl.cpp:14
EV_WM_WINDOWPOSCHANGING
Definition docking.cpp:545
END_RESPONSE_TABLE
Definition button.cpp:26
LRESULT TResult
Result type.
Definition dispatch.h:52
EV_WM_RBUTTONUP
Definition gadgetwi.cpp:50
unsigned int uint
Definition number.h:25
const uint GadgetWindowTimeOut
Definition gadgetwi.cpp:42
EV_WM_LBUTTONDOWN
Definition checklst.cpp:195
EV_WM_SYSCOLORCHANGE
Definition gadgetwi.cpp:53
EV_WM_ERASEBKGND
Definition docking.cpp:965
EV_WM_CREATETOOLTIP
Definition gadgetwi.cpp:54
#define OWL_INI
Definition defs.h:170
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
Definition of TProfile class.
Used by the TGadgetWindow and TGadget classes, TMargins contains the measurements of the margins for ...
Definition gadget.h:54
Microsoft UxTheme Library Encapsulation.
Definition of the TTooltip class and helper objects.
Definition of TUIMetric, a UI metrics provider class.