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