Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGMdiDecorFrame.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Bertrand Bellenot 20/08/2004
3
4/*************************************************************************
5 * Copyright (C) 1995-2004, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12/**************************************************************************
13
14 This file is part of TGMdi an extension to the xclass toolkit.
15 Copyright (C) 1998-2002 by Harald Radke, Hector Peraza.
16
17 This application is free software; you can redistribute it and/or
18 modify it under the terms of the GNU Library General Public
19 License as published by the Free Software Foundation; either
20 version 2 of the License, or (at your option) any later version.
21
22 This application is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 Library General Public License for more details.
26
27 You should have received a copy of the GNU Library General Public
28 License along with this library; if not, write to the Free
29 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30
31**************************************************************************/
32
33//////////////////////////////////////////////////////////////////////////
34// //
35// TGMdiDecorFrame, TGMdiTitleBar, TGMdiButtons, TGMdiTitleIcon, //
36// TGMdiWinResizer, TGMdiVerticalWinResizer, TGMdiHorizontalWinResizer, //
37// and TGMdiCornerWinResizer. //
38// //
39// This file contains all different MDI frame decoration classes. //
40// //
41//////////////////////////////////////////////////////////////////////////
42
43#include <cstdio>
44#include <cstdlib>
45
46#include "KeySymbols.h"
47#include "TGResourcePool.h"
48#include "TGDimension.h"
49#include "WidgetMessageTypes.h"
50#include "TGMdiFrame.h"
51#include "TGMdiDecorFrame.h"
52#include "TGMdiMainFrame.h"
53#include "TVirtualX.h"
54
55
64
65////////////////////////////////////////////////////////////////////////////////
66/// TGMdiDecorFrame constructor.
67/// The TGMdiDecorFrame is the frame containing MDI decorations like
68/// title bar, minimize, maximize, restore and close buttons, and resizers.
69
71 Int_t w, Int_t h, const TGGC *boxGC,
72 UInt_t options, Pixel_t back) :
73 TGCompositeFrame(main->GetContainer(), w, h,
74 options | kOwnBackground | kVerticalFrame | kFixedSize, back)
75{
76
78 fEditDisabled = 1;
79 fFrame = frame;
85
87
89
92
95
97 boxGC, kMdiBorderWidth);
99 boxGC, kMdiBorderWidth);
101 boxGC, kMdiBorderWidth);
103 boxGC, kMdiBorderWidth);
104
107 boxGC, kMdiBorderWidth);
110 boxGC, kMdiBorderWidth);
113 boxGC, kMdiBorderWidth);
116 boxGC, kMdiBorderWidth);
117
126
128
130 fFrame->fParent = this;
132
135 Layout();
136
137 MapWindow();
139
142}
143
144////////////////////////////////////////////////////////////////////////////////
145/// TGMdiDecorFrame destructor.
146
148{
149 if (!MustCleanup()) {
150 delete fUpperHR;
151 delete fLowerHR;
152 delete fLeftVR;
153 delete fRightVR;
154 delete fUpperLeftCR;
155 delete fLowerLeftCR;
156 delete fUpperRightCR;
157 delete fLowerRightCR;
158 }
160}
161
162////////////////////////////////////////////////////////////////////////////////
163/// Set border width of the decor.
164
166{
167 fBorderWidth = bw;
168}
169
170////////////////////////////////////////////////////////////////////////////////
171/// Set-up MDI buttons.
172
174{
175 fButtonMask = buttons;
177 if (fButtonMask & kMdiSize) {
186 } else {
195 }
196}
197
198////////////////////////////////////////////////////////////////////////////////
199/// Set resize mode (opaque or transparent)
200
202{
203 fUpperHR->SetResizeMode(mode);
204 fLowerHR->SetResizeMode(mode);
205 fLeftVR->SetResizeMode(mode);
206 fRightVR->SetResizeMode(mode);
211}
212
213////////////////////////////////////////////////////////////////////////////////
214/// Recalculates the postion and the size of all decor frame components.
215
217{
221
222 if (fIsMaximized == kFALSE) {
223 fUpperLeftCR->Move(0, 0);
228
243 }
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Set MDI Window name (appearing in the title bar)
248
250{
252 fTitlebar->Layout();
253}
254
255////////////////////////////////////////////////////////////////////////////////
256/// Set Window icon (appearing in the title bar)
257
259{
262}
263
264////////////////////////////////////////////////////////////////////////////////
265/// Move the MDI window at position x, y.
266
268{
269 if (x < 0) {
271 }
272 if (y < 0) {
274 }
278}
279
280////////////////////////////////////////////////////////////////////////////////
281/// Move the MDI window at position x, y and set size to w, h.
282
284{
285 if (x < 0) {
287 }
288 if (y < 0) {
290 }
294}
295
296////////////////////////////////////////////////////////////////////////////////
297/// Handle configure notify event.
298
300{
301 if ((event->fX < 0) || (event->fY < 0) ||
302 (event->fX + event->fWidth > fMdiMainFrame->GetViewPort()->GetWidth()) ||
303 (event->fY + event->fHeight > fMdiMainFrame->GetViewPort()->GetHeight())) {
305 }
306
307 if (event->fWindow == fFrame->GetId()) {
308 UInt_t newW = event->fWidth + 2 * fBorderWidth;
309 UInt_t newH = event->fHeight + 2 * fBorderWidth +
311
312 if ((fWidth != newW) || (fHeight != newH)) {
313 Resize(newW, newH);
314 }
316 return kTRUE;
317 }
319 return kFALSE;
320}
321
322////////////////////////////////////////////////////////////////////////////////
323/// Handle mouse button events.
324
326{
327 if (event->fType == kButtonPress) {
328 void *ud;
331 }
332 return kTRUE;
333}
334
335
336////////////////////////////////////////////////////////////////////////////////
337/// TGMdiTitleBar constructor.
338/// the TGMdiTitleBar is the frame containing a title (window name)
339/// an icon and MDI picture buttons as minimize, maximize, restore,
340/// close and help.
341
343 const char *name) :
345{
346 fMdiWin = mdiwin;
348 fWinName = 0;
350
352
355 //fMiddleHint = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 1, 1, 1);
358
359 fLFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
360 fMFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
361 fRFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
365
366 fWinIcon = new TGMdiTitleIcon(fLFrame, this,
367 fClient->GetPicture("mdi_default.xpm"),
368 16, 16);
370
371 fWinName = new TGLabel(fMFrame, new TGString(name));
374
375 fButtons = new TGMdiButtons(fRFrame, this);
377
378 MapWindow();
380 Layout();
382}
383
384////////////////////////////////////////////////////////////////////////////////
385/// TGMdiTitleBar destructor.
386
388{
389 if (!MustCleanup()) {
390 delete fLHint;
391 delete fLeftHint;
392 delete fMiddleHint;
393 delete fRightHint;
394 }
395}
396
397////////////////////////////////////////////////////////////////////////////////
398/// Recalculates the position of every enabled (displayed) buttons.
399
400void TGMdiTitleBar::LayoutButtons(UInt_t buttonmask,Bool_t isMinimized,
401 Bool_t isMaximized)
402{
404
405 if (buttonmask & kMdiSize) {
407 } else {
409 }
410
411 if (buttonmask & kMdiMenu) {
413 } else {
415 }
416
417 if (buttonmask & kMdiClose) {
420 } else {
423 }
424
425 if (buttonmask & kMdiHelp) {
427 } else {
429 }
430
431 if ((buttonmask & kMdiMaximize) && (!isMaximized)) {
434 } else {
437 }
438
439 if (isMinimized | isMaximized) {
443 if (isMaximized) fWinIcon->GetPopup()->DisableEntry(kMdiMove);
444 } else {
447 }
448
449 if ((buttonmask & kMdiMinimize) && (!isMinimized)) {
452 } else {
455 }
456
457 Layout();
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Set title bar color (blue or grey, depends on active state).
462
464{
465 SetBackgroundColor(back);
466
467 fClient->GetFont(font->GetName());
468 fWinName->SetTextFont(font);
474 Layout();
475 fClient->NeedRedraw(this);
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Handle double click in title bar (maximize window)
485
487{
488 if ((event->fType == kButtonPress) && (event->fCode == kButton1)) {
490 }
491 return kTRUE;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Handle mouse click on title bar.
496
498{
499 if (event->fType == kButtonPress) {
500 void *ud;
501 GetWinIcon()->GetPopup()->EndMenu(ud);
502 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kMove));
503 switch (event->fCode) {
504 case kButton1:
505 fX0 = event->fX;
506 fY0 = event->fY;
509 break;
510
511 case kButton2:
513 break;
514
515 case kButton3:
516 gVirtualX->LowerWindow(fParent->GetId());
518 break;
519 }
520 } else {
521 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
522 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
523 switch (event->fCode) {
524
525 case kButton1:
526 //if (!fClient->IsEditable()) ((TGMainFrame *)((TGMdiMainFrame *)fMdiWin)->GetMainFrame())->Layout();
528 break;
529
530 case kButton2:
532 break;
533
534 case kButton3:
536 break;
537 }
538
539 TGFrame *f = GetFrameFromPoint(event->fX, event->fY);
540 if (f && (f != this)) {
541 TranslateCoordinates(f, event->fX, event->fY, event->fX, event->fY);
542 f->HandleButton(event);
543 }
544 }
545 return kTRUE;
546}
547
548////////////////////////////////////////////////////////////////////////////////
549/// Process messages for title bar.
550
552{
553 switch (GET_MSG(msg)) {
554 case kC_COMMAND:
555 switch (GET_SUBMSG(msg)) {
556 case kCM_BUTTON:
557 case kCM_MENU:
559 fParent->GetId(), parm2);
560 break;
561 }
562 break;
563 }
564 return kTRUE;
565}
566
567////////////////////////////////////////////////////////////////////////////////
568/// Handle mouse motion events in title bar (used to move MDI window).
569
571{
572 if (event->fWindow != fId) return kTRUE;
573 if (!fLeftButPressed) return kTRUE;
574
575 Int_t x = ((TGFrame *)fParent)->GetX();
576 Int_t y = ((TGFrame *)fParent)->GetY();
577 ((TGFrame *)fParent)->Move(x + event->fX - fX0, y + event->fY - fY0);
578
579 return kTRUE;
580}
581
582
583////////////////////////////////////////////////////////////////////////////////
584/// This is called from TGMdiMainFrame on Restore().
585
587{
588 icon->ReparentWindow(fLFrame);
589 buttons->ReparentWindow(fRFrame);
590 fLFrame->AddFrame(icon, fLHint);
591 fLFrame->ShowFrame(icon);
592 fRFrame->AddFrame(buttons, fLHint);
593 fRFrame->ShowFrame(buttons);
594}
595
596
597////////////////////////////////////////////////////////////////////////////////
598/// This is called from TGMdiMainFrame on Maximize().
599
601{
602 fLFrame->RemoveFrame(icon);
603 fRFrame->RemoveFrame(buttons);
604}
605
606
607////////////////////////////////////////////////////////////////////////////////
608/// TGMdiButtons constructor.
609/// the TGMdiButtons is the frame containing MDI picture buttons like
610/// minimize, maximize, restore, close and help.
611
612TGMdiButtons::TGMdiButtons(const TGWindow *p, const TGWindow *titlebar) :
614{
615 fDefaultHint = new TGLayoutHints(kLHintsNormal, 0, 0, 1, 0);
616 fCloseHint = new TGLayoutHints(kLHintsNormal, 2, 0, 1, 0);
618 fMsgWindow = 0;
619
620 //--- Minimize button
621
622 fButton[0] = new TGPictureButton(this,
623 fClient->GetPicture("mdi_minimize.xpm"),
625 fButton[0]->SetToolTipText("Minimize");
628 fButton[0]->Associate(titlebar);
629
630 //--- Restore button
631
632 fButton[1] = new TGPictureButton(this,
633 fClient->GetPicture("mdi_restore.xpm"),
635 fButton[1]->SetToolTipText("Restore");
638 fButton[1]->Associate(titlebar);
639
640 //--- Maximize button
641
642 fButton[2] = new TGPictureButton(this,
643 fClient->GetPicture("mdi_maximize.xpm"),
645 fButton[2]->SetToolTipText("Maximize");
648 fButton[2]->Associate(titlebar);
649
650 //--- Help button
651
652 fButton[3] = new TGPictureButton(this,
653 fClient->GetPicture("mdi_help.xpm"),
654 kMdiHelp);
655 fButton[3]->SetToolTipText("Help");
658 fButton[3]->Associate(titlebar);
659
660 //--- Close button
661
662 fButton[4] = new TGPictureButton(this,
663 fClient->GetPicture("mdi_close.xpm"),
664 kMdiClose);
665 fButton[4]->SetToolTipText("Close");
668 fButton[4]->Associate(titlebar);
670}
671
672////////////////////////////////////////////////////////////////////////////////
673/// TGMdiButtons destructor.
674
676{
677 if (!MustCleanup()) {
678 delete fDefaultHint;
679 delete fCloseHint;
680 }
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// TGMdiTitleIcon constructor.
685/// the TGMdiTitleIcon is the left icon used also for the MDI
686/// popup menu allowing access to MDI commands as : restore,
687/// move, size, minimize and close.
688
690 const TGPicture *pic, Int_t w, Int_t h) :
691 TGIcon(p, pic, w, h)
692{
693 fMsgWindow = titlebar;
695
696 //--- MDI system menu
697
698 fPopup = new TGPopupMenu(fClient->GetDefaultRoot());// fClient->GetRoot());
699 fPopup->AddEntry(new TGHotString("&Restore"), kMdiRestore);
700 fPopup->AddEntry(new TGHotString("&Move"), kMdiMove);
701 fPopup->AddEntry(new TGHotString("&Size"), kMdiSize);
702 fPopup->AddEntry(new TGHotString("Mi&nimize"), kMdiMinimize);
703 fPopup->AddEntry(new TGHotString("Ma&ximize"), kMdiMaximize);
705 fPopup->AddEntry(new TGHotString("&Close Ctrl+F4"), kMdiClose);
707 fPopup->Associate(titlebar);
708
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// TGMdiTitleIcon destructor.
715
717{
718 delete fPopup;
719}
720
721////////////////////////////////////////////////////////////////////////////////
722/// Redraw icon.
723
725{
726 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
728}
729
730////////////////////////////////////////////////////////////////////////////////
731/// Handle double click event on MDI icon (close the window)
732
734{
735 if (event->fCode == kButton1) {
736 void *ud;
737 fPopup->EndMenu(ud);
738 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
740 }
741 return kTRUE;
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Handle button event on MDI icon (popup menu)
746
748{
750
751 if (event->fType == kButtonPress) {
752 fPopup->PlaceMenu(event->fXRoot - event->fX,
753 event->fYRoot + (fHeight - event->fY),
754 kTRUE, kTRUE);
755 }
756 return kTRUE;
757}
758
759
760////////////////////////////////////////////////////////////////////////////////
761/// TGMdiWinResizer constructor.
762/// The TGMdiWinResizer is a frame allowing to resize MDI window.
763/// Could be horizontal, vertical or corner resizer (see derived classes
764/// TGMdiVerticalWinResizer, TGMdiHorizontalWinResizer, and
765/// TGMdiCornerWinResizer).
766
768 Int_t pos, const TGGC *boxgc, Int_t linew,
769 Int_t mdioptions, Int_t w, Int_t h, UInt_t options) :
770 TGFrame(p, w, h, options)
771{
772 fWinX = fWinY = fWinW = fWinH = fOldX = fOldY = fOldW = fOldH = 0;
773 fNewX = fNewY = fNewW = fNewH = fX0 = fY0 = 0;
774
776
777 fMdiWin = mdiwin;
778 fMdiOptions = mdioptions;
779 fPos = pos;
780
781 fBoxGC = boxgc;
782 fLineW = linew;
783
784 fMinW = 50;
785 fMinH = 20;
786
788
789 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
791 kNone, kNone);
793}
794
795////////////////////////////////////////////////////////////////////////////////
796/// Handle button events in resizer (grab button and resize).
797
799{
800 if (!IsEnabled()) return kTRUE;
801
802 if (event->fType == kButtonPress) {
803 void *ud;
804 ((TGMdiDecorFrame *)fParent)->GetTitleBar()->GetWinIcon()->GetPopup()->EndMenu(ud);
805 switch (event->fCode) {
806 case kButton1:
808 fNewX = fOldX = fWinX = ((TGFrame *)fParent)->GetX();
809 fNewY = fOldY = fWinY = ((TGFrame *)fParent)->GetY();
810 fWinW = ((TGFrame *)fParent)->GetWidth();
811 fWinH = ((TGFrame *)fParent)->GetHeight();
812 fX0 = event->fXRoot;
813 fY0 = event->fYRoot;
814 fNewW = fWinW;
815 fNewH = fWinH;
816 if (fMdiOptions != kMdiOpaque) {
818 }
822 break;
823
824 case kButton2:
826 break;
827
828 case kButton3:
830 break;
831 }
832 } else {
833 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
834 switch (event->fCode) {
835 case kButton1:
836 if (fMdiOptions != kMdiOpaque) {
838 ((TGFrame *)fParent)->MoveResize(fNewX, fNewY, fNewW, fNewH);
839 }
840 //if (!fClient->IsEditable()) ((TGMainFrame *)((TGMdiMainFrame *)fMdiWin)->GetMainFrame())->Layout();
842 break;
843
844 case kButton2:
846 break;
847
848 case kButton3:
850 break;
851 }
852 }
853 return kTRUE;
854}
855
856////////////////////////////////////////////////////////////////////////////////
857/// Draw resize box (rectangle).
858
860{
862
863 gVirtualX->DrawRectangle(m->GetContainer()->GetId(), fBoxGC->GetGC(),
864 x + fLineW / 2, y + fLineW / 2, width - fLineW, height - fLineW);
865}
866
867////////////////////////////////////////////////////////////////////////////////
868/// Move (resize) parent MDI window.
869
871{
872 if (fMdiOptions == kMdiOpaque) {
874 } else {
877 }
878}
879
880
881////////////////////////////////////////////////////////////////////////////////
882/// TGMdiVerticalWinResizer constructor.
883
885 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
886 Int_t mdioptions, Int_t w, Int_t h) :
887 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
889{
890 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kArrowVer));
891}
892
893////////////////////////////////////////////////////////////////////////////////
894/// Handle motion events in resizer (resize associated MDI window).
895
897{
898 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
899
900 fOldX = fNewX;
901 fOldY = fNewY;
902 fOldW = fNewW;
903 fOldH = fNewH;
904
905 Int_t dy = event->fYRoot - fY0;
906
907 if (!fLeftButPressed) return kTRUE;
908
909 switch (fPos) {
910 case kMdiResizerTop:
911 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
912 fNewY = fWinY + dy;
913 fNewH = fWinH - dy;
914 break;
915
917 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
918 fNewY = fWinY;
919 fNewH = fWinH + dy;
920 break;
921 }
922
923 MoveResizeIt();
924
925 return kTRUE;
926}
927
928////////////////////////////////////////////////////////////////////////////////
929/// Draw vertical resizer frame border.
930
932{
933 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
934 if (fPos == kMdiResizerTop) {
935 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 1, fWidth - 1, 1);
936 } else {
937 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fHeight - 2, fWidth - 1,
938 fHeight - 2);
939 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1, fWidth - 1,
940 fHeight - 1);
941 }
942}
943
944
945////////////////////////////////////////////////////////////////////////////////
946/// TGMdiCornerWinResizer constructor.
947
949 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
950 Int_t mdioptions, Int_t w, Int_t h) :
951 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
953{
954 Cursor_t defaultCursor = kNone;
956
957 switch (fPos) {
959 defaultCursor = gVirtualX->CreateCursor(kTopLeft);
960 break;
961
963 defaultCursor = gVirtualX->CreateCursor(kBottomLeft);
964 break;
965
967 defaultCursor = gVirtualX->CreateCursor(kTopRight);
968 break;
969
971 defaultCursor = gVirtualX->CreateCursor(kBottomRight);
972 break;
973 }
974 gVirtualX->SetCursor(fId, defaultCursor);
975}
976
977////////////////////////////////////////////////////////////////////////////////
978/// Handle motion events in resizer (resize associated MDI window).
979
981{
982 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
983
984 fOldX = fNewX;
985 fOldY = fNewY;
986 fOldW = fNewW;
987 fOldH = fNewH;
988
989 Int_t dx = event->fXRoot - fX0;
990 Int_t dy = event->fYRoot - fY0;
991
992 if (!fLeftButPressed) return kTRUE;
993
994 switch (fPos) {
996 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
997 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
998 fNewX = fWinX + dx;
999 fNewW = fWinW - dx;
1000 fNewY = fWinY + dy;
1001 fNewH = fWinH - dy;
1002 break;
1003
1005 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
1006 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
1007 fNewX = fWinX + dx;
1008 fNewW = fWinW - dx;
1009 fNewY = fWinY;
1010 fNewH = fWinH + dy;
1011 break;
1012
1014 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1015 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
1016 fNewX = fWinX;
1017 fNewW = fWinW + dx;
1018 fNewY = fWinY + dy;
1019 fNewH = fWinH - dy;
1020 break;
1021
1023 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1024 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
1025 fNewX = fWinX;
1026 fNewW = fWinW + dx;
1027 fNewY = fWinY;
1028 fNewH = fWinH + dy;
1029 break;
1030 }
1031
1032 MoveResizeIt();
1033
1034 return kTRUE;
1035}
1036
1037////////////////////////////////////////////////////////////////////////////////
1038/// Draw corner resizer frame border.
1039
1041{
1042 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
1043
1044 switch (fPos) {
1046 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth - 1, 1);
1047 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight - 1);
1048 break;
1049
1051 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 0, 1, fHeight - 1);
1052 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fHeight - 2,
1053 fWidth - 1, fHeight - 2);
1054 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1,
1055 fWidth - 1, fHeight - 1);
1056 break;
1057
1059 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 1, fWidth - 1, 1);
1060 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 1,
1061 fWidth - 2, fHeight - 1);
1062 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0,
1063 fWidth - 1, fHeight - 1);
1064 break;
1065
1067 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 0,
1068 fWidth - 2, fHeight - 2);
1069 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fHeight - 2,
1070 fWidth - 1, fHeight - 2);
1071 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0,
1072 fWidth - 1, fHeight - 1);
1073 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1,
1074 fWidth - 1, fHeight - 1);
1075 break;
1076 }
1077}
1078
1079
1080////////////////////////////////////////////////////////////////////////////////
1081/// TGMdiHorizontalWinResizer constructor.
1082
1084 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
1085 Int_t mdioptions, Int_t w, Int_t h) :
1086 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
1088{
1090 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kArrowHor));
1091 SetWindowName();
1092}
1093
1094////////////////////////////////////////////////////////////////////////////////
1095/// Handle motion events in resizer (resize associated MDI window).
1096
1098{
1099 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
1100
1101 fOldX = fNewX;
1102 fOldY = fNewY;
1103 fOldW = fNewW;
1104 fOldH = fNewH;
1105
1106 Int_t dx = event->fXRoot - fX0;
1107
1108 if (!fLeftButPressed) return kTRUE;
1109
1110 switch (fPos) {
1111 case (kMdiResizerLeft):
1112 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
1113 fNewX = fWinX + dx;
1114 fNewW = fWinW - dx;
1115 break;
1116
1117 case (kMdiResizerRight):
1118 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1119 fNewX = fWinX;
1120 fNewW = fWinW + dx;
1121 break;
1122 }
1123
1124 MoveResizeIt();
1125
1126 return kTRUE;
1127}
1128
1129////////////////////////////////////////////////////////////////////////////////
1130/// Draw horizontal resizer frame border.
1131
1133{
1134 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
1135 if (fPos == kMdiResizerLeft) {
1136 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 0, 1, fHeight - 1);
1137 } else {
1138 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 0, fWidth - 2, fHeight - 1);
1139 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0, fWidth - 1, fHeight - 1);
1140 }
1141}
@ kButtonPress
Definition GuiTypes.h:60
Handle_t Cursor_t
Cursor handle.
Definition GuiTypes.h:34
const Mask_t kButtonMotionMask
Definition GuiTypes.h:164
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kVerticalFrame
Definition GuiTypes.h:381
@ kFixedWidth
Definition GuiTypes.h:387
@ kHorizontalFrame
Definition GuiTypes.h:382
@ kFixedHeight
Definition GuiTypes.h:389
@ kFixedSize
Definition GuiTypes.h:390
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
@ kTopLeft
Definition GuiTypes.h:372
@ kBottomRight
Definition GuiTypes.h:372
@ kArrowVer
Definition GuiTypes.h:374
@ kMove
Definition GuiTypes.h:374
@ kTopRight
Definition GuiTypes.h:372
@ kBottomLeft
Definition GuiTypes.h:372
@ kArrowHor
Definition GuiTypes.h:374
@ kPointer
Definition GuiTypes.h:375
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton2
Definition GuiTypes.h:214
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
long Long_t
Definition RtypesCore.h:54
const Bool_t kTRUE
Definition RtypesCore.h:91
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kDeepCleanup
Definition TGFrame.h:50
@ kLHintsRight
Definition TGLayout.h:33
@ kLHintsExpandY
Definition TGLayout.h:38
@ kLHintsLeft
Definition TGLayout.h:31
@ kLHintsCenterY
Definition TGLayout.h:35
@ kLHintsNormal
Definition TGLayout.h:39
@ kLHintsExpandX
Definition TGLayout.h:37
@ kMdiResizerRight
@ kMdiResizerLeft
@ kMdiResizerBottom
@ kMdiResizerTop
@ kMdiOpaque
@ kMdiMinimize
@ kMdiMove
@ kMdiHelp
@ kMdiMenu
@ kMdiSize
@ kMdiRestore
@ kMdiMaximize
@ kMdiClose
@ kMdiDefaultHints
@ kTextLeft
Definition TGWidget.h:33
@ kWidgetIsEnabled
Definition TGWidget.h:47
char name[80]
Definition TGX11.cxx:110
#define gVirtualX
Definition TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
EWidgetMessageTypes
@ kMDI_CLOSE
@ kCM_MENU
@ kC_COMMAND
@ kCM_BUTTON
@ kMDI_CURRENT
@ kMDI_MAXIMIZE
Int_t GET_SUBMSG(Long_t val)
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:398
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
virtual void SetHsbPosition(Int_t newPos)
Set position of horizontal scrollbar.
TGViewPort * GetViewPort() const
Definition TGCanvas.h:227
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:347
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:371
virtual TGFrame * GetFrameFromPoint(Int_t x, Int_t y)
Get frame located at specified point.
Definition TGFrame.cxx:1293
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1102
virtual void Layout()
Layout the elements of the composite frame.
Definition TGFrame.cxx:1242
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1057
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:352
virtual Bool_t TranslateCoordinates(TGFrame *child, Int_t x, Int_t y, Int_t &fx, Int_t &fy)
Translate coordinates to child frame.
Definition TGFrame.cxx:1317
virtual Int_t MustCleanup() const
Definition TGFrame.h:397
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1149
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1189
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:350
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1134
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1175
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:324
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:720
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:333
virtual void ReparentWindow(const TGWindow *p, Int_t x=0, Int_t y=0)
Reparent window, make p the new parent and position the window at position (x,y) in new parent.
Definition TGFrame.h:226
UInt_t fHeight
Definition TGFrame.h:112
Int_t fBorderWidth
Definition TGFrame.h:117
virtual void Activate(Bool_t)
Definition TGFrame.h:234
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:740
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:297
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition TGFrame.cxx:630
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:750
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition TGFrame.cxx:578
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:590
UInt_t fWidth
Definition TGFrame.h:111
UInt_t GetHeight() const
Definition TGFrame.h:249
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition TGFrame.cxx:614
virtual void MapWindow()
map window
Definition TGFrame.h:228
UInt_t GetWidth() const
Definition TGFrame.h:248
Definition TGGC.h:31
GContext_t GetGC() const
Definition TGGC.h:50
virtual void DoRedraw()
Redraw picture.
Definition TGIcon.cxx:125
virtual void SetPicture(const TGPicture *pic)
Set icon picture.
Definition TGIcon.cxx:78
void SetTextJustify(Int_t tmode)
Set text justification.
Definition TGLabel.cxx:395
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGLabel.cxx:361
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:179
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition TGLabel.cxx:323
TGPictureButton * fButton[5]
TGPictureButton * GetButton(Int_t no) const
TGMdiButtons(const TGWindow *p, const TGWindow *titlebar)
TGMdiButtons constructor.
TGLayoutHints * fCloseHint
virtual ~TGMdiButtons()
TGMdiButtons destructor.
TGLayoutHints * fDefaultHint
const TGWindow * fMsgWindow
virtual Bool_t HandleMotion(Event_t *event)
Handle motion events in resizer (resize associated MDI window).
TGMdiCornerWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=20, Int_t h=20)
TGMdiCornerWinResizer constructor.
virtual void DrawBorder()
Draw corner resizer frame border.
TGMdiTitleBar * fTitlebar
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move the MDI window at position x, y and set size to w, h.
TGMdiVerticalWinResizer * fUpperHR
virtual void Layout()
Recalculates the postion and the size of all decor frame components.
Bool_t IsMaximized() const
Bool_t IsMinimized() const
TGLayoutHints * fExpandHint
TGMdiVerticalWinResizer * fLowerHR
void SetResizeMode(Int_t mode=kMdiDefaultResizeMode)
Set resize mode (opaque or transparent)
virtual ~TGMdiDecorFrame()
TGMdiDecorFrame destructor.
TGMdiCornerWinResizer * fUpperLeftCR
TGMdiHorizontalWinResizer * fLeftVR
TGLayoutHints * fLHint
Bool_t fMinimizedUserPlacement
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button events.
void SetWindowName(const char *name)
Set MDI Window name (appearing in the title bar)
TGMdiMainFrame * fMdiMainFrame
void SetWindowIcon(const TGPicture *pic)
Set Window icon (appearing in the title bar)
TGMdiFrame * fFrame
TGMdiDecorFrame(TGMdiMainFrame *main, TGMdiFrame *frame, Int_t w, Int_t h, const TGGC *boxGC, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
TGMdiDecorFrame constructor.
virtual void Move(Int_t x, Int_t y)
Move the MDI window at position x, y.
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handle configure notify event.
void SetMdiButtons(ULong_t buttons)
Set-up MDI buttons.
TGMdiCornerWinResizer * fLowerRightCR
TGMdiCornerWinResizer * fUpperRightCR
void SetDecorBorderWidth(Int_t bw)
Set border width of the decor.
TGMdiCornerWinResizer * fLowerLeftCR
TGMdiHorizontalWinResizer * fRightVR
virtual Bool_t HandleMotion(Event_t *event)
Handle motion events in resizer (resize associated MDI window).
TGMdiHorizontalWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=5, Int_t h=4)
TGMdiHorizontalWinResizer constructor.
virtual void DrawBorder()
Draw horizontal resizer frame border.
virtual void Layout()
Recalculates the postion and the size of all MDI child windows.
void LayoutButtons(UInt_t buttonmask, Bool_t isMinimized, Bool_t isMaximized)
Recalculates the position of every enabled (displayed) buttons.
TGMdiTitleIcon * GetWinIcon() const
TGLayoutHints * fLeftHint
void SetTitleBarColors(UInt_t fore, UInt_t back, TGFont *f)
Set title bar color (blue or grey, depends on active state).
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events in title bar (used to move MDI window).
TGLabel * GetWinName() const
TGLayoutHints * fMiddleHint
TGMdiTitleBar(const TGWindow *p, const TGWindow *mdiwin, const char *name="Untitled")
TGMdiTitleBar constructor.
virtual ~TGMdiTitleBar()
TGMdiTitleBar destructor.
void RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Maximize().
TGCompositeFrame * fLFrame
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in title bar (maximize window)
void AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Restore().
const TGWindow * fMdiWin
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages for title bar.
TGCompositeFrame * fMFrame
TGMdiTitleIcon * fWinIcon
TGMdiButtons * fButtons
TGCompositeFrame * fRFrame
TGLayoutHints * fLHint
virtual Bool_t HandleButton(Event_t *event)
Handle mouse click on title bar.
TGLayoutHints * fRightHint
virtual Bool_t HandleButton(Event_t *event)
Handle button event on MDI icon (popup menu)
TGMdiTitleIcon(const TGWindow *p, const TGWindow *titlebar, const TGPicture *pic, Int_t w, Int_t h)
TGMdiTitleIcon constructor.
virtual ~TGMdiTitleIcon()
TGMdiTitleIcon destructor.
virtual void DoRedraw()
Redraw icon.
TGPopupMenu * GetPopup() const
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click event on MDI icon (close the window)
const TGWindow * fMsgWindow
TGPopupMenu * fPopup
virtual void DrawBorder()
Draw vertical resizer frame border.
TGMdiVerticalWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=4, Int_t h=5)
TGMdiVerticalWinResizer constructor.
virtual Bool_t HandleMotion(Event_t *event)
Handle motion events in resizer (resize associated MDI window).
const TGGC * fBoxGC
virtual Bool_t HandleButton(Event_t *event)
Handle button events in resizer (grab button and resize).
TGMdiWinResizer(const TGWindow *p, const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew, Int_t mdioptions=kMdiDefaultResizeMode, Int_t w=1, Int_t h=1, UInt_t options=kOwnBackground)
TGMdiWinResizer constructor.
const TGWindow * fMdiWin
void MoveResizeIt()
Move (resize) parent MDI window.
void SetResizeMode(Int_t mode)
void SetMinSize(Int_t w=50, Int_t h=20)
void DrawBox(Int_t x, Int_t y, UInt_t width, UInt_t height)
Draw resize box (rectangle).
TGClient * fClient
Definition TGObject.h:37
Handle_t GetId() const
Definition TGObject.h:47
Handle_t fId
Definition TGObject.h:36
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1723
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1704
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:219
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1288
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1059
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=nullptr, const TGPicture *p=nullptr, TGMenuEntry *before=nullptr)
Add a menu entry.
Definition TGMenu.cxx:989
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1240
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:82
Int_t fWidgetFlags
Definition TGWidget.h:57
Bool_t IsEnabled() const
Definition TGWidget.h:79
virtual void SetWindowName(const char *name=0)
Set window name.
Definition TGWindow.cxx:128
const TGWindow * fParent
Definition TGWindow.h:36
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition TGWindow.cxx:286
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:191
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:294
virtual void RaiseWindow()
raise window
Definition TGWindow.cxx:207
UInt_t fEditDisabled
Definition TGWindow.h:40
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
int main()
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Int_t fXRoot
Definition GuiTypes.h:179
UInt_t fWidth
Definition GuiTypes.h:182
UInt_t fHeight
width and height of exposed area
Definition GuiTypes.h:182
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:180
auto * m
Definition textangle.C:8