Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/CursesDialog/cmCursesWidget.h
4998 views
1
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2
file LICENSE.rst or https://cmake.org/licensing for details. */
3
#pragma once
4
5
#include "cmConfigure.h" // IWYU pragma: keep
6
7
#include <string>
8
9
#include "cmCursesStandardIncludes.h"
10
#include "cmStateTypes.h"
11
12
class cmCursesMainForm;
13
14
class cmCursesWidget
15
{
16
public:
17
cmCursesWidget(int width, int height, int left, int top);
18
virtual ~cmCursesWidget();
19
20
cmCursesWidget(cmCursesWidget const&) = delete;
21
cmCursesWidget& operator=(cmCursesWidget const&) = delete;
22
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
27
*/
28
virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) = 0;
29
30
/**
31
* Change the position of the widget. Set isNewPage to true
32
* if this widget marks the beginning of a new page.
33
*/
34
virtual void Move(int x, int y, bool isNewPage);
35
36
/**
37
* Set/Get the value (setting the value also changes the contents
38
* of the field buffer).
39
*/
40
virtual void SetValue(std::string const& value);
41
virtual char const* GetValue();
42
43
/**
44
* Get the type of the widget (STRING, PATH etc...)
45
*/
46
cmStateEnums::CacheEntryType GetType() { return this->Type; }
47
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.
52
*/
53
virtual bool PrintKeys() { return false; }
54
55
/**
56
* Set/Get the page this widget is in.
57
*/
58
void SetPage(int page) { this->Page = page; }
59
int GetPage() { return this->Page; }
60
61
friend class cmCursesMainForm;
62
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;
69
};
70
71