00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 #include "TGTextEntry.h"
00211 #include "TGResourcePool.h"
00212 #include "TGToolTip.h"
00213 #include "TSystem.h"
00214 #include "TTimer.h"
00215 #include "TColor.h"
00216 #include "KeySymbols.h"
00217 #include "Riostream.h"
00218 #include "TClass.h"
00219 #include "TGMsgBox.h"
00220
00221
00222 TString *TGTextEntry::fgClipboardText = 0;
00223 const TGFont *TGTextEntry::fgDefaultFont = 0;
00224 const TGGC *TGTextEntry::fgDefaultSelectedGC = 0;
00225 const TGGC *TGTextEntry::fgDefaultSelectedBackgroundGC = 0;
00226 const TGGC *TGTextEntry::fgDefaultGC = 0;
00227
00228 TGTextEntry *gBlinkingEntry = 0;
00229
00230
00231 class TBlinkTimer : public TTimer {
00232 private:
00233 TGTextEntry *fTextEntry;
00234 public:
00235 TBlinkTimer(TGTextEntry *t, Long_t ms) : TTimer(ms, kTRUE) { fTextEntry = t; }
00236 Bool_t Notify();
00237 };
00238
00239
00240 Bool_t TBlinkTimer::Notify()
00241 {
00242
00243
00244 fTextEntry->HandleTimer(0);
00245 Reset();
00246 return kFALSE;
00247 }
00248
00249
00250 ClassImp(TGTextEntry)
00251
00252
00253 TGTextEntry::TGTextEntry(const TGWindow *p, TGTextBuffer *text, Int_t id,
00254 GContext_t norm, FontStruct_t font, UInt_t options,
00255 ULong_t back) :
00256 TGFrame(p, 1, 1, options | kOwnBackground, back)
00257 {
00258
00259
00260
00261 TGGC *normgc = fClient->GetResourcePool()->GetGCPool()->FindGC(norm);
00262
00263 fWidgetId = id;
00264 fMsgWindow = p;
00265 if (normgc)
00266 fNormGC = *normgc;
00267 else
00268 fNormGC = GetDefaultGC();
00269 fFontStruct = font;
00270 fText = text;
00271
00272 Init();
00273 }
00274
00275
00276 TGTextEntry::TGTextEntry(const TGWindow *parent, const char *text, Int_t id) :
00277 TGFrame(parent, 1, 1, kSunkenFrame | kDoubleBorder | kOwnBackground, fgWhitePixel)
00278 {
00279
00280
00281 fWidgetId = id;
00282 fMsgWindow = parent;
00283 fNormGC = GetDefaultGC();
00284 fFontStruct = GetDefaultFontStruct();
00285 fText = new TGTextBuffer();
00286 fText->AddText(0, !text && !parent ? GetName() : text);
00287
00288 Init();
00289 }
00290
00291
00292 TGTextEntry::TGTextEntry(const TString &contents, const TGWindow *parent, Int_t id) :
00293 TGFrame(parent, 1, 1, kSunkenFrame | kDoubleBorder | kOwnBackground, fgWhitePixel)
00294 {
00295
00296
00297
00298
00299 fWidgetId = id;
00300 fMsgWindow = parent;
00301 fNormGC = GetDefaultGC();
00302 fFontStruct = GetDefaultFontStruct();
00303 fText = new TGTextBuffer();
00304 fText->AddText(0, contents.Data());
00305
00306 Init();
00307 }
00308
00309
00310 TGTextEntry::~TGTextEntry()
00311 {
00312
00313
00314 delete fText;
00315 delete fCurBlink;
00316 delete fTip;
00317
00318 if (this == gBlinkingEntry) gBlinkingEntry = 0;
00319 }
00320
00321
00322 void TGTextEntry::Init()
00323 {
00324
00325
00326 fWidgetFlags = kWidgetWantFocus | kWidgetIsEnabled;
00327 fSelGC = GetDefaultSelectedGC();
00328 fSelbackGC = GetDefaultSelectedBackgroundGC()();
00329
00330 fOffset = 0;
00331
00332 fMaxLen = 4096;
00333 fFrameDrawn = kTRUE;
00334 fEdited = kFALSE;
00335 fEchoMode = kNormal;
00336 fAlignment= kTextLeft;
00337 fInsertMode = kInsert;
00338 fDefWidth = fDefHeight = 0;
00339
00340 int tw, max_ascent, max_descent;
00341 tw = gVirtualX->TextWidth(fFontStruct, GetText(), fText->GetTextLength());
00342
00343 if (tw < 1) {
00344 TString dummy('w', fText->GetBufferLength());
00345 tw = gVirtualX->TextWidth(fFontStruct, dummy.Data(), dummy.Length());
00346 }
00347 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
00348 Resize(tw + 8, max_ascent + max_descent + 7);
00349
00350 Int_t offset = IsFrameDrawn() ? 4 : 0;
00351 fCursorX = offset ;
00352 fCursorIX = fStartIX = fEndIX = fOffset = 0;
00353 fSelectionOn = fCursorOn = kFALSE;
00354 fCurBlink = 0;
00355 fTip = 0;
00356 fClipboard = fClient->GetResourcePool()->GetClipboard();
00357
00358 gVirtualX->SetCursor(fId, fClient->GetResourcePool()->GetTextCursor());
00359
00360 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
00361 kButtonPressMask | kButtonReleaseMask |
00362 kButtonMotionMask, kNone, kNone);
00363
00364 AddInput(kKeyPressMask | kFocusChangeMask |
00365 kEnterWindowMask | kLeaveWindowMask);
00366
00367 SetWindowAttributes_t wattr;
00368 wattr.fMask = kWAWinGravity | kWABitGravity;
00369 wattr.fBitGravity = 1;
00370 wattr.fWinGravity = 1;
00371 gVirtualX->ChangeWindowAttributes(fId, &wattr);
00372
00373 SetWindowName();
00374 fHasOwnFont = kFALSE;
00375 fEditDisabled = kEditDisableHeight;
00376 }
00377
00378
00379 TGDimension TGTextEntry::GetDefaultSize() const
00380 {
00381
00382
00383 UInt_t w = (GetOptions() & kFixedWidth) || (fDefWidth == 0) ? fWidth : fDefWidth;
00384 UInt_t h = (GetOptions() & kFixedHeight) || (fDefHeight == 0) ? fHeight : fDefHeight;
00385 return TGDimension(w, h);
00386 }
00387
00388
00389 void TGTextEntry::SetDefaultSize(UInt_t w, UInt_t h)
00390 {
00391
00392
00393 fDefWidth = w;
00394 fDefHeight = h;
00395 }
00396
00397
00398 void TGTextEntry::ReturnPressed()
00399 {
00400
00401
00402 SendMessage(fMsgWindow, MK_MSG(kC_TEXTENTRY, kTE_ENTER), fWidgetId, 0);
00403 fClient->ProcessLine(fCommand, MK_MSG(kC_TEXTENTRY, kTE_ENTER),fWidgetId, 0);
00404
00405 Emit("ReturnPressed()");
00406 }
00407
00408
00409 void TGTextEntry::ShiftTabPressed()
00410 {
00411
00412
00413 Emit("ShiftTabPressed()");
00414 }
00415
00416
00417 void TGTextEntry::TabPressed()
00418 {
00419
00420
00421 SendMessage(fMsgWindow, MK_MSG(kC_TEXTENTRY, kTE_TAB), fWidgetId, 0);
00422 fClient->ProcessLine(fCommand, MK_MSG(kC_TEXTENTRY, kTE_TAB), fWidgetId, 0);
00423
00424 Emit("TabPressed()");
00425 }
00426
00427
00428 void TGTextEntry::TextChanged(const char *)
00429 {
00430
00431
00432 SendMessage(fMsgWindow, MK_MSG(kC_TEXTENTRY, kTE_TEXTCHANGED),fWidgetId, 0);
00433 fClient->ProcessLine(fCommand, MK_MSG(kC_TEXTENTRY, kTE_TEXTCHANGED),fWidgetId, 0);
00434
00435 Emit("TextChanged(char*)", GetText());
00436 }
00437
00438
00439 void TGTextEntry::CursorOutLeft()
00440 {
00441
00442
00443 Emit("CursorOutLeft()");
00444 }
00445
00446
00447 void TGTextEntry::CursorOutRight()
00448 {
00449
00450
00451 Emit("CursorOutRight()");
00452 }
00453
00454
00455 void TGTextEntry::CursorOutUp()
00456 {
00457
00458
00459 Emit("CursorOutUp()");
00460 }
00461
00462
00463 void TGTextEntry::CursorOutDown()
00464 {
00465
00466
00467 Emit("CursorOutDown()");
00468 }
00469
00470
00471 void TGTextEntry::DoubleClicked()
00472 {
00473
00474
00475 Emit("DoubleClicked()");
00476 }
00477
00478
00479 TString TGTextEntry::GetDisplayText() const
00480 {
00481
00482
00483
00484
00485
00486 TString res;
00487
00488 switch (GetEchoMode()) {
00489 case kNormal:
00490 res = GetText();
00491 break;
00492 case kNoEcho:
00493 res = "";
00494 break;
00495 case kPassword:
00496 res.Prepend('*', fText->GetTextLength());
00497 break;
00498 }
00499 return res;
00500 }
00501
00502
00503 void TGTextEntry::SetState(Bool_t state)
00504 {
00505
00506
00507 if (state) {
00508 SetFlags(kWidgetIsEnabled);
00509 SetBackgroundColor(fgWhitePixel);
00510 } else {
00511 ClearFlags(kWidgetIsEnabled);
00512 SetBackgroundColor(GetDefaultFrameBackground());
00513 fCursorOn = kFALSE;
00514 if (fCurBlink) fCurBlink->Remove();
00515 }
00516 fClient->NeedRedraw(this);
00517 }
00518
00519
00520 Int_t TGTextEntry::GetCharacterIndex(Int_t xcoord)
00521 {
00522
00523
00524 int tw, ix, up, down, len;
00525
00526
00527 TString dt = GetDisplayText();
00528 len = dt.Length();
00529 tw = gVirtualX->TextWidth(fFontStruct, dt.Data(), len);
00530 if (xcoord < 0) return 0;
00531 if (xcoord > tw) return len;
00532
00533
00534 up = len;
00535 down = 0;
00536 while (up-down > 1) {
00537 ix = (up+down) >> 1;
00538 tw = gVirtualX->TextWidth(fFontStruct, fText->GetString(), ix);
00539 if (tw > xcoord)
00540 up = ix;
00541 else
00542 down = ix;
00543 if (tw == xcoord) break;
00544 }
00545 ix = down;
00546
00547
00548 ix = TMath::Max(ix, 0);
00549 ix = TMath::Min(ix, len);
00550
00551 return ix;
00552 }
00553
00554
00555 void TGTextEntry::SetFrameDrawn(Bool_t enable)
00556 {
00557
00558
00559
00560
00561 if (fFrameDrawn == enable) return;
00562
00563 fFrameDrawn = enable;
00564 fClient->NeedRedraw(this);
00565
00566 }
00567
00568
00569 void TGTextEntry::SetAlignment(ETextJustification mode)
00570 {
00571
00572
00573
00574
00575 if ((mode == kTextRight ||
00576 mode == kTextCenterX ||
00577 mode == kTextLeft)) {
00578
00579 SetWindowAttributes_t wattr;
00580 wattr.fMask = kWAWinGravity | kWABitGravity;
00581 wattr.fWinGravity = 1;
00582
00583 if (mode == kTextLeft) {
00584 wattr.fBitGravity = 1;
00585 } else if (mode == kTextRight) {
00586 wattr.fBitGravity = 3;
00587 } else {
00588 wattr.fBitGravity = 5;
00589 }
00590
00591 gVirtualX->ChangeWindowAttributes(fId, &wattr);
00592
00593 fAlignment = mode;
00594 UpdateOffset();
00595 fClient->NeedRedraw(this);
00596
00597 }
00598 }
00599
00600
00601 void TGTextEntry::SetInsertMode(EInsertMode mode)
00602 {
00603
00604
00605 if (fInsertMode == mode) return;
00606
00607 fInsertMode = mode;
00608 fClient->NeedRedraw(this);
00609
00610 }
00611
00612
00613 void TGTextEntry::SetText(const char *text, Bool_t emit)
00614 {
00615
00616
00617
00618
00619
00620 TString oldText(GetText());
00621
00622 fText->Clear();
00623 fText->AddText(0, text);
00624
00625 Int_t dif = fText->GetTextLength() - fMaxLen;
00626 if (dif > 0) fText->RemoveText(fMaxLen, dif);
00627
00628 End(kFALSE);
00629 if (oldText != GetText()) {
00630 if (emit)
00631 TextChanged();
00632 fClient->NeedRedraw(this);
00633 }
00634 }
00635
00636
00637 void TGTextEntry::SetMaxLength(Int_t maxlen)
00638 {
00639
00640
00641
00642
00643
00644
00645 fMaxLen = maxlen < 0 ? 0 : maxlen;
00646
00647 Int_t dif = fText->GetTextLength() - fMaxLen;
00648 if (dif > 0) fText->RemoveText(fMaxLen, dif);
00649
00650 SetCursorPosition(0);
00651 Deselect();
00652
00653
00654 }
00655
00656
00657 void TGTextEntry::SetEchoMode(EEchoMode mode)
00658 {
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671 if (fEchoMode == mode) return;
00672
00673 Int_t offset = IsFrameDrawn() ? 4 : 0;
00674 fEchoMode = mode;
00675 if (GetEchoMode() == kNoEcho) { fCursorX = offset; }
00676 UpdateOffset();
00677 fClient->NeedRedraw(this);
00678
00679 }
00680
00681
00682 TString TGTextEntry::GetMarkedText() const
00683 {
00684
00685
00686
00687
00688 Int_t minP = MinMark();
00689 Int_t len = MaxMark() - minP;
00690 TString res(GetText()+minP,len);
00691 return res;
00692 }
00693
00694
00695 void TGTextEntry::NewMark(Int_t newPos)
00696 {
00697
00698
00699
00700 TString dt = GetDisplayText();
00701 Int_t offset = IsFrameDrawn() ? 4 : 0;
00702 Int_t x = fOffset + offset;
00703 Int_t len = dt.Length();
00704
00705 Int_t pos = newPos < len ? newPos : len;
00706 fEndIX = pos < 0 ? 0 : pos;
00707
00708 fSelectionOn = fSelectionOn && (fEndIX != fStartIX) && (GetEchoMode() != kNoEcho) ;
00709 SetCursorPosition(pos);
00710
00711 if (fSelectionOn) {
00712 fEndX = x + gVirtualX->TextWidth(fFontStruct, dt.Data() , fEndIX);
00713 fStartX = x + gVirtualX->TextWidth(fFontStruct, dt.Data() , fStartIX);
00714 }
00715 }
00716
00717
00718 void TGTextEntry::SetCursorPosition(Int_t newPos)
00719 {
00720
00721
00722
00723 Int_t offset = IsFrameDrawn() ? 4 : 0;
00724 if (GetEchoMode() == kNoEcho) { fCursorX = offset; return; }
00725
00726 UpdateOffset();
00727 TString dt = GetDisplayText();
00728
00729 Int_t x = fOffset + offset;
00730 Int_t len = dt.Length();
00731
00732 Int_t pos;
00733
00734 if (newPos < len)
00735 pos = newPos;
00736 else {
00737 pos = len;
00738 if (newPos > len) CursorOutRight();
00739 }
00740
00741 if (pos < 0) {
00742 fCursorIX = 0;
00743 CursorOutLeft();
00744 } else
00745 fCursorIX = pos;
00746
00747 fCursorX = x + gVirtualX->TextWidth(fFontStruct, dt.Data(), fCursorIX);
00748
00749 if (!fSelectionOn){
00750 fStartIX = fCursorIX;
00751 fStartX = fCursorX;
00752 }
00753 }
00754
00755
00756 void TGTextEntry::MarkWord(Int_t pos)
00757 {
00758
00759
00760
00761 Int_t i = pos - 1;
00762 while (i >= 0 && isprint(GetText()[i]) && !isspace(GetText()[i])) i--;
00763 i++;
00764 Int_t newStartIX = i;
00765
00766 i = pos;
00767 while (isprint(GetText()[i]) && !isspace(GetText()[i])) i++;
00768 while(isspace(GetText()[i])) i++;
00769
00770 fSelectionOn = kTRUE;
00771 fStartIX = newStartIX;
00772 fEndIX = i;
00773 NewMark(i);
00774 }
00775
00776
00777 void TGTextEntry::Insert(const char *newText)
00778 {
00779
00780
00781
00782 TString old(GetText());
00783 TString t(newText);
00784
00785 if (t.IsNull()) return;
00786
00787 for (int i=0; i<t.Length(); i++) {
00788 if (t[i] < ' ') t[i] = ' ';
00789 }
00790
00791 Int_t minP = MinMark();
00792 Int_t maxP = MaxMark();
00793 Int_t cp = fCursorIX;
00794
00795 if (HasMarkedText()) {
00796 fText->RemoveText(minP, maxP-minP);
00797 cp = minP;
00798 }
00799
00800 if (fInsertMode == kReplace) fText->RemoveText(cp,t.Length());
00801 Int_t ncp = TMath::Min(cp+t.Length(), GetMaxLength());
00802 fText->AddText(cp, t.Data());
00803 Int_t dlen = fText->GetTextLength()-GetMaxLength();
00804 if (dlen>0) fText->RemoveText(GetMaxLength(),dlen);
00805
00806 SetCursorPosition(ncp);
00807 if (old != GetText()) TextChanged();
00808 }
00809
00810
00811 void TGTextEntry::CursorRight(Bool_t mark, Int_t steps)
00812 {
00813
00814
00815
00816 Int_t cp = fCursorIX + steps;
00817
00818 if (cp == fCursorIX) {
00819 if (!mark) {
00820 fSelectionOn = kFALSE;
00821 fEndIX = fStartIX = fCursorIX;
00822 }
00823 } else if (mark) {
00824 fSelectionOn = kTRUE;
00825 NewMark(cp);
00826 } else {
00827 fSelectionOn = kFALSE;
00828 SetCursorPosition(cp);
00829 }
00830 }
00831
00832
00833 void TGTextEntry::CursorLeft(Bool_t mark, Int_t steps)
00834 {
00835
00836
00837
00838 CursorRight(mark, -steps);
00839 }
00840
00841
00842 void TGTextEntry::CursorWordForward(Bool_t mark)
00843 {
00844
00845
00846
00847
00848 Int_t i = fCursorIX;
00849 while (i < (Int_t)fText->GetTextLength() && !isspace(GetText()[i])) ++i;
00850 while (i < (Int_t)fText->GetTextLength() && isspace(GetText()[i])) ++i;
00851 CursorRight(mark, i - fCursorIX);
00852 }
00853
00854
00855 void TGTextEntry::CursorWordBackward(Bool_t mark)
00856 {
00857
00858
00859
00860
00861 Int_t i = fCursorIX;
00862 while (i > 0 && isspace(GetText()[i-1])) --i;
00863 while (i > 0 && !isspace(GetText()[i-1])) --i;
00864 CursorLeft(mark, fCursorIX - i);
00865 }
00866
00867
00868 void TGTextEntry::Backspace()
00869 {
00870
00871
00872
00873
00874
00875
00876 if (HasMarkedText()) {
00877 Del();
00878 } else if (fCursorIX > 0) {
00879 CursorLeft(kFALSE);
00880 Del();
00881 }
00882 }
00883
00884
00885 void TGTextEntry::Del()
00886 {
00887
00888
00889
00890
00891
00892
00893 Int_t minP = MinMark();
00894 Int_t maxP = MaxMark();
00895
00896 if (HasMarkedText()) {
00897 fText->RemoveText(minP, maxP-minP);
00898 fSelectionOn = kFALSE;
00899 SetCursorPosition(minP);
00900 } else if (fCursorIX != (Int_t)fText->GetTextLength()) {
00901 fSelectionOn = kFALSE;
00902 fText->RemoveText(fCursorIX , 1);
00903 SetCursorPosition(fCursorIX);
00904 }
00905 TextChanged();
00906 }
00907
00908
00909 void TGTextEntry::Remove()
00910 {
00911
00912
00913
00914 if (fCursorIX < (Int_t)fText->GetTextLength()) {
00915 fText->RemoveText(fCursorIX , fText->GetTextLength() - fCursorIX);
00916 SetCursorPosition(fCursorIX);
00917 TextChanged();
00918 }
00919 }
00920
00921
00922 void TGTextEntry::CopyText() const
00923 {
00924
00925
00926
00927
00928 if (HasMarkedText() && GetEchoMode() == kNormal) {
00929 if (!fgClipboardText) fgClipboardText = new TString();
00930 *fgClipboardText = GetMarkedText();
00931 gVirtualX->SetPrimarySelectionOwner(fId);
00932 }
00933 }
00934
00935
00936 void TGTextEntry::Paste()
00937 {
00938
00939
00940
00941
00942 if (gVirtualX->GetPrimarySelectionOwner() == kNone) {
00943
00944 if (fgClipboardText) Insert(fgClipboardText->Data());
00945 } else {
00946 gVirtualX->ConvertPrimarySelection(fId, fClipboard, 0);
00947 }
00948 }
00949
00950
00951 void TGTextEntry::Cut()
00952 {
00953
00954
00955
00956 if (HasMarkedText()) {
00957 CopyText();
00958 Del();
00959 }
00960 }
00961
00962
00963 void TGTextEntry::Clear(Option_t *)
00964 {
00965
00966
00967 SetText("");
00968 }
00969
00970
00971 void TGTextEntry::Home(Bool_t mark)
00972 {
00973
00974
00975
00976
00977
00978 fOffset = 0;
00979 if (mark){
00980 fSelectionOn = kTRUE;
00981 fStartIX = fCursorIX;
00982 NewMark(0);
00983 } else {
00984 fSelectionOn = kFALSE;
00985 SetCursorPosition(0);
00986 }
00987 }
00988
00989
00990 void TGTextEntry::End(Bool_t mark)
00991 {
00992
00993
00994
00995
00996
00997 TString dt = GetDisplayText();
00998 Int_t len = dt.Length();
00999
01000 fOffset = (Int_t)GetWidth() - gVirtualX->TextWidth(fFontStruct, dt.Data(), len);
01001 if (fOffset > 0) fOffset = 0;
01002
01003 if (mark){
01004 fSelectionOn = kTRUE;
01005 fStartIX = fCursorIX;
01006 NewMark(len);
01007 } else {
01008 fSelectionOn = kFALSE;
01009 SetCursorPosition(len);
01010 }
01011 }
01012
01013
01014 void TGTextEntry::SelectAll()
01015 {
01016
01017
01018
01019
01020
01021 fSelectionOn = kTRUE;
01022 fStartIX = 0;
01023 NewMark(fText->GetTextLength());
01024 DoRedraw();
01025 }
01026
01027
01028 void TGTextEntry::Deselect()
01029 {
01030
01031
01032
01033 fSelectionOn = kFALSE;
01034 fEndIX = fStartIX = fCursorIX;
01035 DoRedraw();
01036 }
01037
01038
01039 void TGTextEntry::DrawBorder()
01040 {
01041
01042
01043 switch (fOptions & (kSunkenFrame | kRaisedFrame | kDoubleBorder)) {
01044 case kSunkenFrame | kDoubleBorder:
01045 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, fWidth-2, 0);
01046 gVirtualX->DrawLine(fId, GetShadowGC()(), 0, 0, 0, fHeight-2);
01047 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, fWidth-3, 1);
01048 gVirtualX->DrawLine(fId, GetBlackGC()(), 1, 1, 1, fHeight-3);
01049
01050 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, fWidth-1, fHeight-1);
01051 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, 0);
01052 gVirtualX->DrawLine(fId, GetBckgndGC()(), 1, fHeight-2, fWidth-2, fHeight-2);
01053 gVirtualX->DrawLine(fId, GetBckgndGC()(), fWidth-2, 1, fWidth-2, fHeight-2);
01054 break;
01055
01056 default:
01057 TGFrame::DrawBorder();
01058 break;
01059 }
01060 }
01061
01062
01063 void TGTextEntry::DoRedraw()
01064 {
01065
01066
01067 Int_t x, y, max_ascent, max_descent, h;
01068 Int_t offset = IsFrameDrawn() ? 4 : 0;
01069 TString dt = GetDisplayText();
01070 Int_t len = dt.Length();
01071
01072
01073 Int_t border = IsFrameDrawn() ? fBorderWidth : 0;
01074
01075 gVirtualX->ClearArea(fId, border, border,
01076 fWidth - (border << 1), fHeight - (border << 1));
01077
01078 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
01079
01080 h = max_ascent + max_descent;
01081 y = (fHeight - h) >> 1 ;
01082 x = fOffset + offset;
01083
01084 if (fEchoMode == kNoEcho) {
01085 fSelectionOn = kFALSE;
01086 fCursorX = offset;
01087 }
01088
01089 if ((GetInsertMode() == kInsert) || (fEchoMode == kNoEcho)) {
01090
01091 if (fCursorOn) {
01092 gVirtualX->DrawLine(fId, GetBlackGC()(), fCursorX, y - 1,
01093 fCursorX, h + 2);
01094 }
01095 gVirtualX->DrawString(fId, fNormGC(), x, y + max_ascent, dt.Data(), len);
01096
01097 } else {
01098
01099 gVirtualX->DrawString(fId, fNormGC(), x, y + max_ascent, dt.Data(), len);
01100
01101 if (fCursorOn) {
01102 Int_t ind = fCursorIX < len-1 ? fCursorIX : len - 1;
01103 Int_t charWidth = ind < 0 || fCursorIX > len - 1 ? 4 :
01104 gVirtualX->TextWidth(fFontStruct, &dt[ind],1);
01105
01106 Int_t before = gVirtualX->TextWidth(fFontStruct, dt, fCursorIX) + x;
01107
01108 gVirtualX->FillRectangle(fId, fSelbackGC , before, y ,
01109 charWidth , h + 1);
01110
01111 if (fCursorIX < len)
01112 gVirtualX->DrawString(fId, fSelGC(), before, y + max_ascent, &dt[ind], 1);
01113 }
01114 }
01115
01116 if (fSelectionOn) {
01117 int xs, ws, ixs, iws;
01118
01119 xs = TMath::Min(fStartX, fEndX);
01120 ws = TMath::Abs(fEndX - fStartX);
01121 ixs = TMath::Min(fStartIX, fEndIX);
01122 iws = TMath::Abs(fEndIX - fStartIX);
01123
01124 gVirtualX->FillRectangle(fId, fSelbackGC, xs, y, ws, h + 1);
01125
01126 gVirtualX->DrawString(fId, fSelGC(), xs, y + max_ascent,
01127 dt.Data() + ixs, iws);
01128 }
01129 if (IsFrameDrawn()) DrawBorder();
01130 }
01131
01132
01133 Bool_t TGTextEntry::HandleKey(Event_t* event)
01134 {
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206 Int_t n;
01207 char tmp[10];
01208 UInt_t keysym;
01209
01210 if (fTip && event->fType == kGKeyPress) fTip->Hide();
01211
01212 if (!IsEnabled() || event->fType != kGKeyPress) return kTRUE;
01213
01214 gVirtualX->LookupString(event, tmp, sizeof(tmp), keysym);
01215 n = strlen(tmp);
01216 Int_t unknown = 0;
01217
01218 if ((EKeySym)keysym == kKey_Enter || (EKeySym)keysym == kKey_Return) {
01219
01220 ReturnPressed();
01221 if (!TestBit(kNotDeleted)) return kTRUE;
01222 fSelectionOn = kFALSE;
01223
01224 } else if (event->fState & kKeyShiftMask && (EKeySym)keysym == kKey_Backtab) {
01225 ShiftTabPressed();
01226 fSelectionOn = kFALSE;
01227 return kTRUE;
01228
01229 } else if ((EKeySym)keysym == kKey_Tab) {
01230
01231 TabPressed();
01232 fSelectionOn = kFALSE;
01233
01234 } else if (event->fState & kKeyControlMask) {
01235 switch ((EKeySym)keysym & ~0x20) {
01236 case kKey_A:
01237 Home(event->fState & kKeyShiftMask);
01238 break;
01239 case kKey_B:
01240 CursorLeft(event->fState & kKeyShiftMask);
01241 break;
01242 case kKey_C:
01243 CopyText();
01244 break;
01245 case kKey_D:
01246 Del();
01247 break;
01248 case kKey_E:
01249 End(event->fState & kKeyShiftMask);
01250 break;
01251 case kKey_F:
01252 CursorRight(event->fState & kKeyShiftMask);
01253 break;
01254 case kKey_H:
01255 Backspace();
01256 break;
01257 case kKey_K:
01258 HasMarkedText() ? Del() : Remove();
01259 break;
01260 case kKey_U:
01261 Home();
01262 Remove();
01263 break;
01264 case kKey_V:
01265 Paste();
01266 break;
01267 case kKey_X:
01268 Cut();
01269 break;
01270 case kKey_Y:
01271 Paste();
01272 break;
01273 case kKey_Right:
01274 CursorWordForward(event->fState & kKeyShiftMask);
01275 break;
01276 case kKey_Left:
01277 CursorWordBackward(event->fState & kKeyShiftMask);
01278 break;
01279 default:
01280 unknown++;
01281 }
01282 } else if (n && keysym <127 && keysym >=32 &&
01283 (EKeySym)keysym != kKey_Delete &&
01284 (EKeySym)keysym != kKey_Backspace) {
01285
01286 Insert(tmp);
01287 fSelectionOn = kFALSE;
01288
01289 } else {
01290 switch ((EKeySym)keysym) {
01291 case kKey_Down:
01292 CursorOutDown();
01293 break;
01294 case kKey_Up:
01295 CursorOutUp();
01296 break;
01297 case kKey_Left:
01298 CursorLeft(event->fState & kKeyShiftMask);
01299 break;
01300 case kKey_Right:
01301 CursorRight(event->fState & kKeyShiftMask);
01302 break;
01303 case kKey_Backspace:
01304 Backspace();
01305 break;
01306 case kKey_Home:
01307 Home(event->fState & kKeyShiftMask);
01308 break;
01309 case kKey_End:
01310 End(event->fState & kKeyShiftMask);
01311 break;
01312 case kKey_Delete:
01313 Del();
01314 break;
01315 case kKey_Insert:
01316 SetInsertMode(GetInsertMode() == kInsert ? kReplace : kInsert);
01317 break;
01318 default:
01319 unknown++;
01320 }
01321 }
01322
01323 UpdateOffset();
01324 fClient->NeedRedraw(this);
01325
01326 return kTRUE;
01327 }
01328
01329
01330 Bool_t TGTextEntry::HandleButton(Event_t *event)
01331 {
01332
01333
01334 if (fTip) fTip->Hide();
01335
01336 if (!IsEnabled()) return kTRUE;
01337
01338 if (event->fType == kButtonPress) {
01339 SetFocus();
01340 if (fEchoMode == kNoEcho) return kTRUE;
01341
01342 if (event->fCode == kButton1) {
01343 Int_t offset = IsFrameDrawn() ? 4 : 0;
01344 Int_t x = fOffset + offset;
01345 Int_t position = GetCharacterIndex(event->fX - x);
01346 fSelectionOn = kFALSE;
01347 SetCursorPosition(position);
01348 DoRedraw();
01349 } else if (event->fCode == kButton2) {
01350 if (gVirtualX->GetPrimarySelectionOwner() == kNone) {
01351
01352 PastePrimary(fClient->GetDefaultRoot()->GetId(), kCutBuffer, kFALSE);
01353 } else {
01354 gVirtualX->ConvertPrimarySelection(fId, fClipboard, event->fTime);
01355 }
01356 }
01357 }
01358 if (event->fType == kButtonRelease)
01359 if (event->fCode == kButton1)
01360 CopyText();
01361
01362 return kTRUE;
01363 }
01364
01365
01366 Bool_t TGTextEntry::HandleCrossing(Event_t *event)
01367 {
01368
01369
01370 if (event->fType == kEnterNotify) {
01371 if (fTip) fTip->Reset();
01372 } else {
01373 if (fTip) fTip->Hide();
01374 }
01375
01376 return kTRUE;
01377 }
01378
01379
01380 Bool_t TGTextEntry::HandleMotion(Event_t *event)
01381 {
01382
01383
01384 if (!IsEnabled() || (GetEchoMode() == kNoEcho)) return kTRUE;
01385
01386 Int_t offset = IsFrameDrawn() ? 4 : 0;
01387 Int_t x = fOffset + offset;
01388 Int_t position = GetCharacterIndex(event->fX - x);
01389 fSelectionOn = kTRUE;
01390 NewMark(position);
01391 UpdateOffset();
01392 DoRedraw();
01393 return kTRUE;
01394 }
01395
01396
01397 Bool_t TGTextEntry::HandleDoubleClick(Event_t *event)
01398 {
01399
01400
01401 if (!IsEnabled()) return kTRUE;
01402
01403 Int_t offset = IsFrameDrawn() ? 4 : 0;
01404 Int_t x = fOffset + offset ;
01405
01406 DoubleClicked();
01407 SetFocus();
01408 if (fEchoMode == kNoEcho) return kTRUE;
01409
01410 Int_t position = GetCharacterIndex(event->fX - x);
01411 MarkWord(position);
01412 return kTRUE;
01413 }
01414
01415
01416 Bool_t TGTextEntry::HandleConfigureNotify(Event_t* event)
01417 {
01418
01419
01420 TGFrame::HandleConfigureNotify(event);
01421 UpdateOffset();
01422 return kTRUE;
01423 }
01424
01425
01426 Bool_t TGTextEntry::HandleFocusChange(Event_t *event)
01427 {
01428
01429
01430 if (!IsEnabled()) return kTRUE;
01431
01432
01433 if (event->fType == kFocusIn) {
01434 fCursorOn = kTRUE;
01435 if (!fCurBlink) fCurBlink = new TBlinkTimer(this, 500);
01436 fCurBlink->Reset();
01437 gBlinkingEntry = this;
01438 gSystem->AddTimer(fCurBlink);
01439 } else {
01440 fCursorOn = kFALSE;
01441
01442 if (fCurBlink) fCurBlink->Remove();
01443 gBlinkingEntry = 0;
01444 }
01445 fClient->NeedRedraw(this);
01446 return kTRUE;
01447 }
01448
01449
01450 Bool_t TGTextEntry::HandleSelection(Event_t *event)
01451 {
01452
01453
01454 PastePrimary((Window_t)event->fUser[0], (Atom_t)event->fUser[3], kTRUE);
01455 return kTRUE;
01456 }
01457
01458
01459 Bool_t TGTextEntry::HandleSelectionClear(Event_t * )
01460 {
01461
01462
01463 fSelectionOn = kFALSE;
01464 fEndIX = fStartIX = fCursorIX;
01465 fClient->NeedRedraw(this);
01466 return kTRUE;
01467 }
01468
01469
01470 Bool_t TGTextEntry::HandleSelectionRequest(Event_t *event)
01471 {
01472
01473
01474 Event_t reply;
01475 char *buffer;
01476 Long_t len;
01477 Atom_t targets[2];
01478 Atom_t type;
01479
01480 reply.fType = kSelectionNotify;
01481 reply.fTime = event->fTime;
01482 reply.fUser[0] = event->fUser[0];
01483 reply.fUser[1] = event->fUser[1];
01484 reply.fUser[2] = event->fUser[2];
01485 reply.fUser[3] = event->fUser[3];
01486
01487 targets[0] = gVirtualX->InternAtom("TARGETS", kFALSE);
01488 targets[1] = gVirtualX->InternAtom("XA_STRING", kFALSE);
01489
01490 if ((Atom_t)event->fUser[2] == targets[0]) {
01491 type = gVirtualX->InternAtom("XA_ATOM", kFALSE);
01492 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
01493 type, (UChar_t*) targets, (Int_t) 2);
01494
01495 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
01496 return kTRUE;
01497 }
01498
01499 len = 0;
01500 if (fgClipboardText) len = fgClipboardText->Length();
01501 buffer = new char[len+1];
01502 if (fgClipboardText) strlcpy (buffer, fgClipboardText->Data(), len+1);
01503
01504 gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
01505 (Atom_t) event->fUser[2], (UChar_t*) buffer,
01506 (Int_t) len);
01507 delete [] buffer;
01508
01509 gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
01510
01511 return kTRUE;
01512 }
01513
01514
01515 void TGTextEntry::PastePrimary(Window_t wid, Atom_t property, Bool_t del)
01516 {
01517
01518
01519
01520 TString data;
01521 Int_t nchar;
01522
01523 if (!IsEnabled()) return;
01524
01525 gVirtualX->GetPasteBuffer(wid, property, data, nchar, del);
01526
01527 if (nchar) Insert(data.Data());
01528 fClient->NeedRedraw(this);
01529 }
01530
01531
01532 Bool_t TGTextEntry::HandleTimer(TTimer *)
01533 {
01534
01535
01536 fCursorOn = !fCursorOn;
01537 DoRedraw();
01538 return kTRUE;
01539 }
01540
01541
01542 Bool_t TGTextEntry::IsCursorOutOfFrame()
01543 {
01544
01545
01546
01547
01548
01549 Int_t offset = IsFrameDrawn() ? 4 : 0;
01550 Int_t w = GetWidth();
01551 return ((fCursorX < offset) || (fCursorX > w-offset));
01552 }
01553
01554
01555 void TGTextEntry::ScrollByChar()
01556 {
01557
01558
01559 if (GetEchoMode() == kNoEcho) return;
01560
01561 TString dt = GetDisplayText();
01562 Int_t len = dt.Length();
01563 Int_t ind = fCursorIX < len-1 ? fCursorIX : len-1;
01564 Int_t charWidth = ind < 0 ? 4 : gVirtualX->TextWidth(fFontStruct, &dt[ind],1);
01565 Int_t w = GetWidth();
01566 Int_t d;
01567 Int_t offset = IsFrameDrawn() ? 4 : 0;
01568
01569 if (fCursorX < offset) {
01570 fOffset += charWidth;
01571 fCursorX += charWidth;
01572 d = fCursorX;
01573
01574 if (d < offset){
01575 d -= offset;
01576 fOffset -= d;
01577 fCursorX -= d;
01578 charWidth += d;
01579 }
01580 } else if (fCursorX > w-offset) {
01581 fOffset -= charWidth;
01582 fCursorX -= charWidth;
01583 d = w - fCursorX;
01584
01585 if (d < offset) {
01586 d -= offset;
01587 fOffset += d;
01588 fCursorX += d;
01589 charWidth += d;
01590 }
01591 }
01592 }
01593
01594
01595 void TGTextEntry::UpdateOffset()
01596 {
01597
01598
01599
01600
01601 TString dt = GetDisplayText();
01602 Int_t textWidth = gVirtualX->TextWidth(fFontStruct, dt.Data() , dt.Length());
01603 Int_t offset = IsFrameDrawn() ? 4 : 0;
01604 Int_t w = GetWidth() - 2 * offset;
01605
01606 if (textWidth > 0 && textWidth > w) {
01607 if (IsCursorOutOfFrame()) ScrollByChar();
01608 }
01609 else if (fAlignment == kTextRight) fOffset = w - textWidth - 1;
01610 else if (fAlignment == kTextCenterX) fOffset = (w - textWidth)/2;
01611 else if (fAlignment == kTextLeft) fOffset = 0;
01612 }
01613
01614
01615 void TGTextEntry::SetToolTipText(const char *text, Long_t delayms)
01616 {
01617
01618
01619
01620
01621 if (fTip) {
01622 delete fTip;
01623 fTip = 0;
01624 }
01625
01626 if (text && strlen(text))
01627 fTip = new TGToolTip(fClient->GetDefaultRoot(), this, text, delayms);
01628 }
01629
01630
01631 void TGTextEntry::SetFocus()
01632 {
01633
01634
01635 if (gBlinkingEntry && (gBlinkingEntry != this)) {
01636 gBlinkingEntry->fCurBlink->Remove();
01637 }
01638 RequestFocus();
01639 }
01640
01641
01642 void TGTextEntry::InsertText(const char *text, Int_t pos)
01643 {
01644
01645
01646
01647
01648
01649 Int_t position = TMath::Min((Int_t)fText->GetTextLength(), pos);
01650 TString newText(GetText());
01651 newText.Insert(position, text);
01652 SetText(newText.Data());
01653 }
01654
01655
01656 void TGTextEntry::AppendText(const char *text)
01657 {
01658
01659
01660
01661
01662
01663 InsertText(text, fText->GetTextLength());
01664 }
01665
01666
01667 void TGTextEntry::RemoveText(Int_t start, Int_t end)
01668 {
01669
01670
01671
01672
01673 Int_t pos = TMath::Min(start, end);
01674 Int_t len = TMath::Abs(end-start);
01675 TString newText(GetText());
01676 newText.Remove(pos, len);
01677 SetText(newText.Data());
01678 }
01679
01680
01681
01682 void TGTextEntry::SetFont(FontStruct_t font, Bool_t local)
01683 {
01684
01685
01686
01687 if (font == fFontStruct) return;
01688
01689 FontH_t v = gVirtualX->GetFontHandle(font);
01690
01691 if (!v) return;
01692
01693 if (local) {
01694 TGGC *gc = new TGGC(fNormGC);
01695 fHasOwnFont = kTRUE;
01696 fNormGC = *gc;
01697 gc = new TGGC(fSelGC);
01698 fSelGC = *gc;
01699 }
01700 fNormGC.SetFont(v);
01701 fSelGC.SetFont(v);
01702 fFontStruct = font;
01703 fClient->NeedRedraw(this);
01704 }
01705
01706
01707 void TGTextEntry::SetFont(const char *fontName, Bool_t local)
01708 {
01709
01710
01711
01712 TGFont *font = fClient->GetFont(fontName);
01713 if (font) {
01714 SetFont(font->GetFontStruct(), local);
01715 }
01716 }
01717
01718
01719 void TGTextEntry::SetFont(TGFont *font, Bool_t local)
01720 {
01721
01722
01723
01724 if (font) {
01725 SetFont(font->GetFontStruct(), local);
01726 }
01727 }
01728
01729
01730 void TGTextEntry::SetTextColor(Pixel_t color, Bool_t local)
01731 {
01732
01733
01734
01735 if (local) {
01736 TGGC *gc = new TGGC(fNormGC);
01737 fHasOwnFont = kTRUE;
01738 fNormGC = *gc;
01739 }
01740
01741 fNormGC.SetForeground(color);
01742 fClient->NeedRedraw(this);
01743 }
01744
01745
01746 void TGTextEntry::SetTextColor(TColor *color, Bool_t local)
01747 {
01748
01749
01750
01751 if (color) {
01752 SetTextColor(color->GetPixel(), local);
01753 }
01754 }
01755
01756
01757 FontStruct_t TGTextEntry::GetDefaultFontStruct()
01758 {
01759
01760
01761 if (!fgDefaultFont)
01762 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
01763 return fgDefaultFont->GetFontStruct();
01764 }
01765
01766
01767 const TGGC &TGTextEntry::GetDefaultGC()
01768 {
01769
01770
01771 if (!fgDefaultGC)
01772 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
01773 return *fgDefaultGC;
01774 }
01775
01776
01777 const TGGC &TGTextEntry::GetDefaultSelectedGC()
01778 {
01779
01780
01781 if (!fgDefaultSelectedGC)
01782 fgDefaultSelectedGC = gClient->GetResourcePool()->GetSelectedGC();
01783 return *fgDefaultSelectedGC;
01784 }
01785
01786
01787 const TGGC &TGTextEntry::GetDefaultSelectedBackgroundGC()
01788 {
01789
01790
01791 if (!fgDefaultSelectedBackgroundGC)
01792 fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
01793 return *fgDefaultSelectedBackgroundGC;
01794 }
01795
01796
01797 void TGTextEntry::SavePrimitive(ostream &out, Option_t *option )
01798 {
01799
01800
01801 char quote = '"';
01802
01803
01804 option = GetName()+5;
01805 TString parGC, parFont;
01806 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
01807 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
01808
01809 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC.GetGC())) {
01810 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
01811 if (ufont) {
01812 ufont->SavePrimitive(out, option);
01813 parFont.Form("ufont->GetFontStruct()");
01814 }
01815
01816 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC.GetGC());
01817 if (userGC) {
01818 userGC->SavePrimitive(out, option);
01819 parGC.Form("uGC->GetGC()");
01820 }
01821 }
01822
01823 if (fBackground != GetWhitePixel()) SaveUserColor(out, option);
01824
01825 out << " TGTextEntry *";
01826 out << GetName() << " = new TGTextEntry(" << fParent->GetName()
01827 << ", new TGTextBuffer(" << GetBuffer()->GetBufferLength() << ")";
01828
01829 if (fBackground == GetWhitePixel()) {
01830 if (GetOptions() == (kSunkenFrame | kDoubleBorder)) {
01831 if (fFontStruct == GetDefaultFontStruct()) {
01832 if (fNormGC() == GetDefaultGC()()) {
01833 if (fWidgetId == -1) {
01834 out <<");" << endl;
01835 } else {
01836 out << "," << fWidgetId << ");" << endl;
01837 }
01838 } else {
01839 out << "," << fWidgetId << "," << parGC.Data() << ");" << endl;
01840 }
01841 } else {
01842 out << "," << fWidgetId << "," << parGC.Data() << "," << parFont.Data()
01843 <<");" << endl;
01844 }
01845 } else {
01846 out << "," << fWidgetId << "," << parGC.Data() << "," << parFont.Data()
01847 << "," << GetOptionString() << ");" << endl;
01848 }
01849 } else {
01850 out << "," << fWidgetId << "," << parGC.Data() << "," << parFont.Data()
01851 << "," << GetOptionString() << ",ucolor);" << endl;
01852 }
01853 if (option && strstr(option, "keep_names"))
01854 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
01855
01856 out << " " << GetName() << "->SetMaxLength(" << GetMaxLength() << ");" << endl;
01857
01858 out << " " << GetName() << "->SetAlignment(";
01859
01860 if (fAlignment == kTextLeft)
01861 out << "kTextLeft);" << endl;
01862
01863 if (fAlignment == kTextRight)
01864 out << "kTextRight);" << endl;
01865
01866 if (fAlignment == kTextCenterX)
01867 out << "kTextCenterX);" << endl;
01868
01869 out << " " << GetName() << "->SetText(" << quote << GetText() << quote
01870 << ");" << endl;
01871
01872 out << " " << GetName() << "->Resize("<< GetWidth() << "," << GetName()
01873 << "->GetDefaultHeight());" << endl;
01874
01875 if ((fDefWidth > 0) || (fDefHeight > 0)) {
01876 out << " " << GetName() << "->SetDefaultSize(";
01877 out << fDefWidth << "," << fDefHeight << ");" << endl;
01878 }
01879
01880 if (fTip) {
01881 TString tiptext = fTip->GetText()->GetString();
01882 tiptext.ReplaceAll("\n", "\\n");
01883 out << " ";
01884 out << GetName() << "->SetToolTipText(" << quote
01885 << tiptext << quote << ");" << endl;
01886 }
01887 }