Commit 719dadc3 authored by Davis King's avatar Davis King

Added overloads of all the GUI event handlers so that now you can

use general functions as callbacks (via any_function).  This way,
if you have a C++0x compiler, you can use lambda functions with the
event handlers.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%404134
parent a4441c46
...@@ -818,6 +818,15 @@ namespace dlib ...@@ -818,6 +818,15 @@ namespace dlib
event_handler_self.clear(); event_handler_self.clear();
} }
void set_click_handler (
const any_function<void()>& event_handler_
)
{
auto_mutex M(m);
event_handler = event_handler_;
event_handler_self.clear();
}
template < template <
typename T typename T
> >
...@@ -831,6 +840,15 @@ namespace dlib ...@@ -831,6 +840,15 @@ namespace dlib
event_handler.clear(); event_handler.clear();
} }
void set_sourced_click_handler (
const any_function<void(button&)>& event_handler_
)
{
auto_mutex M(m);
event_handler_self = event_handler_;
event_handler.clear();
}
bool is_depressed ( bool is_depressed (
) const ) const
{ {
...@@ -850,6 +868,14 @@ namespace dlib ...@@ -850,6 +868,14 @@ namespace dlib
button_down_handler = make_mfp(object,event_handler); button_down_handler = make_mfp(object,event_handler);
} }
void set_button_down_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
button_down_handler = event_handler;
}
template < template <
typename T typename T
> >
...@@ -862,6 +888,14 @@ namespace dlib ...@@ -862,6 +888,14 @@ namespace dlib
button_up_handler = make_mfp(object,event_handler); button_up_handler = make_mfp(object,event_handler);
} }
void set_button_up_handler (
const any_function<void(bool)>& event_handler
)
{
auto_mutex M(m);
button_up_handler = event_handler;
}
template < template <
typename T typename T
> >
...@@ -874,6 +908,14 @@ namespace dlib ...@@ -874,6 +908,14 @@ namespace dlib
button_down_handler_self = make_mfp(object,event_handler); button_down_handler_self = make_mfp(object,event_handler);
} }
void set_sourced_button_down_handler (
const any_function<void(button&)>& event_handler
)
{
auto_mutex M(m);
button_down_handler_self = event_handler;
}
template < template <
typename T typename T
> >
...@@ -886,6 +928,14 @@ namespace dlib ...@@ -886,6 +928,14 @@ namespace dlib
button_up_handler_self = make_mfp(object,event_handler); button_up_handler_self = make_mfp(object,event_handler);
} }
void set_sourced_button_up_handler (
const any_function<void(bool,button&)>& event_handler
)
{
auto_mutex M(m);
button_up_handler_self = event_handler;
}
private: private:
// restricted functions // restricted functions
...@@ -994,6 +1044,10 @@ namespace dlib ...@@ -994,6 +1044,10 @@ namespace dlib
void (T::*eh)() void (T::*eh)()
) { auto_mutex M(m); scroll_handler = make_mfp(object,eh); } ) { auto_mutex M(m); scroll_handler = make_mfp(object,eh); }
void set_scroll_handler (
const any_function<void()>& eh
) { auto_mutex M(m); scroll_handler = eh; }
void set_pos ( void set_pos (
long x, long x,
long y long y
...@@ -1580,15 +1634,13 @@ namespace dlib ...@@ -1580,15 +1634,13 @@ namespace dlib
class menu_item_text : public menu_item class menu_item_text : public menu_item
{ {
template <typename T>
void initialize ( void initialize (
T &object, const any_function<void()>& event_handler_,
void (T::*event_handler_)(),
unichar hk unichar hk
) )
{ {
dlib::ustring &str = text; dlib::ustring &str = text;
action = make_mfp(object,event_handler_); action = event_handler_;
if (hk != 0) if (hk != 0)
{ {
...@@ -1619,7 +1671,19 @@ namespace dlib ...@@ -1619,7 +1671,19 @@ namespace dlib
f(default_font::get_font()), f(default_font::get_font()),
hotkey(hk) hotkey(hk)
{ {
initialize(object, event_handler_, hk); initialize(make_mfp(object, event_handler_), hk);
}
menu_item_text (
const std::string& str,
const any_function<void()>& event_handler_,
unichar hk = 0
) :
text(convert_wstring_to_utf32(convert_mbstring_to_wstring(str))),
f(default_font::get_font()),
hotkey(hk)
{
initialize(event_handler_, hk);
} }
template <typename T> template <typename T>
...@@ -1633,7 +1697,19 @@ namespace dlib ...@@ -1633,7 +1697,19 @@ namespace dlib
f(default_font::get_font()), f(default_font::get_font()),
hotkey(hk) hotkey(hk)
{ {
initialize(object, event_handler_, hk); initialize(make_mfp(object, event_handler_), hk);
}
menu_item_text (
const std::wstring& str,
const any_function<void()>& event_handler_,
unichar hk = 0
) :
text(convert_wstring_to_utf32(str)),
f(default_font::get_font()),
hotkey(hk)
{
initialize(event_handler_, hk);
} }
template <typename T> template <typename T>
...@@ -1647,7 +1723,19 @@ namespace dlib ...@@ -1647,7 +1723,19 @@ namespace dlib
f(default_font::get_font()), f(default_font::get_font()),
hotkey(hk) hotkey(hk)
{ {
initialize(object, event_handler_, hk); initialize(make_mfp(object, event_handler_), hk);
}
menu_item_text (
const dlib::ustring& str,
const any_function<void()>& event_handler_,
unichar hk = 0
) :
text(str),
f(default_font::get_font()),
hotkey(hk)
{
initialize(event_handler_, hk);
} }
virtual unichar get_hot_key ( virtual unichar get_hot_key (
......
...@@ -499,6 +499,20 @@ namespace dlib ...@@ -499,6 +499,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_click_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called 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
> >
...@@ -520,6 +534,21 @@ namespace dlib ...@@ -520,6 +534,21 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_sourced_click_handler (
const any_function<void(button& self)>& event_handler
);
/*!
ensures
- &self == this
- the event_handler function is called 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
> >
...@@ -540,6 +569,20 @@ namespace dlib ...@@ -540,6 +569,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_button_down_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called 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 < template <
typename T typename T
> >
...@@ -564,6 +607,24 @@ namespace dlib ...@@ -564,6 +607,24 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_button_up_handler (
const any_function<void(bool mouse_over)>& event_handler
);
/*!
ensures
- the event_handler function is called 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
- 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 < template <
typename T typename T
> >
...@@ -585,6 +646,21 @@ namespace dlib ...@@ -585,6 +646,21 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_sourced_button_down_handler (
const any_function<void(button& self)>& event_handler
);
/*!
ensures
- &self == this
- the event_handler function is called 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 < template <
typename T typename T
> >
...@@ -610,6 +686,25 @@ namespace dlib ...@@ -610,6 +686,25 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_sourced_button_up_handler (
const any_function<void(bool mouse_over, button& self)>& event_handler
);
/*!
ensures
- &self == this
- the event_handler function is called 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
- 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
!*/
private: private:
// restricted functions // restricted functions
...@@ -786,6 +881,21 @@ namespace dlib ...@@ -786,6 +881,21 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_scroll_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- The event_handler function is called whenever the user causes the slider box
to move.
- This event is NOT triggered by calling set_slider_pos()
- 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: private:
// restricted functions // restricted functions
...@@ -1263,6 +1373,19 @@ namespace dlib ...@@ -1263,6 +1373,19 @@ namespace dlib
- #get_hot_key() == hotkey - #get_hot_key() == hotkey
!*/ !*/
menu_item_text (
const std::string& str,
const any_function<void()>& on_click_handler,
unichar hotkey = 0
);
/*!
ensures
- The text of this menu item will be str
- the on_click_handler function is called when this menu_item
clicked by the user.
- #get_hot_key() == hotkey
!*/
// overloads for wide character strings // overloads for wide character strings
template < template <
typename T typename T
...@@ -1274,6 +1397,12 @@ namespace dlib ...@@ -1274,6 +1397,12 @@ namespace dlib
unichar hotkey = 0 unichar hotkey = 0
); );
menu_item_text (
const std::wstring& str,
const any_function<void()>& on_click_handler,
unichar hotkey = 0
);
template < template <
typename T typename T
> >
...@@ -1283,6 +1412,15 @@ namespace dlib ...@@ -1283,6 +1412,15 @@ namespace dlib
void (T::*on_click_handler)(), void (T::*on_click_handler)(),
unichar hotkey = 0 unichar hotkey = 0
); );
template <
typename T
>
menu_item_text (
const dlib::ustring& str,
const any_function<void()>& on_click_handler,
unichar hotkey = 0
);
}; };
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -245,6 +245,15 @@ namespace dlib ...@@ -245,6 +245,15 @@ namespace dlib
event_handler_self.clear(); event_handler_self.clear();
} }
void set_click_handler (
const any_function<void()>& event_handler_
)
{
auto_mutex M(m);
event_handler = event_handler_;
event_handler_self.clear();
}
template < template <
typename T typename T
> >
...@@ -258,6 +267,15 @@ namespace dlib ...@@ -258,6 +267,15 @@ namespace dlib
event_handler.clear(); event_handler.clear();
} }
void set_sourced_click_handler (
const any_function<void(toggle_button&)>& event_handler_
)
{
auto_mutex M(m);
event_handler_self = event_handler_;
event_handler.clear();
}
private: private:
// restricted functions // restricted functions
...@@ -500,6 +518,21 @@ namespace dlib ...@@ -500,6 +518,21 @@ namespace dlib
enter_key_handler = make_mfp(object,event_handler); enter_key_handler = make_mfp(object,event_handler);
} }
void set_text_modified_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
text_modified_handler = event_handler;
}
void set_enter_key_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
enter_key_handler = event_handler;
}
template < template <
typename T typename T
...@@ -513,6 +546,14 @@ namespace dlib ...@@ -513,6 +546,14 @@ namespace dlib
focus_lost_handler = make_mfp(object,event_handler); focus_lost_handler = make_mfp(object,event_handler);
} }
void set_focus_lost_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
focus_lost_handler = event_handler;
}
private: private:
void on_cut ( void on_cut (
...@@ -853,6 +894,14 @@ namespace dlib ...@@ -853,6 +894,14 @@ namespace dlib
text_modified_handler = make_mfp(object,event_handler); text_modified_handler = make_mfp(object,event_handler);
} }
void set_text_modified_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
text_modified_handler = event_handler;
}
template < template <
typename T typename T
> >
...@@ -865,6 +914,13 @@ namespace dlib ...@@ -865,6 +914,13 @@ namespace dlib
enter_key_handler = make_mfp(object,event_handler); enter_key_handler = make_mfp(object,event_handler);
} }
void set_enter_key_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
enter_key_handler = event_handler;
}
template < template <
typename T typename T
...@@ -878,6 +934,14 @@ namespace dlib ...@@ -878,6 +934,14 @@ namespace dlib
focus_lost_handler = make_mfp(object,event_handler); focus_lost_handler = make_mfp(object,event_handler);
} }
void set_focus_lost_handler (
const any_function<void()>& event_handler
)
{
auto_mutex M(m);
focus_lost_handler = event_handler;
}
private: private:
void on_cut ( void on_cut (
...@@ -1167,6 +1231,14 @@ namespace dlib ...@@ -1167,6 +1231,14 @@ namespace dlib
event_handler = make_mfp(object,eh); event_handler = make_mfp(object,eh);
} }
void set_click_handler (
const any_function<void(unsigned long,unsigned long)>& eh
)
{
auto_mutex M(m);
event_handler = eh;
}
void set_tab_group ( void set_tab_group (
unsigned long idx, unsigned long idx,
widget_group& group widget_group& group
...@@ -1436,16 +1508,12 @@ namespace dlib ...@@ -1436,16 +1508,12 @@ namespace dlib
~box_win ( ~box_win (
); );
template <
typename T
>
void set_click_handler ( void set_click_handler (
T& object, const any_function<void()>& event_handler_
void (T::*event_handler_)()
) )
{ {
auto_mutex M(wm); auto_mutex M(wm);
event_handler = make_mfp(object,event_handler_); event_handler = event_handler_;
} }
private: private:
...@@ -1516,7 +1584,18 @@ namespace dlib ...@@ -1516,7 +1584,18 @@ namespace dlib
{ {
using namespace message_box_helper; using namespace message_box_helper;
box_win* win = new box_win(title,message); box_win* win = new box_win(title,message);
win->set_click_handler(object,event_handler); win->set_click_handler(make_mfp(object,event_handler));
}
inline void message_box (
const std::string& title,
const std::string& message,
const any_function<void()>& event_handler
)
{
using namespace message_box_helper;
box_win* win = new box_win(title,message);
win->set_click_handler(event_handler);
} }
inline void message_box ( inline void message_box (
...@@ -1670,6 +1749,10 @@ namespace dlib ...@@ -1670,6 +1749,10 @@ namespace dlib
void (T::*eh)(unsigned long index) void (T::*eh)(unsigned long index)
) { auto_mutex M(m); event_handler = make_mfp(object,eh); } ) { auto_mutex M(m); event_handler = make_mfp(object,eh); }
void set_double_click_handler (
const any_function<void(unsigned long)>& eh
) { auto_mutex M(m); event_handler = eh; }
template < template <
typename T typename T
> >
...@@ -1678,6 +1761,10 @@ namespace dlib ...@@ -1678,6 +1761,10 @@ namespace dlib
void (T::*eh)(unsigned long index) void (T::*eh)(unsigned long index)
) { auto_mutex M(m); single_click_event_handler = make_mfp(object,eh); } ) { auto_mutex M(m); single_click_event_handler = make_mfp(object,eh); }
void set_click_handler (
const any_function<void(unsigned long)>& eh
) { auto_mutex M(m); single_click_event_handler = eh; }
bool at_start ( bool at_start (
) const; ) const;
...@@ -1765,16 +1852,12 @@ namespace dlib ...@@ -1765,16 +1852,12 @@ namespace dlib
~box_win ( ~box_win (
); );
template <
typename T
>
void set_click_handler ( void set_click_handler (
T& object, const any_function<void(const std::string&)>& event_handler_
void (T::*event_handler_)(const std::string&)
) )
{ {
auto_mutex M(wm); auto_mutex M(wm);
event_handler = make_mfp(object,event_handler_); event_handler = event_handler_;
} }
private: private:
...@@ -1852,7 +1935,16 @@ namespace dlib ...@@ -1852,7 +1935,16 @@ namespace dlib
{ {
using namespace open_file_box_helper; using namespace open_file_box_helper;
box_win* win = new box_win("Open File",true); box_win* win = new box_win("Open File",true);
win->set_click_handler(object,event_handler); win->set_click_handler(make_mfp(object,event_handler));
}
inline void open_file_box (
const any_function<void(const std::string&)>& event_handler
)
{
using namespace open_file_box_helper;
box_win* win = new box_win("Open File",true);
win->set_click_handler(event_handler);
} }
template < template <
...@@ -1865,7 +1957,16 @@ namespace dlib ...@@ -1865,7 +1957,16 @@ namespace dlib
{ {
using namespace open_file_box_helper; using namespace open_file_box_helper;
box_win* win = new box_win("Open File"); box_win* win = new box_win("Open File");
win->set_click_handler(object,event_handler); win->set_click_handler(make_mfp(object,event_handler));
}
inline void open_existing_file_box (
const any_function<void(const std::string&)>& event_handler
)
{
using namespace open_file_box_helper;
box_win* win = new box_win("Open File");
win->set_click_handler(event_handler);
} }
template < template <
...@@ -1878,7 +1979,16 @@ namespace dlib ...@@ -1878,7 +1979,16 @@ namespace dlib
{ {
using namespace open_file_box_helper; using namespace open_file_box_helper;
box_win* win = new box_win("Save File",true); box_win* win = new box_win("Save File",true);
win->set_click_handler(object,event_handler); win->set_click_handler(make_mfp(object,event_handler));
}
inline void save_file_box (
const any_function<void(const std::string&)>& event_handler
)
{
using namespace open_file_box_helper;
box_win* win = new box_win("Save File",true);
win->set_click_handler(event_handler);
} }
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -2313,6 +2423,14 @@ namespace dlib ...@@ -2313,6 +2423,14 @@ namespace dlib
node_selected_handler = make_mfp(object,event_handler_); node_selected_handler = make_mfp(object,event_handler_);
} }
void set_node_selected_handler (
const any_function<void(unsigned long)>& event_handler_
)
{
auto_mutex M(m);
node_selected_handler = event_handler_;
}
template < template <
typename T typename T
> >
...@@ -2325,6 +2443,14 @@ namespace dlib ...@@ -2325,6 +2443,14 @@ namespace dlib
node_deselected_handler = make_mfp(object,event_handler_); node_deselected_handler = make_mfp(object,event_handler_);
} }
void set_node_deselected_handler (
const any_function<void(unsigned long)>& event_handler_
)
{
auto_mutex M(m);
node_deselected_handler = event_handler_;
}
template < template <
typename T typename T
> >
...@@ -2337,6 +2463,14 @@ namespace dlib ...@@ -2337,6 +2463,14 @@ namespace dlib
node_deleted_handler = make_mfp(object,event_handler_); node_deleted_handler = make_mfp(object,event_handler_);
} }
void set_node_deleted_handler (
const any_function<void()>& event_handler_
)
{
auto_mutex M(m);
node_deleted_handler = event_handler_;
}
template < template <
typename T typename T
> >
...@@ -2349,6 +2483,14 @@ namespace dlib ...@@ -2349,6 +2483,14 @@ namespace dlib
graph_modified_handler = make_mfp(object,event_handler_); graph_modified_handler = make_mfp(object,event_handler_);
} }
void set_graph_modified_handler (
const any_function<void()>& event_handler_
)
{
auto_mutex M(m);
graph_modified_handler = event_handler_;
}
protected: protected:
void on_keydown ( void on_keydown (
...@@ -2951,6 +3093,10 @@ namespace dlib ...@@ -2951,6 +3093,10 @@ namespace dlib
void (T::*eh)(unsigned long, unsigned long) void (T::*eh)(unsigned long, unsigned long)
) { text_modified_handler = make_mfp(object,eh); } ) { text_modified_handler = make_mfp(object,eh); }
void set_text_modified_handler (
const any_function<void(unsigned long, unsigned long)>& eh
) { text_modified_handler = eh; }
private: private:
void on_user_event ( void on_user_event (
......
...@@ -64,6 +64,20 @@ namespace dlib ...@@ -64,6 +64,20 @@ namespace dlib
then nothing occurs. then nothing occurs.
!*/ !*/
void open_file_box (
const any_function<void(const std::string&)>& event_handler
);
/*!
ensures
- Displays a window titled "Open File" that will allow the user to select a
file.
- The displayed window will start out showing the directory get_current_dir()
(i.e. it starts in the current working directory)
- The event_handler function is called if the user selects
a file. If the user closes the window without selecting a file
then nothing occurs.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
...@@ -86,6 +100,20 @@ namespace dlib ...@@ -86,6 +100,20 @@ namespace dlib
then nothing occurs. then nothing occurs.
!*/ !*/
void open_existing_file_box (
const any_function<void(const std::string&)>& event_handler
);
/*!
ensures
- Displays a window titled "Open File" that will allow the user to select
a file. But only a file that already exists.
- The displayed window will start out showing the directory get_current_dir()
(i.e. it starts in the current working directory)
- The event_handler function is called if the user selects
a file. If the user closes the window without selecting a file
then nothing occurs.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
template < template <
...@@ -108,6 +136,20 @@ namespace dlib ...@@ -108,6 +136,20 @@ namespace dlib
then nothing occurs. then nothing occurs.
!*/ !*/
void save_file_box (
const any_function<void(const std::string&)>& event_handler
);
/*!
ensures
- Displays a window titled "Save File" that will allow the user to select
a file.
- The displayed window will start out showing the directory get_current_dir()
(i.e. it starts in the current working directory)
- The event_handler function is called if the user selects
a file. If the user closes the window without selecting a file
then nothing occurs.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// function message_box() // function message_box()
...@@ -157,6 +199,20 @@ namespace dlib ...@@ -157,6 +199,20 @@ namespace dlib
- this function does not block but instead returns immediately. - this function does not block but instead returns immediately.
!*/ !*/
void message_box (
const std::string& title,
const std::string& message,
const any_function<void()>& event_handler
);
/*!
ensures
- Displays a message box with the given title and message. It will have a
single button and when the user clicks it the message box will go away.
- The event_handler function is called when the user clicks
ok or otherwise closes the message box window.
- this function does not block but instead returns immediately.
!*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
// class label // class label
...@@ -405,6 +461,21 @@ namespace dlib ...@@ -405,6 +461,21 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_click_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when the toggle_button is
toggled by the user.
- this event is NOT triggered by calling set_checked() or set_unchecked().
- 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
> >
...@@ -427,6 +498,22 @@ namespace dlib ...@@ -427,6 +498,22 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_sourced_click_handler (
const any_function<void(toggle_button& self)>& event_handler
);
/*!
ensures
- the event_handler function is called when the toggle_button is
toggled by the user. self will be a reference to the toggle_button object
that the user clicked.
- this event is NOT triggered by calling set_checked() or set_unchecked().
- 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: private:
// restricted functions // restricted functions
...@@ -594,6 +681,20 @@ namespace dlib ...@@ -594,6 +681,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_text_modified_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when the text in this text_field
is modified 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
> >
...@@ -614,6 +715,20 @@ namespace dlib ...@@ -614,6 +715,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_enter_key_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when this text field has input
focus and the user hits the enter key on their keyboard.
- 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
> >
...@@ -634,6 +749,20 @@ namespace dlib ...@@ -634,6 +749,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_focus_lost_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when this object loses input
focus due to the user clicking outside the text field
- 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: private:
// restricted functions // restricted functions
...@@ -783,6 +912,20 @@ namespace dlib ...@@ -783,6 +912,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_text_modified_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when the text in this text_box
is modified 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
> >
...@@ -803,6 +946,20 @@ namespace dlib ...@@ -803,6 +946,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_enter_key_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when this text box has input
focus and the user hits the enter key on their keyboard.
- 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
> >
...@@ -823,6 +980,20 @@ namespace dlib ...@@ -823,6 +980,20 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_focus_lost_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when this object loses input
focus due to the user clicking outside the text box
- 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: private:
// restricted functions // restricted functions
...@@ -1023,6 +1194,22 @@ namespace dlib ...@@ -1023,6 +1194,22 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_click_handler (
const any_function<void(unsigned long new_idx, unsigned long old_idx)>& eh
);
/*!
ensures
- The event_handler function is called when the user clicks on a tab
that isn't already selected. new_idx will give the index of the
newly selected tab and old_idx will give the index of the tab that
was previously selected.
- 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: private:
// restricted functions // restricted functions
...@@ -1369,6 +1556,21 @@ namespace dlib ...@@ -1369,6 +1556,21 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_double_click_handler (
const any_function<void(unsigned long index)>& event_handler
);
/*!
ensures
- The event_handler function is called when the user double clicks on
one of the rows in this list box. index gives the row number for
the item the user clicked.
- 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
> >
...@@ -1392,6 +1594,22 @@ namespace dlib ...@@ -1392,6 +1594,22 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_click_handler (
const any_function<void(unsigned long index)>& event_handler
);
/*!
ensures
- The event_handler function is called when the user clicks on one
of the rows in this list box. index gives the row number for the
item the user clicked. (Note that the second click in a double
click triggers the double click handler above instead of this event)
- 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: private:
// restricted functions // restricted functions
...@@ -1689,7 +1907,7 @@ namespace dlib ...@@ -1689,7 +1907,7 @@ namespace dlib
> >
void set_node_selected_handler ( void set_node_selected_handler (
T& object, T& object,
void (T::*event_handler_)(unsigned long node_index) void (T::*event_handler)(unsigned long node_index)
); );
/*! /*!
requires requires
...@@ -1705,12 +1923,27 @@ namespace dlib ...@@ -1705,12 +1923,27 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_node_selected_handler (
const any_function<void(unsigned long node_index)>& event_handler
);
/*!
ensures
- the event_handler function is called when the user selects
a node.
- node_index == the index of the node that was selected
- 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
> >
void set_node_deselected_handler ( void set_node_deselected_handler (
T& object, T& object,
void (T::*event_handler_)(unsigned long node_index) void (T::*event_handler)(unsigned long node_index)
); );
/*! /*!
requires requires
...@@ -1726,12 +1959,26 @@ namespace dlib ...@@ -1726,12 +1959,26 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_node_deselected_handler (
const any_function<void(unsigned long node_index)>& event_handler
);
/*!
ensures
- the event_handler function is called when the user deselects a node.
- node_index == the index of the node that was deselected
- 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
> >
void set_node_deleted_handler ( void set_node_deleted_handler (
T& object, T& object,
void (T::*event_handler_)() void (T::*event_handler)()
); );
/*! /*!
requires requires
...@@ -1746,6 +1993,19 @@ namespace dlib ...@@ -1746,6 +1993,19 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_node_deleted_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when the user deletes a node.
- 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
> >
...@@ -1770,6 +2030,24 @@ namespace dlib ...@@ -1770,6 +2030,24 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_graph_modified_handler (
const any_function<void()>& event_handler
);
/*!
ensures
- the event_handler function is called when the user modifies
the graph (i.e. adds or removes a node or edge)
- the event_handler function is not called when the user just
moves nodes around on the screen.
- This event is always dispatched before any more specific event
that results from the user modifying the graph.
- 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: private:
// restricted functions // restricted functions
...@@ -2011,6 +2289,21 @@ namespace dlib ...@@ -2011,6 +2289,21 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
void set_text_modified_handler (
const any_function<void(unsigned long row, unsigned long col)>& event_handler
);
/*!
ensures
- the event_handler function is called when the user selects a node.
- row == row will give the row of the grid item that was modified
- col == col will give the column of the grid item that was modified
- 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: private:
// restricted functions // restricted functions
......
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