cmWXMainFrame.h 6.8 KB

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