optpresetchooserdlg.cpp

00001 
00002 // Name:        optpresetchooserdlg.cpp
00003 // Purpose:     wxPackageOptionPresetChooserDialog
00004 // Author:      Francesco Montorsi
00005 // Modified by:
00006 // Created:     18/09/2006 23:11:38
00007 // RCS-ID:      $Id: optpresetchooserdlg.cpp,v 1.4 2007/01/27 23:15:36 frm Exp $
00008 // Copyright:   (c) 2006 Francesco Montorsi
00009 // Licence:     wxWidgets license
00011 
00012 
00013 // For compilers that support precompilation, includes "wx/wx.h".
00014 #include "wx/wxprec.h"
00015 
00016 #ifdef __BORLANDC__
00017 #pragma hdrstop
00018 #endif
00019 
00020 #ifndef WX_PRECOMP
00021 #include "wx/wx.h"
00022 #endif
00023 
00024 #include "guipkg/optpresetchooserdlg.h"
00025 #include "guipkg/optlistctrl.h"
00026 
00027 
00028 // ----------------------------------------------------------------------------
00029 // wxPackageOptionPresetChooserDialog
00030 // ----------------------------------------------------------------------------
00031 
00032 IMPLEMENT_DYNAMIC_CLASS( wxPackageOptionPresetChooserDlg, wxDialog )
00033 BEGIN_EVENT_TABLE( wxPackageOptionPresetChooserDlg, wxDialog )
00034     EVT_CHOICE( ID_OPTPRESETCHOOSER_PRESETS, 
00035                 wxPackageOptionPresetChooserDlg::OnPreset )
00036 END_EVENT_TABLE()
00037 
00038 wxPackageOptionPresetChooserDlg::wxPackageOptionPresetChooserDlg( )
00039 {
00040 }
00041 
00042 wxPackageOptionPresetChooserDlg::wxPackageOptionPresetChooserDlg( wxWindow* parent, wxWindowID id, wxPackageBuildSystemType type, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00043 {
00044     Create(parent, id, type, caption, pos, size, style);
00045 }
00046 
00047 bool wxPackageOptionPresetChooserDlg::Create( wxWindow* parent, wxWindowID id, wxPackageBuildSystemType type, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00048 {
00050     m_pPresets = NULL;
00051     m_pDescription = NULL;
00052     m_pPreview = NULL;
00054 
00055     SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00056     wxDialog::Create( parent, id, caption, pos, size, style );
00057 
00058     CreateControls(type);
00059     if (GetSizer())
00060     {
00061         SetMinSize(GetBestSize().Scale(2.5, 1.0));
00062         GetSizer()->SetSizeHints(this);
00063     }
00064     Centre();
00065     return true;
00066 }
00067 
00068 void wxPackageOptionPresetChooserDlg::CreateControls(wxPackageBuildSystemType type)
00069 {    
00071     wxPackageOptionPresetChooserDlg* itemDialog1 = this;
00072 
00073     wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00074     itemDialog1->SetSizer(itemBoxSizer2);
00075 
00076     wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
00077     itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW, 5);
00078 
00079     wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Available option presets:"), wxDefaultPosition, wxDefaultSize, 0 );
00080     itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00081 
00082     wxString* m_pPresetsStrings = NULL;
00083     m_pPresets = new wxChoice( itemDialog1, ID_OPTPRESETCHOOSER_PRESETS, wxDefaultPosition, wxDefaultSize, 0, m_pPresetsStrings, 0 );
00084     itemBoxSizer3->Add(m_pPresets, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00085 
00086     wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Preset description:"), wxDefaultPosition, wxDefaultSize, 0 );
00087     itemBoxSizer2->Add(itemStaticText6, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
00088 
00089     m_pDescription = new wxTextCtrl( itemDialog1, ID_OPTPRESETCHOOSER_DESC, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
00090     itemBoxSizer2->Add(m_pDescription, 1, wxGROW|wxALL, 5);
00091 
00092     wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Preset preview:"), wxDefaultPosition, wxDefaultSize, 0 );
00093     itemBoxSizer2->Add(itemStaticText8, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP, 5);
00094 
00095     m_pPreview = new wxOptionListCtrl( itemDialog1, ID_OPTPRESETCHOOSER_PREVIEW, wxDefaultPosition, wxSize(350, 100), 0 );
00096     itemBoxSizer2->Add(m_pPreview, 3, wxGROW|wxALL, 5);
00097 
00098     wxStdDialogButtonSizer* itemStdDialogButtonSizer10 = new wxStdDialogButtonSizer;
00099 
00100     itemBoxSizer2->Add(itemStdDialogButtonSizer10, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00101     wxButton* itemButton11 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
00102     itemStdDialogButtonSizer10->AddButton(itemButton11);
00103 
00104     wxButton* itemButton12 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
00105     itemStdDialogButtonSizer10->AddButton(itemButton12);
00106 
00107     itemStdDialogButtonSizer10->Realize();
00108 
00110 
00111     // init controls with presets suitable for the given build system type
00112     m_pPresets->Append(wxPresetXMLDescriptor::GetOptionPresetNamesFor(type));
00113 
00114     wxASSERT(m_pPresets->GetCount() > 0);
00115     m_pPresets->Select(0);
00116 
00117     wxCommandEvent fake;
00118     OnPreset(fake);
00119 }
00120 
00121 bool wxPackageOptionPresetChooserDlg::ShowToolTips()
00122 {
00123     return true;
00124 }
00125 
00126 
00127 // ----------------------------------------------------------------------------
00128 // wxPackageOptionPresetChooserDialog - event handlers
00129 // ----------------------------------------------------------------------------
00130 
00131 void wxPackageOptionPresetChooserDlg::OnPreset(wxCommandEvent &WXUNUSED(ev))
00132 {
00133     const wxPackageCommandOptionArray &arr = GetSelectedPreset();
00134 
00135     // update description
00136     m_pDescription->SetValue(arr.GetDescription());
00137 
00138     // update preview
00139     m_pPreview->SetOptions(arr);
00140 }
00141 

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