~ubuntu-branches/ubuntu/hardy/codeblocks/hardy-backports

« back to all changes in this revision

Viewing changes to src/plugins/contrib/codesnippets/edit.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Casadevall
  • Date: 2008-07-17 04:39:23 UTC
  • Revision ID: james.westby@ubuntu.com-20080717043923-gmsy5cwkdjswghkm
Tags: upstream-8.02
ImportĀ upstreamĀ versionĀ 8.02

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
// File:        edit.h
 
3
// Purpose:     wxScintilla test module
 
4
// Maintainer:  Otto Wyss
 
5
// Created:     2003-09-01
 
6
// Copyright:   (c) 2004 wxCode
 
7
// Licence:     wxWindows
 
8
//////////////////////////////////////////////////////////////////////////////
 
9
/*
 
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
 
13
 
 
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.
 
18
 
 
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.
 
23
 
 
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.
 
27
*/
 
28
// RCS-ID: $Id: edit.h 106 2007-12-01 18:31:55Z Pecan $
 
29
 
 
30
#ifndef _EDIT_H_
 
31
#define _EDIT_H_
 
32
 
 
33
//----------------------------------------------------------------------------
 
34
// informations
 
35
//----------------------------------------------------------------------------
 
36
 
 
37
 
 
38
//----------------------------------------------------------------------------
 
39
// headers
 
40
//----------------------------------------------------------------------------
 
41
 
 
42
//! wxWindows headers
 
43
 
 
44
//! wxScintilla headers
 
45
#include <wxscintilla/include/wx/wxscintilla.h>  // scintilla edit control
 
46
 
 
47
//! application headers
 
48
#include "prefs.h"       // preferences
 
49
#include "finddialogs.h"       // preferences
 
50
 
 
51
 
 
52
//============================================================================
 
53
// declarations
 
54
//============================================================================
 
55
 
 
56
class EditPrint;
 
57
class EditProperties;
 
58
class DragScrollEvents;
 
59
 
 
60
 
 
61
//----------------------------------------------------------------------------
 
62
//! Edit
 
63
class Edit: public wxScintilla {
 
64
    friend class EditProperties;
 
65
    friend class EditPrint;
 
66
 
 
67
public:
 
68
    //! constructor
 
69
    Edit (wxWindow *parent, wxWindowID id = -1,
 
70
          const wxPoint &pos = wxDefaultPosition,
 
71
          const wxSize &size = wxDefaultSize,
 
72
          long style = wxSUNKEN_BORDER|wxVSCROLL
 
73
         );
 
74
 
 
75
    //! destructor
 
76
    ~Edit ();
 
77
 
 
78
    // event handlers
 
79
    // common
 
80
    void OnSize( wxSizeEvent &event );
 
81
    // edit
 
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);
 
88
    // find
 
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);
 
95
    // replace
 
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);
 
101
 
 
102
    void OnBraceMatch (wxCommandEvent &event);
 
103
    void OnBraceMatchUI (wxUpdateUIEvent &event);
 
104
 
 
105
 
 
106
    void OnGoto (wxCommandEvent &event);
 
107
    void OnGotoUI (wxUpdateUIEvent &event);
 
108
 
 
109
    void OnEditIndentInc (wxCommandEvent &event);
 
110
    void OnEditIndentRed (wxCommandEvent &event);
 
111
    void OnEditSelectAll (wxCommandEvent &event);
 
112
    void OnEditSelectLine (wxCommandEvent &event);
 
113
    //! view
 
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);
 
125
    //! extra
 
126
    void OnChangeCase (wxCommandEvent &event);
 
127
    void OnConvertEOL (wxCommandEvent &event);
 
128
    // styled text
 
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);
 
135
 
 
136
 
 
137
    //! language/lexer
 
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;};
 
142
 
 
143
    //! load/save file
 
144
    bool LoadFile ();
 
145
    bool LoadFile (const wxString &filename);
 
146
    bool SaveFile ();
 
147
    bool SaveFile (const wxString &filename);
 
148
    bool Modified ();
 
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)
 
152
 
 
153
private:
 
154
 
 
155
    int FindString(const wxString &str, int flags);
 
156
 
 
157
    void    InitDragScroller();
 
158
    DragScrollEvents* pDragScroller;        //(pecan 2007/3/29)
 
159
    wxColour          m_SysWinBkgdColour;   //(pecan 2007/3/27)
 
