Logo ROOT  
Reference Guide
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 <stdio.h>
44#include <stdlib.h>
45
46#include "TROOT.h"
47#include "KeySymbols.h"
48#include "TGResourcePool.h"
49#include "TGDimension.h"
50#include "WidgetMessageTypes.h"
51#include "TGMdiFrame.h"
52#include "TGMdiDecorFrame.h"
53#include "TGMdiMainFrame.h"
54#include "TVirtualX.h"
55
56
65
66////////////////////////////////////////////////////////////////////////////////
67/// TGMdiDecorFrame constructor.
68/// The TGMdiDecorFrame is the frame containing MDI decorations like
69/// title bar, minimize, maximize, restore and close buttons, and resizers.
70
72 Int_t w, Int_t h, const TGGC *boxGC,
73 UInt_t options, Pixel_t back) :
74 TGCompositeFrame(main->GetContainer(), w, h,
75 options | kOwnBackground | kVerticalFrame | kFixedSize, back)
76{
77
79 fEditDisabled = 1;
80 fFrame = frame;
86
88
90
93
96
98 boxGC, kMdiBorderWidth);
100 boxGC, kMdiBorderWidth);
102 boxGC, kMdiBorderWidth);
104 boxGC, kMdiBorderWidth);
105
108 boxGC, kMdiBorderWidth);
111 boxGC, kMdiBorderWidth);
114 boxGC, kMdiBorderWidth);
117 boxGC, kMdiBorderWidth);
118
127
129
131 fFrame->fParent = this;
133
136 Layout();
137
138 MapWindow();
140
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// TGMdiDecorFrame destructor.
147
149{
150 if (!MustCleanup()) {
151 delete fUpperHR;
152 delete fLowerHR;
153 delete fLeftVR;
154 delete fRightVR;
155 delete fUpperLeftCR;
156 delete fLowerLeftCR;
157 delete fUpperRightCR;
158 delete fLowerRightCR;
159 }
161}
162
163////////////////////////////////////////////////////////////////////////////////
164/// Set border width of the decor.
165
167{
168 fBorderWidth = bw;
169}
170
171////////////////////////////////////////////////////////////////////////////////
172/// Set-up MDI buttons.
173
175{
176 fButtonMask = buttons;
178 if (fButtonMask & kMdiSize) {
187 } else {
196 }
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Set resize mode (opaque or transparent)
201
203{
204 fUpperHR->SetResizeMode(mode);
205 fLowerHR->SetResizeMode(mode);
206 fLeftVR->SetResizeMode(mode);
207 fRightVR->SetResizeMode(mode);
212}
213
214////////////////////////////////////////////////////////////////////////////////
215/// Recalculates the postion and the size of all decor frame components.
216
218{
222
223 if (fIsMaximized == kFALSE) {
224 fUpperLeftCR->Move(0, 0);
229
244 }
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Set MDI Window name (appearing in the title bar)
249
251{
253 fTitlebar->Layout();
254}
255
256////////////////////////////////////////////////////////////////////////////////
257/// Set Window icon (appearing in the title bar)
258
260{
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Move the MDI window at position x, y.
267
269{
270 if (x < 0) {
272 }
273 if (y < 0) {
275 }
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Move the MDI window at position x, y and set size to w, h.
283
285{
286 if (x < 0) {
288 }
289 if (y < 0) {
291 }
295}
296
297////////////////////////////////////////////////////////////////////////////////
298/// Handle configure notify event.
299
301{
302 if ((event->fX < 0) || (event->fY < 0) ||
303 (event->fX + event->fWidth > fMdiMainFrame->GetViewPort()->GetWidth()) ||
304 (event->fY + event->fHeight > fMdiMainFrame->GetViewPort()->GetHeight())) {
306 }
307
308 if (event->fWindow == fFrame->GetId()) {
309 UInt_t newW = event->fWidth + 2 * fBorderWidth;
310 UInt_t newH = event->fHeight + 2 * fBorderWidth +
312
313 if ((fWidth != newW) || (fHeight != newH)) {
314 Resize(newW, newH);
315 }
317 return kTRUE;
318 }
320 return kFALSE;
321}
322
323////////////////////////////////////////////////////////////////////////////////
324/// Handle mouse button events.
325
327{
328 if (event->fType == kButtonPress) {
329 void *ud;
332 }
333 return kTRUE;
334}
335
336
337////////////////////////////////////////////////////////////////////////////////
338/// TGMdiTitleBar constructor.
339/// the TGMdiTitleBar is the frame containing a title (window name)
340/// an icon and MDI picture buttons as minimize, maximize, restore,
341/// close and help.
342
344 const char *name) :
346{
347 fMdiWin = mdiwin;
349 fWinName = 0;
351
353
356 //fMiddleHint = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 1, 1, 1);
359
360 fLFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
361 fMFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
362 fRFrame = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
366
367 fWinIcon = new TGMdiTitleIcon(fLFrame, this,
368 fClient->GetPicture("mdi_default.xpm"),
369 16, 16);
371
372 fWinName = new TGLabel(fMFrame, new TGString(name));
375
376 fButtons = new TGMdiButtons(fRFrame, this);
378
379 MapWindow();
381 Layout();
383}
384
385////////////////////////////////////////////////////////////////////////////////
386/// TGMdiTitleBar destructor.
387
389{
390 if (!MustCleanup()) {
391 delete fLHint;
392 delete fLeftHint;
393 delete fMiddleHint;
394 delete fRightHint;
395 }
396}
397
398////////////////////////////////////////////////////////////////////////////////
399/// Recalculates the position of every enabled (displayed) buttons.
400
401void TGMdiTitleBar::LayoutButtons(UInt_t buttonmask,Bool_t isMinimized,
402 Bool_t isMaximized)
403{
405
406 if (buttonmask & kMdiSize) {
408 } else {
410 }
411
412 if (buttonmask & kMdiMenu) {
414 } else {
416 }
417
418 if (buttonmask & kMdiClose) {
421 } else {
424 }
425
426 if (buttonmask & kMdiHelp) {
428 } else {
430 }
431
432 if ((buttonmask & kMdiMaximize) && (!isMaximized)) {
435 } else {
438 }
439
440 if (isMinimized | isMaximized) {
444 if (isMaximized) fWinIcon->GetPopup()->DisableEntry(kMdiMove);
445 } else {
448 }
449
450 if ((buttonmask & kMdiMinimize) && (!isMinimized)) {
453 } else {
456 }
457
458 Layout();
459}
460
461////////////////////////////////////////////////////////////////////////////////
462/// Set title bar color (blue or grey, depends on active state).
463
465{
466 SetBackgroundColor(back);
467
468 fClient->GetFont(font->GetName());
469 fWinName->SetTextFont(font);
475 Layout();
476 fClient->NeedRedraw(this);
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Handle double click in title bar (maximize window)
486
488{
489 if ((event->fType == kButtonPress) && (event->fCode == kButton1)) {
491 }
492 return kTRUE;
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Handle mouse click on title bar.
497
499{
500 if (event->fType == kButtonPress) {
501 void *ud;
502 GetWinIcon()->GetPopup()->EndMenu(ud);
503 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kMove));
504 switch (event->fCode) {
505 case kButton1:
506 fX0 = event->fX;
507 fY0 = event->fY;
510 break;
511
512 case kButton2:
514 break;
515
516 case kButton3:
517 gVirtualX->LowerWindow(fParent->GetId());
519 break;
520 }
521 } else {
522 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
523 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
524 switch (event->fCode) {
525
526 case kButton1:
527 //if (!fClient->IsEditable()) ((TGMainFrame *)((TGMdiMainFrame *)fMdiWin)->GetMainFrame())->Layout();
529 break;
530
531 case kButton2:
533 break;
534
535 case kButton3:
537 break;
538 }
539
540 TGFrame *f = GetFrameFromPoint(event->fX, event->fY);
541 if (f && (f != this)) {
542 TranslateCoordinates(f, event->fX, event->fY, event->fX, event->fY);
543 f->HandleButton(event);
544 }
545 }
546 return kTRUE;
547}
548
549////////////////////////////////////////////////////////////////////////////////
550/// Process messages for title bar.
551
553{
554 switch (GET_MSG(msg)) {
555 case kC_COMMAND:
556 switch (GET_SUBMSG(msg)) {
557 case kCM_BUTTON:
558 case kCM_MENU:
560 fParent->GetId(), parm2);
561 break;
562 }
563 break;
564 }
565 return kTRUE;
566}
567
568////////////////////////////////////////////////////////////////////////////////
569/// Handle mouse motion events in title bar (used to move MDI window).
570
572{
573 if (event->fWindow != fId) return kTRUE;
574 if (!fLeftButPressed) return kTRUE;
575
576 Int_t x = ((TGFrame *)fParent)->GetX();
577 Int_t y = ((TGFrame *)fParent)->GetY();
578 ((TGFrame *)fParent)->Move(x + event->fX - fX0, y + event->fY - fY0);
579
580 return kTRUE;
581}
582
583
584////////////////////////////////////////////////////////////////////////////////
585/// This is called from TGMdiMainFrame on Restore().
586
588{
589 icon->ReparentWindow(fLFrame);
590 buttons->ReparentWindow(fRFrame);
591 fLFrame->AddFrame(icon, fLHint);
592 fLFrame->ShowFrame(icon);
593 fRFrame->AddFrame(buttons, fLHint);
594 fRFrame->ShowFrame(buttons);
595}
596
597
598////////////////////////////////////////////////////////////////////////////////
599/// This is called from TGMdiMainFrame on Maximize().
600
602{
603 fLFrame->RemoveFrame(icon);
604 fRFrame->RemoveFrame(buttons);
605}
606
607
608////////////////////////////////////////////////////////////////////////////////
609/// TGMdiButtons constructor.
610/// the TGMdiButtons is the frame containing MDI picture buttons like
611/// minimize, maximize, restore, close and help.
612
613TGMdiButtons::TGMdiButtons(const TGWindow *p, const TGWindow *titlebar) :
615{
616 fDefaultHint = new TGLayoutHints(kLHintsNormal, 0, 0, 1, 0);
617 fCloseHint = new TGLayoutHints(kLHintsNormal, 2, 0, 1, 0);
619 fMsgWindow = 0;
620
621 //--- Minimize button
622
623 fButton[0] = new TGPictureButton(this,
624 fClient->GetPicture("mdi_minimize.xpm"),
626 fButton[0]->SetToolTipText("Minimize");
629 fButton[0]->Associate(titlebar);
630
631 //--- Restore button
632
633 fButton[1] = new TGPictureButton(this,
634 fClient->GetPicture("mdi_restore.xpm"),
636 fButton[1]->SetToolTipText("Restore");
639 fButton[1]->Associate(titlebar);
640
641 //--- Maximize button
642
643 fButton[2] = new TGPictureButton(this,
644 fClient->GetPicture("mdi_maximize.xpm"),
646 fButton[2]->SetToolTipText("Maximize");
649 fButton[2]->Associate(titlebar);
650
651 //--- Help button
652
653 fButton[3] = new TGPictureButton(this,
654 fClient->GetPicture("mdi_help.xpm"),
655 kMdiHelp);
656 fButton[3]->SetToolTipText("Help");
659 fButton[3]->Associate(titlebar);
660
661 //--- Close button
662
663 fButton[4] = new TGPictureButton(this,
664 fClient->GetPicture("mdi_close.xpm"),
665 kMdiClose);
666 fButton[4]->SetToolTipText("Close");
669 fButton[4]->Associate(titlebar);
671}
672
673////////////////////////////////////////////////////////////////////////////////
674/// TGMdiButtons destructor.
675
677{
678 if (!MustCleanup()) {
679 delete fDefaultHint;
680 delete fCloseHint;
681 }
682}
683
684////////////////////////////////////////////////////////////////////////////////
685/// TGMdiTitleIcon constructor.
686/// the TGMdiTitleIcon is the left icon used also for the MDI
687/// popup menu allowing access to MDI commands as : restore,
688/// move, size, minimize and close.
689
691 const TGPicture *pic, Int_t w, Int_t h) :
692 TGIcon(p, pic, w, h)
693{
694 fMsgWindow = titlebar;
696
697 //--- MDI system menu
698
699 fPopup = new TGPopupMenu(fClient->GetDefaultRoot());// fClient->GetRoot());
700 fPopup->AddEntry(new TGHotString("&Restore"), kMdiRestore);
701 fPopup->AddEntry(new TGHotString("&Move"), kMdiMove);
702 fPopup->AddEntry(new TGHotString("&Size"), kMdiSize);
703 fPopup->AddEntry(new TGHotString("Mi&nimize"), kMdiMinimize);
704 fPopup->AddEntry(new TGHotString("Ma&ximize"), kMdiMaximize);
706 fPopup->AddEntry(new TGHotString("&Close Ctrl+F4"), kMdiClose);
708 fPopup->Associate(titlebar);
709
712}
713
714////////////////////////////////////////////////////////////////////////////////
715/// TGMdiTitleIcon destructor.
716
718{
719 delete fPopup;
720}
721
722////////////////////////////////////////////////////////////////////////////////
723/// Redraw icon.
724
726{
727 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Handle double click event on MDI icon (close the window)
733
735{
736 if (event->fCode == kButton1) {
737 void *ud;
738 fPopup->EndMenu(ud);
739 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
741 }
742 return kTRUE;
743}
744
745////////////////////////////////////////////////////////////////////////////////
746/// Handle button event on MDI icon (popup menu)
747
749{
751
752 if (event->fType == kButtonPress) {
753 fPopup->PlaceMenu(event->fXRoot - event->fX,
754 event->fYRoot + (fHeight - event->fY),
755 kTRUE, kTRUE);
756 }
757 return kTRUE;
758}
759
760
761////////////////////////////////////////////////////////////////////////////////
762/// TGMdiWinResizer constructor.
763/// The TGMdiWinResizer is a frame allowing to resize MDI window.
764/// Could be horizontal, vertical or corner resizer (see derived classes
765/// TGMdiVerticalWinResizer, TGMdiHorizontalWinResizer, and
766/// TGMdiCornerWinResizer).
767
769 Int_t pos, const TGGC *boxgc, Int_t linew,
770 Int_t mdioptions, Int_t w, Int_t h, UInt_t options) :
771 TGFrame(p, w, h, options)
772{
773 fWinX = fWinY = fWinW = fWinH = fOldX = fOldY = fOldW = fOldH = 0;
774 fNewX = fNewY = fNewW = fNewH = fX0 = fY0 = 0;
775
777
778 fMdiWin = mdiwin;
779 fMdiOptions = mdioptions;
780 fPos = pos;
781
782 fBoxGC = boxgc;
783 fLineW = linew;
784
785 fMinW = 50;
786 fMinH = 20;
787
789
790 gVirtualX->GrabButton(fId, kButton1, kAnyModifier,
792 kNone, kNone);
794}
795
796////////////////////////////////////////////////////////////////////////////////
797/// Handle button events in resizer (grab button and resize).
798
800{
801 if (!IsEnabled()) return kTRUE;
802
803 if (event->fType == kButtonPress) {
804 void *ud;
805 ((TGMdiDecorFrame *)fParent)->GetTitleBar()->GetWinIcon()->GetPopup()->EndMenu(ud);
806 switch (event->fCode) {
807 case kButton1:
809 fNewX = fOldX = fWinX = ((TGFrame *)fParent)->GetX();
810 fNewY = fOldY = fWinY = ((TGFrame *)fParent)->GetY();
811 fWinW = ((TGFrame *)fParent)->GetWidth();
812 fWinH = ((TGFrame *)fParent)->GetHeight();
813 fX0 = event->fXRoot;
814 fY0 = event->fYRoot;
815 fNewW = fWinW;
816 fNewH = fWinH;
817 if (fMdiOptions != kMdiOpaque) {
819 }
823 break;
824
825 case kButton2:
827 break;
828
829 case kButton3:
831 break;
832 }
833 } else {
834 gVirtualX->GrabPointer(0, 0, 0, 0, kFALSE);
835 switch (event->fCode) {
836 case kButton1:
837 if (fMdiOptions != kMdiOpaque) {
839 ((TGFrame *)fParent)->MoveResize(fNewX, fNewY, fNewW, fNewH);
840 }
841 //if (!fClient->IsEditable()) ((TGMainFrame *)((TGMdiMainFrame *)fMdiWin)->GetMainFrame())->Layout();
843 break;
844
845 case kButton2:
847 break;
848
849 case kButton3:
851 break;
852 }
853 }
854 return kTRUE;
855}
856
857////////////////////////////////////////////////////////////////////////////////
858/// Draw resize box (rectangle).
859
861{
863
864 gVirtualX->DrawRectangle(m->GetContainer()->GetId(), fBoxGC->GetGC(),
865 x + fLineW / 2, y + fLineW / 2, width - fLineW, height - fLineW);
866}
867
868////////////////////////////////////////////////////////////////////////////////
869/// Move (resize) parent MDI window.
870
872{
873 if (fMdiOptions == kMdiOpaque) {
874 ((TGFrame *)fParent)->MoveResize(fNewX, fNewY, fNewW, fNewH);
875 } else {
878 }
879}
880
881
882////////////////////////////////////////////////////////////////////////////////
883/// TGMdiVerticalWinResizer constructor.
884
886 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
887 Int_t mdioptions, Int_t w, Int_t h) :
888 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
890{
891 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kArrowVer));
892}
893
894////////////////////////////////////////////////////////////////////////////////
895/// Handle motion events in resizer (resize associated MDI window).
896
898{
899 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
900
901 fOldX = fNewX;
902 fOldY = fNewY;
903 fOldW = fNewW;
904 fOldH = fNewH;
905
906 Int_t dy = event->fYRoot - fY0;
907
908 if (!fLeftButPressed) return kTRUE;
909
910 switch (fPos) {
911 case kMdiResizerTop:
912 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
913 fNewY = fWinY + dy;
914 fNewH = fWinH - dy;
915 break;
916
918 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
919 fNewY = fWinY;
920 fNewH = fWinH + dy;
921 break;
922 }
923
924 MoveResizeIt();
925
926 return kTRUE;
927}
928
929////////////////////////////////////////////////////////////////////////////////
930/// Draw vertical resizer frame border.
931
933{
934 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
935 if (fPos == kMdiResizerTop) {
936 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 1, fWidth - 1, 1);
937 } else {
938 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fHeight - 2, fWidth - 1,
939 fHeight - 2);
940 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1, fWidth - 1,
941 fHeight - 1);
942 }
943}
944
945
946////////////////////////////////////////////////////////////////////////////////
947/// TGMdiCornerWinResizer constructor.
948
950 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
951 Int_t mdioptions, Int_t w, Int_t h) :
952 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
954{
955 Cursor_t defaultCursor = kNone;
957
958 switch (fPos) {
960 defaultCursor = gVirtualX->CreateCursor(kTopLeft);
961 break;
962
964 defaultCursor = gVirtualX->CreateCursor(kBottomLeft);
965 break;
966
968 defaultCursor = gVirtualX->CreateCursor(kTopRight);
969 break;
970
972 defaultCursor = gVirtualX->CreateCursor(kBottomRight);
973 break;
974 }
975 gVirtualX->SetCursor(fId, defaultCursor);
976}
977
978////////////////////////////////////////////////////////////////////////////////
979/// Handle motion events in resizer (resize associated MDI window).
980
982{
983 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
984
985 fOldX = fNewX;
986 fOldY = fNewY;
987 fOldW = fNewW;
988 fOldH = fNewH;
989
990 Int_t dx = event->fXRoot - fX0;
991 Int_t dy = event->fYRoot - fY0;
992
993 if (!fLeftButPressed) return kTRUE;
994
995 switch (fPos) {
997 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
998 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
999 fNewX = fWinX + dx;
1000 fNewW = fWinW - dx;
1001 fNewY = fWinY + dy;
1002 fNewH = fWinH - dy;
1003 break;
1004
1006 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
1007 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
1008 fNewX = fWinX + dx;
1009 fNewW = fWinW - dx;
1010 fNewY = fWinY;
1011 fNewH = fWinH + dy;
1012 break;
1013
1015 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1016 if (fWinH - dy < fMinH) dy = fWinH - fMinH;
1017 fNewX = fWinX;
1018 fNewW = fWinW + dx;
1019 fNewY = fWinY + dy;
1020 fNewH = fWinH - dy;
1021 break;
1022
1024 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1025 if (fWinH + dy < fMinH) dy = fMinH - fWinH;
1026 fNewX = fWinX;
1027 fNewW = fWinW + dx;
1028 fNewY = fWinY;
1029 fNewH = fWinH + dy;
1030 break;
1031 }
1032
1033 MoveResizeIt();
1034
1035 return kTRUE;
1036}
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// Draw corner resizer frame border.
1040
1042{
1043 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
1044
1045 switch (fPos) {
1047 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, fWidth - 1, 1);
1048 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 1, 1, fHeight - 1);
1049 break;
1050
1052 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 0, 1, fHeight - 1);
1053 gVirtualX->DrawLine(fId, GetShadowGC()(), 1, fHeight - 2,
1054 fWidth - 1, fHeight - 2);
1055 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1,
1056 fWidth - 1, fHeight - 1);
1057 break;
1058
1060 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 1, fWidth - 1, 1);
1061 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 1,
1062 fWidth - 2, fHeight - 1);
1063 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0,
1064 fWidth - 1, fHeight - 1);
1065 break;
1066
1068 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 0,
1069 fWidth - 2, fHeight - 2);
1070 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, fHeight - 2,
1071 fWidth - 1, fHeight - 2);
1072 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0,
1073 fWidth - 1, fHeight - 1);
1074 gVirtualX->DrawLine(fId, GetBlackGC()(), 0, fHeight - 1,
1075 fWidth - 1, fHeight - 1);
1076 break;
1077 }
1078}
1079
1080
1081////////////////////////////////////////////////////////////////////////////////
1082/// TGMdiHorizontalWinResizer constructor.
1083
1085 const TGWindow *mdiwin, Int_t pos, const TGGC *boxGC, Int_t linew,
1086 Int_t mdioptions, Int_t w, Int_t h) :
1087 TGMdiWinResizer(p, mdiwin, pos, boxGC, linew, mdioptions,
1089{
1091 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kArrowHor));
1092 SetWindowName();
1093}
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// Handle motion events in resizer (resize associated MDI window).
1097
1099{
1100 if (((TGMdiDecorFrame *)fParent)->IsMinimized()) return kTRUE;
1101
1102 fOldX = fNewX;
1103 fOldY = fNewY;
1104 fOldW = fNewW;
1105 fOldH = fNewH;
1106
1107 Int_t dx = event->fXRoot - fX0;
1108
1109 if (!fLeftButPressed) return kTRUE;
1110
1111 switch (fPos) {
1112 case (kMdiResizerLeft):
1113 if (fWinW - dx < fMinW) dx = fWinW - fMinW;
1114 fNewX = fWinX + dx;
1115 fNewW = fWinW - dx;
1116 break;
1117
1118 case (kMdiResizerRight):
1119 if (fWinW + dx < fMinW) dx = fMinW - fWinW;
1120 fNewX = fWinX;
1121 fNewW = fWinW + dx;
1122 break;
1123 }
1124
1125 MoveResizeIt();
1126
1127 return kTRUE;
1128}
1129
1130////////////////////////////////////////////////////////////////////////////////
1131/// Draw horizontal resizer frame border.
1132
1134{
1135 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
1136 if (fPos == kMdiResizerLeft) {
1137 gVirtualX->DrawLine(fId, GetHilightGC()(), 1, 0, 1, fHeight - 1);
1138 } else {
1139 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth - 2, 0, fWidth - 2, fHeight - 1);
1140 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth - 1, 0, fWidth - 1, fHeight - 1);
1141 }
1142}
@ kButtonPress
Definition: GuiTypes.h:59
Handle_t Cursor_t
Definition: GuiTypes.h:33
const Mask_t kButtonMotionMask
Definition: GuiTypes.h:163
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
const Mask_t kPointerMotionMask
Definition: GuiTypes.h:162
@ 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:87
const Mask_t kStructureNotifyMask
Definition: GuiTypes.h:165
const Mask_t kButtonReleaseMask
Definition: GuiTypes.h:161
@ kTopLeft
Definition: GuiTypes.h:371
@ kBottomRight
Definition: GuiTypes.h:371
@ kArrowVer
Definition: GuiTypes.h:373
@ kMove
Definition: GuiTypes.h:373
@ kTopRight
Definition: GuiTypes.h:371
@ kBottomLeft
Definition: GuiTypes.h:371
@ kArrowHor
Definition: GuiTypes.h:373
@ kPointer
Definition: GuiTypes.h:374
ULong_t Pixel_t
Definition: GuiTypes.h:39
@ kButton2
Definition: GuiTypes.h:213
@ kButton3
Definition: GuiTypes.h:213
@ kButton1
Definition: GuiTypes.h:213
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
const Bool_t kFALSE
Definition: RtypesCore.h:90
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
const Bool_t kTRUE
Definition: RtypesCore.h:89
#define ClassImp(name)
Definition: Rtypes.h:361
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
@ kDeepCleanup
Definition: TGFrame.h:51
@ 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:34
@ kWidgetIsEnabled
Definition: TGWidget.h:48
char name[80]
Definition: TGX11.cxx:109
#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_MDI
@ 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:397
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Definition: TGCanvas.cxx:2403
virtual void SetHsbPosition(Int_t newPos)
Set position of horizontal scrollbar.
Definition: TGCanvas.cxx:2389
TGViewPort * GetViewPort() const
Definition: TGCanvas.h:227
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
TGCompositeFrame(const TGCompositeFrame &)
virtual TGFrame * GetFrameFromPoint(Int_t x, Int_t y)
Get frame located at specified point.
Definition: TGFrame.cxx:1292
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1101
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1241
virtual void SetCleanup(Int_t mode=kLocalCleanup)
Turn on automatic cleanup of child frames in dtor.
Definition: TGFrame.cxx:1056
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.h:353
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:1316
virtual Int_t MustCleanup() const
Definition: TGFrame.h:398
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1148
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1188
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:351
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1133
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1174
Definition: TGFont.h:149
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition: TGFrame.cxx:323
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:719
void RemoveInput(UInt_t emask)
Remove events specified in emask from the events the frame should handle.
Definition: TGFrame.cxx:332
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:227
UInt_t fHeight
Definition: TGFrame.h:113
Int_t fBorderWidth
Definition: TGFrame.h:118
virtual void Activate(Bool_t)
Definition: TGFrame.h:235
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:739
virtual void SetBackgroundColor(Pixel_t back)
Set background color (override from TGWindow base class).
Definition: TGFrame.cxx:296
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:629
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:667
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:749
virtual void Move(Int_t x, Int_t y)
Move frame.
Definition: TGFrame.cxx:577
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:589
UInt_t fWidth
Definition: TGFrame.h:112
UInt_t GetHeight() const
Definition: TGFrame.h:250
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:613
virtual void MapWindow()
map window
Definition: TGFrame.h:229
UInt_t GetWidth() const
Definition: TGFrame.h:249
Definition: TGGC.h:31
GContext_t GetGC() const
Definition: TGGC.h:50
Definition: TGIcon.h:30
virtual void DoRedraw()
Redraw picture.
Definition: TGIcon.cxx:127
virtual void SetPicture(const TGPicture *pic)
Set icon picture.
Definition: TGIcon.cxx:80
void SetTextJustify(Int_t tmode)
Set text justification.
Definition: TGLabel.cxx:394
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
Definition: TGLabel.cxx:360
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:178
virtual void SetTextFont(TGFont *font, Bool_t global=kFALSE)
Changes text font specified by pointer to TGFont object.
Definition: TGLabel.cxx:322
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.
Bool_t fRightButPressed
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().
TGLabel * fWinName
Bool_t fLeftButPressed
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 AddEntry(TGHotString *s, Int_t id, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu entry.
Definition: TGMenu.cxx:988
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1058
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1722
virtual void EnableEntry(Int_t id)
Enable entry. By default entries are enabled.
Definition: TGMenu.cxx:1703
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:1287
virtual void PlaceMenu(Int_t x, Int_t y, Bool_t stick_mode, Bool_t grab_pointer)
Popup a popup menu.
Definition: TGMenu.cxx:1239
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
Int_t fWidgetFlags
Definition: TGWidget.h:59
Bool_t IsEnabled() const
Definition: TGWidget.h:81
virtual void SetWindowName(const char *name=0)
Set window name.
Definition: TGWindow.cxx:119
const TGWindow * fParent
Definition: TGWindow.h:36
virtual void DestroyWindow()
destroy window
Definition: TGWindow.cxx:182
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition: TGWindow.cxx:285
virtual void RaiseWindow()
raise window
Definition: TGWindow.cxx:198
UInt_t fEditDisabled
Definition: TGWindow.h:40
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
int main(int argc, char **argv)
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
EGEventType fType
Definition: GuiTypes.h:174
Int_t fY
Definition: GuiTypes.h:177
Int_t fXRoot
Definition: GuiTypes.h:178
UInt_t fWidth
Definition: GuiTypes.h:181
UInt_t fHeight
Definition: GuiTypes.h:181
Window_t fWindow
Definition: GuiTypes.h:175
Int_t fYRoot
Definition: GuiTypes.h:178
Int_t fX
Definition: GuiTypes.h:177
UInt_t fCode
Definition: GuiTypes.h:179
auto * m
Definition: textangle.C:8