cmWXMainFrame.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef __cmMainFrame__h__
  14. #define __cmMainFrame__h__
  15. #include "cmStandardIncludes.h"
  16. #include "wxincludes.h"
  17. class cmCacheProperty;
  18. class cmCommandLineInfo;
  19. class cmake;
  20. class wxButton;
  21. class wxCheckBox;
  22. class wxComboBox;
  23. class wxMenu;
  24. class wxPanel;
  25. class wxScrolledWindow;
  26. class wxSizer;
  27. class wxStaticBox;
  28. class wxStaticText;
  29. class wxApp;
  30. /** \class cmMainFrame
  31. * \brief GUI for CMake with wxWindows toolkit
  32. *
  33. * The main dialog for the CMake
  34. *
  35. */
  36. class cmMainFrame : public wxFrame
  37. {
  38. public:
  39. cmMainFrame(const wxString& title, const wxSize& size);
  40. ~cmMainFrame();
  41. //! Initialize the paths and read the cache.
  42. void Initialize(cmCommandLineInfo*);
  43. //! Different callbacks for events
  44. void OnOk(wxCommandEvent& event);
  45. void OnConfigure(wxCommandEvent& event);
  46. void OnCancel(wxCommandEvent& event);
  47. void OnHelp(wxCommandEvent& event);
  48. void OnBrowseSource(wxCommandEvent& event);
  49. void OnSourceSelected(wxCommandEvent& event);
  50. void OnSourceUpdated(wxCommandEvent& event);
  51. void OnBrowseBinary(wxCommandEvent& event);
  52. void OnBinarySelected(wxCommandEvent& event);
  53. void OnBinaryUpdated(wxCommandEvent& event);
  54. void OnBinaryAccepted(wxCommandEvent& event);
  55. void OnShowAdvancedValues(wxCommandEvent& event);
  56. void OnResize(wxSizeEvent& event);
  57. void OnPropertyChanged(wxEvent& event);
  58. void OnRandomEvent(wxEvent& event);
  59. void OnGeneratorSelected(wxEvent& event);
  60. void OnPopupMenu(wxMouseEvent& event);
  61. void OnCacheStatusBar(wxEvent& event);
  62. void OnStatusBar(wxEvent& event);
  63. void OnExitTimer(wxEvent& event);
  64. //! Callbacks for menu events
  65. void OnPopupMenuIgnore(wxEvent& event);
  66. void OnPopupMenuDelete(wxEvent& event);
  67. void OnPopupMenuHelp(wxEvent& event);
  68. void OnPopupMenuEntry(wxEvent& event, int idx);
  69. // Connect widget and event with method.
  70. void ConnectEvent(wxWindow*, wxEventType, wxObjectEventFunction);
  71. void ConnectEventTo(wxWindow*, wxEventType, wxObjectEventFunction);
  72. //! Callback for the error message.
  73. static void MessageCallback(const char* m, const char* title,
  74. bool& nomore, void* cd);
  75. static void ProgressCallback(const char* m, float prog, void* clientData);
  76. void DisplayMessage(const char* m, const char* title, bool& nomore);
  77. //! Retrieve the current build directory.
  78. const std::string& GetBuildDir() { return this->m_WhereBuild; }
  79. //! Set the application for progress
  80. void SetApplication(wxApp* app) { m_Application = app; }
  81. private:
  82. //! Load cache file from m_WhereBuild and display in GUI editor
  83. void LoadCacheFromDiskToGUI();
  84. //! Save GUI values to cmCacheManager and then save to disk.
  85. void SaveCacheFromGUI();
  86. // copy from the cache manager to the cache edit list box
  87. void FillCacheGUIFromCacheManager();
  88. // copy from the list box to the cache manager
  89. void FillCacheManagerFromCacheGUI();
  90. // set the current generator
  91. void SetGenerator(const char* generator);
  92. // Set the status bar binding.
  93. void SetupStatusBarBinding(wxWindow*);
  94. // set the current source and binary dir
  95. bool SetSourceDir(const char* dir);
  96. std::string GetSourceDir();
  97. bool SetBinaryDir(const char* dir);
  98. std::string GetBinaryDir();
  99. void ChangeDirectoriesFromFile(const char* buffer);
  100. // update source and binary menus.
  101. void UpdateSourceBuildMenus();
  102. // Check wether cache is dirty.
  103. bool IsDirty() { return !this->m_Clean; }
  104. void SetDirty() { this->m_Clean = false; }
  105. void ClearDirty() { this->m_Clean = true; }
  106. // Run the CMake
  107. void RunCMake(bool generateProjectFiles);
  108. void RemoveAdvancedValues();
  109. void UpdateCacheValuesDisplay();
  110. // Change the build directory.
  111. void ChangeWhereSource();
  112. void ChangeWhereBuild();
  113. bool SourceDirectoryChanged();
  114. bool BuildDirectoryChanged();
  115. // Clear the Cache
  116. void ClearCache();
  117. void RemoveCacheEntry(cmCacheProperty*);
  118. void IgnoreCacheEntry(const char* key);
  119. void HelpCacheEntry(const char* key, const char* help);
  120. void LoadFromRegistry();
  121. void SaveToRegistry();
  122. virtual void SetStatusText(const wxString& text, int number = 0);
  123. void ResizeInternal();
  124. //! Change the type of mouse cursor. Set argument to true to store
  125. // the type.
  126. void CursorBusy(bool s=false);
  127. void CursorNormal(bool s=false);
  128. // Main panel
  129. wxPanel* m_MainPanel;
  130. wxSizer* m_TopMostSizer;
  131. // Main sizer
  132. wxSizer* m_MainSizer;
  133. // Top row of main sizer
  134. wxSizer* m_TopGrid;
  135. // Top line:
  136. wxStaticText* m_TextSource;
  137. wxComboBox* m_PathSource;
  138. wxButton* m_BrowseSource;
  139. // Top line end frame:
  140. wxSizer* m_GeneratorFrame;
  141. wxStaticText* m_BuildFor;
  142. wxComboBox* m_GeneratorMenu;
  143. // Bottom line:
  144. wxStaticText* m_TextBinary;
  145. wxComboBox* m_PathBinary;
  146. wxButton* m_BrowseBinary;
  147. wxCheckBox* m_ShowAdvancedValues;
  148. // Cache values:
  149. wxStaticBox* m_CacheValuesBox;
  150. wxSizer* m_CacheValuesFrame;
  151. wxScrolledWindow* m_CacheValuesScroll;
  152. wxPanel* m_CacheValuesPanel;
  153. wxSizer* m_CacheValuesSizer;
  154. // Help text:
  155. wxStaticText* m_HelpText;
  156. // Buttons:
  157. wxSizer* m_BottomButtonsFrame;
  158. wxStaticText* m_VersionText;
  159. wxButton* m_ConfigureButton;
  160. wxButton* m_OKButton;
  161. wxButton* m_CancelButton;
  162. wxButton* m_HelpButton;
  163. // This is set when the cache has to be updated.
  164. bool m_Update;
  165. // This is to detect when cache is not valid such as when cache
  166. // entry is removed or when some new entries are present. You have
  167. // to rerun cmake to set valid to true.
  168. bool m_Valid;
  169. // This is needed for mac, because on mac dialog has to be redrawn
  170. // after the menu is removed.
  171. bool m_EntryRemoved;
  172. std::string m_WhereSource;
  173. std::string m_WhereBuild;
  174. std::string m_PathToExecutable;
  175. bool m_Clean;
  176. bool m_BuildPathChanged;
  177. bool m_CursorChanged;
  178. typedef std::map<std::string, cmCacheProperty*> CacheMapType;
  179. CacheMapType* m_CacheEntries;
  180. cmake* m_CMakeInstance;
  181. wxTimer* m_ExitTimer;
  182. wxApp* m_Application;
  183. enum Events {
  184. ID_MainFrame,
  185. ID_Resize,
  186. ID_OKButton,
  187. ID_ConfigureButton,
  188. ID_CancelButton,
  189. ID_HelpButton,
  190. ID_AdvancedValues
  191. };
  192. };
  193. #endif // __cmMainFrame__h__