edit.h 5.1 KB

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