cgv
gui_driver.h
1 #pragma once
2 
3 #include <cgv/base/base.h>
4 #include <cgv/signal/signal.h>
5 #include <cgv/data/ref_counted.h>
6 #include "button.h"
7 #include "gui_group.h"
8 #include "view.h"
9 #include "control.h"
10 #include "window.h"
11 #include "application.h"
12 #include "text_editor.h"
13 #include "lib_begin.h"
14 
15 namespace cgv {
16  namespace gui {
17 
19 class CGV_API gui_driver : public cgv::base::base, public cgv::base::driver
20 {
21 public:
24  virtual bool enumerate_monitors(std::vector<monitor_description>& monitor_descriptions);
27  virtual window_ptr create_window(int w, int h, const std::string& title, const std::string& window_type) = 0;
29  virtual void remove_window(window_ptr w) = 0;
31  virtual bool set_focus(const_window_ptr) = 0;
33  virtual unsigned int get_nr_windows() = 0;
35  virtual window_ptr get_window(unsigned int i) = 0;
37  virtual bool run() = 0;
39  virtual void quit(int exit_code) = 0;
41  virtual void copy_to_clipboard(const std::string& s) = 0;
43  virtual std::string paste_from_clipboard() = 0;
45 
48  virtual int question(const std::string& _question, const std::vector<std::string>& answers, int default_answer = -1) = 0;
51 
52  virtual bool query(const std::string& question, std::string& text, bool password = false) = 0;
54  virtual text_editor_ptr create_text_editor(unsigned int w, unsigned int h, const std::string& title, int x, int y) = 0;
56  virtual std::string files_open_dialog(std::vector<std::string>& file_names, const std::string& title, const std::string& filter, const std::string& path) = 0;
58  virtual std::string file_open_dialog(const std::string& title, const std::string& filter, const std::string& path) = 0;
60  virtual std::string file_save_dialog(const std::string& title, const std::string& filter, const std::string& path) = 0;
62 
65 
67  virtual void lock() = 0;
69  virtual void unlock() = 0;
71 
74  virtual void wake(const std::string& message = "") = 0;
76  virtual std::string get_wakeup_message() = 0;
78  virtual void sleep(float time_in_seconds) = 0;
80 
83  virtual bool process_gui_file(const std::string& file_name) = 0;
86  virtual gui_group_ptr add_group(gui_group_ptr parent, const std::string& label, const std::string& group_type, const std::string& options, const std::string& align) = 0;
88  virtual base_ptr add_decorator(gui_group_ptr parent, const std::string& label, const std::string& decorator_type, const std::string& options, const std::string& align) = 0;
90  virtual button_ptr add_button(gui_group_ptr parent, const std::string& label, const std::string& options, const std::string& align) = 0;
92  virtual view_ptr add_view(gui_group_ptr parent, const std::string& label, const void* value_ptr, const std::string& value_type, const std::string& gui_type, const std::string& options, const std::string& align) = 0;
94  virtual view_ptr find_view(gui_group_ptr parent, const void* value_ptr, int* idx_ptr) = 0;
96  virtual control_ptr add_control(gui_group_ptr parent, const std::string& label, void* value_ptr, abst_control_provider* acp, const std::string& value_type, const std::string& gui_type, const std::string& options, const std::string& align) = 0;
98  virtual control_ptr find_control(gui_group_ptr parent, void* value_ptr, int* idx_ptr) = 0;
100 
103  virtual base_ptr add_menu_separator(const std::string& menu_path) = 0;
106  virtual button_ptr add_menu_button(const std::string& menu_path, const std::string& options) = 0;
108  virtual data::ref_ptr<control<bool> > add_menu_bool_control(const std::string& menu_path, bool& value, const std::string& options) = 0;
110  virtual base_ptr find_menu_element(const std::string& menu_path) const = 0;
112  virtual void remove_menu_element(base_ptr) = 0;
114 };
115 
118 
119 #if _MSC_VER >= 1400
120 CGV_TEMPLATE template class CGV_API data::ref_ptr<gui_driver>;
121 #endif
122 
124 extern CGV_API gui_driver_ptr get_gui_driver();
125 
127 
129 extern CGV_API void register_gui_driver(gui_driver_ptr _driver);
130 
132 extern CGV_API cgv::signal::signal<gui_driver_ptr>& on_gui_driver_registration();
133 
134  }
135 }
136 
137 #include <cgv/config/lib_end.h>
cgv::gui::gui_driver::get_wakeup_message
virtual std::string get_wakeup_message()=0
return the message send by the thread that woke up the main thread with wake()
cgv::gui::gui_driver::copy_to_clipboard
virtual void copy_to_clipboard(const std::string &s)=0
copy text to the clipboard
cgv::gui::gui_driver::wake
virtual void wake(const std::string &message="")=0
wake main thread.
cgv::gui::gui_driver::get_nr_windows
virtual unsigned int get_nr_windows()=0
return the number of created windows
cgv::gui::gui_driver::paste_from_clipboard
virtual std::string paste_from_clipboard()=0
retreive text from clipboard
cgv::gui::abst_control_provider
type independent base class of control provider interface
Definition: control.h:37
cgv::gui::question
int question(const std::string &_question, const std::vector< std::string > &answers, int default_answer)
ask the user with question to select one of the answers, where default_answer specifies index of defa...
Definition: dialog.cxx:24
cgv::gui::get_gui_driver
gui_driver_ptr get_gui_driver()
return the currently registered gui driver or an empty pointer if non has been registered
Definition: gui_driver.cxx:18
cgv::gui::gui_driver::add_button
virtual button_ptr add_button(gui_group_ptr parent, const std::string &label, const std::string &options, const std::string &align)=0
add new button to the parent group
cgv::gui::gui_driver::set_focus
virtual bool set_focus(const_window_ptr)=0
set the input focus to the given window
cgv::gui::gui_driver::sleep
virtual void sleep(float time_in_seconds)=0
let the main thread sleep for the given number of seconds
cgv::gui::gui_driver::lock
virtual void lock()=0
lock the main thread of the gui from a child thread before any gui specific call.
cgv::gui::gui_driver::add_control
virtual control_ptr add_control(gui_group_ptr parent, const std::string &label, void *value_ptr, abst_control_provider *acp, const std::string &value_type, const std::string &gui_type, const std::string &options, const std::string &align)=0
add new control to the parent group
cgv::gui::gui_driver
abstract base class for gui drivers
Definition: gui_driver.h:20
cgv::gui::gui_driver::find_menu_element
virtual base_ptr find_menu_element(const std::string &menu_path) const =0
return the element of the given menu path
cgv::data::ref_ptr< window >
cgv::gui::gui_driver::get_window
virtual window_ptr get_window(unsigned int i)=0
return the i-th created window
cgv::gui::gui_driver::find_view
virtual view_ptr find_view(gui_group_ptr parent, const void *value_ptr, int *idx_ptr)=0
find a view in the group
cgv::gui::gui_driver::remove_window
virtual void remove_window(window_ptr w)=0
remove a window that has been destroyed
cgv::gui::gui_driver::run
virtual bool run()=0
run the main loop of the window system
cgv::gui::message
void message(const std::string &_message)
tell the user something with a message box
Definition: dialog.cxx:14
cgv::gui::register_gui_driver
void register_gui_driver(gui_driver_ptr _driver)
register a new gui driver.
Definition: gui_driver.cxx:23
cgv::gui::gui_driver::file_save_dialog
virtual std::string file_save_dialog(const std::string &title, const std::string &filter, const std::string &path)=0
ask user for a file to save
cgv::gui::gui_driver::create_text_editor
virtual text_editor_ptr create_text_editor(unsigned int w, unsigned int h, const std::string &title, int x, int y)=0
create a text editor
cgv::gui::on_gui_driver_registration
cgv::signal::signal< gui_driver_ptr > & on_gui_driver_registration()
a signal that is emitted when a gui driver is registered
Definition: gui_driver.cxx:30
cgv::gui::gui_driver::file_open_dialog
virtual std::string file_open_dialog(const std::string &title, const std::string &filter, const std::string &path)=0
ask user for a file to open
cgv::gui::gui_driver::unlock
virtual void unlock()=0
unlock the main thread
cgv::gui::gui_driver::remove_menu_element
virtual void remove_menu_element(base_ptr)=0
remove a single element from the gui
cgv::base::driver
interfaces that add several listeners and objects.
Definition: register.h:208
cgv::gui::gui_driver::quit
virtual void quit(int exit_code)=0
quit the application by closing all windows
cgv::base::base
Definition: base.h:57
cgv::gui::gui_driver::query
virtual bool query(const std::string &question, std::string &text, bool password=false)=0
query the user for a text, where the second parameter is the default text as well as the returned tex...
cgv::gui::gui_driver::files_open_dialog
virtual std::string files_open_dialog(std::vector< std::string > &file_names, const std::string &title, const std::string &filter, const std::string &path)=0
ask user for an open dialog that can select multiple files, return common path prefix and fill field ...
cgv::gui::gui_driver::add_menu_button
virtual button_ptr add_menu_button(const std::string &menu_path, const std::string &options)=0
use the current gui driver to append a new button in the menu, where menu path is a '/' separated pat...
cgv::gui::gui_driver::find_control
virtual control_ptr find_control(gui_group_ptr parent, void *value_ptr, int *idx_ptr)=0
find a control in a group
cgv::gui::gui_driver::add_decorator
virtual base_ptr add_decorator(gui_group_ptr parent, const std::string &label, const std::string &decorator_type, const std::string &options, const std::string &align)=0
add a newly created decorator to the parent group
cgv::gui::gui_driver::add_menu_bool_control
virtual data::ref_ptr< control< bool > > add_menu_bool_control(const std::string &menu_path, bool &value, const std::string &options)=0
use this to add a new control to the gui with a given value type, gui type and init options
cgv::gui::gui_driver_ptr
data::ref_ptr< gui_driver > gui_driver_ptr
ref counted pointer to driver
Definition: gui_driver.h:117
cgv::gui::gui_driver::add_view
virtual view_ptr add_view(gui_group_ptr parent, const std::string &label, const void *value_ptr, const std::string &value_type, const std::string &gui_type, const std::string &options, const std::string &align)=0
add new view to the parent group
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::gui::gui_driver::add_group
virtual gui_group_ptr add_group(gui_group_ptr parent, const std::string &label, const std::string &group_type, const std::string &options, const std::string &align)=0
add a new gui group to the given parent group
cgv::gui::gui_driver::create_window
virtual window_ptr create_window(int w, int h, const std::string &title, const std::string &window_type)=0
create a window of the given type. Currently only the types "viewer with gui", "viewer" and "gui" are...