Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGCanvas.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 11/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, 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 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGCanvas
25 \ingroup guiwidgets
26
27A frame containing two scrollbars (a horizontal and
28a vertical) and a viewport. The viewport acts as the window through
29which we look at the contents of the container frame.
30
31\class TGContainer
32\ingroup guiwidgets
33
34Manages a content area. It can display and
35control a hierarchy of multi-column items, and provides the ability
36to add new items at any time. By default it doesn't map subwindows
37which are items of the container. In this case subwindow must
38provide DrawCopy method, see for example TGLVEntry class.
39It is also possible to use option which allow to map subwindows.
40This option has much slower drawing speed in case of more than 1000
41items placed in container. To activate this option the fMapSubwindows
42data member must be set to kTRUE (for example TTVLVContainer class)
43
44 The TGContainer class can handle the keys:
45
46 - F7, Ctnrl-F - activate search dialog
47 - F3, Ctnrl-G - continue search
48 - End - go to the last item in container
49 - Home - go to the first item in container
50 - PageUp,PageDown,arrow keys - navigate inside container
51 - Return/Enter - equivalent to double click of the mouse button
52 - Ctnrl-A - select/activate all items.
53 - Space - invert selection.
54
55*/
56
57
58#include "TGCanvas.h"
59#include "TGListView.h"
60#include "TGScrollBar.h"
61#include "TTimer.h"
62#include "KeySymbols.h"
63#include "TSystem.h"
64#include "TGTextEditDialogs.h"
65#include "TGMsgBox.h"
66#include "TGResourcePool.h"
67#include "TList.h"
68#include "TClass.h"
69#include "TGMimeTypes.h"
70#include "TKey.h"
71#include "TKeyMapFile.h"
72#include "TGDNDManager.h"
73#include "RConfigure.h"
74#include "TVirtualX.h"
75
76#include <iostream>
77#include <cstdlib>
78
79
81
83const Int_t kAcceleration[kAutoScrollFudge+1] = {1,1,1,2,3,4,6,7,8,16,32};
84const Int_t kKeyboardTime = 700;
85
86
87
88////////////////////////////////////////////////////////////////////////////////
89
97
98////////////////////////////////////////////////////////////////////////////////
99/// single shot timer
100
108
109////////////////////////////////////////////////////////////////////////////////
110
112private:
114public:
116 Bool_t Notify() override;
117};
118
119////////////////////////////////////////////////////////////////////////////////
120/// on-timeout
121
128
129
130////////////////////////////////////////////////////////////////////////////////
131/// Create a viewport object.
132
134 UInt_t options, Pixel_t back) :
135 TGCompositeFrame(p, w, h, options, back)
136{
137 fContainer = 0;
138 fX0 = fY0 = 0;
139
143}
144
145////////////////////////////////////////////////////////////////////////////////
146/// Add container frame to the viewport. We must make sure that the added
147/// container is at least a TGCompositeFrame (TGCanvas::AddFrame depends
148/// on it).
149
151{
152 if (!f) {
154 fContainer = 0;
155 return;
156 }
157
158 if (!fContainer) {
159 fContainer = f;
160 AddFrame(f, 0);
162
164 ((TGContainer*)fContainer)->fViewPort = this;
165 if (fParent->InheritsFrom(TGCanvas::Class())) {
166 ((TGContainer*)fContainer)->fCanvas = (TGCanvas*)fParent;
167 }
168 }
169 }
170}
171
172////////////////////////////////////////////////////////////////////////////////
173/// Moves content of container frame in horizontal direction.
174
176{
177 Int_t diff;
178
179 if (!fContainer) return;
180
183 return;
184 } else {
187 return;
188 }
189 }
190
191 if (-xpos < 0) return;
192 else diff = xpos - fX0;
193
194 if (!diff) return;
195
196 fX0 = xpos;
197
198#if defined(R__HAS_COCOA)
199 //In the current version of cocoa back-end, it's very expensive
200 //to read window's pixels, skip "optimization".
201 ((TGContainer*)fContainer)->DrawRegion(0, 0, fWidth, fHeight);
202#else
203 UInt_t adiff = std::abs(diff);
204
205 if (adiff < fWidth) {
206 if (diff < 0) {
207 gVirtualX->CopyArea(fContainer->GetId(), fContainer->GetId(), GetWhiteGC()(),
208 adiff, 0, fWidth - adiff, fHeight, 0, 0);
209 adiff += 20; // draw larger region
210 ((TGContainer*)fContainer)->DrawRegion(fWidth - adiff, 0, adiff, fHeight);
211 } else {
212 gVirtualX->CopyArea(fContainer->GetId(), fContainer->GetId(), GetWhiteGC()(),
213 0, 0, fWidth - adiff, fHeight, adiff, 0);
214 adiff += 20; // draw larger region
215 ((TGContainer*)fContainer)->DrawRegion(0, 0, adiff, fHeight);
216 }
217 } else {
218 ((TGContainer*)fContainer)->DrawRegion(0, 0, fWidth, fHeight);
219 }
220#endif
221}
222
223////////////////////////////////////////////////////////////////////////////////
224/// Moves content of container frame in vertical direction.
225
227{
228 Int_t diff;
229
230 if (!fContainer) return;
231
232 // for backward compatibility
235 return;
236 } else {
239 return;
240 }
241 }
242
243 if (-ypos < 0) return;
244 else diff = ypos - fY0;
245
246 if (!diff) return;
247
248 fY0 = ypos;
249
250#if defined(R__HAS_COCOA)
251 //In the current version of cocoa back-end, it's very expensive
252 //to read window's pixels, skip "optimization".
253 ((TGContainer*)fContainer)->DrawRegion(0, 0, fWidth, fHeight);
254#else
255 UInt_t adiff = std::abs(diff);
256
257 if (adiff < fHeight) {
258 if (diff < 0) {
259 gVirtualX->CopyArea(fContainer->GetId(), fContainer->GetId(), GetWhiteGC()(),
260 0, adiff, fWidth, fHeight - adiff, 0, 0);
261 adiff += 20; // draw larger region
262 ((TGContainer*)fContainer)->DrawRegion(0, fHeight - adiff, fWidth, adiff);
263 } else {
264 gVirtualX->CopyArea(fContainer->GetId(), fContainer->GetId(), GetWhiteGC()(),
265 0, 0, fWidth, fHeight - adiff, 0, adiff);
266 adiff += 20; // draw larger region
267 ((TGContainer*)fContainer)->DrawRegion(0, 0, fWidth, adiff);
268 }
269 } else {
270 ((TGContainer*)fContainer)->DrawRegion(0, 0, fWidth, fHeight);
271 }
272#endif
273}
274
275////////////////////////////////////////////////////////////////////////////////
276/// Goto new position.
277
279{
280 if (!fContainer) return;
281
282 SetHPos(fX0 = xpos);
283 SetVPos(fY0 = ypos);
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Handle resize events.
288
290{
293 return kTRUE;
294 }
295
297
298 // protection
299 if ((event->fWidth > 32768) || (event->fHeight > 32768)) {
300 return kFALSE;
301 }
302
303 cont->DrawRegion(event->fX, event->fY, event->fWidth, event->fHeight);
304
305 return kTRUE;
306}
307
308////////////////////////////////////////////////////////////////////////////////
309/// Create a canvas container. This is the (large) frame that contains
310/// all the list items. It will be shown through a TGViewPort (which is
311/// created by the TGCanvas).
312
314 UInt_t options, Pixel_t back) :
315 TGCompositeFrame(p, w, h, options, back)
316{
317 fXp = fYp = fX0 = fY0 = fXf = fYf = fXDND = fYDND = 0;
318 fViewPort = 0;
319 fBdown = kFALSE;
320 fMsgWindow = p;
322 fTotal = fSelected = 0;
325 fLastActiveEl = 0;
326 fLastDir = kTRUE;
329 fLastName = "";
334 fCanvas = 0;
336
337 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
340
343
346 wattr.fBitGravity = 1; // NorthWestGravity
347 wattr.fWinGravity = 1;
348 gVirtualX->ChangeWindowAttributes(fId, &wattr);
349
351}
352
353////////////////////////////////////////////////////////////////////////////////
354/// Create a canvas container. This is the (large) frame that contains
355/// all the list items. It will be shown through a TGViewPort (which is
356/// created by the TGCanvas).
357
359 TGCompositeFrame(p->GetViewPort(), p->GetWidth(), p->GetHeight(), options, back)
360{
361 fXp = fYp = fX0 = fY0 = fXf = fYf = fXDND = fYDND = 0;
362 fViewPort = 0;
363 fBdown = kFALSE;
364 fMsgWindow = p->GetViewPort();
365 fCanvas = p;
367 p->GetViewPort()->SetBackgroundColor(back);
368
370 fTotal = fSelected = 0;
373 fLastActiveEl = 0;
374 fLastDir = kTRUE;
377 fLastName = "";
383
384 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
387
390
393 wattr.fBitGravity = 1; // NorthWestGravity
394 wattr.fWinGravity = 1;
395 gVirtualX->ChangeWindowAttributes(fId, &wattr);
396
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Delete canvas container.
402
404{
407 }
408
409 delete fScrollTimer;
410 fScrollTimer = 0;
411
412 delete fKeyTimer;
413 fKeyTimer = 0;
414}
415
416////////////////////////////////////////////////////////////////////////////////
417/// Layout container entries.
418
420{
423
424 // clear content if positions of subframes changed after layout
425 if (lm && lm->IsModified()) ClearViewPort();
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Emit signal when current position changed.
430
432{
433 Longptr_t args[2];
434
435 args[0] = x;
436 args[1] = y;
437
438 Emit("CurrentChanged(Int_t,Int_t)",args);
439}
440
441////////////////////////////////////////////////////////////////////////////////
442/// Emit signal when current selected frame changed.
443
445{
446 Emit("CurrentChanged(TGFrame*)", (Longptr_t)f);
447}
448
449////////////////////////////////////////////////////////////////////////////////
450/// Signal emitted when keyboard key pressed
451///
452/// frame - activated frame
453/// keysym - defined in "KeySymbols.h"
454/// mask - modifier key mask, defined in "GuiTypes.h"
455///
456/// const Mask_t kKeyShiftMask = BIT(0);
457/// const Mask_t kKeyLockMask = BIT(1);
458/// const Mask_t kKeyControlMask = BIT(2);
459/// const Mask_t kKeyMod1Mask = BIT(3); // typically the Alt key
460/// const Mask_t kButton1Mask = BIT(8);
461/// const Mask_t kButton2Mask = BIT(9);
462/// const Mask_t kButton3Mask = BIT(10);
463/// const Mask_t kButton4Mask = BIT(11);
464/// const Mask_t kButton5Mask = BIT(12);
465/// const Mask_t kAnyModifier = BIT(15);
466
468{
469 Longptr_t args[3];
470 args[0] = (Longptr_t)frame;
471 args[1] = (Longptr_t)keysym;
472 args[2] = (Longptr_t)mask;
473 Emit("KeyPressed(TGFrame*,UInt_t,UInt_t)", args);
475}
476
477////////////////////////////////////////////////////////////////////////////////
478/// Signal emitted when Return/Enter key pressed.
479/// It's equivalent to "double click" of mouse button.
480
482{
483 Emit("ReturnPressed(TGFrame*)", (Longptr_t)f);
484}
485
486////////////////////////////////////////////////////////////////////////////////
487/// Signal emitted when space key pressed.
488/// Pressing space key inverts selection.
489
491{
492 Emit("SpacePressed(TGFrame*)", (Longptr_t)f);
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Signal emitted when pointer is over entry.
497
499{
500 if (!fOnMouseOver) Emit("OnMouseOver(TGFrame*)", (Longptr_t)f);
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// Emit Clicked() signal.
506
508{
509 Longptr_t args[2];
510
511 args[0] = (Longptr_t)entry;
512 args[1] = btn;
513
514 Emit("Clicked(TGFrame*,Int_t)", args);
515}
516
517////////////////////////////////////////////////////////////////////////////////
518/// Emit Clicked() signal.
519
521{
522 Longptr_t args[4];
523
524 args[0] = (Longptr_t)entry;
525 args[1] = btn;
526 args[2] = x;
527 args[3] = y;
528
529 Emit("Clicked(TGFrame*,Int_t,Int_t,Int_t)", args);
530}
531
532////////////////////////////////////////////////////////////////////////////////
533/// Emit DoubleClicked() signal.
534
536{
537 Longptr_t args[2];
538
539 args[0] = (Longptr_t)entry;
540 args[1] = btn;
541
542 Emit("DoubleClicked(TGFrame*,Int_t)", args);
543}
544
545////////////////////////////////////////////////////////////////////////////////
546/// Emit DoubleClicked() signal.
547
549{
550 Longptr_t args[4];
551
552 args[0] = (Longptr_t)entry;
553 args[1] = btn;
554 args[2] = x;
555 args[3] = y;
556
557 Emit("DoubleClicked(TGFrame*,Int_t,Int_t,Int_t)", args);
558}
559
560////////////////////////////////////////////////////////////////////////////////
561/// Select all items in the container.
562/// SelectAll() signal emitted.
563
565{
566 TIter next(fList);
568 TGFrame *fr;
569
570 while ((el = (TGFrameElement *) next())) {
571 fr = el->fFrame;
572 if (!fr->IsActive()) {
574 }
575 }
579
580 Emit("SelectAll()");
581}
582
583////////////////////////////////////////////////////////////////////////////////
584/// Unselect all items in the container.
585
587{
588 TIter next(fList);
590 TGFrame *fr;
591
592 while ((el = (TGFrameElement *) next())) {
593 fr = el->fFrame;
594 if (fr->IsActive()) {
596 }
597 }
598 fLastActiveEl = 0;
599 fSelected = 0;
600
603
604 Emit("UnSelectAll()");
605}
606
607////////////////////////////////////////////////////////////////////////////////
608/// Invert the selection, all selected items become unselected and
609/// vice versa.
610
612{
613 int selected = 0;
614
615 TIter next(fList);
617
618 while ((el = (TGFrameElement *) next())) {
619 if (!el->fFrame->IsActive()) {
621 ++selected;
622 } else {
624 }
625 }
626 ClearViewPort(); // full redraw
627 fSelected = selected;
628
631
632 Emit("InvertSelection()");
633}
634
635////////////////////////////////////////////////////////////////////////////////
636/// Remove all items from the container.
637
639{
641 TIter next(fList);
642
643 while ((el = (TGFrameElement *) next())) {
644 el->fFrame->DestroyWindow();
645 delete el->fFrame;
646 fList->Remove(el);
647 delete el;
648 }
649 fLastActiveEl = 0;
650 fSelected = fTotal = 0;
651 ClearViewPort(); // full redraw
652}
653
654////////////////////////////////////////////////////////////////////////////////
655/// Remove item from container.
656
658{
660 TIter next(fList);
661 while ((el = (TGFrameElement *) next())) {
662 if (item == el->fFrame) {
664 item->DestroyWindow();
665 delete item;
666 fList->Remove(el);
667 delete el;
668 break;
669 }
670 }
671 ClearViewPort(); // fill redraw
672}
673
674////////////////////////////////////////////////////////////////////////////////
675/// Return the next selected item. If the "current" pointer is 0, the first
676/// selected item will be returned.
677
679{
680 TGFrame *f;
681 TObjLink *lnk = (TObjLink *) *current;
682
683 lnk = (lnk == 0) ? fList->FirstLink() : lnk->Next();
684 while (lnk) {
685 f = (TGFrame *) ((TGFrameElement *) lnk->GetObject())->fFrame;
686 if (f->IsActive()) {
687 *current = (void *) lnk;
688 return f;
689 }
690 lnk = lnk->Next();
691 }
692 return 0;
693}
694
695////////////////////////////////////////////////////////////////////////////////
696/// Activate item.
697
699{
700 TGFrame *fr = el->fFrame;
701 fr->Activate(kTRUE);
702
703 if (fLastActiveEl != el) {
707 fSelected++;
708 }
709
710 if (!fSelected) fSelected = 1;
711
713
715 DrawRegion(fr->GetX() - pos.fX, fr->GetY() - pos.fY, fr->GetWidth(), fr->GetHeight());
716}
717
718////////////////////////////////////////////////////////////////////////////////
719/// DeActivate item.
720
722{
723 TGFrame *fr = el->fFrame;
724 fr->Activate(kFALSE);
726
728 DrawRegion(fr->GetX() - pos.fX, fr->GetY() - pos.fY, fr->GetWidth(), fr->GetHeight());
729}
730
731////////////////////////////////////////////////////////////////////////////////
732/// Returns page position.
733
735{
737 if (!fViewPort) return ret;
738
739 ret.fX = -fViewPort->GetHPos();
740 ret.fY = -fViewPort->GetVPos();
741
742 return ret;
743}
744
745////////////////////////////////////////////////////////////////////////////////
746/// Returns page dimension.
747
749{
751 if (!fViewPort) return ret;
752
753 ret.fWidth = fViewPort->GetWidth();
754 ret.fHeight = fViewPort->GetHeight();
755 return ret;
756}
757
758////////////////////////////////////////////////////////////////////////////////
759/// Set page position.
760
762{
763 if (!fViewPort) return;
764 fViewPort->SetPos(pos.fX, pos.fY);
765}
766
767////////////////////////////////////////////////////////////////////////////////
768/// Set page position.
769
771{
772 if (!fViewPort) return;
773 fViewPort->SetPos(x, y);
774}
775
776////////////////////////////////////////////////////////////////////////////////
777/// Set page dimension.
778
780{
781 if (!fViewPort) return;
782 fViewPort->Resize(dim);
783}
784
785////////////////////////////////////////////////////////////////////////////////
786/// Set page dimension.
787
789{
790 if (!fViewPort) return;
791 fViewPort->Resize(w, h);
792}
793
794////////////////////////////////////////////////////////////////////////////////
795/// Redraw content of container in the viewport region.
796
798{
799#ifdef R__HAS_COCOA
800 DrawRegion(0, 0, GetWidth(), GetHeight());
801#else
802 if (!fExposedRegion.IsEmpty()) {
805
807 }
808#endif
809}
810
811////////////////////////////////////////////////////////////////////////////////
812/// Draw a region of container in viewport.
813/// x, y, w, h are position and dimension of area to be
814/// redrawn in viewport coordinates.
815
817{
818 static GContext_t gcBg = 0;
819 Pixmap_t pixmap = 0;
820
821 if (!fViewPort) return;
822 // sanity checks
823 if ((x > (Int_t)fViewPort->GetWidth()) || (y > (Int_t)fViewPort->GetHeight())) {
824 return;
825 }
826 x = x < 0 ? 0 : x;
827 y = y < 0 ? 0 : y;
828
829 w = x + w > fViewPort->GetWidth() ? fViewPort->GetWidth() - x : w;
830 h = y + h > fViewPort->GetHeight() ? fViewPort->GetHeight() - y : h;
831
832 if (((Int_t)w < 1) || ((Int_t)h < 1)) {
833 return;
834 }
835
836 if (!fMapSubwindows) {
837 pixmap = gVirtualX->CreatePixmap(fId, w, h);
838
839 if (!gcBg) {
841 gcValues.fForeground = fBackground;
842 gcValues.fBackground = fBackground;
843 gcValues.fGraphicsExposures = kTRUE;
845 gcBg = gVirtualX->CreateGC(fId, &gcValues);
846 }
847
848 gVirtualX->SetForeground(gcBg, fBackground);
849 gVirtualX->FillRectangle(pixmap, gcBg, 0, 0, w, h);
850 }
851
853
854 // translate coordinates in viewport into coordinates in container
855 Int_t xx = pos.fX + x;
856 Int_t yy = pos.fY + y;
857
858 TIter next(fList);
860
861 while ((el = (TGFrameElement *) next())) {
862 if ((Int_t(el->fFrame->GetY()) > yy - (Int_t)el->fFrame->GetHeight()) &&
863 (Int_t(el->fFrame->GetX()) > xx - (Int_t)el->fFrame->GetWidth()) &&
864 (Int_t(el->fFrame->GetY()) < yy + Int_t(h + el->fFrame->GetHeight())) &&
865 (Int_t(el->fFrame->GetX()) < xx + Int_t(w + el->fFrame->GetWidth()))) {
866
867 // draw either in container window or in double-buffer
868 if (!fMapSubwindows) {
869 Int_t fx = el->fFrame->GetX() - xx;
870 Int_t fy = el->fFrame->GetY() - yy;
871 el->fFrame->DrawCopy(pixmap, fx, fy);
872 } else {
873 fClient->NeedRedraw(el->fFrame);
874 }
875 }
876 }
877
878 if (fMapSubwindows) return;
879
880 gVirtualX->CopyArea(pixmap, fId, gcBg, 0, 0, w, h, x, y);
881 gVirtualX->DeletePixmap(pixmap);
882 gVirtualX->Update(kFALSE);
883}
884
885////////////////////////////////////////////////////////////////////////////////
886/// Clear view port and redraw full content
887
896
897////////////////////////////////////////////////////////////////////////////////
898/// Handle expose events. Do not use double buffer.
899
901{
903
904 if (event->fWindow == GetId()) {
905 TGPosition pos(event->fX, event->fY);
906 TGDimension dim(event->fWidth, event->fHeight);
907 TGRectangle rect(pos, dim);
908
909 if (fExposedRegion.IsEmpty()) {
911 } else {
913 }
914
915 fClient->NeedRedraw(this);
916 } else {
918 }
919
920 return kTRUE;
921}
922
923////////////////////////////////////////////////////////////////////////////////
924/// Handle mouse button event in container.
925
927{
928 Int_t total, selected, page = 0;
929
933 page = dim.fHeight/4;
934
935 if (event->fCode == kButton4) {
936 //scroll up
937 newpos = pos.fY - page;
938 if (newpos < 0) newpos = 0;
940 return kTRUE;
941 }
942 if (event->fCode == kButton5) {
943 // scroll down
946 return kTRUE;
947 }
948
949 Int_t xx = pos.fX + event->fX; // translate coordinates
950 Int_t yy = pos.fY + event->fY;
951
952 if (event->fType == kButtonPress) {
953 gVirtualX->SetInputFocus(fId);
954
955 fXp = pos.fX + event->fX;
956 fYp = pos.fY + event->fY;
957
958 fXDND = event->fX;
959 fYDND = event->fY;
960 fBdown = kTRUE;
961
962 UnSelectAll();
963 total = selected = 0;
964
966 TIter next(fList);
968
969 while ((el = (TGFrameElement *) next())) {
971
972 if (!fMapSubwindows) {
973 if ((Int_t(el->fFrame->GetY()) + (Int_t)el->fFrame->GetHeight() > yy ) &&
974 (Int_t(el->fFrame->GetX()) + (Int_t)el->fFrame->GetWidth() > xx ) &&
975 (Int_t(el->fFrame->GetY()) < yy) &&
976 (Int_t(el->fFrame->GetX()) < xx)) {
978 }
979 } else {
980 if (el->fFrame->GetId() == (Window_t)event->fUser[0]) {
982 }
983 }
984
985 if (select_frame) {
986 selected++;
988 Clicked(el->fFrame, event->fCode);
989 Clicked(el->fFrame, event->fCode, event->fXRoot, event->fYRoot);
990 }
991 total++;
992 }
993
994 if (fTotal != total || fSelected != selected) {
995 fTotal = total;
996 fSelected = selected;
999 }
1000
1001 if ( selected == 0 ) {
1002 fDragging = kTRUE;
1003 fX0 = fXf = fXp;
1004 fY0 = fYf = fYp;
1005 gVirtualX->DrawRectangle(fId, GetLineGC()(), fX0-pos.fX, fY0-pos.fY,
1006 fXf-fX0, fYf-fY0);
1007 }
1008 }
1009
1010 if (event->fType == kButtonRelease) {
1011 gVirtualX->SetInputFocus(fId);
1012
1013 fBdown = kFALSE;
1014 if (fDragging) {
1015 fDragging = kFALSE;
1017
1019 gVirtualX->DrawRectangle(fId, GetLineGC()(), fX0-pos.fX, fY0-pos.fY,
1020 fXf-fX0, fYf-fY0);
1021 ClearViewPort();
1022
1023 } else {
1025 event->fCode, (event->fYRoot << 16) | event->fXRoot);
1026 }
1027 }
1028 DoRedraw();
1029 return kTRUE;
1030}
1031
1032////////////////////////////////////////////////////////////////////////////////
1033/// Retrieve icons associated with class "name". Association is made
1034/// via the user's ~/.root.mimes file or via $ROOTSYS/etc/root.mimes.
1035
1037{
1038 TObject *obj = 0;
1039 TClass *cl;
1040 const TGPicture *pic=0;
1041 const char *iconname = 0;
1042
1043 if (f->InheritsFrom("TGLVEntry")) {
1044 obj = (TObject *)((TGLVEntry *)f)->GetUserData();
1045 if (obj) {
1046 if (obj->IsA() == TKey::Class()) {
1047 cl = TClass::GetClass(((TKey *)obj)->GetClassName());
1048 } else if (obj->IsA() == TKeyMapFile::Class()) {
1049 cl = TClass::GetClass(((TKeyMapFile *)obj)->GetTitle());
1050 } else {
1051 cl = obj->IsA();
1052 }
1053 const char *name = obj->GetIconName();
1054 if (((name == 0) || (!name[0])) && (cl != 0))
1055 name = cl->GetName();
1056 iconname = ((name != 0) && (strlen(name) > 0)) ? name : obj->GetName();
1057
1058 if (obj->IsA()->InheritsFrom("TGeoVolume")) {
1059 iconname = obj->GetIconName() ? obj->GetIconName() : obj->IsA()->GetName();
1060 }
1061 pic = fClient->GetMimeTypeList()->GetIcon(iconname, kFALSE);
1062 }
1063 }
1064 if (pic == 0) {
1065 if (obj && obj->IsFolder()) {
1066 pic = fClient->GetPicture("folder_s.xpm");
1067 } else {
1068 pic = fClient->GetPicture("doc_s.xpm");
1069 }
1070 }
1071 return pic;
1072}
1073
1074////////////////////////////////////////////////////////////////////////////////
1075/// Set drag window pixmaps and hotpoint.
1076
1078{
1079 Pixmap_t pic, mask;
1081 pic = selpic->GetPicture();
1082 mask = selpic->GetMask();
1083
1084 if (gDNDManager) {
1085 gDNDManager->SetDragPixmap(pic, mask, p->GetWidth()/2, 2+p->GetHeight()/2);
1086 } else {
1087 gVirtualX->DeletePixmap(pic);
1088 gVirtualX->DeletePixmap(mask);
1089 }
1090}
1091
1092////////////////////////////////////////////////////////////////////////////////
1093/// Handle double click mouse event.
1094
1096{
1098 TIter next(fList);
1099
1101
1102 Int_t xx = pos.fX + event->fX; // translate coordinates
1103 Int_t yy = pos.fY + event->fY;
1104
1106
1107 while ((el = (TGFrameElement *) next())) {
1109
1110 if (!fMapSubwindows) {
1111 if ((Int_t(el->fFrame->GetY()) + (Int_t)el->fFrame->GetHeight() > yy) &&
1112 (Int_t(el->fFrame->GetX()) + (Int_t)el->fFrame->GetWidth() > xx) &&
1113 (Int_t(el->fFrame->GetY()) < yy) &&
1114 (Int_t(el->fFrame->GetX()) < xx)) {
1116 }
1117 } else {
1118 if (el->fFrame->GetId() == (Window_t)event->fUser[0]) {
1120 }
1121 }
1122
1123 if (select_frame) {
1125 event->fCode, (event->fYRoot << 16) | event->fXRoot);
1126
1127 DoubleClicked(el->fFrame, event->fCode);
1128 DoubleClicked(el->fFrame, event->fCode, event->fXRoot, event->fYRoot);
1129 return kTRUE;
1130 }
1131 }
1132 return kTRUE;
1133}
1134
1135////////////////////////////////////////////////////////////////////////////////
1136/// Handle mouse motion events.
1137
1139{
1140 int xf0, yf0, xff, yff, total, selected;
1141
1144 Int_t x = pos.fX + event->fX;
1145 Int_t y = pos.fY + event->fY;
1146 TGFrameElement *el = 0;
1147 TGFrame *f = 0;
1149
1151
1152 if (gDNDManager->IsDragging()) {
1153 gDNDManager->Drag(event->fXRoot, event->fYRoot,
1155 }
1156 else if (fDragging) {
1157
1158 gVirtualX->DrawRectangle(fId, GetLineGC()(), fX0-pos.fX, fY0-pos.fY,
1159 fXf-fX0, fYf-fY0);
1160 fX0 = std::min(fXp,x);
1161 fY0 = std::min(fYp,y);
1162 fXf = std::max(fXp,x);
1163 fYf = std::max(fYp,y);
1164
1165 total = selected = 0;
1166
1167 if (event->fX > Int_t(dim.fWidth) - kAutoScrollFudge) {
1168 //fCanvas->SetHsbPosition(x - dim.fWidth);
1169 fScrolling = kTRUE;
1170 } else if (event->fX < kAutoScrollFudge) {
1171 //fCanvas->SetHsbPosition(x);
1172 fScrolling = kTRUE;
1173 } else if (event->fY > Int_t(dim.fHeight) - kAutoScrollFudge) {
1174 //fCanvas->SetVsbPosition(y - dim.fHeight);
1175 fScrolling = kTRUE;
1176 } else if (event->fY < kAutoScrollFudge) {
1177 //fCanvas->SetVsbPosition(y);
1178 fScrolling = kTRUE;
1179 }
1180 else {
1182 }
1183
1184 TIter next(fList);
1185
1186 while ((el = (TGFrameElement *) next())) {
1187 f = el->fFrame;
1188 ++total;
1189 xf0 = f->GetX() + (f->GetWidth() >> 3);
1190 yf0 = f->GetY() + (f->GetHeight() >> 3);
1191 xff = xf0 + f->GetWidth() - (f->GetWidth() >> 2);
1192 yff = yf0 + f->GetHeight() - (f->GetHeight() >> 2);
1193
1194 if (((xf0 > fX0 && xf0 < fXf) ||
1195 (xff > fX0 && xff < fXf)) &&
1196 ((yf0 > fY0 && yf0 < fYf) ||
1197 (yff > fY0 && yff < fYf))) {
1198 if (!el->fFrame->IsActive())
1200 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
1201 OnMouseOver(f);
1202 ++selected;
1203 } else {
1204 if (el->fFrame->IsActive())
1206 }
1207 }
1208
1209 if (fTotal != total || fSelected != selected) {
1210 fTotal = total;
1211 fSelected = selected;
1213 fTotal, fSelected);
1214 }
1215 gVirtualX->DrawRectangle(fId, GetLineGC()(), fX0-pos.fX, fY0-pos.fY,
1216 fXf-fX0, fYf-fY0);
1217 }
1218 else {
1219 TGFrame *over_frame = 0;
1220
1221 TIter next(fList);
1222
1223 while ((el = (TGFrameElement *) next())) {
1224 if (!fMapSubwindows) {
1225 if ((Int_t(el->fFrame->GetY()) + (Int_t)el->fFrame->GetHeight() > y) &&
1226 (Int_t(el->fFrame->GetX()) + (Int_t)el->fFrame->GetWidth() > x) &&
1227 (Int_t(el->fFrame->GetY()) < y) &&
1228 (Int_t(el->fFrame->GetX()) < x)) {
1229 over_frame = el->fFrame;
1230 break;
1231 }
1232 } else {
1233 if (el->fFrame->GetId() == (Window_t)event->fUser[0]) {
1234 over_frame = el->fFrame;
1235 break;
1236 }
1237 }
1238 }
1239 if (over_frame) {
1240 if (!gDNDManager->IsDragging()) {
1241 if (fBdown && ((abs(event->fX - fXDND) > 2) || (abs(event->fY - fYDND) > 2))) {
1242 if (gDNDManager && over_frame->IsDNDSource()) {
1245 gDNDManager->StartDrag(over_frame, event->fXRoot, event->fYRoot);
1246 }
1247 }
1248 }
1249 if (gDNDManager->IsDragging()) {
1250 gDNDManager->Drag(event->fXRoot, event->fYRoot,
1252 } else {
1254 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kHand));
1255 }
1256 } else {
1257 gVirtualX->SetCursor(fId, gVirtualX->CreateCursor(kPointer));
1258 }
1259 }
1260
1261 if (!wasScrolling && fScrolling) {
1262 if (gSystem) {
1265 }
1266 }
1267
1268 return kTRUE;
1269}
1270
1271////////////////////////////////////////////////////////////////////////////////
1272/// The key press event handler converts a key press to some line editor
1273/// action.
1274
1276{
1277 char input[10];
1278 Int_t n;
1279 UInt_t keysym;
1280
1281 if (event->fType == kGKeyPress) {
1282 gVirtualX->LookupString(event, input, sizeof(input), keysym);
1283 n = strlen(input);
1284
1286
1287 switch ((EKeySym)keysym) {
1288 case kKey_Enter:
1289 case kKey_Return:
1290 // treat 'Enter' and 'Return' as a double click
1292 kButton1, (event->fYRoot << 16) | event->fXRoot);
1294 break;
1295 case kKey_Shift:
1296 case kKey_Control:
1297 case kKey_Meta:
1298 case kKey_Alt:
1299 case kKey_CapsLock:
1300 case kKey_NumLock:
1301 case kKey_ScrollLock:
1302 return kTRUE;
1303 case kKey_Space:
1304 if (fLastActiveEl) {
1307 }
1308 break;
1309 default:
1310 break;
1311 }
1312
1313 if (event->fState & kKeyControlMask) { // Cntrl key modifier pressed
1314 switch((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1315 case kKey_A:
1316 SelectAll();
1317 break;
1318 case kKey_B:
1319 LineLeft();
1320 break;
1321 case kKey_C:
1322 return kTRUE;
1323 case kKey_D:
1324 break;
1325 case kKey_E:
1326 End();
1327 break;
1328 case kKey_F:
1329 Search();
1330 break;
1331 case kKey_G:
1332 RepeatSearch();
1333 break;
1334 case kKey_H:
1335 LineLeft();
1336 break;
1337 case kKey_K:
1338 End();
1339 break;
1340 case kKey_U:
1341 Home();
1342 break;
1343 case kKey_V:
1344 case kKey_Y:
1345 return kTRUE;
1346 case kKey_X:
1347 return kTRUE;
1348 default:
1349 return kTRUE;
1350 }
1351 }
1352 if (n && keysym >= 32 && keysym < 127 && // printable keys
1353 !(event->fState & kKeyControlMask) &&
1356
1357 if (fKeyTimerActive) {
1358 fKeyInput += input;
1359 } else {
1360 fKeyInput = input;
1362 fKeyTimer->Reset();
1364 }
1365 } else {
1366
1367 switch ((EKeySym)keysym) {
1368 case kKey_F3:
1369 RepeatSearch();
1370 break;
1371 case kKey_F5:
1372 Layout();
1373 break;
1374 case kKey_F7:
1375 Search();
1376 break;
1377 case kKey_Left:
1378 LineLeft(event->fState & kKeyShiftMask);
1379 break;
1380 case kKey_Right:
1381 LineRight(event->fState & kKeyShiftMask);
1382 break;
1383 case kKey_Up:
1384 LineUp(event->fState & kKeyShiftMask);
1385 break;
1386 case kKey_Down:
1387 LineDown(event->fState & kKeyShiftMask);
1388 break;
1389 case kKey_PageUp:
1390 PageUp(event->fState & kKeyShiftMask);
1391 break;
1392 case kKey_PageDown:
1393 PageDown(event->fState & kKeyShiftMask);
1394 break;
1395 case kKey_Home:
1396 Home(event->fState & kKeyShiftMask);
1397 break;
1398 case kKey_End:
1399 End(event->fState & kKeyShiftMask);
1400 break;
1401 default:
1402 break;
1403 }
1404 }
1405 }
1406 DoRedraw();
1407 return kTRUE;
1408}
1409
1410////////////////////////////////////////////////////////////////////////////////
1411/// Find frame by name.
1412
1414{
1415 if (!IsMapped()) return 0;
1416
1420
1422 caseSensitive = TGSearchDialog::SearchDialog()->GetType()->fCaseSensitive;
1423 direction = TGSearchDialog::SearchDialog()->GetType()->fDirection;
1424 }
1426 if (sname.Contains("*")) {
1427 subString = kTRUE;
1428 sname.ReplaceAll("*", "");
1429 }
1430
1433 if (!fe) { // find again
1435 fLastActiveEl = 0;
1437
1438 if (!fe) {
1440 TString msg = "Couldn't find \"" + fLastName + '\"';
1441 gVirtualX->Bell(20);
1442 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "Container", msg.Data(),
1444 }
1445 return 0;
1446 } else {
1450 return fe->fFrame;
1451 }
1452 } else {
1456 return fe->fFrame;
1457 }
1458 return 0;
1459}
1460
1461////////////////////////////////////////////////////////////////////////////////
1462/// Invokes search dialog. Looks for item with the entered name.
1463
1465{
1466 static TGSearchType *srch = 0;
1467 Int_t ret = 0;
1468
1469 if (!srch) srch = new TGSearchType;
1470 srch->fClose = close;
1471 srch->fBuffer = 0;
1472
1473 if (!close) {
1476 fCanvas, 400, 150, srch, &ret);
1477 }
1478 TGSearchDialog::SearchDialog()->Connect("TextEntered(char *)", "TGContainer", this,
1479 "FindFrameByName(char *)");
1480 TGSearchDialog::SearchDialog()->MapRaised();
1481 } else {
1482 new TGSearchDialog(fClient->GetDefaultRoot(), fCanvas, 400, 150, srch, &ret);
1483 if (ret) {
1484 FindFrameByName(srch->fBuffer);
1485 }
1486 }
1487}
1488
1489////////////////////////////////////////////////////////////////////////////////
1490/// Autoscroll while close to & beyond The Wall
1491
1493{
1494 TGFrameElement *el = 0;
1495 TGFrame *f = 0;
1496 int xf0, yf0, xff, yff, total, selected;
1497
1500
1502 Event_t ev;
1503 ev.fType = kButtonPress;
1504 Int_t x,y;
1505
1506 // Autoscroll while close to the wall
1507 Int_t dx = 0;
1508 Int_t dy = 0;
1509
1510 // Where's the cursor?
1511 gVirtualX->QueryPointer(fId,dum1,dum2,ev.fXRoot,ev.fYRoot,x,y,ev.fState);
1512
1513 // Figure scroll amount x
1514 if (x < kAutoScrollFudge)
1515 dx = kAutoScrollFudge - x;
1516 else if ((Int_t)dim.fWidth-kAutoScrollFudge <= x)
1517 dx = dim.fWidth - kAutoScrollFudge - x;
1518
1519 // Figure scroll amount y
1520 if (y < kAutoScrollFudge)
1521 dy = kAutoScrollFudge - y;
1522 else if ((Int_t)dim.fHeight - kAutoScrollFudge <= y)
1523 dy = dim.fHeight - kAutoScrollFudge - y;
1524
1525 if (dx || dy) {
1526 if (dx) dx /= 5;
1527 if (dy) dy /= 5;
1528 Int_t adx = std::abs(dx);
1529 Int_t ady = std::abs(dy);
1532
1533 dx *= kAcceleration[adx];
1534 dy *= kAcceleration[ady];
1535
1536 Int_t nx = pos.fX-dx;
1537 Int_t ny = pos.fY-dy;
1538
1541
1542 // position inside container
1543 x += pos.fX;
1544 y += pos.fY;
1545
1546 fX0 = std::min(fXp, x);
1547 fY0 = std::min(fYp, y);
1548 fXf = std::max(fXp, x);
1549 fYf = std::max(fYp ,y);
1550
1551 total = selected = 0;
1552
1553 TIter next(fList);
1554
1555 while ((el = (TGFrameElement *) next())) {
1556 f = el->fFrame;
1557 ++total;
1558 xf0 = f->GetX() + (f->GetWidth() >> 3);
1559 yf0 = f->GetY() + (f->GetHeight() >> 3);
1560 xff = xf0 + f->GetWidth() - (f->GetWidth() >> 2);
1561 yff = yf0 + f->GetHeight() - (f->GetHeight() >> 2);
1562
1563 if (((xf0 > fX0 && xf0 < fXf) ||
1564 (xff > fX0 && xff < fXf)) &&
1565 ((yf0 > fY0 && yf0 < fYf) ||
1566 (yff > fY0 && yff < fYf))) {
1567 if (!el->fFrame->IsActive())
1569 ++selected;
1570 } else {
1571 if (el->fFrame->IsActive())
1573 }
1574 }
1575 gVirtualX->DrawRectangle(fId, GetLineGC()(), fX0-pos.fX, fY0-pos.fY,
1576 fXf-fX0, fYf-fY0);
1577
1578 if (fTotal != total || fSelected != selected) {
1579 fTotal = total;
1580 fSelected = selected;
1582 fTotal, fSelected);
1583 }
1584 ClearViewPort();
1585 DoRedraw();
1586 gVirtualX->DrawRectangle(fId, GetLineGC()(), fX0-pos.fX, fY0-pos.fY,
1587 fXf-fX0, fYf-fY0);
1588 }
1589}
1590
1591////////////////////////////////////////////////////////////////////////////////
1592/// Search for entry which name begins with pattern.
1593
1595{
1596 TGFrameElement *fe = 0;
1597 TIter next(fList);
1598 TString str;
1599
1600 while ((fe=( TGFrameElement*)next())) {
1601 str = fe->fFrame->GetTitle();
1602
1603 if (str.BeginsWith(fKeyInput,TString::kIgnoreCase)) {
1604 if (fLastActiveEl && (fLastActiveEl!=fe) ) {
1606 }
1609 break;
1610 }
1611 }
1612
1613 fKeyInput = ""; //clear
1615}
1616
1617////////////////////////////////////////////////////////////////////////////////
1618/// Repeats search.
1619
1621{
1622 TGFrameElement *fe = 0;
1623
1624 if (fLastName == "")
1625 return Search();
1626
1628
1629 if (!fe) {
1631 fLastActiveEl = 0;
1633
1634 if (!fe) {
1635 TString msg = "Couldn't find \"" + fLastName + '\"';
1636 gVirtualX->Bell(50);
1637 new TGMsgBox(fClient->GetDefaultRoot(), fCanvas, "Container", msg.Data(),
1639 } else {
1643 }
1644 } else {
1648 }
1649}
1650
1651////////////////////////////////////////////////////////////////////////////////
1652/// Find frame located int container at position x,y.
1653
1655{
1656 TIter next(fList);
1658 TGFrameElement *ret = 0;
1659 Int_t dx = 0;
1660 Int_t dy = 0;
1661 Int_t d = 0;
1662 Int_t dd;
1663
1664 el = (TGFrameElement *) next();
1665 if (!el) return 0;
1666
1667 dx = std::abs(el->fFrame->GetX()-x);
1668 dy = std::abs(el->fFrame->GetY()-y);
1669 d = dx + dy;
1670
1671 while ((el = (TGFrameElement *) next())) {
1672 if (exclude && (el==fLastActiveEl) ) continue;
1673 dx = std::abs(el->fFrame->GetX()-x);
1674 dy = std::abs(el->fFrame->GetY()-y);
1675 dd = dx+dy;
1676
1677 if (dd<d) {
1678 d = dd;
1679 ret = el;
1680 }
1681 }
1682 return ret;
1683}
1684
1685////////////////////////////////////////////////////////////////////////////////
1686
1689{
1690 // Find a frame which associated object has a name containing a "name"
1691 // string.
1692
1693 if (name.IsNull()) return 0;
1694 int idx = kNPOS;
1695
1696 TGFrameElement *el = 0;
1697 TString str;
1699
1702 fLastName = name;
1704
1705 if (fLastActiveEl) {
1706 el = fLastActiveEl;
1707
1708 if (direction) {
1710 } else {
1712 }
1713 } else {
1714 if (direction) el = (TGFrameElement *)fList->First();
1715 else el = (TGFrameElement *)fList->Last();
1716 }
1717
1718 while (el) {
1719 str = el->fFrame->GetTitle();
1720 idx = str.Index(name, 0, cmp);
1721
1722 if (idx != kNPOS) {
1723 if (subString) {
1724 return el;
1725 } else {
1726 if (str.Length() == name.Length()) return el;
1727 }
1728 }
1729
1730 if (direction) {
1732 } else {
1734 }
1735 }
1736 return 0;
1737}
1738
1739////////////////////////////////////////////////////////////////////////////////
1740/// returns pointer to hor. scroll bar
1741
1743{
1744 return fCanvas ? fCanvas->GetHScrollbar() : 0;
1745}
1746
1747////////////////////////////////////////////////////////////////////////////////
1748/// returns pointer to vert. scroll bar
1749
1751{
1752 return fCanvas ? fCanvas->GetVScrollbar() : 0;
1753}
1754
1755////////////////////////////////////////////////////////////////////////////////
1756/// Set position of vertical scrollbar.
1757
1759{
1760 if (!fViewPort) return;
1762
1763 if (vb && vb->IsMapped()) {
1764 vb->SetRange((Int_t)GetHeight(), (Int_t)fViewPort->GetHeight());
1765 vb->SetPosition(newPos);
1766 } else {
1767 fViewPort->SetVPos(0);
1768 }
1769}
1770
1771////////////////////////////////////////////////////////////////////////////////
1772/// set new hor. position
1773
1775{
1776 if (!fViewPort) return;
1778
1779 if (hb && hb->IsMapped()) {
1780 hb->SetRange((Int_t)GetWidth(), (Int_t)fViewPort->GetWidth());
1781 hb->SetPosition(newPos);
1782 } else {
1783 fViewPort->SetHPos(0);
1784 }
1785}
1786
1787////////////////////////////////////////////////////////////////////////////////
1788/// Move content to position of highlighted/activated frame.
1789
1791{
1792 if (!fViewPort) return;
1793 if (!fLastActiveEl) return;
1795
1796 Int_t vh = 0;
1797 Int_t v = 0;
1798
1801 Int_t pos = GetPagePosition().fY;
1802 Int_t pg;
1803
1804
1805 if (vb && vb->IsMapped()) {
1806 pg = (vb->GetPageSize()*GetHeight())/fViewPort->GetHeight();
1807 vh = pos + (Int_t)fViewPort->GetHeight();
1808
1809 if (f->GetY() < pos) {
1810 v = std::max(0, f->GetY() - (Int_t)fViewPort->GetHeight()/2);
1811 v = (v*pg)/GetHeight();
1812
1814 } else if (f->GetY() + (Int_t)f->GetHeight() > vh) {
1815 v = std::min((Int_t)GetHeight() - (Int_t)fViewPort->GetHeight(),
1816 f->GetY() + (Int_t)f->GetHeight() - (Int_t)fViewPort->GetHeight()/2);
1817 v = (v*pg)/GetHeight();
1819 }
1820 }
1821
1822 Int_t hw = 0;
1823 Int_t h = 0;
1824
1825 if (hb && hb->IsMapped() && (!vb || (vb && !vb->IsMapped()))) {
1826 pg = (hb->GetPageSize()*GetWidth())/fViewPort->GetWidth();
1827 pos =GetPagePosition().fX;
1828 hw = pos + (Int_t)fViewPort->GetWidth();
1829
1830 if (f->GetX() < pos) {
1831 h = std::max(0, f->GetX() - (Int_t)fViewPort->GetWidth()/2);
1832 h = (h*pg)/GetWidth();
1833
1835 } else if (f->GetX() + (Int_t)f->GetWidth() > hw) {
1836 h = std::min((Int_t)GetWidth() - (Int_t)fViewPort->GetWidth(),
1837 f->GetX() + (Int_t)f->GetWidth() - (Int_t)fViewPort->GetWidth()/2);
1838 h = (h*pg)/GetWidth();
1839
1841 }
1842 }
1843}
1844
1845////////////////////////////////////////////////////////////////////////////////
1846/// Move current position one column left.
1847
1849{
1852
1854 if (!fe) return; // empty list
1855
1857
1858 if (old) DeActivateItem(old); //
1859 else fLastActiveEl = fe;
1860
1862 Int_t dx = la->fLayout->GetPadLeft() + la->fLayout->GetPadRight();
1863 Int_t dy = la->fLayout->GetPadTop() + la->fLayout->GetPadBottom();
1864 Int_t y = la->fFrame->GetY();
1865 Int_t x = la->fFrame->GetX() - dx;
1866
1867 Int_t hw = pos.fX + dim.fWidth;
1868
1870 if (x<=0 && (hb && !hb->IsMapped())) { // move to previous line
1871 x = hw;
1872 y = y - la->fFrame->GetDefaultHeight() - dy;
1873 }
1874
1875 fe = FindFrame(x, y);
1876 if (!fe) fe = (TGFrameElement*)fList->First();
1877
1878 if (!select) fSelected=1;
1879
1882}
1883
1884////////////////////////////////////////////////////////////////////////////////
1885/// Move current position one column right.
1886
1888{
1891
1893 if (!fe) return;
1894
1896
1897 if (old) DeActivateItem(old);
1899
1904
1905 Int_t hw = pos.fX + dim.fWidth - dx;
1906
1908 if (x >= hw && (hb && !hb->IsMapped())) { // move one line down
1909 x = 0;
1911 }
1912
1913 fe = FindFrame(x, y);
1914 if (!fe) fe = (TGFrameElement*)fList->Last();
1915 if (!select) fSelected = 1;
1916
1919}
1920
1921////////////////////////////////////////////////////////////////////////////////
1922/// Make current position first line in window by scrolling up.
1923
1925{
1927 if (!fe) return;
1928
1930
1931 if (old) {
1932 DeActivateItem(old);
1933 } else {
1935 }
1936
1940
1941 fe = FindFrame(x, y);
1942 if (!fe) fe = (TGFrameElement*)fList->First();
1943 if (fe->fFrame->GetY() > fLastActiveEl->fFrame->GetY()) fe = fLastActiveEl;
1944 if (!select) fSelected = 1;
1945
1948}
1949
1950////////////////////////////////////////////////////////////////////////////////
1951/// Move one line down.
1952
1954{
1956 if (!fe) return;
1957
1959
1960 if (old) DeActivateItem(old);
1962
1967
1968 fe = FindFrame(x, y);
1969 if (!fe) fe = (TGFrameElement*)fList->Last();
1970 if (fe->fFrame->GetY() < fLastActiveEl->fFrame->GetY()) fe = fLastActiveEl;
1971 if (!select) fSelected = 1;
1972
1975}
1976
1977////////////////////////////////////////////////////////////////////////////////
1978/// Move position one page up.
1979
1981{
1983
1985 if (!fe) return;
1986
1988
1989 if (old) DeActivateItem(old);
1991
1994
1997
1998 if (vb && vb->IsMapped()) {
1999 y -= dim.fHeight;
2000 } else {
2001 if (hb && hb->IsMapped()) {
2002 x -= dim.fWidth;
2003 } else {
2004 Home();
2005 return;
2006 }
2007 }
2008
2009 fe = FindFrame(x, y);
2010
2011 if (!fe || fe->fFrame->GetY()>fLastActiveEl->fFrame->GetY()) {
2013 }
2014
2015 if (!select) fSelected = 1;
2016
2019}
2020
2021////////////////////////////////////////////////////////////////////////////////
2022/// Move position one page down.
2023
2025{
2027
2028 TList *li = GetList();
2030 if (!fe) return;
2031
2033
2034 if (old) DeActivateItem(old);
2036
2039
2042
2043 if (vb && vb->IsMapped()) {
2044 y += dim.fHeight;
2045 } else {
2046 if (hb && hb->IsMapped()) {
2047 x += dim.fWidth;
2048 } else {
2049 End();
2050 return;
2051 }
2052 }
2053
2054 fe = FindFrame(x, y);
2055 if (!fe || fe->fFrame->GetY()<fLastActiveEl->fFrame->GetY() ) {
2056 fe = (TGFrameElement*)li->Last();
2057 }
2058
2059 if (!select) fSelected = 1;
2060
2063}
2064
2065////////////////////////////////////////////////////////////////////////////////
2066/// Move to upper-left corner of container.
2067
2069{
2071 if (!fe) return;
2072
2074 if (old) DeActivateItem(old);
2075
2076 if (!select) fSelected = 1;
2077
2080}
2081
2082////////////////////////////////////////////////////////////////////////////////
2083/// Move to the bottom-right corner of container.
2084
2086{
2088 if (!fe) return;
2089
2091 if (old) DeActivateItem(old);
2092
2093 if (!select) fSelected = 1;
2094
2097}
2098
2099////////////////////////////////////////////////////////////////////////////////
2100/// Get graphics context for line drawing.
2101
2103{
2104 if (!fgLineGC) {
2109 gval.fForeground = fgWhitePixel ^ fgBlackPixel;
2110 gval.fBackground = fgWhitePixel;
2111 gval.fFunction = kGXxor;
2112 gval.fLineWidth = 0;
2113 gval.fLineStyle = kLineOnOffDash;
2114 gval.fFillStyle = kFillSolid;
2115 gval.fSubwindowMode = kIncludeInferiors;
2116 gval.fGraphicsExposures = kFALSE;
2117 fgLineGC = gClient->GetGC(&gval, kTRUE);
2118 fgLineGC->SetDashOffset(0);
2119 fgLineGC->SetDashList("\x1\x1", 2);
2120 }
2121 return *fgLineGC;
2122}
2123
2124////////////////////////////////////////////////////////////////////////////////
2125/// Create a canvas object.
2126
2148
2149////////////////////////////////////////////////////////////////////////////////
2150/// Delete canvas.
2151
2153{
2154 delete fHScrollbar;
2155 delete fVScrollbar;
2156 delete fVport;
2157}
2158
2159////////////////////////////////////////////////////////////////////////////////
2160/// Map all canvas sub windows.
2161
2163{
2166
2167 if (fVport) {
2169 if (!container) {
2170 Error("MapSubwindows", "no canvas container set yet");
2171 return;
2172 }
2173 container->MapSubwindows();
2175 fVport->MapWindow();
2176 Layout();
2177 }
2178}
2179
2180////////////////////////////////////////////////////////////////////////////////
2181/// Adding a frame to a canvas is actually adding the frame to the
2182/// viewport container. The viewport container must be at least a
2183/// TGCompositeFrame for this method to succeed.
2184
2186{
2188 if (!container) {
2189 Error("AddFrame", "no canvas container set yet");
2190 return;
2191 }
2192 if (container->InheritsFrom(TGCompositeFrame::Class()))
2193 ((TGCompositeFrame*)container)->AddFrame(f, l);
2194 else
2195 Error("AddFrame", "canvas container must inherit from TGCompositeFrame");
2196}
2197
2198////////////////////////////////////////////////////////////////////////////////
2199/// Draw canvas border.
2200
2202{
2205 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
2206 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
2207 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
2208 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
2209 if (gClient->GetStyle() > 1) break;
2210 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
2211 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
2212 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
2213 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
2214 break;
2215
2216 default:
2218 break;
2219 }
2220}
2221
2222////////////////////////////////////////////////////////////////////////////////
2223/// Create layout for canvas. Depending on the size of the container
2224/// we need to add the scrollbars.
2225
2227{
2229 UInt_t cw, ch, tcw, tch;
2230
2232
2234 if (!container) {
2235 Error("Layout", "no canvas container set yet");
2236 return;
2237 }
2238
2239 Bool_t fixedw = container->IsLayoutBroken() || (container->GetOptions() & kFixedWidth) ?
2240 kTRUE : kFALSE;
2241 Bool_t fixedh = container->IsLayoutBroken() || (container->GetOptions() & kFixedHeight) ?
2242 kTRUE : kFALSE;
2243
2244 // test whether we need scrollbars
2245 cw = fWidth - UInt_t(fBorderWidth << 1);
2246 ch = fHeight - UInt_t(fBorderWidth << 1);
2247
2248 if (!fixedw) container->SetWidth(cw);
2249 if (!fixedh) container->SetHeight(ch);
2250
2251 if (container->GetDefaultWidth() > cw) {
2253 need_hsb = kTRUE;
2255 if ((Int_t) ch < 0) {
2256 //Warning("Layout", "height would become too small, setting to 10");
2257 ch = 10;
2258 }
2259 if (!fixedh) container->SetHeight(ch);
2260 }
2261 }
2262
2263 if (container->GetDefaultHeight() > ch) {
2265 need_vsb = kTRUE;
2267 if ((Int_t) cw < 0) {
2268 //Warning("Layout", "width would become too small, setting to 10");
2269 cw = 10;
2270 }
2271 if (!fixedw) container->SetWidth(cw);
2272 }
2273 }
2274
2275 // re-check again (putting the vertical scrollbar could have changed things)
2276
2277 if (container->GetDefaultWidth() > cw) {
2278 if (!need_hsb) {
2280 need_hsb = kTRUE;
2282 if ((Int_t) ch < 0) {
2283 //Warning("Layout", "height would become too small, setting to 10");
2284 ch = 10;
2285 }
2286 if (!fixedh) container->SetHeight(ch);
2287 }
2288 }
2289 }
2290
2292
2293 tcw = std::max(container->GetDefaultWidth(), cw);
2294 tch = std::max(container->GetDefaultHeight(), ch);
2295 UInt_t curw = container->GetDefaultWidth();
2296
2297 container->SetWidth(0); // force a resize in TGFrame::Resize
2298
2299 if (fixedw && fixedh) {
2300 container->Resize(curw, container->GetDefaultHeight());
2301 } else if (fixedw) {
2302 container->Resize(curw, tch);
2303 } else if (fixedh) {
2304 container->Resize(tcw, container->GetDefaultHeight());
2305 } else {
2306 container->Resize(tcw, tch);
2307 }
2308
2309 if (fHScrollbar) {
2310 if (need_hsb) {
2314 } else {
2317 if (container->IsLayoutBroken()) {
2318 container->Resize(fVport->GetWidth(), container->GetHeight());
2319 }
2320 }
2321 }
2322
2323 if (fVScrollbar) {
2324 if (need_vsb) {
2328 } else {
2331 if (container->IsLayoutBroken()) {
2332 container->Resize(container->GetWidth(), fVport->GetHeight());
2333 }
2334 }
2335 }
2336}
2337
2338////////////////////////////////////////////////////////////////////////////////
2339/// Handle message generated by the canvas scrollbars.
2340
2342{
2343 switch (GET_MSG(msg)) {
2344 case kC_HSCROLL:
2345 switch (GET_SUBMSG(msg)) {
2346 case kSB_SLIDERTRACK:
2347 case kSB_SLIDERPOS:
2349 break;
2350 }
2351 break;
2352
2353 case kC_VSCROLL:
2354 switch (GET_SUBMSG(msg)) {
2355 case kSB_SLIDERTRACK:
2356 case kSB_SLIDERPOS:
2358 break;
2359 }
2360 break;
2361
2362 default:
2363 break;
2364 }
2365 return kTRUE;
2366}
2367
2368////////////////////////////////////////////////////////////////////////////////
2369/// Get position of horizontal scrollbar.
2370
2372{
2374 return fHScrollbar->GetPosition();
2375 return 0;
2376}
2377
2378////////////////////////////////////////////////////////////////////////////////
2379/// Get position of vertical scrollbar.
2380
2382{
2384 return fVScrollbar->GetPosition();
2385 return 0;
2386}
2387
2388////////////////////////////////////////////////////////////////////////////////
2389/// Set position of horizontal scrollbar.
2390
2392{
2393 if (fHScrollbar && fHScrollbar->IsMapped()) {
2397 } else {
2398 fVport->SetHPos(0);
2399 }
2400}
2401
2402////////////////////////////////////////////////////////////////////////////////
2403/// Set position of vertical scrollbar.
2404
2406{
2407 if (fVScrollbar && fVScrollbar->IsMapped()) {
2411 } else {
2412 fVport->SetVPos(0);
2413 }
2414}
2415
2416////////////////////////////////////////////////////////////////////////////////
2417/// Set scrolling policy. Use values defined by the enum: kCanvasNoScroll,
2418/// kCanvasScrollHorizontal, kCanvasScrollVertical, kCanvasScrollBoth.
2419
2421{
2422 if (scrolling != fScrolling) {
2424 Layout();
2425 }
2426}
2427
2428////////////////////////////////////////////////////////////////////////////////
2429/// Clear view port and redraw content.
2430
2432{
2434 if (!cont) return;
2435
2436 gVirtualX->ClearArea(cont->GetId(), 0, 0, fVport->GetWidth(), fVport->GetHeight());
2438}
2439
2440////////////////////////////////////////////////////////////////////////////////
2441/// Save a canvas widget as a C++ statement(s) on output stream out.
2442
2443void TGCanvas::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2444{
2446
2447 out << "\n // canvas widget\n";
2448
2449 out << " TGCanvas *" << GetName() << " = new TGCanvas(" << fParent->GetName() << "," << GetWidth() << ","
2450 << GetHeight() << extra_args << ");\n";
2451
2452 if (option && strstr(option, "keep_names"))
2453 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2454
2456 out << "\n // canvas viewport\n";
2457 out << " TGViewPort *" << vp->GetName() << " = " << GetName() << "->GetViewPort();\n";
2458
2460 cont->SavePrimitive(out, option);
2461
2462 out << " " << vp->GetName() << "->AddFrame(" << cont->GetName() << ");\n";
2463
2464 out << " " << cont->GetName() << "->SetLayoutManager(";
2465 cont->GetLayoutManager()->SavePrimitive(out, option);
2466 out << ");\n";
2467
2468 out << " " << cont->GetName() << "->MapSubwindows();\n";
2469
2470 out << " " << GetName() << "->SetContainer(" << cont->GetName() << ");\n";
2471
2472 out << " " << GetName() << "->MapSubwindows();\n";
2473
2475 out << " " << GetName() << "->SetHsbPosition(" << GetHsbPosition() << ");\n";
2476
2478 out << " " << GetName() << "->SetVsbPosition(" << GetVsbPosition() << ");\n";
2479}
2480
2481////////////////////////////////////////////////////////////////////////////////
2482/// Save a canvas container as a C++ statement(s) on output stream out.
2483
2484void TGContainer::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
2485{
2486 // save options and custom color if not default
2488
2489 out << "\n // canvas container\n";
2490
2491 out << " TGContainer *" << GetName() << " = new TGContainer(";
2492 if ((fParent->GetParent())->InheritsFrom(TGCanvas::Class()))
2493 out << GetCanvas()->GetName();
2494 else
2495 out << fParent->GetName() << "," << GetWidth() << "," << GetHeight();
2496 out << extra_args << ");\n";
2497
2498 if (option && strstr(option, "keep_names"))
2499 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
2500}
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonRelease
Definition GuiTypes.h:60
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kWABitGravity
Definition GuiTypes.h:144
const Mask_t kGCBackground
Definition GuiTypes.h:289
const Mask_t kGCForeground
Definition GuiTypes.h:288
const Mask_t kGCLineStyle
Definition GuiTypes.h:291
const Mask_t kGCSubwindowMode
Definition GuiTypes.h:301
const Mask_t kGCLineWidth
Definition GuiTypes.h:290
@ kHand
Definition GuiTypes.h:374
@ kPointer
Definition GuiTypes.h:375
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
const Mask_t kGCFillStyle
Definition GuiTypes.h:294
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWAWinGravity
Definition GuiTypes.h:145
const Mask_t kGCFunction
Definition GuiTypes.h:286
const Mask_t kAnyModifier
Definition GuiTypes.h:210
@ kGXxor
src XOR dst
Definition GuiTypes.h:74
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kFixedHeight
Definition GuiTypes.h:389
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
@ kDefaultScrollBarWidth
Definition GuiTypes.h:86
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
@ kIncludeInferiors
Definition GuiTypes.h:53
@ kFillSolid
Definition GuiTypes.h:51
@ kLineOnOffDash
Definition GuiTypes.h:48
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kGCGraphicsExposures
Definition GuiTypes.h:302
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton4
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:215
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_G
Definition KeySymbols.h:132
@ kKey_Meta
Definition KeySymbols.h:51
@ kKey_Space
Definition KeySymbols.h:93
@ kKey_Y
Definition KeySymbols.h:150
@ kKey_B
Definition KeySymbols.h:127
@ kKey_PageDown
Definition KeySymbols.h:47
@ kKey_F
Definition KeySymbols.h:131
@ kKey_CapsLock
Definition KeySymbols.h:53
@ kKey_F5
Definition KeySymbols.h:61
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_Alt
Definition KeySymbols.h:52
@ kKey_C
Definition KeySymbols.h:128
@ kKey_ScrollLock
Definition KeySymbols.h:55
@ kKey_Delete
Definition KeySymbols.h:33
@ kKey_A
Definition KeySymbols.h:126
@ kKey_F3
Definition KeySymbols.h:59
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_Shift
Definition KeySymbols.h:49
@ kKey_E
Definition KeySymbols.h:130
@ kKey_Backspace
Definition KeySymbols.h:29
@ kKey_D
Definition KeySymbols.h:129
@ kKey_X
Definition KeySymbols.h:149
@ kKey_Home
Definition KeySymbols.h:38
@ kKey_U
Definition KeySymbols.h:146
@ kKey_Enter
Definition KeySymbols.h:31
@ kKey_Control
Definition KeySymbols.h:50
@ kKey_H
Definition KeySymbols.h:133
@ kKey_End
Definition KeySymbols.h:39
@ kKey_NumLock
Definition KeySymbols.h:54
@ kKey_PageUp
Definition KeySymbols.h:45
@ kKey_K
Definition KeySymbols.h:136
@ kKey_V
Definition KeySymbols.h:147
@ kKey_F7
Definition KeySymbols.h:63
#define d(i)
Definition RSha256.hxx:102
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Longptr_t
Integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:89
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
Definition RtypesCore.h:60
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
const Int_t kKeyboardTime
Definition TGCanvas.cxx:84
const Int_t kAutoScrollFudge
Definition TGCanvas.cxx:82
const Int_t kAcceleration[kAutoScrollFudge+1]
Definition TGCanvas.cxx:83
#define gClient
Definition TGClient.h:157
R__EXTERN TGDNDManager * gDNDManager
@ kMBOk
Definition TGMsgBox.h:33
@ kMBIconExclamation
Definition TGMsgBox.h:24
static unsigned int total
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t rect
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void xpos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void ypos
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t gval
char name[80]
Definition TGX11.cxx:110
R__EXTERN void * gTQSender
Definition TQObject.h:46
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Int_t GET_MSG(Long_t val)
@ kCT_SELCHANGED
@ kSB_SLIDERTRACK
@ kSB_SLIDERPOS
@ kC_VSCROLL
@ kCT_ITEMCLICK
@ kCT_KEY
@ kC_HSCROLL
@ kCT_ITEMDBLCLICK
@ kC_CONTAINER
Int_t GET_SUBMSG(Long_t val)
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2973
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
~TGCanvas() override
Delete canvas.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a canvas widget as a C++ statement(s) on output stream out.
void DrawBorder() override
Draw canvas border.
TGFrame * GetContainer() const
Definition TGCanvas.h:216
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
virtual void SetHsbPosition(Int_t newPos)
Set position of horizontal scrollbar.
virtual Int_t GetVsbPosition() const
Get position of vertical scrollbar.
TGViewPort * fVport
viewport through which we look at contents
Definition TGCanvas.h:195
Int_t fScrolling
flag which scrolling modes are allowed
Definition TGCanvas.h:198
TGHScrollBar * fHScrollbar
horizontal scrollbar
Definition TGCanvas.h:196
TGVScrollBar * GetVScrollbar() const
Definition TGCanvas.h:219
TGVScrollBar * fVScrollbar
vertical scrollbar
Definition TGCanvas.h:197
TGViewPort * GetViewPort() const
Definition TGCanvas.h:217
void MapSubwindows() override
Map all canvas sub windows.
virtual Int_t GetHsbPosition() const
Get position of horizontal scrollbar.
virtual void ClearViewPort()
Clear view port and redraw content.
void SetScrolling(Int_t scrolling)
Set scrolling policy.
Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override
Handle message generated by the canvas scrollbars.
@ kCanvasScrollVertical
Definition TGCanvas.h:207
@ kCanvasScrollBoth
Definition TGCanvas.h:208
@ kCanvasScrollHorizontal
Definition TGCanvas.h:206
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Adding a frame to a canvas is actually adding the frame to the viewport container.
TGCanvas(const TGCanvas &)=delete
void Layout() override
Create layout for canvas.
TGHScrollBar * GetHScrollbar() const
Definition TGCanvas.h:218
static TClass * Class()
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
TGMimeTypes * GetMimeTypeList() const
Definition TGClient.h:147
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:380
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1109
virtual TList * GetList() const
Definition TGFrame.h:312
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:340
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1156
void Layout() override
Layout the elements of the composite frame.
Definition TGFrame.cxx:1249
Bool_t fMapSubwindows
kTRUE - map subwindows
Definition TGFrame.h:297
TList * fList
container of frame elements
Definition TGFrame.h:294
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1141
static TClass * Class()
TGContainer * fContainer
Definition TGCanvas.cxx:92
TGContainerKeyboardTimer(TGContainer *t)
Definition TGCanvas.cxx:94
Bool_t Notify() override
single shot timer
Definition TGCanvas.cxx:101
TGContainerScrollTimer(TGContainer *t)
Definition TGCanvas.cxx:115
Bool_t Notify() override
on-timeout
Definition TGCanvas.cxx:122
TGContainer * fContainer
Definition TGCanvas.cxx:113
Manages a content area.
Definition TGCanvas.h:31
TGRectangle fExposedRegion
exposed area
Definition TGCanvas.h:62
virtual void ActivateItem(TGFrameElement *el)
Activate item.
Definition TGCanvas.cxx:698
Bool_t fKeyTimerActive
kTRUE - keyboard timer is active
Definition TGCanvas.h:58
virtual void RemoveItem(TGFrame *item)
Remove item from container.
Definition TGCanvas.cxx:657
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
TGCanvas * fCanvas
pointer to canvas
Definition TGCanvas.h:41
TTimer * fScrollTimer
autoscroll timer
Definition TGCanvas.h:50
virtual void RepeatSearch()
Repeats search.
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click mouse event.
Int_t fYf
other corner of rubber band box
Definition TGCanvas.h:46
virtual void UnSelectAll()
Unselect all items in the container.
Definition TGCanvas.cxx:586
virtual void PageDown(Bool_t select=kFALSE)
Move position one page down.
virtual void LineLeft(Bool_t select=kFALSE)
Move current position one column left.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in container.
Definition TGCanvas.cxx:926
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:888
const TGWindow * fMsgWindow
window handling container messages
Definition TGCanvas.h:42
virtual TGFrameElement * FindFrame(Int_t x, Int_t y, Bool_t exclude=kTRUE)
Find frame located int container at position x,y.
Int_t fYp
previous pointer position
Definition TGCanvas.h:44
virtual void AdjustPosition()
Move content to position of highlighted/activated frame.
~TGContainer() override
Delete canvas container.
Definition TGCanvas.cxx:403
virtual void OnMouseOver(TGFrame *)
Signal emitted when pointer is over entry.
Definition TGCanvas.cxx:498
virtual void Clicked(TGFrame *f, Int_t btn)
Emit Clicked() signal.
Definition TGCanvas.cxx:507
virtual void InvertSelection()
Invert the selection, all selected items become unselected and vice versa.
Definition TGCanvas.cxx:611
virtual void PageUp(Bool_t select=kFALSE)
Move position one page up.
virtual void LineDown(Bool_t select=kFALSE)
Move one line down.
virtual const TGFrame * GetNextSelected(void **current)
Return the next selected item.
Definition TGCanvas.cxx:678
Bool_t HandleExpose(Event_t *event) override
Handle expose events. Do not use double buffer.
Definition TGCanvas.cxx:900
virtual void Search(Bool_t close=kTRUE)
Invokes search dialog. Looks for item with the entered name.
virtual void LineUp(Bool_t select=kFALSE)
Make current position first line in window by scrolling up.
void Layout() override
Layout container entries.
Definition TGCanvas.cxx:419
Bool_t fLastDir
direction of last search
Definition TGCanvas.h:52
Int_t fY0
corner of rubber band box
Definition TGCanvas.h:45
virtual void Home(Bool_t select=kFALSE)
Move to upper-left corner of container.
virtual void KeyPressed(TGFrame *, UInt_t keysym, UInt_t mask)
Signal emitted when keyboard key pressed.
Definition TGCanvas.cxx:467
virtual void SetDragPixmap(const TGPicture *pic)
Set drag window pixmaps and hotpoint.
const TGPicture * GetObjPicture(TGFrame *f)
Retrieve icons associated with class "name".
virtual void SetVsbPosition(Int_t newPos)
Set position of vertical scrollbar.
Int_t fXDND
Definition TGCanvas.h:60
TGCanvas * GetCanvas() const
Definition TGCanvas.h:99
virtual void ReturnPressed(TGFrame *)
Signal emitted when Return/Enter key pressed.
Definition TGCanvas.cxx:481
virtual void SearchPattern()
Search for entry which name begins with pattern.
virtual void SetPageDimension(const TGDimension &dim)
Set page dimension.
Definition TGCanvas.cxx:779
virtual void LineRight(Bool_t select=kFALSE)
Move current position one column right.
TGContainer(const TGContainer &)=delete
Int_t fSelected
number of selected items
Definition TGCanvas.h:49
Bool_t fBdown
Definition TGCanvas.h:61
static TClass * Class()
void DoRedraw() override
Redraw content of container in the viewport region.
Definition TGCanvas.cxx:797
virtual void SpacePressed(TGFrame *)
Signal emitted when space key pressed.
Definition TGCanvas.cxx:490
virtual void SetHsbPosition(Int_t newPos)
set new hor. position
Bool_t fScrolling
kTRUE - when scrolling is ON
Definition TGCanvas.h:59
Int_t fX0
Definition TGCanvas.h:45
virtual TGDimension GetPageDimension() const
Returns page dimension.
Definition TGCanvas.cxx:748
TString fLastName
the name of object of last search
Definition TGCanvas.h:55
virtual void OnAutoScroll()
Autoscroll while close to & beyond The Wall.
Int_t fXp
Definition TGCanvas.h:44
static const TGGC & GetLineGC()
Get graphics context for line drawing.
static TGGC * fgLineGC
Definition TGCanvas.h:64
Bool_t fDragging
true if in dragging mode
Definition TGCanvas.h:47
virtual void CurrentChanged(Int_t x, Int_t y)
Emit signal when current position changed.
Definition TGCanvas.cxx:431
virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
Draw a region of container in viewport.
Definition TGCanvas.cxx:816
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a canvas container as a C++ statement(s) on output stream out.
friend class TGContainerScrollTimer
Definition TGCanvas.h:36
TGViewPort * fViewPort
container viewport
Definition TGCanvas.h:40
virtual TGVScrollBar * GetVScrollbar() const
returns pointer to vert. scroll bar
virtual TGFrame * FindFrameByName(const char *name)
Find frame by name.
Int_t fYDND
Definition TGCanvas.h:60
friend class TGContainerKeyboardTimer
Definition TGCanvas.h:35
virtual void * FindItem(const TString &name, Bool_t direction=kTRUE, Bool_t caseSensitive=kTRUE, Bool_t subString=kFALSE)
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events.
Bool_t fOnMouseOver
kTRUE when mouse pointer is over entry
Definition TGCanvas.h:51
Bool_t fLastCase
case sensitivity of last search
Definition TGCanvas.h:53
Int_t fTotal
total items
Definition TGCanvas.h:48
const TGWindow * GetMessageWindow() const
Definition TGCanvas.h:100
void RemoveAll() override
Remove all items from the container.
Definition TGCanvas.cxx:638
virtual void DoubleClicked(TGFrame *f, Int_t btn)
Emit DoubleClicked() signal.
Definition TGCanvas.cxx:535
virtual TGPosition GetPagePosition() const
Returns page position.
Definition TGCanvas.cxx:734
virtual void End(Bool_t select=kFALSE)
Move to the bottom-right corner of container.
Bool_t fLastSubstring
substring search option of last search
Definition TGCanvas.h:54
virtual void SetPagePosition(const TGPosition &pos)
Set page position.
Definition TGCanvas.cxx:761
virtual TGHScrollBar * GetHScrollbar() const
returns pointer to hor. scroll bar
TGFrameElement * fLastActiveEl
last active item
Definition TGCanvas.h:43
virtual void SelectAll()
Select all items in the container.
Definition TGCanvas.cxx:564
TString fKeyInput
keyboard input (buffer)
Definition TGCanvas.h:57
TTimer * fKeyTimer
keyboard timer
Definition TGCanvas.h:56
virtual void DeActivateItem(TGFrameElement *el)
DeActivate item.
Definition TGCanvas.cxx:721
Int_t fXf
Definition TGCanvas.h:46
Bool_t IsDragging() const
Bool_t StartDrag(TGFrame *src, Int_t x_root, Int_t y_root, Window_t grabWin=kNone)
Start dragging.
void SetDragPixmap(Pixmap_t pic, Pixmap_t mask, Int_t hot_x, Int_t hot_y)
Set drag window pixmaps and hotpoint.
Bool_t Drag(Int_t x_root, Int_t y_root, Atom_t action, Time_t timestamp)
Process drag event.
static Atom_t GetDNDActionCopy()
UInt_t fHeight
Definition TGDimension.h:21
UInt_t fWidth
Definition TGDimension.h:20
TGLayoutHints * fLayout
Definition TGLayout.h:114
TGFrame * fFrame
Definition TGLayout.h:112
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:331
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:621
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:727
UInt_t fOptions
frame options
Definition TGFrame.h:94
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:435
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
virtual Bool_t IsActive() const
Definition TGFrame.h:213
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:192
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:413
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
virtual void Activate(Bool_t)
Definition TGFrame.h:212
void MapWindow() override
map window
Definition TGFrame.h:206
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:747
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:585
Int_t GetX() const
Definition TGFrame.h:233
void UnmapWindow() override
unmap window
Definition TGFrame.h:208
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:227
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2493
Int_t GetY() const
Definition TGFrame.h:234
static const TGGC & GetWhiteGC()
Get white graphics context.
Definition TGFrame.cxx:737
static Pixel_t fgWhitePixel
Definition TGFrame.h:103
UInt_t GetWidth() const
Definition TGFrame.h:226
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
static Pixel_t fgBlackPixel
Definition TGFrame.h:104
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:767
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
The TGHScrollBar will generate the following event messages: kC_HSCROLL, kSB_SLIDERPOS,...
void SetRange(Int_t range, Int_t page_size) override
Set range of horizontal scrollbar.
void SetPosition(Int_t pos) override
Set logical slider position of horizontal scrollbar.
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
Int_t GetPadRight() const
Definition TGLayout.h:86
Int_t GetPadBottom() const
Definition TGLayout.h:84
Int_t GetPadTop() const
Definition TGLayout.h:83
Int_t GetPadLeft() const
Definition TGLayout.h:85
Frame layout manager.
Definition TGLayout.h:135
const TGPicture * GetIcon(const char *filename, Bool_t small_icon)
Return icon belonging to mime type of filename.
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
Int_t fY
y position
Definition TGDimension.h:39
Int_t fX
x position
Definition TGDimension.h:38
Bool_t IsEmpty() const
UInt_t fH
height
Definition TGDimension.h:94
UInt_t fW
width
Definition TGDimension.h:93
Int_t fX
x position
Definition TGDimension.h:91
void Merge(const TGRectangle &r)
Int_t fY
y position
Definition TGDimension.h:92
virtual Int_t GetPosition() const
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
void MapSubwindows() override
map sub windows
static TGSearchDialog *& SearchDialog()
Return global search dialog.
The TGVScrollBar will generate the following event messages: kC_VSCROLL, kSB_SLIDERPOS,...
void SetRange(Int_t range, Int_t page_size) override
Set range of vertical scrollbar.
void SetPosition(Int_t pos) override
Set logical slider position of vertical scrollbar.
Int_t GetHPos() const
Definition TGCanvas.h:184
Int_t GetVPos() const
Definition TGCanvas.h:185
TGFrame * GetContainer() const
Definition TGCanvas.h:173
TGFrame * fContainer
Definition TGCanvas.h:162
Bool_t HandleConfigureNotify(Event_t *event) override
Handle resize events.
Definition TGCanvas.cxx:289
TGViewPort(const TGViewPort &)=delete
Int_t fX0
Definition TGCanvas.h:161
void SetContainer(TGFrame *f)
Add container frame to the viewport.
Definition TGCanvas.cxx:150
virtual void SetHPos(Int_t xpos)
Moves content of container frame in horizontal direction.
Definition TGCanvas.cxx:175
virtual void SetVPos(Int_t ypos)
Moves content of container frame in vertical direction.
Definition TGCanvas.cxx:226
void SetPos(Int_t xpos, Int_t ypos)
Goto new position.
Definition TGCanvas.cxx:278
Int_t fY0
Definition TGCanvas.h:161
virtual void Associate(const TGWindow *w)
Definition TGWidget.h:72
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual UInt_t GetEditDisabled() const
Definition TGWindow.h:112
virtual void SetEditDisabled(UInt_t on=kEditDisable)
Definition TGWindow.h:113
virtual Bool_t HandleExpose(Event_t *event)
Definition TGWindow.h:101
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableBtnEnable
window can handle mouse button events
Definition TGWindow.h:64
@ kEditDisableGrab
window grab cannot be edited
Definition TGWindow.h:59
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:293
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
Utility class for browsing TMapFile objects.
Definition TKeyMapFile.h:20
static TClass * Class()
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
static TClass * Class()
A doubly linked list.
Definition TList.h:38
TObject * After(const TObject *obj) const override
Returns the object after object obj.
Definition TList.cxx:327
TObject * Before(const TObject *obj) const override
Returns the object before object obj.
Definition TList.cxx:368
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
TObject * Last() const override
Return the last object in the list. Returns 0 when list is empty.
Definition TList.cxx:690
TObject * First() const override
Return the first object in the list. Returns 0 when list is empty.
Definition TList.cxx:656
virtual TObjLink * FirstLink() const
Definition TList.h:102
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
Mother of all ROOT objects.
Definition TObject.h:41
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:573
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:457
virtual const char * GetIconName() const
Returns mime type name of object.
Definition TObject.cxx:467
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:543
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:501
virtual TClass * IsA() const
Definition TObject.h:246
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Basic string class.
Definition TString.h:138
ECaseCompare
Definition TString.h:285
@ kIgnoreCase
Definition TString.h:285
@ kExact
Definition TString.h:285
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:469
virtual TTimer * RemoveTimer(TTimer *t)
Remove timer from list of system timers.
Definition TSystem.cxx:479
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
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
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Int_t fX
Definition GuiTypes.h:178
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187
Graphics context structure.
Definition GuiTypes.h:224
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93
TLine l
Definition textangle.C:4