cmdpresetchooserdlg.cpp

00001 
00002 // Name:        cmdpresetchooserdlg.cpp
00003 // Purpose:     wxPackageCommandPresetChooserDialog
00004 // Author:      Francesco Montorsi
00005 // Modified by:
00006 // Created:     18/09/2006 23:11:59
00007 // RCS-ID:      $Id: cmdpresetchooserdlg.cpp,v 1.3 2007/01/01 20:06:20 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/cmdpresetchooserdlg.h"
00025 #include "guicmn/commandlistbox.h"
00026 
00027 
00028 
00029 // ----------------------------------------------------------------------------
00030 // wxPackageCommandPresetChooserDialog
00031 // ----------------------------------------------------------------------------
00032 
00033 IMPLEMENT_DYNAMIC_CLASS( wxPackageCommandPresetChooserDlg, wxDialog )
00034 BEGIN_EVENT_TABLE( wxPackageCommandPresetChooserDlg, wxDialog )
00035     EVT_CHOICE( ID_CMDPRESETCHOOSER_PRESETS, 
00036                 wxPackageCommandPresetChooserDlg::OnPreset )
00037 END_EVENT_TABLE()
00038 
00039 wxPackageCommandPresetChooserDlg::wxPackageCommandPresetChooserDlg( )
00040 {
00041 }
00042 
00043 wxPackageCommandPresetChooserDlg::wxPackageCommandPresetChooserDlg( wxWindow* parent, wxWindowID id, wxPackageBuildSystemType type, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00044 {
00045     Create(parent, id, type, caption, pos, size, style);
00046 }
00047 
00048 bool wxPackageCommandPresetChooserDlg::Create( wxWindow* parent, wxWindowID id, wxPackageBuildSystemType type, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00049 {
00051     m_pPresets = NULL;
00052     m_pDescription = NULL;
00053     m_pVariables = NULL;
00054     m_pPreview = NULL;
00056 
00057     SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00058     wxDialog::Create( parent, id, caption, pos, size, style );
00059 
00060     CreateControls(type);
00061     if (GetSizer())
00062     {
00063         GetSizer()->SetSizeHints(this);
00064     }
00065     Centre();
00066 
00067     return true;
00068 }
00069 
00070 void wxPackageCommandPresetChooserDlg::CreateControls(wxPackageBuildSystemType type)
00071 {    
00073     wxPackageCommandPresetChooserDlg* itemDialog1 = this;
00074 
00075     wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00076     itemDialog1->SetSizer(itemBoxSizer2);
00077 
00078     wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
00079     itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW, 5);
00080 
00081     wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Available command presets:"), wxDefaultPosition, wxDefaultSize, 0 );
00082     itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00083 
00084     wxString* m_pPresetsStrings = NULL;
00085     m_pPresets = new wxChoice( itemDialog1, ID_CMDPRESETCHOOSER_PRESETS, wxDefaultPosition, wxDefaultSize, 0, m_pPresetsStrings, 0 );
00086     itemBoxSizer3->Add(m_pPresets, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00087 
00088     wxBoxSizer* itemBoxSizer6 = new wxBoxSizer(wxHORIZONTAL);
00089     itemBoxSizer2->Add(itemBoxSizer6, 0, wxGROW, 5);
00090 
00091     wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("Preset description:"), wxDefaultPosition, wxDefaultSize, 0 );
00092     itemBoxSizer6->Add(itemStaticText7, 2, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00093 
00094     wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Variables:"), wxDefaultPosition, wxDefaultSize, 0 );
00095     itemBoxSizer6->Add(itemStaticText8, 1, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00096 
00097     wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxHORIZONTAL);
00098     itemBoxSizer2->Add(itemBoxSizer9, 2, wxGROW, 5);
00099 
00100     m_pDescription = new wxTextCtrl( itemDialog1, ID_CMDPRESETCHOOSER_DESC, _T(""), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
00101     itemBoxSizer9->Add(m_pDescription, 2, wxGROW|wxALL, 5);
00102 
00103     wxString* m_pVariablesStrings = NULL;
00104     m_pVariables = new wxListBox( itemDialog1, ID_CMDPRESETCHOOSER_VARIABLES, wxDefaultPosition, wxDefaultSize, 0, m_pVariablesStrings, wxLB_SINGLE );
00105     itemBoxSizer9->Add(m_pVariables, 1, wxGROW|wxALL, 5);
00106 
00107     wxStaticText* itemStaticText12 = new wxStaticText( itemDialog1, wxID_STATIC, _("Preset preview:"), wxDefaultPosition, wxDefaultSize, 0 );
00108     itemBoxSizer2->Add(itemStaticText12, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00109 
00110     m_pPreview = new wxCommandListBox( itemDialog1, ID_CMDPRESETCHOOSER_PREVIEW, wxDefaultPosition, wxSize(400, 100), 0 );
00111     itemBoxSizer2->Add(m_pPreview, 3, wxGROW|wxALL|wxFIXED_MINSIZE, 5);
00112 
00113     wxStdDialogButtonSizer* itemStdDialogButtonSizer14 = new wxStdDialogButtonSizer;
00114 
00115     itemBoxSizer2->Add(itemStdDialogButtonSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00116     wxButton* itemButton15 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
00117     itemStdDialogButtonSizer14->AddButton(itemButton15);
00118 
00119     wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
00120     itemStdDialogButtonSizer14->AddButton(itemButton16);
00121 
00122     itemStdDialogButtonSizer14->Realize();
00123 
00125 
00126     // init controls with presets suitable for the given build system type
00127     m_pPresets->Append(wxPresetXMLDescriptor::GetCommandPresetNamesFor(type));
00128 
00129     wxASSERT(m_pPresets->GetCount() > 0);
00130     m_pPresets->Select(0);
00131 
00132     wxCommandEvent fake;
00133     OnPreset(fake);
00134 }
00135 
00136 bool wxPackageCommandPresetChooserDlg::ShowToolTips()
00137 {
00138     return true;
00139 }
00140 
00141 
00142 // ----------------------------------------------------------------------------
00143 // wxPackageCommandPresetChooserDialog - event handlers
00144 // ----------------------------------------------------------------------------
00145 
00146 void wxPackageCommandPresetChooserDlg::OnPreset(wxCommandEvent &WXUNUSED(ev))
00147 {
00148     const wxPackageCommandSet &arr = GetSelectedPreset();
00149 
00150     // update description
00151     m_pDescription->SetValue(arr.GetDescription());
00152 
00153     // update preview
00154     m_pPreview->SetCommands(arr);
00155 
00156     // update variables
00157     m_pVariables->Clear();
00158     m_pVariables->Append(arr.GetVars());
00159 }

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