cmCursesMainForm.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. protected:
  83. cmCursesMainForm(const cmCursesMainForm& from);
  84. void operator=(const cmCursesMainForm&);
  85. // Copy the cache values from the user interface to the actual
  86. // cache.
  87. void FillCacheManagerFromUI();
  88. // Re-post the existing fields. Used to toggle between
  89. // normal and advanced modes. Render() should be called
  90. // afterwards.
  91. void RePost();
  92. // Remove an entry from the interface and the cache.
  93. void RemoveEntry(const char* value);
  94. // Copies of cache entries stored in the user interface
  95. std::vector<cmCursesCacheEntryComposite*>* m_Entries;
  96. // Errors produced during last run of cmake
  97. std::vector<std::string> m_Errors;
  98. // Command line argumens to be passed to cmake each time
  99. // it is run
  100. std::vector<std::string> m_Args;
  101. // Message displayed when user presses 'h'
  102. // It is: Welcome + info about current entry + common help
  103. std::vector<std::string> m_HelpMessage;
  104. // Common help
  105. static const char* s_ConstHelpMessage;
  106. // Fields displayed. Includes labels, new entry markers, entries
  107. FIELD** m_Fields;
  108. // Where is source of current project
  109. std::string m_WhereSource;
  110. // Where is cmake executable
  111. std::string m_WhereCMake;
  112. // Number of entries shown (depends on mode -normal or advanced-)
  113. int m_NumberOfVisibleEntries;
  114. bool m_AdvancedMode;
  115. // Did the iteration converge (no new entries) ?
  116. bool m_OkToGenerate;
  117. // Number of pages displayed
  118. int m_NumberOfPages;
  119. int m_InitialWidth;
  120. cmake *m_CMakeInstance;
  121. };
  122. #endif // __cmCursesMainForm_h