Vultraz

Untitled

Jan 15th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. FUNCTION:
  2.  
  3. template <const char* id>
  4. void tpreferences::on_tab_select(twindow& window)
  5. {
  6. const int selected_row =
  7. std::max(0, find_widget<tlistbox>(&window, id, false).get_selected_row());
  8. set_visible_tab(window, static_cast<unsigned int>(selected_row));
  9. }
  10.  
  11. USECASE:
  12.  
  13. tabs_general.set_callback_value_change(dialog_callback
  14. <tpreferences, &on_tab_select<"gen_tab_bar"> >);
  15.  
  16. DEFINITION OF set_callback_value_change AND dialog_callback
  17.  
  18. void
  19. set_callback_value_change(const boost::function<void(twidget&)>& callback)
  20. {
  21. callback_value_changed_ = callback;
  22. }
  23.  
  24. template <class D, void (D::*fptr)(twindow&)>
  25. void dialog_callback(twidget& caller)
  26. {
  27. D* dialog = dynamic_cast<D*>(caller.dialog());
  28. assert(dialog);
  29. twindow* window = dynamic_cast<twindow*>(caller.get_window());
  30. assert(window);
  31. (dialog->*fptr)(*window);
  32. }
  33.  
  34. COMPILER ERRORS
  35.  
  36. ||=== Build: Release in liblua (compiler: GNU GCC Compiler) ===|
  37. ||=== Build: Release in wesnoth (compiler: GNU GCC Compiler) ===|
  38. C:\Users\\Documents\wesnoth-git\src\gui\dialogs\preferences_dialog.cpp||In member function 'void gui2::tpreferences::initialize_tabs(gui2::twindow&)':|
  39. C:\Users\\Documents\wesnoth-git\src\gui\dialogs\preferences_dialog.cpp|502|error: no matching function for call to 'gui2::tlistbox::set_callback_value_change(<unresolved overloaded function type>)'|
  40. ..\..\src\gui\widgets\listbox.hpp|219|note: candidate: void gui2::tlistbox::set_callback_value_change(const boost::function<void(gui2::twidget&)>&)|
  41. ..\..\src\gui\widgets\listbox.hpp|219|note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const boost::function<void(gui2::twidget&)>&'|
  42. ||=== Build finished: 1 error(s), 0 warning(s) (0 minute(s), 4 second(s)) ===|
Advertisement
Add Comment
Please, Sign In to add comment