diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2012-11-14 09:56:47 -0300 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2012-11-14 09:56:47 -0300 |
commit | f1ce785e5255816e0e532c0fc4fc2f9952ff4b76 (patch) | |
tree | 3da3c14c5eea1d5363d6eb237210841a6ecb179a /src/tipwin.cc | |
parent | 4a536e35e1cd1c14988f2ad3a61ae56d60ce9e2e (diff) |
Added class TipWinInput (an Input with custom tooltip window)
Diffstat (limited to 'src/tipwin.cc')
-rw-r--r-- | src/tipwin.cc | 43 |
1 files changed, 43 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); +} + |