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