depeditdlg.cpp

00001 
00002 // Name:        depeditdlg.cpp
00003 // Purpose:     wxPackageDependencyEditDlg
00004 // Author:      Francesco Montorsi
00005 // Modified by:
00006 // Created:     Thu 10 Aug 2006 18:22:11 CEST
00007 // RCS-ID:      $Id: depeditdlg.cpp,v 1.2 2007/01/01 20:06:20 frm Exp $
00008 // Copyright:   (c) 2006 Francesco Montorsi
00009 // Licence:     wxWidgets license
00011 
00012 
00013 
00014 // For compilers that support precompilation, includes "wx/wx.h".
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/depeditdlg.h"
00026 
00027 
00028 // ----------------------------------------------------------------------------
00029 // wxPackageDependencyEditDlg
00030 // ----------------------------------------------------------------------------
00031 
00032 IMPLEMENT_DYNAMIC_CLASS( wxPackageDependencyEditDlg, wxDialog )
00033 BEGIN_EVENT_TABLE( wxPackageDependencyEditDlg, wxDialog )
00034     EVT_BUTTON( wxID_OK, wxPackageDependencyEditDlg::OnOK )
00035 END_EVENT_TABLE()
00036 
00037 wxPackageDependencyEditDlg::wxPackageDependencyEditDlg( )
00038 {
00039 }
00040 
00041 wxPackageDependencyEditDlg::wxPackageDependencyEditDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00042 {
00043     Create(parent, id, caption, pos, size, style);
00044 }
00045 
00046 bool wxPackageDependencyEditDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00047 {
00049     m_pDepType = NULL;
00050     m_pName = NULL;
00051     m_pVersion = NULL;
00053 
00055     SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00056     wxDialog::Create( parent, id, caption, pos, size, style );
00057 
00058     CreateControls();
00059     if (GetSizer())
00060     {
00061         GetSizer()->SetSizeHints(this);
00062     }
00063     Centre();
00065     return true;
00066 }
00067 
00068 void wxPackageDependencyEditDlg::CreateControls()
00069 {
00071     wxPackageDependencyEditDlg* itemDialog1 = this;
00072 
00073     wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00074     itemDialog1->SetSizer(itemBoxSizer2);
00075 
00076     wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Note: if this dependency regards some software which has not\nbeen wx-packaged yet, you should use the \"Suggested\"\ndependency type to make this package usable."), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
00077     itemBoxSizer2->Add(itemStaticText3, 0, wxGROW|wxALL|wxADJUST_MINSIZE, 5);
00078 
00079     wxFlexGridSizer* itemFlexGridSizer4 = new wxFlexGridSizer(2, 2, 0, 0);
00080     itemFlexGridSizer4->AddGrowableCol(1);
00081     itemBoxSizer2->Add(itemFlexGridSizer4, 0, wxGROW|wxALL, 5);
00082 
00083     wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Dependency type:"), wxDefaultPosition, wxDefaultSize, 0 );
00084     itemFlexGridSizer4->Add(itemStaticText5, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00085 
00086     wxString* m_pDepTypeStrings = NULL;
00087     m_pDepType = new wxChoice( itemDialog1, ID_DEPEDIT_TYPE, wxDefaultPosition, wxDefaultSize, 0, m_pDepTypeStrings, 0 );
00088     itemFlexGridSizer4->Add(m_pDepType, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00089 
00090     wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("Name of the package:"), wxDefaultPosition, wxDefaultSize, 0 );
00091     itemFlexGridSizer4->Add(itemStaticText7, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00092 
00093     m_pName = new wxTextCtrl( itemDialog1, ID_DEPEDIT_NAME, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00094     itemFlexGridSizer4->Add(m_pName, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00095 
00096     wxStaticText* itemStaticText9 = new wxStaticText( itemDialog1, wxID_STATIC, _("Version of the package:"), wxDefaultPosition, wxDefaultSize, 0 );
00097     itemFlexGridSizer4->Add(itemStaticText9, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00098 
00099     m_pVersion = new wxTextCtrl( itemDialog1, ID_DEPEDIT_VERSION, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00100     m_pVersion->SetHelpText(_("You can use either the 2.1.0-3.4.2 syntax (i.e. the hyphen separes two version numbers) or the 2.x.x syntax ('x' acts as a wildcard)"));
00101     if (ShowToolTips())
00102         m_pVersion->SetToolTip(_("You can use either the 2.1.0-3.4.2 syntax (i.e. the hyphen separes two version numbers) or the 2.x.x syntax ('x' acts as a wildcard)"));
00103     itemFlexGridSizer4->Add(m_pVersion, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
00104 
00105     wxStdDialogButtonSizer* itemStdDialogButtonSizer11 = new wxStdDialogButtonSizer;
00106 
00107     itemBoxSizer2->Add(itemStdDialogButtonSizer11, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00108     wxButton* itemButton12 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
00109     itemStdDialogButtonSizer11->AddButton(itemButton12);
00110 
00111     wxButton* itemButton13 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
00112     itemStdDialogButtonSizer11->AddButton(itemButton13);
00113 
00114     itemStdDialogButtonSizer11->Realize();
00115 
00117 
00118     m_pDepType->Append(wxArrayString(wxPDT_MAX, wxPackageDependencyTypeName));
00119     m_pDepType->Select(0);
00120 }
00121 
00122 bool wxPackageDependencyEditDlg::ShowToolTips()
00123 {
00124     return true;
00125 }
00126 
00127 
00128 
00129 
00130 // ----------------------------------------------------------------------------
00131 // wxPackageDependencyEditDlg - event handlers
00132 // ----------------------------------------------------------------------------
00133 
00134 void wxPackageDependencyEditDlg::OnOK(wxCommandEvent &WXUNUSED(ev))
00135 {
00136     if (m_pName->GetValue().IsEmpty())
00137     {
00138         wxLogError(wxT("Please specify the name of the %s package."),
00139                    m_pDepType->GetSelection() == wxPDT_REQUIRED ? wxT("required") : wxT("suggested"));
00140         return;
00141     }
00142 
00143     if (m_pVersion->GetValue().IsEmpty())
00144     {
00145         wxLogError(wxT("Please specify the valid versions of the %s package."),
00146                    m_pName->GetValue().c_str());
00147         return;
00148     }
00149     else if (!wxVersionRange(m_pVersion->GetValue()).IsOk())
00150     {
00151         wxLogError(wxT("Invalid version range syntax: %s"),
00152                    m_pVersion->GetValue().c_str());
00153         return;
00154     }
00155 
00156     EndModal(wxID_OK);
00157 }

Generated on Thu Feb 1 22:14:30 2007 for wxWidgets Package Manager by  doxygen 1.5.1-p1