Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Source/CursesDialog/cmCursesStringWidget.h
5015 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 "cmCursesWidget.h"
11
12
class cmCursesMainForm;
13
14
/** \class cmCursesStringWidget
15
* \brief A simple entry widget.
16
*
17
* cmCursesStringWdiget is a simple text entry widget.
18
*/
19
20
class cmCursesStringWidget : public cmCursesWidget
21
{
22
public:
23
cmCursesStringWidget(int width, int height, int left, int top);
24
25
/**
26
* Handle user input. Called by the container of this widget
27
* when this widget has focus. Returns true if the input was
28
* handled.
29
*/
30
bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) override;
31
32
/**
33
* Set/Get the string.
34
*/
35
void SetString(std::string const& value);
36
char const* GetString();
37
char const* GetValue() override;
38
39
/**
40
* Set/Get InEdit flag. Can be used to tell the widget to leave
41
* edit mode (in case of a resize for example).
42
*/
43
void SetInEdit(bool inedit);
44
bool GetInEdit() { return this->InEdit; }
45
46
/**
47
* This method is called when different keys are pressed. The
48
* subclass can have a special implementation handler for this.
49
*/
50
virtual void OnTab(cmCursesMainForm* fm, WINDOW* w);
51
virtual void OnReturn(cmCursesMainForm* fm, WINDOW* w);
52
virtual void OnType(int& key, cmCursesMainForm* fm, WINDOW* w);
53
54
/**
55
* If there are any, print the widget specific commands
56
* in the toolbar and return true. Otherwise, return false
57
* and the parent widget will print.
58
*/
59
bool PrintKeys() override;
60
61
protected:
62
// true if the widget is in edit mode
63
bool InEdit;
64
std::string OriginalString;
65
bool Done;
66
};
67
68