summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/tipwin.cc43
-rw-r--r--src/tipwin.hh16
2 files changed, 59 insertions, 0 deletions
diff --git a/src/tipwin.cc b/src/tipwin.cc
index cec3dbaa..1b6d91a2 100644
--- a/src/tipwin.cc
+++ b/src/tipwin.cc
@@ -179,3 +179,46 @@ void CustButton::hl_color(Fl_Color col)
light_color = col;
}
+
+//---------------------------------------------------------------------------
+
+/*
+ * An Input with custom tooltip window
+ */
+TipWinInput::TipWinInput (int x, int y, int w, int h, const char *l) :
+ Fl_Input(x,y,w,h,l)
+{
+ tipwin = my_tipwin();
+ mytooltip = strdup("empty");
+}
+
+TipWinInput::~TipWinInput(void)
+{
+ tipwin->cancel(this); // cancel tooltip if shown
+ free(mytooltip);
+}
+
+int TipWinInput::handle(int e)
+{
+ switch (e) {
+ case FL_ENTER:
+ tipwin->value(mytooltip);
+ tipwin->do_show(this);
+ break;
+ case FL_PUSH: // push mouse
+ case FL_RELEASE: // release mouse
+ case FL_HIDE: // widget goes away
+ case FL_LEAVE: // leave focus
+ case FL_KEYBOARD: // key press
+ tipwin->do_hide();
+ break;
+ }
+ return (Fl_Input::handle(e));
+}
+
+void TipWinInput::set_tooltip(const char *s)
+{
+ free(mytooltip);
+ mytooltip = strdup(s);
+}
+
diff --git a/src/tipwin.hh b/src/tipwin.hh
index 77ffa60e..d3aeeac5 100644
--- a/src/tipwin.hh
+++ b/src/tipwin.hh
@@ -3,6 +3,7 @@
#include <FL/Fl_Menu_Window.H>
#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
/*
@@ -54,5 +55,20 @@ public:
};
+/*
+ * An Input with custom tooltip window
+ */
+class TipWinInput : public Fl_Input {
+ char *mytooltip;
+ TipWin *tipwin;
+public:
+ TipWinInput (int x, int y, int w, int h, const char* l=0);
+ ~TipWinInput(void);
+ virtual int handle(int e);
+
+ void set_tooltip(const char *s);
+};
+
+
#endif // __TIPWIN_HH__