ROOT logo
// @(#)root/gui:$Id: TGTextEdit.h 23115 2008-04-10 13:35:37Z rdm $
// Author: Fons Rademakers   1/7/2000

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGTextEdit
#define ROOT_TGTextEdit


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGTextEdit                                                           //
//                                                                      //
// A TGTextEdit is a specialization of TGTextView. It provides the      //
// text edit functionality to the static text viewing widget.           //
// For the messages supported by this widget see the TGView class.      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGTextView
#include "TGTextView.h"
#endif

class TGPopupMenu;
class TGSearchType;
class TGTextEditHist;

class TGTextEdit : public TGTextView {

private:
   TGTextEdit(const TGTextEdit&); // Not implemented
   TGTextEdit& operator=(const TGTextEdit&); // Not implemented

public:
   enum EInsertMode { kInsert, kReplace };
   enum {
      kM_FILE_NEW, kM_FILE_OPEN, kM_FILE_CLOSE, kM_FILE_SAVE, kM_FILE_SAVEAS,
      kM_FILE_PRINT, kM_EDIT_CUT, kM_EDIT_COPY, kM_EDIT_PASTE, kM_EDIT_SELECTALL,
      kM_SEARCH_FIND, kM_SEARCH_FINDAGAIN, kM_SEARCH_GOTO
   };

protected:
   GContext_t       fCursor0GC;     // graphics context for erasing cursor
   GContext_t       fCursor1GC;     // graphics context for drawing cursor
   Int_t            fCursorState;   // cursor state (1=drawn, 2=erased)
   TViewTimer      *fCurBlink;      // cursor blink timer
   TGPopupMenu     *fMenu;          // popup menu with editor actions
   TGSearchType    *fSearch;        // structure used by search dialog
   TGLongPosition   fCurrent;       // current cursor position
   EInsertMode      fInsertMode;    // *OPTION={GetMethod="GetInsertMode";SetMethod="SetInsertMode";Items=(kInsert="&Insert",kReplace="&Replace")}*
   Bool_t           fEnableMenu;    // enable context menu with editor actions
   TGTextEditHist  *fHistory;       // undo manager
   Bool_t           fEnableCursorWithoutFocus; // enable cursor visibility when focus went out from 
                                               // text editor window (default is kTRUE)

   static TGGC     *fgCursor0GC;
   static TGGC     *fgCursor1GC;

   void Init();

   virtual void SetMenuState();
   virtual void CursorOn();
   virtual void CursorOff();
   virtual void DrawCursor(Int_t mode);
   virtual void AdjustPos();
   virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }

   static const TGGC &GetCursor0GC();
   static const TGGC &GetCursor1GC();

public:
   TGTextEdit(const TGWindow *parent = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
              UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
   TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
              Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
   TGTextEdit(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
              Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());

   virtual ~TGTextEdit();

   virtual Bool_t SaveFile(const char *fname, Bool_t saveas = kFALSE);
   virtual void   Clear(Option_t * = "");
   virtual Bool_t Copy();
   virtual Bool_t Cut();
   virtual Bool_t Paste();
   virtual void   InsChar(char character);
   virtual void   DelChar();
   virtual void   BreakLine();
   virtual void   PrevChar();
   virtual void   NextChar();
   virtual void   LineUp();
   virtual void   LineDown();
   virtual void   ScreenUp();
   virtual void   ScreenDown();
   virtual void   Home();
   virtual void   End();
   virtual void   Print(Option_t * = "") const;
   virtual void   Delete(Option_t * = "");
   virtual Bool_t Search(const char *string, Bool_t direction = kTRUE, Bool_t caseSensitive = kFALSE);
   virtual void   Search(Bool_t close);
   virtual Bool_t Replace(TGLongPosition pos, const char *oldText, const char *newText,
                          Bool_t direction, Bool_t caseSensitive);
   virtual Bool_t Goto(Long_t line, Long_t column = 0);
   virtual void   SetInsertMode(EInsertMode mode = kInsert); //*SUBMENU*
   EInsertMode    GetInsertMode() const { return fInsertMode; }
   TGPopupMenu   *GetMenu() const { return fMenu; }
   virtual void   EnableMenu(Bool_t on = kTRUE) { fEnableMenu = on; } //*TOGGLE* *GETTER=IsMenuEnabled
   virtual Bool_t IsMenuEnabled() const { return fEnableMenu; }
   TList         *GetHistory() const { return (TList *)fHistory; }
   virtual void   EnableCursorWithoutFocus(Bool_t on = kTRUE) { fEnableCursorWithoutFocus = on; }
   virtual Bool_t IsCursorEnabledithoutFocus() const { return fEnableCursorWithoutFocus; }

   virtual void   DrawRegion(Int_t x, Int_t y, UInt_t width, UInt_t height);
   virtual void   ScrollCanvas(Int_t newTop, Int_t direction);
   virtual void   SetFocus() { RequestFocus(); }

   virtual void   SetCurrent(TGLongPosition new_coord);
   TGLongPosition GetCurrentPos() const { return fCurrent; }
   virtual Long_t ReturnLongestLineWidth();

   virtual Bool_t HandleTimer(TTimer *t);
   virtual Bool_t HandleSelection (Event_t *event);
   virtual Bool_t HandleButton(Event_t *event);
   virtual Bool_t HandleKey(Event_t *event);
   virtual Bool_t HandleMotion(Event_t *event);
   virtual Bool_t HandleCrossing(Event_t *event);
   virtual Bool_t HandleFocusChange(Event_t *event);
   virtual Bool_t HandleDoubleClick(Event_t *event);
   virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);

   virtual void   FindAgain() { Emit("FindAgain()"); }  //*SIGNAL*
   virtual void   Closed() { Emit("Closed()"); }        //*SIGNAL*
   virtual void   Opened() { Emit("Opened()"); }        //*SIGNAL*
   virtual void   Saved() { Emit("Saved()"); }          //*SIGNAL*
   virtual void   SavedAs() { Emit("SavedAs()"); }      //*SIGNAL*

   virtual void   SavePrimitive(ostream &out, Option_t * = "");

   ClassDef(TGTextEdit,0)  // Text edit widget
};

