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// //
25// TGTextEntry //
26// //
27// A TGTextEntry is a one line text input widget. //
28// //
29// Changing text in the text entry widget will generate the event: //
30// kC_TEXTENTRY, kTE_TEXTCHANGED, widget id, 0. //
31// Hitting the enter key will generate: //
32// kC_TEXTENTRY, kTE_ENTER, widget id, 0. //
33// Hitting the tab key will generate: //
34// kC_TEXTENTRY, kTE_TAB, widget id, 0. //
35// //
36// This widget has the behaviour e.g. of the "Location" field in //
37// netscape. That includes handling Control/Shift key modifiers and //
38// scrolling the text. //
39//
40//
41// enum TGTextEntry::EEchoMode
42//
43// This enum type describes the ways in which TGTextEntry can display
44// its contents. The currently defined values are:
45//
46/*
47<ul>
48<li> kNormal - display characters as they are entered. This is the default.
49<li> kNoEcho - do not display anything.
50<li> kPassword - display asterisks instead of the characters actually entered.
51</ul>
52*/
53//
54// See also SetEchoMode(), GetEchoMode().
55//
56// enum TGTextEntry::EInsertMode
57//
58// This enum type describes the way how typed characters are
59// inserted in the text entry. This mode is switched by "Insert" key.
60//
61/*
62<ul>
63<li> kInsert - typed character are inserted (cursor has shape of short line).
64<li> kReplace - typed characters substitute already typed ones
65 (cursor has the shape of filled rectangle).
66</ul>
67*/
68//
69//
70// enum TGWidget::ETextJustification
71//
72// This enum type (defined in TGWidget.h) describes the text alignment modes.
73// These modes are valid until text fits the frame width
74//
75/*
76<ul>
77<li> kTextLeft - left-side text alignment
78<li> kTextRight - right-side text alignment
79<li> kTextCenterX - center text alignment
80</ul>
81*/
82//
83//
84//
85// The key press event handler converts a key press to some line editor action.
86// Here are the default key bindings:
87//
88/*
89<ul>
90<li><i> Left Arrow </i>
91 Move the cursor one character leftwards.
92 Scroll the text when cursor is out of frame.
93<li><i> Right Arrow </i>
94 Move the cursor one character rightwards
95 Scroll the text when cursor is out of frame.
96<li><i> Backspace </i>
97 Deletes the character on the left side of the text cursor and moves the
98 cursor one position to the left. If a text has been marked by the user
99 (e.g. by clicking and dragging) the cursor will be put at the beginning
100 of the marked text and the marked text will be removed.
101<li><i> Home </i>
102 Moves the text cursor to the left end of the line. If mark is TRUE text
103 will be marked towards the first position, if not any marked text will
104 be unmarked if the cursor is moved.
105<li><i> End </i>
106 Moves the text cursor to the right end of the line. If mark is TRUE text
107 will be marked towards the last position, if not any marked text will
108 be unmarked if the cursor is moved.
109<li><i> Delete </i>
110 Deletes the character on the right side of the text cursor. If a text
111 has been marked by the user (e.g. by clicking and dragging) the cursor
112 will be put at the beginning of the marked text and the marked text will
113 be removed.
114<li><i> Insert </i>
115 Switches character insert mode.
116<li><i> Shift - Left Arrow </i>
117 Mark text one character leftwards
118<li><i> Shift - Right Arrow </i>
119 Mark text one character rightwards
120<li><i> Control - Left Arrow </i>
121 Move the cursor one word leftwards
122<li><i> Control - Right Arrow </i>
123 Move the cursor one word rightwards.
124<li><i> Control - Shift - Left Arrow </i>
125 Mark text one word leftwards
126<li><i> Control - Shift - Right Arrow </i>
127 Mark text one word rightwards
128<li><i> Control-A </i>
129 Move the cursor to the beginning of the line
130<li><i> Control-B </i>
131 Move the cursor one character leftwards
132<li><i> Control-C </i>
133 Copy the marked text to the clipboard.
134<li><i> Control-D </i>
135 Delete the character to the right of the cursor
136<li><i> Control-E </i>
137 Move the cursor to the end of the line
138<li><i> Control-F </i>
139 Move the cursor one character rightwards
140<li><i> Control-H </i>
141 Delete the character to the left of the cursor
142<li><i> Control-K </i>
143 Delete marked text if any or delete all
144 characters to the right of the cursor
145<li><i> Control-U </i>
146 Delete all characters on the line
147<li><i> Control-V </i>
148 Paste the clipboard text into line edit.
149<li><i> Control-X </i>
150 Cut the marked text, copy to clipboard.
151<li><i> Control-Y </i>
152 Paste the clipboard text into line edit.
153</ul>
154All other keys with valid ASCII codes insert themselves into the line.
155*/
156//
157//
158////////////////////////////////////////////////////////////////////////////////
159
160//******************* TGTextEntry signals *************************************
161//______________________________________________________________________________
162// TGTextEntry::ReturnPressed()
163//
164// This signal is emitted when the return or enter key is pressed.
165//
166//______________________________________________________________________________
167// TGTextEntry::TabPressed()
168//
169// This signal is emitted when the <TAB> key is pressed.
170// Use for changing focus.
171//
172//______________________________________________________________________________
173// TGTextEntry::ShiftTabPressed()
174//
175// This signal is emitted when the <SHIFT> and <TAB> keys are pressed.
176// Use for changing focus in reverse direction.
177//
178//______________________________________________________________________________
179// TGTextEntry::TextChanged(const char *text)
180//
181// This signal is emitted every time the text has changed.
182// The argument is the new text.
183//
184//______________________________________________________________________________
185// TGTextEntry::CursorOutLeft()
186//
187// This signal is emitted when cursor is going out of left side.
188//
189//______________________________________________________________________________
190// TGTextEntry::CursorOutRight()
191//
192// This signal is emitted when cursor is going out of right side.
193//
194//______________________________________________________________________________
195// TGTextEntry::CursorOutUp()
196//
197// This signal is emitted when cursor is going out of upper side.
198//
199//______________________________________________________________________________
200// TGTextEntry::CursorOutDown()
201//
202// This signal is emitted when cursor is going out of bottom side.
203//
204//______________________________________________________________________________
205// TGTextEntry::DoubleClicked()
206//
207// This signal is emitted when widget is double clicked.
208
209
210#include "TGTextEntry.h"
211#include "TGResourcePool.h"
212#include "TGToolTip.h"
213#include "TSystem.h"
214#include "TTimer.h"
215#include "TColor.h"
216#include "KeySymbols.h"
217#include "TClass.h"
218#include "TVirtualX.h"
219#include "strlcpy.h"
220
221#include <iostream>
222
223
229
231
232////////////////////////////////////////////////////////////////////////////////
233
234class TBlinkTimer : public TTimer {
235private:
236 TGTextEntry *fTextEntry;
237public:
238 TBlinkTimer(TGTextEntry *t, Long_t ms) : TTimer(ms, kTRUE) { fTextEntry = t; }
239 Bool_t Notify();
240};
241
242////////////////////////////////////////////////////////////////////////////////
243/// Notify when timer times out and reset the timer.
244
245Bool_t TBlinkTimer::Notify()
246{
247 fTextEntry->HandleTimer(0);
248 Reset();
249 return kFALSE;
250}
251
252
254
255////////////////////////////////////////////////////////////////////////////////
256/// Create a text entry widget. It will adopt the TGTextBuffer object
257/// (i.e. the text buffer will be deleted by the text entry widget).
258
260 GContext_t norm, FontStruct_t font, UInt_t options,
261 ULong_t back) :
262 TGFrame(p, 1, 1, options | kOwnBackground, back)
263{
264 TGGC *normgc = fClient->GetResourcePool()->GetGCPool()->FindGC(norm);
265
266 fWidgetId = id;
267 fMsgWindow = p;
268 if (normgc)
269 fNormGC = *normgc;
270 else
272 fFontStruct = font;
273 fText = text;
274
275 Init();
276}
277
278////////////////////////////////////////////////////////////////////////////////
279/// Simple text entry constructor.
280
281TGTextEntry::TGTextEntry(const TGWindow *parent, const char *text, Int_t id) :
282 TGFrame(parent, 1, 1, kSunkenFrame | kDoubleBorder | kOwnBackground, fgWhitePixel)
283{
284 fWidgetId = id;
285 fMsgWindow = parent;
288 fText = new TGTextBuffer();
289 fText->AddText(0, !text && !parent ? GetName() : text);
290
291 Init(); // default initialization
292}
293
294////////////////////////////////////////////////////////////////////////////////
295/// Simple test entry constructor. Notice TString argument comes before the
296/// parent argument (to make this ctor different from the first one taking a
297/// const char*).
298
299TGTextEntry::TGTextEntry(const TString &contents, const TGWindow *parent, Int_t id) :
300 TGFrame(parent, 1, 1, kSunkenFrame | kDoubleBorder | kOwnBackground, fgWhitePixel)
301{
302 fWidgetId = id;
303 fMsgWindow = parent;
306 fText = new TGTextBuffer();
307 fText->AddText(0, contents.Data());
308
309 Init(); // default initialization
310}
311
312////////////////////////////////////////////////////////////////////////////////
313/// Delete a text entry widget.
314
316{
317 delete fText;
318 delete fCurBlink;
319 delete fTip;
320
321 if (this == gBlinkingEntry) gBlinkingEntry = 0;
322}
323
324////////////////////////////////////////////////////////////////////////////////
325/// Do default initialization.
326
328{
332
333 fOffset = 0;
334 // Set default maximum length to 4096. Can be changed with SetMaxLength()
335 fMaxLen = 4096;
337 fEdited = kFALSE;
341 fDefWidth = fDefHeight = 0;
342
343 int tw, max_ascent, max_descent;
344 tw = gVirtualX->TextWidth(fFontStruct, GetText(), fText->GetTextLength());
345
346 if (tw < 1) {
347 TString dummy('w', fText->GetBufferLength());
348 tw = gVirtualX->TextWidth(fFontStruct, dummy.Data(), dummy.Length());
349 }
350 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
351 Resize(tw + 8, max_ascent + max_descent + 7);
352
353 Int_t offset = IsFrameDrawn() ? 4 : 0;
354 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
355 offset = 2;
356 fCursorX = offset ;
359 fCurBlink = 0;
360 fTip = 0;
362
364
365 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
368
371
374 wattr.fBitGravity = 1; // NorthWestGravity
375 wattr.fWinGravity = 1;
376 gVirtualX->ChangeWindowAttributes(fId, &wattr);
377
381}
382
383////////////////////////////////////////////////////////////////////////////////
384/// Return the default / minimal size of the widget.
385
387{
388 UInt_t w = (GetOptions() & kFixedWidth) || (fDefWidth == 0) ? fWidth : fDefWidth;
390 return TGDimension(w, h);
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Set the default / minimal size of the widget.
395
397{
398 fDefWidth = w;
399 fDefHeight = h;
400}
401
402////////////////////////////////////////////////////////////////////////////////
403/// This signal is emitted when the return or enter key is pressed.
404
406{
409
410 Emit("ReturnPressed()");
411}
412
413////////////////////////////////////////////////////////////////////////////////
414/// This signal is emitted when `SHIFT` and `TAB` keys are pressed.
415
417{
418 Emit("ShiftTabPressed()");
419}
420
421////////////////////////////////////////////////////////////////////////////////
422/// This signal is emitted when the <TAB> key is pressed.
423
425{
428
429 Emit("TabPressed()");
430}
431
432////////////////////////////////////////////////////////////////////////////////
433/// This signal is emitted every time the text has changed.
434
435void TGTextEntry::TextChanged(const char *)
436{
439
440 Emit("TextChanged(char*)", GetText()); // The argument is the new text.
441}
442
443////////////////////////////////////////////////////////////////////////////////
444/// This signal is emitted when cursor is going out of left side.
445
447{
448 Emit("CursorOutLeft()");
449}
450
451////////////////////////////////////////////////////////////////////////////////
452/// This signal is emitted when cursor is going out of right side.
453
455{
456 Emit("CursorOutRight()");
457}
458
459////////////////////////////////////////////////////////////////////////////////
460/// This signal is emitted when cursor is going out of upper side.
461
463{
464 Emit("CursorOutUp()");
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// This signal is emitted when cursor is going out of bottom side.
469
471{
472 Emit("CursorOutDown()");
473}
474
475////////////////////////////////////////////////////////////////////////////////
476/// This signal is emitted when widget is double clicked.
477
479{
480 Emit("DoubleClicked()");
481}
482
483////////////////////////////////////////////////////////////////////////////////
484/// Returns the text that's currently displayed. This is normally
485/// the same as GetText(), but can be e.g.
486/// "*****" if EEchoMode is kPassword or
487/// "" if it is kNoEcho.
488
490{
491 TString res;
492
493 switch (GetEchoMode()) {
494 case kNormal:
495 res = GetText();
496 break;
497 case kNoEcho:
498 res = "";
499 break;
500 case kPassword:
501 res.Prepend('*', fText->GetTextLength()); // fill with '*'
502 break;
503 }
504 return res;
505}
506
507////////////////////////////////////////////////////////////////////////////////
508/// Set state of widget. If kTRUE=enabled, kFALSE=disabled.
509
511{
512 if (state) {
515 } else {
518 fCursorOn = kFALSE; // remove the cursor when disabling the widget
519 if (fCurBlink) fCurBlink->Remove();
520 }
521 fClient->NeedRedraw(this);
522}
523
524////////////////////////////////////////////////////////////////////////////////
525/// Returns the index of the character to whose left edge xcoord is closest.
526
528{
529 int tw, ix, up, down, len;
530
531 // check for out of boundaries first...
532 TString dt = GetDisplayText();
533 len = dt.Length();
534 tw = gVirtualX->TextWidth(fFontStruct, dt.Data(), len);
535 if (xcoord < 0) return 0;
536 if (xcoord > tw) return len; // len-1
537
538 // do a binary approximation
539 up = len; //-1
540 down = 0;
541 while (up-down > 1) {
542 ix = (up+down) >> 1;
543 tw = gVirtualX->TextWidth(fFontStruct, fText->GetString(), ix);
544 if (tw > xcoord)
545 up = ix;
546 else
547 down = ix;
548 if (tw == xcoord) break;
549 }
550 ix = down;
551
552 // safety check...
553 ix = TMath::Max(ix, 0);
554 ix = TMath::Min(ix, len); // len-1
555
556 return ix;
557}
558
559////////////////////////////////////////////////////////////////////////////////
560/// Sets the text entry to draw itself inside a two-pixel frame if
561/// enable is kTRUE, and to draw itself without any frame if enable is
562/// kFALSE. The default is kTRUE.
563
565{
566 if (fFrameDrawn == enable) return;
567
568 fFrameDrawn = enable;
569 fClient->NeedRedraw(this);
570 // ChangedBy("SetFrameDrawn"); // emit signal ChangedBy
571}
572
573////////////////////////////////////////////////////////////////////////////////
574/// Sets the alignment of the text entry.
575/// Possible values are kTextLeft(default), kTextRight, kTextCenterX.
576/// See also GetAlignment().
577
579{
580 if ((mode == kTextRight ||
581 mode == kTextCenterX ||
582 mode == kTextLeft)) {
583
586 wattr.fWinGravity = 1;
587
588 if (mode == kTextLeft) {
589 wattr.fBitGravity = 1;
590 } else if (mode == kTextRight) {
591 wattr.fBitGravity = 3;
592 } else {
593 wattr.fBitGravity = 5;
594 }
595
596 gVirtualX->ChangeWindowAttributes(fId, &wattr);
597
598 fAlignment = mode;
599 UpdateOffset();
600 fClient->NeedRedraw(this);
601 // ChangedBy("SetAlignment"); // emit signal ChangedBy
602 }
603}
604
605////////////////////////////////////////////////////////////////////////////////
606/// Sets the mode how characters are entered to the text entry.
607
609{
610 if (fInsertMode == mode) return;
611
612 fInsertMode = mode;
613 fClient->NeedRedraw(this);
614 // ChangedBy("SetInsertMode"); // emit signal ChangedBy
615}
616
617////////////////////////////////////////////////////////////////////////////////
618/// Sets text entry to text, clears the selection and moves
619/// the cursor to the end of the line.
620/// If necessary the text is truncated to fit MaxLength().
621/// See also GetText().
622
623void TGTextEntry::SetText(const char *text, Bool_t emit)
624{
625 TString oldText(GetText());
626
627 fText->Clear();
628 fText->AddText(0, text); // new text
629
630 Int_t dif = fText->GetTextLength() - fMaxLen;
631 if (dif > 0) fText->RemoveText(fMaxLen, dif); // truncate
632
633 End(kFALSE);
634 if (oldText != GetText()) {
635 if (emit)
636 TextChanged(); // emit signal
637 fClient->NeedRedraw(this);
638 }
639}
640
641////////////////////////////////////////////////////////////////////////////////
642/// Set the maximum length of the text in the editor. If the text is
643/// currently too long, it is chopped off at the limit. Any marked text will
644/// be unmarked. The cursor position is set to 0 and the first part of the
645/// string is shown.
646/// See also GetMaxLength().
647
649{
650 fMaxLen = maxlen < 0 ? 0 : maxlen; // safety check for maxlen < 0
651
652 Int_t dif = fText->GetTextLength() - fMaxLen;
653 if (dif > 0) fText->RemoveText(fMaxLen, dif); // truncate
654
656 Deselect();
657
658 // ChangedBy("SetMaxLength"); // emit signal ChangedBy
659}
660
661////////////////////////////////////////////////////////////////////////////////
662/// The echo modes available are:
663///
664/// <ul>
665/// <li> kNormal - display characters as they are entered. This is the default.
666/// <li> kNoEcho - do not display anything.
667/// <li> kPassword - display asterisks instead of the characters actually entered.
668/// </ul>
669///
670/// It is always possible to cut and paste any marked text; only the widget's own
671/// display is affected.
672/// See also GetEchoMode(), GetDisplayText().
673
675{
676 if (fEchoMode == mode) return;
677
678 Int_t offset = IsFrameDrawn() ? 4 : 0;
679 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
680 offset = 2;
681 fEchoMode = mode;
682 if (GetEchoMode() == kNoEcho) { fCursorX = offset; }
683 UpdateOffset();
684 fClient->NeedRedraw(this);
685 // ChangedBy("SetEchoMode"); // emit signal ChangedBy
686}
687
688////////////////////////////////////////////////////////////////////////////////
689/// Returns the text marked by the user (e.g. by clicking and
690/// dragging), or zero if no text is marked.
691/// See also HasMarkedText().
692
694{
695 Int_t minP = MinMark();
696 Int_t len = MaxMark() - minP;
697 TString res(GetText()+minP,len);
698 return res;
699}
700
701////////////////////////////////////////////////////////////////////////////////
702/// New character mark at position pos.
703/// See also SetCursorPosition().
704
706{
707 TString dt = GetDisplayText();
708 Int_t offset = IsFrameDrawn() ? 4 : 0;
709 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
710 offset = 2;
711 Int_t x = fOffset + offset;
712 Int_t len = dt.Length();
713
714 Int_t pos = newPos < len ? newPos : len;
715 fEndIX = pos < 0 ? 0 : pos;
716
719
720 if (fSelectionOn) {
721 fEndX = x + gVirtualX->TextWidth(fFontStruct, dt.Data() , fEndIX);
722 fStartX = x + gVirtualX->TextWidth(fFontStruct, dt.Data() , fStartIX);
723 }
724}
725
726////////////////////////////////////////////////////////////////////////////////
727/// Set the cursor position to newPos.
728/// See also NewMark().
729
731{
732 Int_t offset = IsFrameDrawn() ? 4 : 0;
733 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
734 offset = 2;
735 if (GetEchoMode() == kNoEcho) { fCursorX = offset; return; }
736
737 UpdateOffset();
738 TString dt = GetDisplayText();
739
740 Int_t x = fOffset + offset;
741 Int_t len = dt.Length();
742
743 Int_t pos;
744
745 if (newPos < len)
746 pos = newPos;
747 else {
748 pos = len;
749 if (newPos > len) CursorOutRight();
750 }
751
752 if (pos < 0) {
753 fCursorIX = 0;
755 } else
756 fCursorIX = pos;
757
758 fCursorX = x + gVirtualX->TextWidth(fFontStruct, dt.Data(), fCursorIX);
759
760 if (!fSelectionOn){
763 }
764}
765
766////////////////////////////////////////////////////////////////////////////////
767/// Marks the word nearest to cursor position.
768/// See also HandleDoubleClick().
769
771{
772 Int_t i = pos - 1;
773 while (i >= 0 && isprint(GetText()[i]) && !isspace(GetText()[i])) i--;
774 i++;
775 Int_t newStartIX = i;
776
777 i = pos;
778 while (isprint(GetText()[i]) && !isspace(GetText()[i])) i++;
779 while(isspace(GetText()[i])) i++;
780
782 fStartIX = newStartIX;
783 fEndIX = i;
784 NewMark(i);
785}
786
787////////////////////////////////////////////////////////////////////////////////
788/// Removes any currently selected text, inserts newText,
789/// sets it as the new contents of the text entry.
790
791void TGTextEntry::Insert(const char *newText)
792{
793 TString old(GetText());
794 TString t(newText);
795
796 if (t.IsNull()) return;
797
798 for (int i=0; i<t.Length(); i++) {
799 if (t[i] < ' ') t[i] = ' '; // unprintable/linefeed becomes space
800 }
801
802 Int_t minP = MinMark();
803 Int_t maxP = MaxMark();
804 Int_t cp = fCursorIX;
805
806 if (HasMarkedText()) {
807 fText->RemoveText(minP, maxP-minP);
808 cp = minP;
809 }
810
811 if (fInsertMode == kReplace) fText->RemoveText(cp,t.Length());
812 Int_t ncp = TMath::Min(cp+t.Length(), GetMaxLength());
813 fText->AddText(cp, t.Data());
815 if (dlen>0) fText->RemoveText(GetMaxLength(),dlen); // truncate
816
818 if (old != GetText()) TextChanged();
819}
820
821////////////////////////////////////////////////////////////////////////////////
822/// Moves the cursor rightwards one or more characters.
823/// See also CursorLeft().
824
826{
827 Int_t cp = fCursorIX + steps;
828
829 if (cp == fCursorIX) {
830 if (!mark) {
833 }
834 } else if (mark) {
836 NewMark(cp);
837 } else {
840 }
841}
842
843////////////////////////////////////////////////////////////////////////////////
844/// Moves the cursor leftwards one or more characters.
845/// See also CursorRight().
846
848{
849 CursorRight(mark, -steps);
850}
851
852////////////////////////////////////////////////////////////////////////////////
853/// Moves the cursor one word to the right. If mark is kTRUE, the text
854/// is marked.
855/// See also CursorWordBackward().
856
858{
859 Int_t i = fCursorIX;
860 while (i < (Int_t)fText->GetTextLength() && !isspace(GetText()[i])) ++i;
861 while (i < (Int_t)fText->GetTextLength() && isspace(GetText()[i])) ++i;
863}
864
865////////////////////////////////////////////////////////////////////////////////
866/// Moves the cursor one word to the left. If mark is kTRUE, the text
867/// is marked.
868/// See also CursorWordForward().
869
871{
872 Int_t i = fCursorIX;
873 while (i > 0 && isspace(GetText()[i-1])) --i;
874 while (i > 0 && !isspace(GetText()[i-1])) --i;
876}
877
878////////////////////////////////////////////////////////////////////////////////
879/// Deletes the character on the left side of the text cursor and moves the
880/// cursor one position to the left. If a text has been marked by the user
881/// (e.g. by clicking and dragging) the cursor will be put at the beginning
882/// of the marked text and the marked text will be removed.
883/// See also Del().
884
886{
887 if (HasMarkedText()) {
888 Del();
889 } else if (fCursorIX > 0) {
891 Del();
892 }
893}
894
895////////////////////////////////////////////////////////////////////////////////
896/// Deletes the character on the right side of the text cursor. If a text
897/// has been marked by the user (e.g. by clicking and dragging) the cursor
898/// will be put at the beginning of the marked text and the marked text will
899/// be removed.
900/// See also Backspace().
901
903{
904 Int_t minP = MinMark();
905 Int_t maxP = MaxMark();
906 Int_t offset = IsFrameDrawn() ? 4 : 0;
907 Int_t w = GetWidth() - 2 * offset; // subtract border twice
908
909 if (HasMarkedText()) {
910 fText->RemoveText(minP, maxP-minP);
912 TString dt = GetDisplayText();
913 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data(), dt.Length());
914 fOffset = w - textWidth - 1;
915 SetCursorPosition(minP);
916 } else if (fCursorIX != (Int_t)fText->GetTextLength()) {
919 TString dt = GetDisplayText();
920 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data(), dt.Length());
921 fOffset = w - textWidth - 1;
923 }
924 TextChanged();
925}
926
927////////////////////////////////////////////////////////////////////////////////
928/// Deletes all characters on the right side of the cursor.
929/// See also Del() Backspace().
930
932{
936 TextChanged(); // emit signal
937 }
938}
939
940////////////////////////////////////////////////////////////////////////////////
941/// Copies the marked text to the clipboard, if there is any and
942/// GetEchoMode() is kNormal.
943/// See also Cut() Paste().
944
946{
947 if (HasMarkedText() && GetEchoMode() == kNormal) {
949 *fgClipboardText = GetMarkedText(); // assign
950 gVirtualX->SetPrimarySelectionOwner(fId);
951 }
952}
953
954////////////////////////////////////////////////////////////////////////////////
955/// Inserts text at the cursor position, deleting any
956/// previous marked text.
957/// See also CopyText() Cut().
958
960{
961 if (gVirtualX->GetPrimarySelectionOwner() == kNone) {
962 // No primary selection, so use the buffer
964 } else {
965 gVirtualX->ConvertPrimarySelection(fId, fClipboard, 0);
966 }
967}
968
969////////////////////////////////////////////////////////////////////////////////
970/// Copies the marked text to the clipboard and deletes it, if there is any.
971/// See also CopyText() Paste().
972
974{
975 if (HasMarkedText()) {
976 CopyText();
977 Del();
978 }
979}
980
981////////////////////////////////////////////////////////////////////////////////
982/// Clears up the text entry.
983
985{
986 SetText("");
987}
988
989////////////////////////////////////////////////////////////////////////////////
990/// Moves the text cursor to the left end of the line. If mark is kTRUE text
991/// will be marked towards the first position, if not any marked text will
992/// be unmarked if the cursor is moved.
993/// See also End().
994
996{
997 fOffset = 0;
998 if (mark){
1001 UpdateOffset();
1002 NewMark(0);
1003 } else {
1006 }
1007}
1008
1009////////////////////////////////////////////////////////////////////////////////
1010/// Moves the text cursor to the right end of the line. If mark is kTRUE text
1011/// will be marked towards the last position, if not any marked text will
1012/// be unmarked if the cursor is moved.
1013/// See also Home().
1014
1016{
1017 TString dt = GetDisplayText();
1018 Int_t len = dt.Length();
1019
1020 fOffset = (Int_t)GetWidth() - gVirtualX->TextWidth(fFontStruct, dt.Data(), len);
1021 if (fOffset > 0) fOffset = 0;
1022
1023 if (mark){
1026 UpdateOffset();
1027 NewMark(len);
1028 } else {
1030 SetCursorPosition(len);
1031 }
1032}
1033
1034////////////////////////////////////////////////////////////////////////////////
1035/// Selects all text (i.e. marks it) and moves the cursor to the
1036/// end. Useful when a default value has been inserted. If the user
1037/// types before clicking on the widget the selected text will be
1038/// erased.
1039
1041{
1043 fStartIX = 0;
1045 DoRedraw();
1046}
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Deselects all text (i.e. removes marking) and leaves the cursor at the
1050/// current position.
1051
1053{
1056 DoRedraw();
1057}
1058
1059////////////////////////////////////////////////////////////////////////////////
1060/// Draw the border of the text entry widget.
1061
1063{
1066 if (gClient->GetStyle() < 2) {
1067 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
1068 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
1069 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
1070 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
1071
1072 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
1073 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
1074 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
1075 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
1076 break;
1077 }
1078 default:
1080 break;
1081 }
1082}
1083
1084////////////////////////////////////////////////////////////////////////////////
1085/// Draw the text entry widget.
1086
1088{
1089 Int_t x, y, max_ascent, max_descent, h;
1090 Int_t offset = IsFrameDrawn() ? 4 : 0;
1091 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1092 offset = 2;
1093 TString dt = GetDisplayText(); // text to be displayed
1094 Int_t len = dt.Length(); // length of displayed text
1095
1096 // TGFrame::DoRedraw() == drawing border twice
1097 Int_t border = IsFrameDrawn() ? fBorderWidth : 0;
1098
1099 gVirtualX->ClearArea(fId, border, border,
1100 fWidth - (border << 1), fHeight - (border << 1));
1101
1102 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
1103
1104 h = max_ascent + max_descent;
1105 y = (fHeight - h) >> 1 ;
1106 x = fOffset + offset;
1107
1108 if (fEchoMode == kNoEcho) {
1110 fCursorX = offset;
1111 }
1112
1113 if ((GetInsertMode() == kInsert) || (fEchoMode == kNoEcho)) {
1114 // line cursor
1115 if (fCursorOn) {
1116 gVirtualX->DrawLine(fId, GetBlackGC()(), fCursorX, y - 1,
1117 fCursorX, h + 2);
1118 }
1119 gVirtualX->DrawString(fId, fNormGC(), x, y + max_ascent, dt.Data(), len);
1120
1121 } else {
1122 // filled rectangle (block) cursor
1123 gVirtualX->DrawString(fId, fNormGC(), x, y + max_ascent, dt.Data(), len);
1124
1125 if (fCursorOn) {
1126 Int_t ind = fCursorIX < len-1 ? fCursorIX : len - 1;
1127 Int_t charWidth = ind < 0 || fCursorIX > len - 1 ? 4 :
1128 gVirtualX->TextWidth(fFontStruct, &dt[ind],1);
1129
1130 Int_t before = gVirtualX->TextWidth(fFontStruct, dt, fCursorIX) + x;
1131
1132 gVirtualX->FillRectangle(fId, fSelbackGC , before, y ,
1133 charWidth , h + 1);
1134
1135 if (fCursorIX < len)
1136 gVirtualX->DrawString(fId, fSelGC(), before, y + max_ascent, &dt[ind], 1);
1137 }
1138 }
1139
1140 if (fSelectionOn) {
1141 int xs, ws, ixs, iws;
1142
1143 xs = TMath::Min(fStartX, fEndX);
1145 ixs = TMath::Min(fStartIX, fEndIX);
1146 iws = TMath::Abs(fEndIX - fStartIX);
1147
1148 gVirtualX->FillRectangle(fId, fSelbackGC, xs, y, ws, h + 1);
1149
1150 gVirtualX->DrawString(fId, fSelGC(), xs, y + max_ascent,
1151 dt.Data() + ixs, iws);
1152 }
1153 if (IsFrameDrawn()) DrawBorder();
1154}
1155
1156////////////////////////////////////////////////////////////////////////////////
1157/// The key press event handler converts a key press to some line editor
1158/// action. Here are the default key bindings:
1159///
1160/// <ul>
1161/// <li><i> Left Arrow </i>
1162/// Move the cursor one character leftwards.
1163/// Scroll the text when cursor is out of frame.
1164/// <li><i> Right Arrow </i>
1165/// Move the cursor one character rightwards
1166/// Scroll the text when cursor is out of frame.
1167/// <li><i> Backspace </i>
1168/// Deletes the character on the left side of the text cursor and moves the
1169/// cursor one position to the left. If a text has been marked by the user
1170/// (e.g. by clicking and dragging) the cursor will be put at the beginning
1171/// of the marked text and the marked text will be removed.
1172/// <li><i> Home </i>
1173/// Moves the text cursor to the left end of the line. If mark is TRUE text
1174/// will be marked towards the first position, if not any marked text will
1175/// be unmarked if the cursor is moved.
1176/// <li><i> End </i>
1177/// Moves the text cursor to the right end of the line. If mark is TRUE text
1178/// will be marked towards the last position, if not any marked text will
1179/// be unmarked if the cursor is moved.
1180/// <li><i> Delete </i>
1181/// Deletes the character on the right side of the text cursor. If a text
1182/// has been marked by the user (e.g. by clicking and dragging) the cursor
1183/// will be put at the beginning of the marked text and the marked text will
1184/// be removed.
1185/// <li><i> Insert </i>
1186/// Switches character insert mode.
1187/// <li><i> Shift - Left Arrow </i>
1188/// Mark text one character leftwards
1189/// <li><i> Shift - Right Arrow </i>
1190/// Mark text one character rightwards
1191/// <li><i> Control - Left Arrow </i>
1192/// Move the cursor one word leftwards
1193/// <li><i> Control - Right Arrow </i>
1194/// Move the cursor one word rightwards.
1195/// <li><i> Control - Shift - Left Arrow </i>
1196/// Mark text one word leftwards
1197/// <li><i> Control - Shift - Right Arrow </i>
1198/// Mark text one word rightwards
1199/// <li><i> Control-A </i>
1200/// Move the cursor to the beginning of the line
1201/// <li><i> Control-B </i>
1202/// Move the cursor one character leftwards
1203/// <li><i> Control-C </i>
1204/// Copy the marked text to the clipboard.
1205/// <li><i> Control-D </i>
1206/// Delete the character to the right of the cursor
1207/// <li><i> Control-E </i>
1208/// Move the cursor to the end of the line
1209/// <li><i> Control-F </i>
1210/// Move the cursor one character rightwards
1211/// <li><i> Control-H </i>
1212/// Delete the character to the left of the cursor
1213/// <li><i> Control-K </i>
1214/// Delete marked text if any or delete all
1215/// characters to the right of the cursor
1216/// <li><i> Control-U </i>
1217/// Delete all characters on the line
1218/// <li><i> Control-V </i>
1219/// Paste the clipboard text into line edit.
1220/// <li><i> Control-X </i>
1221/// Cut the marked text, copy to clipboard.
1222/// <li><i> Control-Y </i>
1223/// Paste the clipboard text into line edit.
1224/// </ul>
1225///
1226/// All other keys with valid ASCII codes insert themselves into the line.
1227
1229{
1230 Int_t n;
1231 char tmp[10];
1232 UInt_t keysym;
1233
1234 if (fTip && event->fType == kGKeyPress) fTip->Hide();
1235
1236 if (!IsEnabled() || event->fType != kGKeyPress) return kTRUE;
1237
1238 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
1239 n = strlen(tmp);
1240 Int_t unknown = 0;
1241
1242 if ((EKeySym)keysym == kKey_Enter || (EKeySym)keysym == kKey_Return) {
1243
1244 ReturnPressed(); // emit signal
1245 if (!TestBit(kNotDeleted)) return kTRUE;
1247
1248 } else if (event->fState & kKeyShiftMask && (EKeySym)keysym == kKey_Backtab) {
1249 ShiftTabPressed(); // emit signal
1251 return kTRUE;
1252
1253 } else if ((EKeySym)keysym == kKey_Tab) {
1254
1255 TabPressed(); // emit signal
1257
1258 } else if (event->fState & kKeyControlMask) { // Cntrl key modifier pressed
1259 switch ((EKeySym)keysym & ~0x20) { // treat upper and lower the same
1260 case kKey_A:
1261 Home(event->fState & kKeyShiftMask);
1262 break;
1263 case kKey_B:
1265 break;
1266 case kKey_C:
1267 CopyText();
1268 break;
1269 case kKey_D:
1270 Del();
1271 break;
1272 case kKey_E:
1273 End(event->fState & kKeyShiftMask);
1274 break;
1275 case kKey_F:
1277 break;
1278 case kKey_H:
1279 Backspace();
1280 break;
1281 case kKey_K:
1282 HasMarkedText() ? Del() : Remove();
1283 break;
1284 case kKey_U:
1285 Home();
1286 Remove();
1287 break;
1288 case kKey_V:
1289 Paste();
1290 break;
1291 case kKey_X:
1292 Cut();
1293 break;
1294 case kKey_Y:
1295 Paste();
1296 break;
1297 case kKey_Right:
1299 break;
1300 case kKey_Left:
1302 break;
1303 default:
1304 unknown++;
1305 }
1306 } else if (n && keysym <127 && keysym >=32 && // printable keys
1307 (EKeySym)keysym != kKey_Delete &&
1308 (EKeySym)keysym != kKey_Backspace) {
1309
1310 Insert(tmp);
1312
1313 } else {
1314 switch ((EKeySym)keysym) {
1315 case kKey_Down:
1316 CursorOutDown();
1317 break;
1318 case kKey_Up:
1319 CursorOutUp();
1320 break;
1321 case kKey_Left:
1323 break;
1324 case kKey_Right:
1326 break;
1327 case kKey_Backspace:
1328 Backspace();
1329 break;
1330 case kKey_Home:
1331 Home(event->fState & kKeyShiftMask);
1332 break;
1333 case kKey_End:
1334 End(event->fState & kKeyShiftMask);
1335 break;
1336 case kKey_Delete:
1337 Del();
1338 break;
1339 case kKey_Insert: // switch on/off insert mode
1341 break;
1342 default:
1343 unknown++;
1344 }
1345 }
1346
1347 UpdateOffset();
1348 fClient->NeedRedraw(this);
1349
1350 return kTRUE;
1351}
1352
1353////////////////////////////////////////////////////////////////////////////////
1354/// Handle mouse button event in text entry widget.
1355
1357{
1358 if (fTip) fTip->Hide();
1359
1360 if (!IsEnabled()) return kTRUE;
1361
1362 if (event->fType == kButtonPress) {
1363 SetFocus();
1364 if (fEchoMode == kNoEcho) return kTRUE;
1365
1366 if (event->fCode == kButton1) {
1367 Int_t offset = IsFrameDrawn() ? 4 : 0;
1368 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1369 offset = 2;
1370 Int_t x = fOffset + offset;
1371 Int_t position = GetCharacterIndex(event->fX - x);
1373 SetCursorPosition(position);
1374 DoRedraw();
1375 } else if (event->fCode == kButton2) {
1376 if (gVirtualX->GetPrimarySelectionOwner() == kNone) {
1377 // No primary selection, so use the cut buffer
1379 } else {
1380 gVirtualX->ConvertPrimarySelection(fId, fClipboard, event->fTime);
1381 }
1382 }
1383 }
1384 if (event->fType == kButtonRelease)
1385 if (event->fCode == kButton1)
1386 CopyText();
1387
1388 return kTRUE;
1389}
1390
1391////////////////////////////////////////////////////////////////////////////////
1392/// Handle mouse crossing event.
1393
1395{
1396 if (event->fType == kEnterNotify) {
1397 if (fTip) fTip->Reset();
1398 } else {
1399 if (fTip) fTip->Hide();
1400 }
1401
1402 return kTRUE;
1403}
1404
1405////////////////////////////////////////////////////////////////////////////////
1406/// Handle mouse motion event in the text entry widget.
1407
1409{
1410 if (!IsEnabled() || (GetEchoMode() == kNoEcho)) return kTRUE;
1411
1412 Int_t offset = IsFrameDrawn() ? 4 : 0;
1413 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1414 offset = 2;
1415 Int_t x = fOffset + offset;
1416 Int_t position = GetCharacterIndex(event->fX - x); // + 1;
1418 NewMark(position);
1419 UpdateOffset();
1420 DoRedraw();
1421 return kTRUE;
1422}
1423
1424////////////////////////////////////////////////////////////////////////////////
1425/// Handle mouse double click event in the text entry widget.
1426
1428{
1429 if (!IsEnabled()) return kTRUE;
1430
1431 Int_t offset = IsFrameDrawn() ? 4 : 0;
1432 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1433 offset = 2;
1434 Int_t x = fOffset + offset ;
1435
1436 DoubleClicked();
1437 SetFocus();
1438 if (fEchoMode == kNoEcho) return kTRUE;
1439
1440 Int_t position = GetCharacterIndex(event->fX - x);
1441 MarkWord(position);
1442 return kTRUE;
1443}
1444
1445////////////////////////////////////////////////////////////////////////////////
1446/// Handles resize events for this widget.
1447
1449{
1451 Bool_t wasSelection = fSelectionOn;
1452 Int_t end = fEndIX, start = fStartIX;
1454 UpdateOffset();
1456 fSelectionOn = wasSelection;
1457 fEndIX = end;
1458 fStartIX = start;
1460 return kTRUE;
1461}
1462
1463////////////////////////////////////////////////////////////////////////////////
1464/// Handle focus change event in text entry widget.
1465
1467{
1468 if (!IsEnabled()) return kTRUE;
1469
1470 // check this when porting to Win32
1471 if (event->fType == kFocusIn) {
1472 fCursorOn = kTRUE;
1473 if (!fCurBlink) fCurBlink = new TBlinkTimer(this, 500);
1474 fCurBlink->Reset();
1475 gBlinkingEntry = this;
1477 } else {
1478 fCursorOn = kFALSE;
1479 // fSelectionOn = kFALSE; // "netscape location behavior"
1480 if (fCurBlink) fCurBlink->Remove();
1481 gBlinkingEntry = 0;
1482 }
1483 fClient->NeedRedraw(this);
1484 return kTRUE;
1485}
1486
1487////////////////////////////////////////////////////////////////////////////////
1488/// Handle text selection event.
1489
1491{
1492 PastePrimary((Window_t)event->fUser[0], (Atom_t)event->fUser[3], kTRUE);
1493 return kTRUE;
1494}
1495
1496////////////////////////////////////////////////////////////////////////////////
1497/// Handle selection clear event.
1498
1500{
1503 fClient->NeedRedraw(this);
1504 return kTRUE;
1505}
1506
1507////////////////////////////////////////////////////////////////////////////////
1508/// Handle request to send current clipboard contents to requestor window.
1509
1511{
1512 Event_t reply;
1513 char *buffer;
1514 Long_t len;
1515 Atom_t targets[2];
1516 Atom_t type;
1517
1518 reply.fType = kSelectionNotify;
1519 reply.fTime = event->fTime;
1520 reply.fUser[0] = event->fUser[0]; // requestor
1521 reply.fUser[1] = event->fUser[1]; // selection
1522 reply.fUser[2] = event->fUser[2]; // target
1523 reply.fUser[3] = event->fUser[3]; // property
1524
1525 targets[0] = gVirtualX->InternAtom("TARGETS", kFALSE);
1526 targets[1] = gVirtualX->InternAtom("XA_STRING", kFALSE);
1527
1528 if ((Atom_t)event->fUser[2] == targets[0]) {
1529 type = gVirtualX->InternAtom("XA_ATOM", kFALSE);
1530 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
1531 type, (UChar_t*) targets, (Int_t) 2);
1532
1533 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
1534 return kTRUE;
1535 }
1536
1537 len = 0;
1539 buffer = new char[len+1];
1540 if (fgClipboardText) strlcpy (buffer, fgClipboardText->Data(), len+1);
1541
1542 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
1543 (Atom_t) event->fUser[2], (UChar_t*) buffer,
1544 (Int_t) len);
1545 delete [] buffer;
1546
1547 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
1548
1549 return kTRUE;
1550}
1551
1552////////////////////////////////////////////////////////////////////////////////
1553/// Paste text from selection (either primary or cut buffer) into
1554/// text entry widget.
1555
1557{
1558 TString data;
1559 Int_t nchar;
1560
1561 if (!IsEnabled()) return;
1562
1563 gVirtualX->GetPasteBuffer(wid, property, data, nchar, del);
1564
1565 if (nchar) Insert(data.Data());
1566 fClient->NeedRedraw(this);
1567}
1568
1569////////////////////////////////////////////////////////////////////////////////
1570/// Handle cursor blink timer.
1571
1573{
1575 DoRedraw();
1576 return kTRUE;
1577}
1578
1579////////////////////////////////////////////////////////////////////////////////
1580/// Returns kTRUE if cursor is out of frame.
1581
1583{
1584 // fCursorX = fOffset + 4 + gVirtualX->TextWidth(fFontStruct,
1585 // GetDisplayText(), fCursorIX);
1586
1587 Int_t offset = IsFrameDrawn() ? 4 : 0;
1588 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1589 offset = 2;
1590 Int_t w = GetWidth();
1591 return ((fCursorX < offset) || (fCursorX > w-offset));
1592}
1593
1594////////////////////////////////////////////////////////////////////////////////
1595/// Shift position of cursor by one character.
1596
1598{
1599 if (GetEchoMode() == kNoEcho) return;
1600
1601 TString dt = GetDisplayText();
1602 Int_t len = dt.Length();
1603 Int_t ind = fCursorIX < len-1 ? fCursorIX : len-1;
1604 Int_t charWidth = ind < 0 ? 4 : gVirtualX->TextWidth(fFontStruct, &dt[ind],1);
1605 Int_t w = GetWidth();
1606 Int_t d;
1607 Int_t offset = IsFrameDrawn() ? 4 : 0;
1608 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1609 offset = 2;
1610
1611 if (fCursorX < offset) {
1612 fOffset += charWidth;
1613 fCursorX += charWidth;
1614 d = fCursorX;
1615
1616 if (d < offset){ // correction
1617 d -= offset;
1618 fOffset -= d;
1619 fCursorX -= d;
1620 charWidth += d;
1621 }
1622 } else if (fCursorX > w-offset) {
1623 fOffset -= charWidth;
1624 fCursorX -= charWidth;
1625 d = w - fCursorX;
1626
1627 if (d < offset) { // correction
1628 d -= offset;
1629 fOffset += d;
1630 fCursorX += d;
1631 charWidth += d;
1632 }
1633 }
1634}
1635
1636////////////////////////////////////////////////////////////////////////////////
1637/// Updates start text offset according GetAlignment() mode,
1638/// if cursor is out of frame => scroll the text.
1639/// See also SetAlignment() and ScrollByChar().
1640
1642{
1643 TString dt = GetDisplayText();
1644 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data() , dt.Length());
1645 Int_t offset = IsFrameDrawn() ? 4 : 0;
1646 if ((offset == 0) && fParent->InheritsFrom("TGComboBox"))
1647 offset = 2;
1648 Int_t w = GetWidth() - 2 * offset; // subtract border twice
1649
1650 if (fAlignment == kTextRight) fOffset = w - textWidth - 1;
1651 else if (fAlignment == kTextCenterX) fOffset = (w - textWidth)/2;
1652 else if (fAlignment == kTextLeft) fOffset = 0;
1653 if (textWidth > 0 && textWidth > w) { // may need to scroll.
1655 }
1656}
1657
1658////////////////////////////////////////////////////////////////////////////////
1659/// Set tool tip text associated with this text entry. The delay is in
1660/// milliseconds (minimum 250). To remove tool tip call method with
1661/// text = 0.
1662
1663void TGTextEntry::SetToolTipText(const char *text, Long_t delayms)
1664{
1665 if (fTip) {
1666 delete fTip;
1667 fTip = 0;
1668 }
1669
1670 if (text && strlen(text))
1671 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
1672}
1673
1674////////////////////////////////////////////////////////////////////////////////
1675/// Set focus to this text entry.
1676
1678{
1679 if (gBlinkingEntry && (gBlinkingEntry != this)) {
1680 gBlinkingEntry->fCurBlink->Remove();
1681 }
1682 RequestFocus();
1683}
1684
1685////////////////////////////////////////////////////////////////////////////////
1686/// Inserts text at position pos, clears the selection and moves
1687/// the cursor to the end of the line.
1688/// If necessary the text is truncated to fit MaxLength().
1689/// See also GetText(), SetText(), AppendText(), RemoveText().
1690
1691void TGTextEntry::InsertText(const char *text, Int_t pos)
1692{
1693 Int_t position = TMath::Min((Int_t)fText->GetTextLength(), pos);
1694 TString newText(GetText());
1695 newText.Insert(position, text);
1696 SetText(newText.Data());
1697}
1698
1699////////////////////////////////////////////////////////////////////////////////
1700/// Appends text to the end of text entry, clears the selection
1701/// and moves the cursor to the end of the line.
1702/// If necessary the text is truncated to fit MaxLength().
1703/// See also GetText(), InsertText(), SetText(), RemoveText().
1704
1706{
1708}
1709
1710////////////////////////////////////////////////////////////////////////////////
1711/// Removes text at the range, clears the selection and moves
1712/// the cursor to the end of the line.
1713/// See also GetText(), InsertText(), SetText(), AppendText().
1714
1716{
1717 Int_t pos = TMath::Min(start, end);
1718 Int_t len = TMath::Abs(end-start);
1719 TString newText(GetText());
1720 newText.Remove(pos, len);
1721 SetText(newText.Data());
1722}
1723
1724
1725////////////////////////////////////////////////////////////////////////////////
1726/// Changes text font.
1727/// If local is kTRUE font is changed locally.
1728
1730{
1731 if (font == fFontStruct) return;
1732
1733 FontH_t v = gVirtualX->GetFontHandle(font);
1734
1735 if (!v) return;
1736
1737 if (local) {
1738 TGGC *gc = new TGGC(fNormGC); // copy
1740 fNormGC = *gc;
1741 gc = new TGGC(fSelGC); // copy
1742 fSelGC = *gc;
1743 }
1744 fNormGC.SetFont(v);
1745 fSelGC.SetFont(v);
1746 fFontStruct = font;
1747 fClient->NeedRedraw(this);
1748}
1749
1750////////////////////////////////////////////////////////////////////////////////
1751/// Changes text font specified by name.
1752/// If local is kTRUE font is changed locally.
1753
1754void TGTextEntry::SetFont(const char *fontName, Bool_t local)
1755{
1756 TGFont *font = fClient->GetFont(fontName);
1757 if (font) {
1758 SetFont(font->GetFontStruct(), local);
1759 }
1760}
1761
1762////////////////////////////////////////////////////////////////////////////////
1763/// Changes text font specified by pointer to TGFont object.
1764/// If local is kTRUE font is changed locally.
1765
1767{
1768 if (font) {
1769 SetFont(font->GetFontStruct(), local);
1770 }
1771}
1772
1773////////////////////////////////////////////////////////////////////////////////
1774/// Changes text color.
1775/// If local is true color is changed locally.
1776
1778{
1779 if (local) {
1780 TGGC *gc = new TGGC(fNormGC); // copy
1782 fNormGC = *gc;
1783 }
1784
1785 fNormGC.SetForeground(color);
1786 fClient->NeedRedraw(this);
1787}
1788
1789////////////////////////////////////////////////////////////////////////////////
1790/// Changes text color.
1791/// If local is true color is changed locally.
1792
1794{
1795 if (color) {
1796 SetTextColor(color->GetPixel(), local);
1797 }
1798}
1799
1800////////////////////////////////////////////////////////////////////////////////
1801/// Return default font structure in use.
1802
1804{
1805 if (!fgDefaultFont)
1806 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
1807 return fgDefaultFont->GetFontStruct();
1808}
1809
1810////////////////////////////////////////////////////////////////////////////////
1811/// Return default graphics context.
1812
1814{
1815 if (!fgDefaultGC)
1816 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
1817 return *fgDefaultGC;
1818}
1819
1820////////////////////////////////////////////////////////////////////////////////
1821/// Return selection graphics context.
1822
1824{
1826 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
1827 return *fgDefaultSelectedGC;
1828}
1829
1830////////////////////////////////////////////////////////////////////////////////
1831/// Return graphics context for highlighted frame background.
1832
1834{
1836 fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
1838}
1839
1840////////////////////////////////////////////////////////////////////////////////
1841/// Save a text entry widget as a C++ statement(s) on output stream out.
1842
1843void TGTextEntry::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
1844{
1845 char quote = '"';
1846
1847 // font + GC
1848 option = GetName()+5; // unique digit id of the name
1849 TString parGC, parFont;
1850 // coverity[returned_null]
1851 // coverity[dereference]
1852 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
1853 // coverity[returned_null]
1854 // coverity[dereference]
1855 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
1856
1857 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC.GetGC())) {
1858 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
1859 if (ufont) {
1860 ufont->SavePrimitive(out, option);
1861 parFont.Form("ufont->GetFontStruct()");
1862 }
1863
1864 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC.GetGC());
1865 if (userGC) {
1866 userGC->SavePrimitive(out, option);
1867 parGC.Form("uGC->GetGC()");
1868 }
1869 }
1870
1871 if (fBackground != GetWhitePixel()) SaveUserColor(out, option);
1872
1873 out << " TGTextEntry *";
1874 out << GetName() << " = new TGTextEntry(" << fParent->GetName()
1875 << ", new TGTextBuffer(" << GetBuffer()->GetBufferLength() << ")";
1876
1877 if (fBackground == GetWhitePixel()) {
1878 if (GetOptions() == (kSunkenFrame | kDoubleBorder)) {
1880 if (fNormGC() == GetDefaultGC()()) {
1881 if (fWidgetId == -1) {
1882 out <<");" << std::endl;
1883 } else {
1884 out << "," << fWidgetId << ");" << std::endl;
1885 }
1886 } else {
1887 out << "," << fWidgetId << "," << parGC.Data() << ");" << std::endl;
1888 }
1889 } else {
1890 out << "," << fWidgetId << "," << parGC.Data() << "," << parFont.Data()
1891 <<");" << std::endl;
1892 }
1893 } else {
1894 out << "," << fWidgetId << "," << parGC.Data() << "," << parFont.Data()
1895 << "," << GetOptionString() << ");" << std::endl;
1896 }
1897 } else {
1898 out << "," << fWidgetId << "," << parGC.Data() << "," << parFont.Data()
1899 << "," << GetOptionString() << ",ucolor);" << std::endl;
1900 }
1901 if (option && strstr(option, "keep_names"))
1902 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
1903
1904 out << " " << GetName() << "->SetMaxLength(" << GetMaxLength() << ");" << std::endl;
1905
1906 out << " " << GetName() << "->SetAlignment(";
1907
1908 if (fAlignment == kTextLeft)
1909 out << "kTextLeft);" << std::endl;
1910
1911 if (fAlignment == kTextRight)
1912 out << "kTextRight);" << std::endl;
1913
1914 if (fAlignment == kTextCenterX)
1915 out << "kTextCenterX);" << std::endl;
1916
1917 out << " " << GetName() << "->SetText(" << quote << GetText() << quote
1918 << ");" << std::endl;
1919
1920 out << " " << GetName() << "->Resize("<< GetWidth() << "," << GetName()
1921 << "->GetDefaultHeight());" << std::endl;
1922
1923 if ((fDefWidth > 0) || (fDefHeight > 0)) {
1924 out << " " << GetName() << "->SetDefaultSize(";
1925 out << fDefWidth << "," << fDefHeight << ");" << std::endl;
1926 }
1927
1928 if (fTip) {
1929 TString tiptext = fTip->GetText()->GetString();
1930 tiptext.ReplaceAll("\n", "\\n");
1931 out << " ";
1932 out << GetName() << "->SetToolTipText(" << quote
1933 << tiptext << quote << ");" << std::endl;
1934 }
1935}
@ 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
const Mask_t kWAWinGravity
Definition GuiTypes.h:145
const Mask_t kAnyModifier
Definition GuiTypes.h:210
const Mask_t kKeyPressMask
Definition GuiTypes.h:159
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
Handle_t Atom_t
WM token.
Definition GuiTypes.h:37
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
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kButtonReleaseMask
Definition GuiTypes.h:162
const Mask_t kEnterWindowMask
Definition GuiTypes.h:167
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
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 Window_t
Window handle.
Definition GuiTypes.h:29
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
int Int_t
Definition RtypesCore.h:45
unsigned char UChar_t
Definition RtypesCore.h:38
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
#define gClient
Definition TGClient.h:166
TGTextEntry * gBlinkingEntry
ETextJustification
Definition TGWidget.h:32
@ kTextCenterX
Definition TGWidget.h:35
@ kTextLeft
Definition TGWidget.h:33
@ kTextRight
Definition TGWidget.h:34
@ kWidgetIsEnabled
Definition TGWidget.h:47
@ kWidgetWantFocus
Definition TGWidget.h:45
XFontStruct * id
Definition TGX11.cxx:109
int type
Definition TGX11.cxx:121
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
#define gVirtualX
Definition TVirtualX.h:338
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kTE_TEXTCHANGED
@ kTE_ENTER
@ kTE_TAB
@ kC_TEXTENTRY
The color creation and management class.
Definition TColor.h:19
ULong_t GetPixel() const
Return pixel value corresponding to this color.
Definition TColor.cxx:1437
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:913
TGFont * GetFont(const char *font, Bool_t fixedDefault=kTRUE)
Get a font from the font pool.
Definition TGClient.cxx:347
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
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save the used font as a C++ statement(s) on output stream out.
Definition TGFont.cxx:1871
void AddInput(UInt_t emask)
Add events specified in the emask to the events the frame should handle.
Definition TGFrame.cxx:324
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:720
UInt_t fOptions
Definition TGFrame.h:118
virtual Bool_t HandleConfigureNotify(Event_t *event)
This event is generated when the frame is resized.
Definition TGFrame.cxx:428
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition TGFrame.cxx:694
UInt_t fHeight
Definition TGFrame.h:112
virtual void DrawBorder()
Draw frame border.
Definition TGFrame.cxx:406
Int_t fBorderWidth
Definition TGFrame.h:117
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:740
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
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:668
virtual UInt_t GetOptions() const
Definition TGFrame.h:221
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2465
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:750
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
static Pixel_t fgWhitePixel
Definition TGFrame.h:127
UInt_t GetWidth() const
Definition TGFrame.h:248
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2438
Pixel_t fBackground
Definition TGFrame.h:119
static const TGGC & GetBckgndGC()
Get background color graphics context.
Definition TGFrame.cxx:760
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition TGGC.cxx:950
Definition TGGC.h:31
GContext_t GetGC() const
Definition TGGC.h:50
void SavePrimitive(std::ostream &out, Option_t *option="")
Save graphics context info as a C++ statement(s) on output stream out.
Definition TGGC.cxx:626
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
Definition TGObject.h:37
Handle_t GetId() const
Definition TGObject.h:47
Handle_t fId
Definition TGObject.h:36
Cursor_t GetTextCursor() const
Atom_t GetClipboard() const
TGGCPool * GetGCPool() const
const char * GetString() const
Definition TGString.h:40
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
virtual void SetState(Bool_t state)
Set state of widget. If kTRUE=enabled, kFALSE=disabled.
Int_t fOffset
Definition TGTextEntry.h:52
virtual void SetFocus()
Set focus to this text entry.
virtual Bool_t HandleKey(Event_t *event)
The key press event handler converts a key press to some line editor action.
void CursorLeft(Bool_t mark=kFALSE, Int_t steps=1)
Moves the cursor leftwards one or more characters.
Bool_t fFrameDrawn
Definition TGTextEntry.h:65
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
Definition TGTextEntry.h:49
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
Definition TGTextEntry.h:71
virtual void SetMaxLength(Int_t maxlen)
Set the maximum length of the text in the editor.
EEchoMode fEchoMode
Definition TGTextEntry.h:66
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
Definition TGTextEntry.h:47
virtual Bool_t HandleSelectionRequest(Event_t *event)
Handle request to send current clipboard contents to requestor window.
TGTextBuffer * fText
Definition TGTextEntry.h:46
TString GetDisplayText() const
Returns the text that's currently displayed.
UInt_t fDefWidth
Definition TGTextEntry.h:70
virtual ~TGTextEntry()
Delete a text entry widget.
virtual Bool_t HandleConfigureNotify(Event_t *event)
Handles resize events for this widget.
Bool_t fHasOwnFont
Definition TGTextEntry.h:69
void Deselect()
Deselects all text (i.e.
TBlinkTimer * fCurBlink
Definition TGTextEntry.h:61
void CopyText() const
Copies the marked text to the clipboard, if there is any and GetEchoMode() is kNormal.
virtual Bool_t HandleCrossing(Event_t *event)
Handle mouse crossing event.
static TString * fgClipboardText
Definition TGTextEntry.h:83
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
virtual void TabPressed()
This signal is emitted when the <TAB> key is pressed.
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.
virtual Bool_t HandleFocusChange(Event_t *event)
Handle focus change event in text entry widget.
void Del()
Deletes the character on the right side of the text cursor.
Bool_t fCursorOn
Definition TGTextEntry.h:55
static const TGFont * fgDefaultFont
Definition TGTextEntry.h:84
TGToolTip * fTip
Definition TGTextEntry.h:62
virtual Bool_t HandleTimer(TTimer *t)
Handle cursor blink timer.
void NewMark(Int_t pos)
New character mark at position pos.
Bool_t IsFrameDrawn() const
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion event in the text entry widget.
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 SavePrimitive(std::ostream &out, Option_t *option="")
Save a text entry widget as a C++ statement(s) on output stream out.
virtual void SelectAll()
Selects all text (i.e.
virtual void CursorOutRight()
This signal is emitted when cursor is going out of right side.
virtual Bool_t HandleSelectionClear(Event_t *event)
Handle selection clear event.
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
Definition TGTextEntry.h:67
virtual void SetAlignment(ETextJustification mode=kTextLeft)
Sets the alignment of the text entry.
Atom_t fClipboard
Definition TGTextEntry.h:60
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.
EInsertMode GetInsertMode() const
virtual void ShiftTabPressed()
This signal is emitted when SHIFT and TAB keys are pressed.
virtual void ReturnPressed()
This signal is emitted when the return or enter key is pressed.
static const TGGC * fgDefaultSelectedGC
Definition TGTextEntry.h:85
GContext_t fSelbackGC
Definition TGTextEntry.h:59
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
EEchoMode GetEchoMode() const
ETextJustification fAlignment
Definition TGTextEntry.h:68
Bool_t fSelectionOn
Definition TGTextEntry.h:51
virtual void SetTextColor(Pixel_t color, Bool_t local=kTRUE)
Changes text color.
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.
FontStruct_t fFontStruct
Definition TGTextEntry.h:56
virtual void CursorOutLeft()
This signal is emitted when cursor is going out of left side.
virtual TGDimension GetDefaultSize() const
Return the default / minimal size of the widget.
Int_t MaxMark() const
void Clear(Option_t *option="")
Clears up the text entry.
void Cut()
Copies the marked text to the clipboard and deletes it, if there is any.
static const TGGC * fgDefaultGC
Definition TGTextEntry.h:87
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.
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.
virtual Bool_t HandleSelection(Event_t *event)
Handle text selection event.
Bool_t fEdited
Definition TGTextEntry.h:64
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 Bool_t HandleDoubleClick(Event_t *event)
Handle mouse double click event in the text entry widget.
virtual Bool_t HandleButton(Event_t *event)
Handle mouse button event in text entry widget.
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
Definition TGTextEntry.h:53
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
Definition TGTextEntry.h:63
Int_t fCursorIX
Definition TGTextEntry.h:54
virtual void DoRedraw()
Draw the text entry widget.
virtual void DrawBorder()
Draw the border of the text entry widget.
void Remove()
Deletes all characters on the right side of the cursor.
static const TGGC * fgDefaultSelectedBackgroundGC
Definition TGTextEntry.h:86
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
Definition TGWidget.h:56
TString fCommand
Definition TGWidget.h:59
Int_t ClearFlags(Int_t flags)
Definition TGWidget.h:69
Int_t fWidgetFlags
Definition TGWidget.h:57
Int_t SetFlags(Int_t flags)
Definition TGWidget.h:68
const TGWindow * fMsgWindow
Definition TGWidget.h:58
Bool_t IsEnabled() const
Definition TGWidget.h:79
virtual void SetWindowName(const char *name=0)
Set window name.
Definition TGWindow.cxx:128
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:335
virtual void RequestFocus()
request focus
Definition TGWindow.cxx:231
const TGWindow * fParent
Definition TGWindow.h:36
@ kEditDisableHeight
Definition TGWindow.h:63
UInt_t fEditDisabled
Definition TGWindow.h:40
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:187
@ kNotDeleted
object has not been deleted
Definition TObject.h:78
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:445
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition TQObject.h:164
Basic string class.
Definition TString.h:136
Ssiz_t Length() const
Definition TString.h:410
TString & Insert(Ssiz_t pos, const char *s)
Definition TString.h:649
const char * Data() const
Definition TString.h:369
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:692
TString & Prepend(const char *cs)
Definition TString.h:661
Bool_t IsNull() const
Definition TString.h:407
TString & Remove(Ssiz_t pos)
Definition TString.h:673
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2309
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
virtual Bool_t Notify()
Notify when timer times out.
Definition TTimer.cxx:143
TText * text
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Short_t Max(Short_t a, Short_t b)
Definition TMathBase.h:212
Short_t Min(Short_t a, Short_t b)
Definition TMathBase.h:180
Short_t Abs(Short_t d)
Definition TMathBase.h:120
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
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
Attributes that can be used when creating or changing a window.
Definition GuiTypes.h:93
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:110
Int_t fWinGravity
one of the window gravity values
Definition GuiTypes.h:100
Int_t fBitGravity
one of bit gravity values
Definition GuiTypes.h:99
#define mark(osub)
Definition triangle.c:1206
void ws()
Definition ws.C:66