1 ////////////////////////////////////////////////////////////////////////////// 2 // File: edit.h 3 // Purpose: STC test module 4 // Maintainer: Wyo 5 // Created: 2003-09-01 6 // Copyright: (c) wxGuide 7 // Licence: wxWindows licence 8 ////////////////////////////////////////////////////////////////////////////// 9 10 #ifndef _EDIT_H_ 11 #define _EDIT_H_ 12 13 //---------------------------------------------------------------------------- 14 // information 15 //---------------------------------------------------------------------------- 16 17 18 //---------------------------------------------------------------------------- 19 // headers 20 //---------------------------------------------------------------------------- 21 22 //! wxWidgets headers 23 24 //! wxWidgets/contrib headers 25 #include "wx/stc/stc.h" // styled text control 26 27 //! application headers 28 #include "prefs.h" // preferences 29 30 31 //============================================================================ 32 // declarations 33 //============================================================================ 34 35 class EditPrint; 36 class EditProperties; 37 38 39 //---------------------------------------------------------------------------- 40 //! Edit 41 class Edit: public wxStyledTextCtrl { 42 friend class EditProperties; 43 friend class EditPrint; 44 45 public: 46 //! constructor 47 Edit (wxWindow *parent, wxWindowID id = wxID_ANY, 48 const wxPoint &pos = wxDefaultPosition, 49 const wxSize &size = wxDefaultSize, 50 long style = 51 #ifndef __WXMAC__ 52 wxSUNKEN_BORDER| 53 #endif 54 wxVSCROLL 55 ); 56 57 //! destructor 58 ~Edit (); 59 60 // event handlers 61 // common 62 void OnSize( wxSizeEvent &event ); 63 // edit 64 void OnEditRedo (wxCommandEvent &event); 65 void OnEditUndo (wxCommandEvent &event); 66 void OnEditClear (wxCommandEvent &event); 67 void OnEditCut (wxCommandEvent &event); 68 void OnEditCopy (wxCommandEvent &event); 69 void OnEditPaste (wxCommandEvent &event); 70 // find 71 void OnFind (wxCommandEvent &event); 72 void OnFindNext (wxCommandEvent &event); 73 void OnReplace (wxCommandEvent &event); 74 void OnReplaceNext (wxCommandEvent &event); 75 void OnBraceMatch (wxCommandEvent &event); 76 void OnGoto (wxCommandEvent &event); 77 void OnEditIndentInc (wxCommandEvent &event); 78 void OnEditIndentRed (wxCommandEvent &event); 79 void OnEditSelectAll (wxCommandEvent &event); 80 void OnEditSelectLine (wxCommandEvent &event); 81 //! view 82 void OnHilightLang (wxCommandEvent &event); 83 void OnDisplayEOL (wxCommandEvent &event); 84 void OnIndentGuide (wxCommandEvent &event); 85 void OnLineNumber (wxCommandEvent &event); 86 void OnLongLineOn (wxCommandEvent &event); 87 void OnWhiteSpace (wxCommandEvent &event); 88 void OnFoldToggle (wxCommandEvent &event); 89 void OnSetOverType (wxCommandEvent &event); 90 void OnSetReadOnly (wxCommandEvent &event); 91 void OnWrapmodeOn (wxCommandEvent &event); 92 void OnUseCharset (wxCommandEvent &event); 93 // annotations 94 void OnAnnotationAdd(wxCommandEvent& event); 95 void OnAnnotationRemove(wxCommandEvent& event); 96 void OnAnnotationClear(wxCommandEvent& event); 97 void OnAnnotationStyle(wxCommandEvent& event); 98 //! extra 99 void OnChangeCase (wxCommandEvent &event); 100 void OnConvertEOL (wxCommandEvent &event); 101 // stc 102 void OnMarginClick (wxStyledTextEvent &event); 103 void OnCharAdded (wxStyledTextEvent &event); 104 void OnKey (wxStyledTextEvent &event); 105 106 void OnKeyDown(wxKeyEvent &event); 107 108 //! language/lexer 109 wxString DeterminePrefs (const wxString &filename); 110 bool InitializePrefs (const wxString &filename); 111 bool UserSettings (const wxString &filename); GetLanguageInfo()112 LanguageInfo const* GetLanguageInfo () {return m_language;}; 113 114 //! load/save file 115 bool LoadFile (); 116 bool LoadFile (const wxString &filename); 117 bool SaveFile (); 118 bool SaveFile (const wxString &filename); 119 bool Modified (); GetFilename()120 wxString GetFilename () {return m_filename;}; SetFilename(const wxString & filename)121 void SetFilename (const wxString &filename) {m_filename = filename;}; 122 123 private: 124 // file 125 wxString m_filename; 126 127 // language properties 128 LanguageInfo const* m_language; 129 130 // margin variables 131 int m_LineNrID; 132 int m_LineNrMargin; 133 int m_FoldingID; 134 int m_FoldingMargin; 135 int m_DividerID; 136 137 wxDECLARE_EVENT_TABLE(); 138 }; 139 140 //---------------------------------------------------------------------------- 141 //! EditProperties 142 class EditProperties: public wxDialog { 143 144 public: 145 146 //! constructor 147 EditProperties (Edit *edit, long style = 0); 148 149 private: 150 151 }; 152 153 #if wxUSE_PRINTING_ARCHITECTURE 154 155 //---------------------------------------------------------------------------- 156 //! EditPrint 157 class EditPrint: public wxPrintout { 158 159 public: 160 161 //! constructor 162 EditPrint (Edit *edit, const wxChar *title = wxT("")); 163 164 //! event handlers 165 bool OnPrintPage (int page); 166 bool OnBeginDocument (int startPage, int endPage); 167 168 //! print functions 169 bool HasPage (int page); 170 void GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); 171 172 private: 173 Edit *m_edit; 174 int m_printed; 175 wxRect m_pageRect; 176 wxRect m_printRect; 177 178 bool PrintScaling (wxDC *dc); 179 }; 180 181 #endif // wxUSE_PRINTING_ARCHITECTURE 182 183 #endif // _EDIT_H_ 184