00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015 #include "wx/wxprec.h"
00016
00017 #ifdef __BORLANDC__
00018 #pragma hdrstop
00019 #endif
00020
00021 #ifndef WX_PRECOMP
00022 #include "wx/wx.h"
00023 #endif
00024
00025 #include "guipkg/opteditdlg.h"
00026
00027
00028
00029
00030
00031
00032 IMPLEMENT_DYNAMIC_CLASS( wxPackageOptionEditDlg, wxDialog )
00033 BEGIN_EVENT_TABLE( wxPackageOptionEditDlg, wxDialog )
00034 EVT_BUTTON( wxID_OK, wxPackageOptionEditDlg::OnOK )
00035 EVT_CHOICE( ID_OPTEDIT_CATEGORY, wxPackageOptionEditDlg::OnCategory )
00036 END_EVENT_TABLE()
00037
00038 wxPackageOptionEditDlg::wxPackageOptionEditDlg( )
00039 {
00040 }
00041
00042 wxPackageOptionEditDlg::wxPackageOptionEditDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00043 {
00044 Create(parent, id, caption, pos, size, style);
00045 }
00046
00047 bool wxPackageOptionEditDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00048 {
00050 m_pNotebook = NULL;
00051 m_pName = NULL;
00052 m_pCategory = NULL;
00053 m_pAllowedValues = NULL;
00054 m_pDefValue = NULL;
00055 m_pGroup = NULL;
00056 m_pDescription = NULL;
00058
00060 SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00061 wxDialog::Create( parent, id, caption, pos, size, style );
00062
00063 CreateControls();
00064 if (GetSizer())
00065 {
00066 GetSizer()->SetSizeHints(this);
00067 }
00068 Centre();
00070 return true;
00071 }
00072
00073 void wxPackageOptionEditDlg::CreateControls()
00074 {
00076 wxPackageOptionEditDlg* itemDialog1 = this;
00077
00078 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00079 itemDialog1->SetSizer(itemBoxSizer2);
00080
00081 m_pNotebook = new wxNotebook( itemDialog1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP );
00082
00083 wxPanel* itemPanel4 = new wxPanel( m_pNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
00084 wxFlexGridSizer* itemFlexGridSizer5 = new wxFlexGridSizer(2, 2, 0, 0);
00085 itemFlexGridSizer5->AddGrowableRow(5);
00086 itemFlexGridSizer5->AddGrowableCol(1);
00087 itemPanel4->SetSizer(itemFlexGridSizer5);
00088
00089 wxStaticText* itemStaticText6 = new wxStaticText( itemPanel4, wxID_STATIC, _("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
00090 itemFlexGridSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00091
00092 m_pName = new wxTextCtrl( itemPanel4, ID_OPTEDIT_NAME, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00093 if (ShowToolTips())
00094 m_pName->SetToolTip(_("Be sure to use only characters in range A-Z and a-z for the option name!"));
00095 itemFlexGridSizer5->Add(m_pName, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00096
00097 wxStaticText* itemStaticText8 = new wxStaticText( itemPanel4, wxID_STATIC, _("Category:"), wxDefaultPosition, wxDefaultSize, 0 );
00098 itemFlexGridSizer5->Add(itemStaticText8, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00099
00100 wxString* m_pCategoryStrings = NULL;
00101 m_pCategory = new wxChoice( itemPanel4, ID_OPTEDIT_CATEGORY, wxDefaultPosition, wxDefaultSize, 0, m_pCategoryStrings, 0 );
00102 itemFlexGridSizer5->Add(m_pCategory, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00103
00104 wxStaticText* itemStaticText10 = new wxStaticText( itemPanel4, wxID_STATIC, _("Allowed values:"), wxDefaultPosition, wxDefaultSize, 0 );
00105 itemFlexGridSizer5->Add(itemStaticText10, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00106
00107 m_pAllowedValues = new wxTextCtrl( itemPanel4, ID_OPTEDIT_VALUES, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00108 if (ShowToolTips())
00109 m_pAllowedValues->SetToolTip(_("Type a comma-separed list of the values allowed for this option"));
00110 itemFlexGridSizer5->Add(m_pAllowedValues, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00111
00112 wxStaticText* itemStaticText12 = new wxStaticText( itemPanel4, wxID_STATIC, _("Default value:"), wxDefaultPosition, wxDefaultSize, 0 );
00113 itemFlexGridSizer5->Add(itemStaticText12, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00114
00115 m_pDefValue = new wxTextCtrl( itemPanel4, ID_OPTEDIT_DEFVALUE, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00116 itemFlexGridSizer5->Add(m_pDefValue, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00117
00118 wxStaticText* itemStaticText14 = new wxStaticText( itemPanel4, wxID_STATIC, _("Group:"), wxDefaultPosition, wxDefaultSize, 0 );
00119 itemFlexGridSizer5->Add(itemStaticText14, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00120
00121 wxString* m_pGroupStrings = NULL;
00122 m_pGroup = new wxComboBox( itemPanel4, ID_OPTEDIT_GROUP, _T(""), wxDefaultPosition, wxDefaultSize, 0, m_pGroupStrings, wxCB_DROPDOWN );
00123 itemFlexGridSizer5->Add(m_pGroup, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00124
00125 wxStaticText* itemStaticText16 = new wxStaticText( itemPanel4, wxID_STATIC, _("Description:"), wxDefaultPosition, wxDefaultSize, 0 );
00126 itemFlexGridSizer5->Add(itemStaticText16, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00127
00128 m_pDescription = new wxTextCtrl( itemPanel4, ID_OPTEDIT_DESCRIPTION, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
00129 itemFlexGridSizer5->Add(m_pDescription, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00130
00131 m_pNotebook->AddPage(itemPanel4, _("Option"));
00132
00133 itemBoxSizer2->Add(m_pNotebook, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00134
00135 wxStdDialogButtonSizer* itemStdDialogButtonSizer18 = new wxStdDialogButtonSizer;
00136
00137 itemBoxSizer2->Add(itemStdDialogButtonSizer18, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00138 wxButton* itemButton19 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
00139 itemStdDialogButtonSizer18->AddButton(itemButton19);
00140
00141 wxButton* itemButton20 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
00142 itemStdDialogButtonSizer18->AddButton(itemButton20);
00143
00144 itemStdDialogButtonSizer18->Realize();
00145
00147
00148
00149 wxPanel *panel = new wxPanel(m_pNotebook, wxID_ANY);
00150 wxSizer *sz = new wxBoxSizer(wxVERTICAL);
00151 m_pConditionPanel = new wxPackageConditionPanel(panel, wxID_ANY);
00152 sz->Add(new wxStaticText(panel, wxID_ANY,
00153 _("Check the build systems, platforms, formats and stages to which this option applies.")), 0, wxGROW|wxALL, 5);
00154 sz->AddSpacer(10);
00155 sz->Add(m_pConditionPanel, 1, wxGROW);
00156 sz->AddSpacer(10);
00157 panel->SetSizer(sz);
00158 sz->SetSizeHints(panel);
00159 m_pNotebook->AddPage(panel, _("Condition"));
00160
00161
00162 m_pCategory->Append(wxArrayString(wxPCOC_MAX, wxPackageCommandOptionCategoryName));
00163 m_pCategory->Select(0);
00164
00165
00166 m_pGroup->Append(wxT("wxWidgets"));
00167 m_pGroup->Append(wxT("Compiler"));
00168
00169
00170 wxPackageCondition cond;
00171 cond.SetAlwaysTrue();
00172 m_pConditionPanel->SetCondition(cond);
00173 }
00174
00175 bool wxPackageOptionEditDlg::ShowToolTips()
00176 {
00177 return true;
00178 }
00179
00180
00181
00182
00183
00184
00185 void wxPackageOptionEditDlg::OnOK(wxCommandEvent &WXUNUSED(ev))
00186 {
00187 wxString name(m_pName->GetValue());
00188 if (name.IsEmpty())
00189 {
00190 wxLogError(wxT("Please provide the option name."));
00191 return;
00192 }
00193 else if (!wxIsPlainWord(name))
00194 {
00195 wxLogError(wxT("Invalid name '%s'.\nYou can use only the following characters:\n%s"),
00196 name.c_str(), wxGetPlainWordAllowedCharacters().c_str());
00197 return;
00198 }
00199
00200 wxString defvalue(m_pDefValue->GetValue());
00201 if (!wxIsPlainWord(defvalue))
00202 {
00203 wxLogError(wxT("Invalid default value '%s'.\nYou can use only the following characters:\n%s"),
00204 defvalue.c_str(), wxGetPlainWordAllowedCharacters().c_str());
00205 return;
00206 }
00207
00208 wxString values(m_pAllowedValues->GetValue());
00209 if (m_pCategory->GetSelection() == wxPCOC_LISTED_VALUES)
00210 {
00211 if (values.IsEmpty())
00212 {
00213 wxLogError(wxT("Please provide the allowed values."));
00214 return;
00215 }
00216 else if (!values.Contains(defvalue))
00217 {
00218 wxLogError(wxT("The default value '%s' is not one of the allowed values '%s' ?"),
00219 defvalue.c_str(), values.c_str());
00220 return;
00221 }
00222 }
00223
00224 if (m_pGroup->GetValue().IsEmpty())
00225 {
00226 wxLogError(wxT("Please provide the name of the group of the option.\nNote that you can create new groups just typing the name of a group which does not exist yet."));
00227 return;
00228 }
00229
00230 EndModal(wxID_OK);
00231 }
00232
00233 void wxPackageOptionEditDlg::OnCategory(wxCommandEvent &WXUNUSED(ev))
00234 {
00235 bool enable = m_pCategory->GetSelection() == wxPCOC_LISTED_VALUES;
00236 m_pAllowedValues->Enable(enable);
00237 }