TGTextEdit.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTextEdit.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   1/7/2000
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_TGTextEdit
00013 #define ROOT_TGTextEdit
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGTextEdit                                                           //
00019 //                                                                      //
00020 // A TGTextEdit is a specialization of TGTextView. It provides the      //
00021 // text edit functionality to the static text viewing widget.           //
00022 // For the messages supported by this widget see the TGView class.      //
00023 //                                                                      //
00024 //////////////////////////////////////////////////////////////////////////
00025 
00026 #ifndef ROOT_TGTextView
00027 #include "TGTextView.h"
00028 #endif
00029 
00030 class TGPopupMenu;
00031 class TGSearchType;
00032 class TGTextEditHist;
00033 
00034 class TGTextEdit : public TGTextView {
00035 
00036 private:
00037    TGTextEdit(const TGTextEdit&); // Not implemented
00038    TGTextEdit& operator=(const TGTextEdit&); // Not implemented
00039 
00040 public:
00041    enum EInsertMode { kInsert, kReplace };
00042    enum {
00043       kM_FILE_NEW, kM_FILE_OPEN, kM_FILE_CLOSE, kM_FILE_SAVE, kM_FILE_SAVEAS,
00044       kM_FILE_PRINT, kM_EDIT_CUT, kM_EDIT_COPY, kM_EDIT_PASTE, kM_EDIT_SELECTALL,
00045       kM_SEARCH_FIND, kM_SEARCH_FINDAGAIN, kM_SEARCH_GOTO
00046    };
00047 
00048 protected:
00049    GContext_t       fCursor0GC;     // graphics context for erasing cursor
00050    GContext_t       fCursor1GC;     // graphics context for drawing cursor
00051    Int_t            fCursorState;   // cursor state (1=drawn, 2=erased)
00052    TViewTimer      *fCurBlink;      // cursor blink timer
00053    TGPopupMenu     *fMenu;          // popup menu with editor actions
00054    TGSearchType    *fSearch;        // structure used by search dialog
00055    TGLongPosition   fCurrent;       // current cursor position
00056    EInsertMode      fInsertMode;    // *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",kReplace="&Replace")}*
00057    Bool_t           fEnableMenu;    // enable context menu with editor actions
00058    TGTextEditHist  *fHistory;       // undo manager
00059    Bool_t           fEnableCursorWithoutFocus; // enable cursor visibility when focus went out from 
00060                                                // text editor window (default is kTRUE)
00061 
00062    static TGGC     *fgCursor0GC;
00063    static TGGC     *fgCursor1GC;
00064 
00065    void Init();
00066 
00067    virtual void SetMenuState();
00068    virtual void CursorOn();
00069    virtual void CursorOff();
00070    virtual void DrawCursor(Int_t mode);
00071    virtual void AdjustPos();
00072    virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
00073 
00074    static const TGGC &GetCursor0GC();
00075    static const TGGC &GetCursor1GC();
00076 
00077 public:
00078    TGTextEdit(const TGWindow *parent = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
00079               UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
00080    TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
00081               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
00082    TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
00083               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
00084 
00085    virtual ~TGTextEdit();
00086 
00087    virtual Bool_t SaveFile(const char *fname, Bool_t saveas = kFALSE);
00088    virtual void   Clear(Option_t * = "");
00089    virtual Bool_t Copy();
00090    virtual Bool_t Cut();
00091    virtual Bool_t Paste();
00092    virtual void   InsChar(char character);
00093    virtual void   DelChar();
00094    virtual void   BreakLine();
00095    virtual void   PrevChar();
00096    virtual void   NextChar();
00097    virtual void   LineUp();
00098    virtual void   LineDown();
00099    virtual void   ScreenUp();
00100    virtual void   ScreenDown();
00101    virtual void   Home();
00102    virtual void   End();
00103    virtual void   Print(Option_t * = "") const;
00104    virtual void   Delete(Option_t * = "");
00105    virtual Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE);
00106    virtual void   Search(Bool_t close);
00107    virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText,
00108                           Bool_t direction, Bool_t caseSensitive);
00109    virtual Bool_t Goto(Long_t line, Long_t column = 0);
00110    virtual void   SetInsertMode(EInsertMode mode = kInsert); //*SUBMENU*
00111    EInsertMode    GetInsertMode() const { return fInsertMode; }
00112    TGPopupMenu   *GetMenu() const { return fMenu; }
00113    virtual void   EnableMenu(Bool_t on = kTRUE) { fEnableMenu = on; } //*TOGGLE* *GETTER=IsMenuEnabled
00114    virtual Bool_t IsMenuEnabled() const { return fEnableMenu; }
00115    TList         *GetHistory() const { return (TList *)fHistory; }
00116    virtual void   EnableCursorWithoutFocus(Bool_t on = kTRUE) { fEnableCursorWithoutFocus = on; }
00117    virtual Bool_t IsCursorEnabledithoutFocus() const { return fEnableCursorWithoutFocus; }
00118 
00119    virtual void   DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
00120    virtual void   ScrollCanvas(Int_t newTop, Int_t direction);
00121    virtual void   SetFocus() { RequestFocus(); }
00122 
00123    virtual void   SetCurrent(TGLongPosition new_coord);
00124    TGLongPosition GetCurrentPos() const { return fCurrent; }
00125    virtual Long_t ReturnLongestLineWidth();
00126 
00127    virtual Bool_t HandleTimer(TTimer *t);
00128    virtual Bool_t HandleSelection (Event_t *event);
00129    virtual Bool_t HandleButton(Event_t *event);
00130    virtual Bool_t HandleKey(Event_t *event);
00131    virtual Bool_t HandleMotion(Event_t *event);
00132    virtual Bool_t HandleCrossing(Event_t *event);
00133    virtual Bool_t HandleFocusChange(Event_t *event);
00134    virtual Bool_t HandleDoubleClick(Event_t *event);
00135    virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
00136 
00137    virtual void   FindAgain() { Emit("FindAgain()"); }  //*SIGNAL*
00138    virtual void   Closed() { Emit("Closed()"); }        //*SIGNAL*
00139    virtual void   Opened() { Emit("Opened()"); }        //*SIGNAL*
00140    virtual void   Saved() { Emit("Saved()"); }          //*SIGNAL*
00141    virtual void   SavedAs() { Emit("SavedAs()"); }      //*SIGNAL*
00142 
00143    virtual void   SavePrimitive(ostream &out, Option_t * = "");
00144 
00145    ClassDef(TGTextEdit,0)  // Text edit widget
00146 };
00147 
00148 #endif

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