Merge branch 'release-3.29'
[kiteware-cmake.git] / Source / CursesDialog / cmCursesWidget.h
blob29ec28b305a7c45467f1fc3176ef0a94254afb31
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #pragma once
5 #include "cmConfigure.h" // IWYU pragma: keep
7 #include <string>
9 #include "cmCursesStandardIncludes.h"
10 #include "cmStateTypes.h"
12 class cmCursesMainForm;
14 class cmCursesWidget
16 public:
17 cmCursesWidget(int width, int height, int left, int top);
18 virtual ~cmCursesWidget();
20 cmCursesWidget(cmCursesWidget const&) = delete;
21 cmCursesWidget& operator=(cmCursesWidget const&) = delete;
23 /**
24 * Handle user input. Called by the container of this widget
25 * when this widget has focus. Returns true if the input was
26 * handled
28 virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) = 0;
30 /**
31 * Change the position of the widget. Set isNewPage to true
32 * if this widget marks the beginning of a new page.
34 virtual void Move(int x, int y, bool isNewPage);
36 /**
37 * Set/Get the value (setting the value also changes the contents
38 * of the field buffer).
40 virtual void SetValue(const std::string& value);
41 virtual const char* GetValue();
43 /**
44 * Get the type of the widget (STRING, PATH etc...)
46 cmStateEnums::CacheEntryType GetType() { return this->Type; }
48 /**
49 * If there are any, print the widget specific commands
50 * in the toolbar and return true. Otherwise, return false
51 * and the parent widget will print.
53 virtual bool PrintKeys() { return false; }
55 /**
56 * Set/Get the page this widget is in.
58 void SetPage(int page) { this->Page = page; }
59 int GetPage() { return this->Page; }
61 friend class cmCursesMainForm;
63 protected:
64 cmStateEnums::CacheEntryType Type;
65 std::string Value;
66 FIELD* Field;
67 // The page in the main form this widget is in
68 int Page;