Commit 2055ec6e authored by Davis King's avatar Davis King

Removed the arrow_button widget and moved its functionality into the

button widget.  I also added 4 new button styles that correspond to
the 4 types of arrow button.  Lastly, I had to move some things around
so that is why there seem to be a lot of code changes in this commit.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402585
parent 1e103791
This diff is collapsed.
This diff is collapsed.
...@@ -329,74 +329,52 @@ namespace dlib ...@@ -329,74 +329,52 @@ namespace dlib
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// class arrow_button // class button
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
class arrow_button : public button_action class button : public button_action
{ {
/*! /*!
INITIAL VALUE INITIAL VALUE
direction() == a value given to the constructor. name() == ""
tooltip_text() == "" (i.e. there is no tooltip by default)
WHAT THIS OBJECT REPRESENTS WHAT THIS OBJECT REPRESENTS
This object represents a push button with an arrow in the middle. This object represents a simple button.
When this object is disabled it means it will not respond to user clicks. When this object is disabled it means it will not respond to user clicks.
!*/ !*/
public: public:
enum arrow_direction
{
UP,
DOWN,
LEFT,
RIGHT
};
arrow_button( button(
drawable_window& w, drawable_window& w
arrow_direction dir
); );
/*! /*!
ensures ensures
- #*this is properly initialized - #*this is properly initialized
- #*this has been added to window w - #*this has been added to window w
- #direction() == dir
- #parent_window() == w - #parent_window() == w
throws throws
- std::bad_alloc - std::bad_alloc
- dlib::thread_error - dlib::thread_error
!*/ !*/
virtual ~arrow_button( virtual ~button(
); );
/*! /*!
ensures ensures
- all resources associated with *this have been released - all resources associated with *this have been released
!*/ !*/
arrow_direction direction (
) const;
/*!
ensures
- returns the direction that this arrow_button's arrow points
!*/
void set_direction (
arrow_direction new_direction
);
/*!
ensures
- #direction() == new_direction
!*/
void set_size ( void set_size (
unsigned long width_, unsigned long width_,
unsigned long height_ unsigned long height_
); );
/*! /*!
ensures ensures
- if (width and height are big enough to contain the name of this button) then
- #width() == width_ - #width() == width_
- #height() == height_ - #height() == height_
- #top() == top() - #top() == top()
...@@ -405,18 +383,118 @@ namespace dlib ...@@ -405,18 +383,118 @@ namespace dlib
same but its width and height are modified same but its width and height are modified
!*/ !*/
void set_name (const std::wstring& name);
void set_name (const dlib::ustring& name);
void set_name (
const std::string& name
);
/*!
ensures
- #name() == name
- this button has been resized such that it is big enough to contain
the new name.
throws
- std::bad_alloc
!*/
const std::wstring wname () const;
const dlib::string uname () const;
const std::string name (
) const;
/*!
ensures
- returns the name of this button
throws
- std::bad_alloc
!*/
void set_tooltip_text (const std::wstring& text);
void set_tooltip_text (const dlib::ustring& text);
void set_tooltip_text (
const std::string& text
);
/*!
ensures
- #tooltip_text() == text
- enables the tooltip for this button
!*/
const dlib::ustring tooltip_utext () const;
const std::wstring tooltip_wtext () const;
const std::string tooltip_text (
) const;
/*!
ensures
- returns the text that is displayed in the tooltip for this button
!*/
bool is_depressed ( bool is_depressed (
) const; ) const;
/*! /*!
ensures ensures
- if (this button is currently in a depressed state) then - if (this button is currently in a depressed state) then
- the user has left clicked on this drawable and is still - the user has left clicked on this widget and is still
holding the left mouse button down over it. holding the left mouse button down over it.
- returns true - returns true
- else - else
- returns false - returns false
!*/ !*/
template <
typename style_type
>
void set_style (
const style_type& style
);
/*!
requires
- style_type == a type that inherits from button_style
ensures
- this button object will draw itself using the given
button style
!*/
template <
typename T
>
void set_click_handler (
T& object,
void (T::*event_handler)()
);
/*!
requires
- event_handler is a valid pointer to a member function in T
ensures
- the event_handler function is called on object when the button is
clicked by the user.
- any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this
event at a time)
throws
- std::bad_alloc
!*/
template <
typename T
>
void set_click_handler (
T& object,
void (T::*event_handler)(button& self)
);
/*!
requires
- event_handler is a valid pointer to a member function in T
ensures
- &self == this
- the event_handler function is called on object when the button is
clicked by the user.
- any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this
event at a time)
throws
- std::bad_alloc
!*/
template < template <
typename T typename T
> >
...@@ -428,8 +506,8 @@ namespace dlib ...@@ -428,8 +506,8 @@ namespace dlib
requires requires
- event_handler is a valid pointer to a member function in T - event_handler is a valid pointer to a member function in T
ensures ensures
- The event_handler function is called whenever this object transitions - the event_handler function is called on object when the user causes
from the state where is_depressed() == false to is_depressed() == true the button to go into its depressed state.
- any previous calls to this function are overridden by this new call. - any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this (i.e. you can only have one event handler associated with this
event at a time) event at a time)
...@@ -448,10 +526,55 @@ namespace dlib ...@@ -448,10 +526,55 @@ namespace dlib
requires requires
- event_handler is a valid pointer to a member function in T - event_handler is a valid pointer to a member function in T
ensures ensures
- The event_handler function is called whenever this object transitions - the event_handler function is called on object when the user causes
from the state where is_depressed() == true to is_depressed() == false. the button to go into its non-depressed state.
furthermore: - if (the mouse is over this button when this event occurs) then
- if (the mouse was over this button when this event occurred) then - mouse_over == true
- else
- mouse_over == false
- any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this
event at a time)
throws
- std::bad_alloc
!*/
template <
typename T
>
void set_button_down_handler (
T& object,
void (T::*event_handler)(button& self)
);
/*!
requires
- event_handler is a valid pointer to a member function in T
ensures
- &self == this
- the event_handler function is called on object when the user causes
the button to go into its depressed state.
- any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this
event at a time)
throws
- std::bad_alloc
!*/
template <
typename T
>
void set_button_up_handler (
T& object,
void (T::*event_handler)(bool mouse_over, button& self)
);
/*!
requires
- event_handler is a valid pointer to a member function in T
ensures
- &self == this
- the event_handler function is called on object when the user causes
the button to go into its non-depressed state.
- if (the mouse is over this button when this event occurs) then
- mouse_over == true - mouse_over == true
- else - else
- mouse_over == false - mouse_over == false
...@@ -465,8 +588,8 @@ namespace dlib ...@@ -465,8 +588,8 @@ namespace dlib
private: private:
// restricted functions // restricted functions
arrow_button(arrow_button&); // copy constructor button(button&); // copy constructor
arrow_button& operator=(arrow_button&); // assignment operator button& operator=(button&); // assignment operator
}; };
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -275,6 +275,212 @@ namespace dlib ...@@ -275,6 +275,212 @@ namespace dlib
return rectangle(img_normal.nc()+2*padding, img_normal.nr()+2*padding); return rectangle(img_normal.nc()+2*padding, img_normal.nr()+2*padding);
} }
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
namespace arrow_button_style_helper
{
enum arrow_direction
{
UP,
DOWN,
LEFT,
RIGHT
};
void draw_arrow_button (
const canvas& c,
const rectangle& rect,
const bool enabled,
const bool is_depressed,
const arrow_direction dir
)
{
rectangle area = rect.intersect(c);
if (area.is_empty())
return;
fill_rect(c,rect,rgb_pixel(212,208,200));
const long height = rect.height();
const long width = rect.width();
const long smallest = (width < height) ? width : height;
const long rows = (smallest+3)/4;
const long start = rows + rows/2-1;
long dep;
long tip_x = 0;
long tip_y = 0;
long wy = 0;
long hy = 0;
long wx = 0;
long hx = 0;
if (is_depressed)
{
dep = 0;
// draw the button's border
draw_button_down(c,rect);
}
else
{
dep = -1;
// draw the button's border
draw_button_up(c,rect);
}
switch (dir)
{
case UP:
tip_x = width/2 + rect.left() + dep;
tip_y = (height - start)/2 + rect.top() + dep + 1;
wy = 0;
hy = 1;
wx = 1;
hx = 0;
break;
case DOWN:
tip_x = width/2 + rect.left() + dep;
tip_y = rect.bottom() - (height - start)/2 + dep;
wy = 0;
hy = -1;
wx = 1;
hx = 0;
break;
case LEFT:
tip_x = rect.left() + (width - start)/2 + dep + 1;
tip_y = height/2 + rect.top() + dep;
wy = 1;
hy = 0;
wx = 0;
hx = 1;
break;
case RIGHT:
tip_x = rect.right() - (width - start)/2 + dep;
tip_y = height/2 + rect.top() + dep;
wy = 1;
hy = 0;
wx = 0;
hx = -1;
break;
}
rgb_pixel color;
if (enabled)
{
color.red = 0;
color.green = 0;
color.blue = 0;
}
else
{
color.red = 128;
color.green = 128;
color.blue = 128;
}
for (long i = 0; i < rows; ++i)
{
draw_line(c,point(tip_x + wx*i + hx*i, tip_y + wy*i + hy*i),
point(tip_x + wx*i*-1 + hx*i, tip_y + wy*i*-1 + hy*i),
color);
}
}
}
void button_style_left_arrow::
draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const
{
using namespace arrow_button_style_helper;
draw_arrow_button(c, rect, enabled, is_depressed, LEFT);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void button_style_right_arrow::
draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const
{
using namespace arrow_button_style_helper;
draw_arrow_button(c, rect, enabled, is_depressed, RIGHT);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void button_style_up_arrow::
draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const
{
using namespace arrow_button_style_helper;
draw_arrow_button(c, rect, enabled, is_depressed, UP);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void button_style_down_arrow::
draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const
{
using namespace arrow_button_style_helper;
draw_arrow_button(c, rect, enabled, is_depressed, DOWN);
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// toggle button style stuff // toggle button style stuff
......
...@@ -215,6 +215,98 @@ namespace dlib ...@@ -215,6 +215,98 @@ namespace dlib
}; };
// ----------------------------------------------------------------------------------------
class button_style_left_arrow : public button_style
{
public:
virtual void draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const;
virtual rectangle get_min_size (
const ustring& name,
const font& mfont
) const { return rectangle(); }
};
// ----------------------------------------------------------------------------------------
class button_style_right_arrow : public button_style
{
public:
virtual void draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const;
virtual rectangle get_min_size (
const ustring& name,
const font& mfont
) const { return rectangle(); }
};
// ----------------------------------------------------------------------------------------
class button_style_up_arrow : public button_style
{
public:
virtual void draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const;
virtual rectangle get_min_size (
const ustring& name,
const font& mfont
) const { return rectangle(); }
};
// ----------------------------------------------------------------------------------------
class button_style_down_arrow : public button_style
{
public:
virtual void draw_button (
const canvas& c,
const rectangle& rect,
const bool hidden,
const bool enabled,
const font& mfont,
const long lastx,
const long lasty,
const ustring& name,
const bool is_depressed
) const;
virtual rectangle get_min_size (
const ustring& name,
const font& mfont
) const { return rectangle(); }
};
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// toggle button styles // toggle button styles
......
...@@ -122,6 +122,42 @@ namespace dlib ...@@ -122,6 +122,42 @@ namespace dlib
!*/ !*/
}; };
// ----------------------------------------------------------------------------------------
class button_style_left_arrow : public button_style
{
/*!
This draws a simple button with a left pointing arrow in it
!*/
};
// ----------------------------------------------------------------------------------------
class button_style_right_arrow : public button_style
{
/*!
This draws a simple button with a right pointing arrow in it
!*/
};
// ----------------------------------------------------------------------------------------
class button_style_up_arrow : public button_style
{
/*!
This draws a simple button with an up pointing arrow in it
!*/
};
// ----------------------------------------------------------------------------------------
class button_style_down_arrow : public button_style
{
/*!
This draws a simple button with a down pointing arrow in it
!*/
};
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// toggle button styles // toggle button styles
......
...@@ -9,242 +9,6 @@ ...@@ -9,242 +9,6 @@
namespace dlib namespace dlib
{ {
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// button object methods
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void button::
set_size (
unsigned long width,
unsigned long height
)
{
auto_mutex M(m);
rectangle min_rect = style->get_min_size(name_,*mfont);
// only change the size if it isn't going to be too small to fit the name
if (height >= min_rect.height() &&
width >= min_rect.width())
{
rectangle old(rect);
rect = resize_rect(rect,width,height);
parent.invalidate_rectangle(rect+old);
btn_tooltip.set_size(width,height);
}
}
// ----------------------------------------------------------------------------------------
void button::
show (
)
{
button_action::show();
btn_tooltip.show();
}
// ----------------------------------------------------------------------------------------
void button::
hide (
)
{
button_action::hide();
btn_tooltip.hide();
}
// ----------------------------------------------------------------------------------------
void button::
enable (
)
{
button_action::enable();
btn_tooltip.enable();
}
// ----------------------------------------------------------------------------------------
void button::
disable (
)
{
button_action::disable();
btn_tooltip.disable();
}
// ----------------------------------------------------------------------------------------
void button::
set_tooltip_text (
const std::string& text
)
{
btn_tooltip.set_text(text);
}
// ----------------------------------------------------------------------------------------
void button::
set_tooltip_text (
const std::wstring& text
)
{
btn_tooltip.set_text(text);
}
// ----------------------------------------------------------------------------------------
void button::
set_tooltip_text (
const ustring& text
)
{
btn_tooltip.set_text(text);
}
// ----------------------------------------------------------------------------------------
const std::string button::
tooltip_text (
) const
{
return btn_tooltip.text();
}
const std::wstring button::
tooltip_wtext (
) const
{
return btn_tooltip.wtext();
}
const dlib::ustring button::
tooltip_utext (
) const
{
return btn_tooltip.utext();
}
// ----------------------------------------------------------------------------------------
void button::
set_main_font (
const shared_ptr_thread_safe<font>& f
)
{
auto_mutex M(m);
mfont = f;
set_name(name_);
}
// ----------------------------------------------------------------------------------------
void button::
set_pos (
long x,
long y
)
{
auto_mutex M(m);
button_action::set_pos(x,y);
btn_tooltip.set_pos(x,y);
}
// ----------------------------------------------------------------------------------------
void button::
set_name (
const std::string& name
)
{
set_name(convert_mbstring_to_wstring(name));
}
void button::
set_name (
const std::wstring& name
)
{
set_name(convert_wstring_to_utf32(name));
}
void button::
set_name (
const ustring& name
)
{
auto_mutex M(m);
name_ = name;
// do this to get rid of any reference counting that may be present in
// the std::string implementation.
name_[0] = name_[0];
rectangle old(rect);
rect = move_rect(style->get_min_size(name,*mfont),rect.left(),rect.top());
btn_tooltip.set_size(rect.width(),rect.height());
parent.invalidate_rectangle(rect+old);
}
// ----------------------------------------------------------------------------------------
const std::string button::
name (
) const
{
auto_mutex M(m);
std::string temp = convert_wstring_to_mbstring(wname());
// do this to get rid of any reference counting that may be present in
// the std::string implementation.
char c = temp[0];
temp[0] = c;
return temp;
}
const std::wstring button::
wname (
) const
{
auto_mutex M(m);
std::wstring temp = convert_utf32_to_wstring(uname());
// do this to get rid of any reference counting that may be present in
// the std::wstring implementation.
wchar_t w = temp[0];
temp[0] = w;
return temp;
}
const dlib::ustring button::
uname (
) const
{
auto_mutex M(m);
dlib::ustring temp = name_;
// do this to get rid of any reference counting that may be present in
// the dlib::ustring implementation.
temp[0] = name_[0];
return temp;
}
// ----------------------------------------------------------------------------------------
void button::
on_button_up (
bool mouse_over
)
{
if (mouse_over)
{
// this is a valid button click
if (event_handler.is_set())
event_handler();
else if (event_handler_self.is_set())
event_handler_self(*this);
}
}
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// toggle_button object methods // toggle_button object methods
......
...@@ -108,165 +108,6 @@ namespace dlib ...@@ -108,165 +108,6 @@ namespace dlib
}; };
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// class button
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
class button : public button_action
{
public:
button(
drawable_window& w
) :
button_action(w),
btn_tooltip(w)
{
style.reset(new button_style_default());
enable_events();
}
~button() { disable_events(); parent.invalidate_rectangle(rect); }
void set_size (
unsigned long width,
unsigned long height
);
void set_name (
const std::string& name_
);
void set_name (
const std::wstring& name_
);
void set_name (
const dlib::ustring& name_
);
const std::string name (
) const;
const std::wstring wname (
) const;
const dlib::ustring uname (
) const;
void set_tooltip_text (
const std::string& text
);
void set_tooltip_text (
const std::wstring& text
);
void set_tooltip_text (
const dlib::ustring& text
);
void set_pos(
long x,
long y
);
const std::string tooltip_text (
) const;
const std::wstring tooltip_wtext (
) const;
const dlib::ustring tooltip_utext (
) const;
void set_main_font (
const shared_ptr_thread_safe<font>& f
);
void show (
);
void hide (
);
void enable (
);
void disable (
);
template <
typename style_type
>
void set_style (
const style_type& style_
)
{
auto_mutex M(m);
style.reset(new style_type(style_));
rect = move_rect(style->get_min_size(name_,*mfont), rect.left(), rect.top());
parent.invalidate_rectangle(rect);
}
template <
typename T
>
void set_click_handler (
T& object,
void (T::*event_handler_)()
)
{
auto_mutex M(m);
event_handler.set(object,event_handler_);
event_handler_self.clear();
}
template <
typename T
>
void set_click_handler (
T& object,
void (T::*event_handler_)(button&)
)
{
auto_mutex M(m);
event_handler_self.set(object,event_handler_);
event_handler.clear();
}
private:
// restricted functions
button(button&); // copy constructor
button& operator=(button&); // assignment operator
dlib::ustring name_;
tooltip btn_tooltip;
member_function_pointer<>::kernel_1a event_handler;
member_function_pointer<button&>::kernel_1a event_handler_self;
scoped_ptr<button_style> style;
protected:
void draw (
const canvas& c
) const { style->draw_button(c,rect,hidden,enabled,*mfont,lastx,lasty,name_,is_depressed()); }
void on_button_up (
bool mouse_over
);
void on_mouse_over (
){ if (style->redraw_on_mouse_over()) parent.invalidate_rectangle(rect); }
void on_mouse_not_over (
){ if (style->redraw_on_mouse_over()) parent.invalidate_rectangle(rect); }
};
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// class toggle_button // class toggle_button
......
...@@ -239,169 +239,6 @@ namespace dlib ...@@ -239,169 +239,6 @@ namespace dlib
label& operator=(label&); // assignment operator label& operator=(label&); // assignment operator
}; };
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// class button
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
class button : public button_action
{
/*!
INITIAL VALUE
name() == ""
tooltip_text() == "" (i.e. there is no tooltip by default)
WHAT THIS OBJECT REPRESENTS
This object represents a simple button.
When this object is disabled it means it will not respond to user clicks.
!*/
public:
button(
drawable_window& w
);
/*!
ensures
- #*this is properly initialized
- #*this has been added to window w
- #parent_window() == w
throws
- std::bad_alloc
- dlib::thread_error
!*/
virtual ~button(
);
/*!
ensures
- all resources associated with *this have been released
!*/
void set_size (
unsigned long width_,
unsigned long height_
);
/*!
ensures
- if (width and height are big enough to contain the name of this button) then
- #width() == width_
- #height() == height_
- #top() == top()
- #left() == left()
- i.e. The location of the upper left corner of this button stays the
same but its width and height are modified
!*/
void set_name (const std::wstring& name);
void set_name (const dlib::ustring& name);
void set_name (
const std::string& name
);
/*!
ensures
- #name() == name
- this button has been resized such that it is big enough to contain
the new name.
throws
- std::bad_alloc
!*/
const std::wstring wname () const;
const dlib::string uname () const;
const std::string name (
) const;
/*!
ensures
- returns the name of this button
throws
- std::bad_alloc
!*/
void set_tooltip_text (const std::wstring& text);
void set_tooltip_text (const dlib::ustring& text);
void set_tooltip_text (
const std::string& text
);
/*!
ensures
- #tooltip_text() == text
- enables the tooltip for this button
!*/
const dlib::ustring tooltip_utext () const;
const std::wstring tooltip_wtext () const;
const std::string tooltip_text (
) const;
/*!
ensures
- returns the text that is displayed in the tooltip for this button
!*/
template <
typename style_type
>
void set_style (
const style_type& style
);
/*!
requires
- style_type == a type that inherits from button_style
ensures
- this button object will draw itself using the given
button style
!*/
template <
typename T
>
void set_click_handler (
T& object,
void (T::*event_handler)()
);
/*!
requires
- event_handler is a valid pointer to a member function in T
ensures
- the event_handler function is called on object when the button is
clicked by the user.
- any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this
event at a time)
throws
- std::bad_alloc
!*/
template <
typename T
>
void set_click_handler (
T& object,
void (T::*event_handler)(button& self)
);
/*!
requires
- event_handler is a valid pointer to a member function in T
ensures
- &self == this
- the event_handler function is called on object when the button is
clicked by the user.
- any previous calls to this function are overridden by this new call.
(i.e. you can only have one event handler associated with this
event at a time)
throws
- std::bad_alloc
!*/
private:
// restricted functions
button(button&); // copy constructor
button& operator=(button&); // assignment operator
};
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// class toggle_button // class toggle_button
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment