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

GTextView2.h

00001 #ifndef __GTEXTVIEW2_H
00002 #define __GTEXTVIEW2_H
00003 
00004 #include "GDocView.h"
00005 
00006 // Word wrap
00007 #define TEXTED_WRAP_NONE            0   // no word wrap
00008 #define TEXTED_WRAP_REFLOW          1   // dynamically wrap line to editor width
00009 
00010 // Code pages
00011 #define TVCP_US_ASCII               0
00012 #define TVCP_ISO_8859_2             1
00013 #define TVCP_WIN_1250               2
00014 #define TVCP_MAX                    3
00015 
00016 // use CRLF as opposed to just LF
00017 // internally it uses LF only... this is just to remember what to
00018 // save out as.
00019 #define TEXTED_USES_CR              0x00000001
00020 #define TAB_SIZE                    4
00021 #define DEBUG_TIMES_MSG             8000 // a=0 b=(char*)Str
00022 
00023 extern char Delimiters[];
00024 
00025 class GTextView2 : public GDocView
00026 {
00027     friend class GTextStyle;
00028     friend class GUrl;
00029 
00030 protected:
00031     // Internal classes
00032     enum GTextViewSeek
00033     {
00034         PrevLine,
00035         NextLine,
00036         StartLine,
00037         EndLine
00038     };
00039 
00040     class GTextLine {
00041     public:
00042         int Start;          // Start offset
00043         int Len;            // length of text
00044         GRect r;            // Screen location
00045 
00046         virtual ~GTextLine() {}
00047         bool Overlap(int i)
00048         {
00049             return i>=Start AND i<=Start+Len;
00050         }
00051     };
00052 
00053     class GTextStyle
00054     {
00055     public:
00056         // data
00057         class GTextView2 *View;
00058         int Start;
00059         int Len;
00060         GFont *Font;
00061         COLOUR c;
00062 
00063         // attach
00064         char *Data;
00065 
00066         GTextStyle(class GTextView2 *Tv);
00067 
00068         virtual bool OnMouseClick(GMouse *m) { return false; }
00069         virtual bool OnMenu(GSubMenu *m) { return false; }
00070         virtual void OnMenuClick(int i) {}
00071         virtual char *GetCursor() { return 0; }
00072     };
00073 
00074     // Options
00075     int WrapAtCol;
00076     int WrapType;
00077     bool UrlDetect;
00078     bool AcceptEdit;
00079     bool CrLf;
00080     bool Dirty;
00081     bool AutoIndent;
00082     COLOUR BackColour;
00083 
00084     // Display
00085     GFont *Font;
00086     GFont *BlueUnderline;   // URL display
00087     int LineY;
00088     int Lines;
00089     int LeftMargin;
00090     int SelStart, SelEnd;
00091     int DocOffset;
00092     int MaxX;
00093     bool Blink;
00094     GRect CursorPos;
00095 
00096     List<GTextLine> Line;
00097     List<GTextStyle> Style;     // sorted in 'Start' order
00098 
00099     // History
00100     char *LastFind;
00101     char *LastReplace;
00102     bool MatchCase;
00103     bool MatchWord;
00104 
00105     // Data
00106     char *Text;
00107     int Cursor;
00108     int CharSize;
00109     int Size;
00110     int Alloc;
00111 
00112     // private methods
00113     bool Insert(int At, char *Data, int Len);
00114     bool Delete(int At, int Len);
00115     int HitText(int x, int y);
00116     GTextLine *GetLine(int Offset, int *Index = 0);
00117     void DeleteSelection(char **Cut = 0);
00118     int SeekLine(int Start, GTextViewSeek Where);
00119     int TextWidth(GFont *f, char *s, int Len, int x, int Origin);
00120     
00121     // styles
00122     void InsertStyle(GTextStyle *s);
00123     GTextStyle *GetNextStyle(int Where = -1);
00124     GTextStyle *HitStyle(int i);
00125 
00126     // Overridables
00127     virtual void PourText();
00128     virtual void PourStyle();
00129     virtual void OnFontChange();
00130 
00131     #ifdef _DEBUG
00132     // debug
00133     int _PourTime;
00134     int _StyleTime;
00135     int _PaintTime;
00136     #endif
00137 
00138 public:
00139     // Construction
00140     GTextView2( int Id,
00141                 int x,
00142                 int y,
00143                 int cx,
00144                 int cy,
00145                 GFontType *FontInfo = 0);
00146     ~GTextView2();
00147 
00148     // Data
00149     char *Name();
00150     bool Name(char *s);
00151 
00152     // Font
00153     GFont *GetFont();
00154     void SetFont(GFont *f, bool OwnIt = false);
00155 
00156     // Options
00157     void SetBorder(int b);
00158     void AcceptEdits(bool i);
00159     void SetWrapType(uint8 i);
00160 
00161     // State / Selection
00162     void SetCursor(int i, bool Select, bool ForceFullUpdate = false);
00163     int IndexAt(int x, int y);
00164     bool IsDirty() { return Dirty; }
00165     bool HasSelection();
00166     void UnSelectAll();
00167     void SelectWord(int From);
00168     void SelectAll();
00169     GdcPt2 GetCursor();
00170     int GetLines();
00171     void GetTextExtent(int &x, int &y);
00172 
00173     // File IO
00174     bool Open(char *Name);
00175     bool Save(char *Name);
00176 
00177     // Clipboard IO
00178     bool Cut();
00179     bool Copy();
00180     bool Paste();
00181 
00182     // Actions
00183     bool ClearDirty(bool Ask, char *FileName = 0);
00184     void UpdateScrollBars(bool Reset = false);
00185     bool DoFind();
00186     bool DoReplace();
00187 
00188     // Object Events
00189     bool OnFind(char *Find, bool MatchWord, bool MatchCase);
00190     bool OnReplace(char *Find, char *Replace, bool All, bool MatchWord, bool MatchCase);
00191     bool OnMultiLineTab(bool In);
00192     void OnSetHidden(int Hidden);
00193     void OnPosChange();
00194     void OnCreate();
00195     void OnEscape(GKey &K);
00196     void OnMouseWheel(double Lines);
00197 
00198     // Window Events
00199     void OnFocus(bool f);
00200     void OnMouseClick(GMouse &m);
00201     void OnMouseMove(GMouse &m);
00202     bool OnKey(GKey &k);
00203     void OnPaint(GSurface *pDC);
00204     int OnEvent(GMessage *Msg);
00205     int OnNotify(GView *Ctrl, int Flags);
00206     void OnPulse();
00207     int OnHitTest(int x, int y);
00208 
00209     // Virtuals
00210     virtual void OnEnter(GKey &k);
00211     virtual void OnUrl(char *Url);
00212 };
00213 
00214 #endif

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