proppanel_basics.cpp

00001 
00002 // Name:        proppanel_basics.cpp
00003 // Purpose:     wxPackagePropertiesPanel
00004 //              (stuff for handling the "basics" page)
00005 // Author:      Francesco Montorsi
00006 // Modified by:
00007 // Created:     28/06/2006 19:22:47
00008 // RCS-ID:      $Id: proppanel_basics.cpp,v 1.5 2007/01/02 19:33:00 frm Exp $
00009 // Copyright:   (c) 2006 Julian Smart, Francesco Montorsi
00010 // Licence:     wxWidgets license
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/proppanel.h"
00026 #include "guicmn/commandlistbox.h"
00027 
00028 #include "wxp/package.h"
00029 #include "wxp/wxp.h"
00030 #include "wxp/packagewxp.h"
00031 
00032 #include "wx/miscutils.h"
00033 
00034 
00035 // ----------------------------------------------------------------------------
00036 // wxPackagePropertiesPanel - basics panel - I/O
00037 // ----------------------------------------------------------------------------
00038 
00039 void wxPackagePropertiesPanel::InitBasicsPage()
00040 {
00041     m_pPrimaryCat->Append(wxArrayString(wxPC_MAX, wxPackageCategoryName));
00042     m_pSecondaryCat->Append(wxArrayString(wxPC_MAX, wxPackageCategoryName));
00043     m_pPrimaryCat->Select(0);
00044     m_pSecondaryCat->Select(0);
00045 }
00046 
00047 void wxPackagePropertiesPanel::GetBasicsPackageInfo(wxPackageInfo &ret) const
00048 {
00049     // BASIC info
00050     ret.SetName(m_pName->GetValue());
00051     ret.SetVersion(m_pVersion->GetValue());
00052     ret.SetDescription(m_pDescription->GetValue());
00053     ret.SetKeywords(m_pKeywords->GetValue());
00054     ret.SetCategories((wxPackageCategory)m_pPrimaryCat->GetSelection(),
00055                       (wxPackageCategory)m_pSecondaryCat->GetSelection());
00056 }
00057 
00058 void wxPackagePropertiesPanel::DoSetBasicsPackageInfo(const wxPackageInfo &p)
00059 {
00060     // BASIC info
00061     m_pName->SetValue(p.GetName());
00062     if (p.GetVersion().IsOk())
00063         m_pVersion->SetValue(p.GetVersion());
00064     else
00065         m_pVersion->SetValue(wxEmptyString);
00066     m_pDescription->SetValue(p.GetDescription());
00067     m_pKeywords->SetValue(p.GetKeywordsStr());
00068     m_pPrimaryCat->Select(p.GetPrimaryCategory());
00069     m_pSecondaryCat->Select(p.GetSecondaryCategory());
00070 }
00071 
00072 bool wxPackagePropertiesPanel::IsBasicsPageOk() const
00073 {
00074     bool isok = true;
00075 
00076     // check name
00077     wxString name(m_pName->GetValue());
00078     if (name.IsEmpty())
00079     {
00080         wxLogError(wxT("The package name is not optional"));
00081         isok = false;
00082     }
00083     else if (!wxIsPlainWord(name))
00084     {
00085         wxLogError(wxT("Invalid name '%s'.\nYou can use only the following characters:\n%s"),
00086                    name.c_str(), wxGetPlainWordAllowedCharacters().c_str());
00087         isok = false;
00088     }
00089 
00090     // check version
00091     wxString ver(m_pVersion->GetValue());
00092     if (ver.IsEmpty())
00093     {
00094         wxLogError(wxT("The package version is not optional"));
00095         isok = false;
00096     }
00097     else if (!wxVersion(ver).IsOk())
00098     {
00099         wxLogError(wxT("Invalid version syntax '%s'"), ver.c_str());
00100         isok = false;
00101     }
00102 
00103     // check description
00104     wxString desc(m_pDescription->GetValue());
00105     if (desc.IsEmpty())
00106     {
00107         wxLogError(wxT("The package description is not optional"));
00108         isok = false;
00109     }
00110 
00111     // check keywords
00112     wxString k(m_pKeywords->GetValue());
00113     if (k.IsEmpty())
00114     {
00115         wxLogError(wxT("The package keywords are not optional"));
00116         isok = false;
00117     }
00118 
00119     // check categories
00120     if (m_pPrimaryCat->GetSelection() == m_pSecondaryCat->GetSelection())
00121     {
00122         wxLogWarning(wxT("The same category is selected both as primary and as secondary."));
00123         isok = false;
00124     }
00125 
00126     return isok;
00127 }
00128 

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