cmCursesMainForm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCursesMainForm_h
  11. #define cmCursesMainForm_h
  12. #include "cmCursesStandardIncludes.h"
  13. #include "../cmState.h"
  14. #include "cmCursesForm.h"
  15. class cmCursesCacheEntryComposite;
  16. class cmCursesWidget;
  17. class cmake;
  18. /** \class cmCursesMainForm
  19. * \brief The main page of ccmake
  20. *
  21. * cmCursesMainForm is the main page of ccmake.
  22. */
  23. class cmCursesMainForm : public cmCursesForm
  24. {
  25. public:
  26. cmCursesMainForm(std::vector<std::string> const& args, int initwidth);
  27. ~cmCursesMainForm() CM_OVERRIDE;
  28. /**
  29. * Set the widgets which represent the cache entries.
  30. */
  31. void InitializeUI();
  32. /**
  33. * Handle user input.
  34. */
  35. void HandleInput() CM_OVERRIDE;
  36. /**
  37. * Display form. Use a window of size width x height, starting
  38. * at top, left.
  39. */
  40. void Render(int left, int top, int width, int height) CM_OVERRIDE;
  41. /**
  42. * Returns true if an entry with the given key is in the
  43. * list of current composites.
  44. */
  45. bool LookForCacheEntry(const std::string& key);
  46. enum
  47. {
  48. MIN_WIDTH = 65,
  49. MIN_HEIGHT = 6,
  50. IDEAL_WIDTH = 80,
  51. MAX_WIDTH = 512
  52. };
  53. /**
  54. * This method should normally be called only by the form. The only
  55. * exception is during a resize. The optional argument specifies the
  56. * string to be displayed in the status bar.
  57. */
  58. void UpdateStatusBar() CM_OVERRIDE { this->UpdateStatusBar(CM_NULLPTR); }
  59. virtual void UpdateStatusBar(const char* message);
  60. /**
  61. * Display current commands and their keys on the toolbar. This
  62. * method should normally called only by the form. The only
  63. * exception is during a resize. If the optional argument process is
  64. * specified and is either 1 (configure) or 2 (generate), then keys
  65. * will be displayed accordingly.
  66. */
  67. void PrintKeys(int process = 0);
  68. /**
  69. * During a CMake run, an error handle should add errors
  70. * to be displayed afterwards.
  71. */
  72. void AddError(const char* message, const char* title) CM_OVERRIDE;
  73. /**
  74. * Used to do a configure. If argument is specified, it does only the check
  75. * and not configure.
  76. */
  77. int Configure(int noconfigure = 0);
  78. /**
  79. * Used to generate
  80. */
  81. int Generate();
  82. /**
  83. * Used by main program
  84. */
  85. int LoadCache(const char* dir);
  86. /**
  87. * Progress callback
  88. */
  89. static void UpdateProgressOld(const char* msg, float prog, void*);
  90. static void UpdateProgress(const char* msg, float prog, void*);
  91. protected:
  92. cmCursesMainForm(const cmCursesMainForm& from);
  93. void operator=(const cmCursesMainForm&);
  94. // Copy the cache values from the user interface to the actual
  95. // cache.
  96. void FillCacheManagerFromUI();
  97. // Fix formatting of values to a consistent form.
  98. void FixValue(cmState::CacheEntryType type, const std::string& in,
  99. std::string& out) const;
  100. // Re-post the existing fields. Used to toggle between
  101. // normal and advanced modes. Render() should be called
  102. // afterwards.
  103. void RePost();
  104. // Remove an entry from the interface and the cache.
  105. void RemoveEntry(const char* value);
  106. // Jump to the cache entry whose name matches the string.
  107. void JumpToCacheEntry(const char* str);
  108. // Copies of cache entries stored in the user interface
  109. std::vector<cmCursesCacheEntryComposite*>* Entries;
  110. // Errors produced during last run of cmake
  111. std::vector<std::string> Errors;
  112. // Command line argumens to be passed to cmake each time
  113. // it is run
  114. std::vector<std::string> Args;
  115. // Message displayed when user presses 'h'
  116. // It is: Welcome + info about current entry + common help
  117. std::vector<std::string> HelpMessage;
  118. // Common help
  119. static const char* s_ConstHelpMessage;
  120. // Fields displayed. Includes labels, new entry markers, entries
  121. FIELD** Fields;
  122. // Where is source of current project
  123. std::string WhereSource;
  124. // Where is cmake executable
  125. std::string WhereCMake;
  126. // Number of entries shown (depends on mode -normal or advanced-)
  127. size_t NumberOfVisibleEntries;
  128. bool AdvancedMode;
  129. // Did the iteration converge (no new entries) ?
  130. bool OkToGenerate;
  131. // Number of pages displayed
  132. int NumberOfPages;
  133. int InitialWidth;
  134. cmake* CMakeInstance;
  135. std::string SearchString;
  136. std::string OldSearchString;
  137. bool SearchMode;
  138. };
  139. #endif // cmCursesMainForm_h