proppanel_xmlsource.cpp

00001 
00002 // Name:        proppanel_xmlsource.cpp
00003 // Purpose:     wxPackagePropertiesPanel
00004 //              (stuff for handling the "xml source" page)
00005 // Author:      Francesco Montorsi
00006 // Modified by:
00007 // Created:     28/06/2006 19:22:47
00008 // RCS-ID:      $Id: proppanel_xmlsource.cpp,v 1.7 2007/01/31 13:01:22 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 <wx/sstream.h>
00026 
00027 #include "guipkg/proppanel.h"
00028 #include "guipkg/sourceeditctrl.h"
00029 
00030 #include "wxp/package.h"
00031 #include "wxp/wxp.h"
00032 #include "wxp/packagewxp.h"
00033 
00034 
00035 
00036 // ----------------------------------------------------------------------------
00037 // wxPackagePropertiesPanel - xml source stuff
00038 // ----------------------------------------------------------------------------
00039 
00040 void wxPackagePropertiesPanel::InitXMLSourcePage()
00041 {
00042     m_pEditor = new wxPackageSourceEditCtrl(m_pXMLPanel, -1);
00043     m_pXMLSizer->Add(m_pEditor, 1, wxGROW|wxALL, 5);
00044 
00045     m_pEditor->SetToolTip(_("This is the read-only XML source for the package description file (WXP) which will be created when you use the 'Save' command."));
00046 }
00047 
00048 void wxPackagePropertiesPanel::UpdateXML()
00049 {
00050     // use updated data
00051     TransferDataFromWindow();
00052 
00053     // save XML description to a wxString
00054     wxStringOutputStream out;
00055     m_xmlDescriptor.SetPackageInfo(GetPackageInfo());
00056     if (!m_xmlDescriptor.Save(out))
00057     {
00058         wxLogError(wxT("Could not create an XML description for this package!"));
00059         return;
00060     }
00061 
00062     // update XML source page
00063     m_pEditor->UpdateSource(out.GetString());
00064 }
00065 
00066 
00067 
00068 // ----------------------------------------------------------------------------
00069 // wxPackagePropertiesPanel - event handlers
00070 // ----------------------------------------------------------------------------
00071 
00072 void wxPackagePropertiesPanel::OnPageChanged(wxNotebookEvent &ev)
00073 {
00074     // we are only interested to this event when the user
00075     // selects the XML source page
00076     if (ev.GetSelection() != wxPROPPANEL_XMLSOURCE_PAGE_INDEX)
00077         return;
00078 
00079     UpdateXML();
00080 }

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