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

vdkeditor.h

00001 /* 00002 * =========================== 00003 * VDK Visual Development Kit 00004 * Version 2.0.0 00005 * February 2001 00006 * =========================== 00007 * 00008 * Copyright (C) 1998,199,2000,2001 Mario Motta 00009 * Developed by Mario Motta <mmotta@guest.net> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Library General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00024 * 02111-1307, USA. 00025 */ 00026 00027 #ifndef _vdkeditor_h 00028 #define _vdkeditor_h 00029 #if HAVE_CONFIG_H 00030 #include <config.h> 00031 #endif 00032 #include <vdk/vdk.h> 00033 #include <vdk/gtksourceview.h> 00034 #include <vdk/rawpixbuf.h> 00035 #define INSERT_MARK "insert" 00036 00037 typedef VDKValueList<VDKString> TokenList; 00038 typedef VDKValueListIterator<VDKString> TokenListIterator; 00039 /* 00040 Syntax editor class 00041 */ 00051 class VDKEditor : public VDKObject 00052 { 00053 // signal section 00054 private: 00055 virtual void LocalConnect(); 00056 static int TabHandler (GtkWidget *widget, 00057 GdkEvent *ev, 00058 gpointer gp); 00059 static void HandleRealize(GtkWidget*, gpointer); 00060 protected: 00061 TokenList* tokenlist; 00062 GtkSourceBuffer* buffer; 00063 GtkWidget* view; 00064 bool MakeCompletion(const char* word); 00065 00066 void ShowTipWindow(char* word); 00067 void AddToken(); 00068 int ShowParenMatch(int start,char keyval, 00069 GtkWidget* widget, 00070 bool insert, int restore); 00071 static int OnKeyRelease (GtkWidget *widget, 00072 GdkEvent *ev, 00073 gpointer gp); 00074 static void OnBufferChanged(GtkWidget* buf, gpointer gp); 00075 public: 00087 VDKEditor(VDKForm* owner, GtkSourceBuffer* buff = NULL); 00091 virtual ~VDKEditor(); 00099 static TokenList* LoadTokens( const char* filename); 00105 TokenList* SetTokens(TokenList* tkl = NULL) 00106 { 00107 if(tkl) 00108 tokenlist = tkl; 00109 return tokenlist; 00110 } 00111 00112 virtual void SetForeground(VDKRgb rgb, 00113 GtkStateType state = GTK_STATE_NORMAL); 00114 00115 virtual void SetBackground(VDKRgb color, 00116 GtkStateType state = GTK_STATE_NORMAL); 00117 00118 virtual void SetFont(VDKFont* font); 00119 00123 GtkSourceBuffer* Buffer(void) { return buffer; } 00128 void Scroll (int pointer = -1, int margin = 0); 00132 void Scroll(int line, int col, int margin = 0); 00138 char* GetWord(int pos = -1); 00139 /* 00140 Sets/gets syntax higlighting 00141 */ 00142 VDKReadWriteValueProp<VDKEditor,bool> Syntax; 00143 00148 VDKReadWriteValueProp<VDKEditor,int> Pointer; 00152 VDKReadWriteValueProp<VDKEditor,int> Column; 00156 VDKReadWriteValueProp<VDKEditor,int> Line; 00157 /* 00158 Gets buffer length in chars 00159 */ 00160 VDKReadOnlyValueProp<VDKEditor,unsigned int> Length; 00161 /* 00162 Sets/gets text view editable 00163 */ 00164 VDKReadWriteValueProp<VDKEditor,bool> Editable; 00165 /* 00166 Sets/gets tab stops 00167 */ 00168 VDKReadWriteValueProp<VDKEditor,int> TabStop; 00169 /* 00170 Sets/gets max undo (dummy for now) 00171 */ 00172 VDKReadWriteValueProp<VDKEditor,unsigned int> MaxUndo; 00173 /* 00174 Sets/gets text line auto select (dummy for now) 00175 */ 00176 VDKReadWriteValueProp<VDKEditor,bool> LineAutoSelect; 00177 /* 00178 Sets/gets text show line numbers (dummy for now) 00179 */ 00180 VDKReadWriteValueProp<VDKEditor,bool> ShowLineNumbers; 00184 VDKReadOnlyValueProp<VDKEditor,int> FirstVisibleLine; 00188 VDKReadOnlyValueProp<VDKEditor,int> LastVisibleLine; 00192 VDKReadWriteValueProp<VDKEditor,bool> Changed; 00197 bool LoadFromFile(const char* filename); 00201 void Clear(); 00212 gchar* GetChars(int start = 0, int end = -1); 00216 bool SaveToFile( const char* filename); 00217 // dummy 00218 bool Undo(); 00222 void Eol() { TextInsert("\n"); } 00228 void TextInsert(const char* txt, int nchar = -1); 00232 void ForwardDelete(int nchars); 00236 void BackwardDelete(int nchars); 00242 bool IsLineVisible(int line) 00243 { 00244 return (line >= FirstVisibleLine) && 00245 (line <= LastVisibleLine); 00246 } 00252 int GetLineAtOffset(int offset); 00270 void InstallSyntaxTable (VDKColor *key_color, 00271 VDKFont *key_font, 00272 VDKColor *gtk_color, 00273 VDKFont *gtk_font, 00274 VDKColor *macro_color, 00275 VDKFont *macro_font, 00276 VDKColor *pp_color, 00277 VDKFont *pp_font, 00278 VDKColor *const_color, 00279 VDKFont *const_font, 00280 VDKColor *comment_color, 00281 VDKFont *comment_font ); 00285 void ClearSyntaxTable(); 00290 void ScrollToPos (int pointer = -1, int margin = 0); 00294 void ScrollToLine(int line, int col, int margin = 0); 00298 void SelectText(int start, int end); 00302 void UnselectText(); 00309 bool AddMarkIcon(VDKPixbuf* image, const char * icon_key, bool overwrite = true); 00315 void AddLineMark(int line, const char* icon_key); 00321 void RemoveLineMark(int line, const char* icon_key); 00326 void RemoveLineMarks(int line); 00330 void RemoveAllLineMarks(); 00331 /* 00332 properties setting/getting functions 00333 */ 00334 void SetSyntax(bool f); 00335 void SetPointer(int p); 00336 int GetPointer(); 00337 void SetLine(int r); 00338 int GetLine(); 00339 void SetTabStop(int r); 00340 int GetTabStop(); 00341 void SetColumn(int r); 00342 int GetColumn(); 00343 unsigned int GetLength(); 00344 bool GetEditable(); 00345 void SetEditable(bool f); 00346 void SetShowLineNumbers(bool f); 00347 bool GetShowLineNumbers(void); 00348 int GetFirstVisibleLine(); 00349 int GetLastVisibleLine(); 00350 bool GetChanged(); 00351 void SetChanged(bool f); 00352 void SetMaxUndo(int ); 00353 }; 00354 /* 00355 showed hints forms 00356 */ 00357 class Tipwin: public VDKForm 00358 { 00359 VDKLabel* label; 00360 char* tip; 00361 public: 00362 Tipwin(VDKForm* owner, char* tip): 00363 VDKForm(owner,NULL,v_box,GTK_WINDOW_POPUP),tip(tip) 00364 {} 00365 ~Tipwin() {} 00366 void Setup(void); 00367 00368 }; 00369 #endif

Generated on Tue Aug 17 12:39:51 2004 for vdk 2.4.0 by doxygen 1.3.7