cmCursesMainForm.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. // 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 value with index idx. If string str is
  106. // specified, it will stop on widget that contain that string.
  107. void JumpToCacheEntry(int idx, const char* str);
  108. // Copies of cache entries stored in the user interface
  109. std::vector<cmCursesCacheEntryComposite*>* m_Entries;
  110. // Errors produced during last run of cmake
  111. std::vector<std::string> m_Errors;
  112. // Command line argumens to be passed to cmake each time
  113. // it is run
  114. std::vector<std::string> m_Args;
  115. // Message displayed when user presses 'h'
  116. // It is: Welcome + info about current entry + common help
  117. std::vector<std::string> m_HelpMessage;
  118. // Common help
  119. static const char* s_ConstHelpMessage;
  120. // Fields displayed. Includes labels, new entry markers, entries
  121. FIELD** m_Fields;
  122. // Where is source of current project
  123. std::string m_WhereSource;
  124. // Where is cmake executable
  125. std::string m_WhereCMake;
  126. // Number of entries shown (depends on mode -normal or advanced-)
  127. int m_NumberOfVisibleEntries;
  128. bool m_AdvancedMode;
  129. // Did the iteration converge (no new entries) ?
  130. bool m_OkToGenerate;
  131. // Number of pages displayed
  132. int m_NumberOfPages;
  133. int m_InitialWidth;
  134. cmake *m_CMakeInstance;
  135. std::string m_SearchString;
  136. std::string m_OldSearchString;
  137. bool m_SearchMode;
  138. };
  139. #endif // __cmCursesMainForm_h