1
//////////////////////////////////////////////////////////////////////////////
3
// Purpose: wxScintilla test module
4
// Maintainer: Otto Wyss
6
// Copyright: (c) 2004 wxCode
8
//////////////////////////////////////////////////////////////////////////////
10
This file is part of Code Snippets, a plugin for Code::Blocks
11
Copyright (C) 2006 Arto Jonsson
12
Copyright (C) 2007 Pecan Heber
14
This program is free software; you can redistribute it and/or
15
modify it under the terms of the GNU General Public License
16
as published by the Free Software Foundation; either version 2
17
of the License, or (at your option) any later version.
19
This program is distributed in the hope that it will be useful,
20
but WITHOUT ANY WARRANTY; without even the implied warranty of
21
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
GNU General Public License for more details.
24
You should have received a copy of the GNU General Public License
25
along with this program; if not, write to the Free Software
26
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28
// RCS-ID: $Id: edit.h 106 2007-12-01 18:31:55Z Pecan $
33
//----------------------------------------------------------------------------
35
//----------------------------------------------------------------------------
38
//----------------------------------------------------------------------------
40
//----------------------------------------------------------------------------
44
//! wxScintilla headers
45
#include <wxscintilla/include/wx/wxscintilla.h> // scintilla edit control
47
//! application headers
48
#include "prefs.h" // preferences
49
#include "finddialogs.h" // preferences
52
//============================================================================
54
//============================================================================
58
class DragScrollEvents;
61
//----------------------------------------------------------------------------
63
class Edit: public wxScintilla {
64
friend class EditProperties;
65
friend class EditPrint;
69
Edit (wxWindow *parent, wxWindowID id = -1,
70
const wxPoint &pos = wxDefaultPosition,
71
const wxSize &size = wxDefaultSize,
72
long style = wxSUNKEN_BORDER|wxVSCROLL
80
void OnSize( wxSizeEvent &event );
82
void OnEditRedo (wxCommandEvent &event);
83
void OnEditUndo (wxCommandEvent &event);
84
void OnEditClear (wxCommandEvent &event);
85
void OnEditCut (wxCommandEvent &event);
86
void OnEditCopy (wxCommandEvent &event);
87
void OnEditPaste (wxCommandEvent &event);
89
void OnFind (wxCommandEvent &event);
90
void OnFindUI (wxUpdateUIEvent &event);
91
void OnFindNext (wxCommandEvent &event);
92
void OnFindNextUI (wxUpdateUIEvent &event);
93
void OnFindPrev (wxCommandEvent &event);
94
void OnFindPrevUI (wxUpdateUIEvent &event);
96
void OnReplace (wxCommandEvent &event);
97
void OnReplaceUI (wxUpdateUIEvent &event);
98
void OnReplaceNext (wxCommandEvent &event);
99
void OnReplaceNextUI (wxUpdateUIEvent &event);
100
void OnReplaceAll (wxCommandEvent& event);
102
void OnBraceMatch (wxCommandEvent &event);
103
void OnBraceMatchUI (wxUpdateUIEvent &event);
106
void OnGoto (wxCommandEvent &event);
107
void OnGotoUI (wxUpdateUIEvent &event);
109
void OnEditIndentInc (wxCommandEvent &event);
110
void OnEditIndentRed (wxCommandEvent &event);
111
void OnEditSelectAll (wxCommandEvent &event);
112
void OnEditSelectLine (wxCommandEvent &event);
114
void OnHilightLang (wxCommandEvent &event);
115
void OnDisplayEOL (wxCommandEvent &event);
116
void OnIndentGuide (wxCommandEvent &event);
117
void OnLineNumber (wxCommandEvent &event);
118
void OnLongLineOn (wxCommandEvent &event);
119
void OnWhiteSpace (wxCommandEvent &event);
120
void OnFoldToggle (wxCommandEvent &event);
121
void OnSetOverType (wxCommandEvent &event);
122
void OnSetReadOnly (wxCommandEvent &event);
123
void OnWrapmodeOn (wxCommandEvent &event);
124
void OnUseCharset (wxCommandEvent &event);
126
void OnChangeCase (wxCommandEvent &event);
127
void OnConvertEOL (wxCommandEvent &event);
129
void OnMarginClick (wxScintillaEvent &event);
130
void OnCharAdded (wxScintillaEvent &event);
131
void OnEnterWindow(wxMouseEvent& event);
132
void OnLeaveWindow(wxMouseEvent& event);
133
void OnScroll(wxScrollEvent& event);
134
void OnScrollWin(wxScrollWinEvent& event);
138
wxString DeterminePrefs (const wxString &filename);
139
bool InitializePrefs (const wxString &filename);
140
bool UserSettings (const wxString &filename);
141
LanguageInfo const* GetLanguageInfo () {return m_language;};
145
bool LoadFile (const wxString &filename);
147
bool SaveFile (const wxString &filename);
149
wxString GetFilename () {return m_filename;};
150
void SetFilename (const wxString &filename) {m_filename = filename;};
151
int GetLongestLinePixelWidth( int top_line = -1, int bottom_line = -1); //(pecan 2007/4/04)
155
int FindString(const wxString &str, int flags);
157
void InitDragScroller();
158
DragScrollEvents* pDragScroller; //(pecan 2007/3/29)
159
wxColour m_SysWinBkgdColour; //(pecan 2007/3/27)
163
// lanugage properties
164
LanguageInfo const* m_language;
174
myFindReplaceDlg* m_FindReplaceDlg;
177
myGotoDlg* m_GotoDlg;
179
DECLARE_EVENT_TABLE()
182
//----------------------------------------------------------------------------
184
class EditProperties: public wxDialog {
189
EditProperties (Edit *edit, long style = 0);
195
//----------------------------------------------------------------------------
197
class EditPrint: public wxPrintout
198
// ----------------------------------------------------------------------------
204
EditPrint (Edit *edit, const wxChar *title = _T(""));
207
bool OnPrintPage (int page);
208
bool OnBeginDocument (int startPage, int endPage);
211
bool HasPage (int page);
212
void GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
220
bool PrintScaling (wxDC *dc);
228
// ----------------------------------------------------------------------------
229
// MOUSE DRAG and SCROLL CLASS
230
// ----------------------------------------------------------------------------
234
#define DRAG_DRAGGING 2
235
// ----------------------------------------------------------------------------
236
class DragScrollEvents : public wxEvtHandler
237
// ----------------------------------------------------------------------------
241
DragScrollEvents(wxWindow *window);
244
void OnMouseEvent(wxMouseEvent& event);
249
wxWindow* m_pMS_Window;
251
wxPoint m_DragStartPos;
252
wxObject* m_pEvtObject;
253
bool m_MouseHasMoved;
254
double m_MouseMoveToLineMoveRatio;
255
double m_RatioX, m_RatioY;
256
int m_StartX, m_StartY;
257
int m_InitX, m_InitY;
258
// Scroll Direction move -1(mouse direction) +1(reverse mouse direction)
260
unsigned m_gtkContextDelay;
262
bool MouseDragScrollEnabled ; //Enable/Disable mouse event handler
263
bool MouseEditorFocusEnabled; //Enable/Disable mouse focus() editor
264
bool MouseFocusEnabled ; //focus follows mouse
265
int MouseDragDirection ; //Move with or opposite mouse
266
int MouseDragKey ; //Right or Middle mouse key
267
int MouseDragSensitivity ; //Adaptive speed sensitivity
268
int MouseToLineRatio ; //Percentage of mouse moves that make a line
269
//bool MouseRightKeyCtrl ; //Hide Right mouse down from ListCtrl windows
270
int MouseContextDelay ; //Linux context menu delay to catch possible mouse scroll move
272
bool GetMouseDragScrollEnabled() { return MouseDragScrollEnabled; }
273
bool GetMouseEditorFocusEnabled(){ return MouseEditorFocusEnabled; }
274
int GetMouseDragDirection() { return MouseDragDirection; }
275
bool GetMouseFocusEnabled() { return MouseFocusEnabled; }
276
int GetMouseDragKey() { return MouseDragKey; }
277
int GetMouseDragSensitivity() { return MouseDragSensitivity; }
278
int GetMouseToLineRatio() { return MouseToLineRatio; }
279
//int GetMouseRightKeyCtrl() { return MouseRightKeyCtrl; }
280
int GetMouseContextDelay() { return MouseContextDelay; }
283
bool KeyDown(wxMouseEvent& event)
284
{ if ( 0 == GetMouseDragKey() )
285
return event.RightDown();
286
return event.MiddleDown();
288
bool KeyIsDown(wxMouseEvent& event)
289
{ if ( 0 == GetMouseDragKey() )
290
return event.RightIsDown();
291
return event.MiddleIsDown();
293
bool KeyUp(wxMouseEvent& event)
294
{ if ( 0 == GetMouseDragKey() )
295
return event.RightUp();
296
return event.MiddleUp();
299
{ return ( GetMouseDragKey() ? wxMOUSE_BTN_MIDDLE:wxMOUSE_BTN_RIGHT );}
301
DECLARE_EVENT_TABLE()
304
// ----------------------------------------------------------------------------
305
#endif //DragScrollEvents