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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/HexEditor/HexEditLineBuffer.cpp

  • 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: HexEditLineBuffer.cpp 5445 2009-02-07 00:35:09Z byo $
 
20
* $HeadURL: svn+ssh://jenslody@svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/contrib/HexEditor/HexEditLineBuffer.cpp $
 
21
*/
 
22
 
 
23
#include "HexEditLineBuffer.h"
 
24
 
 
25
#include <logmanager.h>
 
26
 
 
27
HexEditLineBuffer::HexEditLineBuffer( unsigned length )
 
28
{
 
29
    if ( length )
 
30
    {
 
31
        m_Buffer = new char[ 2 * length ];
 
32
        m_Position = m_Buffer;
 
33
        m_End = m_Buffer + 2 * length;
 
34
    }
 
35
    else
 
36
    {
 
37
        m_Buffer = 0L;
 
38
        m_Position = 0L;
 
39
        m_End = 0L;
 
40
    }
 
41
    Reset();
 
42
}
 
43
 
 
44
HexEditLineBuffer::~HexEditLineBuffer()
 
45
{
 
46
    delete[] m_Buffer;
 
47
}
 
48
 
 
49
void HexEditLineBuffer::Reset( char defaultChar, char defaultStyle )
 
50
{
 
51
    for ( char* ptr = m_Buffer; ptr < m_End; ptr += 2 )
 
52
    {
 
53
        ptr[ 0 ] = defaultChar;
 
54
        ptr[ 1 ] = defaultStyle;
 
55
    }
 
56
    m_Position = m_Buffer;
 
57
}
 
58
 
 
59
void HexEditLineBuffer::PutChar( char ch, char style )
 
60
{
 
61
    if ( m_Position < m_End )
 
62
    {
 
63
        *m_Position++ = ch;
 
64
        *m_Position++ = style;
 
65
    }
 
66
}
 
67
 
 
68
void HexEditLineBuffer::Draw( wxDC& dc, int x, int y, int fontX, int fontY, wxColour* foregrounds, wxColour* backgrounds )
 
69
{
 
70
    for ( char* ptr = m_Buffer; ptr < m_End; )
 
71
    {
 
72
        // Searching for continous block with same style
 
73
        wxString str;
 
74
 
 
75
        do
 
76
        {
 
77
            str += wxChar( ptr[ 0 ] );
 
78
            ptr += 2;
 
79
        }
 
80
        while ( ( ptr < m_End ) && ( ptr[1] == ptr[-1] ) );
 
81
 
 
82
        char style = ptr[-1];
 
83
 
 
84
        dc.SetBrush( backgrounds[ (int)style ] );
 
85
        dc.SetPen( backgrounds[ (int)style ] );
 
86
 
 
87
        dc.DrawRectangle( x, y, fontX * str.length(), fontY );
 
88
 
 
89
        dc.SetPen( foregrounds[ (int)style ] );
 
90
        dc.SetTextForeground( foregrounds[ (int)style ] );
 
91
        dc.SetTextBackground( backgrounds[ (int)style ] );
 
92
 
 
93
        dc.DrawText( str, x, y );
 
94
        x += fontX * str.length();
 
95
    }
 
96
}
 
97