~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/HexEditor/HexEditPanel.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is part of HexEditor plugin for Code::Blocks Studio
 
3
* Copyright (C) 2008-2009 Bartlomiej Swiecki
 
4
*
 
5
* HexEditor plugin is free software; you can redistribute it and/or modify
 
6
* it under the terms of the GNU General Public License as published by
 
7
* the Free Software Foundation; either version 3 of the License, or
 
8
* (at your option) any later version.
 
9
*
 
10
* HexEditor pluging is distributed in the hope that it will be useful,
 
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
13
* GNU General Public License for more details.
 
14
*
 
15
* You should have received a copy of the GNU General Public License
 
16
* along with HexEditor. If not, see <http://www.gnu.org/licenses/>.
 
17
*
 
18
* $Revision: 5867 $
 
19
* $Id: HexEditPanel.h 5867 2009-10-20 08:34:02Z mortenmacfly $
 
20
* $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/contrib/HexEditor/HexEditPanel.h $
 
21
*/
 
22
 
 
23
#ifndef HEXEDITPANEL_H
 
24
#define HEXEDITPANEL_H
 
25
 
 
26
//(*Headers(HexEditPanel)
 
27
#include <wx/scrolbar.h>
 
28
#include <wx/checkbox.h>
 
29
#include <wx/sizer.h>
 
30
#include <wx/button.h>
 
31
#include <wx/menu.h>
 
32
#include <wx/panel.h>
 
33
#include <wx/statline.h>
 
34
#include <wx/stattext.h>
 
35
#include <wx/textctrl.h>
 
36
#include <wx/timer.h>
 
37
//*)
 
38
 
 
39
#include <editorbase.h>
 
40
#include <vector>
 
41
#include <set>
 
42
 
 
43
#include "FileContentBase.h"
 
44
#include "ExpressionPreprocessed.h"
 
45
#include "HexEditViewBase.h"
 
46
 
 
47
class DigitView;
 
48
 
 
49
class HexEditPanel: public EditorBase
 