#endif
 TGTextEdit.h:1
 TGTextEdit.h:2
 TGTextEdit.h:3
 TGTextEdit.h:4
 TGTextEdit.h:5
 TGTextEdit.h:6
 TGTextEdit.h:7
 TGTextEdit.h:8
 TGTextEdit.h:9
 TGTextEdit.h:10
 TGTextEdit.h:11
 TGTextEdit.h:12
 TGTextEdit.h:13
 TGTextEdit.h:14
 TGTextEdit.h:15
 TGTextEdit.h:16
 TGTextEdit.h:17
 TGTextEdit.h:18
 TGTextEdit.h:19
 TGTextEdit.h:20
 TGTextEdit.h:21
 TGTextEdit.h:22
 TGTextEdit.h:23
 TGTextEdit.h:24
 TGTextEdit.h:25
 TGTextEdit.h:26
 TGTextEdit.h:27
 TGTextEdit.h:28
 TGTextEdit.h:29
 TGTextEdit.h:30
 TGTextEdit.h:31
 TGTextEdit.h:32
 TGTextEdit.h:33
 TGTextEdit.h:34
 TGTextEdit.h:35
 TGTextEdit.h:36
 TGTextEdit.h:37
 TGTextEdit.h:38
 TGTextEdit.h:39
 TGTextEdit.h:40
 TGTextEdit.h:41
 TGTextEdit.h:42
 TGTextEdit.h:43
 TGTextEdit.h:44
 TGTextEdit.h:45
 TGTextEdit.h:46
 TGTextEdit.h:47
 TGTextEdit.h:48
 TGTextEdit.h:49
 TGTextEdit.h:50
 TGTextEdit.h:51
 TGTextEdit.h:52
 TGTextEdit.h:53
 TGTextEdit.h:54
 TGTextEdit.h:55
 TGTextEdit.h:56
 TGTextEdit.h:57
 TGTextEdit.h:58
 TGTextEdit.h:59
 TGTextEdit.h:60
 TGTextEdit.h:61
 TGTextEdit.h:62
 TGTextEdit.h:63
 TGTextEdit.h:64
 TGTextEdit.h:65
 TGTextEdit.h:66
 TGTextEdit.h:67
 TGTextEdit.h:68
 TGTextEdit.h:69
 TGTextEdit.h:70
 TGTextEdit.h:71
 TGTextEdit.h:72
 TGTextEdit.h:73
 TGTextEdit.h:74
 TGTextEdit.h:75
 TGTextEdit.h:76
 TGTextEdit.h:77
 TGTextEdit.h:78
 TGTextEdit.h:79
 TGTextEdit.h:80
 TGTextEdit.h:81
 TGTextEdit.h:82
 TGTextEdit.h:83
 TGTextEdit.h:84
 TGTextEdit.h:85
 TGTextEdit.h:86
 TGTextEdit.h:87
 TGTextEdit.h:88
 TGTextEdit.h:89
 TGTextEdit.h:90
 TGTextEdit.h:91
 TGTextEdit.h:92
 TGTextEdit.h:93
 TGTextEdit.h:94
 TGTextEdit.h:95
 TGTextEdit.h:96
 TGTextEdit.h:97
 TGTextEdit.h:98
 TGTextEdit.h:99
 TGTextEdit.h:100
 TGTextEdit.h:101
 TGTextEdit.h:102
 TGTextEdit.h:103
 TGTextEdit.h:104
 TGTextEdit.h:105
 TGTextEdit.h:106
 TGTextEdit.h:107
 TGTextEdit.h:108
 TGTextEdit.h:109
 TGTextEdit.h:110
 TGTextEdit.h:111
 TGTextEdit.h:112
 TGTextEdit.h:113
 TGTextEdit.h:114
 TGTextEdit.h:115
 TGTextEdit.h:116
 TGTextEdit.h:117
 TGTextEdit.h:118
 TGTextEdit.h:119
 TGTextEdit.h:120
 TGTextEdit.h:121
 TGTextEdit.h:122
 TGTextEdit.h:123
 TGTextEdit.h:124
 TGTextEdit.h:125
 TGTextEdit.h:126
 TGTextEdit.h:127
 TGTextEdit.h:128
 TGTextEdit.h:129
 TGTextEdit.h:130
 TGTextEdit.h:131
 TGTextEdit.h:132
 TGTextEdit.h:133
 TGTextEdit.h:134
 TGTextEdit.h:135
 TGTextEdit.h:136
 TGTextEdit.h:137
 TGTextEdit.h:138
 TGTextEdit.h:139
 TGTextEdit.h:140
 TGTextEdit.h:141
 TGTextEdit.h:142
 TGTextEdit.h:143
 TGTextEdit.h:144
 TGTextEdit.h:145
 TGTextEdit.h:146
 TGTextEdit.h:147
 TGTextEdit.h:148