Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / WXDialog / CMakeSetupFrame.h
blobcf48988f164342edab7c21bc948cce41893b6a4f
1 /*=========================================================================
3 Program: WXDialog - wxWidgets X-platform GUI Front-End for CMake
4 Module: $RCSfile: CMakeSetupFrame.h,v $
5 Language: C++
6 Date: $Date: 2005/06/30 19:54:14 $
7 Version: $Revision: 1.1 $
9 Author: Jorgen Bodde
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 #ifndef _CMAKESETUPFRAME_H_
21 #define _CMAKESETUPFRAME_H_
23 #if defined(__GNUG__) && !defined(__APPLE__)
24 #pragma interface "CMakeSetupFrame.cpp"
25 #endif
27 /*!
28 * Includes
31 ////@begin includes
32 #include "wx/frame.h"
33 #include "wx/splitter.h"
34 #include "wx/grid.h"
35 #include "wx/statline.h"
36 #include "wx/statusbr.h"
37 ////@end includes
39 #include <wx/config.h>
40 #include <wx/dataobj.h>
41 #include <wx/dnd.h>
44 #include "../cmake.h"
45 #include "progressdlg.h"
46 #include "optionsdlg.h"
47 #include "CommandLineInfo.h"
48 #include "config.h"
50 // this ID should be taken as base to make sure they are unique
51 // NOTE: DialogBlocks starts at 10100 so 10000 to 10099 are free
52 #define CM_NEXT_USABLEID CM_RECENT_BUILD_ITEM + CM_MAX_RECENT_PATHS
54 /*!
55 * Forward declarations
58 ////@begin forward declarations
59 class wxSplitterWindow;
60 class wxPropertyList;
61 ////@end forward declarations
63 /*!
64 * Control identifiers
67 ////@begin control identifiers
68 #define ID_FRAME 10100
69 #define SYMBOL_CMAKESETUPFRM_STYLE wxDEFAULT_FRAME_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX|wxSUNKEN_BORDER
70 #define SYMBOL_CMAKESETUPFRM_TITLE _("CMake Setup v2.0.x")
71 #define SYMBOL_CMAKESETUPFRM_IDNAME ID_FRAME
72 #define SYMBOL_CMAKESETUPFRM_SIZE wxSize(600, 550)
73 #define SYMBOL_CMAKESETUPFRM_POSITION wxDefaultPosition
74 #define ID_SPLITTERWINDOW 10101
75 #define ID_MAINPANEL 10102
76 #define ID_PROJECT_PATH 10103
77 #define ID_BROWSE_PROJECT 10104
78 #define ID_SOURCE_BUILD_PATH 10105
79 #define ID_BROWSE_BUILD 10106
80 #define ID_CHOOSE_GENERATOR 10107
81 #define ID_SEARCHQUERY 10109
82 #define ID_SHOW_ADVANCED 10108
83 #define ID_OPTIONS 10110
84 #define ID_LOGPANEL 10111
85 #define ID_LOG_AREA 10112
86 #define ID_DESCRIPTION 10113
87 #define ID_DO_CONFIGURE 10114
88 #define ID_DO_OK 10115
89 #define ID_DO_CANCEL 10116
90 #define ID_DO_DELETE_CACHE 10117
91 #define ID_CLEAR_LOG 10118
92 #define ID_BROWSE_GRID 10119
93 #define ID_STATUSBAR 10120
94 #define ID_MENU_RELOAD_CACHE 10122
95 #define ID_MENU_DELETE_CACHE 10123
96 #define ID_MENU_QUIT 10125
97 #define ID_MENU_CONFIGURE 10126
98 #define ID_MENU_EXITGENERATE 10127
99 #define ID_MENU_TOGGLE_ADVANCED 10128
100 #define ID_CMAKE_OPTIONS 10124
101 #define ID_ABOUTDLG 10121
102 ////@end control identifiers
105 * Compatibility
108 #ifndef wxCLOSE_BOX
109 #define wxCLOSE_BOX 0x1000
110 #endif
111 #ifndef wxFIXED_MINSIZE
112 #define wxFIXED_MINSIZE 0
113 #endif
115 class DnDFile : public wxFileDropTarget
117 public:
118 DnDFile(wxTextCtrl *pOwner)
119 : m_pOwner(pOwner)
123 virtual bool OnDropFiles(wxCoord x, wxCoord y,
124 const wxArrayString& filenames);
126 private:
127 wxTextCtrl *m_pOwner;
132 * CMakeSetupFrm class declaration
135 class CMakeSetupFrm: public wxFrame
137 DECLARE_CLASS( CMakeSetupFrm )
138 DECLARE_EVENT_TABLE()
140 public:
141 /// Constructors
142 CMakeSetupFrm( );
143 CMakeSetupFrm( wxWindow* parent, wxWindowID id = SYMBOL_CMAKESETUPFRM_IDNAME, const wxString& caption = SYMBOL_CMAKESETUPFRM_TITLE, const wxPoint& pos = SYMBOL_CMAKESETUPFRM_POSITION, const wxSize& size = SYMBOL_CMAKESETUPFRM_SIZE, long style = SYMBOL_CMAKESETUPFRM_STYLE );
145 // Destructor
146 virtual ~CMakeSetupFrm();
148 bool Create( wxWindow* parent, wxWindowID id = SYMBOL_CMAKESETUPFRM_IDNAME, const wxString& caption = SYMBOL_CMAKESETUPFRM_TITLE, const wxPoint& pos = SYMBOL_CMAKESETUPFRM_POSITION, const wxSize& size = SYMBOL_CMAKESETUPFRM_SIZE, long style = SYMBOL_CMAKESETUPFRM_STYLE );
150 /// Creates the controls and sizers
151 void CreateControls();
153 /** Logs a message. For the kind parameter use;
154 1 - neutral message
155 0 - warning message (blue text)
156 -1 - error message (red text)
158 void LogMessage(int logkind, const char *msg);
160 void UpdateProgress(float progress) {
161 if(m_progressDlg)
162 m_progressDlg->SetProgress(progress);
164 // also show in the tiny field
165 wxStatusBar *bar = GetStatusBar();
166 if(bar)
168 wxString str;
169 str.Printf("%2.1f %%", (progress * 100));
170 bar->SetStatusText(str, 1);
174 void IssueUpdate();
176 /** Initialise all crap in the frame, like listing the make generators,
177 selecting the best one to use, and loading the cache for the first time
178 when the build paths were set */
179 void DoInitFrame(cmCommandLineInfo &cm, const wxString &fn);
181 ////@begin CMakeSetupFrm event handler declarations
183 /// wxEVT_CLOSE_WINDOW event handler for ID_FRAME
184 void OnCloseWindow( wxCloseEvent& event );
186 /// wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING event handler for ID_SPLITTERWINDOW
187 void OnSplitterPosChanging( wxSplitterEvent& event );
189 /// wxEVT_COMMAND_SPLITTER_DOUBLECLICKED event handler for ID_SPLITTERWINDOW
190 void OnSplitterwindowSashDClick( wxSplitterEvent& event );
192 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_PROJECT
193 void OnButtonBrowseProject( wxCommandEvent& event );
195 /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SOURCE_BUILD_PATH
196 void OnSourceBuildPathUpdated( wxCommandEvent& event );
198 /// wxEVT_COMMAND_TEXT_ENTER event handler for ID_SOURCE_BUILD_PATH
199 void OnSourceBuildPathEnter( wxCommandEvent& event );
201 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_BUILD
202 void OnButtonBrowseBuild( wxCommandEvent& event );
204 /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_SEARCHQUERY
205 void OnSearchquerySelected( wxCommandEvent& event );
207 /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHQUERY
208 void OnSearchqueryUpdated( wxCommandEvent& event );
210 /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_SHOW_ADVANCED
211 void OnShowAdvancedValues( wxCommandEvent& event );
213 /// wxEVT_GRID_CELL_CHANGE event handler for ID_OPTIONS
214 void OnCellChange( wxGridEvent& event );
216 /// wxEVT_GRID_SELECT_CELL event handler for ID_OPTIONS
217 void OnGridSelectCell( wxGridEvent& event );
219 /// wxEVT_MOTION event handler for ID_OPTIONS
220 void OnPropertyMotion( wxMouseEvent& event );
222 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_CONFIGURE
223 void OnButtonConfigure( wxCommandEvent& event );
225 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_OK
226 void OnButtonOk( wxCommandEvent& event );
228 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_CANCEL
229 void OnButtonCancel( wxCommandEvent& event );
231 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_DELETE_CACHE
232 void OnButtonDeleteCache( wxCommandEvent& event );
234 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR_LOG
235 void OnClearLogClick( wxCommandEvent& event );
237 /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_GRID
238 void OnBrowseGridClick( wxCommandEvent& event );
240 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_RELOAD_CACHE
241 void OnMenuReloadCacheClick( wxCommandEvent& event );
243 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_DELETE_CACHE
244 void OnMenuDeleteCacheClick( wxCommandEvent& event );
246 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_QUIT
247 void OnMenuQuitClick( wxCommandEvent& event );
249 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_CONFIGURE
250 void OnMenuConfigureClick( wxCommandEvent& event );
252 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_EXITGENERATE
253 void OnMenuGenerateClick( wxCommandEvent& event );
255 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_TOGGLE_ADVANCED
256 void OnMenuToggleAdvancedClick( wxCommandEvent& event );
258 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_CMAKE_OPTIONS
259 void OnOptionsClick( wxCommandEvent& event );
261 /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_ABOUTDLG
262 void OnAboutClick( wxCommandEvent& event );
264 ////@end CMakeSetupFrm event handler declarations
266 void OnRecentFileMenu( wxCommandEvent &event );
268 void OnAddQuery ( wxCommandEvent &event );
270 ////@begin CMakeSetupFrm member function declarations
272 /// Retrieves bitmap resources
273 wxBitmap GetBitmapResource( const wxString& name );
275 /// Retrieves icon resources
276 wxIcon GetIconResource( const wxString& name );
277 ////@end CMakeSetupFrm member function declarations
279 /// Should we show tooltips?
280 static bool ShowToolTips();
282 /** Load cache for the CMakeLists to the GUI */
283 void LoadCacheFromDiskToGUI();
285 /** Display the grid with the loaded cache. */
286 void FillCacheGUIFromCacheManager();
288 int RunCMake(bool generateProjectFiles);
290 /** Save cache to disk from the GUI */
291 void SaveCacheFromGUI();
293 void FillCacheManagerFromCacheGUI();
295 /** Update the cache and mark all the new items as old */
296 bool PerformCacheRun();
298 /** Shows the property matched by the row in the description area
299 or nothing when the row is not correct */
300 void ShowPropertyDescription(int row);
302 /** Disable or enable controls based upon the internal state of the
303 program */
304 void UpdateWindowState();
306 void AppendPathToRecentList(const wxString &p);
308 /** Used to synchonise any options that have immediate effect on the GUI
309 form, like clearing a search list, resetting a spitter perhaps, etc */
310 void SyncFormOptions(CMOptionsDlg *dlg);
312 void DoCancelButton();
314 void DoReloadCache();
316 void DoDeleteCache();
318 void DoConfigure();
320 void DoGenerate();
322 void OnExitTimer(wxTimerEvent &event);
324 ////@begin CMakeSetupFrm member variables
325 wxSplitterWindow* m_splitter;
326 wxTextCtrl* m_cmProjectPath;
327 wxButton* m_BrowseProjectPathButton;
328 wxTextCtrl* m_cmBuildPath;
329 wxButton* m_BrowseSourcePathButton;
330 wxComboBox* m_cmGeneratorChoice;
331 wxComboBox* m_cmSearchQuery;
332 wxCheckBox* m_cmShowAdvanced;
333 wxPropertyList* m_cmOptions;
334 wxTextCtrl* m_cmLog;
335 wxTextCtrl* m_cmDescription;
336 wxButton* m_ConfigureButton;
337 wxButton* m_OkButton;
338 wxButton* m_CancelButton;
339 wxButton* m_DeleteCacheButton;
340 wxButton* m_ClearLogButton;
341 wxButton* m_cmBrowseCell;
342 ////@end CMakeSetupFrm member variables
344 // this is the cmake instance with which we will communicate
345 // to generate our stuff, and get the info from.
346 cmake *m_cmake;
348 // the config class for project build dir and source path
349 wxTimer *m_ExitTimer;
350 wxConfig *m_config;
351 wxString m_PathToExecutable;
352 wxArrayString m_recentPaths;
353 CMProgressDialog *m_progressDlg;
354 bool m_RunningConfigure;
355 bool m_noRefresh;
356 bool m_quitAfterGenerating;
359 #endif
360 // _CMAKESETUPFRAME_H_