OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
decframe.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 class TDecoratedFrame
7//----------------------------------------------------------------------------
8#include <owl/pch.h>
9
10#include <owl/decframe.h>
11#include <owl/messageb.h>
12#include <owl/tooltip.h>
13#include <owl/controlb.h>
14#include <owl/functor.h>
15#include <owl/bardescr.h>
16#include <algorithm>
17
18#if defined(__BORLANDC__)
19# pragma option -w-ccc // Disable "Condition is always true/false"
20#endif
21
22using namespace std;
23
24namespace owl {
25
27DIAG_DECLARE_GROUP(OwlWin); // diagnostic group for windows
28DIAG_DECLARE_GROUP(OwlCmd); // diagnostic group for commands
29
30
36
38
39//
40//
41//
42static TGadgetWindow* CreateToolBar(TWindow* wnd)
43{
44 return new TControlBar(wnd);
45}
46
48{
49 if(frame.GetHandle())
50 destWindow.Create();
52 return true;
53}
54
55//
56/// Constructs a TDecoratedFrame object with the specified parent window (parent),
57/// window caption (title), and module ID. Sets TWindow::Attr.Title to the new
58/// title. Passes a pointer to the client window if one is specified. By default set
59/// to false, trackMenuSelection controls whether hint text appears at the bottom of
60/// the window when a menu item is highlighted.
61//
66 TModule* module)
67:
68 TLayoutWindow(parent, title, module)
69{
70 Init(parent, title, clientWnd, trackMenuSelection, module);
71}
72
73//
74/// String-aware overload
75//
77 : TLayoutWindow(parent, title, module)
78{
79 Init(parent, title.c_str(), client, trackMenuSelection, module);
80}
81
82//
83/// Initialization shared by the constructors
84//
86{
87 // Initialize virtual bases, in case the derived-most used default ctor
88 //
89 TWindow::Init(parent, title, module);
91
93
94 TrackMenuSelection = trackMenuSelection;
95 MenuItemId = 0;
96 SettingClient = false;
97 BarCreatorFunct = new TGadgetWndFunctor;
98 BarInserterFunct = new TBarInsertFunctor;
99 SetBarCreator(TGadgetWnd_FUNCTOR(CreateToolBar));
101
102
103 if (!ClientWnd)
104 ClientWnd = new TWindow(this, _T("\007")); // create dummy placeholder
105
106 if (ClientWnd->GetWindowAttr().Style & WS_BORDER) {
107 metrics.X.SameAs(lmParent, lmLeft);
108 metrics.Y.SameAs(lmParent, lmTop);
109 metrics.Width.SameAs(lmParent, lmRight);
110 metrics.Height.SameAs(lmParent, lmBottom);
111 }
112 else {
117 }
118
119 SetChildLayoutMetrics(*ClientWnd, metrics);
120}
121
122//
123//
124//
126{
127 delete BarCreatorFunct;
128 delete BarInserterFunct;
129}
130//
131//
132//
134{
135 *BarCreatorFunct = funct;
136}
137//
138//
140{
141 *BarInserterFunct = funct;
142}
143//
144/// Override SetupWindow in order to layout & position decorations
145/// Calls TLayoutWindow::Layout to size and position the decoration.
146//
147void
149{
151
152 // Size/position child windows. Don't wait until we get the WM_SIZE event
153 // because by then the windows will have been displayed on the screen
154 //
156
157 ClientSize.cx = clientRect.right;
158 ClientSize.cy = clientRect.bottom;
159
161 CreateBar();
162 Layout();
163}
164
165//
166//
167//
168void
170{
172
173 if (!GetBarDescr())
174 return;
176 if(toolBar) // already created
177 ((TBarDescr*)GetBarDescr())->RemoveGadgets(*toolBar);
178}
179
180//
181/// Overrides TFrameWindows virtual function. Sets the client window to the
182/// specified window. Users are responsible for destroying the old client window if
183/// they want to remove it.
184//
185/// Handle SetClientWindow() here to manage fixing up the layout metrics of
186/// all the children before & after the client is changed.
187//
188TWindow*
190{
192 GetChildLayoutMetrics(*ClientWnd, metrics);
193 if (!clientWnd)
194 clientWnd = new TWindow(this, _T("\007")); // create dummy placeholder
195
196 clientWnd->SetParent(this);
198
200
201 // Make sure that all child metrics that were based on the old client window
202 // get updated to the new client
203 //
205 if (first) {
207 do {
209 if (metrics.X.RelWin == oldWnd)
210 metrics.X.RelWin = clientWnd;
211 if (metrics.Y.RelWin == oldWnd)
212 metrics.Y.RelWin = clientWnd;
213 if (metrics.Width.RelWin == oldWnd)
214 metrics.Width.RelWin = clientWnd;
215 if (metrics.Height.RelWin == oldWnd)
216 metrics.Height.RelWin = clientWnd;
218 }
219 child = child->Next();
220 } while (child != first);
221 }
222
223 // Now let the TFrameWindow set the client. Then delete the old client if it
224 // was our temporary place holder. Set a flag while the client is being set
225 // so that RemoveChild() below knows that we are taking care of things.
226 //
227 SettingClient = true;
229 SettingClient = false;
230
231 if (oldWnd->GetCaption() && oldWnd->GetCaption()[0] == 007) {
232 oldWnd->Destroy();
233 delete oldWnd;
234 oldWnd = nullptr;
235 }
236
237 // Relayout the children to get the new client sized right
238 //
239 Layout();
240
241 return oldWnd;
242}
243
244//
245/// Makes sure that both bases get a chance to see the child removed. TWindow's will
246/// be called twice, but the second call will be ignored. If the client is being
247/// removed and the client is not currently being set, then this function calls
248/// SetClientWindow to put in a placeholder.
249//
250void
252{
253 if (child == ClientWnd && !SettingClient)
254 SetClientWindow(nullptr);
257}
258
259//
260/// Give the decorations an opportunity to do pre-processing. Don't bother
261/// checking the client window since it is typically in the focus chain and
262/// will be given an opportunity to do pre-processing
263//
264bool
266{
268
269 if (firstChild) {
271
272 do {
273 if (child != ClientWnd && child->GetHandle() &&
274 (child->GetWindowLong(GWL_STYLE) & WS_VISIBLE) &&
275 child->PreProcessMsg(msg))
276 return true;
277
278 child = child->Next();
279 } while (child != firstChild);
280 }
281
283}
284
285//
286/// Retrieves the text specified by the resource id.
287/// If hintType equals htToolTip, GetHintText first searches for
288/// id in the menu strings. If the id cannot be found in the menu strings,
289/// GetHintText looks for the id in the resource strings. If hintType equal
290/// htStatus, GetHintText looks for the id in the module's resource strings.
291//
294{
295 if (id == static_cast<uint>(-1))
296 return tstring();
297
298 tchar buf[4096];
299 const int size = COUNTOF(buf);
300 if (hintType == htTooltip)
301 {
302 // For tooltips, we first look if the same id exists on the
303 // window's menu and use the associated menu string.
304 //
305 if (::IsMenu(GetMenu()) &&
306 TUser::GetMenuString(GetMenu(), id, &buf[0], size, MF_BYCOMMAND))
307 {
308 // Trim accelerator text e.g., '\tCtrl+X' (if any)
309 //
310 LPTSTR c = _tcschr(buf, _T('\t'));
311 if (c)
312 *c = 0;
313
314 // Accelerator can be \b instead of \t (NOTE: \a in .rc make a \b
315 // in res)
316 //
317 c = _tcschr(buf, _T('\b'));
318 if (c)
319 *c = 0;
320
321 // Trim trailing dots, e.g., '...' (if any)
322 //
323 int i;
324 for (i = static_cast<int>(::_tcslen(buf)) - 1; i >= 0; i--)
325 if (buf[i] == _T('.'))
326 buf[i] = 0;
327 else
328 break;
329
330#if defined(BI_DBCS_SUPPORT)
331 // Trim trailing access key, e.g., '(&N)' (if any)
332 //
333 if (i >= 3 && buf[i-3] == '(' && buf[i-2] == '&' && buf[i] == ')')
334 buf[i-3] = 0;
335#endif
336 // Eliminate '&' (just emliminate first one)
337 //
338 i = -1;
339 while(buf[++i])
340 if (buf[i] == _T('&')) {
341 do {
342 buf[i] = buf[i+1];
343 i++;
344 } while (buf[i]);
345 break;
346 }
347 return tstring(&buf[0]);
348 }
349 else
350 {
351 // If the tip text cannot be retrieved from the menu, we then look
352 // for a string resource - The resource is expected to contain a
353 // longer status text followed by a '\n' and the tip text.
354 //
355 tchar resStr[256];
356 int len = GetModule()->LoadString(id, resStr, 256);
357 if (len == 0 && MergeModule != nullptr)
358 len = MergeModule->LoadString(id, resStr, 256);
359
360 WARNX(OwlWin, len == 0, 0,
361 _T("TDecoratedFrame::GetHintText LoadString(")
362 << *GetModule() << _T(",") << id << _T(") Failed"));
363
364 LPTSTR pLF;
365 if (len && (pLF = _tcschr(resStr, _T('\n'))) != nullptr)
366 {
367 return tstring(pLF + 1);
368 }
369 }
370 }
371
372 if (hintType == htStatus) {
373 int numBytes = GetModule()->LoadString(id, buf, size);
374 if (numBytes == 0 && MergeModule != nullptr)
375 numBytes = MergeModule->LoadString(id, buf, size);
376
377 WARNX(OwlWin, numBytes == 0, 0,
378 _T("TDecoratedFrame::GetHintText LoadString(")
379 << *GetModule() << _T(",") << id << _T(") Failed"));
380
381 if (numBytes)
382 {
383 // Clear beyond the '\n' in case this string resource contains both
384 // a status and a tooltip hint text.
385 //
386 LPTSTR pLF = _tcschr(buf, _T('\n'));
387 if (pLF)
388 *pLF = 0;
389 return tstring(&buf[0]);
390 }
391 }
392 return tstring();
393}
394
395
396//
397/// Responds to user menu selection. If MenuItemId is blank, displays an empty help
398/// message; otherwise, it displays a help message with the specified string ID. See
399/// EvEnterIdle for a description of how the help message is loaded.
400//
401/// Handle WM_MENUSELECT to provide hint text in the status bar based on the
402/// menu item id. Treat popup items seperatly and ask them for their ids.
403//
404void
406{
407 if (TrackMenuSelection) {
408 if (flags == 0xFFFF && hMenu == nullptr) { // Menu closing
411 if (messageBar)
412 messageBar->ClearHintText();
413 MenuItemId = 0;
414 }
415 else if (flags & MF_POPUP) {
416
417#if 0 // !BB
418// !BB TMenu popupMenu(hMenu);
419// !BB int count = popupMenu.GetMenuItemCount();
420// !BB int pos = 0;
421// !BB for (;pos < count && popupMenu.GetSubMenu(pos) != HMENU(menuItemId);
422// !BB pos++)
423// !BB ;
424// !BB MenuItemId = popupMenu.GetMenuItemID(pos);
425 // !BB
426 // !BB The above logic seems suspicious - The docs. seem to imply that
427 // !BB if (flags & MF_POPUP) then popup = GetSubMenu(hMenu, menuItemId);
428 // !BB I don't understand why we iterate through the menu when we have the
429 // !BB index. i.e. menuItemId is then an index not an HMENU as used above.
430 // !BB Also, there's no check to prevent the case where the for loop would
431 // !BB break until 'pos == count'. CodeGuard points out that the
432 // !BB eventual '::GetMenuItemID' call does indeed fail in these cases
433 // !BB given that 'pos' is out of range.
434 // !BB
435#else
436 // Retrieve id of popup menu
437 //
438 MenuItemId = TMenu(hMenu).GetMenuItemID(menuItemId);
439#endif
440 }
441 else if (flags & (MF_SEPARATOR | MF_MENUBREAK | MF_MENUBARBREAK)
442#if 0 // changed by Y.B 5/23/98
444#else
445 ){
446#endif
447 MenuItemId = BLANK_HELP; // display an empty help message
448 // could also restore bar at this point too
449 }
450 else {
451 MenuItemId = menuItemId; // display a help message with this string Id
452 }
453 }
454}
455
456//
457/// Forward our size event to the layout window base, and not the frame base
458//
459void
461{
463
464 // Since TFrameWindow::EvSize wasn't called, broadcast
465 // relevant info to children explicitly.
466 //
468}
469
470//
471/// Responds to a window message that tells an application's main window that a
472/// dialog box or a menu is entering an idle state. EvEnterIdle also handles
473/// updating the status bar with the appropriate help message.
474//
475/// Handle WM_ENTERIDLE in order to display help hints on the messsage bar if
476/// there is a hint pending & this frame has a message bar.
477//
478void
480{
481 if (source == MSGF_MENU && MenuItemId) {
484 if (messageBar)
485 {
487 if (MenuItemId != BLANK_HELP)
488 hint = GetHintText(MenuItemId, htStatus);
489 messageBar->SetHintText(hint);
490 }
491 MenuItemId = 0; // Don't repaint on subsequent EvEnterIdle's
492 }
494}
495
496namespace {
497
498//
499// Get or set location codes stashed in the style long for a decoration
500//
501const uint32 locMask = 0x0F00;
502const int locShift = 8;
503
505{
506 return TDecoratedFrame::TLocation(uint16((w.GetWindowAttr().Style & locMask) >> locShift));
507}
508
510{
511 w.GetWindowAttr().Style = (w.GetWindowAttr().Style & ~locMask) | (uint32(loc) << locShift);
512}
513
514} // namespace
515
516//
517/// Automates hiding and showing of decorations.
518//
521{
522 TRACEX(OwlCmd, 1, _T("TDecoratedFrame:EvCommand - id(") << id << _T("), ctl(") <<\
523 static_cast<void*>(hWndCtl) << _T("), code(") << notifyCode << _T(")"));
524
525 // Check if it's a menu-style command (i.e. skip commands from Controls)
526 //
527 if (hWndCtl == nullptr) {
528
529 // Does the command Id correspond to the Id of one of our children
530 //
532
533 // If yes, toggle it's visibility
534 //
535 if (decoration) {
536 bool visible = decoration->IsWindowVisible();
537
538 // If it's visible, remove it's layout metrics - We'll 'Layout' below
539 // and toggle the actual visibility of the child below.
540 //
541 if (visible) {
543 }
544 else {
545
546 // Check if decoration wants to be against the frame's edge
547 //
548 bool insertAtEdge = decoration->IsFlagSet(wfInsertAtEdge);
549
550 // We want to display this child window, first retrieve it's location
551 //
553
554 // Find the decoration it should be adjacent to.
555 //
556 struct TSiblingSearch
557 {
561
563 : Decoration(d), Sibling(nullptr), Location(loc)
564 {}
565 };
567 if (insertAtEdge)
568 {
569 auto c = GetChildren();
570 const auto i = std::find_if(c.begin(), c.end(), [&](TWindow& w)
571 { return ((&w != search.Decoration) && (GetLocation_(w) == search.Location)); });
572 search.Sibling = (i != c.end()) ? &(*i) : nullptr;
573 }
574 else
575 for (auto& w : GetChildren())
576 {
577 if (&w == search.Decoration)
578 break;
579
580 if (GetLocation_(w) == search.Location && w.IsWindowVisible())
581 search.Sibling = &w;
582 }
583
584 // Default to client window if we could not find the decoration's
585 // potential neighbor.
586 //
587 if (!search.Sibling)
588 search.Sibling = ClientWnd;
589
590 // Insert at its desired location
591 //
592 switch (location) {
593 case None:
594 break;
595 case Top:
596 InsertAtTop(*decoration, search.Sibling);
597 break;
598
599 case Bottom:
600 InsertAtBottom(*decoration, search.Sibling);
601 break;
602
603 case Left:
604 InsertAtLeft(*decoration, search.Sibling);
605 break;
606
607 case Right:
608 InsertAtRight(*decoration, search.Sibling);
609 break;
610
611 default: //JJH added empty default statement
612 break;
613 }
614 }
615
616 // Force the layout manager to compute new locations and shuffle
617 // windows around
618 //
619 Layout();
620
621 // Hide or display the decoration
622 //
623 decoration->ShowWindow(visible ? SW_HIDE : SW_SHOWNA);
624 return 0;
625 }
626 }
627
629}
630
631//
632// !CQ Auto-hide all docking areas? Give them IDW_s
633//
634/// Handles checking and unchecking of menu items that are associated with
635/// decorations.
636//
637void
639{
640 // Provide default command text to TooltipEnablers
641 //
642 if (dynamic_cast<TTooltipEnabler*>(&commandEnabler))
643 {
645 if (hint.length() > 0)
646 {
647 commandEnabler.SetText(hint);
648 return;
649 }
650 }
651
653 if (!decoration)
655 else
656 {
657 commandEnabler.Enable();
658 commandEnabler.SetCheck(decoration->IsWindowVisible() ?
660 }
661}
662
663//
664/// Insert a decoration window at the top of the client area, possibly above
665/// another given decoration or the client
666//
667void
668TDecoratedFrame::InsertAtTop(TWindow& decoration, TWindow* insertAbove)
669{
672
673 // Get the layout metrics for "insertAbove" (the window the decoration is
674 // going to be inserted above)
675 //
677
678 insertBelow = metrics.Y.RelWin;
679
680 // If "insertAbove" has a border then set its top edge to be the same as
681 // the decoration's bottom edge; otherwise place its top edge below the
682 // decoration's bottom edge
683 //
684 metrics.Y.Set(lmTop,
685 insertAbove->GetWindowAttr().Style & WS_BORDER ? lmSameAs : lmBelow,
688
689 // Now set the layout metrics for the decoration so its top edge is the same
690 // as or below the bottom edge of "insertBelow" (they overlap if WS_BORDER)
691 // !CQ want to use lmBelow if no border!?
692 //
693 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
694
697
698 metrics.Height.AsIs(lmHeight);
701
703}
704
705//
706/// Insert a decoration window at the bottom of the client area, possibly below
707/// another given decoration or the client
708//
709void
710TDecoratedFrame::InsertAtBottom(TWindow& decoration, TWindow* insertBelow)
711{
712 TLayoutMetrics metrics;
714
715 // Get the layout metrics for "insertBelow"(the window the decoration is
716 // going to be inserted below)
717 //
719
720 if (insertBelow == ClientWnd) {
721 insertAbove = metrics.Height.RelWin;
722
723 // If the client window has a border then set the client window's bottom
724 // to be the same as the top edge of the decoration; otherwise set the
725 // client window's bottom edge to be above the decoration's top edge
726 //
727 metrics.Height.Set(lmBottom,
728 ClientWnd->GetWindowAttr().Style & WS_BORDER ? lmSameAs : lmAbove,
729 &decoration, lmTop);
730 }
731 else {
732 insertAbove = metrics.Y.RelWin;
733
734 // Set the bottom edge of "insertBelow" to be the same as the top edge of
735 // the decoration
736 //
738 }
740
741 // Now set the layout metrics for the decoration so its bottom edge is the
742 // same as the top edge of "insertAbove"
743 //
744 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
745
748
749 metrics.Height.AsIs(lmHeight);
752
754}
755
756//
757/// Insert a decoration window at the left of the client area, possibly to the
758/// left of another given decoration or the client
759//
760void
761TDecoratedFrame::InsertAtLeft(TWindow& decoration, TWindow* insertLeftOf)
762{
763 TLayoutMetrics metrics;
765
766 // Get the layout metrics for "insertLeftOf"(the window the decoration is
767 // going to be inserted to the left of)
768 //
770
771 insertRightOf = metrics.X.RelWin;
772
773 // If "insertLeftOf" has a border then set its left edge to be the same as
774 // the decoration's right edge; otherwise place its left edge one pixel to
775 // the right of the decoration's right edge
776 //
777 metrics.X.Set(lmLeft,
778 insertLeftOf->GetWindowAttr().Style & WS_BORDER ? lmSameAs : lmRightOf,
781
782 // Now set the layout metrics for the decoration so it's left edge is the
783 // same as the right edge of "insertRightOf"
784 //
785 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
786
789
790 metrics.Width.AsIs(lmWidth);
791
792 // If the client window & decoration both have or don't have borders then
793 // place the decoration so its "y" and "bottom" are the same as the client
794 // windows; otherwise place its "y" above/below the client window's "y" and
795 // its "bottom" below/above the client window's "bottom" based on who's has
796 // borders & who doesn't
797 //
798 // This way if there are top or bottom decorations they will be tiled
799 // over/under the left/right decorations
800 //
801 if (ToBool(ClientWnd->GetWindowAttr().Style & WS_BORDER) == overlap) {
802 metrics.Y.SameAs(ClientWnd, lmTop);
803 metrics.Height.SameAs(ClientWnd, lmBottom);
804 }
805 else if (overlap) {
806 metrics.Y.Set(lmTop, lmAbove, ClientWnd, lmTop);
807 metrics.Height.Set(lmBottom, lmBelow, ClientWnd, lmBottom);
808 }
809 else {
810 metrics.Y.Set(lmTop, lmBelow, ClientWnd, lmTop);
811 metrics.Height.Set(lmBottom, lmAbove, ClientWnd, lmBottom);
812 }
814}
815
816//
817/// Insert a decoration window at the right of the client area, possibly to the
818/// right of another given decoration or the client
819//
820void
821TDecoratedFrame::InsertAtRight(TWindow& decoration, TWindow* insertRightOf)
822{
823 TLayoutMetrics metrics;
825
826 // Get the layout metrics for "insertRightOf" (the window the decoration is
827 // going to be inserted to the right of)
828 //
830
831 if (insertRightOf == ClientWnd) {
832 insertLeftOf = metrics.Width.RelWin;
833
834 // If the client window has a border then set the client window's right
835 // edge to be the same as the left edge of the decoration; otherwise set
836 // the client window's right edge to be one pixel to the left of the
837 // decoration's left edge
838 //
839 metrics.Width.Set(lmRight,
840 ClientWnd->GetWindowAttr().Style & WS_BORDER ? lmSameAs : lmLeftOf,
842 }
843 else {
844 insertLeftOf = metrics.X.RelWin;
845
846 // Set the right edge of "insertRightOf" to be the same as the left edge of
847 // the decoration
848 //
850 }
852
853 // Now set the layout metrics for the decoration so its right edge is the
854 // same as the left edge of "insertLeftOf"
855 //
856 bool overlap = (decoration.GetWindowAttr().Style & WS_BORDER);
857
860
861 metrics.Width.AsIs(lmWidth);
862
863 // If the client window & decoration both have or don't have borders then
864 // place the decoration so its "y" and "bottom" are the same as the client
865 // windows; otherwise place its "y" above/below the client window's "y" and
866 // its "bottom" below/above the client window's "bottom" based on who's has
867 // borders & who doesn't
868 //
869 // This way if there are top or bottom decorations they will be tiled
870 // over/under the left/right decorations
871 //
872 if (ToBool(ClientWnd->GetWindowAttr().Style & WS_BORDER) == overlap) {
873 metrics.Y.SameAs(ClientWnd, lmTop);
874 metrics.Height.SameAs(ClientWnd, lmBottom);
875 }
876 else if (overlap) {
877 metrics.Y.Set(lmTop, lmAbove, ClientWnd, lmTop);
878 metrics.Height.Set(lmBottom, lmBelow, ClientWnd, lmBottom);
879 }
880 else {
881 metrics.Y.Set(lmTop, lmBelow, ClientWnd, lmTop);
882 metrics.Height.Set(lmBottom, lmAbove, ClientWnd, lmBottom);
883 }
885}
886
887//
888/// Insert a decoration window into position at one of the four edges.
889//
890/// After you specify where the decoration should be placed, Insert adds it just
891/// above, below, left, or right of the client window. This process is especially
892/// important when there are multiple decorations. Insert looks at the decoration's
893/// Attr.Style member and checks the WS_VISIBLE flag to tell whether the decoration
894/// should initially be visible or hidden.
895/// To position the decoration, Insert uses TLocation enum, which describes Top,
896/// Left, Bottom, and Right positions where the decoration can be placed.
897//
898void
900{
901 // Store away location for remove/re-insetion
902 //
904
905 // Make sure the decoration has clipsiblings style, since our rearranging
906 // causes corners to overlap sometimes.
907 //
908 ModifyStyle(0, WS_CLIPSIBLINGS);//|WS_CLIPCHILDREN);///????
909
910 // Parent to decframe and remove layoutmetrics in case it's a re-insert
911 //
912 decoration.SetParent(this);
914
915 // If the window should be visible, proceed with insertion.
916 // NOTE: Should we check the 'wfInsertAtEdge' flag here? It mostly
917 // important when hiding/showing decorations [i.e. In EvCommand
918 // handler]. However, it would be nice to check for it and use
919 // something other than ClientWnd if necessary.
920 //
921 if (decoration.GetWindowAttr().Style & WS_VISIBLE) {
922 switch (location) {
923 case None:
924 break;
925 case Top:
926 InsertAtTop(decoration, ClientWnd);
927 break;
928 case Bottom:
929 InsertAtBottom(decoration, ClientWnd);
930 break;
931 case Left:
932 InsertAtLeft(decoration, ClientWnd);
933 break;
934 case Right:
935 InsertAtRight(decoration, ClientWnd);
936 break;
937 default: //JJH added empty default statement
938 break;
939 }
940 }
941}
942
943//
944/// Search for child with ID = IDW_TOOLBAR, and if found check that it is
945/// GadgetWindow and return it;
946//
949{
951 if (!wnd)
952 {
953 // Look for grand-child toolbar.
954 //
955 auto c = GetChildren();
956 const auto i = find_if(c.begin(), c.end(), [](TWindow& w) { return w.ChildWithId(IDW_TOOLBAR); });
957 if (i == c.end()) return nullptr;
958 wnd = i->ChildWithId(IDW_TOOLBAR);
959 CHECK(wnd);
960 }
962 if(toolBar)
963 return toolBar;
964 return nullptr;
965}
966
967
968//
969/// SetupWindow() call this function to create control bar, if it is MainWindow and
970/// if BarDescriptor exist.
971//
972bool
974{
976 if(!toolBar){ // already created
977 toolBar = (*GetBarCreator())(this);
978 toolBar->GetWindowAttr().Id = IDW_TOOLBAR;
979 }
980 if(((TBarDescr*)GetBarDescr())->Create(*toolBar))
981 return (*GetBarInserter())(*this, *toolBar, alTop);
982 return false;
983}
984
985//
986/// Merges the given bar descriptor with this frame's own bar descriptor and
987/// displays the resulting control bar in this frame. See TBarDescr for a
988/// description of control bar types that can be merged.
989//
990bool
992{
993 if (!GetHandle() || !GetBarDescr())
994 return false;
996 if(toolBar) // already created
998 return true;
999}
1000
1001//
1002/// Restores the default control bar of the frame window.
1003//
1004bool
1006{
1007 if (!GetHandle() || !GetBarDescr())
1008 return false;
1010 if(toolBar) // already created
1011 ((TBarDescr*)GetBarDescr())->Restore(*toolBar);
1012 return true;
1013}
1014
1015
1017
1018#if OWL_PERSISTENT_STREAMS
1019
1020//
1021//
1022//
1023void*
1024TDecoratedFrame::Streamer::Read(ipstream& is, uint32 /*version*/) const
1025{
1026 ReadVirtualBase((TFrameWindow*)GetObject(), is);
1027 ReadBaseObject((TLayoutWindow*)GetObject(), is);
1028 return GetObject();
1029}
1030
1031//
1032//
1033//
1034void
1035TDecoratedFrame::Streamer::Write(opstream& os) const
1036{
1037 WriteVirtualBase((TFrameWindow*)GetObject(), os);
1038 WriteBaseObject((TLayoutWindow*)GetObject(), os);
1039}
1040
1041#endif
1042
1043} // OWL namespace
1044
Class definition for TBarDescr.
#define CHECK(condition)
Definition checks.h:239
#define WARNX(group, condition, level, message)
Definition checks.h:277
#define DIAG_DECLARE_GROUP(group)
Definition checks.h:404
#define TRACEX(group, level, message)
Definition checks.h:263
Descriptor of Bar Implementation.
Definition bardescr.h:71
Base class for an extensible interface for auto enabling/disabling of commands (menu items,...
Definition window.h:209
@ Unchecked
Command is not enabled.
Definition window.h:226
@ Checked
Command is enabled.
Definition window.h:227
Derived from TGadgetWindow, TControlBar implements a control bar that provides mnemonic access for it...
Definition controlb.h:61
TDecoratedFrame automatically positions its client window (you must supply a client window) so that i...
Definition decframe.h:74
void SetBarInserter(const TBarInsertFunctor &funct)
Definition decframe.cpp:139
void EvMenuSelect(uint menuItemId, uint flags, HMENU hMenu)
Responds to user menu selection.
Definition decframe.cpp:405
TBarInsertFunctor * GetBarInserter()
Definition decframe.h:229
auto RestoreBar() -> bool override
Restores the default control bar of the frame window.
void RemoveChild(TWindow *) override
Makes sure that both bases get a chance to see the child removed.
Definition decframe.cpp:251
void EvEnterIdle(uint source, HWND hWndDlg)
Responds to a window message that tells an application's main window that a dialog box or a menu is e...
Definition decframe.cpp:479
void SetBarCreator(const TGadgetWndFunctor &funct)
Definition decframe.cpp:133
TDecoratedFrame(TWindow *parent, LPCTSTR title, TWindow *clientWnd, bool trackMenuSelection=false, TModule *module=0)
Constructs a TDecoratedFrame object with the specified parent window (parent), window caption (title)...
Definition decframe.cpp:62
virtual TGadgetWindow * GetControlBar()
Search for child with ID = IDW_TOOLBAR, and if found check that it is GadgetWindow and return it;.
Definition decframe.cpp:948
TGadgetWndFunctor * GetBarCreator()
Definition decframe.h:222
auto MergeBar(const TBarDescr &) -> bool override
Merges the given bar descriptor with this frame's own bar descriptor and displays the resulting contr...
Definition decframe.cpp:991
auto SetClientWindow(TWindow *) -> TWindow *override
Overrides TFrameWindows virtual function.
Definition decframe.cpp:189
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
Automates hiding and showing of decorations.
Definition decframe.cpp:520
void Init(TWindow *parent, LPCTSTR title, TWindow *client, bool trackMenuSelection, TModule *)
Initialization shared by the constructors.
Definition decframe.cpp:85
virtual bool CreateBar()
SetupWindow() call this function to create control bar, if it is MainWindow and if BarDescriptor exis...
Definition decframe.cpp:973
void EvSize(uint sizeType, const TSize &size)
Forward our size event to the layout window base, and not the frame base.
Definition decframe.cpp:460
~TDecoratedFrame() override
Definition decframe.cpp:125
void EvCommandEnable(TCommandEnabler &) override
Handles checking and unchecking of menu items that are associated with decorations.
Definition decframe.cpp:638
auto PreProcessMsg(MSG &) -> bool override
Override TFrameWindow member function to give decorations an opportunity to do pre-processing (e....
Definition decframe.cpp:265
TLocation
Enumeration describing the possible locations of a Gadgetwindow [Used mainly for location of Toolbar ...
Definition decframe.h:88
@ Bottom
Refers to bottom edge of frame.
Definition decframe.h:91
@ None
No location specified.
Definition decframe.h:89
@ Top
Refers to top edge of frame.
Definition decframe.h:90
@ Left
Refers to left edge of frame.
Definition decframe.h:92
@ Right
Refers to right edge of frame.
Definition decframe.h:93
virtual tstring GetHintText(uint id, THintText hintType) const
Retrieves the text specified by the resource id.
Definition decframe.cpp:293
void CleanupWindow() override
Definition decframe.cpp:169
void SetupWindow() override
Override SetupWindow in order to layout & position decorations Calls TLayoutWindow::Layout to size an...
Definition decframe.cpp:148
virtual void Insert(TWindow &decoration, TLocation location=Top)
Insert a decoration window into position at one of the four edges.
Definition decframe.cpp:899
Derived from TWindow, TFrameWindow controls such window-specific behavior as keyboard navigation and ...
Definition framewin.h:96
void Init(TWindow *clientWnd, bool shrinkToClient)
Normal initialization of a default constructed TFrameWindow.
Definition framewin.cpp:166
virtual TWindow * GetClientWindow()
Returns a pointer to the client window.
Definition framewin.cpp:591
void EvCommandEnable(TCommandEnabler &) override
Handle WM_COMMAND_ENABLE to provide command enable distribution and default support for windows witho...
Definition framewin.cpp:423
void CleanupWindow() override
Cleans up any associated icons.
auto PreProcessMsg(MSG &) -> bool override
Overrides TWindow's virtual function.
Definition framewin.cpp:436
void BroadcastResizeToChildren(uint sizeType, const TSize &size)
Tell child windows frame has minimized/maximized/restored (They may want to change enabled state or r...
auto EvCommand(uint id, HWND hWndCtl, uint notifyCode) -> TResult override
Handle WM_COMMAND to provide extra processing for commands: Extra processing for commands: starts wit...
Definition framewin.cpp:387
virtual TWindow * SetClientWindow(TWindow *clientWnd)
Sets the client window to the specified window.
Definition framewin.cpp:603
const TBarDescr * GetBarDescr() const
Returns a pointer to the control bar descriptor.
Definition framewin.h:324
TFrameWindow()
< String-aware overload
Definition framewin.cpp:151
void SetupWindow() override
Calls TWindow::SetUpWindow to create windows in a child list.
void RemoveChild(TWindow *) override
If someone removes our client with a RemoveChild() call, update our client and restore focus ptrs.
Definition framewin.cpp:652
Functor with 1 parameter, return R.
Definition functor.h:294
Functor with 3 parameters, return R.
Definition functor.h:589
Derived from TWindow, TGadgetWindow maintains a list of tiled gadgets for a window and lets you dynam...
Definition gadgetwi.h:122
When specifying the layout metrics for a window, four layout constraints are needed.
Definition layoutwi.h:54
Derived from TWindow, TLayoutWindow provides functionality for defining the layout metrics for a wind...
Definition layoutwi.h:122
TLayoutWindow(TWindow *parent, LPCTSTR title=0, TModule *module=0)
Creates a TLayoutWindow object with specified parent, window caption, and library ID.
Definition layoutwi.cpp:262
void EvSize(uint sizeType, const TSize &size)
Responds to a change in size by calling Layout() to resize the window.
Definition layoutwi.cpp:615
virtual void Layout()
Causes the window to resize and position its children according to the specified metrics.
Definition layoutwi.cpp:351
bool GetChildLayoutMetrics(const TWindow &child, TLayoutMetrics &metrics)
Gets the layout metrics of the child window.
Definition layoutwi.cpp:500
void SetChildLayoutMetrics(TWindow &child, const TLayoutMetrics &metrics)
Sets the metrics for the window and removes any existing ones.
Definition layoutwi.cpp:465
void RemoveChild(TWindow *) override
Overrides TWindow virtual to allow cleanup of child metrics.
Definition layoutwi.cpp:660
bool RemoveChildLayoutMetrics(const TWindow &child)
Removes child (layout) metrics for a given child (if found) and updates other children as necessary.
Definition layoutwi.cpp:529
The TMenu class encapsulates window menus.
Definition menu.h:77
uint GetMenuItemID(int posItem) const
Returns the ID of the menu item at the position specified by posItem.
Definition menu.cpp:174
Derived from TGadgetWindow, TMessageBar implements a message bar with one text gadget as wide as the ...
Definition messageb.h:36
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
The tagSIZE struct is defined as.
Definition geometry.h:234
TTooltipEnabler is the object forwarded along the command-chain to retrieve the tip text of a tool.
Definition tooltip.h:149
static int GetMenuString(HMENU, UINT, TCHAR *, int, UINT)
Definition module.cpp:1099
TWindow, derived from TEventHandler and TStreamableBase, provides window-specific behavior and encaps...
Definition window.h:414
void EvEnterIdle(uint source, HWND hWndDlg)
The default message handler for WM_ENTERIDLE.
Definition window.cpp:3926
TWindow()
Protected constructor for use by immediate virtually derived classes.
Definition window.cpp:392
auto GetChildren()
Returns a TWindow::TChildrenRange that can be iterated by standard means.
Definition window.h:550
void Init(TWindow *parent, LPCTSTR title, TModule *module)
Normal initialization of a default constructed TWindow.
Definition window.cpp:401
TModule * GetModule() const
Returns a pointer to the module object.
Definition window.h:1841
HMENU GetMenu() const
Returns the handle to the menu of the indicated window.
Definition window.h:3244
bool ModifyStyle(uint32 offBits, uint32 onBits, uint swpFlags=0)
Modifies the style bits of the window.
Definition window.cpp:3591
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
bool IsFlagSet(uint mask)
Returns the state of the bit flag in Attr.Flags whose mask is supplied.
Definition window.h:1797
TWindow * GetFirstChild()
Returns a pointer to the first child window, which is the first window created in the interface objec...
Definition window.h:1770
HWND GetHandle() const
Returns the handle of the window.
Definition window.h:2020
auto ChildWithId(int id) const -> const TWindow *
Definition window.h:681
ipstream, a specialized input stream derivative of pstream, is the base class for reading (extracting...
Definition objstrm.h:391
Definition of class TControlBar.
#define _tcslen
Definition cygwin.h:74
#define _T(x)
Definition cygwin.h:51
#define _tcschr
Definition cygwin.h:85
Definition of class TDecoratedFrame, a TFrameWindow that can manage decorations around the client win...
#define TBarInsert_FUNCTOR(func)
Definition decframe.h:44
#define TGadgetWnd_FUNCTOR(func)
Definition decframe.h:33
#define DEFINE_RESPONSE_TABLE2(cls, base1, base2)
Macro to define a response table for a class with two bases.
Definition eventhan.h:506
C++ Functor template implementation.
#define lmParent
Use to represent the parent in layout metrics.
Definition layoutco.h:31
@ lmTop
The top edge of the window.
Definition layoutco.h:38
@ lmBottom
The bottom edge of the window.
Definition layoutco.h:40
@ lmRight
The right edge of the window.
Definition layoutco.h:39
@ lmLeft
The left edge of the window.
Definition layoutco.h:37
@ lmLeftOf
Definition layoutco.h:71
@ lmAbove
Definition layoutco.h:71
@ lmSameAs
Definition layoutco.h:73
@ lmRightOf
Definition layoutco.h:72
@ lmBelow
Definition layoutco.h:72
@ lmWidth
Definition layoutco.h:48
@ lmHeight
Definition layoutco.h:48
void ReadBaseObject(Base *base, ipstream &in)
Definition objstrm.h:1159
void ReadVirtualBase(Base *base, ipstream &in)
Definition objstrm.h:1190
#define IMPLEMENT_STREAMABLE3(cls, base1, base2, base3)
Definition objstrm.h:1727
void WriteVirtualBase(Base *base, opstream &out)
Definition objstrm.h:1169
void WriteBaseObject(Base *base, opstream &out)
Definition objstrm.h:1150
THintText
Definition decframe.h:51
@ htStatus
Text displayed on status bar.
Definition decframe.h:52
@ htTooltip
Shorter text displayed in a tooltip.
Definition decframe.h:53
TAbsLocation
General use absolute 2-D rectangular location enum.
Definition geometry.h:62
@ alTop
Refers to top edge of frame.
Definition geometry.h:64
int LoadString(uint id, TCHAR *buf, int maxChars) const
Loads a string resource identified by id into the buffer pointed to by buff.
Definition module.cpp:586
@ wfMainWindow
This frame window is the main window.
Definition window.h:63
@ wfInsertAtEdge
(Decoration) Window to be inserted against frame's edge
Definition window.h:83
Definition of class TMessageBar.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
const int IDW_TOOLBAR
Definition decframe.h:24
unsigned long uint32
Definition number.h:34
TFunctor3< bool, TDecoratedFrame &, TGadgetWindow &, TAbsLocation > TBarInsertFunctor
Definition decframe.h:42
bool ToBool(const T &t)
Definition defs.h:291
const uint BLANK_HELP
Definition decframe.cpp:37
OWL_DIAGINFO
Definition animctrl.cpp:14
END_RESPONSE_TABLE
Definition button.cpp:26
const int IDW_STATUSBAR
Definition messageb.h:25
EV_WM_MENUSELECT
Definition decframe.cpp:33
LRESULT TResult
Result type.
Definition dispatch.h:52
unsigned short uint16
Definition number.h:33
std::string tstring
Definition defs.h:79
bool EvBarInserter(TDecoratedFrame &frame, TGadgetWindow &destWindow, TAbsLocation loc)
Definition decframe.cpp:47
unsigned int uint
Definition number.h:25
const unsigned int IDW_FIRSTMDICHILD
child window IDs, 32 max to 32032
Definition framewin.h:29
EV_WM_ENTERIDLE
Definition decframe.cpp:32
TFunctor1< TGadgetWindow *, TWindow * > TGadgetWndFunctor
Definition decframe.h:31
EV_WM_SIZE
Definition decframe.cpp:34
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Definition defs.h:376
#define TYPESAFE_DOWNCAST(object, toClass)
Definition defs.h:269
Definition of the TTooltip class and helper objects.