2
* This file is part of HexEditor plugin for Code::Blocks Studio
3
* Copyright (C) 2008-2009 Bartlomiej Swiecki
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.
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.
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/>.
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 $
23
#ifndef HEXEDITPANEL_H
24
#define HEXEDITPANEL_H
26
//(*Headers(HexEditPanel)
27
#include <wx/scrolbar.h>
28
#include <wx/checkbox.h>
30
#include <wx/button.h>
33
#include <wx/statline.h>
34
#include <wx/stattext.h>
35
#include <wx/textctrl.h>
39
#include <editorbase.h>
43
#include "FileContentBase.h"
44
#include "ExpressionPreprocessed.h"
45
#include "HexEditViewBase.h"
49
class HexEditPanel: public EditorBase
53
HexEditPanel( const wxString& fileName, const wxString& title );
55
virtual ~HexEditPanel();
57
/** \brief Check if given editor is HexEditor */
58
static bool IsHexEditor( EditorBase* editor );
60
/** \brief Close all editors */
61
static void CloseAllEditors();
65
virtual bool GetModified() const;
66
virtual void SetModified( bool modified );
68
virtual bool SaveAs();
69
virtual void SetFilename(const wxString& filename);
73
typedef FileContentBase::OffsetT OffsetT;
75
//(*Declarations(HexEditPanel)
76
wxMenuItem* MenuItem29;
77
wxMenuItem* MenuItem2;
78
wxMenu m_ColsModeMenu;
79
wxMenuItem* MenuItem23;
80
wxBoxSizer* PreviewSizer;
82
wxMenuItem* MenuItem31;
83
wxMenuItem* MenuItem1;
84
wxButton* m_ColsModeBtn;
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;
102
wxMenuItem* MenuItem20;
103
wxStaticText* m_DwordVal;
106
wxCheckBox* CheckBox1;
108
wxMenuItem* MenuItem33;
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;
122
wxMenuItem* MenuItem9;
123
wxStaticText* StaticText8;
124
wxStaticText* m_WordVal;
125
wxBoxSizer* BoxSizer4;
126
wxMenuItem* MenuItem11;
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;
148
wxMenuItem* MenuItem14;
149
wxButton* m_Endianess;
150
wxButton* m_DigitBits;
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;
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);
282
typedef std::set< EditorBase* > EditorsSet;
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
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
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
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
321
bool m_ViewNotifyContentChange;
322
bool m_ViewNotifyOffsetChange;
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
333
static EditorsSet m_AllEditors; ///< \brief Set of all opened editors, used to close all editors when plugin is being unloaded
335
/** \brief Open the file content structure and check for errors */
338
/** \brief Set font of given size as used font, does not recalculate coefficients nor font size */
339
void SetFontSize( int size );
341
/** \brief Recalculate all coefficients (width, height, block sizes eetc) */
342
void RecalculateCoefs();
344
/** \brief Returns offset of first byte displayed on the screen from the scroll bar */
345
FileContentBase::OffsetT DetectStartOffset();
347
/** \brief Refresh status line (position, percentage etc) */
348
void RefreshStatus();
350
/** \brief Update the state of "modified" document */
351
void UpdateModified();
353
/** \brief Adjust the scrollbar to make sure that m_Current byte is shown on the screen */
354
void EnsureCarretVisible();
356
/** \brief Adjust the m_Current position to make sure that it points to some byte shown on the screen */
357
void ClampCursorToVisibleArea();
359
/** \brief Process GOTO request */
362
/** \brief Process search request */
363
void ProcessSearch();
365
/** \brief Reparse expression entered by the user in preview bar */
366
void ReparseExpression();
368
/** \brief Create views of the editor */
369
inline void CreateViews();
371
/** \brief Activate view at given index */
372
inline void ActivateView( HexEditViewBase* view );
374
/** \brief Propagate change of the offset to all views */
375
void PropagateOffsetChange( int flagsForCurrentView = -1 );
377
/** \brief Notification about content change from the view */
378
inline void ViewNotifyContentChange() { m_ViewNotifyContentChange = true; }
380
/** \brief Notification about offset change from the view */
381
inline void ViewNotifyOffsetChange( OffsetT newOffset ) { m_Current = newOffset; m_ViewNotifyOffsetChange = true; }
383
/** \brief Called to adjust views due to display settings change */
384
void DisplayChanged();
386
/** \brief Called to set columns mode */
387
void ColsMode( int mode, int value );
389
/** \brief Check if given columns count matches column setting mode */
390
bool MatchColumnsCount( int colsCount );
393
friend class HexEditViewBase;
395
virtual bool CanUndo() const;
396
virtual bool CanRedo() const;
400
DECLARE_EVENT_TABLE()