TGTextEntry.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTextEntry.h 32694 2010-03-22 09:08:25Z bellenot $
00002 // Author: Fons Rademakers   08/01/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGTextEntry
00013 #define ROOT_TGTextEntry
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGTextEntry                                                          //
00019 //                                                                      //
00020 // A TGTextEntry is a one line text input widget.                       //
00021 //                                                                      //
00022 // Changing text in the text entry widget will generate the event:      //
00023 // kC_TEXTENTRY, kTE_TEXTCHANGED, widget id, 0.                         //
00024 // Hitting the enter key will generate:                                 //
00025 // kC_TEXTENTRY, kTE_ENTER, widget id, 0.                               //
00026 // Hitting the tab key will generate:                                   //
00027 // kC_TEXTENTRY, kTE_TAB, widget id, 0.                                 //
00028 //                                                                      //
00029 //////////////////////////////////////////////////////////////////////////
00030 
00031 #ifndef ROOT_TGFrame
00032 #include "TGFrame.h"
00033 #endif
00034 #ifndef ROOT_TGWidget
00035 #include "TGWidget.h"
00036 #endif
00037 #ifndef ROOT_TGTextBuffer
00038 #include "TGTextBuffer.h"
00039 #endif
00040 
00041 class TBlinkTimer;
00042 class TGToolTip;
00043 class TColor;
00044 
00045 class TGTextEntry : public TGFrame, public TGWidget {
00046 
00047 public:
00048    enum   EEchoMode { kNormal, kNoEcho, kPassword };
00049    enum   EInsertMode { kInsert, kReplace };
00050 
00051 protected:
00052    TGTextBuffer     *fText;              // text buffer
00053    Int_t             fStartX;            // selection begin in pixels
00054    Int_t             fEndX;              // selection end in pixels
00055    Int_t             fStartIX;           // selection begin in characters
00056    Int_t             fEndIX;             // selection end in characters
00057    Bool_t            fSelectionOn;       // selection status (on/off)
00058    Int_t             fOffset;            // start position of text (in pixels)
00059    Int_t             fCursorX;           // cursor position in pixels
00060    Int_t             fCursorIX;          // cursor position in characters
00061    Bool_t            fCursorOn;          // cursor status (on/off)
00062    FontStruct_t      fFontStruct;        // text font
00063    TGGC              fNormGC;            // normal drawing context
00064    TGGC              fSelGC;             // selected text drawing context
00065    GContext_t        fSelbackGC;         // selected background drawing context
00066    Atom_t            fClipboard;         // clipboard property
00067    TBlinkTimer      *fCurBlink;          // cursor blink timer
00068    TGToolTip        *fTip;               // associated tooltip
00069    Int_t             fMaxLen;            // maximum length of text
00070    Bool_t            fEdited;            // kFALSE, if the line edit's contents have not been changed since the construction
00071    Bool_t            fFrameDrawn;        // kTRUE draw itself inside a two-pixel frame, kFALSE draw without any frame
00072    EEchoMode         fEchoMode;          // *OPTION={GetMethod="GetEchoMode";SetMethod="SetEchoMode";Items=(kNormal="Normal",kNoEcho="No Echo",kPassword="Password")}*
00073    EInsertMode       fInsertMode;        // *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="Insert",kReplace="Replace")}*
00074    ETextJustification fAlignment;        // *OPTION={GetMethod="GetAlignment";SetMethod="SetAlignment";Items=(kTextLeft="Left",kTextCenterX="Center",kTextRight="Right")}*
00075    Bool_t            fHasOwnFont;        // kTRUE - font defined locally,  kFALSE - globally
00076    UInt_t            fDefWidth;          // default width
00077    UInt_t            fDefHeight;         // default height
00078 
00079             void        CopyText() const;
00080    virtual  void        DoRedraw();
00081             Int_t       GetCharacterIndex(Int_t xcoord);
00082    virtual  void        Init();
00083    virtual  Bool_t      IsCursorOutOfFrame();
00084             void        Paste();
00085    virtual  void        PastePrimary(Window_t wid, Atom_t property, Bool_t del);
00086    virtual  void        ScrollByChar();
00087    virtual  void        UpdateOffset();
00088 
00089    static TString      *fgClipboardText; // application clipboard text
00090    static const TGFont *fgDefaultFont;
00091    static const TGGC   *fgDefaultSelectedGC;
00092    static const TGGC   *fgDefaultSelectedBackgroundGC;
00093    static const TGGC   *fgDefaultGC;
00094 
00095    static const TGGC   &GetDefaultSelectedGC();
00096    static const TGGC   &GetDefaultSelectedBackgroundGC();
00097 
00098 private:
00099    TGTextEntry(const TGTextEntry&);              // not implemented
00100    TGTextEntry& operator=(const TGTextEntry&);   // not implemented
00101 
00102 public:
00103    static FontStruct_t  GetDefaultFontStruct();
00104    static const TGGC   &GetDefaultGC();
00105 
00106    TGTextEntry(const TGWindow *p, TGTextBuffer *text, Int_t id = -1,
00107                GContext_t norm = GetDefaultGC()(),
00108                FontStruct_t font = GetDefaultFontStruct(),
00109                UInt_t option = kSunkenFrame | kDoubleBorder,
00110                Pixel_t back = GetWhitePixel());
00111 
00112    TGTextEntry(const TGWindow *parent = 0, const char *text = 0, Int_t id = -1);
00113    TGTextEntry(const TString &contents, const TGWindow *parent, Int_t id = -1);
00114 
00115    virtual ~TGTextEntry();
00116 
00117    virtual  TGDimension GetDefaultSize() const;
00118    virtual  void        SetDefaultSize(UInt_t w, UInt_t h);
00119 
00120    virtual  void        AppendText(const char *text);
00121             void        Backspace();
00122             void        Clear(Option_t *option="");
00123             void        CursorLeft(Bool_t mark = kFALSE , Int_t steps = 1);
00124             void        CursorRight(Bool_t mark = kFALSE , Int_t steps = 1);
00125             void        CursorWordForward(Bool_t mark = kFALSE);
00126             void        CursorWordBackward(Bool_t mark = kFALSE);
00127             void        Cut();
00128             void        Del();
00129             void        Deselect();
00130    virtual  void        DrawBorder();
00131             void        End(Bool_t mark = kFALSE);
00132    ETextJustification   GetAlignment() const       { return fAlignment; }
00133    TGTextBuffer        *GetBuffer() const { return fText; }
00134             Int_t       GetCursorPosition() const  { return fCursorIX; }
00135             TString     GetDisplayText() const;
00136    EEchoMode            GetEchoMode() const        { return fEchoMode; }
00137    EInsertMode          GetInsertMode() const      { return fInsertMode; }
00138             TString     GetMarkedText() const;
00139             Int_t       GetMaxLength() const    { return fMaxLen; }
00140    const    char       *GetText() const { return fText->GetString(); }
00141    virtual TGToolTip   *GetToolTip() const { return fTip; }
00142    virtual const char  *GetTitle() const { return GetText(); }
00143             Bool_t      HasMarkedText() const  { return fSelectionOn && (fStartIX != fEndIX); }
00144             Pixel_t     GetTextColor() const { return fNormGC.GetForeground(); }
00145            FontStruct_t GetFontStruct() const { return fFontStruct; }
00146             void        Home(Bool_t mark = kFALSE);
00147    virtual  void        Insert(const char *);
00148    virtual  void        InsertText(const char *text, Int_t pos);
00149             Bool_t      IsFrameDrawn() const       { return fFrameDrawn; }
00150             Bool_t      IsEdited() const           { return fEdited; }
00151    virtual  void        Layout() { UpdateOffset(); }
00152             void        MarkWord(Int_t pos);
00153             Int_t       MaxMark() const { return fStartIX > fEndIX ? fStartIX : fEndIX; }
00154             Int_t       MinMark() const { return fStartIX < fEndIX ? fStartIX : fEndIX; }
00155             void        NewMark(Int_t pos);
00156             void        Remove();
00157    virtual  void        RemoveText(Int_t start, Int_t end);
00158    virtual  void        SetFont(TGFont *font, Bool_t local = kTRUE);
00159    virtual  void        SetFont(FontStruct_t font, Bool_t local = kTRUE);
00160    virtual  void        SetFont(const char *fontName, Bool_t local = kTRUE);
00161    virtual  void        SetTextColor(Pixel_t color, Bool_t local = kTRUE);
00162    virtual  void        SetTextColor(TColor *color, Bool_t local = kTRUE);
00163    virtual  void        SetText(const char *text, Bool_t emit = kTRUE);          //*MENU*
00164    virtual  void        SetToolTipText(const char *text, Long_t delayms = 500);  //*MENU*
00165    virtual  void        SetMaxLength(Int_t maxlen);                              //*MENU*
00166    virtual  void        SelectAll();
00167    virtual  void        SetAlignment(ETextJustification mode = kTextLeft);       //*SUBMENU*
00168    virtual  void        SetInsertMode(EInsertMode mode = kInsert);               //*SUBMENU*
00169    virtual  void        SetEchoMode(EEchoMode mode = kNormal);                   //*SUBMENU*
00170             void        SetEnabled(Bool_t flag = kTRUE) { SetState( flag ); }    //*TOGGLE* *GETTER=IsEnabled
00171    virtual  void        SetCursorPosition(Int_t pos);
00172             void        SetEdited(Bool_t flag = kTRUE) { fEdited = flag; }
00173    virtual  void        SetFocus();
00174    virtual  void        SetFrameDrawn(Bool_t flag = kTRUE);
00175    virtual  void        SetState(Bool_t state);
00176    virtual  void        SetTitle(const char *label) { SetText(label); }
00177    virtual  void        SetForegroundColor(Pixel_t fore) { SetTextColor(fore, kFALSE); }
00178    Pixel_t              GetForeground() const { return fNormGC.GetForeground(); }
00179    Bool_t               HasOwnFont() const { return fHasOwnFont; }
00180 
00181    virtual  void        SavePrimitive(ostream &out, Option_t *option = "");
00182 
00183    virtual  Bool_t      HandleButton(Event_t *event);
00184    virtual  Bool_t      HandleDoubleClick(Event_t *event);
00185    virtual  Bool_t      HandleCrossing(Event_t *event);
00186    virtual  Bool_t      HandleMotion(Event_t *event);
00187    virtual  Bool_t      HandleKey(Event_t *event);
00188    virtual  Bool_t      HandleFocusChange(Event_t *event);
00189    virtual  Bool_t      HandleSelection(Event_t *event);
00190    virtual  Bool_t      HandleSelectionClear(Event_t *event);
00191    virtual  Bool_t      HandleSelectionRequest(Event_t *event);
00192    virtual  Bool_t      HandleTimer(TTimer *t);
00193    virtual  Bool_t      HandleConfigureNotify(Event_t *event);
00194 
00195    virtual  void        TextChanged(const char *text = 0);      //*SIGNAL*
00196    virtual  void        ReturnPressed();                        //*SIGNAL*
00197    virtual  void        TabPressed();                           //*SIGNAL*
00198    virtual  void        ShiftTabPressed();                      //*SIGNAL*
00199    virtual  void        CursorOutLeft();                        //*SIGNAL*
00200    virtual  void        CursorOutRight();                       //*SIGNAL*
00201    virtual  void        CursorOutUp();                          //*SIGNAL*
00202    virtual  void        CursorOutDown();                        //*SIGNAL*
00203    virtual  void        DoubleClicked();                        //*SIGNAL*
00204 
00205    ClassDef(TGTextEntry,0) // The TGTextEntry widget is a simple line editor for inputting text
00206 };
00207 
00208 #endif

Generated on Tue Jul 5 14:20:10 2011 for ROOT_528-00b_version by  doxygen 1.5.1