Code::Blocks  SVN r11506
compilerflagdlg.cpp
Go to the documentation of this file.
1 #include <sdk.h>
2 #include <prep.h>
3 #ifndef CB_PRECOMP
4  #include <wx/button.h>
5  #include <wx/combobox.h>
6  #include <wx/xrc/xmlres.h>
7  #include <wx/textctrl.h>
8 #endif
9 #include <wx/tglbtn.h>
10 
11 #include "compilerflagdlg.h"
12 #include "compileroptions.h"
13 
15  const wxString &selectedCategory)
16 {
17  wxXmlResource::Get()->LoadObject(this, parent, wxT("CompilerFlagDlg"), wxT("wxDialog"));
18  XRCCTRL(*this, "wxID_OK", wxButton)->SetDefault();
19  NameText = (wxTextCtrl*)FindWindow(XRCID("ID_Name"));
20  CompilerText = (wxTextCtrl*)FindWindow(XRCID("ID_Compiler"));
21  LinkerText = (wxTextCtrl*)FindWindow(XRCID("ID_Linker"));
22  CategoryCombo = (wxComboBox*)FindWindow(XRCID("ID_Category"));
23  AgainstText = (wxTextCtrl*)FindWindow(XRCID("ID_Against"));
24  MessageText = (wxTextCtrl*)FindWindow(XRCID("ID_Message"));
25  SupersedeText = (wxTextCtrl*)FindWindow(XRCID("ID_Supersede"));
26  ExclusiveToggle = (wxToggleButton*)FindWindow(XRCID("ID_Exclusive"));
27 
28  Connect(XRCID("ID_Against"), wxEVT_COMMAND_TEXT_UPDATED, (wxObjectEventFunction)&CompilerFlagDlg::OnAdvancedOption);
29  Connect(XRCID("ID_Exclusive"), wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, (wxObjectEventFunction)&CompilerFlagDlg::OnAdvancedOption);
30 
31  copt = opt;
32  if (!copt->name.IsEmpty())
33  {
34  SetTitle(_("Modify flag"));
35  wxString oName;
36  copt->name.EndsWith(wxT("[") + copt->option + wxT("]"), &oName);
37  if (oName == wxEmptyString)
38  copt->name.EndsWith(wxT("[") + copt->additionalLibs + wxT("]"), &oName);
39  if (oName == wxEmptyString)
40  oName = copt->name;
41  NameText->SetValue(oName.Trim());
42  CompilerText->SetValue(copt->option);
43  LinkerText->SetValue(copt->additionalLibs);
44  CategoryCombo->SetValue(copt->category);
45  AgainstText->SetValue(copt->checkAgainst);
46  MessageText->SetValue(copt->checkMessage);
47  SupersedeText->SetValue(copt->supersedes);
48  if (copt->exclusive)
49  {
51  ExclusiveToggle->SetLabel(_("True"));
52  }
53  }
54  CategoryCombo->Append(categ);
55  if (!selectedCategory.empty())
56  CategoryCombo->SetStringSelection(selectedCategory);
57  MessageText->Enable(!AgainstText->GetValue().Trim().Trim(false).IsEmpty());
58 
59  // Limit vertical resizing.
60  SetMaxSize(wxSize(-1, GetMinHeight()));
61 }
62 
64 {
65  // dtor
66 }
67 
69 {
71  ExclusiveToggle->SetLabel(_("True"));
72  else
73  ExclusiveToggle->SetLabel(_("False"));
74  MessageText->Enable(!AgainstText->GetValue().Trim().Trim(false).IsEmpty());
75 }
76 
77 void CompilerFlagDlg::EndModal(int retCode)
78 {
79  if (retCode == wxID_CANCEL)
80  {
81  wxDialog::EndModal(retCode);
82  return;
83  }
84  bool same = copt->name.BeforeLast(wxT('[')).Trim() == NameText->GetValue() &&
85  copt->option == CompilerText->GetValue() &&
86  copt->additionalLibs == LinkerText->GetValue() &&
87  copt->category == CategoryCombo->GetValue() &&
88  copt->checkAgainst == AgainstText->GetValue() &&
89  copt->checkMessage == MessageText->GetValue() &&
90  copt->supersedes == SupersedeText->GetValue() &&
92  copt->name = NameText->GetValue().Trim().Trim(false);
93  copt->option = CompilerText->GetValue().Trim().Trim(false);
94  copt->additionalLibs = LinkerText->GetValue().Trim().Trim(false);
95  copt->category = CategoryCombo->GetValue().Trim().Trim(false);
96  if (copt->category.IsEmpty())
97  copt->category = wxT("General");
98  copt->checkAgainst = AgainstText->GetValue().Trim().Trim(false);
99  if (!copt->checkAgainst.IsEmpty())
100  copt->checkMessage = MessageText->GetValue().Trim().Trim(false);
101  copt->supersedes = SupersedeText->GetValue().Trim().Trim(false);
103  if (same || copt->name.IsEmpty() || (copt->option.IsEmpty() && copt->additionalLibs.IsEmpty()))
105  else
106  wxDialog::EndModal(retCode);
107 }
wxString additionalLibs
void EndModal(int retCode)
Definition: sc_dialog.cpp:112
wxTextCtrl * SupersedeText
wxToggleButton * ExclusiveToggle
wxTextCtrl * NameText
CompOption * copt
wxString supersedes
virtual bool GetValue() const
wxString BeforeLast(wxUniChar ch, wxString *rest=NULL) const
wxString name
#define wxT(string)
bool empty() const
wxString option
void EndModal(int retCode)
wxTextCtrl * CompilerText
void OnAdvancedOption(wxCommandEvent &event)
virtual void SetValue(bool state)
wxString wxEmptyString
wxTextCtrl * AgainstText
wxComboBox * CategoryCombo
const wxString & _(const wxString &string)
wxString & Trim(bool fromRight=true)
wxString category
wxTextCtrl * LinkerText
wxString checkMessage
bool IsEmpty() const
wxString checkAgainst
bool EndsWith(const wxString &suffix, wxString *rest=NULL) const
wxTextCtrl * MessageText
static wxXmlResource * Get()
CompilerFlagDlg(wxWindow *parent, CompOption *opt, wxArrayString &categ, const wxString &selectedCategory)
virtual ~CompilerFlagDlg()
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)