wxbuildpropdlg.cpp

00001 
00002 // Name:        wxbuildpropdlg.cpp
00003 // Purpose:     wxPackageWXBuildPropDlg
00004 // Author:      Francesco Montorsi
00005 // Modified by:
00006 // Created:     25/07/2006 16:35:04
00007 // RCS-ID:      $Id: wxbuildpropdlg.cpp,v 1.3 2007/01/17 21:51:46 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 "guipm/opteditctrl.h"
00025 #include "guipm/wxbuildpropdlg.h"
00026 #include "wxp/wxp.h"
00027 
00028 #include "wx/filepicker.h"
00029 #include "wx/apptrait.h"
00030 
00031 
00032 // the list of wx ports which can be used on the platform we're running on
00033 #if defined( __WXMSW__ )
00034     long g_supportedPorts = wxPORT_MSW;
00035 #elif defined( __WXGTK__ ) || defined( __WXX11__ ) || defined( __WXMOTIF__ )
00036     long g_supportedPorts = wxPORT_GTK|wxPORT_X11|wxPORT_MOTIF;
00037 #elif defined( __WXMAC__ )
00038     long g_supportedPorts = wxPORT_MAC;
00039 #endif
00040 
00041 
00042 
00043 // ----------------------------------------------------------------------------
00044 // wxPackageWXBuildPropDlg
00045 // ----------------------------------------------------------------------------
00046 
00047 IMPLEMENT_DYNAMIC_CLASS( wxPackageWXBuildPropDlg, wxDialog )
00048 BEGIN_EVENT_TABLE( wxPackageWXBuildPropDlg, wxDialog )
00049     EVT_BUTTON(wxID_OK, wxPackageWXBuildPropDlg::OnOK)
00050     EVT_BUTTON(ID_WXBUILDPROP_AUTODETECT, wxPackageWXBuildPropDlg::OnAutodetect)
00051 END_EVENT_TABLE()
00052 
00053 wxPackageWXBuildPropDlg::wxPackageWXBuildPropDlg( )
00054 {
00055 }
00056 
00057 wxPackageWXBuildPropDlg::wxPackageWXBuildPropDlg( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00058 {
00059     Create(parent, id, caption, pos, size, style);
00060 }
00061 
00062 bool wxPackageWXBuildPropDlg::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00063 {
00065     m_pPortChoice = NULL;
00066     m_pVersionChoice = NULL;
00067     m_pCompilerChoice = NULL;
00068     m_pUnicodeRadioBox = NULL;
00069     m_pDebugRadioBox = NULL;
00070     m_pStaticRadioBox = NULL;
00072 
00074     SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00075     wxDialog::Create( parent, id, caption, pos, size, style );
00076 
00077     CreateControls();
00078     if (GetSizer())
00079     {
00080         GetSizer()->SetSizeHints(this);
00081     }
00082     Centre();
00084     return true;
00085 }
00086 
00087 void wxPackageWXBuildPropDlg::CreateControls()
00088 {
00089     m_pLocation = new wxDirPickerCtrl(this, ID_WXBUILDPROP_LOCATION);
00090 
00092     wxPackageWXBuildPropDlg* itemDialog1 = this;
00093 
00094     wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00095     itemDialog1->SetSizer(itemBoxSizer2);
00096 
00097     wxStaticText* itemStaticText3 = new wxStaticText( itemDialog1, wxID_STATIC, _("Location of this wxWidgets build:"), wxDefaultPosition, wxDefaultSize, 0 );
00098     itemBoxSizer2->Add(itemStaticText3, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00099 
00100     wxWindow* itemWindow4 = (wxWindow*) FindWindow(ID_WXBUILDPROP_LOCATION);
00101     wxASSERT( itemWindow4 != NULL );
00102     itemBoxSizer2->Add(itemWindow4, 0, wxGROW|wxALL, 5);
00103 
00104     wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
00105     itemBoxSizer2->Add(itemBoxSizer5, 0, wxGROW, 5);
00106 
00107     wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, _("Port:"), wxDefaultPosition, wxDefaultSize, 0 );
00108     itemBoxSizer5->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00109 
00110     wxString* m_pPortChoiceStrings = NULL;
00111     m_pPortChoice = new wxChoice( itemDialog1, ID_WXBUILDPROP_PORT, wxDefaultPosition, wxDefaultSize, 0, m_pPortChoiceStrings, 0 );
00112     itemBoxSizer5->Add(m_pPortChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00113 
00114     wxStaticText* itemStaticText8 = new wxStaticText( itemDialog1, wxID_STATIC, _("Version:"), wxDefaultPosition, wxDefaultSize, 0 );
00115     itemBoxSizer5->Add(itemStaticText8, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00116 
00117     wxString* m_pVersionChoiceStrings = NULL;
00118     m_pVersionChoice = new wxChoice( itemDialog1, ID_WXBUILDPROP_VERSION, wxDefaultPosition, wxDefaultSize, 0, m_pVersionChoiceStrings, 0 );
00119     itemBoxSizer5->Add(m_pVersionChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00120 
00121     wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
00122     itemBoxSizer2->Add(itemBoxSizer10, 0, wxGROW, 5);
00123 
00124     wxStaticText* itemStaticText11 = new wxStaticText( itemDialog1, wxID_STATIC, _("Compiler used to build it:"), wxDefaultPosition, wxDefaultSize, 0 );
00125     itemBoxSizer10->Add(itemStaticText11, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxADJUST_MINSIZE, 5);
00126 
00127     wxString* m_pCompilerChoiceStrings = NULL;
00128     m_pCompilerChoice = new wxChoice( itemDialog1, ID_WXBUILDPROP_COMPILER, wxDefaultPosition, wxDefaultSize, 0, m_pCompilerChoiceStrings, 0 );
00129     itemBoxSizer10->Add(m_pCompilerChoice, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00130 
00131     wxStaticText* itemStaticText13 = new wxStaticText( itemDialog1, wxID_STATIC, _("Main build options:"), wxDefaultPosition, wxDefaultSize, 0 );
00132     itemBoxSizer2->Add(itemStaticText13, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5);
00133 
00134     wxBoxSizer* itemBoxSizer14 = new wxBoxSizer(wxHORIZONTAL);
00135     itemBoxSizer2->Add(itemBoxSizer14, 0, wxALIGN_CENTER_HORIZONTAL, 5);
00136 
00137     wxString m_pUnicodeRadioBoxStrings[] = {
00138         _("Unicode"),
00139         _("ANSI")
00140     };
00141     m_pUnicodeRadioBox = new wxRadioBox( itemDialog1, ID_WXBUILDPROP_UNICODE, _T(""), wxDefaultPosition, wxDefaultSize, 2, m_pUnicodeRadioBoxStrings, 1, wxRA_SPECIFY_ROWS );
00142     m_pUnicodeRadioBox->SetSelection(0);
00143     itemBoxSizer14->Add(m_pUnicodeRadioBox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00144 
00145     wxString m_pDebugRadioBoxStrings[] = {
00146         _("Debug"),
00147         _("Release")
00148     };
00149     m_pDebugRadioBox = new wxRadioBox( itemDialog1, ID_WXBUILDPROP_DEBUG, _T(""), wxDefaultPosition, wxDefaultSize, 2, m_pDebugRadioBoxStrings, 1, wxRA_SPECIFY_ROWS );
00150     m_pDebugRadioBox->SetSelection(0);
00151     itemBoxSizer14->Add(m_pDebugRadioBox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00152 
00153     wxString m_pStaticRadioBoxStrings[] = {
00154         _("&Static"),
00155         _("&DLL")
00156     };
00157     m_pStaticRadioBox = new wxRadioBox( itemDialog1, ID_WXBUILDPROP_STATIC, _T(""), wxDefaultPosition, wxDefaultSize, 2, m_pStaticRadioBoxStrings, 1, wxRA_SPECIFY_ROWS );
00158     m_pStaticRadioBox->SetSelection(0);
00159     itemBoxSizer14->Add(m_pStaticRadioBox, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00160 
00161     itemBoxSizer2->Add(5, 5, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
00162 
00163     wxBoxSizer* itemBoxSizer19 = new wxBoxSizer(wxHORIZONTAL);
00164     itemBoxSizer2->Add(itemBoxSizer19, 0, wxGROW|wxALL, 5);
00165 
00166     wxButton* itemButton20 = new wxButton( itemDialog1, ID_WXBUILDPROP_AUTODETECT, _("Autodetect..."), wxDefaultPosition, wxDefaultSize, 0 );
00167     itemBoxSizer19->Add(itemButton20, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00168 
00169     itemBoxSizer19->Add(5, 5, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00170 
00171     wxButton* itemButton22 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
00172     itemBoxSizer19->Add(itemButton22, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00173 
00174     wxButton* itemButton23 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
00175     itemBoxSizer19->Add(itemButton23, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00176 
00178 
00179 
00180     // setup controls
00181 
00182     wxString versions[] = {
00183         _("2.6.0"),
00184         _("2.6.1"),
00185         _("2.6.2"),
00186         _("2.6.3"),
00187         _("2.6.4"),
00188         _("2.7.0"),
00189         _("2.7.1"),
00190         _("2.7.2"),
00191         _("2.8.0"),
00192         _("2.8.1"),
00193         _("2.8.2"),
00194         _("2.8.3"),
00195         _("2.8.4"),
00196         _("2.9.0"),
00197         _("2.9.1")
00198     };
00199 
00200     m_pVersionChoice->Append(wxArrayString(WXSIZEOF(versions), versions));
00201     m_pCompilerChoice->Append(wxArrayString(wxPCF_MAX, wxPackageCompilerFormatName));
00202 
00203     wxPlatformInfo pi;
00204     wxPortId thisport = pi.GetPortId();
00205     for (size_t i=0; i < wxPORT_MAX; i++)
00206     {
00207         wxPortId current = (wxPortId)(1 << i);
00208 
00209         // is this port usable on the running platform ?
00210         // if not it does not make sense to add it here as it's not possible
00211         // that the user built that wxport on this platform...
00212         if (g_supportedPorts & current)
00213         {
00214             int last = m_pPortChoice->Append(wxPlatformInfo::GetPortIdName(current, false));
00215             if (current == thisport)
00216                 m_pPortChoice->SetSelection(last);
00217         }
00218     }
00219 
00220     wxASSERT(m_pPortChoice->GetSelection() != wxNOT_FOUND);
00221 
00222     m_pLocation->SetPath(wxGetCwd());
00223 
00224     // select the first available items
00225     m_pCompilerChoice->SetSelection(0);
00226     m_pVersionChoice->SetSelection(0);
00227 }
00228 
00229 bool wxPackageWXBuildPropDlg::ShowToolTips()
00230 {
00231     return true;
00232 }
00233 
00234 void wxPackageWXBuildPropDlg::SetBuild(const wxWidgetsBuild &build)
00235 {
00236     m_pLocation->SetPath(build.GetLocation());
00237 
00238     // update selections
00239     m_pPortChoice->SetStringSelection(wxPlatformInfo::GetPortIdName(build.GetPortId(), false));
00240     m_pVersionChoice->SetStringSelection(build.GetVersion());
00241     m_pCompilerChoice->SetStringSelection(wxPackageCompilerFormat2String(build.GetCompilerUsed()));
00242 
00243     // get defaults for the radio boxes from 'wx' option preset
00244     m_pUnicodeRadioBox->SetSelection(build.IsUnicodeBuild() ? 0 : 1);
00245     m_pDebugRadioBox->SetSelection(build.IsDebugBuild() ? 0 : 1);
00246     m_pStaticRadioBox->SetSelection(build.IsStaticBuild() ? 0 : 1);
00247 }
00248 
00249 wxWidgetsBuild wxPackageWXBuildPropDlg::GetBuild() const
00250 {
00251     wxWidgetsBuild ret;
00252 
00253     ret.SetCompilerUsed(
00254         wxIdx2PackageCompilerFormat(m_pCompilerChoice->GetSelection()));
00255     ret.SetPortId(wxPlatformInfo::GetPortId(m_pPortChoice->GetStringSelection()));
00256 
00257     ret.SetLocation(m_pLocation->GetPath());
00258     ret.SetVersion(m_pVersionChoice->GetStringSelection());
00259 
00260     ret.SetBuildProp(m_pStaticRadioBox->GetSelection() == 0,
00261                      m_pDebugRadioBox->GetSelection() == 0,
00262                      m_pUnicodeRadioBox->GetSelection() == 0);
00263 
00264     return ret;
00265 }
00266 
00267 
00268 // ----------------------------------------------------------------------------
00269 // wxPackageWXBuildPropDlg - event handlers
00270 // ----------------------------------------------------------------------------
00271 
00272 void wxPackageWXBuildPropDlg::OnOK(wxCommandEvent &ev)
00273 {
00274     // let default handler process this
00275     ev.Skip();
00276 }
00277 
00278 void wxPackageWXBuildPropDlg::OnAutodetect(wxCommandEvent &ev)
00279 {
00280     wxMessageBox(wxT("Not implemented yet! Sorry"));
00281 }
00282 

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