Remove some explicit string management.
This commit is contained in:
@ -133,20 +133,18 @@ TipWinButton::TipWinButton(int x, int y, int w, int h, const char *l) :
|
|||||||
Fl_Button(x, y, w, h, l)
|
Fl_Button(x, y, w, h, l)
|
||||||
{
|
{
|
||||||
tipwin = my_tipwin();
|
tipwin = my_tipwin();
|
||||||
mytooltip = dStrdup("empty");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TipWinButton::~TipWinButton(void)
|
TipWinButton::~TipWinButton(void)
|
||||||
{
|
{
|
||||||
tipwin->cancel(this); // cancel tooltip if shown
|
tipwin->cancel(this); // cancel tooltip if shown
|
||||||
free(mytooltip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TipWinButton::handle(int e)
|
int TipWinButton::handle(int e)
|
||||||
{
|
{
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case FL_ENTER:
|
case FL_ENTER:
|
||||||
tipwin->value(mytooltip);
|
tipwin->value(mytooltip.c_str());
|
||||||
tipwin->do_show(this);
|
tipwin->do_show(this);
|
||||||
break;
|
break;
|
||||||
case FL_PUSH: // push mouse
|
case FL_PUSH: // push mouse
|
||||||
@ -159,10 +157,9 @@ int TipWinButton::handle(int e)
|
|||||||
return (Fl_Button::handle(e));
|
return (Fl_Button::handle(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TipWinButton::set_tooltip(const char *s)
|
void TipWinButton::set_tooltip(std::string s)
|
||||||
{
|
{
|
||||||
free(mytooltip);
|
mytooltip= std::move( s );
|
||||||
mytooltip = dStrdup(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -210,20 +207,18 @@ TipWinInput::TipWinInput (int x, int y, int w, int h, const char *l) :
|
|||||||
Fl_Input(x,y,w,h,l)
|
Fl_Input(x,y,w,h,l)
|
||||||
{
|
{
|
||||||
tipwin = my_tipwin();
|
tipwin = my_tipwin();
|
||||||
mytooltip = dStrdup("empty");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TipWinInput::~TipWinInput(void)
|
TipWinInput::~TipWinInput()
|
||||||
{
|
{
|
||||||
tipwin->cancel(this); // cancel tooltip if shown
|
tipwin->cancel(this); // cancel tooltip if shown
|
||||||
free(mytooltip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TipWinInput::handle(int e)
|
int TipWinInput::handle(int e)
|
||||||
{
|
{
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case FL_ENTER:
|
case FL_ENTER:
|
||||||
tipwin->value(mytooltip);
|
tipwin->value(mytooltip.c_str());
|
||||||
tipwin->do_show(this);
|
tipwin->do_show(this);
|
||||||
break;
|
break;
|
||||||
case FL_PUSH: // push mouse
|
case FL_PUSH: // push mouse
|
||||||
@ -237,9 +232,8 @@ int TipWinInput::handle(int e)
|
|||||||
return (Fl_Input::handle(e));
|
return (Fl_Input::handle(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TipWinInput::set_tooltip(const char *s)
|
void TipWinInput::set_tooltip(std::string s)
|
||||||
{
|
{
|
||||||
free(mytooltip);
|
mytooltip = std::move( s );
|
||||||
mytooltip = dStrdup(s);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#ifndef __TIPWIN_HH__
|
#ifndef __TIPWIN_HH__
|
||||||
#define __TIPWIN_HH__
|
#define __TIPWIN_HH__
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <FL/Fl_Menu_Window.H>
|
#include <FL/Fl_Menu_Window.H>
|
||||||
#include <FL/Fl_Button.H>
|
#include <FL/Fl_Button.H>
|
||||||
#include <FL/Fl_Input.H>
|
#include <FL/Fl_Input.H>
|
||||||
@ -33,14 +35,14 @@ extern TipWin *my_tipwin(void);
|
|||||||
* A Button sharing a custom tooltip window
|
* A Button sharing a custom tooltip window
|
||||||
*/
|
*/
|
||||||
class TipWinButton : public Fl_Button {
|
class TipWinButton : public Fl_Button {
|
||||||
char *mytooltip;
|
std::string mytooltip= "empty";
|
||||||
TipWin *tipwin;
|
TipWin *tipwin;
|
||||||
public:
|
public:
|
||||||
TipWinButton(int x, int y, int w, int h, const char *l = 0);
|
TipWinButton(int x, int y, int w, int h, const char *l = 0);
|
||||||
~TipWinButton();
|
~TipWinButton();
|
||||||
virtual int handle(int e);
|
virtual int handle(int e);
|
||||||
|
|
||||||
void set_tooltip(const char *s);
|
void set_tooltip(std::string s);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,14 +61,14 @@ public:
|
|||||||
* An Input with custom tooltip window
|
* An Input with custom tooltip window
|
||||||
*/
|
*/
|
||||||
class TipWinInput : public Fl_Input {
|
class TipWinInput : public Fl_Input {
|
||||||
char *mytooltip;
|
std::string mytooltip= "empty";
|
||||||
TipWin *tipwin;
|
TipWin *tipwin;
|
||||||
public:
|
public:
|
||||||
TipWinInput (int x, int y, int w, int h, const char* l=0);
|
TipWinInput (int x, int y, int w, int h, const char* l=0);
|
||||||
~TipWinInput(void);
|
~TipWinInput();
|
||||||
virtual int handle(int e);
|
virtual int handle(int e);
|
||||||
|
|
||||||
void set_tooltip(const char *s);
|
void set_tooltip(std::string s);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user