Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

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 #define INSERT_MARK "insert"
00035 
00036 typedef VDKValueList<VDKString> TokenList;
00037 typedef VDKValueListIterator<VDKString> TokenListIterator;
00038 /*
00039     Syntax editor class
00040 */
00050 class VDKEditor : public VDKObject
00051 {
00052   // signal section
00053  private:
00054   virtual void LocalConnect();
00055   static int TabHandler (GtkWidget *widget,
00056                          GdkEvent *ev,
00057                          gpointer gp);
00058   static void HandleRealize(GtkWidget*, gpointer);
00059  protected:
00060   TokenList* tokenlist;
00061   GtkSourceBuffer* buffer;
00062   GtkWidget* view;
00063   bool MakeCompletion(const char* word);
00064 
00065   void ShowTipWindow(char* word);
00066   void AddToken();
00067   int ShowParenMatch(int start,char keyval,
00068                                 GtkWidget* widget,
00069                                 bool insert, int restore);
00070   static int OnKeyRelease (GtkWidget *widget,
00071                     GdkEvent *ev,
00072                     gpointer gp); 
00073   static void OnBufferChanged(GtkWidget* buf, gpointer gp);
00074   public:
00086   VDKEditor(VDKForm* owner, GtkSourceBuffer* buff = NULL);
00090   virtual ~VDKEditor();
00098   static TokenList* LoadTokens( const char* filename);
00104   TokenList* SetTokens(TokenList* tkl = NULL)
00105   { 
00106     if(tkl) 
00107       tokenlist = tkl; 
00108     return tokenlist; 
00109   }
00110 
00111   virtual void SetForeground(VDKRgb rgb, 
00112                              GtkStateType state = GTK_STATE_NORMAL);
00113 
00114   virtual void SetBackground(VDKRgb color, 
00115                              GtkStateType state = GTK_STATE_NORMAL);
00116 
00117   virtual void SetFont(VDKFont* font);
00118 
00122   GtkSourceBuffer* Buffer(void) { return buffer; }
00127   void Scroll (int pointer = -1, int margin = 0);
00131   void Scroll(int line, int col, int margin = 0);
00137   char* GetWord(int pos = -1);
00138   /*
00139   Sets/gets syntax higlighting
00140   */
00141   VDKReadWriteValueProp<VDKEditor,bool> Syntax;
00142 
00147   VDKReadWriteValueProp<VDKEditor,int>   Pointer;
00151   VDKReadWriteValueProp<VDKEditor,int>   Column;
00155   VDKReadWriteValueProp<VDKEditor,int>   Line;
00156   /*
00157   Gets buffer length in chars
00158   */
00159   VDKReadOnlyValueProp<VDKEditor,unsigned int> Length;
00160   /*
00161   Sets/gets text view editable
00162   */
00163   VDKReadWriteValueProp<VDKEditor,bool> Editable;
00164   /*
00165   Sets/gets max undo (dummy for now)
00166   */
00167   VDKReadWriteValueProp<VDKEditor,unsigned int> MaxUndo;
00168   /*
00169   Sets/gets text line auto select (dummy for now)
00170   */
00171   VDKReadWriteValueProp<VDKEditor,bool> LineAutoSelect;
00172   /*
00173   Sets/gets text show line numbers (dummy for now)
00174   */
00175   VDKReadWriteValueProp<VDKEditor,bool> ShowLineNumbers;
00179   VDKReadOnlyValueProp<VDKEditor,int> FirstVisibleLine;
00183   VDKReadOnlyValueProp<VDKEditor,int> LastVisibleLine;
00187   VDKReadWriteValueProp<VDKEditor,bool>   Changed;
00192   bool LoadFromFile(const char* filename);
00196   void Clear();
00207   gchar* GetChars(int start = 0, int end = -1);
00211   bool SaveToFile( const char* filename);
00212   // dummy
00213   bool Undo();
00217   void Eol() { TextInsert("\n"); }
00223   void TextInsert(const char* txt, int nchar = -1);
00227   void  ForwardDelete(int nchars);
00231   void  BackwardDelete(int nchars);
00237   bool IsLineVisible(int line)
00238     { 
00239       return (line >= FirstVisibleLine) && 
00240       (line <= LastVisibleLine);
00241     }
00247   int GetLineAtOffset(int offset);
00265   void InstallSyntaxTable (VDKColor *key_color,
00266                                VDKFont  *key_font,
00267                                VDKColor *gtk_color,
00268                                VDKFont  *gtk_font,
00269                                VDKColor *macro_color,
00270                                VDKFont  *macro_font,
00271                                VDKColor *pp_color,
00272                                VDKFont  *pp_font,
00273                        VDKColor *const_color,
00274                                VDKFont  *const_font,
00275                       VDKColor *comment_color,
00276                                VDKFont  *comment_font );
00280   void ClearSyntaxTable();
00285   void ScrollToPos (int pointer = -1, int margin = 0);
00289   void ScrollToLine(int line, int col, int margin = 0);
00293   void SelectText(int start, int end);
00297   void UnselectText();
00298   /*
00299   properties setting/getting functions
00300   */
00301   void SetSyntax(bool f);
00302   void SetPointer(int p);
00303   int GetPointer();
00304   void SetLine(int r);
00305   int GetLine();
00306   void SetColumn(int r);
00307   int GetColumn();
00308   unsigned int GetLength();
00309   bool GetEditable();
00310   void SetEditable(bool f);
00311   void SetShowLineNumbers(bool f);
00312   bool GetShowLineNumbers(void);
00313   int GetFirstVisibleLine();
00314   int GetLastVisibleLine();
00315   bool GetChanged();
00316   void SetChanged(bool f);
00317   void SetMaxUndo(int );
00318 };
00319 /*
00320 showed hints forms
00321 */
00322 class Tipwin: public VDKForm
00323 {
00324   VDKLabel*  label;  
00325   char* tip;
00326 public:
00327   Tipwin(VDKForm* owner, char* tip):
00328     VDKForm(owner,NULL,v_box,GTK_WINDOW_POPUP),tip(tip)
00329     {}
00330   ~Tipwin() {}
00331   void Setup(void);
00332 
00333 };
00334 #endif

Generated on Sat May 4 21:58:35 2002 for vdk 2.0.1 by doxygen1.2.15