TGTextView.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTextView.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_TGTextView
00013 #define ROOT_TGTextView
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGTextView                                                           //
00019 //                                                                      //
00020 // A TGTextView is a text viewer widget. It is a specialization of      //
00021 // TGView. It uses the TGText class (which contains all text            //
00022 // manipulation code, i.e. loading a file in memory, changing,          //
00023 // removing lines, etc.). Use a TGTextView to view non-editable text.   //
00024 // For supported messages see TGView.                                   //
00025 //                                                                      //
00026 //////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef ROOT_TGView
00029 #include "TGView.h"
00030 #endif
00031 #ifndef ROOT_TGText
00032 #include "TGText.h"
00033 #endif
00034 
00035 class TViewTimer;
00036 
00037 class TGTextView : public TGView {
00038 
00039 protected:
00040    TGText         *fText;         // text buffer
00041    TGText         *fClipText;     // clipboard text buffer
00042    FontStruct_t    fFont;         // text font
00043    Int_t           fMaxAscent;    // maximum ascent in font
00044    Int_t           fMaxDescent;   // maximum descent in font
00045    Int_t           fMaxWidth;     // maximum width of character in font
00046    TGGC            fNormGC;       // graphics context for drawing text
00047    TGGC            fSelGC;        // graphics context for drawing marked text
00048    TGGC            fSelbackGC;    // graphics context for drawing marked background
00049    Bool_t          fMarkedFromX;  // true if text is marked from x
00050    Bool_t          fMarkedFromY;  // true if text is marker from y
00051    Bool_t          fIsMarked;     // true if text is marked/selected
00052    Bool_t          fIsMarking;    // true if in marking mode
00053    Bool_t          fIsSaved;      // true is content is saved
00054    Bool_t          fReadOnly;     // text cannot be editted
00055    TGLongPosition  fMarkedStart;  // start position of marked text
00056    TGLongPosition  fMarkedEnd;    // end position of marked text
00057    TViewTimer     *fScrollTimer;  // scrollbar timer
00058    Atom_t         *fDNDTypeList;  // handles DND types
00059 
00060    static const TGFont *fgDefaultFont;
00061    static TGGC         *fgDefaultGC;
00062    static TGGC         *fgDefaultSelectedGC;
00063    static const TGGC   *fgDefaultSelectedBackgroundGC;
00064 
00065    void Init(Pixel_t bg);
00066    virtual void DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h);
00067    virtual void Mark(Long_t xPos, Long_t yPos);
00068    virtual void UnMark();
00069    virtual void Copy(TObject &) const { MayNotUse("Copy(TObject &)"); }
00070    virtual void HLayout();
00071    virtual void VLayout();
00072 
00073    static FontStruct_t  GetDefaultFontStruct();
00074    static const TGGC   &GetDefaultGC();
00075    static const TGGC   &GetDefaultSelectedGC();
00076    static const TGGC   &GetDefaultSelectedBackgroundGC();
00077 
00078 private:
00079    TGTextView(const TGTextView&);
00080    TGTextView& operator=(const TGTextView&);
00081 
00082 public:
00083    TGTextView(const TGWindow *parent = 0, UInt_t w = 1, UInt_t h = 1, Int_t id = -1,
00084               UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
00085    TGTextView(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
00086               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
00087    TGTextView(const TGWindow *parent, UInt_t w, UInt_t h, const char *string,
00088               Int_t id = -1, UInt_t sboptions = 0, Pixel_t back = GetWhitePixel());
00089 
00090    virtual ~TGTextView();
00091 
00092    virtual Bool_t IsSaved() { fIsSaved = fText->IsSaved(); return fIsSaved;}
00093    virtual Long_t ToObjXCoord(Long_t xCoord, Long_t line);
00094    virtual Long_t ToObjYCoord(Long_t yCoord);
00095    virtual Long_t ToScrXCoord(Long_t xCoord, Long_t line);
00096    virtual Long_t ToScrYCoord(Long_t yCoord);
00097    virtual void   AdjustWidth();
00098    virtual Bool_t LoadFile(const char *fname, long startpos = 0, long length = -1);
00099    virtual Bool_t LoadBuffer(const char *txtbuf);
00100    virtual void   Clear(Option_t * = "");
00101    virtual Bool_t Copy();
00102    virtual Bool_t SelectAll();
00103    virtual Bool_t Search(const char *string, Bool_t direction, Bool_t caseSensitive);
00104    virtual void   SetFont(FontStruct_t font);
00105    virtual Long_t ReturnHeighestColHeight() { return fText->RowCount()*fScrollVal.fY; }
00106    virtual Long_t ReturnLongestLineWidth();
00107    virtual Long_t ReturnLineLength(Long_t line) { return fText->GetLineLength(line); }
00108    virtual Long_t ReturnLongestLine() { return fText->GetLongestLine(); }
00109    virtual Long_t ReturnLineCount() { return fText->RowCount(); }
00110 
00111    virtual void   SetSBRange(Int_t direction);
00112    virtual void   SetHsbPosition(Long_t newPos);
00113    virtual void   SetVsbPosition(Long_t newPos);
00114    virtual void   ShowBottom();
00115    virtual void   ShowTop();
00116 
00117    virtual void   SavePrimitive(ostream &out, Option_t * = "");
00118    virtual void   SetText(TGText *text);
00119    virtual void   AddText(TGText *text);
00120    virtual void   AddLine(const char *string);
00121    virtual void   AddLineFast(const char *string);
00122    virtual void   Update();
00123    virtual void   Layout();
00124 
00125    virtual void   SetBackground(Pixel_t p);
00126    virtual void   SetSelectBack(Pixel_t p);
00127    virtual void   SetSelectFore(Pixel_t p);
00128    virtual void   SetForegroundColor(Pixel_t);
00129 
00130    TGText        *GetText() const { return fText; }
00131 
00132    virtual void   SetReadOnly(Bool_t on = kTRUE) { fReadOnly = on; } //*TOGGLE* *GETTER=IsReadOnly
00133    Bool_t IsReadOnly() const { return fReadOnly; }
00134    Bool_t IsMarked() const { return fIsMarked; }
00135 
00136    virtual Bool_t HandleDNDDrop(TDNDData *data);
00137    virtual Atom_t HandleDNDPosition(Int_t x, Int_t y, Atom_t action,
00138                                     Int_t xroot, Int_t yroot);
00139    virtual Atom_t HandleDNDEnter(Atom_t * typelist);
00140    virtual Bool_t HandleDNDLeave();
00141 
00142    virtual Bool_t HandleButton(Event_t *event);
00143    virtual Bool_t HandleDoubleClick(Event_t *event);
00144    virtual Bool_t HandleSelectionClear(Event_t *event);
00145    virtual Bool_t HandleSelectionRequest(Event_t *event);
00146    virtual Bool_t HandleMotion(Event_t *event);
00147    virtual Bool_t HandleTimer(TTimer *t);
00148    virtual Bool_t HandleCrossing(Event_t *event);
00149 
00150    virtual void DataChanged() { Emit("DataChanged()"); }  //*SIGNAL*
00151    virtual void DataDropped(const char *fname) { Emit("DataDropped(char *)", fname); }  //*SIGNAL*
00152    virtual void Marked(Bool_t mark) { Emit("Marked(Bool_t)", mark); } // *SIGNAL*
00153    virtual void Clicked(const char *word) { Emit("Clicked(char *)", word); }  //*SIGNAL*
00154    virtual void DoubleClicked(const char *word) { Emit("DoubleClicked(char *)", word); }  //*SIGNAL*
00155 
00156    ClassDef(TGTextView,0)  // Non-editable text viewer widget
00157 };
00158 
00159 
00160 class TViewTimer : public TTimer {
00161 private:
00162    TGView   *fView;
00163 
00164    TViewTimer(const TViewTimer&);             // not implemented
00165    TViewTimer& operator=(const TViewTimer&);  // not implemented
00166 
00167 public:
00168    TViewTimer(TGView *t, Long_t ms) : TTimer(ms, kTRUE), fView(t) { }
00169    Bool_t Notify();
00170 };
00171 
00172 
00173 #endif

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