Mercurial > octave
annotate libinterp/corefcn/gtk-manager.h @ 33617:ec2635a02328 bytecode-interpreter tip
maint: Merge default to bytecode-interpreter.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 21 May 2024 18:29:03 +0200 |
parents | 2e484f9f1f18 |
children |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31855
diff
changeset
|
3 // Copyright (C) 2007-2024 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
25 |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
26 #if ! defined (octave_gtk_manager_h) |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
27 #define octave_gtk_manager_h 1 |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
28 |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
29 #include "octave-config.h" |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
30 |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
31 #include <map> |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
32 #include <set> |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
33 #include <string> |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
34 |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
35 #include "Cell.h" |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
36 #include "graphics-toolkit.h" |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
37 |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
38 OCTAVE_BEGIN_NAMESPACE(octave) |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
39 |
31730
610a85b0ff62
use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
40 class interpreter; |
610a85b0ff62
use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
41 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
42 class OCTINTERP_API gtk_manager |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
43 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
44 public: |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
45 |
31730
610a85b0ff62
use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
46 gtk_manager (interpreter& interp) : m_interpreter (interp) { } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
47 |
31855
1daf8bfceac3
default or disable more ctors, dtors, and assignment ops
John W. Eaton <jwe@octave.org>
parents:
31771
diff
changeset
|
48 OCTAVE_DISABLE_CONSTRUCT_COPY_MOVE (gtk_manager) |
1daf8bfceac3
default or disable more ctors, dtors, and assignment ops
John W. Eaton <jwe@octave.org>
parents:
31771
diff
changeset
|
49 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31730
diff
changeset
|
50 ~gtk_manager () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
51 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
52 unload_all_toolkits (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
53 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
54 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31730
diff
changeset
|
55 graphics_toolkit get_toolkit () const; |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
56 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
57 void register_toolkit (const std::string& name); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
58 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
59 void unregister_toolkit (const std::string& name); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
60 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
61 void load_toolkit (const graphics_toolkit& tk) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
62 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
63 m_loaded_toolkits[tk.get_name ()] = tk; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
64 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
65 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
66 void unload_toolkit (const std::string& name) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
67 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
68 m_loaded_toolkits.erase (name); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
69 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
70 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
71 graphics_toolkit find_toolkit (const std::string& name) const |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
72 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
73 auto p = m_loaded_toolkits.find (name); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
74 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
75 if (p != m_loaded_toolkits.end ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
76 return p->second; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
77 else |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
78 return graphics_toolkit (); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
79 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
80 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31730
diff
changeset
|
81 Cell available_toolkits_list () const |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
82 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
83 Cell m (1, m_available_toolkits.size ()); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
84 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
85 octave_idx_type i = 0; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
86 for (const auto& tkit : m_available_toolkits) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
87 m(i++) = tkit; |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
88 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
89 return m; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
90 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
91 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31730
diff
changeset
|
92 Cell loaded_toolkits_list () const |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
93 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
94 Cell m (1, m_loaded_toolkits.size ()); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
95 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
96 octave_idx_type i = 0; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
97 for (const auto& nm_tkit_p : m_loaded_toolkits) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
98 m(i++) = nm_tkit_p.first; |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
99 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
100 return m; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
101 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
102 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31730
diff
changeset
|
103 void unload_all_toolkits () |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
104 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
105 while (! m_loaded_toolkits.empty ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
106 { |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
107 auto p = m_loaded_toolkits.begin (); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
108 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
109 std::string name = p->first; |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
110 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
111 p->second.close (); |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
112 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
113 // The toolkit may have unloaded itself. If not, we'll do it here. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
114 if (m_loaded_toolkits.find (name) != m_loaded_toolkits.end ()) |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
115 unload_toolkit (name); |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
116 } |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
117 } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
118 |
31771
21f9b34eb893
maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents:
31730
diff
changeset
|
119 std::string default_toolkit () const { return m_dtk; } |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
120 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
121 private: |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
122 |
31730
610a85b0ff62
use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
123 interpreter& m_interpreter; |
610a85b0ff62
use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents:
31706
diff
changeset
|
124 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
125 // The name of the default toolkit. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
126 std::string m_dtk; |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
127 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
128 // The list of toolkits that we know about. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
129 std::set<std::string> m_available_toolkits; |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
130 |
31607
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
131 // The list of toolkits we have actually loaded. |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
132 std::map<std::string, graphics_toolkit> m_loaded_toolkits; |
aac27ad79be6
maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents:
31605
diff
changeset
|
133 }; |
31605
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
134 |
e88a07dec498
maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents:
30564
diff
changeset
|
135 OCTAVE_END_NAMESPACE(octave) |
23774
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
136 |
41795b504a8b
don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff
changeset
|
137 #endif |