cmCursesMainForm.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.
  77. */
  78. int Configure();
  79. /**
  80. * Used to generate
  81. */
  82. int Generate();
  83. /**
  84. * Used by main program
  85. */
  86. int LoadCache(const char *dir);
  87. /**
  88. * Progress callback
  89. */
  90. static void UpdateProgressOld(const char *msg, float prog, void*);
  91. static void UpdateProgress(const char *msg, float prog, void*);
  92. protected:
  93. cmCursesMainForm(const cmCursesMainForm& from);
  94. void operator=(const cmCursesMainForm&);
  95. // Copy the cache values from the user interface to the actual
  96. // cache.
  97. void FillCacheManagerFromUI();
  98. // Re-post the existing fields. Used to toggle between
  99. // normal and advanced modes. Render() should be called
  100. // afterwards.
  101. void RePost();
  102. // Remove an entry from the interface and the cache.
  103. void RemoveEntry(const char* value);
  104. // Jump to the cache value with index idx. If string str is
  105. // specified, it will stop on widget that contain that string.
  106. void JumpToCacheEntry(int idx, const char* str);
  107. // Copies of cache entries stored in the user interface
  108. std::vector<cmCursesCacheEntryComposite*>* m_Entries;
  109. // Errors produced during last run of cmake
  110. std::vector<std::string> m_Errors;
  111. // Command line argumens to be passed to cmake each time
  112. // it is run
  113. std::vector<std::string> m_Args;
  114. // Message displayed when user presses 'h'
  115. // It is: Welcome + info about current entry + common help
  116. std::vector<std::string> m_HelpMessage;
  117. // Common help
  118. static const char* s_ConstHelpMessage;
  119. // Fields displayed. Includes labels, new entry markers, entries
  120. FIELD** m_Fields;
  121. // Where is source of current project
  122. std::string m_WhereSource;
  123. // Where is cmake executable
  124. std::string m_WhereCMake;
  125. // Number of entries shown (depends on mode -normal or advanced-)
  126. int m_NumberOfVisibleEntries;
  127. bool m_AdvancedMode;
  128. // Did the iteration converge (no new entries) ?
  129. bool m_OkToGenerate;
  130. // Number of pages displayed
  131. int m_NumberOfPages;
  132. int m_InitialWidth;
  133. cmake *m_CMakeInstance;
  134. std::string m_SearchString;
  135. std::string m_OldSearchString;
  136. bool m_SearchMode;
  137. };
  138. #endif // __cmCursesMainForm_h