Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

GTextView3.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 #ifndef __GTEXTVIEW3_H
00006 #define __GTEXTVIEW3_H
00007 
00008 #include "GDocView.h"
00009 #include "GUndo.h"
00010 
00011 // use CRLF as opposed to just LF
00012 // internally it uses LF only... this is just to remember what to
00013 // save out as.
00014 #define TEXTED_USES_CR              0x00000001
00015 #define TAB_SIZE                    4
00016 #define DEBUG_TIMES_MSG             8000 // a=0 b=(char*)Str
00017 
00018 #define M_TEXTVIEW_DEBUG_TEXT       (M_USER+0x3421)
00019 
00020 extern char Delimiters[];
00021 
00022 class GTextView3;
00023 
00024 class GTextStyle
00025 {
00026     friend class GUrl;
00027 
00028 protected:
00029     void RefreshLayout(int Start, int Len);
00030 
00031 public:
00032     // data
00033     GTextView3 *View;
00034     int Start;
00035     int Len;
00036     GFont *Font;
00037     COLOUR c;
00038 
00039     // attach
00040     char *Data;
00041 
00042     GTextStyle()
00043     {
00044         View = 0;
00045     }
00046 
00047     virtual bool OnMouseClick(GMouse *m) { return false; }
00048     virtual bool OnMenu(GSubMenu *m) { return false; }
00049     virtual void OnMenuClick(int i) {}
00050     virtual char *GetCursor() { return 0; }
00051 };
00052 
00054 class GTextView3 :
00055     public GDocView,
00056     public ResObject
00057 {
00058     friend class GTextStyle;
00059     friend class GUrl;
00060     friend class GTextView3Undo;
00061 
00062 protected:
00063     // Internal classes
00064     enum GTextViewSeek
00065     {
00066         PrevLine,
00067         NextLine,
00068         StartLine,
00069         EndLine
00070     };
00071 
00072     class GTextLine
00073     {
00074     public:
00075         int Start;      // Start offset
00076         int Len;        // length of text
00077         GRect r;        // Screen location
00078         COLOUR Col;     // Colour of line
00079 
00080         GTextLine()
00081         {
00082             Col = 0x80000000;
00083         }
00084         virtual ~GTextLine() {}
00085         bool Overlap(int i)
00086         {
00087             return i>=Start AND i<=Start+Len;
00088         }
00089     };
00090     
00091     class GTextView3Private *d;
00092     friend class GTextView3Private;
00093 
00094     // Options
00095     bool Dirty;
00096     bool CanScrollX;
00097 
00098     // Display
00099     GFont *Font;
00100     GFont *FixedFont;
00101     GFont *Underline;   // URL display
00102     int LineY;
00103     int SelStart, SelEnd;
00104     int DocOffset;
00105     int MaxX;
00106     bool Blink;
00107     int ScrollX;
00108     GRect CursorPos;
00109 
00110     List<GTextLine> Line;
00111     List<GTextStyle> Style;     // sorted in 'Start' order
00112 
00113     // For ::Name(...)
00114     char *TextCache;
00115 
00116     // Data
00117     char16 *Text;
00118     int Cursor;
00119     int Size;
00120     int Alloc;
00121 
00122     // Undo stuff
00123     bool UndoOn;
00124     GUndo UndoQue;
00125 
00126     // private methods
00127     GTextLine *GetLine(int Offset, int *Index = 0);
00128     int SeekLine(int Start, GTextViewSeek Where);
00129     int TextWidth(GFont *f, char16 *s, int Len, int x, int Origin);
00130     int ScrollYLine();
00131     int ScrollYPixel();
00132     int MatchText(char16 *Text, bool MatchWord, bool MatchCase, bool SelectionOnly);
00133     
00134     // styles
00135     void InsertStyle(GTextStyle *s);
00136     GTextStyle *GetNextStyle(int Where = -1);
00137     GTextStyle *HitStyle(int i);
00138     int GetColumn();
00139 
00140     // Overridables
00141     virtual void PourText(int Start, int Length);
00142     virtual void PourStyle(int Start, int Length);
00143     virtual void OnFontChange();
00144     virtual char16 *MapText(char16 *Str, int Len, bool RtlTrailingSpace = false);
00145 
00146     #ifdef _DEBUG
00147     // debug
00148     int _PourTime;
00149     int _StyleTime;
00150     int _PaintTime;
00151     #endif
00152 
00153 public:
00154     // Construction
00155     GTextView3( int Id,
00156                 int x,
00157                 int y,
00158                 int cx,
00159                 int cy,
00160                 GFontType *FontInfo = 0);
00161     ~GTextView3();
00162 
00163     // Data
00164     char *Name();
00165     bool Name(char *s);
00166     char16 *NameW();
00167     bool NameW(char16 *s);
00168     int Value();
00169     void Value(int i);
00170     char *GetMimeType() { return "text/plain"; }
00171 
00172     virtual bool Insert(int At, char16 *Data, int Len);
00173     virtual bool Delete(int At, int Len);
00174     int HitText(int x, int y);
00175     void DeleteSelection(char16 **Cut = 0);
00176 
00177     // Font
00178     GFont *GetFont();
00179     void SetFont(GFont *f, bool OwnIt = false);
00180     void SetFixedWidthFont(bool i);
00181 
00182     // Options
00183     void SetTabSize(uint8 i);
00184     void SetBorder(int b);
00185     void SetReadOnly(bool i);
00186 
00188     void SetWrapType(uint8 i);
00189     
00190     // Margin
00191     GRect &GetMargin();
00192     void SetMargin(GRect &r);
00193 
00194     // State / Selection
00195     void SetCursor(int i, bool Select, bool ForceFullUpdate = false);
00196     int IndexAt(int x, int y);
00197     bool IsDirty() { return Dirty; }
00198     void IsDirty(bool d) { Dirty = d; }
00199     bool HasSelection();
00200     void UnSelectAll();
00201     void SelectWord(int From);
00202     void SelectAll();
00203     int GetCursor(bool Cursor = true);
00204     void PositionAt(int &x, int &y, int Index = -1);
00205     int GetLines();
00206     void GetTextExtent(int &x, int &y);
00207     char *GetSelection();
00208 
00209     // File IO
00210     bool Open(char *Name, char *Cs = 0);
00211     bool Save(char *Name, char *Cs = 0);
00212 
00213     // Clipboard IO
00214     bool Cut();
00215     bool Copy();
00216     bool Paste();
00217 
00218     // Undo/Redo
00219     void Undo();
00220     void Redo();
00221 
00222     // Action UI
00223     virtual bool DoGoto();
00224     virtual bool DoCase(bool Upper);
00225     virtual bool DoFind();
00226     virtual bool DoFindNext();
00227     virtual bool DoReplace();
00228 
00229     // Action Processing    
00230     bool ClearDirty(bool Ask, char *FileName = 0);
00231     void UpdateScrollBars(bool Reset = false);
00232     void GotoLine(int Line);
00233     GDocFindReplaceParams *CreateFindReplaceParams();
00234     void SetFindReplaceParams(GDocFindReplaceParams *Params);
00235 
00236     // Object Events
00237     bool OnFind(char16 *Find, bool MatchWord, bool MatchCase, bool SelectionOnly);
00238     bool OnReplace(char16 *Find, char16 *Replace, bool All, bool MatchWord, bool MatchCase, bool SelectionOnly);
00239     bool OnMultiLineTab(bool In);
00240     void OnSetHidden(int Hidden);
00241     void OnPosChange();
00242     void OnCreate();
00243     void OnEscape(GKey &K);
00244     void OnMouseWheel(double Lines);
00245 
00246     // Window Events
00247     void OnFocus(bool f);
00248     void OnMouseClick(GMouse &m);
00249     void OnMouseMove(GMouse &m);
00250     bool OnKey(GKey &k);
00251     void OnPaint(GSurface *pDC);
00252     int OnEvent(GMessage *Msg);
00253     int OnNotify(GView *Ctrl, int Flags);
00254     void OnPulse();
00255     int OnHitTest(int x, int y);
00256 
00257     // Virtuals
00258     virtual void OnEnter(GKey &k);
00259     virtual void OnUrl(char *Url);
00260 };
00261 
00262 #endif

Generated on Wed Oct 26 14:46:50 2005 for Lgi by  doxygen 1.4.1