summaryrefslogtreecommitdiffstats
path: root/Source/CursesDialog/cmCursesBoolWidget.cxx
diff options
context:
space:
mode:
authorBerk Geveci <berk.geveci@kitware.com>2001-11-04 23:05:21 (GMT)
committerBerk Geveci <berk.geveci@kitware.com>2001-11-04 23:05:21 (GMT)
commit939d614978ff6772aae619bfbc3ef89e27b69f73 (patch)
tree0b6d52df9911a29a10d25afc7650cf7a1c5ba2f1 /Source/CursesDialog/cmCursesBoolWidget.cxx
parentef74458b34dcf2d25b3948c535d59273c2307546 (diff)
downloadCMake-939d614978ff6772aae619bfbc3ef89e27b69f73.zip
CMake-939d614978ff6772aae619bfbc3ef89e27b69f73.tar.gz
CMake-939d614978ff6772aae619bfbc3ef89e27b69f73.tar.bz2
Adding curses support.
Diffstat (limited to 'Source/CursesDialog/cmCursesBoolWidget.cxx')
-rw-r--r--Source/CursesDialog/cmCursesBoolWidget.cxx61
1 files changed, 61 insertions, 0 deletions
diff --git a/Source/CursesDialog/cmCursesBoolWidget.cxx b/Source/CursesDialog/cmCursesBoolWidget.cxx
new file mode 100644
index 0000000..4057a3f
--- /dev/null
+++ b/Source/CursesDialog/cmCursesBoolWidget.cxx
@@ -0,0 +1,61 @@
+#include "cmCursesBoolWidget.h"
+
+cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
+ int left, int top) :
+ cmCursesWidget(width, height, left, top)
+{
+ m_Type = cmCacheManager::BOOL;
+ set_field_fore(m_Field, A_NORMAL);
+ set_field_back(m_Field, A_STANDOUT);
+ field_opts_off(m_Field, O_STATIC);
+ this->SetValueAsBool(false);
+}
+
+bool cmCursesBoolWidget::HandleInput(int& key, FORM* form, WINDOW* w)
+{
+ // 10 == enter
+ if (key == 10)
+ {
+ if (this->GetValueAsBool())
+ {
+ this->SetValueAsBool(false);
+ }
+ else
+ {
+ this->SetValueAsBool(true);
+ }
+
+ touchwin(w);
+ wrefresh(w);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+
+}
+
+void cmCursesBoolWidget::SetValueAsBool(bool value)
+{
+ if (value)
+ {
+ this->SetValue("ON");
+ }
+ else
+ {
+ this->SetValue("OFF");
+ }
+}
+
+bool cmCursesBoolWidget::GetValueAsBool()
+{
+ if (m_Value == "ON")
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}