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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/HexEditor/HexEditViewBase.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: 5445 $
 
19
* $Id: HexEditViewBase.h 5445 2009-02-07 00:35:09Z byo $
 
20
* $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/contrib/HexEditor/HexEditViewBase.h $
 
21
*/
 
22
 
 
23
#ifndef HEXEDITVIEWBASE_H
 
24
#define HEXEDITVIEWBASE_H
 
25
 
 
26
#include "FileContentBase.h"
 
27
#include "HexEditLineBuffer.h"
 
28
 
 
29
class HexEditPanel;
 
30
 
 
31
 
 
32
/** \brief Base class for the view in editor area
 
33
 *
 
34
 * This is base interface used to represent views inside of the editor
 
35
 * (like the hex view or character preview, I don't know anything about
 
36
 * other usages at the momment of writing this peace of code ;) )
 
37
 *
 
38
 * Offtopic: There's strange story about how this class was created
 
39
 *  I tried to make some nice solution for the problem with lack
 
40
 *  of editor's flexibility. I tied at least four solutions and
 
41
 *  I was dropping the m one after another since more problems
 
42
 *  were found while coding. Finally I was so angry about that
 
43
 *  that I said "God help me" ... and the solution was just
 
44
 *  few hours later, jumped into my mind just with all those
 
45
 *  details needed to make it work. Yeah, for me it's a proof
 
46
 *  that God really exists and that He cares about the
 
47
 *  Open-Source community :)
 
48
 */
 
49
class HexEditViewBase
 
