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