160
    // file
 
161
    wxString m_filename;
 
162
 
 
163
    // lanugage properties
 
164
    LanguageInfo const* m_language;
 
165
 
 
166
    // margin variables
 
167
    int m_LineNrID;
 
168
    int m_LineNrMargin;
 
169
    int m_FoldingID;
 
170
    int m_FoldingMargin;
 
171
    int m_DividerID;
 
172
 
 
173
    // find variables
 
174
    myFindReplaceDlg* m_FindReplaceDlg;
 
175
    int         m_startpos;
 
176
    bool        m_replace;
 
177
    myGotoDlg*  m_GotoDlg;
 
178
 
 
179
    DECLARE_EVENT_TABLE()
 
180
};
 
181
 
 
182
//----------------------------------------------------------------------------
 
183
//! EditProperties
 
184
class EditProperties: public wxDialog {
 
185
 
 
186
public:
 
187
 
 
188
    //! constructor
 
189
    EditProperties (Edit *edit, long style = 0);
 
190
 
 
191
private:
 
192
 
 
193
};
 
194
 
 
195
//----------------------------------------------------------------------------
 
196
//! EditPrint
 
197
class EditPrint: public wxPrintout
 
198
// ----------------------------------------------------------------------------
 
199
{
 
200
 
 
201
public:
 
202
 
 
203
    //! constructor
 
204
    EditPrint (Edit *edit, const wxChar *title = _T(""));
 
205
 
 
206
    //! event handlers
 
207
    bool OnPrintPage (int page);
 
208
    bool OnBeginDocument (int startPage, int endPage);
 
209
 
 
210
    //! print functions
 
211
    bool HasPage (int page);
 
212
    void GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
 
213
 
 
214
private:
 
215
    Edit *m_edit;
 
216
    int m_printed;
 
217
    wxRect m_pageRect;
 
218
    wxRect m_printRect;
 
219
 
 
220
    bool PrintScaling (wxDC *dc);
 
221
};
 
222
 
 
223
#endif // _EDIT_H_
 
224
 
 
225
#ifndef DRAGSCROLL_H
 
226
#define DRAGSCROLL_H
 
227
 
 
228
// ----------------------------------------------------------------------------
 
229
//      MOUSE DRAG and SCROLL CLASS
 
230
// ----------------------------------------------------------------------------
 
231
// Dragging modes
 
232
#define DRAG_NONE     0
 
233
#define DRAG_START    1
 
234
#define DRAG_DRAGGING 2
 
235
// ----------------------------------------------------------------------------
 
236
class DragScrollEvents : public wxEvtHandler
 
237
// ----------------------------------------------------------------------------
 
238
{
 
239
 
 
240
    public:
 
241
        DragScrollEvents(wxWindow *window);
 
242
        ~DragScrollEvents();
 
243
 
 
244
        void OnMouseEvent(wxMouseEvent& event);
 
245
    private:
 
246
 
 
247
 
 
248
        wxWindow*   m_Window;
 
249
        wxWindow*   m_pMS_Window;
 
250
        int         m_DragMode;
 
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)
 
259
        int         m_Direction;
 
260
        unsigned    m_gtkContextDelay;
 
261
 
 
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
 
271
 
 
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; }
 
281
 
 
282
 
 
283
        bool KeyDown(wxMouseEvent& event)
 
284
            { if ( 0 ==  GetMouseDragKey() )
 
285
                return event.RightDown();
 
286
                return event.MiddleDown();
 
287
            }
 
288
        bool KeyIsDown(wxMouseEvent& event)
 
289
            { if ( 0 ==  GetMouseDragKey() )
 
290
                return event.RightIsDown();
 
291
                return event.MiddleIsDown();
 
292
            }
 
293
        bool KeyUp(wxMouseEvent& event)
 
294
            { if ( 0 ==  GetMouseDragKey() )
 
295
                return event.RightUp();
 
296
                return event.MiddleUp();
 
297
            }
 
298
        int GetUserDragKey()
 
299
            { return ( GetMouseDragKey() ? wxMOUSE_BTN_MIDDLE:wxMOUSE_BTN_RIGHT );}
 
300
 
 
301
        DECLARE_EVENT_TABLE()
 
302
};
 
303
 
 
304
// ----------------------------------------------------------------------------
 
305
#endif //DragScrollEvents