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/** \class TGMdiDecorFrame
35 \ingroup guiwidgets
36
37This file contains all different MDI frame decoration classes.
38
39*/
40
41
42#include <cstdio>
43#include <cstdlib>
44
45#include "KeySymbols.h"
46#include "TGResourcePool.h"
47#include "TGDimension.h"
48#include "WidgetMessageTypes.h"
49#include "TGMdiFrame.h"
50#include "TGMdiDecorFrame.h"
51#include "TGMdiMainFrame.h"
52#include "TVirtualX.h"
53
54
63
64////////////////////////////////////////////////////////////////////////////////
65/// TGMdiDecorFrame constructor.
66/// The TGMdiDecorFrame is the frame containing MDI decorations like
67/// title bar, minimize, maximize, restore and close buttons, and resizers.
68
70 Int_t w, Int_t h, const TGGC *boxGC,
71 UInt_t options, Pixel_t back) :
72 TGCompositeFrame(main->GetContainer(), w, h,
73 options | kOwnBackground | kVerticalFrame | kFixedSize, back)
74{
75
77 fEditDisabled = 1;
78 fFrame = frame;
84
86
88
91
94
96 boxGC, kMdiBorderWidth);
98 boxGC, kMdiBorderWidth);
100 boxGC, kMdiBorderWidth);
102 boxGC, kMdiBorderWidth);
103
106 boxGC, kMdiBorderWidth);
109 boxGC, kMdiBorderWidth);
112 boxGC, kMdiBorderWidth);
115 boxGC, kMdiBorderWidth);
116
125
127
129 fFrame->fParent = this;
131
134 Layout();
135
136 MapWindow();
138
141}
142
143////////////////////////////////////////////////////////////////////////////////
144/// TGMdiDecorFrame destructor.
145
147{
148 if (!MustCleanup()) {
149 delete fUpperHR;
150 delete fLowerHR;
151 delete fLeftVR;
152 delete fRightVR;
153 delete fUpperLeftCR;
154 delete fLowerLeftCR;
155 delete fUpperRightCR;
156 delete fLowerRightCR;
157 }
159}
160
161////////////////////////////////////////////////////////////////////////////////
162/// Set border width of the decor.
163
165{
166 fBorderWidth = bw;
167}
168
169////////////////////////////////////////////////////////////////////////////////
170/// Set-up MDI buttons.
171
173{
174 fButtonMask = buttons;
176 if (fButtonMask & kMdiSize) {
185 } else {
194 }
195}
196
197////////////////////////////////////////////////////////////////////////////////
198/// Set resize mode (opaque or transparent)
199
201{
202 fUpperHR->SetResizeMode(mode);
203 fLowerHR->SetResizeMode(mode);
204 fLeftVR->SetResizeMode(mode);
205 fRightVR->SetResizeMode(mode);
210}
211
212////////////////////////////////////////////////////////////////////////////////
213/// Recalculates the postion and the size of all decor frame components.
214
216{
220
221 if (fIsMaximized == kFALSE) {
222 fUpperLeftCR->Move(0, 0);
227
242 }
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Set MDI Window name (appearing in the title bar)
247
249{
251 fTitlebar->Layout();
252}
253
254////////////////////////////////////////////////////////////////////////////////
255/// Set Window icon (appearing in the title bar)
256
258{
261}
262
263////////////////////////////////////////////////////////////////////////////////
264/// Move the MDI window at position x, y.
265
267{
268 if (x < 0) {
270 }
271 if (y < 0) {
273 }
277}
278
279////////////////////////////////////////////////////////////////////////////////
280/// Move the MDI window at position x, y and set size to w, h.
281
283{
284 if (x < 0) {
286 }
287 if (y < 0) {
289 }
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Handle configure notify event.
297
299{
300 if ((event->fX < 0) || (event->fY < 0) ||
301 (event->fX + event->fWidth > fMdiMainFrame->GetViewPort()->GetWidth()) ||
302 (event->fY + event->fHeight > fMdiMainFrame->GetViewPort()->GetHeight())) {
304 }
305
306 if (event->fWindow == fFrame->GetId()) {
307 UInt_t newW = event->fWidth + 2 * fBorderWidth;
308 UInt_t newH = event->fHeight + 2 * fBorderWidth +
310
311 if ((fWidth != newW) || (fHeight != newH)) {
312 Resize(newW, newH);
313 }
315 return kTRUE;
316 }
318 return kFALSE;
319}
320
321////////////////////////////////////////////////////////////////////////////////
322/// Handle mouse button events.
323
325{
326 if (event->fType == kButtonPress) {
327 void *ud;
330 }
331 return kTRUE;
332}
333
334
335////////////////////////////////////////////////////////////////////////////////
336/// TGMdiTitleBar constructor.
337/// the TGMdiTitleBar is the frame containing a title (window name)
338/// an icon and MDI picture buttons as minimize, maximize, restore,
339/// close and help.
340
342 const char *name) :
344{
345 fMdiWin = mdiwin;
347 fWinName = 0;
349
351
354 //fMiddleHint = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 1, 1, 1);
357
358 fLFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
359 fMFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
360 fRFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
364
365 fWinIcon = new TGMdiTitleIcon(fLFrame, this,
366 fClient->GetPicture("mdi_default.xpm"),
367 16, 16);
369
370 fWinName = new TGLabel(fMFrame, new TGString(name));
373
374 fButtons = new TGMdiButtons(fRFrame, this);
376
377 MapWindow();
379 Layout();
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// TGMdiTitleBar destructor.
385
387{
388 if (!MustCleanup()) {
389 delete fLHint;
390 delete fLeftHint;
391 delete fMiddleHint;
392 delete fRightHint;
393 }
394}
395
396////////////////////////////////////////////////////////////////////////////////
397/// Recalculates the position of every enabled (displayed) buttons.
398
399void TGMdiTitleBar::LayoutButtons(UInt_t buttonmask,Bool_t isMinimized,
400 Bool_t isMaximized)
401{
403
404 if (buttonmask & kMdiSize) {
406 } else {
408 }
409
410 if (buttonmask & kMdiMenu) {
412 } else {
414 }
415
416 if (buttonmask & kMdiClose) {
419 } else {
422 }
423
424 if (buttonmask & kMdiHelp) {
426 } else {
428 }
429
430 if ((buttonmask & kMdiMaximize) && (!isMaximized)) {
433 } else {
436 }
437
438 if (isMinimized | isMaximized) {
442 if (isMaximized) fWinIcon->GetPopup()->DisableEntry(kMdiMove);
443 } else {
446 }
447
448 if ((buttonmask & kMdiMinimize) && (!isMinimized)) {
451 } else {
454 }
455
456 Layout();
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// Set title bar color (blue or grey, depends on active state).
461
463{
464 SetBackgroundColor(back);
465
466 fClient->GetFont(font->GetName());
467 fWinName->SetTextFont(font);
473 Layout();
474 fClient->NeedRedraw(this);
480}
481
482////////////////////////////////////////////////////////////////////////////////
483/// Handle double click in title bar (maximize window)
484
486{
487 if ((event->fType == kButtonPress) && (event->fCode == kButton1)) {
489 }
490 return kTRUE;
491}
492
493////////////////////////////////////////////////////////////////////////////////
494/// Handle mouse click on title bar.
495
497{
498 if (event->fType == kButtonPress) {
499 void *ud;
500 GetWinIcon()->GetPopup()->EndMenu(ud);
501 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kMove));
502 switch (event->fCode) {
503 case kButton1:
504 fX0 = event->fX;
505 fY0 = event->fY;
508 break;
509
510 case kButton2:
512 break;
513
514 case kButton3:
515 gVirtualX->LowerWindow(fParent->GetId());
517 break;
518 }
519 } else {
520 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
521 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
522 switch (event->fCode) {
523
524 case kButton1:
525 //if (!fClient->IsEditable()) ((TGMainFrame *)((TGMdiMainFrame *)fMdiWin)->GetMainFrame())->Layout();
527 break;
528
529 case kButton2:
531 break;
532
533 case kButton3:
535 break;
536 }
537
539 if (f && (f != this)) {
540 TranslateCoordinates(f, event->fX, event->fY, event->fX, event->fY);
541 f->HandleButton(event);
542 }
543 }
544 return kTRUE;
545}
546
547////////////////////////////////////////////////////////////////////////////////
548/// Process messages for title bar.
549
551{
552 switch (GET_MSG(msg)) {
553 case kC_COMMAND:
554 switch (GET_SUBMSG(msg)) {
555 case kCM_BUTTON:
556 case kCM_MENU:
558 fParent->GetId(), parm2);
559 break;
560 }
561 break;
562 }
563 return kTRUE;
564}
565
566////////////////////////////////////////////////////////////////////////////////
567/// Handle mouse motion events in title bar (used to move MDI window).
568
570{
571 if (event->fWindow != fId) return kTRUE;
572 if (!fLeftButPressed) return kTRUE;
573
574 Int_t x = ((TGFrame *)fParent)->GetX();
575 Int_t y = ((TGFrame *)fParent)->GetY();
576 ((TGFrame *)fParent)->Move(x + event->fX - fX0, y + event->fY - fY0);
577
578 return kTRUE;
579}
580
581
582////////////////////////////////////////////////////////////////////////////////
583/// This is called from TGMdiMainFrame on Restore().
584
586{
587 icon->ReparentWindow(fLFrame);
588 buttons->ReparentWindow(fRFrame);
589 fLFrame->AddFrame(icon, fLHint);
590 fLFrame->ShowFrame(icon);
591 fRFrame->AddFrame(buttons, fLHint);
592 fRFrame->ShowFrame(buttons);
593}
594
595
596////////////////////////////////////////////////////////////////////////////////
597/// This is called from TGMdiMainFrame on Maximize().
598
600{
601 fLFrame->RemoveFrame(icon);
602 fRFrame->RemoveFrame(buttons);
603}
604
605
606////////////////////////////////////////////////////////////////////////////////
607/// TGMdiButtons constructor.
608/// the TGMdiButtons is the frame containing MDI picture buttons like
609/// minimize, maximize, restore, close and help.
610
611TGMdiButtons::TGMdiButtons(const TGWindow *p, const TGWindow *titlebar) :
613{
614 fDefaultHint = new TGLayoutHints(kLHintsNormal, 0, 0, 1, 0);
615 fCloseHint = new TGLayoutHints(kLHintsNormal, 2, 0, 1, 0);
617 fMsgWindow = 0;
618
619 //--- Minimize button
620
621 fButton[0] = new TGPictureButton(this,
622 fClient->GetPicture("mdi_minimize.xpm"),
624 fButton[0]->SetToolTipText("Minimize");
627 fButton[0]->Associate(titlebar);
628
629 //--- Restore button
630
631 fButton[1] = new TGPictureButton(this,
632 fClient->GetPicture("mdi_restore.xpm"),
634 fButton[1]->SetToolTipText("Restore");
637 fButton[1]->Associate(titlebar);
638
639 //--- Maximize button
640
641 fButton[2] = new TGPictureButton(this,
642 fClient->GetPicture("mdi_maximize.xpm"),
644 fButton[2]->SetToolTipText("Maximize");
647 fButton[2]->Associate(titlebar);
648
649 //--- Help button
650
651 fButton[3] = new TGPictureButton(this,
652 fClient->GetPicture("mdi_help.xpm"),
653 kMdiHelp);
654 fButton[3]->SetToolTipText("Help");
657 fButton[3]->Associate(titlebar);
658
659 //--- Close button
660
661 fButton[4] = new TGPictureButton(this,
662 fClient->GetPicture("mdi_close.xpm"),
663 kMdiClose);
664 fButton[4]->SetToolTipText("Close");
667 fButton[4]->Associate(titlebar);
669}
670
671////////////////////////////////////////////////////////////////////////////////
672/// TGMdiButtons destructor.
673
675{
676 if (!MustCleanup()) {
677 delete fDefaultHint;
678 delete fCloseHint;
679 }
680}
681
682////////////////////////////////////////////////////////////////////////////////
683/// TGMdiTitleIcon constructor.
684/// the TGMdiTitleIcon is the left icon used also for the MDI
685/// popup menu allowing access to MDI commands as : restore,
686/// move, size, minimize and close.
687
689 const TGPicture *pic, Int_t w, Int_t h) :
690 TGIcon(p, pic, w, h)
691{
692 fMsgWindow = titlebar;
694
695 //--- MDI system menu
696
697 fPopup = new TGPopupMenu(fClient->GetDefaultRoot());// fClient->GetRoot());
698 fPopup->AddEntry(new TGHotString("&Restore"), kMdiRestore);
699 fPopup->AddEntry(new TGHotString("&Move"), kMdiMove);
700 fPopup->AddEntry(new TGHotString("&Size"), kMdiSize);
701 fPopup->AddEntry(new TGHotString("Mi&nimize"), kMdiMinimize);
702 fPopup->AddEntry(new TGHotString("Ma&ximize"), kMdiMaximize);
704 fPopup->AddEntry(new TGHotString("&Close Ctrl+F4"), kMdiClose);
706 fPopup->Associate(titlebar);
707
710}
711
712////////////////////////////////////////////////////////////////////////////////
713/// TGMdiTitleIcon destructor.
714
716{
717 delete fPopup;
718}
719
720////////////////////////////////////////////////////////////////////////////////
721/// Redraw icon.
722
724{
725 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
727}
728
729////////////////////////////////////////////////////////////////////////////////
730/// Handle double click event on MDI icon (close the window)
731
733{
734 if (event->fCode == kButton1) {
735 void *ud;
736 fPopup->EndMenu(ud);
737 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
739 }
740 return kTRUE;
741}
742
743////////////////////////////////////////////////////////////////////////////////
744/// Handle button event on MDI icon (popup menu)
745
747{
749
750 if (event->fType == kButtonPress) {
751 fPopup->PlaceMenu(event->fXRoot - event->fX,
752 event->fYRoot + (fHeight - event->fY),
753 kTRUE, kTRUE);
754 }
755 return kTRUE;
756}
757
758
759////////////////////////////////////////////////////////////////////////////////
760/// TGMdiWinResizer constructor.
761/// The TGMdiWinResizer is a frame allowing to resize MDI window.
762/// Could be horizontal, vertical or corner resizer (see derived classes
763/// TGMdiVerticalWinResizer, TGMdiHorizontalWinResizer, and
764/// TGMdiCornerWinResizer).
765
767 Int_t pos, const TGGC *boxgc, Int_t linew,
768 Int_t mdioptions, Int_t w, Int_t h, UInt_t options) :
769 TGFrame(p, w, h, options)
770{
771 fWinX = fWinY = fWinW = fWinH = fOldX = fOldY = fOldW = fOldH = 0;
772 fNewX = fNewY = fNewW = fNewH = fX0 = fY0 = 0;
773
775
776 fMdiWin = mdiwin;
777 fMdiOptions = mdioptions;
778 fPos = pos;
779
780 fBoxGC = boxgc;
781 fLineW = linew;
782
783 fMinW = 50;
784 fMinH = 20;
785
787
788 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
790 kNone, kNone);
792}
793
794////////////////////////////////////////////////////////////////////////////////
795/// Handle button events in resizer (grab button and resize).
796
798{
799 if (!IsEnabled()) return kTRUE;
800
801 if (event->fType == kButtonPress) {
802 void *ud;
803 ((TGMdiDecorFrame *)fParent)->GetTitleBar()->GetWinIcon()->GetPopup()->EndMenu(ud);
804 switch (event->fCode) {
805 case kButton1:
807 fNewX = fOldX = fWinX = ((TGFrame *)fParent)->GetX();
808 fNewY = fOldY = fWinY = ((TGFrame *)fParent)->GetY();
809 fWinW = ((TGFrame *)fParent)->GetWidth();
810 fWinH = ((TGFrame *)fParent)->GetHeight();
811 fX0 = event->fXRoot;
812 fY0 = event->fYRoot;
813 fNewW = fWinW;
814 fNewH = fWinH;
815 if (fMdiOptions != kMdiOpaque) {
817 }
821 break;
822
823 case kButton2:
825 break;
826
827 case kButton3:
829 break;
830 }
831 } else {
832 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
833 switch (event->fCode) {
834 case kButton1:
835 if (fMdiOptions != kMdiOpaque) {
837 ((TGFrame *)fParent)->MoveResize(fNewX, fNewY, fNewW, fNewH);
838 }
839 //if (!fClient->IsEditable()) ((TGMainFrame *)((TGMdiMainFrame *)fMdiWin)->GetMainFrame())->Layout();
841 break;
842
843 case kButton2:
845 break;
846
847 case kButton3:
849 break;
850 }
851 }
852 return kTRUE;
853}
854
855////////////////////////////////////////////////////////////////////////////////
856/// Draw resize box (rectangle).
857
859{
861
862 gVirtualX->DrawRectangle(m->GetContainer()->GetId(), fBoxGC->GetGC(),
863 x + fLineW / 2, y + fLineW / 2, width - fLineW, height - fLineW);
864}
865
866////////////////////////////////////////////////////////////////////////////////
867/// Move (resize) parent MDI window.
868
870{
871 if (fMdiOptions == kMdiOpaque) {
873 } else {
876 }
877}
878
879
880////////////////////////////////////////////////////////////////////////////////
881/// TGMdiVerticalWinResizer constructor.
882
884 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
885 Int_t mdioptions, Int_t w, Int_t h) :
886 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
888{
889 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kArrowVer));
890}
891
892////////////////////////////////////////////////////////////////////////////////
893/// Handle motion events in resizer (resize associated MDI window).
894
896{
897 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
898
899 fOldX = fNewX;
900 fOldY = fNewY;
901 fOldW = fNewW;
902 fOldH = fNewH;
903
904 Int_t dy = event->fYRoot - fY0;
905
906 if (!fLeftButPressed) return kTRUE;
907
908 switch (fPos) {
909 case kMdiResizerTop:
910 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
911 fNewY = fWinY + dy;
912 fNewH = fWinH - dy;
913 break;
914
916 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
917 fNewY = fWinY;
918 fNewH = fWinH + dy;
919 break;
920 }
921
922 MoveResizeIt();
923
924 return kTRUE;
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Draw vertical resizer frame border.
929
931{
932 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
933 if (fPos == kMdiResizerTop) {
934 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 1, fWidth - 1, 1);
935 } else {
936 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fHeight - 2, fWidth - 1,
937 fHeight - 2);
938 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1, fWidth - 1,
939 fHeight - 1);
940 }
941}
942
943
944////////////////////////////////////////////////////////////////////////////////
945/// TGMdiCornerWinResizer constructor.
946
948 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
949 Int_t mdioptions, Int_t w, Int_t h) :
950 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
952{
953 Cursor_t defaultCursor = kNone;
955
956 switch (fPos) {
958 defaultCursor = gVirtualX->CreateCursor(kTopLeft);
959 break;
960
962 defaultCursor = gVirtualX->CreateCursor(kBottomLeft);
963 break;
964
966 defaultCursor = gVirtualX->CreateCursor(kTopRight);
967 break;
968
970 defaultCursor = gVirtualX->CreateCursor(kBottomRight);
971 break;
972 }
973 gVirtualX->SetCursor(fId, defaultCursor);
974}
975
976////////////////////////////////////////////////////////////////////////////////
977/// Handle motion events in resizer (resize associated MDI window).
978
980{
981 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
982
983 fOldX = fNewX;
984 fOldY = fNewY;
985 fOldW = fNewW;
986 fOldH = fNewH;
987
988 Int_t dx = event->fXRoot - fX0;
989 Int_t dy = event->fYRoot - fY0;
990
991 if (!fLeftButPressed) return kTRUE;
992
993 switch (fPos) {
995 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
996 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
997 fNewX = fWinX + dx;
998 fNewW = fWinW - dx;
999 fNewY = fWinY + dy;
1000 fNewH = fWinH - dy;
1001 break;
1002
1004 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
1005 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
1006 fNewX = fWinX + dx;
1007 fNewW = fWinW - dx;
1008 fNewY = fWinY;
1009 fNewH = fWinH + dy;
1010 break;
1011
1013 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1014 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
1015 fNewX = fWinX;
1016 fNewW = fWinW + dx;
1017 fNewY = fWinY + dy;
1018 fNewH = fWinH - dy;
1019 break;
1020
1022 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1023 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
1024 fNewX = fWinX;
1025 fNewW = fWinW + dx;
1026 fNewY = fWinY;
1027 fNewH = fWinH + dy;
1028 break;
1029 }
1030
1031 MoveResizeIt();
1032
1033 return kTRUE;
1034}
1035
1036////////////////////////////////////////////////////////////////////////////////
1037/// Draw corner resizer frame border.
1038
1040{
1041 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
1042
1043 switch (fPos) {
1045 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth - 1, 1);
1046 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight - 1);
1047 break;
1048
1050 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 0, 1, fHeight - 1);
1051 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fHeight - 2,
1052 fWidth - 1, fHeight - 2);
1053 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1,
1054 fWidth - 1, fHeight - 1);
1055 break;
1056
1058 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 1, fWidth - 1, 1);
1059 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 1,
1060 fWidth - 2, fHeight - 1);
1061 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0,
1062 fWidth - 1, fHeight - 1);
1063 break;
1064
1066 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 0,
1067 fWidth - 2, fHeight - 2);
1068 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fHeight - 2,
1069 fWidth - 1, fHeight - 2);
1070 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0,
1071 fWidth - 1, fHeight - 1);
1072 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1,
1073 fWidth - 1, fHeight - 1);
1074 break;
1075 }
1076}
1077
1078
1079////////////////////////////////////////////////////////////////////////////////
1080/// TGMdiHorizontalWinResizer constructor.
1081
1083 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
1084 Int_t mdioptions, Int_t w, Int_t h) :
1085 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
1087{
1089 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kArrowHor));
1090 SetWindowName();
1091}
1092
1093////////////////////////////////////////////////////////////////////////////////
1094/// Handle motion events in resizer (resize associated MDI window).
1095
1097{
1098 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
1099
1100 fOldX = fNewX;
1101 fOldY = fNewY;
1102 fOldW = fNewW;
1103 fOldH = fNewH;
1104
1105 Int_t dx = event->fXRoot - fX0;
1106
1107 if (!fLeftButPressed) return kTRUE;
1108
1109 switch (fPos) {
1110 case (kMdiResizerLeft):
1111 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
1112 fNewX = fWinX + dx;
1113 fNewW = fWinW - dx;
1114 break;
1115
1116 case (kMdiResizerRight):
1117 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1118 fNewX = fWinX;
1119 fNewW = fWinW + dx;
1120 break;
1121 }
1122
1123 MoveResizeIt();
1124
1125 return kTRUE;
1126}
1127
1128////////////////////////////////////////////////////////////////////////////////
1129/// Draw horizontal resizer frame border.
1130
1132{
1133 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
1134 if (fPos == kMdiResizerLeft) {
1135 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 0, 1, fHeight - 1);
1136 } else {
1137 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 0, fWidth - 2, fHeight - 1);
1138 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0, fWidth - 1, fHeight - 1);
1139 }
1140}
@ 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
int main()
Definition Prototype.cxx:12
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
long Longptr_t
Definition RtypesCore.h:82
const Bool_t kFALSE
Definition RtypesCore.h:101
unsigned long ULong_t
Definition RtypesCore.h:55
const Bool_t kTRUE
Definition RtypesCore.h:100
#define ClassImp(name)
Definition Rtypes.h:364
include TDocParser_001 C image html pict1_TDocParser_001 png width
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsExpandX
Definition TGLayout.h:30
@ kMdiResizerRight
@ kMdiResizerLeft
@ kMdiResizerBottom
@ kMdiResizerTop
@ kMdiOpaque
@ kMdiMinimize
@ kMdiMove
@ kMdiHelp
@ kMdiMenu
@ kMdiSize
@ kMdiRestore
@ kMdiMaximize
@ kMdiClose
@ kMdiDefaultHints
@ kTextLeft
Definition TGWidget.h:23
@ kWidgetIsEnabled
Definition TGWidget.h:37
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
WidgetMessageTypes.
@ 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:445
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:217
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:234
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:348
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
virtual TGFrame * GetFrameFromPoint(Int_t x, Int_t y)
Get frame located at specified point.
Definition TGFrame.cxx:1308
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual void Layout()
Layout the elements of the composite frame.
Definition TGFrame.cxx:1257
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1072
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:316
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:1332
virtual Int_t MustCleanup() const
Definition TGFrame.h:361
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1164
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition TGFrame.cxx:1204
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:314
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition TGFrame.cxx:1190
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:339
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:735
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition TGFrame.cxx:348
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:202
UInt_t fHeight
frame height
Definition TGFrame.h:88
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
virtual void Activate(Bool_t)
Definition TGFrame.h:210
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:755
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:312
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition TGFrame.cxx:593
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition TGFrame.cxx:605
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:225
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:629
virtual void MapWindow()
map window
Definition TGFrame.h:204
UInt_t GetWidth() const
Definition TGFrame.h:224
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
GContext_t GetGC() const
Definition TGGC.h:41
TGHotString is a string with a "hot" character underlined.
Definition TGString.h:42
This class handles GUI icons.
Definition TGIcon.h:22
virtual void DoRedraw()
Redraw picture.
Definition TGIcon.cxx:126
virtual void SetPicture(const TGPicture *pic)
Set icon picture.
Definition TGIcon.cxx:79
This class handles GUI labels.
Definition TGLabel.h:24
void SetTextJustify(Int_t tmode)
Set text justification.
Definition TGLabel.cxx:396
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition TGLabel.cxx:362
virtual void SetText(TGString *newText)
Set new text in label.
Definition TGLabel.cxx:180
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition TGLabel.cxx:324
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
TGPictureButton * fButton[5]
MDI picture buttons.
TGPictureButton * GetButton(Int_t no) const
TGMdiButtons(const TGWindow *p, const TGWindow *titlebar)
TGMdiButtons constructor.
TGLayoutHints * fCloseHint
Layout hints.
virtual ~TGMdiButtons()
TGMdiButtons destructor.
TGLayoutHints * fDefaultHint
const TGWindow * fMsgWindow
window handling container messages
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.
This file contains all different MDI frame decoration classes.
TGMdiTitleBar * fTitlebar
MDI window title bar.
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
layout hints
TGMdiVerticalWinResizer * fLowerHR
upper and lower vertical resizers
void SetResizeMode(Int_t mode=kMdiDefaultResizeMode)
Set resize mode (opaque or transparent)
ULong_t fButtonMask
mask used to display/hide buttons
virtual ~TGMdiDecorFrame()
TGMdiDecorFrame destructor.
TGMdiCornerWinResizer * fUpperLeftCR
TGMdiHorizontalWinResizer * fLeftVR
TGLayoutHints * fLHint
Bool_t fIsMaximized
minimized and maximized flags
Bool_t fMinimizedUserPlacement
user placement flag
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
MDI main frame.
void SetWindowIcon(const TGPicture *pic)
Set Window icon (appearing in the title bar)
TGMdiFrame * fFrame
parent (owner) MDI frame
TGMdiDecorFrame(TGMdiMainFrame *main, TGMdiFrame *frame, Int_t w, Int_t h, const TGGC *boxGC, UInt_t options=0, Pixel_t back=GetDefaultFrameBackground())
TGMdiDecorFrame constructor.
Int_t fMinimizedY
minimized position
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
upper right and lower right resizers
TGMdiCornerWinResizer * fUpperRightCR
void SetDecorBorderWidth(Int_t bw)
Set border width of the decor.
TGMdiCornerWinResizer * fLowerLeftCR
upper left and lower left resizers
TGMdiHorizontalWinResizer * fRightVR
left and right horizontal resizers
This file contains the TGMdiFrame class.
Definition TGMdiFrame.h:44
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.
This file contains the TGMdiMainFrame class.
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 ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Process messages for title bar.
Int_t fY0
initial position of the mouse click
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click in title bar (maximize window)
Bool_t fMidButPressed
mouse button pressed
void AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
This is called from TGMdiMainFrame on Restore().
TGLabel * fWinName
window name label
const TGWindow * fMdiWin
owner MDI window
TGCompositeFrame * fMFrame
TGMdiTitleIcon * fWinIcon
title icon
TGMdiButtons * fButtons
MDI buttons.
TGCompositeFrame * fRFrame
the three parts of the title bar
TGLayoutHints * fLHint
virtual Bool_t HandleButton(Event_t *event)
Handle mouse click on title bar.
TGLayoutHints * fRightHint
layout hints
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
window handling container messages
TGPopupMenu * fPopup
Popup menu associated to the title icon.
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).
Int_t fPos
position of the resizer
const TGGC * fBoxGC
GC used for resizing rectangle.
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.
Int_t fNewH
new MDI win position and dimension
Int_t fMdiOptions
MDI options.
Int_t fLineW
line width of resizing rectangle
const TGWindow * fMdiWin
owner MDI Window
void MoveResizeIt()
Move (resize) parent MDI window.
void SetResizeMode(Int_t mode)
Int_t fY0
initial position of the mouse click
Bool_t fMidButPressed
mouse buttons flags
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).
Int_t fWinH
MDI win position and dimension.
Int_t fOldH
old MDI win position and dimension
Int_t fMinH
Min width and height of the MDI Win.
TGClient * fClient
Connection to display server.
Definition TGObject.h:27
Handle_t GetId() const
Definition TGObject.h:37
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:26
Yield an action as soon as it is clicked.
Definition TGButton.h:228
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
This class creates a popup menu object.
Definition TGMenu.h:110
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition TGMenu.cxx:1724
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition TGMenu.cxx:1705
virtual void Associate(const TGWindow *w)
Definition TGMenu.h:206
virtual Int_t EndMenu(void *&userData)
Close menu and return ID of selected menu item.
Definition TGMenu.cxx:1289
virtual void AddSeparator(TGMenuEntry *before=nullptr)
Add a menu separator to the menu.
Definition TGMenu.cxx:1060
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:990
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition TGMenu.cxx:1241
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
Int_t fWidgetFlags
widget status flags (OR of EWidgetStatus)
Definition TGWidget.h:47
Bool_t IsEnabled() const
Definition TGWidget.h:69
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void SetWindowName(const char *name=0)
Set window name.
Definition TGWindow.cxx:129
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual void MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
Move and resize the window.
Definition TGWindow.cxx:287
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:192
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:295
virtual void RaiseWindow()
raise window
Definition TGWindow.cxx:208
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
Event structure.
Definition GuiTypes.h:174
auto * m
Definition textangle.C:8