cmCursesMainForm.h 4.7 KB

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