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

« back to all changes in this revision

Viewing changes to src/plugins/contrib/regex_testbed/regexdlg.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:
32
32
//(*IdInit(regex_dialog)
33
33
//*)
34
34
 
35
 
BEGIN_EVENT_TABLE(RegExDlg,wxDialog)
 
35
BEGIN_EVENT_TABLE(RegExDlg,wxScrollingDialog)
36
36
        EVT_INIT_DIALOG(RegExDlg::OnInit)
37
37
        EVT_UPDATE_UI(-1, RegExDlg::OnUpdateUI)
38
38
END_EVENT_TABLE()
39
39
 
 
40
RegExDlg::VisibleDialogs RegExDlg::m_visible_dialogs;
 
41
 
40
42
RegExDlg::RegExDlg(wxWindow* parent,wxWindowID id)
41
43
{
42
44
    //(*Initialize(regex_dialog)
43
 
    wxXmlResource::Get()->LoadObject(this,parent,_T("regex_dialog"),_T("wxDialog"));
 
45
    wxXmlResource::Get()->LoadObject(this,parent,_T("regex_dialog"),_T("wxScrollingDialog"));
44
46
    m_regex = (wxTextCtrl*)FindWindow(XRCID("ID_REGEX"));
45
47
    m_quoted = (wxTextCtrl*)FindWindow(XRCID("ID_QUOTED"));
46
48
    m_library = (wxChoice*)FindWindow(XRCID("ID_LIBRARY"));
48
50
    m_newlines = (wxCheckBox*)FindWindow(XRCID("ID_NEWLINES"));
49
51
    m_text = (wxTextCtrl*)FindWindow(XRCID("ID_TEXT"));
50
52
    m_output = (wxHtmlWindow*)FindWindow(XRCID("ID_OUT"));
 
53
 
 
54
    Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&RegExDlg::OnClose);
51
55
    //*)
52
56
 
53
57
    assert(m_regex);
58
62
    assert(m_text);
59
63
    assert(m_output);
60
64
 
 
65
    m_text->MoveAfterInTabOrder(m_quoted);
 
66
 
61
67
    m_library->SetSelection(0);
62
68
    m_output->SetBorders(0);
63
69
    m_quoted->SetEditable(false);
 
70
 
 
71
    m_visible_dialogs.insert(this);
64
72
}
65
73
 
66
74
RegExDlg::~RegExDlg()
67
75
{
68
76
}
69
77
 
 
78
void RegExDlg::OnClose(wxCloseEvent& event)
 
79
{
 
80
    VisibleDialogs::iterator it = m_visible_dialogs.find(this);
 
81
    if(it != m_visible_dialogs.end())
 
82
    {
 
83
        delete *it;
 
84
        m_visible_dialogs.erase(it);
 
85
    }
 
86
}
 
87
 
 
88
 
 
89
void RegExDlg::ReleaseAll()
 
90
{
 
91
    for(VisibleDialogs::iterator it = m_visible_dialogs.begin(); it != m_visible_dialogs.end(); ++it)
 
92
        delete *it;
 
93
    m_visible_dialogs.clear();
 
94
}
 
95
 
 
96
/**
 
97
    @brief Makes the input string to be valid html string (replaces <,>,&," with &lt;,&gt;,&amp;,&quot; respectively)
 
98
    @param [inout] s - string that will be escaped
 
99
*/
 
100
void cbEscapeHtml(wxString &s)
 
101
{
 
102
    s.Replace(wxT("&"), wxT("&amp;"));
 
103
    s.Replace(wxT("<"), wxT("&lt;"));
 
104
    s.Replace(wxT(">"), wxT("&gt;"));
 
105
    s.Replace(wxT("\""), wxT("&quot;"));
 
106
}
70
107
 
71
108
void RegExDlg::OnUpdateUI(wxUpdateUIEvent& event)
72
109
{
73
110
    static wxString regex;
74
111
    static wxString text;
75
 
 
76
 
    if(event.GetId() == XRCID("ID_NOCASE") || event.GetId() == XRCID("ID_NEWLINES"))
77
 
        regex = _T("$^"); // bullshit
78
 
 
79
 
    if(regex == m_regex->GetValue() && text == m_text->GetValue())
80
 
        return;
 
112
    static bool nocase;
 
113
    static bool newlines;
 
114
    static int library;
 
115
 
 
116
//    if(event.GetId() == XRCID("ID_NOCASE") || event.GetId() == XRCID("ID_NEWLINES"))
 
117
//        regex = _T("$^"); // bullshit
 
118
//    all UI elements send events quite often (on linux on every mouse mouve, if the parent window
 
119
//    has the focus, on windows even without any user action). So we can not use the event Id to force a new
 
120
//    run of GetBuiltinMatches(), because every time the value of m_quoted and m_output gets upadeted a selection of text in m_quoted
 
121
//    will be reset and therefore the user can not copy it's content (linux) and m_output jumps to the top, so that the user
 
122
//    cannot scroll the text (windows and linux).
 
123
//
 
124
 
 
125
    if( regex == m_regex->GetValue() &&
 
126
        text == m_text->GetValue() &&
 
127
        nocase == m_nocase->GetValue() &&
 
128
        newlines == m_newlines->GetValue() &&
 
129
        library == m_library->GetSelection())
 
130
        {
 
131
            return;
 
132
        }
81
133
 
82
134
    regex = m_regex->GetValue();
83
135
    text = m_text->GetValue();
 
136
    nocase = m_nocase->GetValue();
 
137
    newlines = m_newlines->GetValue();
 
138
    library = m_library->GetSelection();
84
139
 
85
140
    wxString tmp(regex);
86
141
 
100
155
 
101
156
    for(size_t i = 0; i < as.GetCount(); ++i)
102
157
    {
 
158
        cbEscapeHtml(as[i]);
103
159
        tmp.Printf(_T("<tr><td width=35><b>%d</b></td><td>%s</td></tr>"), i, as[i].c_str());
104
160
        s.append(tmp);
105
161
    }
116
172
 
117
173
void RegExDlg::EndModal(int retCode)
118
174
{
119
 
    wxDialog::EndModal(retCode);
 
175
    wxScrollingDialog::EndModal(retCode);
120
176
}
121
177
 
122
178
void RegExDlg::OnInit(wxInitDialogEvent& event)