Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTextView.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id: 1f399bfa44c1323de4c6fe38d6d7a83a4bdf2e32 $
2// Author: Fons Rademakers 1/7/2000
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 TGTextView
25 \ingroup guiwidgets
26
27A TGTextView is a text viewer widget. It is a specialization of
28TGView. It uses the TGText class (which contains all text
29manipulation code, i.e. loading a file in memory, changing,
30removing lines, etc.). Use a TGTextView to view non-editable text.
31For supported messages see TGView.
32
33*/
34
35
36#include "TGTextView.h"
37#include "TGScrollBar.h"
38#include "TGResourcePool.h"
39#include "TSystem.h"
40#include "TGDNDManager.h"
41#include "TBufferFile.h"
42#include "TSystemFile.h"
43#include "TObjString.h"
44#include "TMacro.h"
45#include "TGMsgBox.h"
46#include "TUrl.h"
47#include "TVirtualX.h"
48
49#include <iostream>
50
51const TGFont *TGTextView::fgDefaultFont = nullptr;
55
56
57////////////////////////////////////////////////////////////////////////////////
58/// Notify when timer times out and reset the timer.
59
61{
62 fView->HandleTimer(this);
63 Reset();
64 return kFALSE;
65}
66
68
69
70////////////////////////////////////////////////////////////////////////////////
71/// Initialize a text view widget.
72
74{
75 // set in TGResourcePool via .rootrc
80
85
86 fMarkedFromX = 0;
87 fMarkedFromY = 0;
90
91 fText = new TGText();
93
94 fClipText = new TGText();
95
96 gVirtualX->GetFontProperties(fFont, fMaxAscent, fMaxDescent);
98 fScrollVal.fX = fMaxWidth = gVirtualX->TextWidth(fFont, "@", 1);
99
100 fScrollTimer = new TViewTimer(this, 75);
102
103 // define DND types
104 fDNDTypeList = new Atom_t[3];
105 fDNDTypeList[0] = gVirtualX->InternAtom("application/root", kFALSE);
106 fDNDTypeList[1] = gVirtualX->InternAtom("text/uri-list", kFALSE);
107 fDNDTypeList[2] = 0;
108 gVirtualX->SetDNDAware(fId, fDNDTypeList);
110
111 gVirtualX->ClearWindow(fCanvas->GetId());
112 Layout();
113}
114
115////////////////////////////////////////////////////////////////////////////////
116/// Create a text view widget.
117
119 UInt_t sboptions, Pixel_t back) :
120 TGView(parent, w, h, id, 3, 3, kSunkenFrame | kDoubleBorder, sboptions, back)
121{
122 Init(back);
123}
124
125////////////////////////////////////////////////////////////////////////////////
126/// Create a text view widget.
127
129 Int_t id, UInt_t sboptions, Pixel_t back) :
130 TGView(parent, w, h, id, 3, 3, kSunkenFrame | kDoubleBorder, sboptions, back)
131{
132 Init(back);
133 TGLongPosition pos, srcStart, srcEnd;
134 pos.fX = pos.fY = 0;
135 srcStart.fX = srcStart.fY = 0;
136 srcEnd.fY = text->RowCount()-1;
137 srcEnd.fX = text->GetLineLength(srcEnd.fY)-1;
138 fText->InsText(pos, text, srcStart, srcEnd);
139}
140
141////////////////////////////////////////////////////////////////////////////////
142/// Create a text view widget.
143
145 const char *string, Int_t id, UInt_t sboptions,
146 Pixel_t back) :
147 TGView(parent, w, h, id, 3, 3, kSunkenFrame | kDoubleBorder, sboptions, back)
148{
149 Init(back);
150 TGLongPosition pos;
151 pos.fX = pos.fY = 0;
152 fText->InsText(pos, string);
153}
154
155////////////////////////////////////////////////////////////////////////////////
156/// Cleanup text view widget.
157
159{
160 delete fScrollTimer;
161 delete fText;
162 delete fClipText;
163 delete [] fDNDTypeList;
164}
165
166////////////////////////////////////////////////////////////////////////////////
167/// set background color
168
170{
174}
175
176////////////////////////////////////////////////////////////////////////////////
177/// set selected text background color
178
180{
183}
184
185////////////////////////////////////////////////////////////////////////////////
186/// set selected text color
187
189{
192}
193
194////////////////////////////////////////////////////////////////////////////////
195/// Adopt a new text buffer. The text will be deleted by this object.
196
198{
199 Clear();
200 delete fText;
201 fText = text;
202 Layout();
203}
204
205////////////////////////////////////////////////////////////////////////////////
206/// Add text to the view widget.
207
209{
211
213 Layout();
214
216
217 if (h2 <= h1) {
218 return;
219 }
220
221 if (h2 < fCanvas->GetHeight()) {
222 UpdateRegion(0, h1, fCanvas->GetWidth(), h2 - h1);
223 }
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Add a line of text to the view widget.
228
229void TGTextView::AddLine(const char *string)
230{
232
233 AddLineFast(string);
234 Layout();
235
237
238 if (h2 <= h1) {
239 return;
240 }
241 if (h2 < fCanvas->GetHeight()) {
242 UpdateRegion(0, h1, fCanvas->GetWidth(), h2 - h1);
243 }
244}
245
246////////////////////////////////////////////////////////////////////////////////
247/// Add a line of text to the view widget.
248/// Fast version. Use it if you are going to add
249/// several lines, than call Update().
250
251void TGTextView::AddLineFast(const char *string)
252{
253 TGLongPosition pos;
254 pos.fX = 0;
255 pos.fY = fText->RowCount();
256 fText->InsText(pos, string);
257}
258
259////////////////////////////////////////////////////////////////////////////////
260/// update the whole window of text view
261
263{
264 Layout();
267}
268
269////////////////////////////////////////////////////////////////////////////////
270/// Return width of longest line.
271
273{
274 Long_t count = 0, longest = 0, width;
275 Long_t rows = fText->RowCount();
276 while (count < rows) {
277 width = ToScrXCoord(fText->GetLineLength(count), count) + fVisible.fX;
278 if (width > longest) {
279 longest = width;
280 }
281 count++;
282 }
283 return longest;
284}
285
286////////////////////////////////////////////////////////////////////////////////
287/// Search for string in text. If direction is true search forward.
288/// Returns true if string is found.
289
290Bool_t TGTextView::Search(const char *string, Bool_t direction, Bool_t caseSensitive)
291{
292 TGLongPosition pos, pos2;
293 pos2.fX = pos2.fY = 0;
294 if (fIsMarked) {
295 if (!direction) {
296 pos2.fX = fMarkedStart.fX;
297 pos2.fY = fMarkedStart.fY;
298 } else {
299 pos2.fX = fMarkedEnd.fX + 1;
300 pos2.fY = fMarkedEnd.fY;
301 }
302 }
303 if (!fText->Search(&pos, pos2, string, direction, caseSensitive)) {
304 return kFALSE;
305 }
306 UnMark();
309 fMarkedStart.fX = pos.fX;
310 fMarkedEnd.fX = fMarkedStart.fX + strlen(string) - 1;
311 pos.fY = ToObjYCoord(fVisible.fY);
312 if ((fMarkedStart.fY < pos.fY) ||
314 pos.fY = fMarkedStart.fY;
315 }
316 pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
317 if ((fMarkedStart.fX < pos.fX) ||
319 pos.fX = fMarkedStart.fX;
320 }
321
326
327 return kTRUE;
328}
329
330////////////////////////////////////////////////////////////////////////////////
331/// Changes text entry font.
332
334{
335 if (font != fFont) {
336 fFont = font;
337 fNormGC.SetFont(gVirtualX->GetFontHandle(fFont));
338 fSelGC.SetFont(gVirtualX->GetFontHandle(fFont));
339 fClient->NeedRedraw(this);
340 }
341}
342
343////////////////////////////////////////////////////////////////////////////////
344/// Convert line number to screen coordinate.
345
347{
348 if (yCoord * (fMaxAscent + fMaxDescent) <= 0) {
349 return 0;
350 }
351 if (yCoord > fText->RowCount()) {
352 return fText->RowCount() * (fMaxAscent + fMaxDescent);
353 }
354 return yCoord * (fMaxAscent + fMaxDescent) - fVisible.fY;
355}
356
357////////////////////////////////////////////////////////////////////////////////
358/// Convert column number in specified line to screen coordinate.
359
361{
362 TGLongPosition pos;
363 char *buffer;
364
365 pos.fX = 0;
366 pos.fY = line;
368 if (xCoord <= 0 || pos.fY < 0 || width <= 0) {
369 return 0;
370 }
371 if (xCoord > width) {
372 xCoord = width;
373 }
374 buffer = fText->GetLine(pos, xCoord);
375 width = gVirtualX->TextWidth(fFont, buffer, (Int_t)xCoord) - fVisible.fX;
376 delete [] buffer;
377
378 return width;
379}
380
381////////////////////////////////////////////////////////////////////////////////
382/// Convert y screen coordinate to line number.
383
385{
386 return yCoord / (fMaxAscent + fMaxDescent);
387}
388
389////////////////////////////////////////////////////////////////////////////////
390/// Convert x screen coordinate to column in specified line.
391
393{
394 TGLongPosition pos;
395 char *buffer, *travelBuffer;
396 char charBuffer;
397
398 if (line < 0 || line >= fText->RowCount()) {
399 return 0;
400 }
401
403 pos.fX = 0;
404 pos.fY = line;
405 if (len <= 0 || xCoord < 0) {
406 return 0;
407 }
408
409 Long_t viscoord = xCoord;
410 buffer = fText->GetLine(pos, len);
411 if (!buffer) return 0;
412 travelBuffer = buffer;
413 charBuffer = *travelBuffer++;
414 int cw = gVirtualX->TextWidth(fFont, &charBuffer, 1);
415
416 while (viscoord - cw >= 0 && pos.fX < len) {
417 viscoord -= cw;
418 pos.fX++;
419 charBuffer = *travelBuffer++;
420 cw = gVirtualX->TextWidth(fFont, &charBuffer, 1);
421 }
422
423 delete [] buffer;
424 return pos.fX;
425}
426
427////////////////////////////////////////////////////////////////////////////////
428/// Clear text view widget.
429
431{
434 fIsSaved = kTRUE;
438
439 delete fText;
440 fText = new TGText();
441 fText->Clear();
443 Marked(kFALSE);
444 gVirtualX->ClearWindow(fCanvas->GetId());
446 DataChanged();
447 Layout();
448}
449
450////////////////////////////////////////////////////////////////////////////////
451/// Load a file in the text view widget. Return false in case file does not
452/// exist.
453
455{
456 FILE *fp;
457 if (!(fp = fopen(filename, "r")))
458 return kFALSE;
459 fclose(fp);
460
461 ShowTop();
462 Clear();
463 fText->Load(filename, startpos, length);
464 Update();
465 return kTRUE;
466}
467
468////////////////////////////////////////////////////////////////////////////////
469/// Load text from a text buffer. Return false in case of failure.
470
472{
473 if (!txtbuf || !txtbuf[0]) {
474 return kFALSE;
475 }
476
477 Clear();
478 fText->LoadBuffer(txtbuf);
479 Update();
480 return kTRUE;
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Copy selected text to clipboard.
485
487{
488 TGLongPosition insPos, startPos, endPos;
489
490 if (!fIsMarked) {
491 return kFALSE;
492 }
493 delete fClipText;
494 fClipText = new TGText();
495 insPos.fY = insPos.fX = 0;
496 startPos.fX = fMarkedStart.fX;
497 startPos.fY = fMarkedStart.fY;
498 endPos.fX = fMarkedEnd.fX-1;
499 endPos.fY = fMarkedEnd.fY;
500 if (endPos.fX == -1) {
501 if (endPos.fY > 0) {
502 endPos.fY--;
503 }
504 endPos.fX = fText->GetLineLength(endPos.fY);
505 if (endPos.fX < 0) {
506 endPos.fX = 0;
507 }
508 }
509 fClipText->InsText(insPos, fText, startPos, endPos);
510 gVirtualX->SetPrimarySelectionOwner(fId);
511 return kTRUE;
512}
513
514////////////////////////////////////////////////////////////////////////////////
515/// Select all text in the viewer.
516
518{
519 if (fText->RowCount() == 1 && fText->GetLineLength(0) == 0) {
520 return kFALSE;
521 }
523 fMarkedStart.fY = 0;
524 fMarkedStart.fX = 0;
527 if (fMarkedEnd.fX < 0) {
528 fMarkedEnd.fX = 0;
529 }
531 Copy();
532
533 return kTRUE;
534}
535
536////////////////////////////////////////////////////////////////////////////////
537/// Draw lines in exposed region.
538
540{
541 char *buffer;
542
543 TGLongPosition pos;
544 Long_t xoffset, len, len1, len2;
545 Long_t line_count = fText->RowCount();
547 rect.fX = x;
548 rect.fY = y;
549 pos.fY = ToObjYCoord(fVisible.fY + h);
550 rect.fHeight = UShort_t(h + ToScrYCoord(pos.fY + 1) - ToScrYCoord(pos.fY));
551 pos.fX = ToObjXCoord(fVisible.fX + w, pos.fY);
552 rect.fWidth = UShort_t(w + ToScrXCoord(pos.fX + 1, pos.fY) - ToScrXCoord(pos.fX, pos.fY));
553 Int_t yloc = rect.fY + (Int_t)fScrollVal.fY;
554 pos.fY = ToObjYCoord(fVisible.fY + rect.fY);
555
556 while (pos.fY <= line_count &&
557 yloc - fScrollVal.fY <= (Int_t)fCanvas->GetHeight() &&
558 yloc <= rect.fY + rect.fHeight) {
559
560 pos.fX = ToObjXCoord(fVisible.fX + rect.fX, pos.fY);
561 xoffset = ToScrXCoord(pos.fX, pos.fY);
562 len = fText->GetLineLength(pos.fY) - pos.fX;
563
564 gVirtualX->ClearArea(fCanvas->GetId(), x, Int_t(ToScrYCoord(pos.fY)),
565 rect.fWidth, UInt_t(ToScrYCoord(pos.fY+1)-ToScrYCoord(pos.fY)));
566
567
568 if (len > 0) {
569 if (len > ToObjXCoord(fVisible.fX + rect.fX + rect.fWidth, pos.fY) - pos.fX) {
570 len = ToObjXCoord(fVisible.fX + rect.fX + rect.fWidth, pos.fY) - pos.fX + 1;
571 }
572 if (pos.fX == 0) {
573 xoffset = -fVisible.fX;
574 }
575 if (pos.fY >= ToObjYCoord(fVisible.fY)) {
576 buffer = fText->GetLine(pos, len);
577 if (!buffer) // skip next lines and continue the while() loop
578 continue;
579 Int_t i = 0;
580 while (buffer[i] != '\0') {
581 if (buffer[i] == '\t') {
582 buffer[i] = ' ';
583 Int_t j = i+1;
584 while (buffer[j] == 16 && buffer[j] != '\0') {
585 buffer[j++] = ' ';
586 }
587 }
588 i++;
589 }
590
591 if (!fIsMarked ||
592 pos.fY < fMarkedStart.fY || pos.fY > fMarkedEnd.fY ||
593 (pos.fY == fMarkedStart.fY &&
594 fMarkedStart.fX >= pos.fX+len &&
596 (pos.fY == fMarkedEnd.fY &&
597 fMarkedEnd.fX < pos.fX &&
600 (fMarkedEnd.fX < pos.fX ||
601 fMarkedStart.fX > pos.fX+len))) {
602
603 gVirtualX->DrawString(fCanvas->GetId(), fNormGC(), Int_t(xoffset),
605 buffer, Int_t(len));
606 } else {
607 if (pos.fY > fMarkedStart.fY && pos.fY < fMarkedEnd.fY) {
608 len1 = 0;
609 len2 = len;
610 } else {
611 if (fMarkedStart.fY == fMarkedEnd.fY) {
612 if (fMarkedStart.fX >= pos.fX &&
613 fMarkedStart.fX <= pos.fX + len) {
614 len1 = fMarkedStart.fX - pos.fX;
615 } else {
616 len1 = 0;
617 }
618 if (fMarkedEnd.fX >= pos.fX &&
619 fMarkedEnd.fX <= pos.fX + len) {
620 len2 = fMarkedEnd.fX - pos.fX - len1; // +1
621 } else {
622 len2 = len - len1;
623 }
624 } else {
625 if (pos.fY == fMarkedStart.fY) {
626 if (fMarkedStart.fX < pos.fX) {
627 len1 = 0;
628 len2 = len;
629 } else {
630 len1 = fMarkedStart.fX - pos.fX;
631 len2 = len - len1;
632 }
633 } else {
634 if (fMarkedEnd.fX > pos.fX+len) {
635 len1 = 0;
636 len2 = len;
637 } else {
638 len1 = 0 ;
639 len2 = fMarkedEnd.fX - pos.fX; // +1
640 }
641 }
642 }
643 }
644 gVirtualX->DrawString(fCanvas->GetId(), fNormGC(),
645 Int_t(ToScrXCoord(pos.fX, pos.fY)),
647 buffer, Int_t(len1));
648 gVirtualX->FillRectangle(fCanvas->GetId(), fSelbackGC(),
649 Int_t(ToScrXCoord(pos.fX+len1, pos.fY)),
650 Int_t(ToScrYCoord(pos.fY)),
651 UInt_t(ToScrXCoord(pos.fX+len1+len2, pos.fY) -
652 ToScrXCoord(pos.fX+len1, pos.fY)),
653 UInt_t(ToScrYCoord(pos.fY+1)-ToScrYCoord(pos.fY)));
654 gVirtualX->DrawString(fCanvas->GetId(), fSelGC(),
655 Int_t(ToScrXCoord(pos.fX+len1, pos.fY)),
657 buffer+len1, Int_t(len2));
658 gVirtualX->DrawString(fCanvas->GetId(), fNormGC(),
659 Int_t(ToScrXCoord(pos.fX+len1+len2, pos.fY)),
661 buffer+len1+len2, Int_t(len-(len1+len2)));
662 }
663 delete [] buffer;
664 }
665 }
666 pos.fY++;
667 yloc += Int_t(ToScrYCoord(pos.fY) - ToScrYCoord(pos.fY-1));
668 }
669}
670
671////////////////////////////////////////////////////////////////////////////////
672/// Handle mouse crossing event.
673
675{
676 if (event->fWindow != fCanvas->GetId())
677 return kTRUE;
678
681 fMousePos.fY--;
682 }
685 fMousePos.fX--;
686 }
687 if ((event->fState & kButton1Mask) && fIsMarked && fIsMarking) {
688 if (event->fType == kLeaveNotify) {
689 if (event->fX < 0) {
690 fScrolling = 0;
691 return kFALSE;
692 }
693 if (event->fX >= (Int_t)fCanvas->GetWidth()) {
694 fScrolling = 1;
695 return kFALSE;
696 }
697 if (event->fY < 0) {
698 fScrolling = 2;
699 return kFALSE;
700 }
701 if (event->fY >= (Int_t)fCanvas->GetHeight()) {
702 fScrolling = 3;
703 return kFALSE;
704 }
705 } else {
706 fScrolling = -1;
708 }
709 } else {
711 }
712
713 return kTRUE;
714}
715
716////////////////////////////////////////////////////////////////////////////////
717/// Handle scroll timer.
718
720{
721 static const Int_t kAutoScrollFudge = 10;
722 static const Int_t kAcceleration[kAutoScrollFudge + 1] = {1, 1, 1, 1, 2, 3, 4, 6, 8, 12, 16};
723
725 Window_t dum1, dum2;
726 Event_t ev;
727 ev.fType = kButtonPress;
728 Int_t x, y;
729 Int_t dy = 0;
730
731 if (fMarkedStart.fY == fMarkedEnd.fY) {
732 return kFALSE;
733 }
734 if (fIsMarked && (fScrolling != -1)) {
735 // where cursor
736 gVirtualX->QueryPointer(fId, dum1, dum2, ev.fXRoot, ev.fYRoot, x, y, ev.fState);
737
739
740 if (fMousePos.fY >= ReturnLineCount()) {
742 }
743 if (fMousePos.fY < 0) {
744 fMousePos.fY = 0;
745 }
746 if (ev.fState & kButton1Mask) {
747
748 // Figure scroll amount y
749 if (y < kAutoScrollFudge) {
750 dy = kAutoScrollFudge - y;
751 } else if ((Int_t)fCanvas->GetHeight() - kAutoScrollFudge <= y) {
753 }
754 Int_t ady = TMath::Abs(dy) >> 3;
755
756 if (dy) {
757 if (ady > kAutoScrollFudge) ady = kAutoScrollFudge;
758 dy = kAcceleration[ady];
759 } else {
760 dy = 1;
761 }
762
763 if (y > (Int_t)fCanvas->GetHeight()) {
764 fScrolling = 3;
765 }
766 if (y < 0) {
767 fScrolling = 2;
768 }
769 } else {
770 fScrolling = -1;
771 }
772
775 switch (fScrolling) {
776 case -1:
777 break;
778 case 0:
779 if (fVisible.fX == 0) {
780 fScrolling = -1;
781 break;
782 } else {
785 }
786 break;
787 case 1:
789 fScrolling = -1;
790 break;
791 } else {
793 Mark(size.fX+1, fMousePos.fY);
794 }
795 break;
796 case 2:
797 if (fVisible.fY == 0) {
798 fScrolling = -1;
799 break;
800 } else {
803 }
804 break;
805 case 3:
807 fScrolling = -1;
808 break;
809 } else {
811 Mark(fMousePos.fX, size.fY + 1);
812 }
813 break;
814 default:
815 break;
816 }
817 }
818 return kTRUE;
819}
820
821////////////////////////////////////////////////////////////////////////////////
822/// Handle mouse button event in text editor.
823
825{
826 if (event->fWindow != fCanvas->GetId()) {
827 return kFALSE;
828 }
829
830 if (event->fCode == kButton1) {
831 if (event->fType == kButtonPress) {
832 if (fIsMarked) {
833 if (event->fState & kKeyShiftMask) {
836 return kTRUE;
837 }
838
839 UnMark();
840 }
847 } else {
848 fScrolling = -1;
849 if ((fMarkedStart.fX == fMarkedEnd.fX) &&
854 Marked(kFALSE);
855 } else {
858 Marked(kTRUE);
859 }
861 }
862 } else if (event->fCode == kButton4) {
863 // move three lines up
864 if (fVisible.fY > 0) {
865 Long_t amount = fVisible.fY / fScrollVal.fY - 3;
866 SetVsbPosition((amount >= 0) ? amount : 0);
867 //Mark(fMousePos.fX, fMarkedStart.fY - 3);
868 }
869 } else if (event->fCode == kButton5) {
870 // move three lines down
875 //Mark(fMousePos.fX, size.fY + 3);
876 }
877 } else if (event->fType == kButtonPress) {
878 if (event->fCode == kButton2) {
880 fWidgetId, (event->fYRoot << 16) | event->fXRoot);
881 UnMark();
882 } else if (event->fCode == kButton3) {
884 fWidgetId, (event->fYRoot << 16) | event->fXRoot);
885 }
886 }
887
888 if (event->fType == kButtonRelease) {
889 if (event->fCode == kButton1) {
890 if (fIsMarked) {
891 Copy();
892 }
893 }
894 }
895
896 return kTRUE;
897}
898
899////////////////////////////////////////////////////////////////////////////////
900/// handle double click
901
903{
904 return kFALSE;
905}
906
907////////////////////////////////////////////////////////////////////////////////
908/// Handle mouse motion event in the text editor widget.
909
911{
912 if ((ToObjYCoord(fVisible.fY+event->fY) == fMousePos.fY) &&
914 return kTRUE;
915 }
916
917 if (fScrolling != -1) {
918 return kTRUE;
919 }
920
922 if (fMousePos.fY >= ReturnLineCount()) {
924 }
926
929 }
930 if (event->fWindow != fCanvas->GetId()) {
931 return kTRUE;
932 }
933
934 if (!fIsMarking) {
935 return kTRUE;
936 }
937 if (event->fX < 0) {
938 return kTRUE;
939 }
940 if (event->fX >= (Int_t)fCanvas->GetWidth()) {
941 return kTRUE;
942 }
943 if (event->fY < 0) {
944 return kTRUE;
945 }
946 if (event->fY >= (Int_t)fCanvas->GetHeight()) {
947 return kTRUE;
948 }
950 return kTRUE;
951}
952
953////////////////////////////////////////////////////////////////////////////////
954/// Handle selection clear event.
955
957{
958 if (fIsMarked) {
959 UnMark();
960 }
961 return kTRUE;
962}
963
964////////////////////////////////////////////////////////////////////////////////
965/// Handle request to send current clipboard contents to requestor window.
966
968{
969 Event_t reply;
970 char *buffer, *temp_buffer;
971 Long_t len, prev_len, temp_len, count;
972 TGLongPosition pos;
973 Atom_t targets[2];
974 Atom_t type;
975
976 reply.fType = kSelectionNotify;
977 reply.fTime = event->fTime;
978 reply.fUser[0] = event->fUser[0]; // requestor
979 reply.fUser[1] = event->fUser[1]; // selection
980 reply.fUser[2] = event->fUser[2]; // target
981 reply.fUser[3] = event->fUser[3]; // property
982
983 targets[0] = gVirtualX->InternAtom("TARGETS", kFALSE);
984 targets[1] = gVirtualX->InternAtom("XA_STRING", kFALSE);
985
986 if ((Atom_t)event->fUser[2] == targets[0]) {
987 type = gVirtualX->InternAtom("XA_ATOM", kFALSE);
988 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
989 type, (UChar_t*) targets, (Int_t) 2);
990
991 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
992 return kTRUE;
993 }
994
995 len = 0;
996 for (count = 0; count < fClipText->RowCount(); count++) {
997 len += fClipText->GetLineLength(count)+1;
998 }
999 len--; // remove \n for last line
1000
1001 pos.fY = pos.fX = 0;
1002 buffer = new char[len+1];
1003 prev_len = 0;
1004 for (pos.fY = 0; pos.fY < fClipText->RowCount(); pos.fY++) {
1005 temp_len = fClipText->GetLineLength(pos.fY);
1006 if (temp_len < 0) break;
1007 temp_buffer = fClipText->GetLine(pos, temp_len);
1008 strncpy(buffer+prev_len, temp_buffer, (UInt_t)temp_len);
1009 if (pos.fY < fClipText->RowCount()-1) {
1010 buffer[prev_len+temp_len] = 10; // \n
1011 prev_len += temp_len+1;
1012 } else
1013 prev_len += temp_len;
1014 delete [] temp_buffer;
1015 }
1016 buffer[len] = '\0';
1017
1018 // get rid of special tab fillers
1019 ULong_t i = 0;
1020 while (buffer[i]) {
1021 if (buffer[i] == '\t') {
1022 ULong_t j = i + 1;
1023 while (buffer[j] == 16 && buffer[j]) {
1024 j++;
1025 }
1026 // coverity[secure_coding]
1027 strcpy(buffer+i+1, buffer+j);
1028 len -= j - i - 1;
1029 }
1030 i++;
1031 }
1032
1033 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
1034 (Atom_t) event->fUser[2], (UChar_t*) buffer,
1035 (Int_t) len);
1036
1037 delete [] buffer;
1038
1039 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
1040
1041 return kTRUE;
1042}
1043
1044////////////////////////////////////////////////////////////////////////////////
1045/// Returns true if given a text file
1046/// Uses the specification given on p86 of the Camel book
1047/// - Text files have no NULLs in the first block
1048/// - and less than 30% of characters with high bit set
1049
1050static Bool_t IsTextFile(const char *candidate)
1051{
1052 Int_t i;
1053 Int_t nchars;
1054 Int_t weirdcount = 0;
1055 char buffer[512];
1056 FILE *infile;
1057 FileStat_t buf;
1058
1059 if (gSystem->GetPathInfo(candidate, buf) || !(buf.fMode & kS_IFREG))
1060 return kFALSE;
1061
1062 infile = fopen(candidate, "r");
1063 if (infile) {
1064 // Read a block
1065 nchars = fread(buffer, 1, 512, infile);
1066 fclose (infile);
1067 // Examine the block
1068 for (i = 0; i < nchars; i++) {
1069 if (buffer[i] & 128)
1070 weirdcount++;
1071 if (buffer[i] == '\0')
1072 // No NULLs in text files
1073 return kFALSE;
1074 }
1075 if ((nchars > 0) && ((weirdcount * 100 / nchars) > 30))
1076 return kFALSE;
1077 } else {
1078 // Couldn't open it. Not a text file then
1079 return kFALSE;
1080 }
1081 return kTRUE;
1082}
1083
1084////////////////////////////////////////////////////////////////////////////////
1085/// Handle Drop event
1086
1088{
1089 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1090 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1091
1092 if (fText->RowCount() > 1) {
1093 Int_t ret;
1095 "Overwrite", "Do you want to replace existing text?",
1097 if (ret == kMBNo)
1098 return kTRUE;
1099 }
1100 if (data->fDataType == rootObj) {
1101 TBufferFile buf(TBuffer::kRead, data->fDataLength, (void *)data->fData);
1102 buf.SetReadMode();
1104 if (obj && obj->InheritsFrom("TMacro")) {
1105 TMacro *macro = (TMacro *)obj;
1106 TIter next(macro->GetListOfLines());
1107 TObjString *objs;
1108 while ((objs = (TObjString*) next())) {
1109 AddLine(objs->GetName());
1110 }
1111 }
1112 else if (obj && obj->InheritsFrom("TSystemFile")) {
1113 TSystemFile *sfile = (TSystemFile *)obj;
1114 LoadFile(sfile->GetName());
1115 DataDropped(sfile->GetName());
1116 }
1117 return kTRUE;
1118 }
1119 else if (data->fDataType == uriObj) {
1120 TString sfname((char *)data->fData);
1121 if (sfname.Length() > 7) {
1122 sfname.ReplaceAll("\r\n", "");
1123 TUrl uri(sfname.Data());
1124 if (IsTextFile(uri.GetFile())) {
1125 LoadFile(uri.GetFile());
1126 DataDropped(uri.GetFile());
1127 }
1128 }
1129 }
1130 return kFALSE;
1131}
1132
1133////////////////////////////////////////////////////////////////////////////////
1134/// Handle Drag position event
1135
1137 Int_t /*xroot*/, Int_t /*yroot*/)
1138{
1139 return action;
1140}
1141
1142////////////////////////////////////////////////////////////////////////////////
1143/// Handle Drag Enter event
1144
1146{
1147 static Atom_t rootObj = gVirtualX->InternAtom("application/root", kFALSE);
1148 static Atom_t uriObj = gVirtualX->InternAtom("text/uri-list", kFALSE);
1149 Atom_t ret = kNone;
1150 for (int i = 0; typelist[i] != kNone; ++i) {
1151 if (typelist[i] == rootObj)
1152 ret = rootObj;
1153 if (typelist[i] == uriObj)
1154 ret = uriObj;
1155 }
1156 return ret;
1157}
1158
1159////////////////////////////////////////////////////////////////////////////////
1160/// Handle Drag Leave event
1161
1163{
1164 return kTRUE;
1165}
1166
1167////////////////////////////////////////////////////////////////////////////////
1168/// Mark a text region from xPos to yPos.
1169
1171{
1172 TGLongPosition posStart, posEnd, pos;
1173
1174 pos.fY = yPos;
1175 pos.fX = xPos;
1176 if (pos.fY > fText->RowCount()-1) {
1177 pos.fY = fText->RowCount()-1;
1178 }
1179 if (pos.fX > fText->GetLineLength(pos.fY)) {
1180 pos.fX = fText->GetLineLength(pos.fY);
1181 }
1182 if (pos.fY < fMarkedStart.fY) {
1183 posEnd.fY = fMarkedStart.fY;
1184 if (fMarkedFromY == 1 || fMarkedFromX == 1) {
1185 posEnd.fY = fMarkedEnd.fY;
1188 }
1189 posStart.fY = pos.fY;
1190 fMarkedStart.fY = pos.fY;
1191 fMarkedStart.fX = pos.fX;
1192 fMarkedFromY = 0;
1193 fMarkedFromX = 0;
1194 } else if (pos.fY > fMarkedEnd.fY) {
1195 posStart.fY = fMarkedEnd.fY;
1196 if (fMarkedFromY == 0 || fMarkedFromX == 0) {
1197 if (fMarkedStart.fY != fMarkedEnd.fY) {
1198 posStart.fY = fMarkedStart.fY;
1201 }
1202 }
1203 fMarkedEnd.fY = pos.fY;
1204 fMarkedEnd.fX = pos.fX; // -1
1205 fMarkedFromY = 1;
1206 fMarkedFromX = 1;
1207
1208 posEnd.fY = fMarkedEnd.fY;
1209 } else {
1210 if (pos.fX <= fMarkedStart.fX && pos.fY == fMarkedStart.fY) {
1211 posEnd.fY = fMarkedStart.fY;
1212 if (fMarkedFromY == 1 || fMarkedFromX == 1) {
1213 posEnd.fY = fMarkedEnd.fY;
1216 }
1217 fMarkedStart.fX = pos.fX;
1218 fMarkedFromY = 0;
1219 fMarkedFromX = 0;
1220 posStart.fY = fMarkedStart.fY;
1221 } else {
1222 if (pos.fX > fMarkedEnd.fX && pos.fY == fMarkedEnd.fY) {
1223 posStart.fY = fMarkedEnd.fY;
1224 if (fMarkedFromY == 0 || fMarkedFromX == 0) {
1225 posStart.fY = fMarkedStart.fY;
1228 }
1229 fMarkedEnd.fX = pos.fX; // -1
1230 fMarkedFromY = 1;
1231 fMarkedFromX = 1;
1232 posEnd.fY = fMarkedEnd.fY;
1233 } else {
1234 if (fMarkedFromY == 0 || fMarkedFromX == 0) {
1235 posStart.fY = fMarkedStart.fY;
1236 fMarkedStart.fY = pos.fY;
1237 fMarkedStart.fX = pos.fX;
1238 posEnd.fY = fMarkedStart.fY;
1239 fMarkedFromX = 0;
1240 if (fMarkedStart.fY == fMarkedEnd.fY &&
1243 fMarkedEnd.fX = pos.fX; // -1
1244 fMarkedFromX = 1;
1245 }
1246 } else if (fMarkedFromX == 1 || fMarkedFromY == 1) {
1247 posStart.fY = pos.fY;
1248 posEnd.fY = fMarkedEnd.fY;
1249 fMarkedEnd.fY = pos.fY;
1250 fMarkedEnd.fX = pos.fX; // -1
1251 fMarkedFromY = 1;
1252 fMarkedFromX = 1;
1253 if (fMarkedEnd.fX == -1) {
1254 fMarkedEnd.fY = pos.fY-1;
1256 if (fMarkedEnd.fX < 0) {
1257 fMarkedEnd.fX = 0;
1258 }
1259 }
1260 fMarkedFromX = 1;
1261 if (fMarkedStart.fY == fMarkedEnd.fY &&
1264 fMarkedStart.fX = pos.fX;
1265 fMarkedFromX = 0;
1266 }
1267 }
1268 }
1269 }
1270 }
1271
1272 if (fMarkedEnd.fX == -1) {
1273 if (fMarkedEnd.fY > 0) {
1274 fMarkedEnd.fY--;
1275 }
1277 if (fMarkedEnd.fX < 0) {
1278 fMarkedEnd.fX = 0;
1279 }
1280 }
1281 fIsMarked = kTRUE;
1282
1283 Int_t yy = (Int_t)ToScrYCoord(posStart.fY);
1284 UInt_t hh = UInt_t(ToScrYCoord(posEnd.fY + 1) - ToScrYCoord(posStart.fY));
1285
1286 DrawRegion(0, yy, fCanvas->GetWidth(), hh);
1287 return;
1288}
1289
1290////////////////////////////////////////////////////////////////////////////////
1291/// Clear marked region.
1292
1294{
1295 if (!fIsMarked ||
1296 ((fMarkedEnd.fY == fMarkedStart.fY) &&
1297 (fMarkedEnd.fX == fMarkedStart.fX))) {
1298 return;
1299 }
1300 fIsMarked = kFALSE;
1301
1304
1305 // update marked region
1306 UpdateRegion(0, y, fCanvas->GetWidth(), h);
1307}
1308
1309////////////////////////////////////////////////////////////////////////////////
1310/// Adjust widget width to longest line.
1311
1313{
1315 if (line <= 0) {
1316 return;
1317 }
1319 if (fVsb->IsMapped()) {
1321 }
1322 size += (fBorderWidth << 1) + fXMargin+1;
1324}
1325
1326////////////////////////////////////////////////////////////////////////////////
1327/// Layout the components of view.
1328
1330{
1331 VLayout();
1332 HLayout();
1333}
1334
1335////////////////////////////////////////////////////////////////////////////////
1336/// Horizontal layout of widgets (canvas, scrollbar).
1337
1339{
1340 if (!fHsb) return;
1341
1342 Int_t tcw, tch;
1343 Long_t cols;
1344 tch = fHeight - (fBorderWidth << 1) - fYMargin-1;
1345 tcw = fWidth - (fBorderWidth << 1) - fXMargin-1;
1346
1347 if (fVsb && fVsb->IsMapped()) {
1348 tcw -= fVsb->GetDefaultWidth();
1349 if (tcw < 0) tcw = 0;
1350 }
1351 fCanvas->SetHeight(tch);
1352 fCanvas->SetWidth(tcw);
1353 cols = ReturnLongestLineWidth();
1354 if (cols <= tcw) {
1355 if (fHsb && fHsb->IsMapped()) {
1357 fHsb->UnmapWindow();
1358 VLayout();
1359 }
1361 } else {
1362 if (fHsb) {
1363 tch -= fHsb->GetDefaultHeight();
1364 if (tch < 0) tch = 0;
1367 fHsb->MapWindow();
1369 }
1371 }
1372}
1373
1374////////////////////////////////////////////////////////////////////////////////
1375/// Vertical layout of widgets (canvas, scrollbar).
1376
1378{
1379 Int_t tcw, tch;
1380 Long_t lines;
1381
1382 tch = fHeight - (fBorderWidth << 1) - fYMargin-1;
1383 tcw = fWidth - (fBorderWidth << 1) - fXMargin-1;
1384 if (fHsb && fHsb->IsMapped()) {
1385 tch -= fHsb->GetDefaultHeight();
1386 if (tch < 0) tch = 0;
1387 }
1388 fCanvas->SetHeight(tch);
1389 fCanvas->SetWidth(tcw);
1390 lines = ReturnHeighestColHeight();
1391 if (lines <= tch) {
1392 if (fVsb && fVsb->IsMapped()) {
1394 fVsb->UnmapWindow();
1395 HLayout();
1396 }
1398 } else {
1399 if (fVsb) {
1400 tcw -= fVsb->GetDefaultWidth();
1401 if (tcw < 0) tcw = 0;
1404 fVsb->MapWindow();
1406 }
1408 }
1409}
1410
1411////////////////////////////////////////////////////////////////////////////////
1412/// Set the range for the kVertical or kHorizontal scrollbar.
1413
1415{
1416 if (direction == kVertical) {
1417 if (!fVsb) {
1418 return;
1419 }
1421 if (fVsb->IsMapped()) {
1422 VLayout();
1423 } else {
1424 return;
1425 }
1426 }
1427 if (!fVsb->IsMapped()) {
1428 VLayout();
1429 }
1432 HLayout();
1433 } else {
1434 if (!fHsb) {
1435 return;
1436 }
1438 if (fHsb->IsMapped()) {
1439 HLayout();
1440 } else {
1441 return;
1442 }
1443 }
1444 if (!fHsb->IsMapped()) {
1445 HLayout();
1446 }
1449 VLayout();
1450 }
1451}
1452
1453////////////////////////////////////////////////////////////////////////////////
1454/// Set position of horizontal scrollbar.
1455
1457{
1458 if (fHsb && fHsb->IsMapped()) {
1459 fHsb->SetPosition(Int_t(newPos));
1460 } else {
1462 }
1463}
1464
1465////////////////////////////////////////////////////////////////////////////////
1466/// Set position of vertical scrollbar.
1467
1469{
1470 if (fVsb && fVsb->IsMapped()) {
1471 fVsb->SetPosition(Int_t(newPos));
1472 } else {
1474 }
1475}
1476
1477////////////////////////////////////////////////////////////////////////////////
1478/// Return default font structure in use.
1479
1481{
1482 if (!fgDefaultFont) {
1483 fgDefaultFont = gClient->GetResourcePool()->GetDocumentFixedFont();
1484 }
1485 return fgDefaultFont->GetFontStruct();
1486}
1487
1488////////////////////////////////////////////////////////////////////////////////
1489/// Show bottom of the page.
1490
1492{
1493 Int_t tch;
1494 Long_t lines, newPos;
1495
1496 tch = fCanvas->GetHeight();
1497 lines = ReturnHeighestColHeight();
1498 if (lines > tch) {
1499 newPos = lines / fScrollVal.fY;
1500 SetVsbPosition(newPos);
1501 }
1502 Layout();
1503}
1504
1505////////////////////////////////////////////////////////////////////////////////
1506/// Show top of the page.
1507
1509{
1510 SetVsbPosition(0);
1511 Layout();
1512}
1513
1514////////////////////////////////////////////////////////////////////////////////
1515/// Set text color.
1516
1518{
1521}
1522
1523////////////////////////////////////////////////////////////////////////////////
1524/// Return default graphics context in use.
1525
1527{
1528 if (!fgDefaultGC) {
1529 fgDefaultGC = new TGGC(*gClient->GetResourcePool()->GetFrameGC());
1531 }
1532 return *fgDefaultGC;
1533}
1534
1535////////////////////////////////////////////////////////////////////////////////
1536/// Return selection graphics context in use.
1537
1539{
1540 if (!fgDefaultSelectedGC) {
1541 fgDefaultSelectedGC = new TGGC(*gClient->GetResourcePool()->GetSelectedGC());
1543 }
1544 return *fgDefaultSelectedGC;
1545}
1546
1547////////////////////////////////////////////////////////////////////////////////
1548/// Return graphics context for highlighted frame background.
1549
1551{
1553 fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
1554 }
1556}
1557
1558////////////////////////////////////////////////////////////////////////////////
1559/// Save a text edit widget as a C++ statement(s) on output stream out
1560
1561void TGTextView::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1562{
1563 char quote = '"';
1564 out << " TGTextView *";
1565 out << GetName() << " = new TGTextView(" << fParent->GetName()
1566 << "," << GetWidth() << "," << GetHeight()
1567 << ");"<< std::endl;
1568
1569 if (option && strstr(option, "keep_names"))
1570 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
1571
1573 out << " " << GetName() << "->ChangeBackground(" << fCanvas->GetBackground() << ");" << std::endl;
1574 }
1575
1576 TGText *txt = GetText();
1577 Bool_t fromfile = strlen(txt->GetFileName()) ? kTRUE : kFALSE;
1578 TString fn;
1579
1580 if (fromfile) {
1581 const char *filename = txt->GetFileName();
1584 } else {
1585 fn = TString::Format("Txt%s", GetName()+5);
1586 txt->Save(fn.Data());
1587 }
1588 out << " " << GetName() << "->LoadFile(" << quote << fn.Data() << quote << ");" << std::endl;
1589}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kButtonRelease
Definition GuiTypes.h:60
@ kSelectionNotify
Definition GuiTypes.h:63
@ kButtonPress
Definition GuiTypes.h:60
@ kLeaveNotify
Definition GuiTypes.h:61
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kButton1Mask
Definition GuiTypes.h:203
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton4
Definition GuiTypes.h:215
@ kButton2
Definition GuiTypes.h:214
@ kButton5
Definition GuiTypes.h:215
@ kButton3
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Definition RtypesCore.h:63
unsigned short UShort_t
Definition RtypesCore.h:40
int Int_t
Definition RtypesCore.h:45
unsigned char UChar_t
Definition RtypesCore.h:38
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
unsigned long ULong_t
Definition RtypesCore.h:55
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
const Int_t kAutoScrollFudge
Definition TGCanvas.cxx:82
const Int_t kAcceleration[kAutoScrollFudge+1]
Definition TGCanvas.cxx:83
#define gClient
Definition TGClient.h:157
static Bool_t IsTextFile(const char *candidate)
Returns true if given a text file Uses the specification given on p86 of the Camel book.
@ kMBNo
Definition TGMsgBox.h:32
@ kMBYes
Definition TGMsgBox.h:31
@ kMBIconExclamation
Definition TGMsgBox.h:24
static Bool_t IsTextFile(const char *candidate)
Returns true if given a text file Uses the specification given on p86 of the Camel book.
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 data
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 GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
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 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 GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
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 GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
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 GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t Atom_t typelist
Option_t Option_t width
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 GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
@ kS_IFREG
Definition TSystem.h:93
#define gVirtualX
Definition TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kC_TEXTVIEW
@ kTXT_CLICK3
@ kTXT_CLICK2
@ kTXT_ISMARKED
@ kTXT_DATACHANGE
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition TBufferFile.h:47
void * ReadObjectAny(const TClass *cast) override
Read object from I/O buffer.
@ kRead
Definition TBuffer.h:73
void SetReadMode()
Set buffer in read mode.
Definition TBuffer.cxx:302
Drag and drop data container.
const TGWindow * GetRoot() const
Returns current root (i.e.
Definition TGClient.cxx:224
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
FontH_t GetFontHandle() const
Definition TGFont.h:183
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:629
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:190
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:312
void MapWindow() override
map window
Definition TGFrame.h:204
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:225
virtual Pixel_t GetBackground() const
Definition TGFrame.h:192
virtual void SetWidth(UInt_t w)
Definition TGFrame.h:246
void SetDNDTarget(Bool_t onoff)
Definition TGFrame.h:270
static Pixel_t fgWhitePixel
Definition TGFrame.h:103
UInt_t GetWidth() const
Definition TGFrame.h:224
virtual void SetHeight(UInt_t h)
Definition TGFrame.h:247
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
void SetFont(FontH_t v)
Set font.
Definition TGGC.cxx:411
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:278
void SetBackground(Pixel_t v)
Set background color.
Definition TGGC.cxx:289
void SetGraphicsExposures(Bool_t v)
True if graphics exposure should be generated.
Definition TGGC.cxx:433
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.
Long_t fX
x position
Definition TGDimension.h:56
Long_t fY
y position
Definition TGDimension.h:57
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
const TGGC * GetDocumentBckgndGC() const
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
A TGTextView is a text viewer widget.
Definition TGTextView.h:22
Bool_t HandleDNDLeave() override
Handle Drag Leave event.
virtual Long_t ReturnLineLength(Long_t line)
Definition TGTextView.h:92
virtual void AdjustWidth()
Adjust widget width to longest line.
virtual Bool_t Search(const char *string, Bool_t direction, Bool_t caseSensitive)
Search for string in text.
Int_t fMaxDescent
maximum descent in font
Definition TGTextView.h:29
virtual void Update()
update the whole window of text view
TGGC fNormGC
graphics context for drawing text
Definition TGTextView.h:31
Int_t fMaxAscent
maximum ascent in font
Definition TGTextView.h:28
Bool_t fReadOnly
text cannot be edited
Definition TGTextView.h:39
TGText * fText
text buffer
Definition TGTextView.h:25
virtual void UnMark()
Clear marked region.
virtual Long_t ToObjXCoord(Long_t xCoord, Long_t line)
Convert x screen coordinate to column in specified line.
virtual void SetHsbPosition(Long_t newPos)
Set position of horizontal scrollbar.
virtual Bool_t LoadFile(const char *fname, long startpos=0, long length=-1)
Load a file in the text view widget.
virtual void Mark(Long_t xPos, Long_t yPos)
Mark a text region from xPos to yPos.
void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h) override
Draw lines in exposed region.
static TGGC * fgDefaultSelectedGC
Definition TGTextView.h:47
virtual Long_t ToScrYCoord(Long_t yCoord)
Convert line number to screen coordinate.
virtual Long_t ReturnLongestLineWidth()
Return width of longest line.
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
Int_t fMaxWidth
maximum width of character in font
Definition TGTextView.h:30
TGText * fClipText
clipboard text buffer
Definition TGTextView.h:26
virtual Bool_t LoadBuffer(const char *txtbuf)
Load text from a text buffer. Return false in case of failure.
void Layout() override
Layout the components of view.
FontStruct_t fFont
text font
Definition TGTextView.h:27
virtual void DataDropped(const char *fname)
Definition TGTextView.h:136
void Init(Pixel_t bg)
Initialize a text view widget.
Bool_t fIsSaved
true is content is saved
Definition TGTextView.h:38
static const TGGC & GetDefaultSelectedGC()
Return selection graphics context in use.
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Bool_t fIsMarking
true if in marking mode
Definition TGTextView.h:37
Bool_t HandleTimer(TTimer *t) override
Handle scroll timer.
Bool_t HandleSelectionClear(Event_t *event) override
Handle selection clear event.
Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action, Int_t xroot, Int_t yroot) override
Handle Drag position event.
virtual void AddLine(const char *string)
Add a line of text to the view widget.
Bool_t fIsMarked
true if text is marked/selected
Definition TGTextView.h:36
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in the text editor widget.
TGGC fSelbackGC
graphics context for drawing marked background
Definition TGTextView.h:33
virtual void HLayout()
Horizontal layout of widgets (canvas, scrollbar).
TGGC fSelGC
graphics context for drawing marked text
Definition TGTextView.h:32
Atom_t HandleDNDEnter(Atom_t *typelist) override
Handle Drag Enter event.
TViewTimer * fScrollTimer
scrollbar timer
Definition TGTextView.h:42
Bool_t HandleDoubleClick(Event_t *event) override
handle double click
static const TGGC & GetDefaultSelectedBackgroundGC()
Return graphics context for highlighted frame background.
virtual Bool_t SelectAll()
Select all text in the viewer.
TGText * GetText() const
Definition TGTextView.h:115
void SetForegroundColor(Pixel_t) override
Set text color.
Atom_t * fDNDTypeList
handles DND types
Definition TGTextView.h:43
virtual void SetSelectBack(Pixel_t p)
set selected text background color
static TGGC * fgDefaultGC
Definition TGTextView.h:46
virtual void SetVsbPosition(Long_t newPos)
Set position of vertical scrollbar.
TGLongPosition fMarkedEnd
end position of marked text
Definition TGTextView.h:41
virtual Long_t ToScrXCoord(Long_t xCoord, Long_t line)
Convert column number in specified line to screen coordinate.
virtual void VLayout()
Vertical layout of widgets (canvas, scrollbar).
static const TGFont * fgDefaultFont
Definition TGTextView.h:45
virtual void DataChanged()
Definition TGTextView.h:135
Bool_t fMarkedFromY
true if text is marker from y
Definition TGTextView.h:35
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a text edit widget as a C++ statement(s) on output stream out.
virtual Long_t ReturnLineCount()
Definition TGTextView.h:94
virtual Bool_t Copy()
Copy selected text to clipboard.
TGTextView(const TGTextView &)=delete
Bool_t HandleSelectionRequest(Event_t *event) override
Handle request to send current clipboard contents to requestor window.
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text editor.
virtual Long_t ReturnHeighestColHeight()
Definition TGTextView.h:90
virtual void AddLineFast(const char *string)
Add a line of text to the view widget.
virtual ~TGTextView()
Cleanup text view widget.
Bool_t HandleDNDDrop(TDNDData *data) override
Handle Drop event.
virtual void SetFont(FontStruct_t font)
Changes text entry font.
virtual void SetBackground(Pixel_t p)
set background color
virtual void ShowBottom()
Show bottom of the page.
virtual void SetSBRange(Int_t direction)
Set the range for the kVertical or kHorizontal scrollbar.
TGLongPosition fMarkedStart
start position of marked text
Definition TGTextView.h:40
virtual void SetText(TGText *text)
Adopt a new text buffer. The text will be deleted by this object.
Bool_t fMarkedFromX
true if text is marked from x
Definition TGTextView.h:34
virtual void ShowTop()
Show top of the page.
virtual void AddText(TGText *text)
Add text to the view widget.
virtual void SetSelectFore(Pixel_t p)
set selected text color
virtual Long_t ToObjYCoord(Long_t yCoord)
Convert y screen coordinate to line number.
void Clear(Option_t *="") override
Clear text view widget.
static const TGGC * fgDefaultSelectedBackgroundGC
Definition TGTextView.h:48
A TGText is a multi line text buffer.
Definition TGText.h:57
Bool_t AddText(TGText *text)
Add another text buffer to this buffer.
Definition TGText.cxx:911
Long_t RowCount() const
Definition TGText.h:106
Long_t GetLongestLine() const
Definition TGText.h:110
Bool_t Search(TGLongPosition *foundPos, TGLongPosition start, const char *searchString, Bool_t direction, Bool_t caseSensitive)
Search for string searchString starting at the specified position going in forward (direction = true)...
Definition TGText.cxx:1143
Bool_t Save(const char *fn)
Save text buffer to file fn.
Definition TGText.cxx:610
Bool_t InsText(TGLongPosition pos, const char *buf)
Insert single line at specified position.
Definition TGText.cxx:888
char * GetLine(TGLongPosition pos, ULong_t length)
Return string at position pos.
Definition TGText.cxx:997
Bool_t Load(const char *fn, Long_t startpos=0, Long_t length=-1)
Load text from file fn.
Definition TGText.cxx:431
Bool_t LoadBuffer(const char *txtbuf)
Load a 0 terminated buffer. Lines will be split at ' '.
Definition TGText.cxx:513
void Clear()
Clear text buffer.
Definition TGText.cxx:406
const char * GetFileName() const
Definition TGText.h:88
Long_t GetLineLength(Long_t row)
Get length of specified line. Returns -1 if row does not exist.
Definition TGText.cxx:1043
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.
A TGView provides the infrastructure for text viewer and editor widgets.
Definition TGView.h:23
TGHScrollBar * fHsb
horizontal scrollbar
Definition TGView.h:43
TGVScrollBar * fVsb
vertical scrollbar
Definition TGView.h:44
TGLongPosition fMousePos
position of mouse
Definition TGView.h:33
TGLongPosition fVisible
position of visible region
Definition TGView.h:32
UInt_t fXMargin
x margin
Definition TGView.h:40
virtual void SetVisibleStart(Int_t newTop, Int_t direction)
Scroll view in specified direction to make newTop the visible location.
Definition TGView.cxx:178
Int_t fScrolling
scrolling direction
Definition TGView.h:38
TGLongPosition fScrollVal
scroll value
Definition TGView.h:34
TGViewFrame * fCanvas
frame containing the text
Definition TGView.h:42
void Clear(Option_t *="") override
Clear view.
Definition TGView.cxx:161
virtual void UpdateRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
update a part of view
Definition TGView.cxx:204
@ kHorizontal
Definition TGView.h:29
@ kVertical
Definition TGView.h:29
TGGC fWhiteGC
graphics context used for scrolling generates GraphicsExposure events
Definition TGView.h:46
UInt_t fYMargin
y margin
Definition TGView.h:41
TGRectangle fExposedRegion
exposed area
Definition TGView.h:36
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual const TGWindow * GetMainFrame() const
Returns top level main frame.
Definition TGWindow.cxx:152
Bool_t HandleTimer(TTimer *) override
Execute action in response of a timer timing out.
Definition TGWindow.h:104
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
virtual Bool_t IsMapped()
Returns kTRUE if window is mapped on screen, kFALSE otherwise.
Definition TGWindow.cxx:295
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
Class supporting a collection of lines with C++ code.
Definition TMacro.h:31
TList * GetListOfLines() const
Definition TMacro.h:51
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Collectable string class.
Definition TObjString.h:28
const char * GetName() const override
Returns name of object.
Definition TObjString.h:38
Mother of all ROOT objects.
Definition TObject.h:41
static TClass * Class()
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
SCoord_t fY
Definition TPoint.h:36
SCoord_t fX
Definition TPoint.h:35
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:421
const char * Data() const
Definition TString.h:380
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2356
A TSystemFile describes an operating system file.
Definition TSystemFile.h:29
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1277
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition TSystem.cxx:1401
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1066
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:474
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:159
This class represents a WWW compatible URL.
Definition TUrl.h:33
const char * GetFile() const
Definition TUrl.h:69
TGView * fView
Definition TGTextView.h:147
Bool_t Notify() override
Notify when timer times out and reset the timer.
TLine * line
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TH1F * h1
Definition legend1.C:5
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
#define Marked(f)
Definition render.c:146
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fXRoot
Definition GuiTypes.h:179
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fYRoot
coordinates relative to root
Definition GuiTypes.h:179
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
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
Int_t fMode
Definition TSystem.h:127
Rectangle structure (maps to the X11 XRectangle structure)
Definition GuiTypes.h:361