Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTextEntry.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 08/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11/**************************************************************************
12
13 This source is based on Xclass95, a Win95-looking GUI toolkit.
14 Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15
16 Xclass95 is free software; you can redistribute it and/or
17 modify it under the terms of the GNU Library General Public
18 License as published by the Free Software Foundation; either
19 version 2 of the License, or (at your option) any later version.
20
21**************************************************************************/
22
23
24/** \class TGTextEntry
25 \ingroup guiwidgets
26
27A TGTextEntry is a one line text input widget.
28
29Changing text in the text entry widget will generate the event:
30kC_TEXTENTRY, kTE_TEXTCHANGED, widget id, 0.
31Hitting the enter key will generate:
32kC_TEXTENTRY, kTE_ENTER, widget id, 0.
33Hitting the tab key will generate:
34kC_TEXTENTRY, kTE_TAB, widget id, 0.
35
36This widget has the behaviour e.g. of the "Location" field in
37web browsers. That includes handling Control/Shift key modifiers and
38scrolling the text.
39
40enum TGTextEntry::EEchoMode
41
42This enum type describes the ways in which TGTextEntry can display
43its contents. The currently defined values are:
44
45<ul>
46<li> kNormal - display characters as they are entered. This is the default.
47<li> kNoEcho - do not display anything.
48<li> kPassword - display asterisks instead of the characters actually entered.
49</ul>
50
51See also SetEchoMode(), GetEchoMode().
52
53enum TGTextEntry::EInsertMode
54
55This enum type describes the way how typed characters are
56inserted in the text entry. This mode is switched by "Insert" key.
57
58<ul>
59<li> kInsert - typed character are inserted (cursor has shape of short line).
60<li> kReplace - typed characters substitute already typed ones
61 (cursor has the shape of filled rectangle).
62</ul>
63
64enum TGWidget::ETextJustification
65
66This enum type (defined in TGWidget.h) describes the text alignment modes.
67These modes are valid until text fits the frame width
68
69<ul>
70<li> kTextLeft - left-side text alignment
71<li> kTextRight - right-side text alignment
72<li> kTextCenterX - center text alignment
73</ul>
74
75The key press event handler converts a key press to some line editor action.
76Here are the default key bindings:
77
78
79<ul>
80<li><i> Left Arrow </i>
81 Move the cursor one character leftwards.
82 Scroll the text when cursor is out of frame.
83<li><i> Right Arrow </i>
84 Move the cursor one character rightwards
85 Scroll the text when cursor is out of frame.
86<li><i> Backspace </i>
87 Deletes the character on the left side of the text cursor and moves the
88 cursor one position to the left. If a text has been marked by the user
89 (e.g. by clicking and dragging) the cursor will be put at the beginning
90 of the marked text and the marked text will be removed.
91<li><i> Home </i>
92 Moves the text cursor to the left end of the line. If mark is TRUE text
93 will be marked towards the first position, if not any marked text will
94 be unmarked if the cursor is moved.
95<li><i> End </i>
96 Moves the text cursor to the right end of the line. If mark is TRUE text
97 will be marked towards the last position, if not any marked text will
98 be unmarked if the cursor is moved.
99<li><i> Delete </i>
100 Deletes the character on the right side of the text cursor. If a text
101 has been marked by the user (e.g. by clicking and dragging) the cursor
102 will be put at the beginning of the marked text and the marked text will
103 be removed.
104<li><i> Insert </i>
105 Switches character insert mode.
106<li><i> Shift - Left Arrow </i>
107 Mark text one character leftwards
108<li><i> Shift - Right Arrow </i>
109 Mark text one character rightwards
110<li><i> Control - Left Arrow </i>
111 Move the cursor one word leftwards
112<li><i> Control - Right Arrow </i>
113 Move the cursor one word rightwards.
114<li><i> Control - Shift - Left Arrow </i>
115 Mark text one word leftwards
116<li><i> Control - Shift - Right Arrow </i>
117 Mark text one word rightwards
118<li><i> Control-A </i>
119 Move the cursor to the beginning of the line
120<li><i> Control-B </i>
121 Move the cursor one character leftwards
122<li><i> Control-C </i>
123 Copy the marked text to the clipboard.
124<li><i> Control-D </i>
125 Delete the character to the right of the cursor
126<li><i> Control-E </i>
127 Move the cursor to the end of the line
128<li><i> Control-F </i>
129 Move the cursor one character rightwards
130<li><i> Control-H </i>
131 Delete the character to the left of the cursor
132<li><i> Control-K </i>
133 Delete marked text if any or delete all
134 characters to the right of the cursor
135<li><i> Control-U </i>
136 Delete all characters on the line
137<li><i> Control-V </i>
138 Paste the clipboard text into line edit.
139<li><i> Control-X </i>
140 Cut the marked text, copy to clipboard.
141<li><i> Control-Y </i>
142 Paste the clipboard text into line edit.
143</ul>
144All other keys with valid ASCII codes insert themselves into the line.
145*/
146
147
148//******************* TGTextEntry signals *************************************
149//______________________________________________________________________________
150// TGTextEntry::ReturnPressed()
151//
152// This signal is emitted when the return or enter key is pressed.
153//
154//______________________________________________________________________________
155// TGTextEntry::TabPressed()
156//
157// This signal is emitted when the <TAB> key is pressed.
158// Use for changing focus.
159//
160//______________________________________________________________________________
161// TGTextEntry::ShiftTabPressed()
162//
163// This signal is emitted when the <SHIFT> and <TAB> keys are pressed.
164// Use for changing focus in reverse direction.
165//
166//______________________________________________________________________________
167// TGTextEntry::TextChanged(const char *text)
168//
169// This signal is emitted every time the text has changed.
170// The argument is the new text.
171//
172//______________________________________________________________________________
173// TGTextEntry::CursorOutLeft()
174//
175// This signal is emitted when cursor is going out of left side.
176//
177//______________________________________________________________________________
178// TGTextEntry::CursorOutRight()
179//
180// This signal is emitted when cursor is going out of right side.
181//
182//______________________________________________________________________________
183// TGTextEntry::CursorOutUp()
184//
185// This signal is emitted when cursor is going out of upper side.
186//
187//______________________________________________________________________________
188// TGTextEntry::CursorOutDown()
189//
190// This signal is emitted when cursor is going out of bottom side.
191//
192//______________________________________________________________________________
193// TGTextEntry::DoubleClicked()
194//
195// This signal is emitted when widget is double clicked.
196
197
198#include "TGTextEntry.h"
199#include "TGResourcePool.h"
200#include "TGToolTip.h"
201#include "TSystem.h"
202#include "TTimer.h"
203#include "TColor.h"
204#include "KeySymbols.h"
205#include "TClass.h"
206#include "TVirtualX.h"
207#include "strlcpy.h"
208
209#include <iostream>
210
211
217
219
220////////////////////////////////////////////////////////////////////////////////
221
222class TBlinkTimer : public TTimer {
223private:
225public:
227 Bool_t Notify() override;
228};
229
230////////////////////////////////////////////////////////////////////////////////
231/// Notify when timer times out and reset the timer.
232
234{
236 Reset();
237 return kFALSE;
238}
239
240
241
242////////////////////////////////////////////////////////////////////////////////
243/// Create a text entry widget. It will adopt the TGTextBuffer object
244/// (i.e. the text buffer will be deleted by the text entry widget).
245
247 GContext_t norm, FontStruct_t font, UInt_t options,
248 Pixel_t back) :
249 TGFrame(p, 1, 1, options | kOwnBackground, back)
250{
251 TGGC *normgc = fClient->GetResourcePool()->GetGCPool()->FindGC(norm);
252
253 fWidgetId = id;
254 fMsgWindow = p;
255 if (normgc)
256 fNormGC = *normgc;
257 else
259 fFontStruct = font;
260 fText = text;
261
262 Init();
263}
264
265////////////////////////////////////////////////////////////////////////////////
266/// Simple text entry constructor.
267
268TGTextEntry::TGTextEntry(const TGWindow *parent, const char *text, Int_t id) :
269 TGFrame(parent, 1, 1, kSunkenFrame | kDoubleBorder | kOwnBackground, fgWhitePixel)
270{
271 fWidgetId = id;
272 fMsgWindow = parent;
275 fText = new TGTextBuffer();
276 fText->AddText(0, !text && !parent ? GetName() : text);
277
278 Init(); // default initialization
279}
280
281////////////////////////////////////////////////////////////////////////////////
282/// Simple test entry constructor. Notice TString argument comes before the
283/// parent argument (to make this ctor different from the first one taking a
284/// const char*).
285
286TGTextEntry::TGTextEntry(const TString &contents, const TGWindow *parent, Int_t id) :
287 TGFrame(parent, 1, 1, kSunkenFrame | kDoubleBorder | kOwnBackground, fgWhitePixel)
288{
289 fWidgetId = id;
290 fMsgWindow = parent;
293 fText = new TGTextBuffer();
294 fText->AddText(0, contents.Data());
295
296 Init(); // default initialization
297}
298
299////////////////////////////////////////////////////////////////////////////////
300/// Delete a text entry widget.
301
303{
304 delete fText;
305 delete fCurBlink;
306 delete fTip;
307
308 if (this == gBlinkingEntry) gBlinkingEntry = 0;
309}
310
311////////////////////////////////////////////////////////////////////////////////
312/// Do default initialization.
313
315{
319
320 fOffset = 0;
321 // Set default maximum length to 4096. Can be changed with SetMaxLength()
322 fMaxLen = 4096;
324 fEdited = kFALSE;
328 fDefWidth = fDefHeight = 0;
329
331 tw = gVirtualX->TextWidth(fFontStruct, GetText(), fText->GetTextLength());
332
333 if (tw < 1) {
334 TString dummy('w', fText->GetBufferLength());
335 tw = gVirtualX->TextWidth(fFontStruct, dummy.Data(), dummy.Length());
336 }
337 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
338 Resize(tw + 8, max_ascent + max_descent + 7);
339
340 Int_t offset = IsFrameDrawn() ? 4 : 0;
341 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
342 offset = 2;
343 fCursorX = offset ;
346 fCurBlink = 0;
347 fTip = 0;
348 fClipboard = fClient->GetResourcePool()->GetClipboard();
349
350 gVirtualX->SetCursor(fId, fClient->GetResourcePool()->GetTextCursor());
351
352 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
355
358
361 wattr.fBitGravity = 1; // NorthWestGravity
362 wattr.fWinGravity = 1;
363 gVirtualX->ChangeWindowAttributes(fId, &wattr);
364
368}
369
370////////////////////////////////////////////////////////////////////////////////
371/// Return the default / minimal size of the widget.
372
379
380////////////////////////////////////////////////////////////////////////////////
381/// Set the default / minimal size of the widget.
382
388
389////////////////////////////////////////////////////////////////////////////////
390/// This signal is emitted when the return or enter key is pressed.
391
399
400////////////////////////////////////////////////////////////////////////////////
401/// This signal is emitted when `SHIFT` and `TAB` keys are pressed.
402
404{
405 Emit("ShiftTabPressed()");
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// This signal is emitted when the `<TAB>` key is pressed.
410
418
419////////////////////////////////////////////////////////////////////////////////
420/// This signal is emitted every time the text has changed.
421
422void TGTextEntry::TextChanged(const char *)
423{
426
427 Emit("TextChanged(char*)", GetText()); // The argument is the new text.
428}
429
430////////////////////////////////////////////////////////////////////////////////
431/// This signal is emitted when cursor is going out of left side.
432
434{
435 Emit("CursorOutLeft()");
436}
437
438////////////////////////////////////////////////////////////////////////////////
439/// This signal is emitted when cursor is going out of right side.
440
442{
443 Emit("CursorOutRight()");
444}
445
446////////////////////////////////////////////////////////////////////////////////
447/// This signal is emitted when cursor is going out of upper side.
448
450{
451 Emit("CursorOutUp()");
452}
453
454////////////////////////////////////////////////////////////////////////////////
455/// This signal is emitted when cursor is going out of bottom side.
456
458{
459 Emit("CursorOutDown()");
460}
461
462////////////////////////////////////////////////////////////////////////////////
463/// This signal is emitted when widget is double clicked.
464
466{
467 Emit("DoubleClicked()");
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Returns the text that's currently displayed. This is normally
472/// the same as GetText(), but can be e.g.
473/// "*****" if EEchoMode is kPassword or
474/// "" if it is kNoEcho.
475
477{
478 TString res;
479
480 switch (GetEchoMode()) {
481 case kNormal:
482 res = GetText();
483 break;
484 case kNoEcho:
485 res = "";
486 break;
487 case kPassword:
488 res.Prepend('*', fText->GetTextLength()); // fill with '*'
489 break;
490 }
491 return res;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495/// Set state of widget. If kTRUE=enabled, kFALSE=disabled.
496
498{
499 if (state) {
502 } else {
505 fCursorOn = kFALSE; // remove the cursor when disabling the widget
506 if (fCurBlink) fCurBlink->Remove();
507 }
508 fClient->NeedRedraw(this);
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Returns the index of the character to whose left edge xcoord is closest.
513
515{
516 int tw, ix, up, down, len;
517
518 // check for out of boundaries first...
520 len = dt.Length();
521 tw = gVirtualX->TextWidth(fFontStruct, dt.Data(), len);
522 if (xcoord < 0) return 0;
523 if (xcoord > tw) return len; // len-1
524
525 // do a binary approximation
526 up = len; //-1
527 down = 0;
528 while (up-down > 1) {
529 ix = (up+down) >> 1;
530 tw = gVirtualX->TextWidth(fFontStruct, fText->GetString(), ix);
531 if (tw > xcoord)
532 up = ix;
533 else
534 down = ix;
535 if (tw == xcoord) break;
536 }
537 ix = down;
538
539 // safety check...
540 ix = std::max(ix, 0);
541 ix = std::min(ix, len); // len-1
542
543 return ix;
544}
545
546////////////////////////////////////////////////////////////////////////////////
547/// Sets the text entry to draw itself inside a two-pixel frame if
548/// enable is kTRUE, and to draw itself without any frame if enable is
549/// kFALSE. The default is kTRUE.
550
552{
553 if (fFrameDrawn == enable) return;
554
556 fClient->NeedRedraw(this);
557 // ChangedBy("SetFrameDrawn"); // emit signal ChangedBy
558}
559
560////////////////////////////////////////////////////////////////////////////////
561/// Sets the alignment of the text entry.
562/// Possible values are kTextLeft(default), kTextRight, kTextCenterX.
563/// See also GetAlignment().
564
566{
567 if ((mode == kTextRight ||
568 mode == kTextCenterX ||
569 mode == kTextLeft)) {
570
573 wattr.fWinGravity = 1;
574
575 if (mode == kTextLeft) {
576 wattr.fBitGravity = 1;
577 } else if (mode == kTextRight) {
578 wattr.fBitGravity = 3;
579 } else {
580 wattr.fBitGravity = 5;
581 }
582
583 gVirtualX->ChangeWindowAttributes(fId, &wattr);
584
586 UpdateOffset();
587 fClient->NeedRedraw(this);
588 // ChangedBy("SetAlignment"); // emit signal ChangedBy
589 }
590}
591
592////////////////////////////////////////////////////////////////////////////////
593/// Sets the mode how characters are entered to the text entry.
594
596{
597 if (fInsertMode == mode) return;
598
600 fClient->NeedRedraw(this);
601 // ChangedBy("SetInsertMode"); // emit signal ChangedBy
602}
603
604////////////////////////////////////////////////////////////////////////////////
605/// Sets text entry to text, clears the selection and moves
606/// the cursor to the end of the line.
607/// If necessary the text is truncated to fit MaxLength().
608/// See also GetText().
609
611{
613
614 fText->Clear();
615 fText->AddText(0, text); // new text
616
618 if (dif > 0) fText->RemoveText(fMaxLen, dif); // truncate
619
620 End(kFALSE);
621 if (oldText != GetText()) {
622 if (emit)
623 TextChanged(); // emit signal
624 fClient->NeedRedraw(this);
625 }
626}
627
628////////////////////////////////////////////////////////////////////////////////
629/// Set the maximum length of the text in the editor. If the text is
630/// currently too long, it is chopped off at the limit. Any marked text will
631/// be unmarked. The cursor position is set to 0 and the first part of the
632/// string is shown.
633/// See also GetMaxLength().
634
636{
637 fMaxLen = maxlen < 0 ? 0 : maxlen; // safety check for maxlen < 0
638
640 if (dif > 0) fText->RemoveText(fMaxLen, dif); // truncate
641
643 Deselect();
644
645 // ChangedBy("SetMaxLength"); // emit signal ChangedBy
646}
647
648////////////////////////////////////////////////////////////////////////////////
649/// The echo modes available are:
650///
651/// <ul>
652/// <li> kNormal - display characters as they are entered. This is the default.
653/// <li> kNoEcho - do not display anything.
654/// <li> kPassword - display asterisks instead of the characters actually entered.
655/// </ul>
656///
657/// It is always possible to cut and paste any marked text; only the widget's own
658/// display is affected.
659/// See also GetEchoMode(), GetDisplayText().
660
662{
663 if (fEchoMode == mode) return;
664
665 Int_t offset = IsFrameDrawn() ? 4 : 0;
666 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
667 offset = 2;
668 fEchoMode = mode;
669 if (GetEchoMode() == kNoEcho) { fCursorX = offset; }
670 UpdateOffset();
671 fClient->NeedRedraw(this);
672 // ChangedBy("SetEchoMode"); // emit signal ChangedBy
673}
674
675////////////////////////////////////////////////////////////////////////////////
676/// Returns the text marked by the user (e.g. by clicking and
677/// dragging), or zero if no text is marked.
678/// See also HasMarkedText().
679
681{
682 Int_t minP = MinMark();
683 Int_t len = MaxMark() - minP;
684 TString res(GetText()+minP,len);
685 return res;
686}
687
688////////////////////////////////////////////////////////////////////////////////
689/// New character mark at position pos.
690/// See also SetCursorPosition().
691
693{
695 Int_t offset = IsFrameDrawn() ? 4 : 0;
696 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
697 offset = 2;
698 Int_t x = fOffset + offset;
699 Int_t len = dt.Length();
700
701 Int_t pos = newPos < len ? newPos : len;
702 fEndIX = pos < 0 ? 0 : pos;
703
706
707 if (fSelectionOn) {
708 fEndX = x + gVirtualX->TextWidth(fFontStruct, dt.Data() , fEndIX);
709 fStartX = x + gVirtualX->TextWidth(fFontStruct, dt.Data() , fStartIX);
710 }
711}
712
713////////////////////////////////////////////////////////////////////////////////
714/// Set the cursor position to newPos.
715/// See also NewMark().
716
718{
719 Int_t offset = IsFrameDrawn() ? 4 : 0;
720 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
721 offset = 2;
722 if (GetEchoMode() == kNoEcho) { fCursorX = offset; return; }
723
724 UpdateOffset();
726
727 Int_t x = fOffset + offset;
728 Int_t len = dt.Length();
729
730 Int_t pos;
731
732 if (newPos < len)
733 pos = newPos;
734 else {
735 pos = len;
736 if (newPos > len) CursorOutRight();
737 }
738
739 if (pos < 0) {
740 fCursorIX = 0;
742 } else
743 fCursorIX = pos;
744
745 fCursorX = x + gVirtualX->TextWidth(fFontStruct, dt.Data(), fCursorIX);
746
747 if (!fSelectionOn){
750 }
751}
752
753////////////////////////////////////////////////////////////////////////////////
754/// Marks the word nearest to cursor position.
755/// See also HandleDoubleClick().
756
758{
759 Int_t i = pos - 1;
760 while (i >= 0 && isprint(GetText()[i]) && !isspace(GetText()[i])) i--;
761 i++;
762 Int_t newStartIX = i;
763
764 i = pos;
765 while (isprint(GetText()[i]) && !isspace(GetText()[i])) i++;
766 while(isspace(GetText()[i])) i++;
767
770 fEndIX = i;
771 NewMark(i);
772}
773
774////////////////////////////////////////////////////////////////////////////////
775/// Removes any currently selected text, inserts newText,
776/// sets it as the new contents of the text entry.
777
779{
780 TString old(GetText());
781 TString t(newText);
782
783 if (t.IsNull()) return;
784
785 for (int i=0; i<t.Length(); i++) {
786 if (t[i] < ' ') t[i] = ' '; // unprintable/linefeed becomes space
787 }
788
789 Int_t minP = MinMark();
790 Int_t maxP = MaxMark();
792
793 if (HasMarkedText()) {
795 cp = minP;
796 }
797
799 Int_t ncp = std::min(cp+t.Length(), GetMaxLength());
800 fText->AddText(cp, t.Data());
802 if (dlen>0) fText->RemoveText(GetMaxLength(),dlen); // truncate
803
805 if (old != GetText()) TextChanged();
806}
807
808////////////////////////////////////////////////////////////////////////////////
809/// Moves the cursor rightwards one or more characters.
810/// See also CursorLeft().
811
813{
815
816 if (cp == fCursorIX) {
817 if (!mark) {
820 }
821 } else if (mark) {
823 NewMark(cp);
824 } else {
827 }
828}
829
830////////////////////////////////////////////////////////////////////////////////
831/// Moves the cursor leftwards one or more characters.
832/// See also CursorRight().
833
835{
836 CursorRight(mark, -steps);
837}
838
839////////////////////////////////////////////////////////////////////////////////
840/// Moves the cursor one word to the right. If mark is kTRUE, the text
841/// is marked.
842/// See also CursorWordBackward().
843
845{
846 Int_t i = fCursorIX;
847 while (i < (Int_t)fText->GetTextLength() && !isspace(GetText()[i])) ++i;
848 while (i < (Int_t)fText->GetTextLength() && isspace(GetText()[i])) ++i;
849 CursorRight(mark, i - fCursorIX);
850}
851
852////////////////////////////////////////////////////////////////////////////////
853/// Moves the cursor one word to the left. If mark is kTRUE, the text
854/// is marked.
855/// See also CursorWordForward().
856
858{
859 Int_t i = fCursorIX;
860 while (i > 0 && isspace(GetText()[i-1])) --i;
861 while (i > 0 && !isspace(GetText()[i-1])) --i;
862 CursorLeft(mark, fCursorIX - i);
863}
864
865////////////////////////////////////////////////////////////////////////////////
866/// Deletes the character on the left side of the text cursor and moves the
867/// cursor one position to the left. If a text has been marked by the user
868/// (e.g. by clicking and dragging) the cursor will be put at the beginning
869/// of the marked text and the marked text will be removed.
870/// See also Del().
871
873{
874 if (HasMarkedText()) {
875 Del();
876 } else if (fCursorIX > 0) {
878 Del();
879 }
880}
881
882////////////////////////////////////////////////////////////////////////////////
883/// Deletes the character on the right side of the text cursor. If a text
884/// has been marked by the user (e.g. by clicking and dragging) the cursor
885/// will be put at the beginning of the marked text and the marked text will
886/// be removed.
887/// See also Backspace().
888
890{
891 Int_t minP = MinMark();
892 Int_t maxP = MaxMark();
893 Int_t offset = IsFrameDrawn() ? 4 : 0;
894 Int_t w = GetWidth() - 2 * offset; // subtract border twice
895
896 if (HasMarkedText()) {
900 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data(), dt.Length());
901 fOffset = w - textWidth - 1;
903 } else if (fCursorIX != (Int_t)fText->GetTextLength()) {
907 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data(), dt.Length());
908 fOffset = w - textWidth - 1;
910 }
911 TextChanged();
912}
913
914////////////////////////////////////////////////////////////////////////////////
915/// Deletes all characters on the right side of the cursor.
916/// See also Del() Backspace().
917
919{
923 TextChanged(); // emit signal
924 }
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Copies the marked text to the clipboard, if there is any and
929/// GetEchoMode() is kNormal.
930/// See also Cut() Paste().
931
933{
934 if (HasMarkedText() && GetEchoMode() == kNormal) {
936 *fgClipboardText = GetMarkedText(); // assign
937 gVirtualX->SetPrimarySelectionOwner(fId);
938 }
939}
940
941////////////////////////////////////////////////////////////////////////////////
942/// Inserts text at the cursor position, deleting any
943/// previous marked text.
944/// See also CopyText() Cut().
945
947{
948 if (gVirtualX->GetPrimarySelectionOwner() == kNone) {
949 // No primary selection, so use the buffer
951 } else {
952 gVirtualX->ConvertPrimarySelection(fId, fClipboard, 0);
953 }
954}
955
956////////////////////////////////////////////////////////////////////////////////
957/// Copies the marked text to the clipboard and deletes it, if there is any.
958/// See also CopyText() Paste().
959
961{
962 if (HasMarkedText()) {
963 CopyText();
964 Del();
965 }
966}
967
968////////////////////////////////////////////////////////////////////////////////
969/// Clears up the text entry.
970
972{
973 SetText("");
974}
975
976////////////////////////////////////////////////////////////////////////////////
977/// Moves the text cursor to the left end of the line. If mark is kTRUE text
978/// will be marked towards the first position, if not any marked text will
979/// be unmarked if the cursor is moved.
980/// See also End().
981
983{
984 fOffset = 0;
985 if (mark){
988 UpdateOffset();
989 NewMark(0);
990 } else {
993 }
994}
995
996////////////////////////////////////////////////////////////////////////////////
997/// Moves the text cursor to the right end of the line. If mark is kTRUE text
998/// will be marked towards the last position, if not any marked text will
999/// be unmarked if the cursor is moved.
1000/// See also Home().
1001
1003{
1005 Int_t len = dt.Length();
1006
1007 fOffset = (Int_t)GetWidth() - gVirtualX->TextWidth(fFontStruct, dt.Data(), len);
1008 if (fOffset > 0) fOffset = 0;
1009
1010 if (mark){
1013 UpdateOffset();
1014 NewMark(len);
1015 } else {
1018 }
1019}
1020
1021////////////////////////////////////////////////////////////////////////////////
1022/// Selects all text (i.e. marks it) and moves the cursor to the
1023/// end. Useful when a default value has been inserted. If the user
1024/// types before clicking on the widget the selected text will be
1025/// erased.
1026
1028{
1030 fStartIX = 0;
1032 DoRedraw();
1033}
1034
1035////////////////////////////////////////////////////////////////////////////////
1036/// Deselects all text (i.e. removes marking) and leaves the cursor at the
1037/// current position.
1038
1040{
1043 DoRedraw();
1044}
1045
1046////////////////////////////////////////////////////////////////////////////////
1047/// Draw the border of the text entry widget.
1048
1050{
1053 if (gClient->GetStyle() < 2) {
1054 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
1055 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
1056 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
1057 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
1058
1059 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
1060 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
1061 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
1062 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
1063 break;
1064 }
1065 default:
1067 break;
1068 }
1069}
1070
1071////////////////////////////////////////////////////////////////////////////////
1072/// Draw the text entry widget.
1073
1075{
1077 Int_t offset = IsFrameDrawn() ? 4 : 0;
1078 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1079 offset = 2;
1080 TString dt = GetDisplayText(); // text to be displayed
1081 Int_t len = dt.Length(); // length of displayed text
1082
1083 // TGFrame::DoRedraw() == drawing border twice
1084 Int_t border = IsFrameDrawn() ? fBorderWidth : 0;
1085
1086 gVirtualX->ClearArea(fId, border, border,
1087 fWidth - (border << 1), fHeight - (border << 1));
1088
1089 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
1090
1092 y = (fHeight - h) >> 1 ;
1093 x = fOffset + offset;
1094
1095 if (fEchoMode == kNoEcho) {
1097 fCursorX = offset;
1098 }
1099
1100 if ((GetInsertMode() == kInsert) || (fEchoMode == kNoEcho)) {
1101 // line cursor
1102 if (fCursorOn) {
1103 gVirtualX->DrawLine(fId, GetBlackGC()(), fCursorX, y - 1,
1104 fCursorX, h + 2);
1105 }
1106 gVirtualX->DrawString(fId, fNormGC(), x, y + max_ascent, dt.Data(), len);
1107
1108 } else {
1109 // filled rectangle (block) cursor
1110 gVirtualX->DrawString(fId, fNormGC(), x, y + max_ascent, dt.Data(), len);
1111
1112 if (fCursorOn) {
1113 Int_t ind = fCursorIX < len-1 ? fCursorIX : len - 1;
1115 gVirtualX->TextWidth(fFontStruct, &dt[ind],1);
1116
1117 Int_t before = gVirtualX->TextWidth(fFontStruct, dt, fCursorIX) + x;
1118
1119 gVirtualX->FillRectangle(fId, fSelbackGC , before, y ,
1120 charWidth , h + 1);
1121
1122 if (fCursorIX < len)
1123 gVirtualX->DrawString(fId, fSelGC(), before, y + max_ascent, &dt[ind], 1);
1124 }
1125 }
1126
1127 if (fSelectionOn) {
1128 int xs, ws, ixs, iws;
1129
1130 xs = std::min(fStartX, fEndX);
1131 ws = std::abs(fEndX - fStartX);
1132 ixs = std::min(fStartIX, fEndIX);
1133 iws = std::abs(fEndIX - fStartIX);
1134
1135 gVirtualX->FillRectangle(fId, fSelbackGC, xs, y, ws, h + 1);
1136
1137 gVirtualX->DrawString(fId, fSelGC(), xs, y + max_ascent,
1138 dt.Data() + ixs, iws);
1139 }
1140 if (IsFrameDrawn()) DrawBorder();
1141}
1142
1143////////////////////////////////////////////////////////////////////////////////
1144/// The key press event handler converts a key press to some line editor
1145/// action. Here are the default key bindings:
1146///
1147/// <ul>
1148/// <li><i> Left Arrow </i>
1149/// Move the cursor one character leftwards.
1150/// Scroll the text when cursor is out of frame.
1151/// <li><i> Right Arrow </i>
1152/// Move the cursor one character rightwards
1153/// Scroll the text when cursor is out of frame.
1154/// <li><i> Backspace </i>
1155/// Deletes the character on the left side of the text cursor and moves the
1156/// cursor one position to the left. If a text has been marked by the user
1157/// (e.g. by clicking and dragging) the cursor will be put at the beginning
1158/// of the marked text and the marked text will be removed.
1159/// <li><i> Home </i>
1160/// Moves the text cursor to the left end of the line. If mark is TRUE text
1161/// will be marked towards the first position, if not any marked text will
1162/// be unmarked if the cursor is moved.
1163/// <li><i> End </i>
1164/// Moves the text cursor to the right end of the line. If mark is TRUE text
1165/// will be marked towards the last position, if not any marked text will
1166/// be unmarked if the cursor is moved.
1167/// <li><i> Delete </i>
1168/// Deletes the character on the right side of the text cursor. If a text
1169/// has been marked by the user (e.g. by clicking and dragging) the cursor
1170/// will be put at the beginning of the marked text and the marked text will
1171/// be removed.
1172/// <li><i> Insert </i>
1173/// Switches character insert mode.
1174/// <li><i> Shift - Left Arrow </i>
1175/// Mark text one character leftwards
1176/// <li><i> Shift - Right Arrow </i>
1177/// Mark text one character rightwards
1178/// <li><i> Control - Left Arrow </i>
1179/// Move the cursor one word leftwards
1180/// <li><i> Control - Right Arrow </i>
1181/// Move the cursor one word rightwards.
1182/// <li><i> Control - Shift - Left Arrow </i>
1183/// Mark text one word leftwards
1184/// <li><i> Control - Shift - Right Arrow </i>
1185/// Mark text one word rightwards
1186/// <li><i> Control-A </i>
1187/// Move the cursor to the beginning of the line
1188/// <li><i> Control-B </i>
1189/// Move the cursor one character leftwards
1190/// <li><i> Control-C </i>
1191/// Copy the marked text to the clipboard.
1192/// <li><i> Control-D </i>
1193/// Delete the character to the right of the cursor
1194/// <li><i> Control-E </i>
1195/// Move the cursor to the end of the line
1196/// <li><i> Control-F </i>
1197/// Move the cursor one character rightwards
1198/// <li><i> Control-H </i>
1199/// Delete the character to the left of the cursor
1200/// <li><i> Control-K </i>
1201/// Delete marked text if any or delete all
1202/// characters to the right of the cursor
1203/// <li><i> Control-U </i>
1204/// Delete all characters on the line
1205/// <li><i> Control-V </i>
1206/// Paste the clipboard text into line edit.
1207/// <li><i> Control-X </i>
1208/// Cut the marked text, copy to clipboard.
1209/// <li><i> Control-Y </i>
1210/// Paste the clipboard text into line edit.
1211/// </ul>
1212///
1213/// All other keys with valid ASCII codes insert themselves into the line.
1214
1216{
1217 Int_t n;
1218 char tmp[10];
1219 UInt_t keysym;
1220
1221 if (fTip && event->fType == kGKeyPress) fTip->Hide();
1222
1223 if (!IsEnabled() || event->fType != kGKeyPress) return kTRUE;
1224
1225 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
1226 n = strlen(tmp);
1227
1229
1230 ReturnPressed(); // emit signal
1231 if (ROOT::Detail::HasBeenDeleted(this)) return kTRUE;
1233
1234 } else if (event->fState & kKeyShiftMask && (EKeySym)keysym == kKey_Backtab) {
1235 ShiftTabPressed(); // emit signal
1237 return kTRUE;
1238
1239 } else if ((EKeySym)keysym == kKey_Tab) {
1240
1241 TabPressed(); // emit signal
1243
1244 } else if (event->fState & kKeyControlMask) { // Cntrl key modifier pressed
1245 switch ((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1246 case kKey_A:
1247 Home(event->fState & kKeyShiftMask);
1248 break;
1249 case kKey_B:
1251 break;
1252 case kKey_C:
1253 CopyText();
1254 break;
1255 case kKey_D:
1256 Del();
1257 break;
1258 case kKey_E:
1259 End(event->fState & kKeyShiftMask);
1260 break;
1261 case kKey_F:
1263 break;
1264 case kKey_H:
1265 Backspace();
1266 break;
1267 case kKey_K:
1268 HasMarkedText() ? Del() : Remove();
1269 break;
1270 case kKey_U:
1271 Home();
1272 Remove();
1273 break;
1274 case kKey_V:
1275 Paste();
1276 break;
1277 case kKey_X:
1278 Cut();
1279 break;
1280 case kKey_Y:
1281 Paste();
1282 break;
1283 case kKey_Right:
1285 break;
1286 case kKey_Left:
1288 break;
1289 }
1290 } else if (n && keysym <127 && keysym >=32 && // printable keys
1293
1294 Insert(tmp);
1296
1297 } else {
1298 switch ((EKeySym)keysym) {
1299 case kKey_Down:
1300 CursorOutDown();
1301 break;
1302 case kKey_Up:
1303 CursorOutUp();
1304 break;
1305 case kKey_Left:
1307 break;
1308 case kKey_Right:
1310 break;
1311 case kKey_Backspace:
1312 Backspace();
1313 break;
1314 case kKey_Home:
1315 Home(event->fState & kKeyShiftMask);
1316 break;
1317 case kKey_End:
1318 End(event->fState & kKeyShiftMask);
1319 break;
1320 case kKey_Delete:
1321 Del();
1322 break;
1323 case kKey_Insert: // switch on/off insert mode
1325 break;
1326 default:
1327 // empty case to avoid compiler warning about unhandled enum values
1328 break;
1329 }
1330 }
1331
1332 UpdateOffset();
1333 fClient->NeedRedraw(this);
1334
1335 return kTRUE;
1336}
1337
1338////////////////////////////////////////////////////////////////////////////////
1339/// Handle mouse button event in text entry widget.
1340
1342{
1343 if (fTip) fTip->Hide();
1344
1345 if (!IsEnabled()) return kTRUE;
1346
1347 if (event->fType == kButtonPress) {
1348 SetFocus();
1349 if (fEchoMode == kNoEcho) return kTRUE;
1350
1351 if (event->fCode == kButton1) {
1352 Int_t offset = IsFrameDrawn() ? 4 : 0;
1353 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1354 offset = 2;
1355 Int_t x = fOffset + offset;
1356 Int_t position = GetCharacterIndex(event->fX - x);
1358 SetCursorPosition(position);
1359 DoRedraw();
1360 } else if (event->fCode == kButton2) {
1361 if (gVirtualX->GetPrimarySelectionOwner() == kNone) {
1362 // No primary selection, so use the cut buffer
1364 } else {
1365 gVirtualX->ConvertPrimarySelection(fId, fClipboard, event->fTime);
1366 }
1367 }
1368 }
1369 if (event->fType == kButtonRelease)
1370 if (event->fCode == kButton1)
1371 CopyText();
1372
1373 return kTRUE;
1374}
1375
1376////////////////////////////////////////////////////////////////////////////////
1377/// Handle mouse crossing event.
1378
1380{
1381 if (event->fType == kEnterNotify) {
1382 if (fTip) fTip->Reset();
1383 } else {
1384 if (fTip) fTip->Hide();
1385 }
1386
1387 return kTRUE;
1388}
1389
1390////////////////////////////////////////////////////////////////////////////////
1391/// Handle mouse motion event in the text entry widget.
1392
1394{
1395 if (!IsEnabled() || (GetEchoMode() == kNoEcho)) return kTRUE;
1396
1397 Int_t offset = IsFrameDrawn() ? 4 : 0;
1398 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1399 offset = 2;
1400 Int_t x = fOffset + offset;
1401 Int_t position = GetCharacterIndex(event->fX - x); // + 1;
1403 NewMark(position);
1404 UpdateOffset();
1405 DoRedraw();
1406 return kTRUE;
1407}
1408
1409////////////////////////////////////////////////////////////////////////////////
1410/// Handle mouse double click event in the text entry widget.
1411
1413{
1414 if (!IsEnabled()) return kTRUE;
1415
1416 Int_t offset = IsFrameDrawn() ? 4 : 0;
1417 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1418 offset = 2;
1419 Int_t x = fOffset + offset ;
1420
1421 DoubleClicked();
1422 SetFocus();
1423 if (fEchoMode == kNoEcho) return kTRUE;
1424
1425 Int_t position = GetCharacterIndex(event->fX - x);
1426 MarkWord(position);
1427 return kTRUE;
1428}
1429
1430////////////////////////////////////////////////////////////////////////////////
1431/// Handles resize events for this widget.
1432
1447
1448////////////////////////////////////////////////////////////////////////////////
1449/// Handle focus change event in text entry widget.
1450
1452{
1453 if (!IsEnabled()) return kTRUE;
1454
1455 // check this when porting to Win32
1456 if (event->fType == kFocusIn) {
1457 fCursorOn = kTRUE;
1458 if (!fCurBlink) fCurBlink = new TBlinkTimer(this, 500);
1459 fCurBlink->Reset();
1460 gBlinkingEntry = this;
1462 } else {
1463 fCursorOn = kFALSE;
1464 // fSelectionOn = kFALSE; // "web browser location behavior"
1465 if (fCurBlink) fCurBlink->Remove();
1466 gBlinkingEntry = 0;
1467 }
1468 fClient->NeedRedraw(this);
1469 return kTRUE;
1470}
1471
1472////////////////////////////////////////////////////////////////////////////////
1473/// Handle text selection event.
1474
1476{
1477 PastePrimary((Window_t)event->fUser[0], (Atom_t)event->fUser[3], kTRUE);
1478 return kTRUE;
1479}
1480
1481////////////////////////////////////////////////////////////////////////////////
1482/// Handle selection clear event.
1483
1485{
1488 fClient->NeedRedraw(this);
1489 return kTRUE;
1490}
1491
1492////////////////////////////////////////////////////////////////////////////////
1493/// Handle request to send current clipboard contents to requestor window.
1494
1496{
1497 Event_t reply;
1498 char *buffer;
1499 Long_t len;
1500 Atom_t targets[2];
1501 Atom_t type;
1502
1503 reply.fType = kSelectionNotify;
1504 reply.fTime = event->fTime;
1505 reply.fUser[0] = event->fUser[0]; // requestor
1506 reply.fUser[1] = event->fUser[1]; // selection
1507 reply.fUser[2] = event->fUser[2]; // target
1508 reply.fUser[3] = event->fUser[3]; // property
1509
1510 targets[0] = gVirtualX->InternAtom("TARGETS", kFALSE);
1511 targets[1] = gVirtualX->InternAtom("XA_STRING", kFALSE);
1512
1513 if ((Atom_t)event->fUser[2] == targets[0]) {
1514 type = gVirtualX->InternAtom("XA_ATOM", kFALSE);
1515 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
1516 type, (UChar_t*) targets, (Int_t) 2);
1517
1518 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
1519 return kTRUE;
1520 }
1521
1522 len = 0;
1523 if (fgClipboardText) len = fgClipboardText->Length();
1524 buffer = new char[len+1];
1525 if (fgClipboardText) strlcpy (buffer, fgClipboardText->Data(), len+1);
1526
1527 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
1528 (Atom_t) event->fUser[2], (UChar_t*) buffer,
1529 (Int_t) len);
1530 delete [] buffer;
1531
1532 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
1533
1534 return kTRUE;
1535}
1536
1537////////////////////////////////////////////////////////////////////////////////
1538/// Paste text from selection (either primary or cut buffer) into
1539/// text entry widget.
1540
1542{
1543 TString data;
1544 Int_t nchar;
1545
1546 if (!IsEnabled()) return;
1547
1548 gVirtualX->GetPasteBuffer(wid, property, data, nchar, del);
1549
1550 if (nchar) Insert(data.Data());
1551 fClient->NeedRedraw(this);
1552}
1553
1554////////////////////////////////////////////////////////////////////////////////
1555/// Handle cursor blink timer.
1556
1558{
1560 DoRedraw();
1561 return kTRUE;
1562}
1563
1564////////////////////////////////////////////////////////////////////////////////
1565/// Returns kTRUE if cursor is out of frame.
1566
1568{
1569 // fCursorX = fOffset + 4 + gVirtualX->TextWidth(fFontStruct,
1570 // GetDisplayText(), fCursorIX);
1571
1572 Int_t offset = IsFrameDrawn() ? 4 : 0;
1573 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1574 offset = 2;
1575 Int_t w = GetWidth();
1576 return ((fCursorX < offset) || (fCursorX > w-offset));
1577}
1578
1579////////////////////////////////////////////////////////////////////////////////
1580/// Shift position of cursor by one character.
1581
1583{
1584 if (GetEchoMode() == kNoEcho) return;
1585
1587 Int_t len = dt.Length();
1588 Int_t ind = fCursorIX < len-1 ? fCursorIX : len-1;
1589 Int_t charWidth = ind < 0 ? 4 : gVirtualX->TextWidth(fFontStruct, &dt[ind],1);
1590 Int_t w = GetWidth();
1591 Int_t d;
1592 Int_t offset = IsFrameDrawn() ? 4 : 0;
1593 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1594 offset = 2;
1595
1596 if (fCursorX < offset) {
1597 fOffset += charWidth;
1599 d = fCursorX;
1600
1601 if (d < offset){ // correction
1602 d -= offset;
1603 fOffset -= d;
1604 fCursorX -= d;
1605 }
1606 } else if (fCursorX > w-offset) {
1607 fOffset -= charWidth;
1609 d = w - fCursorX;
1610
1611 if (d < offset) { // correction
1612 d -= offset;
1613 fOffset += d;
1614 fCursorX += d;
1615 }
1616 }
1617}
1618
1619////////////////////////////////////////////////////////////////////////////////
1620/// Updates start text offset according GetAlignment() mode,
1621/// if cursor is out of frame => scroll the text.
1622/// See also SetAlignment() and ScrollByChar().
1623
1625{
1627 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data() , dt.Length());
1628 Int_t offset = IsFrameDrawn() ? 4 : 0;
1629 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1630 offset = 2;
1631 Int_t w = GetWidth() - 2 * offset; // subtract border twice
1632
1633 if (fAlignment == kTextRight) fOffset = w - textWidth - 1;
1634 else if (fAlignment == kTextCenterX) fOffset = (w - textWidth)/2;
1635 else if (fAlignment == kTextLeft) fOffset = 0;
1636 if (textWidth > 0 && textWidth > w) { // may need to scroll.
1638 }
1639}
1640
1641////////////////////////////////////////////////////////////////////////////////
1642/// Set tool tip text associated with this text entry. The delay is in
1643/// milliseconds (minimum 250). To remove tool tip call method with
1644/// text = 0.
1645
1647{
1648 if (fTip) {
1649 delete fTip;
1650 fTip = 0;
1651 }
1652
1653 if (text && strlen(text))
1654 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
1655}
1656
1657////////////////////////////////////////////////////////////////////////////////
1658/// Set focus to this text entry.
1659
1661{
1662 if (gBlinkingEntry && (gBlinkingEntry != this)) {
1664 }
1665 RequestFocus();
1666}
1667
1668////////////////////////////////////////////////////////////////////////////////
1669/// Inserts text at position pos, clears the selection and moves
1670/// the cursor to the end of the line.
1671/// If necessary the text is truncated to fit MaxLength().
1672/// See also GetText(), SetText(), AppendText(), RemoveText().
1673
1674void TGTextEntry::InsertText(const char *text, Int_t pos)
1675{
1676 Int_t position = std::min((Int_t)fText->GetTextLength(), pos);
1678 newText.Insert(position, text);
1679 SetText(newText.Data());
1680}
1681
1682////////////////////////////////////////////////////////////////////////////////
1683/// Appends text to the end of text entry, clears the selection
1684/// and moves the cursor to the end of the line.
1685/// If necessary the text is truncated to fit MaxLength().
1686/// See also GetText(), InsertText(), SetText(), RemoveText().
1687
1689{
1691}
1692
1693////////////////////////////////////////////////////////////////////////////////
1694/// Removes text at the range, clears the selection and moves
1695/// the cursor to the end of the line.
1696/// See also GetText(), InsertText(), SetText(), AppendText().
1697
1699{
1700 Int_t pos = std::min(start, end);
1701 Int_t len = std::abs(end-start);
1703 newText.Remove(pos, len);
1704 SetText(newText.Data());
1705}
1706
1707
1708////////////////////////////////////////////////////////////////////////////////
1709/// Changes text font.
1710/// If local is kTRUE font is changed locally.
1711
1713{
1714 if (font == fFontStruct) return;
1715
1716 FontH_t v = gVirtualX->GetFontHandle(font);
1717
1718 if (!v) return;
1719
1720 if (local) {
1721 TGGC *gc = new TGGC(fNormGC); // copy
1723 fNormGC = *gc;
1724 gc = new TGGC(fSelGC); // copy
1725 fSelGC = *gc;
1726 }
1727 fNormGC.SetFont(v);
1728 fSelGC.SetFont(v);
1729 fFontStruct = font;
1730 fClient->NeedRedraw(this);
1731}
1732
1733////////////////////////////////////////////////////////////////////////////////
1734/// Changes text font specified by name.
1735/// If local is kTRUE font is changed locally.
1736
1738{
1739 TGFont *font = fClient->GetFont(fontName);
1740 if (font) {
1741 SetFont(font->GetFontStruct(), local);
1742 }
1743}
1744
1745////////////////////////////////////////////////////////////////////////////////
1746/// Changes text font specified by pointer to TGFont object.
1747/// If local is kTRUE font is changed locally.
1748
1750{
1751 if (font) {
1752 SetFont(font->GetFontStruct(), local);
1753 }
1754}
1755
1756////////////////////////////////////////////////////////////////////////////////
1757/// Changes text color.
1758/// If local is true color is changed locally.
1759
1761{
1762 if (local) {
1763 TGGC *gc = new TGGC(fNormGC); // copy
1765 fNormGC = *gc;
1766 }
1767
1768 fNormGC.SetForeground(color);
1769 fClient->NeedRedraw(this);
1770}
1771
1772////////////////////////////////////////////////////////////////////////////////
1773/// Changes text color.
1774/// If local is true color is changed locally.
1775
1777{
1778 if (color) {
1779 SetTextColor(color->GetPixel(), local);
1780 }
1781}
1782
1783////////////////////////////////////////////////////////////////////////////////
1784/// Return default font structure in use.
1785
1787{
1788 if (!fgDefaultFont)
1789 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1790 return fgDefaultFont->GetFontStruct();
1791}
1792
1793////////////////////////////////////////////////////////////////////////////////
1794/// Return default graphics context.
1795
1797{
1798 if (!fgDefaultGC)
1799 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1800 return *fgDefaultGC;
1801}
1802
1803////////////////////////////////////////////////////////////////////////////////
1804/// Return selection graphics context.
1805
1807{
1809 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
1810 return *fgDefaultSelectedGC;
1811}
1812
1813////////////////////////////////////////////////////////////////////////////////
1814/// Return graphics context for highlighted frame background.
1815
1817{
1819 fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
1821}
1822
1823////////////////////////////////////////////////////////////////////////////////
1824/// Save a text entry widget as a C++ statement(s) on output stream out.
1825
1826void TGTextEntry::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1827{
1828 // font + GC
1829 option = GetName() + 5; // unique digit id of the name
1831 // coverity[returned_null]
1832 // coverity[dereference]
1833 parFont.Form("%s::GetDefaultFontStruct()", IsA()->GetName());
1834 // coverity[returned_null]
1835 // coverity[dereference]
1836 parGC.Form("%s::GetDefaultGC()()", IsA()->GetName());
1837
1838 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC.GetGC())) {
1839 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
1840 if (ufont) {
1841 ufont->SavePrimitive(out, option);
1842 parFont.Form("ufont->GetFontStruct()");
1843 }
1844
1845 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC.GetGC());
1846 if (userGC) {
1847 userGC->SavePrimitive(out, option);
1848 parGC.Form("uGC->GetGC()");
1849 }
1850 }
1851
1852 // store options and color if differ from defauls
1854
1855 out << " TGTextEntry *" << GetName() << " = new TGTextEntry(" << fParent->GetName() << ", new TGTextBuffer("
1856 << GetBuffer()->GetBufferLength() << ")";
1857 if (!extra_args.IsNull() || (fFontStruct != GetDefaultFontStruct()))
1858 out << ", " << fWidgetId << ", " << parGC << ", " << parFont << extra_args;
1859 else if (fNormGC() != GetDefaultGC()())
1860 out << ", " << fWidgetId << ", " << parGC;
1861 else if (fWidgetId != -1)
1862 out << ", " << fWidgetId;
1863 out << ");\n";
1864
1865 if (option && strstr(option, "keep_names"))
1866 out << " " << GetName() << "->SetName(\"" << GetName() << "\");\n";
1867
1868 out << " " << GetName() << "->SetMaxLength(" << GetMaxLength() << ");\n";
1869
1870 out << " " << GetName() << "->SetAlignment(";
1871
1872 if (fAlignment == kTextLeft)
1873 out << "kTextLeft);\n";
1874 else if (fAlignment == kTextRight)
1875 out << "kTextRight);\n";
1876 else /* if (fAlignment == kTextCenterX) */
1877 out << "kTextCenterX);\n";
1878
1879 out << " " << GetName() << "->SetText(\"" << TString(GetText()).ReplaceSpecialCppChars() << "\");\n";
1880
1881 out << " " << GetName() << "->Resize(" << GetWidth() << "," << GetName() << "->GetDefaultHeight());\n";
1882
1883 if ((fDefWidth > 0) || (fDefHeight > 0))
1884 out << " " << GetName() << "->SetDefaultSize(" << fDefWidth << "," << fDefHeight << ");\n";
1885
1886 if (fTip)
1887 out << " " << GetName() << "->SetToolTipText(\""
1888 << TString(fTip->GetText()->GetString()).ReplaceSpecialCppChars() << "\");\n";
1889}
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
@ kGKeyPress
Definition GuiTypes.h:60
@ kButtonRelease
Definition GuiTypes.h:60
@ kSelectionNotify
Definition GuiTypes.h:63
@ kButtonPress
Definition GuiTypes.h:60
@ kFocusIn
Definition GuiTypes.h:61
@ kEnterNotify
Definition GuiTypes.h:61
const Mask_t kWABitGravity
Definition GuiTypes.h:144
const Mask_t kButtonMotionMask
Definition GuiTypes.h:164
const Mask_t kFocusChangeMask
Definition GuiTypes.h:169
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:35
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kWAWinGravity
Definition GuiTypes.h:145
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kKeyShiftMask
Definition GuiTypes.h:195
@ kRaisedFrame
Definition GuiTypes.h:384
@ kSunkenFrame
Definition GuiTypes.h:383
@ kDoubleBorder
Definition GuiTypes.h:385
@ kFixedWidth
Definition GuiTypes.h:387
@ kFixedHeight
Definition GuiTypes.h:389
@ kOwnBackground
Definition GuiTypes.h:391
const Handle_t kNone
Definition GuiTypes.h:88
const Mask_t kKeyControlMask
Definition GuiTypes.h:197
const Mask_t kLeaveWindowMask
Definition GuiTypes.h:168
const Mask_t kStructureNotifyMask
Definition GuiTypes.h:166
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton2
Definition GuiTypes.h:214
@ kButton1
Definition GuiTypes.h:214
@ kAnyButton
Definition GuiTypes.h:214
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
const Atom_t kCutBuffer
in /usr/include/X11/Xatom.h
Definition GuiTypes.h:368
EKeySym
Definition KeySymbols.h:25
@ kKey_Right
Definition KeySymbols.h:42
@ kKey_Down
Definition KeySymbols.h:43
@ kKey_Y
Definition KeySymbols.h:150
@ kKey_B
Definition KeySymbols.h:127
@ kKey_F
Definition KeySymbols.h:131
@ kKey_Up
Definition KeySymbols.h:41
@ kKey_Return
Definition KeySymbols.h:30
@ kKey_C
Definition KeySymbols.h:128
@ kKey_Delete
Definition KeySymbols.h:33
@ kKey_A
Definition KeySymbols.h:126
@ kKey_Left
Definition KeySymbols.h:40
@ kKey_E
Definition KeySymbols.h:130
@ kKey_Backspace
Definition KeySymbols.h:29
@ kKey_D
Definition KeySymbols.h:129
@ kKey_X
Definition KeySymbols.h:149
@ kKey_Home
Definition KeySymbols.h:38
@ kKey_U
Definition KeySymbols.h:146
@ kKey_Insert
Definition KeySymbols.h:32
@ kKey_Enter
Definition KeySymbols.h:31
@ kKey_Tab
Definition KeySymbols.h:27
@ kKey_H
Definition KeySymbols.h:133
@ kKey_Backtab
Definition KeySymbols.h:28
@ kKey_End
Definition KeySymbols.h:39
@ kKey_K
Definition KeySymbols.h:136
@ kKey_V
Definition KeySymbols.h:147
#define d(i)
Definition RSha256.hxx:102
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gClient
Definition TGClient.h:157
TGTextEntry * gBlinkingEntry
ETextJustification
Definition TGWidget.h:22
@ kTextCenterX
Definition TGWidget.h:25
@ kTextLeft
Definition TGWidget.h:23
@ kTextRight
Definition TGWidget.h:24
@ kWidgetIsEnabled
Definition TGWidget.h:37
@ kWidgetWantFocus
Definition TGWidget.h:35
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t del
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
Option_t Option_t TPoint TPoint const char mode
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t nchar
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
Option_t Option_t TPoint TPoint const char text
R__EXTERN TSystem * gSystem
Definition TSystem.h:572
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kTE_TEXTCHANGED
@ kTE_ENTER
@ kTE_TAB
@ kC_TEXTENTRY
TGTextEntry * fTextEntry
Bool_t Notify() override
Notify when timer times out and reset the timer.
TBlinkTimer(TGTextEntry *t, Long_t ms)
The color creation and management class.
Definition TColor.h:22
ULong_t GetPixel() const
Return pixel value corresponding to this color.
Definition TColor.cxx:1564
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition TGClient.cxx:233
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:922
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:356
const TGResourcePool * GetResourcePool() const
Definition TGClient.h:124
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:380
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:331
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:727
UInt_t fOptions
frame options
Definition TGFrame.h:94
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:435
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:413
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
void SetBackgroundColor(Pixel_t back) override
Set background color (override from TGWindow base class).
Definition TGFrame.cxx:304
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:747
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:675
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:637
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:757
UInt_t fWidth
frame width
Definition TGFrame.h:87
TString SaveCtorArgs(std::ostream &out, UInt_t dflt_options=kChildFrame, Bool_t check_white_pixel=kFALSE)
Return options and custom color as constructor args Used in the SavePrimitive methods,...
Definition TGFrame.cxx:2493
static Pixel_t fgWhitePixel
Definition TGFrame.h:103
UInt_t GetWidth() const
Definition TGFrame.h:226
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:767
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
GContext_t GetGC() const
Definition TGGC.h:41
void SetFont(FontH_t v)
Set font.
Definition TGGC.cxx:410
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:277
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
A text buffer is used in several widgets, like TGTextEntry, TGFileDialog, etc.
UInt_t GetBufferLength() const
void AddText(Int_t pos, const char *text)
const char * GetString() const
void RemoveText(Int_t pos, Int_t length)
UInt_t GetTextLength() const
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
Int_t fOffset
start position of text (in pixels)
Definition TGTextEntry.h:37
virtual void SetFocus()
Set focus to this text entry.
void CursorLeft(Bool_t mark=kFALSE, Int_t steps=1)
Moves the cursor leftwards one or more characters.
Bool_t fFrameDrawn
kTRUE draw itself inside a two-pixel frame, kFALSE draw without any frame
Definition TGTextEntry.h:50
void CursorRight(Bool_t mark=kFALSE, Int_t steps=1)
Moves the cursor rightwards one or more characters.
Bool_t HasMarkedText() const
Int_t fStartIX
selection begin in characters
Definition TGTextEntry.h:34
virtual void SetEchoMode(EEchoMode mode=kNormal)
The echo modes available are:
virtual void SetDefaultSize(UInt_t w, UInt_t h)
Set the default / minimal size of the widget.
UInt_t fDefHeight
default height
Definition TGTextEntry.h:56
Bool_t HandleConfigureNotify(Event_t *event) override
Handles resize events for this widget.
virtual void SetMaxLength(Int_t maxlen)
Set the maximum length of the text in the editor.
EEchoMode fEchoMode
OPTION={GetMethod="GetEchoMode";SetMethod="SetEchoMode";Items=(kNormal="Normal",kNoEcho="No Echo",...
Definition TGTextEntry.h:51
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
virtual void RemoveText(Int_t start, Int_t end)
Removes text at the range, clears the selection and moves the cursor to the end of the line.
Int_t fStartX
selection begin in pixels
Definition TGTextEntry.h:32
Bool_t HandleKey(Event_t *event) override
The key press event handler converts a key press to some line editor action.
TGTextBuffer * fText
text buffer
Definition TGTextEntry.h:31
Bool_t HandleSelectionRequest(Event_t *event) override
Handle request to send current clipboard contents to requestor window.
TString GetDisplayText() const
Returns the text that's currently displayed.
UInt_t fDefWidth
default width
Definition TGTextEntry.h:55
TGGC fNormGC
normal drawing context
Definition TGTextEntry.h:42
~TGTextEntry() override
Delete a text entry widget.
Bool_t fHasOwnFont
kTRUE - font defined locally, kFALSE - globally
Definition TGTextEntry.h:54
void Clear(Option_t *option="") override
Clears up the text entry.
void Deselect()
Deselects all text (i.e.
TBlinkTimer * fCurBlink
cursor blink timer
Definition TGTextEntry.h:46
void CopyText() const
Copies the marked text to the clipboard, if there is any and GetEchoMode() is kNormal.
static TString * fgClipboardText
application clipboard text
Definition TGTextEntry.h:68
virtual void UpdateOffset()
Updates start text offset according GetAlignment() mode, if cursor is out of frame => scroll the text...
TGTextBuffer * GetBuffer() const
const char * GetText() const
Bool_t HandleTimer(TTimer *t) override
Handle cursor blink timer.
virtual void TabPressed()
This signal is emitted when the <TAB> key is pressed.
Bool_t HandleSelectionClear(Event_t *event) override
Handle selection clear event.
void CursorWordBackward(Bool_t mark=kFALSE)
Moves the cursor one word to the left.
virtual void SetCursorPosition(Int_t pos)
Set the cursor position to newPos.
void Backspace()
Deletes the character on the left side of the text cursor and moves the cursor one position to the le...
TString GetMarkedText() const
Returns the text marked by the user (e.g.
Bool_t HandleSelection(Event_t *event) override
Handle text selection event.
void Del()
Deletes the character on the right side of the text cursor.
Bool_t fCursorOn
cursor status (on/off)
Definition TGTextEntry.h:40
static const TGFont * fgDefaultFont
Definition TGTextEntry.h:69
Bool_t HandleDoubleClick(Event_t *event) override
Handle mouse double click event in the text entry widget.
TGToolTip * fTip
associated tooltip
Definition TGTextEntry.h:47
void NewMark(Int_t pos)
New character mark at position pos.
Bool_t IsFrameDrawn() const
static const TGGC & GetDefaultSelectedBackgroundGC()
Return graphics context for highlighted frame background.
TGTextEntry(const TGTextEntry &)=delete
virtual void AppendText(const char *text)
Appends text to the end of text entry, clears the selection and moves the cursor to the end of the li...
virtual void SelectAll()
Selects all text (i.e.
virtual void CursorOutRight()
This signal is emitted when cursor is going out of right side.
void Paste()
Inserts text at the cursor position, deleting any previous marked text.
virtual void SetFrameDrawn(Bool_t flag=kTRUE)
Sets the text entry to draw itself inside a two-pixel frame if enable is kTRUE, and to draw itself wi...
EInsertMode fInsertMode
OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="Insert",...
Definition TGTextEntry.h:52
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
Int_t fEndIX
selection end in characters
Definition TGTextEntry.h:35
Atom_t fClipboard
clipboard property
Definition TGTextEntry.h:45
virtual void ScrollByChar()
Shift position of cursor by one character.
Int_t GetCharacterIndex(Int_t xcoord)
Returns the index of the character to whose left edge xcoord is closest.
TGGC fSelGC
selected text drawing context
Definition TGTextEntry.h:43
TClass * IsA() const override
EInsertMode GetInsertMode() const
virtual void ShiftTabPressed()
This signal is emitted when SHIFT and TAB keys are pressed.
Int_t fEndX
selection end in pixels
Definition TGTextEntry.h:33
virtual void ReturnPressed()
This signal is emitted when the return or enter key is pressed.
static const TGGC * fgDefaultSelectedGC
Definition TGTextEntry.h:70
GContext_t fSelbackGC
selected background drawing context
Definition TGTextEntry.h:44
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
EEchoMode GetEchoMode() const
ETextJustification fAlignment
OPTION={GetMethod="GetAlignment";SetMethod="SetAlignment";Items=(kTextLeft="Left",...
Definition TGTextEntry.h:53
Bool_t fSelectionOn
selection status (on/off)
Definition TGTextEntry.h:36
Bool_t HandleFocusChange(Event_t *event) override
Handle focus change event in text entry widget.
virtual void SetTextColor(Pixel_t color, Bool_t local=kTRUE)
Changes text color.
void DoRedraw() override
Draw the text entry widget.
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line.
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion event in the text entry widget.
FontStruct_t fFontStruct
text font
Definition TGTextEntry.h:41
virtual void CursorOutLeft()
This signal is emitted when cursor is going out of left side.
TGDimension GetDefaultSize() const override
Return the default / minimal size of the widget.
void DrawBorder() override
Draw the border of the text entry widget.
Int_t MaxMark() const
void Cut()
Copies the marked text to the clipboard and deletes it, if there is any.
static const TGGC * fgDefaultGC
Definition TGTextEntry.h:72
void End(Bool_t mark=kFALSE)
Moves the text cursor to the right end of the line.
virtual void InsertText(const char *text, Int_t pos)
Inserts text at position pos, clears the selection and moves the cursor to the end of the line.
virtual void CursorOutDown()
This signal is emitted when cursor is going out of bottom side.
virtual void SetFont(TGFont *font, Bool_t local=kTRUE)
Changes text font specified by pointer to TGFont object.
virtual Bool_t IsCursorOutOfFrame()
Returns kTRUE if cursor is out of frame.
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a text entry widget as a C++ statement(s) on output stream out.
virtual void SetInsertMode(EInsertMode mode=kInsert)
Sets the mode how characters are entered to the text entry.
void CursorWordForward(Bool_t mark=kFALSE)
Moves the cursor one word to the right.
virtual void Insert(const char *)
Removes any currently selected text, inserts newText, sets it as the new contents of the text entry.
virtual void Init()
Do default initialization.
Bool_t HandleButton(Event_t *event) override
Handle mouse button event in text entry widget.
Bool_t fEdited
kFALSE, if the line edit's contents have not been changed since the construction
Definition TGTextEntry.h:49
Int_t MinMark() const
void MarkWord(Int_t pos)
Marks the word nearest to cursor position.
virtual void TextChanged(const char *text=nullptr)
This signal is emitted every time the text has changed.
void Home(Bool_t mark=kFALSE)
Moves the text cursor to the left end of the line.
virtual void DoubleClicked()
This signal is emitted when widget is double clicked.
virtual void PastePrimary(Window_t wid, Atom_t property, Bool_t del)
Paste text from selection (either primary or cut buffer) into text entry widget.
Int_t fCursorX
cursor position in pixels
Definition TGTextEntry.h:38
static const TGGC & GetDefaultSelectedGC()
Return selection graphics context.
virtual void CursorOutUp()
This signal is emitted when cursor is going out of upper side.
static const TGGC & GetDefaultGC()
Return default graphics context.
Int_t GetMaxLength() const
Int_t fMaxLen
maximum length of text
Definition TGTextEntry.h:48
Int_t fCursorIX
cursor position in characters
Definition TGTextEntry.h:39
Bool_t HandleCrossing(Event_t *event) override
Handle mouse crossing event.
void Remove()
Deletes all characters on the right side of the cursor.
static const TGGC * fgDefaultSelectedBackgroundGC
Definition TGTextEntry.h:71
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
void Hide()
Hide tool tip window.
const TGString * GetText() const
Get the tool tip text.
void Reset()
Reset tool tip popup delay timer.
Int_t fWidgetId
the widget id (used for event processing)
Definition TGWidget.h:46
TString fCommand
command to be executed
Definition TGWidget.h:49
Int_t ClearFlags(Int_t flags)
Definition TGWidget.h:59
Int_t fWidgetFlags
widget status flags (OR of EWidgetStatus)
Definition TGWidget.h:47
Int_t SetFlags(Int_t flags)
Definition TGWidget.h:58
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
Bool_t IsEnabled() const
Definition TGWidget.h:69
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:230
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableHeight
window height cannot be edited
Definition TGWindow.h:62
virtual void SetWindowName(const char *name=nullptr)
Set window name.
Definition TGWindow.cxx:127
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:425
TString & ReplaceSpecialCppChars()
Find special characters which are typically used in printf() calls and replace them by appropriate es...
Definition TString.cxx:1121
const char * Data() const
Definition TString.h:384
TString & Prepend(const char *cs)
Definition TString.h:681
Bool_t IsNull() const
Definition TString.h:422
virtual void AddTimer(TTimer *t)
Add timer to list of system timers.
Definition TSystem.cxx:469
Handles synchronous and a-synchronous timer events.
Definition TTimer.h:51
void Reset()
Reset the timer.
Definition TTimer.cxx:162
void Remove() override
Definition TTimer.h:86
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:405
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
UInt_t fState
key or button mask
Definition GuiTypes.h:181
Int_t fX
Definition GuiTypes.h:178
Time_t fTime
time event event occurred in ms
Definition GuiTypes.h:177
UInt_t fCode
key or button code
Definition GuiTypes.h:180
Longptr_t fUser[5]
5 longs can be used by client message events NOTE: only [0], [1] and [2] may be used.
Definition GuiTypes.h:187
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93