1
/*=========================================================================
3
Program: WXDialog - wxWidgets X-platform GUI Front-End for CMake
4
Module: $RCSfile: CMakeSetupFrame.cpp,v $
6
Date: $Date: 2007-11-05 19:47:20 $
7
Version: $Revision: 1.3 $
11
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
12
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
14
This software is distributed WITHOUT ANY WARRANTY; without even
15
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16
PURPOSE. See the above copyright notices for more information.
18
=========================================================================*/
20
#if defined(__GNUG__) && !defined(__APPLE__)
21
#pragma implementation "CMakeSetupFrame.h"
24
// For compilers that support precompilation, includes "wx/wx.h".
25
#include "wx/wxprec.h"
38
#include <wx/dirdlg.h>
39
#include <wx/msgdlg.h>
40
#include <wx/filename.h>
42
#include "CMakeSetupFrame.h"
43
#include "PropertyList.h"
44
#include "app_resources.h"
45
#include "CMakeIcon.xpm"
49
#include "../cmVersion.h"
50
#include "../cmListFileCache.h"
51
#include "../cmCacheManager.h"
52
#include "../cmGlobalGenerator.h"
53
#include "../cmDynamicLoader.h"
59
* CMakeSetupFrm type definition
62
IMPLEMENT_CLASS( CMakeSetupFrm, wxFrame )
65
* CMakeSetupFrm event table definition
68
BEGIN_EVENT_TABLE( CMakeSetupFrm, wxFrame )
70
////@begin CMakeSetupFrm event table entries
71
EVT_CLOSE( CMakeSetupFrm::OnCloseWindow )
73
EVT_SPLITTER_SASH_POS_CHANGING( ID_SPLITTERWINDOW, CMakeSetupFrm::OnSplitterPosChanging )
74
EVT_SPLITTER_DCLICK( ID_SPLITTERWINDOW, CMakeSetupFrm::OnSplitterwindowSashDClick )
76
EVT_BUTTON( ID_BROWSE_PROJECT, CMakeSetupFrm::OnButtonBrowseProject )
78
EVT_TEXT( ID_SOURCE_BUILD_PATH, CMakeSetupFrm::OnSourceBuildPathUpdated )
79
EVT_TEXT_ENTER( ID_SOURCE_BUILD_PATH, CMakeSetupFrm::OnSourceBuildPathEnter )
81
EVT_BUTTON( ID_BROWSE_BUILD, CMakeSetupFrm::OnButtonBrowseBuild )
83
EVT_COMBOBOX( ID_SEARCHQUERY, CMakeSetupFrm::OnSearchquerySelected )
84
EVT_TEXT( ID_SEARCHQUERY, CMakeSetupFrm::OnSearchqueryUpdated )
86
EVT_CHECKBOX( ID_SHOW_ADVANCED, CMakeSetupFrm::OnShowAdvancedValues )
88
EVT_GRID_CELL_CHANGE( CMakeSetupFrm::OnCellChange )
89
EVT_GRID_SELECT_CELL( CMakeSetupFrm::OnGridSelectCell )
90
EVT_MOTION( CMakeSetupFrm::OnPropertyMotion )
92
EVT_BUTTON( ID_DO_CONFIGURE, CMakeSetupFrm::OnButtonConfigure )
94
EVT_BUTTON( ID_DO_OK, CMakeSetupFrm::OnButtonOk )
96
EVT_BUTTON( ID_DO_CANCEL, CMakeSetupFrm::OnButtonCancel )
98
EVT_BUTTON( ID_DO_DELETE_CACHE, CMakeSetupFrm::OnButtonDeleteCache )
100
EVT_BUTTON( ID_CLEAR_LOG, CMakeSetupFrm::OnClearLogClick )
102
EVT_BUTTON( ID_BROWSE_GRID, CMakeSetupFrm::OnBrowseGridClick )
104
EVT_MENU( ID_MENU_RELOAD_CACHE, CMakeSetupFrm::OnMenuReloadCacheClick )
106
EVT_MENU( ID_MENU_DELETE_CACHE, CMakeSetupFrm::OnMenuDeleteCacheClick )
108
EVT_MENU( ID_MENU_QUIT, CMakeSetupFrm::OnMenuQuitClick )
110
EVT_MENU( ID_MENU_CONFIGURE, CMakeSetupFrm::OnMenuConfigureClick )
112
EVT_MENU( ID_MENU_EXITGENERATE, CMakeSetupFrm::OnMenuGenerateClick )
114
EVT_MENU( ID_MENU_TOGGLE_ADVANCED, CMakeSetupFrm::OnMenuToggleAdvancedClick )
116
EVT_MENU( ID_CMAKE_OPTIONS, CMakeSetupFrm::OnOptionsClick )
118
EVT_MENU( ID_ABOUTDLG, CMakeSetupFrm::OnAboutClick )
120
////@end CMakeSetupFrm event table entries
122
EVT_MENU_RANGE(CM_RECENT_BUILD_ITEM, CM_RECENT_BUILD_ITEM + CM_MAX_RECENT_PATHS, CMakeSetupFrm::OnRecentFileMenu)
124
EVT_TEXT_ENTER(ID_SEARCHQUERY, CMakeSetupFrm::OnAddQuery )
128
/** Callback function for CMake generator, to tell user how
129
far the generation actually is */
130
void updateProgress(const char *msg, float prog, void *cd)
132
// TODO: Make some kind of progress counter
134
CMakeSetupFrm *fm = (CMakeSetupFrm *)cd;
139
fm->LogMessage(0, msg);
142
fm->UpdateProgress(prog);
148
/** Callback function for CMake generator, to tell user about stuff. This should be
149
logged in the m_log window */
150
void MFCMessageCallback(const char* m, const char* title, bool& nomore, void *clientdata)
152
CMakeSetupFrm *fm = (CMakeSetupFrm *)clientdata;
156
wxString what = m, msg;
157
if(what.StartsWith("CMake Error: "))
158
fm->LogMessage(-1, m);
160
fm->LogMessage(1, m);
164
// Convert to Win32 path (slashes). This calls the system tools one and then
165
// removes the spaces. It is not in system tools because we don't want any
166
// generators accidentally use it
167
std::string ConvertToWindowsPath(const char* path)
169
// Convert to output path.
170
// Remove the "" around it (if any) since it's an output path for
171
// the shell. If another shell-oriented feature is not designed
172
// for a GUI use, then we are in trouble.
173
// save the value of the force to unix path option
174
bool saveForce = cmSystemTools::GetForceUnixPaths();
175
// make sure we get windows paths no matter what for the GUI
176
cmSystemTools::SetForceUnixPaths(false);
177
std::string s = cmSystemTools::ConvertToOutputPath(path);
178
// now restore the force unix path to its previous value
179
cmSystemTools::SetForceUnixPaths(saveForce);
182
std::string::iterator i = s.begin();
187
i = s.begin() + s.length() - 1;
197
bool DnDFile::OnDropFiles(wxCoord, wxCoord, const wxArrayString& filenames)
199
size_t nFiles = filenames.GetCount();
201
// only one item allowed
207
// only one dir allowed
208
if(!wxDirExists(filenames[0]))
211
// strip the seperator
213
name.AssignDir(filenames[0]);
215
// issue a 'drop' by changing text ctrl
216
m_pOwner->SetValue(name.GetFullPath());
225
* CMakeSetupFrm constructors
228
CMakeSetupFrm::CMakeSetupFrm( )
233
CMakeSetupFrm::CMakeSetupFrm( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
236
Create( parent, id, caption, pos, size, style );
240
* CMakeSetupFrm creator
243
bool CMakeSetupFrm::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
245
////@begin CMakeSetupFrm member initialisation
247
m_cmProjectPath = NULL;
248
m_BrowseProjectPathButton = NULL;
249
m_cmBuildPath = NULL;
250
m_BrowseSourcePathButton = NULL;
251
m_cmGeneratorChoice = NULL;
252
m_cmSearchQuery = NULL;
253
m_cmShowAdvanced = NULL;
256
m_cmDescription = NULL;
257
m_ConfigureButton = NULL;
259
m_CancelButton = NULL;
260
m_DeleteCacheButton = NULL;
261
m_ClearLogButton = NULL;
262
m_cmBrowseCell = NULL;
263
////@end CMakeSetupFrm member initialisation
265
wxFrame::Create( parent, id, caption, pos, size, style );
267
// make sure the developer does not assign more then 100
268
// would be rediculous but also overlap other id's
269
wxASSERT(CM_MAX_RECENT_PATHS < 100);
275
m_quitAfterGenerating = false;
277
m_config = new wxConfig("CMakeSetup");
279
wxIcon icon(CMakeIcon_xpm);
284
//SetIcon(GetIconResource(wxT("cmake_icon.xpm")));
285
//SetIcon(wxIcon("NGDialog.ico", wxBITMAP_TYPE_ICO_RESOURCE));
288
// is it needed to hide console?
289
m_RunningConfigure = false;
290
cmSystemTools::SetRunCommandHideConsole(true);
291
cmSystemTools::SetErrorCallback(MFCMessageCallback, (void *)this);
293
// create our cmake instance
295
m_cmake->SetProgressCallback(updateProgress, (void *)this);
300
CMakeSetupFrm::~CMakeSetupFrm()
304
// write configs back to disk
305
m_config->Write(CM_LASTPROJECT_PATH, m_cmProjectPath->GetValue());
306
m_config->Write(CM_LASTBUILD_PATH, m_cmBuildPath->GetValue());
308
// clear the config first
309
for(size_t i = 0 ; i < CM_MAX_RECENT_PATHS; i++)
311
str.Printf("%s%i", _(CM_RECENT_BUILD_PATH), i);
312
m_config->Write(str, _(""));
315
// write the last CM_MAX_RECENT_PATHS items back to config
316
int i = (m_recentPaths.Count() >= CM_MAX_RECENT_PATHS ? CM_MAX_RECENT_PATHS : m_recentPaths.Count());
319
str.Printf("%s%i", _(CM_RECENT_BUILD_PATH), i);
320
m_config->Write(str, m_recentPaths[i - 1]);
324
// write recent query list to config
325
for(int j = 0; j < m_cmSearchQuery->GetCount(); j++)
327
// allow max to be written
328
if(j < CM_MAX_SEARCH_QUERIES)
330
str.Printf("%s%i", _(CM_SEARCH_QUERY), j);
331
m_config->Write(str, m_cmSearchQuery->GetString(j));
337
// set window pos + size in settings
338
if(!IsIconized() && !IsMaximized())
341
GetSize(&xsize, &ysize);
342
if(xsize > 0 && ysize > 0)
344
m_config->Write(CM_XSIZE, (long)xsize);
345
m_config->Write(CM_YSIZE, (long)ysize);
348
if(m_splitter->GetSashPosition() > 0)
349
m_config->Write(CM_SPLITTERPOS, (long)m_splitter->GetSashPosition());
351
GetPosition(&xsize, &ysize);
352
if(xsize != 0 && ysize != 0)
354
m_config->Write(CM_XPOS, (long)xsize);
355
m_config->Write(CM_YPOS, (long)ysize);
359
// write changes (will be done before deletion)
366
// delete our cmake instance again
371
void CMakeSetupFrm::UpdateWindowState()
373
bool dogenerate = !m_RunningConfigure && !m_cmOptions->IsCacheDirty() &&
374
(m_cmOptions->GetCount() != 0);
376
// when configure is running, disable a lot of stuff
377
m_cmProjectPath->Enable(!m_RunningConfigure);
378
m_BrowseProjectPathButton->Enable(!m_RunningConfigure);
379
m_cmBuildPath->Enable(!m_RunningConfigure);
380
m_BrowseSourcePathButton->Enable(!m_RunningConfigure);
381
m_cmGeneratorChoice->Enable(!m_RunningConfigure);
382
m_cmShowAdvanced->Enable(!m_RunningConfigure);
383
m_cmOptions->Enable(!m_RunningConfigure);
384
m_ConfigureButton->Enable(!m_RunningConfigure);
385
m_OkButton->Enable(dogenerate);
386
m_CancelButton->Enable(m_RunningConfigure);
387
m_DeleteCacheButton->Enable(!m_RunningConfigure);
388
m_ClearLogButton->Enable(!m_RunningConfigure);
389
if(m_RunningConfigure)
390
m_cmBrowseCell->Enable(false);
392
// when cache loaded (items available show other control)
393
m_cmGeneratorChoice->Enable(m_cmOptions->GetCount() == 0 && !m_RunningConfigure);
394
m_cmSearchQuery->Enable(!m_RunningConfigure);
395
m_cmBrowseCell->Enable(!m_RunningConfigure && m_cmOptions->IsSelectedItemBrowsable());
397
// disable the menus when configuring
400
// disable configure button when there is nothing, and generate and exit
401
// only when it is allowed to generate
402
GetMenuBar()->Enable(ID_MENU_EXITGENERATE, dogenerate);
403
GetMenuBar()->Enable(ID_MENU_CONFIGURE, !m_RunningConfigure);
405
for(size_t i = 0; i < GetMenuBar()->GetMenuCount(); i++)
406
GetMenuBar()->EnableTop(i, !m_RunningConfigure);
410
void CMakeSetupFrm::LogMessage(int logkind, const char *msg)
412
// put CR first but prevent a CR at the end
414
if(m_cmLog->IsModified())
415
(*m_cmLog) << wxT("\n");
417
// Linux requires a different approach
418
if(!m_cmLog->GetValue().IsEmpty())
419
(*m_cmLog) << wxT("\n");
422
// log error, warning, or message
423
wxTextAttr defattr = m_cmLog->GetDefaultStyle();
430
wxTextAttr colattr(*wxBLUE);
431
m_cmLog->SetDefaultStyle(colattr);
433
m_cmLog->SetDefaultStyle(defattr);
445
wxTextAttr colattr(*wxRED);
446
m_cmLog->SetDefaultStyle(colattr);
448
m_cmLog->SetDefaultStyle(defattr);
456
void CMakeSetupFrm::IssueUpdate()
458
//::wxSafeYield(m_CancelButton, true);
461
// when we pressed cancel on the progress dialog
462
// stop all activities
465
if(m_progressDlg->CancelPressed() && !m_progressDlg->IsCancelling())
467
m_progressDlg->CancelAcknowledged();
469
// send a button event to cancel the progress
470
wxCommandEvent event( wxEVT_COMMAND_BUTTON_CLICKED, ID_DO_CANCEL);
471
wxPostEvent(this, event);
477
* Control creation for CMakeSetupFrm
480
void CMakeSetupFrm::CreateControls()
482
////@begin CMakeSetupFrm content construction
483
CMakeSetupFrm* itemFrame1 = this;
485
wxMenuBar* menuBar = new wxMenuBar;
486
wxMenu* itemMenu37 = new wxMenu;
487
itemMenu37->Append(ID_MENU_RELOAD_CACHE, _("&Reload Cache\tCtrl+R"), _("Reload the cache from disk"), wxITEM_NORMAL);
488
itemMenu37->Append(ID_MENU_DELETE_CACHE, _("&Delete Cache\tCtrl+D"), _("Delete the cache on disk of the current path"), wxITEM_NORMAL);
489
itemMenu37->AppendSeparator();
490
itemMenu37->Append(ID_MENU_QUIT, _("E&xit\tAlt+F4"), _("Quit CMake Setup"), wxITEM_NORMAL);
491
menuBar->Append(itemMenu37, _("&File"));
492
wxMenu* itemMenu42 = new wxMenu;
493
itemMenu42->Append(ID_MENU_CONFIGURE, _("&Configure\tCtrl+N"), _T(""), wxITEM_NORMAL);
494
itemMenu42->Append(ID_MENU_EXITGENERATE, _("&Generate and Exit\tCtrl+G"), _T(""), wxITEM_NORMAL);
495
itemMenu42->Append(ID_MENU_TOGGLE_ADVANCED, _("Toggle &Advanced\tCtrl+A"), _T(""), wxITEM_NORMAL);
496
itemMenu42->AppendSeparator();
497
itemMenu42->Append(ID_CMAKE_OPTIONS, _("&Options\tCtrl+O"), _T(""), wxITEM_NORMAL);
498
menuBar->Append(itemMenu42, _("&Tools"));
499
wxMenu* itemMenu48 = new wxMenu;
500
itemMenu48->Append(ID_ABOUTDLG, _("&About ..."), _("Shows the about dialog ..."), wxITEM_NORMAL);
501
menuBar->Append(itemMenu48, _("&Help"));
502
itemFrame1->SetMenuBar(menuBar);
504
m_splitter = new wxSplitterWindow( itemFrame1, ID_SPLITTERWINDOW, wxDefaultPosition, wxSize(100, 100), wxSP_3DBORDER|wxSP_3DSASH|wxNO_BORDER );
506
wxPanel* itemPanel3 = new wxPanel( m_splitter, ID_MAINPANEL, wxDefaultPosition, wxSize(600, 400), wxNO_BORDER|wxTAB_TRAVERSAL );
507
itemPanel3->SetExtraStyle(itemPanel3->GetExtraStyle()|wxWS_EX_VALIDATE_RECURSIVELY);
508
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL);
509
itemPanel3->SetSizer(itemBoxSizer4);
511
wxBoxSizer* itemBoxSizer5 = new wxBoxSizer(wxHORIZONTAL);
512
itemBoxSizer4->Add(itemBoxSizer5, 0, wxGROW|wxTOP|wxBOTTOM, 5);
513
wxFlexGridSizer* itemFlexGridSizer6 = new wxFlexGridSizer(2, 3, 0, 0);
514
itemFlexGridSizer6->AddGrowableRow(1);
515
itemFlexGridSizer6->AddGrowableCol(1);
516
itemBoxSizer5->Add(itemFlexGridSizer6, 1, wxALIGN_TOP|wxLEFT, 5);
517
wxStaticText* itemStaticText7 = new wxStaticText( itemPanel3, wxID_STATIC, _("CMake project path"), wxDefaultPosition, wxDefaultSize, 0 );
518
itemFlexGridSizer6->Add(itemStaticText7, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
520
m_cmProjectPath = new wxTextCtrl( itemPanel3, ID_PROJECT_PATH, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
521
itemFlexGridSizer6->Add(m_cmProjectPath, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM, 5);
523
m_BrowseProjectPathButton = new wxButton( itemPanel3, ID_BROWSE_PROJECT, _("Browse"), wxDefaultPosition, wxSize(55, -1), 0 );
524
itemFlexGridSizer6->Add(m_BrowseProjectPathButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
526
wxStaticText* itemStaticText10 = new wxStaticText( itemPanel3, wxID_STATIC, _("Project build path"), wxDefaultPosition, wxDefaultSize, 0 );
527
itemFlexGridSizer6->Add(itemStaticText10, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxADJUST_MINSIZE, 5);
529
m_cmBuildPath = new wxTextCtrl( itemPanel3, ID_SOURCE_BUILD_PATH, _T(""), wxDefaultPosition, wxSize(50, -1), 0 );
530
itemFlexGridSizer6->Add(m_cmBuildPath, 1, wxGROW|wxALIGN_TOP|wxTOP|wxBOTTOM, 5);
532
m_BrowseSourcePathButton = new wxButton( itemPanel3, ID_BROWSE_BUILD, _("Browse"), wxDefaultPosition, wxSize(55, -1), 0 );
533
itemFlexGridSizer6->Add(m_BrowseSourcePathButton, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 5);
535
wxBoxSizer* itemBoxSizer13 = new wxBoxSizer(wxVERTICAL);
536
itemBoxSizer5->Add(itemBoxSizer13, 0, wxGROW|wxLEFT|wxRIGHT, 5);
537
wxFlexGridSizer* itemFlexGridSizer14 = new wxFlexGridSizer(2, 2, 0, 0);
538
itemBoxSizer13->Add(itemFlexGridSizer14, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5);
539
wxStaticText* itemStaticText15 = new wxStaticText( itemPanel3, wxID_STATIC, _("Generate"), wxDefaultPosition, wxDefaultSize, 0 );
540
itemFlexGridSizer14->Add(itemStaticText15, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxADJUST_MINSIZE, 5);
542
wxString* m_cmGeneratorChoiceStrings = NULL;
543
m_cmGeneratorChoice = new wxComboBox( itemPanel3, ID_CHOOSE_GENERATOR, _T(""), wxDefaultPosition, wxSize(170, -1), 0, m_cmGeneratorChoiceStrings, wxCB_READONLY );
544
itemFlexGridSizer14->Add(m_cmGeneratorChoice, 1, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxTOP|wxBOTTOM, 5);
546
wxStaticText* itemStaticText17 = new wxStaticText( itemPanel3, wxID_STATIC, _("Search"), wxDefaultPosition, wxDefaultSize, 0 );
547
itemFlexGridSizer14->Add(itemStaticText17, 0, wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL|wxRIGHT|wxADJUST_MINSIZE, 5);
549
wxString* m_cmSearchQueryStrings = NULL;
550
m_cmSearchQuery = new wxComboBox( itemPanel3, ID_SEARCHQUERY, _T(""), wxDefaultPosition, wxSize(170, -1), 0, m_cmSearchQueryStrings, wxWANTS_CHARS );
551
itemFlexGridSizer14->Add(m_cmSearchQuery, 1, wxALIGN_CENTER_HORIZONTAL|wxGROW|wxTOP|wxBOTTOM, 5);
553
m_cmShowAdvanced = new wxCheckBox( itemPanel3, ID_SHOW_ADVANCED, _("Show advanced values"), wxDefaultPosition, wxDefaultSize, wxCHK_2STATE );
554
m_cmShowAdvanced->SetValue(FALSE);
555
itemBoxSizer13->Add(m_cmShowAdvanced, 0, wxALIGN_RIGHT|wxLEFT|wxRIGHT, 5);
557
m_cmOptions = new wxPropertyList( itemPanel3, ID_OPTIONS, wxDefaultPosition, wxSize(200, 150), wxSTATIC_BORDER|wxWANTS_CHARS|wxVSCROLL );
558
m_cmOptions->SetDefaultColSize(250);
559
m_cmOptions->SetDefaultRowSize(25);
560
m_cmOptions->SetColLabelSize(20);
561
m_cmOptions->SetRowLabelSize(0);
562
m_cmOptions->CreateGrid(10, 2, wxGrid::wxGridSelectRows);
563
itemBoxSizer4->Add(m_cmOptions, 1, wxGROW|wxALL, 5);
565
wxPanel* itemPanel21 = new wxPanel( m_splitter, ID_LOGPANEL, wxDefaultPosition, wxSize(-1, 100), wxNO_BORDER|wxTAB_TRAVERSAL );
566
wxBoxSizer* itemBoxSizer22 = new wxBoxSizer(wxVERTICAL);
567
itemPanel21->SetSizer(itemBoxSizer22);
569
wxBoxSizer* itemBoxSizer23 = new wxBoxSizer(wxHORIZONTAL);
570
itemBoxSizer22->Add(itemBoxSizer23, 1, wxGROW|wxLEFT|wxRIGHT|wxTOP, 5);
571
m_cmLog = new wxTextCtrl( itemPanel21, ID_LOG_AREA, _("Select your project path (where CMakeLists.txt is) and then select the build path (where the projects should be saved), or select a previous build path.\n\nRight click on a cache value for additional options (delete and ignore). Press configure to update and display new values in red, press OK to generate the projects and exit."), wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH2|wxSTATIC_BORDER );
572
itemBoxSizer23->Add(m_cmLog, 1, wxGROW|wxRIGHT, 5);
574
m_cmDescription = new wxTextCtrl( itemPanel21, ID_DESCRIPTION, _T(""), wxDefaultPosition, wxSize(200, -1), wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH2|wxSTATIC_BORDER );
575
itemBoxSizer23->Add(m_cmDescription, 0, wxGROW|wxLEFT, 5);
577
wxBoxSizer* itemBoxSizer26 = new wxBoxSizer(wxHORIZONTAL);
578
itemBoxSizer22->Add(itemBoxSizer26, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
579
m_ConfigureButton = new wxButton( itemPanel21, ID_DO_CONFIGURE, _("Co&nfigure"), wxDefaultPosition, wxDefaultSize, 0 );
580
m_ConfigureButton->SetDefault();
581
itemBoxSizer26->Add(m_ConfigureButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
583
m_OkButton = new wxButton( itemPanel21, ID_DO_OK, _("&Generate!"), wxDefaultPosition, wxDefaultSize, 0 );
584
itemBoxSizer26->Add(m_OkButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
586
m_CancelButton = new wxButton( itemPanel21, ID_DO_CANCEL, _("C&ancel"), wxDefaultPosition, wxDefaultSize, 0 );
587
itemBoxSizer26->Add(m_CancelButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
589
#if defined(__WXMSW__)
590
wxStaticLine* itemStaticLine30 = new wxStaticLine( itemPanel21, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
591
itemBoxSizer26->Add(itemStaticLine30, 0, wxGROW|wxALL, 5);
594
m_DeleteCacheButton = new wxButton( itemPanel21, ID_DO_DELETE_CACHE, _("&Delete Cache"), wxDefaultPosition, wxDefaultSize, 0 );
595
itemBoxSizer26->Add(m_DeleteCacheButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
597
m_ClearLogButton = new wxButton( itemPanel21, ID_CLEAR_LOG, _("Clear &Log"), wxDefaultPosition, wxDefaultSize, 0 );
598
itemBoxSizer26->Add(m_ClearLogButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
600
#if defined(__WXMSW__)
601
wxStaticLine* itemStaticLine33 = new wxStaticLine( itemPanel21, wxID_STATIC, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
602
itemBoxSizer26->Add(itemStaticLine33, 0, wxGROW|wxALL, 5);
605
m_cmBrowseCell = new wxButton( itemPanel21, ID_BROWSE_GRID, _("&Browse"), wxDefaultPosition, wxDefaultSize, 0 );
606
itemBoxSizer26->Add(m_cmBrowseCell, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
608
m_splitter->SplitHorizontally(itemPanel3, itemPanel21, 300);
610
wxStatusBar* itemStatusBar35 = new wxStatusBar( itemFrame1, ID_STATUSBAR, wxST_SIZEGRIP|wxNO_BORDER );
611
itemStatusBar35->SetFieldsCount(2);
612
itemFrame1->SetStatusBar(itemStatusBar35);
614
////@end CMakeSetupFrm content construction
617
void CMakeSetupFrm::DoInitFrame(cmCommandLineInfo &cm, const wxString &fn)
619
// path to where cmake.exe is
620
// m_PathToExecutable = cm.GetPathToExecutable().c_str();
621
m_PathToExecutable = fn;
623
// adjust size of last bar, to display % progress
624
wxStatusBar *bar = GetStatusBar();
627
wxASSERT(bar->GetFieldsCount() > 1);
629
// fill all with -1. Why this way? because the count of the status bars
630
// can change. All of the widths must be accounted for and initialised
631
int *widths = new int[bar->GetFieldsCount()];
632
for(int i = 0; i < bar->GetFieldsCount(); i++)
637
bar->SetStatusWidths(bar->GetFieldsCount(), widths);
641
wxString name, generator;
642
std::vector<std::string> names;
644
m_RunningConfigure = false;
647
m_cmOptions->SetColLabelValue(0, wxT("Cache Name"));
648
m_cmOptions->SetColLabelValue(1, wxT("Cache Value"));
649
m_cmOptions->SetProjectGenerated(false);
652
m_cmOptions->SetDropTarget(new DnDFile(m_cmBuildPath));
654
m_cmake->GetRegisteredGenerators(names);
655
for(std::vector<std::string>::iterator i = names.begin(); i != names.end(); ++i)
658
m_cmGeneratorChoice->Append(name);
661
// sync advanced option with grid
662
m_cmOptions->SetShowAdvanced(m_cmShowAdvanced->GetValue());
664
// if we have a command line query that a generator
665
// needs to be chosen instead of the default, take it
666
bool foundGivenGenerator = false;
667
if(!cm.m_GeneratorChoiceString.IsEmpty())
669
// set proper discovered generator
670
foundGivenGenerator = m_cmGeneratorChoice->SetStringSelection(cm.m_GeneratorChoiceString);
673
// if none selected, we will see if VS8, VS7 or VS6 is present
674
if(!foundGivenGenerator || m_cmGeneratorChoice->GetValue().IsEmpty())
677
mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup;Dbghelp_path]";
678
cmSystemTools::ExpandRegistryValues(mp);
679
if(mp != "/registry")
680
generator = wxT("Visual Studio 8 2005");
683
mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1;InstallDir]";
684
cmSystemTools::ExpandRegistryValues(mp);
685
if (mp != "/registry")
686
generator = wxT("Visual Studio 7 .NET 2003");
689
mp = "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.0;InstallDir]";
690
cmSystemTools::ExpandRegistryValues(mp);
691
if (mp != "/registry")
692
generator = wxT("Visual Studio 7");
694
generator = wxT("Visual Studio 6");
699
// set proper discovered generator
700
m_cmGeneratorChoice->SetStringSelection(generator);
703
str.Printf("CMake %d.%d - %s", cmVersion::GetMajorVersion(),
704
cmVersion::GetMinorVersion(),
705
cmVersion::GetReleaseVersion().c_str());
706
str.Printf("CMakeSetup v%i.%i%s", CMAKEGUI_MAJORVER, CMAKEGUI_MINORVER, CMAKEGUI_ADDVER);
711
// get last 5 used projects
712
for(size_t i = 0; i < CM_MAX_RECENT_PATHS; i++)
714
path.Printf("%s%i", _(CM_RECENT_BUILD_PATH), i);
715
if(m_config->Read(path, &str))
716
AppendPathToRecentList(str);
720
for(size_t i = 0; i < CM_MAX_SEARCH_QUERIES; i++)
722
path.Printf("%s%i", _(CM_SEARCH_QUERY), i);
723
if(m_config->Read(path, &str))
724
m_cmSearchQuery->Append(str);
728
// make sure the call to update grid is not executed
730
m_cmSearchQuery->SetValue(_(""));
733
// Get the parameters from the command line info
734
// If an unknown parameter is found, try to interpret it too, since it
735
// is likely to be a file dropped on the shortcut :)
736
bool sourceDirLoaded = false,
737
buildDirLoaded = false;
739
if(cm.m_LastUnknownParameter.empty())
741
if(cm.m_WhereSource.size() > 0 )
743
m_cmProjectPath->SetValue(cm.m_WhereSource.c_str());
744
sourceDirLoaded = true;
747
if (cm.m_WhereBuild.size() > 0 )
749
m_cmBuildPath->SetValue(cm.m_WhereBuild.c_str());
750
buildDirLoaded = true;
753
m_cmShowAdvanced->SetValue(cm.m_AdvancedValues);
757
m_cmShowAdvanced->SetValue(false);
759
// TODO: Interpret directory from dropped shortcut
760
//this->ChangeDirectoriesFromFile(cmdInfo->m_LastUnknownParameter.c_str());
763
if (cm.m_ExitAfterLoad)
766
m_ExitTimer = new wxTimer(this, id);
767
m_ExitTimer->Start(3000);
769
Connect( id, wxEVT_TIMER,(wxObjectEventFunction) &CMakeSetupFrm::OnExitTimer );
773
// retrieve settings, this needs to be done here
774
// because writing to the m_cmBuildPath triggers a cache reload
775
if(!sourceDirLoaded && m_config->Read(CM_LASTPROJECT_PATH, &str))
776
m_cmProjectPath->SetValue(str);
780
m_cmOptions->RemoveAll();
781
if(m_config->Read(CM_LASTBUILD_PATH, &str))
782
m_cmBuildPath->SetValue(str);
785
// set window size from settings
786
long xsize, ysize, splitpos;
787
if(m_config->Read(CM_XSIZE, &xsize) && m_config->Read(CM_YSIZE, &ysize) &&
788
m_config->Read(CM_SPLITTERPOS, &splitpos))
790
SetSize(xsize, ysize);
791
m_splitter->SetSashPosition(splitpos);
794
if(m_config->Read(CM_XPOS, &xsize) && m_config->Read(CM_YPOS, &ysize))
795
SetSize(xsize, ysize, -1, -1, wxSIZE_USE_EXISTING);
800
void CMakeSetupFrm::LoadCacheFromDiskToGUI()
802
wxString builddir = m_cmBuildPath->GetValue();
804
cmCacheManager *cachem = m_cmake->GetCacheManager();
805
if(cachem && !builddir.Trim().IsEmpty())
807
if(cachem->LoadCache(builddir.c_str()))
808
AppendPathToRecentList(builddir);
810
// represent this cache in the grid, but not before we
811
// wiped all of the old items
812
FillCacheGUIFromCacheManager();
814
// set the generator string to the one used in the cache
815
cmCacheManager::CacheIterator it = cachem->GetCacheIterator("CMAKE_GENERATOR");
818
wxString curGen = it.GetValue();
819
m_cmGeneratorChoice->SetStringSelection(curGen);
824
void CMakeSetupFrm::AppendPathToRecentList(const wxString &p)
832
// cheap way to get rid of trailing seperators
834
str = path.GetPath();
836
// append the item, or add it to end to make sure
837
// it is remembered between sessions
838
for(size_t i = 0; i < m_recentPaths.Count(); i++)
840
if(m_recentPaths[i].IsSameAs(str, false))
842
m_recentPaths.RemoveAt(i);
844
// only re-add when item is still valid
845
if(::wxDirExists(str))
846
m_recentPaths.Add(str);
848
return; // no add when the item is not existing
858
wxMenu *mnu = GetMenuBar()->GetMenu(0);
861
if(::wxDirExists(str))
864
if(m_recentPaths.Count() == 0)
865
mnu->AppendSeparator();
867
lastUsedID = CM_RECENT_BUILD_ITEM + m_recentPaths.Count();
868
m_recentPaths.Add(str);
870
// when we have more in list then we can display, prune and
871
// remove some menu items until we have room (and available ID's again)
872
if(m_recentPaths.Count() > CM_MAX_RECENT_PATHS)
875
while(m_recentPaths.Count() > CM_MAX_RECENT_PATHS)
876
m_recentPaths.RemoveAt(0);
878
// now determine count, and remove until we have room
879
int index = mnu->GetMenuItemCount() - 1;
886
item = mnu->FindItemByPosition(index);
889
if(item->IsSeparator())
891
// next index is valid item
901
while(index >= 0 && item);
903
// ok, if count > CM_MAX_RECENT_PATHS then we are going to
904
// delete some items on the index position
905
if(count >= CM_MAX_RECENT_PATHS)
907
// delete items that are exceeding
908
while(count >= CM_MAX_RECENT_PATHS)
910
lastUsedID = mnu->FindItemByPosition(index)->GetId();
911
mnu->Delete(lastUsedID);
918
mnu->Append(lastUsedID, str);
923
bool CMakeSetupFrm::PerformCacheRun()
926
cmCacheManager *cachem = m_cmake->GetCacheManager();
927
cmCacheManager::CacheIterator it = cachem->NewIterator();
929
// remove all items that are no longer present
931
while(j < m_cmOptions->GetCount())
933
// check to see if it is still in the CMake cache
934
// if it is still in the cache then it is no longer new
935
wxPropertyItem *item = m_cmOptions->GetItem(j);
936
if ( !it.Find((const char*)item->GetPropName().c_str()) )
937
m_cmOptions->RemoveProperty(item);
940
// ok we found it, mark as old
941
item->SetNewValue(false);
942
int row = m_cmOptions->FindProperty(item);
944
m_cmOptions->UpdatePropertyItem(item, row);
949
if(cachem->GetSize() > 0 && !cmSystemTools::GetErrorOccuredFlag())
952
for(size_t i = 0; i < m_cmOptions->GetCount(); i++)
954
wxPropertyItem* item = m_cmOptions->GetItem(i);
955
if(item->GetAdvanced())
957
if(item->GetNewValue() && m_cmOptions->GetShowAdvanced())
959
// if one new value then disable to OK button
966
if(item->GetNewValue())
968
// if one new value then disable to OK button
979
void CMakeSetupFrm::FillCacheGUIFromCacheManager()
981
cmCacheManager *cachem = m_cmake->GetCacheManager();
982
cmCacheManager::CacheIterator it = cachem->NewIterator();
984
// remove all items that are no longer present
986
while(j < m_cmOptions->GetCount())
988
// check to see if it is still in the CMake cache
989
// if it is still in the cache then it is no longer new
990
wxPropertyItem *item = m_cmOptions->GetItem(j);
991
if ( !it.Find((const char*)item->GetPropName().c_str()) )
992
m_cmOptions->RemoveProperty(item);
997
// if there are already entries in the cache, then
998
// put the new ones in the top, so they show up first
999
bool reverseOrder = false;
1000
for(cmCacheManager::CacheIterator i = cachem->NewIterator(); !i.IsAtEnd(); i.Next())
1002
const char* key = i.GetName();
1004
// if value has trailing space or tab, enclose it in single quotes
1005
// to enforce the fact that it has 'invisible' trailing stuff
1006
std::string value = i.GetValue();
1007
if (value.size() && (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t'))
1008
value = '\'' + value + '\'';
1010
bool advanced = i.GetPropertyAsBool("ADVANCED");
1011
switch(i.GetType() )
1013
case cmCacheManager::BOOL:
1017
if(cmSystemTools::IsOn(value.c_str()))
1022
m_cmOptions->AddProperty(key,
1024
i.GetProperty("HELPSTRING"),
1025
wxPropertyList::CHECKBOX, "ON|OFF",
1031
case cmCacheManager::PATH:
1032
m_cmOptions->AddProperty(key,
1034
i.GetProperty("HELPSTRING"),
1035
wxPropertyList::PATH,"",
1036
reverseOrder, advanced);
1039
case cmCacheManager::FILEPATH:
1040
m_cmOptions->AddProperty(key,
1042
i.GetProperty("HELPSTRING"),
1043
wxPropertyList::FILE,"",
1044
reverseOrder, advanced);
1047
case cmCacheManager::STRING:
1048
m_cmOptions->AddProperty(key,
1050
i.GetProperty("HELPSTRING"),
1051
wxPropertyList::EDIT,"",
1052
reverseOrder, advanced);
1055
case cmCacheManager::INTERNAL:
1057
wxPropertyItem *pItem = m_cmOptions->FindPropertyByName(key);
1059
m_cmOptions->RemoveProperty(pItem);
1066
void CMakeSetupFrm::OnExitTimer(wxTimerEvent &event)
1072
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_PROJECT
1075
void CMakeSetupFrm::OnButtonBrowseProject( wxCommandEvent& event )
1077
const wxString& dir = wxDirSelector("Select project directory", m_cmProjectPath->GetValue());
1079
m_cmProjectPath->SetValue(dir);
1083
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_BUILD
1086
void CMakeSetupFrm::OnButtonBrowseBuild( wxCommandEvent& event )
1088
const wxString& dir = wxDirSelector("Select build directory", m_cmBuildPath->GetValue());
1090
m_cmBuildPath->SetValue(dir);
1094
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_SHOW_ADVANCED
1097
void CMakeSetupFrm::OnShowAdvancedValues( wxCommandEvent& event )
1099
if(m_cmShowAdvanced->GetValue())
1100
m_cmOptions->ShowAdvanced();
1102
m_cmOptions->HideAdvanced();
1106
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_CONFIGURE
1109
void CMakeSetupFrm::OnButtonConfigure( wxCommandEvent& event )
1114
void CMakeSetupFrm::DoConfigure()
1116
// enable error messages each time configure is pressed
1117
cmSystemTools::EnableMessages();
1118
m_cmOptions->HideControls();
1120
cmSystemTools::ResetErrorOccuredFlag();
1122
// instantiate a dialog for the progress meter
1128
int CMakeSetupFrm::RunCMake(bool generateProjectFiles)
1134
m_cmLog->DiscardEdits();
1136
wxString builddir = m_cmBuildPath->GetValue(),
1137
sourcedir = m_cmProjectPath->GetValue(),
1138
err = wxT("Error in configuration process, project files may be invalid");
1141
// sanity check for people pressing OK on empty dirs
1142
if(builddir.Trim().IsEmpty() || sourcedir.Trim().IsEmpty())
1144
wxMessageBox(wxT("Please enter a valid source directory and build directory"), wxT("Error"), wxOK | wxICON_ERROR, this);
1148
// check if the directory exists, if not, create it
1149
if(!cmSystemTools::FileExists(builddir.c_str()))
1152
str << wxT("Build directory does not exist, should I create it?\n\nDirectory: ") << builddir;
1154
int answer = wxMessageBox(str, wxT("Create directory"), wxYES_NO, this);
1155
if (answer == wxYES)
1157
if(!cmSystemTools::MakeDirectory(builddir.c_str()))
1159
// could not create, tell and abort
1160
wxMessageBox(wxT("Could not create directory"), wxT("Error"), wxOK | wxICON_ERROR, this);
1166
// we abort because the user did not want to make the directory
1167
wxMessageBox(wxT("Build Project aborted, nothing done."), wxT("Aborted"),
1168
wxOK | wxICON_EXCLAMATION, this);
1173
/** show progress dialog that informs the user with a progress bar */
1175
m_progressDlg->Destroy();
1177
m_progressDlg = new CMProgressDialog(this);
1178
m_progressDlg->Show();
1180
// set the wait cursor
1181
m_RunningConfigure = true;
1182
UpdateWindowState();
1184
// always save the current gui values to disk
1187
// Make sure we are working from the cache on disk
1188
LoadCacheFromDiskToGUI();
1190
// setup the cmake instance
1191
if (generateProjectFiles)
1193
if(m_cmake->Generate() != 0)
1195
wxMessageBox(err, wxT("Error"), wxOK | wxICON_ERROR, this);
1196
cmSystemTools::Error(err.c_str());
1202
m_cmOptions->SetProjectGenerated(true); // clear cache dirty when generated
1208
m_cmake->SetHomeDirectory(m_cmProjectPath->GetValue().c_str());
1209
m_cmake->SetStartDirectory(m_cmProjectPath->GetValue().c_str());
1210
m_cmake->SetHomeOutputDirectory(m_cmBuildPath->GetValue().c_str());
1211
m_cmake->SetStartOutputDirectory(m_cmBuildPath->GetValue().c_str());
1213
m_cmake->SetGlobalGenerator(m_cmake->CreateGlobalGenerator(m_cmGeneratorChoice->GetValue().c_str()));
1214
m_cmake->SetCMakeCommand(m_PathToExecutable.c_str());
1215
m_cmake->LoadCache();
1216
if(m_cmake->Configure() != 0)
1218
wxMessageBox(err, wxT("Error"), wxOK | wxICON_ERROR, this);
1219
cmSystemTools::Error(err.c_str());
1222
// update the GUI with any new values in the caused by the
1223
// generation process
1224
LoadCacheFromDiskToGUI();
1227
m_RunningConfigure = false;
1230
cmSystemTools::ResetErrorOccuredFlag();
1232
m_progressDlg->Destroy();
1235
// reset the statusbar progress
1236
wxStatusBar *bar = GetStatusBar();
1238
bar->SetStatusText(wxEmptyString, 1);
1240
UpdateWindowState();
1244
//! Save GUI values to cmCacheManager and then save to disk.
1245
void CMakeSetupFrm::SaveCacheFromGUI()
1247
cmCacheManager *cachem = m_cmake->GetCacheManager();
1248
FillCacheManagerFromCacheGUI();
1250
// write the cache to disk
1251
if(!m_cmBuildPath->GetValue().Trim().IsEmpty())
1252
cachem->SaveCache(m_cmBuildPath->GetValue().c_str());
1255
void CMakeSetupFrm::FillCacheManagerFromCacheGUI()
1257
cmCacheManager *cachem = m_cmake->GetCacheManager();
1259
cmCacheManager::CacheIterator it = cachem->NewIterator();
1260
for(size_t i = 0; i < m_cmOptions->GetCount(); i++)
1262
wxPropertyItem* item = m_cmOptions->GetItem(i);
1263
if ( it.Find((const char*)item->GetPropName().c_str()) )
1265
// if value is enclosed in single quotes ('foo') then remove them
1266
// they were used to enforce the fact that it had 'invisible'
1268
if (item->GetCurValue().Len() >= 2 &&
1269
item->GetCurValue().GetChar(0) == '\'' &&
1270
item->GetCurValue().GetChar(item->GetCurValue().Len() - 1) == '\'')
1272
it.SetValue(item->GetCurValue().Mid(1, item->GetCurValue().Len() - 2).c_str());
1275
it.SetValue(item->GetCurValue().c_str());
1282
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_OK
1285
void CMakeSetupFrm::OnButtonOk( wxCommandEvent& event )
1290
void CMakeSetupFrm::DoGenerate()
1292
cmSystemTools::EnableMessages();
1294
cmSystemTools::ResetErrorOccuredFlag();
1296
m_cmOptions->HideControls();
1301
// issue a close when this is done (this is issued by menu "Generate and Exit"
1302
if(m_quitAfterGenerating)
1304
else if(!wxGetKeyState(WXK_SHIFT))
1307
m_config->Read(CM_CLOSEAFTERGEN, &close, CM_CLOSEAFTERGEN_DEF);
1310
wxMessageBox(wxT("Building of project files succesful!"), wxT("Success!"), wxOK|wxICON_INFORMATION);
1318
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_CANCEL
1321
void CMakeSetupFrm::OnButtonCancel( wxCommandEvent& event )
1326
void CMakeSetupFrm::DoCancelButton()
1328
if(m_RunningConfigure)
1330
int result = wxMessageBox(wxT("You are in the middle of a Configure.\n"
1331
"If you Cancel now the configure information will be lost.\n"
1332
"Are you sure you want to Cancel?"), wxT("Warning"), wxYES_NO|wxICON_WARNING);
1334
cmSystemTools::SetFatalErrorOccured();
1337
m_progressDlg->ResetCancel();
1342
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_DELETE_CACHE
1345
void CMakeSetupFrm::OnButtonDeleteCache( wxCommandEvent& event )
1350
void CMakeSetupFrm::DoDeleteCache()
1352
bool deletecache = true;
1353
if(m_cmOptions->IsCacheDirty() || (m_cmOptions->GetCount() > 0 && !m_cmOptions->IsGenerated()))
1355
int result = ::wxMessageBox(_("You have changed options, are you sure you want to delete all items?\n"),
1356
_("Warning"), wxYES_NO|wxICON_QUESTION);
1358
// when user wants to wait, wait.. else quit
1360
deletecache = false;
1366
// indicate that we haven't generated a project yet
1367
m_cmOptions->SetProjectGenerated(false);
1369
if(!m_cmBuildPath->GetValue().Trim().IsEmpty() && m_cmake != 0)
1370
m_cmake->GetCacheManager()->DeleteCache(m_cmBuildPath->GetValue().Trim());
1372
LoadCacheFromDiskToGUI();
1373
UpdateWindowState();
1378
* Should we show tooltips?
1381
bool CMakeSetupFrm::ShowToolTips()
1387
* Get bitmap resources
1390
wxBitmap CMakeSetupFrm::GetBitmapResource( const wxString& name )
1393
////@begin CMakeSetupFrm bitmap retrieval
1394
return wxNullBitmap;
1395
////@end CMakeSetupFrm bitmap retrieval
1399
* Get icon resources
1402
wxIcon CMakeSetupFrm::GetIconResource( const wxString& name )
1405
////@begin CMakeSetupFrm icon retrieval
1406
if (name == wxT("cmake_icon.xpm"))
1408
wxIcon icon(_T("cmake_icon.xpm"), wxBITMAP_TYPE_XPM);
1412
////@end CMakeSetupFrm icon retrieval
1416
* wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING event handler for ID_SPLITTERWINDOW
1419
void CMakeSetupFrm::OnSplitterPosChanging( wxSplitterEvent& event )
1423
GetSize(&width, &height);
1427
if(event.GetSashPosition() < 170)
1428
event.SetSashPosition(170);
1431
if(event.GetSashPosition() > (height - 180))
1432
event.SetSashPosition(height - 180);
1442
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR_LOG
1445
void CMakeSetupFrm::OnClearLogClick( wxCommandEvent& event )
1447
// delete the log text
1449
m_cmLog->DiscardEdits();
1454
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SOURCE_BUILD_PATH
1457
void CMakeSetupFrm::OnSourceBuildPathUpdated( wxCommandEvent& event )
1462
void CMakeSetupFrm::DoReloadCache()
1464
wxString buildpath = m_cmBuildPath->GetValue();
1465
// The build dir has changed, check if there is a cache, and
1466
// grab the source dir from it
1468
// make sure the call to update grid is not executed
1470
m_cmSearchQuery->SetValue(_(""));
1471
m_noRefresh = false;
1473
std::string path = buildpath.c_str();
1474
cmSystemTools::ConvertToUnixSlashes(path);
1476
// adjust the cmake instance
1477
m_cmake->SetHomeOutputDirectory(buildpath.c_str());
1478
m_cmake->SetStartOutputDirectory(buildpath.c_str());
1480
std::string cache_file = path;
1481
cache_file += "/CMakeCache.txt";
1483
// fill in the project path where the source is located, this is
1484
// read from the CMake cache
1485
cmCacheManager *cachem = m_cmake->GetCacheManager();
1486
cmCacheManager::CacheIterator it = cachem->NewIterator();
1487
if (cmSystemTools::FileExists(cache_file.c_str()) && cachem->LoadCache(path.c_str()) &&
1488
it.Find("CMAKE_HOME_DIRECTORY"))
1490
path = ConvertToWindowsPath(it.GetValue());
1491
m_cmProjectPath->SetValue(path.c_str());
1494
m_cmOptions->RemoveAll();
1495
LoadCacheFromDiskToGUI();
1496
UpdateWindowState();
1501
* wxEVT_COMMAND_TEXT_ENTER event handler for ID_SOURCE_BUILD_PATH
1504
void CMakeSetupFrm::OnSourceBuildPathEnter( wxCommandEvent& event )
1506
OnSourceBuildPathUpdated(event);
1510
* wxEVT_MOTION event handler for ID_OPTIONS
1513
void CMakeSetupFrm::OnPropertyMotion( wxMouseEvent& event )
1515
ShowPropertyDescription(m_cmOptions->YToRow(event.GetY()));
1521
* wxEVT_GRID_SELECT_CELL event handler for ID_OPTIONS
1524
void CMakeSetupFrm::OnGridSelectCell( wxGridEvent& event )
1527
ShowPropertyDescription(event.GetRow());
1529
// enable or disable the browse button
1530
m_cmBrowseCell->Enable(m_cmOptions->IsSelectedItemBrowsable(event.GetRow()));
1534
void CMakeSetupFrm::ShowPropertyDescription(int row)
1536
if(row == wxNOT_FOUND || row < 0)
1537
m_cmDescription->SetValue(wxEmptyString);
1540
wxPropertyItem *pItem = m_cmOptions->GetPropertyItemFromRow(row);
1542
m_cmDescription->SetValue(pItem->GetHelpString());
1544
m_cmDescription->SetValue(wxEmptyString);
1549
* wxEVT_GRID_CELL_CHANGE event handler for ID_OPTIONS
1552
void CMakeSetupFrm::OnCellChange( wxGridEvent& event )
1554
// update the button state when the cache is invalidated
1555
UpdateWindowState();
1558
void CMakeSetupFrm::OnRecentFileMenu( wxCommandEvent &event )
1563
wxMenu *mnu = GetMenuBar()->GetMenu(0);
1566
wxMenuItem *item = mnu->FindItem(event.GetId());
1568
m_cmBuildPath->SetValue(item->GetLabel());
1572
* wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_COMBOBOX
1575
void CMakeSetupFrm::OnSearchquerySelected( wxCommandEvent& event )
1577
m_cmOptions->SetQuery(m_cmSearchQuery->GetValue());
1580
void CMakeSetupFrm::OnAddQuery ( wxCommandEvent &event )
1582
// add current text if not yet present
1583
if(m_cmSearchQuery->FindString(m_cmSearchQuery->GetValue()) == wxNOT_FOUND)
1585
m_cmSearchQuery->Append(m_cmSearchQuery->GetValue());
1587
// if too many items are present, prune
1588
while(m_cmSearchQuery->GetCount() > CM_MAX_SEARCH_QUERIES)
1589
m_cmSearchQuery->Delete(0);
1594
* wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHQUERY
1597
void CMakeSetupFrm::OnSearchqueryUpdated( wxCommandEvent& event )
1599
// only refresh when this event was caused by user
1601
m_cmOptions->SetQuery(m_cmSearchQuery->GetValue());
1606
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_GRID
1609
void CMakeSetupFrm::OnBrowseGridClick( wxCommandEvent& event )
1611
m_cmOptions->BrowseSelectedItem();
1616
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_RELOAD_CACHE
1619
void CMakeSetupFrm::OnMenuReloadCacheClick( wxCommandEvent& event )
1622
if(m_cmOptions->IsCacheDirty() || (m_cmOptions->GetCount() > 0 && !m_cmOptions->IsGenerated()))
1624
int result = ::wxMessageBox(_("You have changed options, are you sure you want to reload?\n"),
1625
_("Warning"), wxYES_NO|wxICON_QUESTION);
1627
// when user wants to wait, wait.. else quit
1638
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_DELETE_CACHE
1641
void CMakeSetupFrm::OnMenuDeleteCacheClick( wxCommandEvent& event )
1648
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_QUIT
1651
void CMakeSetupFrm::OnMenuQuitClick( wxCommandEvent& event )
1653
// the close event will veto if the user
1654
// did not want to quit due to unsaved changes
1660
* wxEVT_CLOSE_WINDOW event handler for ID_FRAME
1663
void CMakeSetupFrm::OnCloseWindow( wxCloseEvent& event )
1666
// - The cache is dirty
1667
// - Or the cache is OK and has some items, and no project was generated recently (configure -> generate)
1668
if(m_cmOptions->IsCacheDirty() || (m_cmOptions->GetCount() > 0 && !m_cmOptions->IsGenerated()))
1670
int result = ::wxMessageBox(_("You have changed options, but not yet generated the projects\n"
1671
"are you sure you want to quit?"), _("Warning"), wxYES_NO|wxICON_QUESTION);
1673
// when user wants to wait, wait.. else quit
1685
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_ABOUTDLG
1688
void CMakeSetupFrm::OnAboutClick( wxCommandEvent& event )
1690
CMAboutDlg *dlg = new CMAboutDlg(this);
1692
wxArrayString generators;
1693
std::vector<std::string> names;
1694
m_cmake->GetRegisteredGenerators(names);
1695
for(std::vector<std::string>::iterator i = names.begin(); i != names.end(); ++i)
1696
generators.Add(i->c_str());
1698
wxString cmversion, cmsversion;
1699
// cmversion.Printf("v%i.%i %s", cmake::GetMajorVersion(), cmake::GetMinorVersion(), cmake::GetReleaseVersion());
1700
cmsversion.Printf("v%i.%i%s", CMAKEGUI_MAJORVER, CMAKEGUI_MINORVER, CMAKEGUI_ADDVER);
1702
dlg->SetAboutText(cmversion, cmsversion, generators);
1710
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_CMAKE_OPTIONS
1713
void CMakeSetupFrm::OnOptionsClick( wxCommandEvent& event )
1715
CMOptionsDlg *dlg = new CMOptionsDlg(this);
1717
dlg->SetConfig(m_config);
1718
if(dlg->ShowModal() == wxID_OK)
1720
// store volatile settings
1721
dlg->GetConfig(m_config);
1723
// apply non volatile setting such as clear search query, recent menu, etc.
1724
SyncFormOptions(dlg);
1730
void CMakeSetupFrm::SyncFormOptions(CMOptionsDlg *dlg)
1732
// TODO: Clear search query etc.
1735
* wxEVT_COMMAND_SPLITTER_DOUBLECLICKED event handler for ID_SPLITTERWINDOW
1738
void CMakeSetupFrm::OnSplitterwindowSashDClick( wxSplitterEvent& event )
1745
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_CONFIGURE
1748
void CMakeSetupFrm::OnMenuConfigureClick( wxCommandEvent& event )
1754
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_EXITGENERATE
1757
void CMakeSetupFrm::OnMenuGenerateClick( wxCommandEvent& event )
1759
// set flag so that a close command is issued
1760
// after generating the cmake cache to projects
1761
m_quitAfterGenerating = true;
1763
m_quitAfterGenerating = false;
1768
* wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_TOGGLE_ADVANCED
1771
void CMakeSetupFrm::OnMenuToggleAdvancedClick( wxCommandEvent& event )
1773
// toggle the check box
1774
m_cmShowAdvanced->SetValue(!m_cmShowAdvanced->GetValue());
1775
OnShowAdvancedValues(event);