cmCursesMainForm.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 cmake;
  20. /** \class cmCursesMainForm
  21. * \brief The main page of ccmake
  22. *
  23. * cmCursesMainForm is the main page of ccmake.
  24. */
  25. class cmCursesMainForm : public cmCursesForm
  26. {
  27. public:
  28. cmCursesMainForm(std::vector<std::string> const& args, int initwidth);
  29. virtual ~cmCursesMainForm();
  30. /**
  31. * Set the widgets which represent the cache entries.
  32. */
  33. void InitializeUI();
  34. /**
  35. * Handle user input.
  36. */
  37. virtual void HandleInput();
  38. /**
  39. * Display form. Use a window of size width x height, starting
  40. * at top, left.
  41. */
  42. virtual void Render(int left, int top, int width, int height);
  43. /**
  44. * Returns true if an entry with the given key is in the
  45. * list of current composites.
  46. */
  47. bool LookForCacheEntry(const char* key);
  48. enum {
  49. MIN_WIDTH = 65,
  50. MIN_HEIGHT = 6,
  51. IDEAL_WIDTH = 80,
  52. MAX_WIDTH = 512
  53. };
  54. /**
  55. * This method should normally called only by the form.
  56. * The only exception is during a resize.
  57. */
  58. virtual void UpdateStatusBar();
  59. /**
  60. * Display current commands and their keys on the toolbar.
  61. * This method should normally called only by the form.
  62. * The only exception is during a resize.
  63. */
  64. void PrintKeys();
  65. /**
  66. * During a CMake run, an error handle should add errors
  67. * to be displayed afterwards.
  68. */
  69. virtual void AddError(const char* message, const char* title);
  70. /**
  71. * Used to do a configure.
  72. */
  73. int Configure();
  74. /**
  75. * Used to generate
  76. */
  77. int Generate();
  78. /**
  79. * Used by main program
  80. */
  81. void LoadCache(const char *dir);
  82. /**
  83. * Progress callback
  84. */
  85. static void UpdateProgress(const char *msg, float prog, void*);
  86. protected:
  87. cmCursesMainForm(const cmCursesMainForm& from);
  88. void operator=(const cmCursesMainForm&);
  89. // Copy the cache values from the user interface to the actual
  90. // cache.
  91. void FillCacheManagerFromUI();
  92. // Re-post the existing fields. Used to toggle between
  93. // normal and advanced modes. Render() should be called
  94. // afterwards.
  95. void RePost();
  96. // Remove an entry from the interface and the cache.
  97. void RemoveEntry(const char* value);
  98. // Copies of cache entries stored in the user interface
  99. std::vector<cmCursesCacheEntryComposite*>* m_Entries;
  100. // Errors produced during last run of cmake
  101. std::vector<std::string> m_Errors;
  102. // Command line argumens to be passed to cmake each time
  103. // it is run
  104. std::vector<std::string> m_Args;
  105. // Message displayed when user presses 'h'
  106. // It is: Welcome + info about current entry + common help
  107. std::vector<std::string> m_HelpMessage;
  108. // Common help
  109. static const char* s_ConstHelpMessage;
  110. // Fields displayed. Includes labels, new entry markers, entries
  111. FIELD** m_Fields;
  112. // Where is source of current project
  113. std::string m_WhereSource;
  114. // Where is cmake executable
  115. std::string m_WhereCMake;
  116. // Number of entries shown (depends on mode -normal or advanced-)
  117. int m_NumberOfVisibleEntries;
  118. bool m_AdvancedMode;
  119. // Did the iteration converge (no new entries) ?
  120. bool m_OkToGenerate;
  121. // Number of pages displayed
  122. int m_NumberOfPages;
  123. int m_InitialWidth;
  124. cmake *m_CMakeInstance;
  125. };
  126. #endif // __cmCursesMainForm_h