cmCursesMainForm.h 4.8 KB

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