CMakeSetupFrame.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /*=========================================================================
  2. Program: WXDialog - wxWidgets X-platform GUI Front-End for CMake
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Author: Jorgen Bodde
  8. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  9. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  10. This software is distributed WITHOUT ANY WARRANTY; without even
  11. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  12. PURPOSE. See the above copyright notices for more information.
  13. =========================================================================*/
  14. #ifndef _CMAKESETUPFRAME_H_
  15. #define _CMAKESETUPFRAME_H_
  16. #if defined(__GNUG__) && !defined(__APPLE__)
  17. #pragma interface "CMakeSetupFrame.cpp"
  18. #endif
  19. /*!
  20. * Includes
  21. */
  22. ////@begin includes
  23. #include "wx/frame.h"
  24. #include "wx/splitter.h"
  25. #include "wx/grid.h"
  26. #include "wx/statline.h"
  27. #include "wx/statusbr.h"
  28. ////@end includes
  29. #include <wx/config.h>
  30. #include <wx/dataobj.h>
  31. #include <wx/dnd.h>
  32. #include "../cmake.h"
  33. #include "progressdlg.h"
  34. #include "optionsdlg.h"
  35. #include "CommandLineInfo.h"
  36. #include "config.h"
  37. // this ID should be taken as base to make sure they are unique
  38. // NOTE: DialogBlocks starts at 10100 so 10000 to 10099 are free
  39. #define CM_NEXT_USABLEID CM_RECENT_BUILD_ITEM + CM_MAX_RECENT_PATHS
  40. /*!
  41. * Forward declarations
  42. */
  43. ////@begin forward declarations
  44. class wxSplitterWindow;
  45. class wxPropertyList;
  46. ////@end forward declarations
  47. /*!
  48. * Control identifiers
  49. */
  50. ////@begin control identifiers
  51. #define ID_FRAME 10100
  52. #define SYMBOL_CMAKESETUPFRM_STYLE wxDEFAULT_FRAME_STYLE|wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX|wxSUNKEN_BORDER
  53. #define SYMBOL_CMAKESETUPFRM_TITLE _("CMake Setup v2.0.x")
  54. #define SYMBOL_CMAKESETUPFRM_IDNAME ID_FRAME
  55. #define SYMBOL_CMAKESETUPFRM_SIZE wxSize(600, 550)
  56. #define SYMBOL_CMAKESETUPFRM_POSITION wxDefaultPosition
  57. #define ID_SPLITTERWINDOW 10101
  58. #define ID_MAINPANEL 10102
  59. #define ID_PROJECT_PATH 10103
  60. #define ID_BROWSE_PROJECT 10104
  61. #define ID_SOURCE_BUILD_PATH 10105
  62. #define ID_BROWSE_BUILD 10106
  63. #define ID_CHOOSE_GENERATOR 10107
  64. #define ID_SEARCHQUERY 10109
  65. #define ID_SHOW_ADVANCED 10108
  66. #define ID_OPTIONS 10110
  67. #define ID_LOGPANEL 10111
  68. #define ID_LOG_AREA 10112
  69. #define ID_DESCRIPTION 10113
  70. #define ID_DO_CONFIGURE 10114
  71. #define ID_DO_OK 10115
  72. #define ID_DO_CANCEL 10116
  73. #define ID_DO_DELETE_CACHE 10117
  74. #define ID_CLEAR_LOG 10118
  75. #define ID_BROWSE_GRID 10119
  76. #define ID_STATUSBAR 10120
  77. #define ID_MENU_RELOAD_CACHE 10122
  78. #define ID_MENU_DELETE_CACHE 10123
  79. #define ID_MENU_QUIT 10125
  80. #define ID_MENU_CONFIGURE 10126
  81. #define ID_MENU_EXITGENERATE 10127
  82. #define ID_MENU_TOGGLE_ADVANCED 10128
  83. #define ID_CMAKE_OPTIONS 10124
  84. #define ID_ABOUTDLG 10121
  85. ////@end control identifiers
  86. /*!
  87. * Compatibility
  88. */
  89. #ifndef wxCLOSE_BOX
  90. #define wxCLOSE_BOX 0x1000
  91. #endif
  92. #ifndef wxFIXED_MINSIZE
  93. #define wxFIXED_MINSIZE 0
  94. #endif
  95. class DnDFile : public wxFileDropTarget
  96. {
  97. public:
  98. DnDFile(wxTextCtrl *pOwner)
  99. : m_pOwner(pOwner)
  100. {
  101. };
  102. virtual bool OnDropFiles(wxCoord x, wxCoord y,
  103. const wxArrayString& filenames);
  104. private:
  105. wxTextCtrl *m_pOwner;
  106. };
  107. /*!
  108. * CMakeSetupFrm class declaration
  109. */
  110. class CMakeSetupFrm: public wxFrame
  111. {
  112. DECLARE_CLASS( CMakeSetupFrm )
  113. DECLARE_EVENT_TABLE()
  114. public:
  115. /// Constructors
  116. CMakeSetupFrm( );
  117. 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 );
  118. // Destructor
  119. virtual ~CMakeSetupFrm();
  120. 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 );
  121. /// Creates the controls and sizers
  122. void CreateControls();
  123. /** Logs a message. For the kind parameter use;
  124. 1 - neutral message
  125. 0 - warning message (blue text)
  126. -1 - error message (red text)
  127. */
  128. void LogMessage(int logkind, const char *msg);
  129. void UpdateProgress(float progress) {
  130. if(m_progressDlg)
  131. m_progressDlg->SetProgress(progress);
  132. // also show in the tiny field
  133. wxStatusBar *bar = GetStatusBar();
  134. if(bar)
  135. {
  136. wxString str;
  137. str.Printf("%2.1f %%", (progress * 100));
  138. bar->SetStatusText(str, 1);
  139. }
  140. };
  141. void IssueUpdate();
  142. /** Initialise all crap in the frame, like listing the make generators,
  143. selecting the best one to use, and loading the cache for the first time
  144. when the build paths were set */
  145. void DoInitFrame(cmCommandLineInfo &cm, const wxString &fn);
  146. ////@begin CMakeSetupFrm event handler declarations
  147. /// wxEVT_CLOSE_WINDOW event handler for ID_FRAME
  148. void OnCloseWindow( wxCloseEvent& event );
  149. /// wxEVT_COMMAND_SPLITTER_SASH_POS_CHANGING event handler for ID_SPLITTERWINDOW
  150. void OnSplitterPosChanging( wxSplitterEvent& event );
  151. /// wxEVT_COMMAND_SPLITTER_DOUBLECLICKED event handler for ID_SPLITTERWINDOW
  152. void OnSplitterwindowSashDClick( wxSplitterEvent& event );
  153. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_PROJECT
  154. void OnButtonBrowseProject( wxCommandEvent& event );
  155. /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SOURCE_BUILD_PATH
  156. void OnSourceBuildPathUpdated( wxCommandEvent& event );
  157. /// wxEVT_COMMAND_TEXT_ENTER event handler for ID_SOURCE_BUILD_PATH
  158. void OnSourceBuildPathEnter( wxCommandEvent& event );
  159. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_BUILD
  160. void OnButtonBrowseBuild( wxCommandEvent& event );
  161. /// wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_SEARCHQUERY
  162. void OnSearchquerySelected( wxCommandEvent& event );
  163. /// wxEVT_COMMAND_TEXT_UPDATED event handler for ID_SEARCHQUERY
  164. void OnSearchqueryUpdated( wxCommandEvent& event );
  165. /// wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_SHOW_ADVANCED
  166. void OnShowAdvancedValues( wxCommandEvent& event );
  167. /// wxEVT_GRID_CELL_CHANGE event handler for ID_OPTIONS
  168. void OnCellChange( wxGridEvent& event );
  169. /// wxEVT_GRID_SELECT_CELL event handler for ID_OPTIONS
  170. void OnGridSelectCell( wxGridEvent& event );
  171. /// wxEVT_MOTION event handler for ID_OPTIONS
  172. void OnPropertyMotion( wxMouseEvent& event );
  173. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_CONFIGURE
  174. void OnButtonConfigure( wxCommandEvent& event );
  175. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_OK
  176. void OnButtonOk( wxCommandEvent& event );
  177. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_CANCEL
  178. void OnButtonCancel( wxCommandEvent& event );
  179. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_DO_DELETE_CACHE
  180. void OnButtonDeleteCache( wxCommandEvent& event );
  181. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_CLEAR_LOG
  182. void OnClearLogClick( wxCommandEvent& event );
  183. /// wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_BROWSE_GRID
  184. void OnBrowseGridClick( wxCommandEvent& event );
  185. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_RELOAD_CACHE
  186. void OnMenuReloadCacheClick( wxCommandEvent& event );
  187. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_DELETE_CACHE
  188. void OnMenuDeleteCacheClick( wxCommandEvent& event );
  189. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_QUIT
  190. void OnMenuQuitClick( wxCommandEvent& event );
  191. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_CONFIGURE
  192. void OnMenuConfigureClick( wxCommandEvent& event );
  193. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_EXITGENERATE
  194. void OnMenuGenerateClick( wxCommandEvent& event );
  195. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_MENU_TOGGLE_ADVANCED
  196. void OnMenuToggleAdvancedClick( wxCommandEvent& event );
  197. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_CMAKE_OPTIONS
  198. void OnOptionsClick( wxCommandEvent& event );
  199. /// wxEVT_COMMAND_MENU_SELECTED event handler for ID_ABOUTDLG
  200. void OnAboutClick( wxCommandEvent& event );
  201. ////@end CMakeSetupFrm event handler declarations
  202. void OnRecentFileMenu( wxCommandEvent &event );
  203. void OnAddQuery ( wxCommandEvent &event );
  204. ////@begin CMakeSetupFrm member function declarations
  205. /// Retrieves bitmap resources
  206. wxBitmap GetBitmapResource( const wxString& name );
  207. /// Retrieves icon resources
  208. wxIcon GetIconResource( const wxString& name );
  209. ////@end CMakeSetupFrm member function declarations
  210. /// Should we show tooltips?
  211. static bool ShowToolTips();
  212. /** Load cache for the CMakeLists to the GUI */
  213. void LoadCacheFromDiskToGUI();
  214. /** Display the grid with the loaded cache. */
  215. void FillCacheGUIFromCacheManager();
  216. int RunCMake(bool generateProjectFiles);
  217. /** Save cache to disk from the GUI */
  218. void SaveCacheFromGUI();
  219. void FillCacheManagerFromCacheGUI();
  220. /** Update the cache and mark all the new items as old */
  221. bool PerformCacheRun();
  222. /** Shows the property matched by the row in the description area
  223. or nothing when the row is not correct */
  224. void ShowPropertyDescription(int row);
  225. /** Disable or enable controls based upon the internal state of the
  226. program */
  227. void UpdateWindowState();
  228. void AppendPathToRecentList(const wxString &p);
  229. /** Used to synchonise any options that have immediate effect on the GUI
  230. form, like clearing a search list, resetting a spitter perhaps, etc */
  231. void SyncFormOptions(CMOptionsDlg *dlg);
  232. void DoCancelButton();
  233. void DoReloadCache();
  234. void DoDeleteCache();
  235. void DoConfigure();
  236. void DoGenerate();
  237. void OnExitTimer(wxTimerEvent &event);
  238. ////@begin CMakeSetupFrm member variables
  239. wxSplitterWindow* m_splitter;
  240. wxTextCtrl* m_cmProjectPath;
  241. wxButton* m_BrowseProjectPathButton;
  242. wxTextCtrl* m_cmBuildPath;
  243. wxButton* m_BrowseSourcePathButton;
  244. wxComboBox* m_cmGeneratorChoice;
  245. wxComboBox* m_cmSearchQuery;
  246. wxCheckBox* m_cmShowAdvanced;
  247. wxPropertyList* m_cmOptions;
  248. wxTextCtrl* m_cmLog;
  249. wxTextCtrl* m_cmDescription;
  250. wxButton* m_ConfigureButton;
  251. wxButton* m_OkButton;
  252. wxButton* m_CancelButton;
  253. wxButton* m_DeleteCacheButton;
  254. wxButton* m_ClearLogButton;
  255. wxButton* m_cmBrowseCell;
  256. ////@end CMakeSetupFrm member variables
  257. // this is the cmake instance with which we will communicate
  258. // to generate our stuff, and get the info from.
  259. cmake *m_cmake;
  260. // the config class for project build dir and source path
  261. wxTimer *m_ExitTimer;
  262. wxConfig *m_config;
  263. wxString m_PathToExecutable;
  264. wxArrayString m_recentPaths;
  265. CMProgressDialog *m_progressDlg;
  266. bool m_RunningConfigure;
  267. bool m_noRefresh;
  268. bool m_quitAfterGenerating;
  269. };
  270. #endif
  271. // _CMAKESETUPFRAME_H_