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