50
{
 
51
    public:
 
52
 
 
53
        HexEditPanel( const wxString& fileName, const wxString& title );
 
54
 
 
55
        virtual ~HexEditPanel();
 
56
 
 
57
        /** \brief Check if given editor is HexEditor */
 
58
        static bool IsHexEditor( EditorBase* editor );
 
59
 
 
60
        /** \brief Close all editors */
 
61
        static void CloseAllEditors();
 
62
 
 
63
    protected:
 
64
 
 
65
        virtual bool GetModified() const;
 
66
        virtual void SetModified( bool modified );
 
67
        virtual bool Save();
 
68
        virtual bool SaveAs();
 
69
        virtual void SetFilename(const wxString& filename);
 
70
 
 
71
    private:
 
72
 
 
73
        typedef FileContentBase::OffsetT OffsetT;
 
74
 
 
75
        //(*Declarations(HexEditPanel)
 
76
        wxMenuItem* MenuItem29;
 
77
        wxMenuItem* MenuItem2;
 
78
        wxMenu m_ColsModeMenu;
 
79
        wxMenuItem* MenuItem23;
 
80
        wxBoxSizer* PreviewSizer;
 
81
        wxMenu* MenuItem10;
 
82
        wxMenuItem* MenuItem31;
 
83
        wxMenuItem* MenuItem1;
 
84
        wxButton* m_ColsModeBtn;
 
85
        wxMenu* MenuItem19;
 
86
        wxFlexGridSizer* FlexGridSizer1;
 
87
        wxMenuItem* MenuItem30;
 
88
        wxTextCtrl* m_Expression;
 
89
        wxBoxSizer* BoxSizer3;
 
90
        wxStaticLine* StaticLine2;
 
91
        wxMenu m_EndianessMenu;
 
92
        wxStaticText* m_ExpressionVal;
 
93
        wxStaticText* m_LDoubleVal;
 
94
        wxMenuItem* MenuItem16;
 
95
        wxMenuItem* MenuItem12;
 
96
        wxMenuItem* MenuItem25;
 
97
        wxButton* m_BlockSize;
 
98
        wxScrollBar* m_ContentScroll;
 
99
        wxStaticText* m_FloatVal;
 
100
        wxMenuItem* MenuItem32;
 
101
        wxButton* Button4;
 
102
        wxMenuItem* MenuItem20;
 
103
        wxStaticText* m_DwordVal;
 
104
        wxButton* Button1;
 
105
        wxPanel* m_DrawArea;
 
106
        wxCheckBox* CheckBox1;
 
107
        wxButton* Button2;
 
108
        wxMenuItem* MenuItem33;
 
109
        wxButton* Button3;
 
110
        wxMenu m_BaseMenu;
 
111
        wxMenuItem* MenuItem24;
 
112
        wxBoxSizer* BoxSizer2;
 
113
        wxMenuItem* MenuItem15;
 
114
        wxStaticText* StaticText1;
 
115
        wxMenuItem* MenuItem21;
 
116
        wxMenuItem* MenuItem17;
 
117
        wxStaticText* StaticText3;
 
118
        wxMenu m_BlockSizeMenu;
 
119
        wxMenuItem* MenuItem3;
 
120
        wxStaticLine* StaticLine1;
 
121
        wxButton* Button5;
 
122
        wxMenuItem* MenuItem9;
 
123
        wxStaticText* StaticText8;
 
124
        wxStaticText* m_WordVal;
 
125
        wxBoxSizer* BoxSizer4;
 
126
        wxMenuItem* MenuItem11;
 
127
        wxMenu* MenuItem28;
 
128
        wxMenuItem* MenuItem22;
 
129
        wxMenuItem* MenuItem5;
 
130
        wxStaticText* StaticText4;
 
131
        wxTimer ReparseTimer;
 
132
        wxBoxSizer* BoxSizer1;
 
133
        wxStaticText* m_DoubleVal;
 
134
        wxStaticText* StaticText5;
 
135
        wxStaticText* StaticText2;
 
136
        wxMenuItem* MenuItem27;
 
137
        wxMenuItem* MenuItem18;
 
138
        wxMenuItem* MenuItem7;
 
139
        wxMenuItem* MenuItem6;
 
140
        wxMenuItem* MenuItem4;
 
141
        wxMenuItem* MenuItem26;
 
142
        wxStaticText* StaticText6;
 
143
        wxMenuItem* MenuItem13;
 
144
        wxStaticText* m_ByteVal;
 
145
        wxStaticText* m_Status;
 
146
        wxMenuItem* MenuItem8;
 
147
        wxButton* Button6;
 
148
        wxMenuItem* MenuItem14;
 
149
        wxButton* m_Endianess;
 
150
        wxButton* m_DigitBits;
 
151
        //*)
 
152
 
 
153
        //(*Identifiers(HexEditPanel)
 
154
        static const long ID_STATICTEXT1;
 
155
        static const long ID_BUTTON10;
 
156
        static const long ID_BUTTON9;
 
157
        static const long ID_STATICLINE2;
 
158
        static const long ID_BUTTON7;
 
159
        static const long ID_BUTTON4;
 
160
        static const long ID_BUTTON6;
 
161
        static const long ID_BUTTON5;
 
162
        static const long ID_STATICLINE1;
 
163
        static const long ID_BUTTON1;
 
164
        static const long ID_BUTTON8;
 
165
        static const long ID_CHECKBOX1;
 
166
        static const long ID_PANEL1;
 
167
        static const long ID_SCROLLBAR1;
 
168
        static const long ID_STATICTEXT2;
 
169
        static const long ID_STATICTEXT3;
 
170
        static const long ID_STATICTEXT4;
 
171
        static const long ID_STATICTEXT5;
 
172
        static const long ID_STATICTEXT6;
 
173
        static const long ID_STATICTEXT7;
 
174
        static const long ID_STATICTEXT8;
 
175
        static const long ID_STATICTEXT9;
 
176
        static const long ID_STATICTEXT10;
 
177
        static const long ID_STATICTEXT11;
 
178
        static const long ID_STATICTEXT12;
 
179
        static const long ID_STATICTEXT13;
 
180
        static const long ID_STATICTEXT14;
 
181
        static const long ID_TEXTCTRL1;
 
182
        static const long ID_BUTTON3;
 
183
        static const long ID_BUTTON2;
 
184
        static const long ID_STATICTEXT15;
 
185
        static const long ID_TIMER1;
 
186
        static const long ID_MENUITEM2;
 
187
        static const long ID_MENUITEM1;
 
188
        static const long ID_MENUITEM3;
 
189
        static const long ID_MENUITEM4;
 
190
        static const long ID_MENUITEM5;
 
191
        static const long ID_MENUITEM6;
 
192
        static const long ID_MENUITEM7;
 
193
        static const long ID_MENUITEM8;
 
194
        static const long ID_MENUITEM9;
 
195
        static const long ID_MENUITEM11;
 
196
        static const long ID_MENUITEM12;
 
197
        static const long ID_MENUITEM13;
 
198
        static const long ID_MENUITEM14;
 
199
        static const long ID_MENUITEM15;
 
200
        static const long ID_MENUITEM16;
 
201
        static const long ID_MENUITEM17;
 
202
        static const long ID_MENUITEM18;
 
203
        static const long ID_MENUITEM32;
 
204
        static const long ID_MENUITEM10;
 
205
        static const long ID_MENUITEM20;
 
206
        static const long ID_MENUITEM21;
 
207
        static const long ID_MENUITEM22;
 
208
        static const long ID_MENUITEM23;
 
209
        static const long ID_MENUITEM24;
 
210
        static const long ID_MENUITEM25;
 
211
        static const long ID_MENUITEM26;
 
212
        static const long ID_MENUITEM27;
 
213
        static const long ID_MENUITEM19;
 
214
        static const long ID_MENUITEM29;
 
215
        static const long ID_MENUITEM30;
 
216
        static const long ID_MENUITEM31;
 
217
        static const long ID_MENUITEM33;
 
218
        static const long ID_MENUITEM28;
 
219
        //*)
 
220
 
 
221
        //(*Handlers(HexEditPanel)
 
222
        void OnContentPaint( wxPaintEvent& event );
 
223
        void OnContentSize( wxSizeEvent& event );
 
224
        void OnContentScroll( wxScrollEvent& event );
 
225
        void OnContentMouseWheel(wxMouseEvent& event);
 
226
        void OnDrawAreaKeyDown(wxKeyEvent& event);
 
227
        void OnDrawAreaEraseBackground(wxEraseEvent& event);
 
228
        void OnForwardFocus(wxFocusEvent& event);
 
229
        void OnDrawAreaLeftDown(wxMouseEvent& event);
 
230
        void OnDrawAreaLeftUp(wxMouseEvent& event);
 
231
        void OnDrawAreaMouseMove(wxMouseEvent& event);
 
232
        void OnCheckBox1Click(wxCommandEvent& event);
 
233
        void OnSpecialKeyDown(wxKeyEvent& event);
 
234
        void OnButton1Click(wxCommandEvent& event);
 
235
        void OnReparseTimerTrigger(wxTimerEvent& event);
 
236
        void Onm_ExpressionText(wxCommandEvent& event);
 
237
        void OnButton2Click(wxCommandEvent& event);
 
238
        void OnExpressionTextEnter(wxCommandEvent& event);
 
239
        void OnButton3Click(wxCommandEvent& event);
 
240
        void OnButton3Click1(wxCommandEvent& event);
 
241
        void OnButton4Click(wxCommandEvent& event);
 
242
        void OnSetBaseHex(wxCommandEvent& event);
 
243
        void OnSetBaseBin(wxCommandEvent& event);
 
244
        void Onm_EndianessClick(wxCommandEvent& event);
 
245
        void OnSetEndianessBig(wxCommandEvent& event);
 
246
        void OnSetEndianessLittle(wxCommandEvent& event);
 
247
        void Onm_BlockSizeClick(wxCommandEvent& event);
 
248
        void OnSetBlockSize1(wxCommandEvent& event);
 
249
        void OnSetBlockSize2(wxCommandEvent& event);
 
250
        void OnSetBlockSize4(wxCommandEvent& event);
 
251
        void OnSetBlockSize8(wxCommandEvent& event);
 
252
        void Onm_ColsModeClick(wxCommandEvent& event);
 
253
        void OnSetColsMul1(wxCommandEvent& event);
 
254
        void OnSetColsMul2(wxCommandEvent& event);
 
255
        void OnSetColsMul3(wxCommandEvent& event);
 
256
        void OnSetColsMul4(wxCommandEvent& event);
 
257
        void OnSetColsMul5(wxCommandEvent& event);
 
258
        void OnSetColsMul6(wxCommandEvent& event);
 
259
        void OnSetColsMul7(wxCommandEvent& event);
 
260
        void OnSetColsMul8(wxCommandEvent& event);
 
261
        void OnSetColsMulOther(wxCommandEvent& event);
 
262
        void OnSetColsValue1(wxCommandEvent& event);
 
263
        void OnSetColsValue2(wxCommandEvent& event);
 
264
        void OnSetColsValue3(wxCommandEvent& event);
 
265
        void OnSetColsValue4(wxCommandEvent& event);
 
266
        void OnSetColsValue5(wxCommandEvent& event);
 
267
        void OnSetColsValue6(wxCommandEvent& event);
 
268
        void OnSetColsValue7(wxCommandEvent& event);
 
269
        void OnSetColsValue8(wxCommandEvent& event);
 
270
        void OnSetColsValueOther(wxCommandEvent& event);
 
271
        void OnSetColsPower2(wxCommandEvent& event);
 
272
        void OnSetColsPower4(wxCommandEvent& event);
 
273
        void OnSetColsPower8(wxCommandEvent& event);
 
274
        void OnSetColsPowerOther(wxCommandEvent& event);
 
275
        void OnButton4Click1(wxCommandEvent& event);
 
276
        void OnContentScrollTop(wxScrollEvent& event);
 
277
        void OnContentScrollBottom(wxScrollEvent& event);
 
278
        void OnButton6Click(wxCommandEvent& event);
 
279
        void OnButton5Click(wxCommandEvent& event);
 
280
        //*)
 
281
 
 
282
        typedef std::set< EditorBase* > EditorsSet;
 
283
 
 
284
        enum
 
285
        {
 
286
            VIEW_DIGIT,
 
287
            VIEW_CHARS,
 
288
            MAX_VIEWS
 
289
        };
 
290
 
 
291
        enum
 
292
        {
 
293
            CM_ANY,
 
294
            CM_MULT,
 
295
            CM_POWER,
 
296
            CM_SPECIFIED
 
297
        };
 
298
 
 
299
        wxString                 m_FileName;                    ///< \brief Name of the file being edited
 
300
        FileContentBase*         m_Content;                     ///< \brief Content structure of file being edited
 
301
        wxString                 m_ErrorString;                 ///< \brief String containg error description (if couldn't read the content)
 
302
        wxFont*                  m_DrawFont;                    ///< \brief Font used for drawing
 
303
        wxCoord                  m_FontX;                       ///< \brief Width of character
 
304
        wxCoord                  m_FontY;                       ///< \brief Height of character
 
305
        unsigned int             m_Cols;                        ///< \brief Number of available characters in row in the editor
 
306
        unsigned int             m_Lines;                       ///< \brief Number of available lines of characters in the editor
 
307
        unsigned int             m_LineBytes;                   ///< \brief Number of bytes shown in a line
 
308
 
 
309
        OffsetT                  m_Current;                     ///< \brief Offset of current character
 
310
        OffsetT                  m_CurrentBlockStart;           ///< \brief Offset of start of current character block
 
311
        OffsetT                  m_CurrentBlockEnd;             ///< \brief Offset of end of current character block
 
312
 
 
313
        wxString                 m_ExpressionError;             ///< \brief Last error reported while compiling user-defined expression in preview bar
 
314
        Expression::Preprocessed m_ExpressionCode;              ///< \brief Bytecode of user-defined expression in preview bar
 
315
 
 
316
        HexEditViewBase*         m_Views[ MAX_VIEWS ];          ///< \brief List of all used views
 
317
        unsigned                 m_ViewsCols[ MAX_VIEWS ];      ///< \brief Size of each view in characters
 
318
        HexEditViewBase*         m_ActiveView;                  ///< \brief Index of active view
 
319
        DigitView*               m_DigitView;                   ///< \brief Cached pointer to digit view
 
320
 
 
321
        bool                     m_ViewNotifyContentChange;
 
322
        bool                     m_ViewNotifyOffsetChange;
 
323
        bool                     m_MouseDown;
 
324
 
 
325
        int                      m_ColsMode;
 
326
        int                      m_ColsValue;
 
327
        int                      m_ColsCount;
 
328
 
 
329
        OffsetT                  m_LinesPerScrollUnit;          ///< \brief Number of lines per one scroll unit
 
330
        int                      m_LastScrollUnits;             ///< \brief Last position of the scroll (in scroll units)
 
331
        OffsetT                  m_LastScrollPos;               ///< \brief Last position of the scroll as offset in file
 
332
 
 
333
        static EditorsSet        m_AllEditors;                  ///< \brief Set of all opened editors, used to close all editors when plugin is being unloaded
 
334
 
 
335
        /** \brief Open the file content structure and check for errors */
 
336
        void ReadContent();
 
337
 
 
338
        /** \brief Set font of given size as used font, does not recalculate coefficients nor font size */
 
339
        void SetFontSize( int size );
 
340
 
 
341
        /** \brief Recalculate all coefficients (width, height, block sizes eetc) */
 
342
        void RecalculateCoefs();
 
343
 
 
344
        /** \brief Returns offset of first byte displayed on the screen from the scroll bar */
 
345
        FileContentBase::OffsetT DetectStartOffset();
 
346
 
 
347
        /** \brief Refresh status line (position, percentage etc) */
 
348
        void RefreshStatus();
 
349
 
 
350
        /** \brief Update the state of "modified" document */
 
351
        void UpdateModified();
 
352
 
 
353
        /** \brief Adjust the scrollbar to make sure that m_Current byte is shown on the screen */
 
354
        void EnsureCarretVisible();
 
355
 
 
356
        /** \brief Adjust the m_Current position to make sure that it points to some byte shown on the screen */
 
357
        void ClampCursorToVisibleArea();
 
358
 
 
359
        /** \brief Process GOTO request */
 
360
        void ProcessGoto();
 
361
 
 
362
        /** \brief Process search request */
 
363
        void ProcessSearch();
 
364
 
 
365
        /** \brief Reparse expression entered by the user in preview bar */
 
366
        void ReparseExpression();
 
367
 
 
368
        /** \brief Create views of the editor */
 
369
        inline void CreateViews();
 
370
 
 
371
        /** \brief Activate view at given index */
 
372
        inline void ActivateView( HexEditViewBase* view );
 
373
 
 
374
        /** \brief Propagate change of the offset to all views */
 
375
        void PropagateOffsetChange( int flagsForCurrentView = -1 );
 
376
 
 
377
        /** \brief Notification about content change from the view */
 
378
        inline void ViewNotifyContentChange() { m_ViewNotifyContentChange = true; }
 
379
 
 
380
        /** \brief Notification about offset change from the view */
 
381
        inline void ViewNotifyOffsetChange( OffsetT newOffset ) { m_Current = newOffset; m_ViewNotifyOffsetChange = true; }
 
382
 
 
383
        /** \brief Called to adjust views due to display settings change */
 
384
        void DisplayChanged();
 
385
 
 
386
        /** \brief Called to set columns mode */
 
387
        void ColsMode( int mode, int value );
 
388
 
 
389
        /** \brief Check if given columns count matches column setting mode */
 
390
        bool MatchColumnsCount( int colsCount );
 
391
 
 
392
 
 
393
        friend class HexEditViewBase;
 
394
 
 
395
        virtual bool CanUndo() const;
 
396
        virtual bool CanRedo() const;
 
397
        virtual void Undo();
 
398
        virtual void Redo();
 
399
 
 
400
        DECLARE_EVENT_TABLE()
 
401
};
 
402
 
 
403
#endif