cmWXCacheProperty.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 CMCACHEPROPERTY_H
  14. #define CMCACHEPROPERTY_H
  15. #include "cmStandardIncludes.h"
  16. #include "wxincludes.h"
  17. class cmMainFrame;
  18. class wxControl;
  19. class wxPanel;
  20. class wxSizer;
  21. class wxWindow;
  22. /** \class cmCacheProperty
  23. * \brief GUI Control class for cmake's cache property
  24. *
  25. * Stores cache property as displayed on GUI, caches its value, colors
  26. * red when new.
  27. *
  28. */
  29. class cmCacheProperty
  30. {
  31. public:
  32. cmCacheProperty(cmMainFrame*, const std::string& name);
  33. ~cmCacheProperty();
  34. const std::string& GetName() { return this->m_Name; }
  35. //! Get and set the value
  36. const std::string& GetValue() { return this->m_Value; }
  37. void SetValue(const std::string& s) { this->m_Value = s; }
  38. //! Get and set the help value
  39. void SetHelp(const std::string& s) { this->m_HelpString = s; }
  40. const std::string& GetHelp() { return this->m_HelpString; }
  41. //! Display the property in the window. Return the maximum height.
  42. int Display(wxSizer*, wxPanel*);
  43. //! Remove the property from the window
  44. void Remove(wxSizer*, wxPanel*);
  45. //! This method is called when property is changed
  46. void OnPropertyChanged(wxEvent& event);
  47. //! Mark cache entry as being removed.
  48. void MarkRemoved() { this->m_Removed = true; }
  49. //! Check if the entry was removed
  50. bool IsRemoved() { return this->m_Removed; }
  51. //! Get and set the new flag.
  52. void SetNewFlag(bool f) { this->m_NewValue = f; }
  53. bool GetNewFlag() { return this->m_NewValue; }
  54. //! Mark cache entry as being removed.
  55. void MarkAdvanced() { this->m_Advanced = true; }
  56. //! Check if the entry was removed
  57. bool IsAdvanced() { return this->m_Advanced; }
  58. //! Set item type
  59. void SetItemType(int t) { this->m_ItemType = t; }
  60. //! Get the main frame asociated with the cache property
  61. cmMainFrame* GetMainFrame() { return this->m_MainFrame; }
  62. enum ItemType
  63. {
  64. NOTHING = 0,
  65. EDIT,
  66. FILE,
  67. CHECKBOX,
  68. PATH
  69. };
  70. enum
  71. {
  72. Menu_Popup_Ignore = 200,
  73. Menu_Popup_Delete,
  74. Menu_Popup_Help
  75. };
  76. protected:
  77. bool m_NewValue;
  78. bool m_Advanced;
  79. int m_ItemType;
  80. wxWindow* m_KeyWindow;
  81. wxWindow* m_ValueWindow;
  82. std::string m_Name;
  83. std::string m_Value;
  84. std::string m_HelpString;
  85. bool m_Removed;
  86. //! The following methods set the events handling of widgets for the
  87. // cache property.
  88. void ConnectEvent(wxWindow* win, wxEventType et, wxObjectEventFunction func);
  89. void ConnectEventTo(wxWindow* win, wxEventType et, wxObjectEventFunction func);
  90. void SetupMenu(wxWindow* win);
  91. //! This are event callbacks for different events.
  92. void OnFileBrowseButton(wxEvent& event);
  93. void OnPathBrowseButton(wxEvent& event);
  94. void OnCheckboxButton(wxEvent& event);
  95. void OnEntryChanged(wxEvent& event);
  96. private:
  97. cmMainFrame* m_MainFrame;
  98. wxControl* m_TextControl;
  99. };
  100. #endif