File: NewToolBase.cpp

package info (click to toggle)
codelite 14.0+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 112,816 kB
  • sloc: cpp: 483,662; ansic: 150,144; php: 9,569; lex: 4,186; python: 3,417; yacc: 2,820; sh: 1,147; makefile: 52; xml: 13
file content (237 lines) | stat: -rw-r--r-- 11,635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
//////////////////////////////////////////////////////////////////////
// This file was auto-generated by codelite's wxCrafter Plugin
// wxCrafter project file: NewToolBase.wxcp
// Do not modify this file by hand!
//////////////////////////////////////////////////////////////////////

#include "NewToolBase.h"

// Declare the bitmap loading function
extern void wxC3E45InitBitmapResources();

static bool bBitmapLoaded = false;

NewToolBase::NewToolBase(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
                         long style)
    : wxDialog(parent, id, title, pos, size, style)
{
    if(!bBitmapLoaded) {
        // We need to initialise the default bitmap handler
        wxXmlResource::Get()->AddHandler(new wxBitmapXmlHandler);
        wxC3E45InitBitmapResources();
        bBitmapLoaded = true;
    }

    wxBoxSizer* bSizer1 = new wxBoxSizer(wxVERTICAL);
    this->SetSizer(bSizer1);

    wxFlexGridSizer* fgSizer1 = new wxFlexGridSizer(5, 3, 0, 0);
    fgSizer1->SetFlexibleDirection(wxBOTH);
    fgSizer1->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
    fgSizer1->AddGrowableCol(1);

    bSizer1->Add(fgSizer1, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_staticText5 =
        new wxStaticText(this, wxID_ANY, _("Tool ID:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer1->Add(m_staticText5, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    wxArrayString m_choiceIdArr;
    m_choiceId = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), m_choiceIdArr, 0);
    m_choiceId->SetToolTip(_("Identify this tool with an ID from the given list"));

    fgSizer1->Add(m_choiceId, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    fgSizer1->Add(0, 0, 1, wxEXPAND, WXC_FROM_DIP(5));

    m_staticText6 =
        new wxStaticText(this, wxID_ANY, _("Name:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer1->Add(m_staticText6, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_textCtrlName = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_textCtrlName->SetToolTip(_("The name is used to identify this tool in the 'External Tools' toolbar"));
    m_textCtrlName->SetFocus();
#if wxVERSION_NUMBER >= 3000
    m_textCtrlName->SetHint(wxT(""));
#endif

    fgSizer1->Add(m_textCtrlName, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    fgSizer1->Add(0, 0, 1, wxEXPAND, WXC_FROM_DIP(5));

    m_staticText1 =
        new wxStaticText(this, wxID_ANY, _("Tool path:"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer1->Add(m_staticText1, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_textCtrlPath = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_textCtrlPath->SetToolTip(_("Path to the executable to run"));
#if wxVERSION_NUMBER >= 3000
    m_textCtrlPath->SetHint(wxT(""));
#endif
    m_textCtrlPath->AutoCompleteFileNames();

    fgSizer1->Add(m_textCtrlPath, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_buttonBrowsePath =
        new wxButton(this, wxID_ANY, _("..."), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), wxBU_EXACTFIT);

    fgSizer1->Add(m_buttonBrowsePath, 0, wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_staticText2 = new wxStaticText(this, wxID_ANY, _("Working directory:"), wxDefaultPosition,
                                     wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer1->Add(m_staticText2, 0, wxALL | wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_textCtrlWd = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_textCtrlWd->SetToolTip(_("Set the working directory for this tool"));
#if wxVERSION_NUMBER >= 3000
    m_textCtrlWd->SetHint(wxT(""));
#endif
    m_textCtrlWd->AutoCompleteDirectories();

    fgSizer1->Add(m_textCtrlWd, 1, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_buttonBrowseWd =
        new wxButton(this, wxID_ANY, _("..."), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), wxBU_EXACTFIT);

    fgSizer1->Add(m_buttonBrowseWd, 0, wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    wxStaticBoxSizer* sbSizer1 = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("Toolbar:")), wxVERTICAL);

    bSizer1->Add(sbSizer1, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    wxFlexGridSizer* fgSizer2 = new wxFlexGridSizer(2, 3, 0, 0);
    fgSizer2->SetFlexibleDirection(wxBOTH);
    fgSizer2->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED);
    fgSizer2->AddGrowableCol(1);

    sbSizer1->Add(fgSizer2, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_staticText8 = new wxStaticText(this, wxID_ANY, _("Toolbar icon (24x24):"), wxDefaultPosition,
                                     wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer2->Add(m_staticText8, 0, wxRIGHT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_textCtrlIcon24 = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
#if wxVERSION_NUMBER >= 3000
    m_textCtrlIcon24->SetHint(wxT(""));
#endif

    fgSizer2->Add(m_textCtrlIcon24, 0, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_buttonBrowseIcon24 =
        new wxButton(this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer2->Add(m_buttonBrowseIcon24, 0, wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_staticText7 = new wxStaticText(this, wxID_ANY, _("Toolbar icon (16x16):"), wxDefaultPosition,
                                     wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer2->Add(m_staticText7, 0, wxRIGHT | wxTOP | wxBOTTOM | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_textCtrlIcon16 = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
#if wxVERSION_NUMBER >= 3000
    m_textCtrlIcon16->SetHint(wxT(""));
#endif

    fgSizer2->Add(m_textCtrlIcon16, 1, wxALL | wxEXPAND | wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    m_buttonBrowseIcon16 =
        new wxButton(this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);

    fgSizer2->Add(m_buttonBrowseIcon16, 0, wxALIGN_CENTER_VERTICAL, WXC_FROM_DIP(5));

    wxStaticBoxSizer* sbSizer2 = new wxStaticBoxSizer(new wxStaticBox(this, wxID_ANY, _("General:")), wxVERTICAL);

    bSizer1->Add(sbSizer2, 0, wxALL | wxEXPAND, WXC_FROM_DIP(5));

    m_checkBoxSaveAllFilesBefore = new wxCheckBox(this, wxID_ANY, _("Save all files before executing this tool"),
                                                  wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_checkBoxSaveAllFilesBefore->SetValue(false);
    m_checkBoxSaveAllFilesBefore->SetToolTip(_("Before executing this tool, save all files"));

    sbSizer2->Add(m_checkBoxSaveAllFilesBefore, 0, wxALL, WXC_FROM_DIP(5));

    m_checkBoxCaptureOutput = new wxCheckBox(this, wxID_ANY, _("Capture process output"), wxDefaultPosition,
                                             wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_checkBoxCaptureOutput->SetValue(false);

    sbSizer2->Add(m_checkBoxCaptureOutput, 0, wxALL, WXC_FROM_DIP(5));

    m_checkBoxCallOnFileSave = new wxCheckBox(this, wxID_ANY, _("Run this tool when a file is saved"),
                                              wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_checkBoxCallOnFileSave->SetValue(false);
    m_checkBoxCallOnFileSave->SetToolTip(_(
        "Whenever a file is being saved, this tool is called with\nthe file's fullpath as the first input argument."));

    sbSizer2->Add(m_checkBoxCallOnFileSave, 0, wxALL, WXC_FROM_DIP(5));

    bSizer1->Add(0, 0, 1, wxALL, WXC_FROM_DIP(5));

    m_stdBtnSizer2 = new wxStdDialogButtonSizer();

    bSizer1->Add(m_stdBtnSizer2, 0, wxALL | wxALIGN_CENTER_HORIZONTAL, WXC_FROM_DIP(10));

    m_button4 = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_button4->SetDefault();
    m_stdBtnSizer2->AddButton(m_button4);

    m_button6 = new wxButton(this, wxID_CANCEL, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_stdBtnSizer2->AddButton(m_button6);

    m_button8 = new wxButton(this, wxID_HELP, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
    m_button8->SetToolTip(_("Show list of available macros"));
    m_button8->SetToolTip(_("Show list of available macros"));
    m_stdBtnSizer2->AddButton(m_button8);
    m_stdBtnSizer2->Realize();

    SetName(wxT("NewToolBase"));
    SetSize(-1, -1);
    if(GetSizer()) { GetSizer()->Fit(this); }
    if(GetParent()) {
        CentreOnParent(wxBOTH);
    } else {
        CentreOnScreen(wxBOTH);
    }
#if wxVERSION_NUMBER >= 2900
    if(!wxPersistenceManager::Get().Find(this)) {
        wxPersistenceManager::Get().RegisterAndRestore(this);
    } else {
        wxPersistenceManager::Get().Restore(this);
    }
#endif
    // Connect events
    m_choiceId->Connect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(NewToolBase::OnIdSelected), NULL, this);
    m_buttonBrowsePath->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonBrowsePath),
                                NULL, this);
    m_buttonBrowseWd->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonBrowseWD), NULL,
                              this);
    m_buttonBrowseIcon24->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
                                  wxCommandEventHandler(NewToolBase::OnButtonBrowseIcon24), NULL, this);
    m_buttonBrowseIcon16->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
                                  wxCommandEventHandler(NewToolBase::OnButtonBrowseIcon16), NULL, this);
    m_button4->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonOk), NULL, this);
    m_button4->Connect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(NewToolBase::OnButtonOkUI), NULL, this);
    m_button6->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonCancel), NULL, this);
    m_button8->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonHelp), NULL, this);
}

NewToolBase::~NewToolBase()
{
    m_choiceId->Disconnect(wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler(NewToolBase::OnIdSelected), NULL, this);
    m_buttonBrowsePath->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonBrowsePath),
                                   NULL, this);
    m_buttonBrowseWd->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonBrowseWD),
                                 NULL, this);
    m_buttonBrowseIcon24->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED,
                                     wxCommandEventHandler(NewToolBase::OnButtonBrowseIcon24), NULL, this);
    m_buttonBrowseIcon16->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED,
                                     wxCommandEventHandler(NewToolBase::OnButtonBrowseIcon16), NULL, this);
    m_button4->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonOk), NULL, this);
    m_button4->Disconnect(wxEVT_UPDATE_UI, wxUpdateUIEventHandler(NewToolBase::OnButtonOkUI), NULL, this);
    m_button6->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonCancel), NULL, this);
    m_button8->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(NewToolBase::OnButtonHelp), NULL, this);
}