cgv
Loading...
Searching...
No Matches
application.cxx
1#include "application.h"
2#include "gui_driver.h"
3#include <iostream>
4#include <stdlib.h>
5
6namespace cgv {
7 namespace gui {
8
9bool application::enumerate_monitors(std::vector<monitor_description>& monitor_descriptions)
10{
11 if (get_gui_driver().empty())
12 return window_ptr();
13 return get_gui_driver()->enumerate_monitors(monitor_descriptions);
14}
15
16window_ptr application::create_window(int w, int h, const std::string& title, const std::string& window_type)
17{
18 if (get_gui_driver().empty())
19 return window_ptr();
20 return get_gui_driver()->create_window(w,h,title,window_type);
21}
22
24{
25 if (get_gui_driver().empty())
26 return false;
27 get_gui_driver()->remove_window(w);
28 return true;
29}
30
32{
34 if (d.empty())
35 return false;
36 return d->set_focus(w);
37}
38
40{
42 if (d.empty())
43 return 0;
44 return d->get_nr_windows();
45}
46
48{
49 if (get_gui_driver().empty())
50 return window_ptr();
51 return get_gui_driver()->get_window(i);
52}
53
55{
57 if (d.empty()) {
58 std::cerr << "\nSorry, but no cgv::gui-driver available.\n"
59 << "To get one, compile project 'cg_fltk' and add 'plugin:cg_fltk.cgv'\n"
60 << "to the argument list when starting the fltk_viewer\n"
61 << "(in Visual Studio right click you project and get to properties,\n"
62 << " select 'configuration settings' -> 'debugging' -> command line arguments')" << std::endl;
63 return false;
64 }
65 return d->run();
66}
67
68void application::quit(int exit_code)
69{
71 if (d.empty())
72 exit(exit_code);
73 d->quit(exit_code);
74}
75
77void application::copy_to_clipboard(const std::string& s)
78{
80 if (d.empty())
81 exit(0);
82 d->copy_to_clipboard(s);
83}
84
87{
89 if (d.empty())
90 return "";
91 return d->paste_from_clipboard();
92}
93
94 }
95}
bool empty() const
check if pointer is not yet set
Definition ref_ptr.h:230
static window_ptr create_window(int w, int h, const std::string &title, const std::string &window_type="viewer")
create a window of the given type, where all gui implementations must support the type "viewer"
static void copy_to_clipboard(const std::string &s)
copy text to the clipboard
static bool run()
run the main loop of the window system
static bool enumerate_monitors(std::vector< monitor_description > &monitor_descriptions)
fill the passed vector with a list of all monitors descriptions; returns false if no gui driver is av...
static window_ptr get_window(unsigned int i)
return the i-th created window
static void quit(int exit_code=0)
quit the application by closing all windows
static std::string paste_from_clipboard()
retreive text from clipboard
static bool remove_window(window_ptr w)
remove a window from the application's list of windows
static unsigned int get_nr_windows()
return the number of created windows
static bool set_focus(const_window_ptr)
set the input focus to the given window
data::ref_ptr< window > window_ptr
ref counted pointer to &window
Definition window.h:31
gui_driver_ptr get_gui_driver()
return the currently registered gui driver or an empty pointer if non has been registered
the cgv namespace
Definition print.h:11