50
{
 
51
    public:
 
52
 
 
53
        typedef FileContentBase::OffsetT OffsetT;
 
54
 
 
55
        /** \brief Ctor */
 
56
        HexEditViewBase( HexEditPanel* panel );
 
57
 
 
58
        /** \brief Dctor */
 
59
        virtual ~HexEditViewBase();
 
60
 
 
61
        /** \brief Activate this view
 
62
         *  \return previous active state
 
63
         */
 
64
        bool SetActive( bool makeMeActive = true );
 
65
 
 
66
        /** \brief Get the active state */
 
67
        bool GetActive() { return m_IsActive; }
 
68
 
 
69
        /** \brief Calculate size of block at current offset's position */
 
70
        void CalculateBlockSize(
 
71
            OffsetT  screenStartOffset,
 
72
            OffsetT  currentOffset,
 
73
            OffsetT& blockStart,
 
74
            OffsetT& blockEnd );
 
75
 
 
76
        /** \brief Jump to given offset and calculate range for current data block
 
77
         *  \param screenStartOffset offset of first data byte shown on the screen
 
78
         *  \param currentOffset offset of current position
 
79
         *  \param blockStart here current block start is put and new value will be stored if wider range is required
 
80
         *  \param blockEnd here current block end is put and new value will be storeed if wider range is required
 
81
         *  \param positionFlags flags of current position (like which bit of the byte is currently edited), this
 
82
         *         argument will be -1 if called can not deduce it's value
 
83
         */
 
84
        void JumpToOffset(
 
85
            OffsetT screenStartOffset,
 
86
            OffsetT currentOffset,
 
87
            OffsetT blockStart,
 
88
            OffsetT blockEnd,
 
89
            int     positionFlags );
 
90
 
 
91
        /** \brief Get scrren start offset */
 
92
        OffsetT GetScreenStartOffset() { return m_ScreenStartOffset; }
 
93
 
 
94
        /** \brief Get current position offset */
 
95
        OffsetT GetCurrentOffset() { return m_CurrentOffset; }
 
96
 
 
97
        /** \brief Get flags for current offset */
 
98
        int GetCurrentPositionFlags() { return OnGetCurrentPositionFlags(); }
 
99
 
 
100
        /** \brief Get block start offset */
 
101
        OffsetT GetBlockStartOffset() { return m_BlockStartOffset; }
 
102
 
 
103
        /** \brief Get block end offset */
 
104
        OffsetT GetBlockEndOffset() { return m_BlockEndOffset; }
 
105
 
 
106
        /** \brief Drop a character into this view
 
107
         *  \note If the view is not active, character will not be processed
 
108
         */
 
109
        void PutChar( wxChar ch );
 
110
 
 
111
        /** \brief Move cursor left */
 
112
        void MoveLeft();
 
113
 
 
114
        /** \brief Move cursor right */
 
115
        void MoveRight();
 
116
 
 
117
        /** \brief Move cursor up */
 
118
        void MoveUp();
 
119
 
 
120
        /** \brief Move cursor down */
 
121
        void MoveDown();
 
122
 
 
123
        /** \brief Put given line into line buffer */
 
124
        void PutLine( OffsetT lineStartOffset, HexEditLineBuffer& buffer, char* content, int bytes );
 
125
 
 
126
        /** \brief Get block sizez */
 
127
        void GetBlockSizes( int& blockLength, int& blockBytes, int& spacing );
 
128
 
 
129
        /** \brief Detect offset from position in line */
 
130
        int GetOffsetFromColumn( int column, int& positionFlags );
 
131
 
 
132
    protected:
 
133
 
 
134
        /** \brief Called when switching the active state */
 
135
        virtual void OnActivate( bool becomesActive ) = 0;
 
136
 
 
137
        /** \brief Detect block start and end at given offset */
 
138
        virtual void OnCalculateBlockSize( OffsetT& blockStart, OffsetT& blockEnd );
 
139
 
 
140
        /** \brief Called when changing current cursor offset */
 
141
        virtual void OnOffsetChange( int positionFlags );
 
142
 
 
143
        /** \brief Called when fetching current position flags */
 
144
        virtual int OnGetCurrentPositionFlags();
 
145
 
 
146
        /** \brief Called when character is sent to this view */
 
147
        virtual void OnProcessChar( wxChar ) = 0;
 
148
 
 
149
        /** \brief Called when moving left */
 
150
        virtual void OnMoveLeft() = 0;
 
151
 
 
152
        /** \brief Called when moving right */
 
153
        virtual void OnMoveRight() = 0;
 
154
 
 
155
        /** \brief Called when moving up */
 
156
        virtual void OnMoveUp() = 0;
 
157
 
 
158
        /** \brief Called when moving down */
 
159
        virtual void OnMoveDown() = 0;
 
160
 
 
161
        /** \brief Called when there's need to fill line buffer for this content */
 
162
        virtual void OnPutLine( OffsetT startOffset, HexEditLineBuffer& buff, char* content, int bytes ) = 0;
 
163
 
 
164
        /** \brief Fetching informations about current data block sizes
 
165
         *  \param blockLength length of block in characters
 
166
         *  \param blockBytes number of bytes in one block
 
167
         *  \param spacing number of characters splitting two blocks next to each other
 
168
         */
 
169
        virtual void OnGetBlockSizes( int& blockLength, int& blockBytes, int& spacing ) = 0;
 
170
 
 
171
        /** \brief Calculate offset from the beginning of the line at given position */
 
172
        virtual int OnGetOffsetFromColumn( int column, int& positionFlags ) = 0;
 
173
 
 
174
 
 
175
        /** \brief Fetch assigned file content */
 
176
        FileContentBase* GetContent();
 
177
 
 
178
        /** \brief Get length of one line */
 
179
        unsigned int GetLineBytes();
 
180
 
 
181
        /** \brief Notify about offset change
 
182
         *  \param currentOffset new current offset
 
183
         */
 
184
        void OffsetChange( OffsetT currentOffset );
 
185
 
 
186
        /** \brief Notify about content change */
 
187
        void ContentChange();
 
188
 
 
189
 
 
190
    private:
 
191
 
 
192
        bool    m_IsActive;             ///< \brief Set to true if this view is active (has keyboard focus)
 
193
        OffsetT m_ScreenStartOffset;    ///< \brief Offset of first data byte shown on the screen
 
194
        OffsetT m_CurrentOffset;        ///< \brief Offset of current byte
 
195
        OffsetT m_BlockStartOffset;     ///< \brief Start offset of current data block
 
196
        OffsetT m_BlockEndOffset;       ///< \brief End offset of current data block
 
197
        HexEditPanel* m_Panel;          ///< \brief Owning panel
 
198
 
 
199
};
 
200
 
 
201
#endif