summaryrefslogtreecommitdiffstats
path: root/curses/curseschoicebutton.H
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /curses/curseschoicebutton.H
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'curses/curseschoicebutton.H')
-rw-r--r--curses/curseschoicebutton.H81
1 files changed, 81 insertions, 0 deletions
diff --git a/curses/curseschoicebutton.H b/curses/curseschoicebutton.H
new file mode 100644
index 0000000..bfa223b
--- /dev/null
+++ b/curses/curseschoicebutton.H
@@ -0,0 +1,81 @@
+/*
+** Copyright 2002, Double Precision Inc.
+**
+** See COPYING for distribution information.
+*/
+
+#ifndef curseschoicebutton_H
+#define curseschoicebutton_H
+
+#include "mycurses.H"
+#include "cursesbutton.H"
+
+#include <vector>
+
+////////////////////////////////////////////////////////////////////////
+//
+// A button that cycles through a small list of options, each time it
+// is "clicked".
+//
+
+class CursesChoiceButton : public CursesButton {
+
+ std::vector<std::string> optionList;
+ size_t selectedOption;
+
+public:
+ CursesChoiceButton(CursesContainer *parent);
+ ~CursesChoiceButton();
+
+ void setOptions(const std::vector<std::string> &optionListArg,
+ size_t initialOption);
+
+ size_t getSelectedOption() const { return selectedOption; }
+
+ void clicked();
+};
+
+//////////////////////////////////////////////////////////////////////////
+//
+// Instead of subclassing CursesChoiceButton, here's a template to have it be a
+// member of another class. Typical usage:
+//
+// class X {
+//
+// CursesChoiceButtonRedirect<X> button1;
+//
+// void button1clicked();
+// } ;
+//
+// X::X()
+// {
+// button1=this;
+// button1=&X::button1clicked;
+// }
+
+template<class T> class CursesChoiceButtonRedirect
+ : public CursesChoiceButton {
+
+ T *myClass;
+ void (T::*mymethod)();
+public:
+ CursesChoiceButtonRedirect(CursesContainer *parent)
+ : CursesChoiceButton(parent)
+ {
+ }
+
+ ~CursesChoiceButtonRedirect()
+ {
+ }
+
+ void operator=(T *p) { myClass=p; }
+ void operator=(void (T::*p)()) {mymethod=p; }
+
+ void clicked()
+ {
+ CursesChoiceButton::clicked();
+ (myClass->*mymethod)();
+ }
+};
+
+#endif