annotate libinterp/corefcn/graphics-toolkit.h @ 30565:83f9f8bda883

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:59:33 -0500
parents eff73c13fcf3 796f54d4ddbf
children e88a07dec498
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29993
diff changeset
3 // Copyright (C) 2007-2022 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_graphics_toolkit_h)
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 #define octave_graphics_toolkit_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>
27732
da163456abb3 use std::shared_ptr to manage graphics_toolkit rep
John W. Eaton <jwe@octave.org>
parents: 27446
diff changeset
32 #include <memory>
23774
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 "dMatrix.h"
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "Cell.h"
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include "error.h"
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 #include "graphics-handle.h"
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
41 namespace octave
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
42 {
29993
b5fae48ad807 move classes for graphics objects and properties inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29954
diff changeset
43 class graphics_object;
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
44 class graphics_toolkit;
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
46 class base_graphics_toolkit
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 {
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
48 public:
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
49
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
50 friend class graphics_toolkit;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
51
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
52 public:
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
53
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
54 base_graphics_toolkit (const std::string& nm)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
55 : m_name (nm)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
56 { }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
57
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
58 virtual ~base_graphics_toolkit (void) = default;
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
60 std::string get_name (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
61 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
62 return m_name;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
63 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
64
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
65 virtual bool is_valid (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
66 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
67 return false;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
68 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
69
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
70 virtual void redraw_figure (const graphics_object&) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
71 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
72 gripe_if_tkit_invalid ("redraw_figure");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
73 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
75 virtual void show_figure (const graphics_object&) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
76 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
77 gripe_if_tkit_invalid ("show_figure");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
78 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
79
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
80 virtual void print_figure (const graphics_object&, const std::string&,
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
81 const std::string&,
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
82 const std::string& = "") const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
83 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
84 gripe_if_tkit_invalid ("print_figure");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
85 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
87 virtual uint8NDArray get_pixels (const graphics_object&) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
88 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
89 gripe_if_tkit_invalid ("get_pixels");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
90 return uint8NDArray ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
91 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
93 virtual Matrix get_canvas_size (const graphics_handle&) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
94 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
95 gripe_if_tkit_invalid ("get_canvas_size");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
96 return Matrix (1, 2, 0.0);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
97 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
99 virtual double get_screen_resolution (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
100 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
101 gripe_if_tkit_invalid ("get_screen_resolution");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
102 return 72.0;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
103 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
105 virtual Matrix get_screen_size (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
106 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
107 gripe_if_tkit_invalid ("get_screen_size");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
108 return Matrix (1, 2, 0.0);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
109 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
110
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
111 virtual Matrix get_text_extent (const graphics_object&) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
112 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
113 gripe_if_tkit_invalid ("get_text_extent");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
114 return Matrix ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
115 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
117 // Callback function executed when the given graphics object
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
118 // changes. This allows the graphics toolkit to act on property
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
119 // changes if needed.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
120 virtual void update (const graphics_object&, int)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
121 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
122 gripe_if_tkit_invalid ("base_graphics_toolkit::update");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
123 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
125 void update (const graphics_handle&, int);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
126
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
127 // Callback function executed when the given graphics object is
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
128 // created. This allows the graphics toolkit to do toolkit-specific
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
129 // initializations for a newly created object.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
130 virtual bool initialize (const graphics_object&)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
131 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
132 gripe_if_tkit_invalid ("base_graphics_toolkit::initialize");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
133 return false;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
134 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
136 bool initialize (const graphics_handle&);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
137
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
138 // Callback function executed just prior to deleting the given
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
139 // graphics object. This allows the graphics toolkit to perform
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
140 // toolkit-specific cleanup operations before an object is deleted.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
141 virtual void finalize (const graphics_object&)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
142 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
143 gripe_if_tkit_invalid ("base_graphics_toolkit::finalize");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
144 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
145
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
146 void finalize (const graphics_handle&);
25799
d04b74f5d02e make shg and figure (N) activate and raise figure windows (bug #45943)
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
147
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
148 // Close the graphics toolkit.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
149 virtual void close (void)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
150 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
151 gripe_if_tkit_invalid ("base_graphics_toolkit::close");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
152 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
153
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
154 private:
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
155
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
156 std::string m_name;
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
158 private:
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
160 void gripe_if_tkit_invalid (const std::string& fname) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
161 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
162 if (! is_valid ())
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
163 error ("%s: invalid graphics toolkit", fname.c_str ());
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
164 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
165 };
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
166
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
167 class graphics_toolkit
27733
6dc797df4287 * graphics_toolkit.h: Style fixes. Use m_ prefix for member variables.
John W. Eaton <jwe@octave.org>
parents: 27732
diff changeset
168 {
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
169 public:
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
170 graphics_toolkit (const std::string& name = "unknown")
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
171 : m_rep (new base_graphics_toolkit (name))
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
172 { }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
173
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
174 // NEW_REP must be dynamically allocated.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
175 graphics_toolkit (base_graphics_toolkit *new_rep)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
176 : m_rep (std::shared_ptr<base_graphics_toolkit> (new_rep))
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
177 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
178 if (! m_rep)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
179 error ("invalid graphics_toolkit!");
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
180 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
182 graphics_toolkit (const graphics_toolkit& b) = default;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
183
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
184 graphics_toolkit& operator = (const graphics_toolkit& b) = default;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
185
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
186 ~graphics_toolkit (void) = default;
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
188 operator bool (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
189 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
190 return m_rep->is_valid ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
191 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
192
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
193 std::string get_name (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
194 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
195 return m_rep->get_name ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
196 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
198 void redraw_figure (const graphics_object& go) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
199 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
200 m_rep->redraw_figure (go);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
201 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
202
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
203 void show_figure (const graphics_object& go) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
204 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
205 m_rep->show_figure (go);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
206 }
27254
e3d886685813 Let graphics toolkit compute the extent of uicontrol text strings (bug #48446)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
207
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
208 void print_figure (const graphics_object& go, const std::string& term,
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
209 const std::string& file,
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
210 const std::string& debug_file = "") const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
211 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
212 m_rep->print_figure (go, term, file, debug_file);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
213 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
215 uint8NDArray get_pixels (const graphics_object& go) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
216 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
217 return m_rep->get_pixels (go);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
218 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
219
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
220 Matrix get_canvas_size (const graphics_handle& fh) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
221 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
222 return m_rep->get_canvas_size (fh);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
223 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
224
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
225 double get_screen_resolution (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
226 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
227 return m_rep->get_screen_resolution ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
228 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
230 Matrix get_screen_size (void) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
231 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
232 return m_rep->get_screen_size ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
233 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
234
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
235 Matrix get_text_extent (const graphics_object& go) const
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
236 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
237 return m_rep->get_text_extent (go);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
238 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
239
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
240 // Notifies graphics toolkit that object't property has changed.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
241 void update (const graphics_object& go, int id)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
242 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
243 m_rep->update (go, id);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
244 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
245
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
246 void update (const graphics_handle& h, int id)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
247 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
248 m_rep->update (h, id);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
249 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
250
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
251 // Notifies graphics toolkit that new object was created.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
252 bool initialize (const graphics_object& go)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
253 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
254 return m_rep->initialize (go);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
255 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
256
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
257 bool initialize (const graphics_handle& h)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
258 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
259 return m_rep->initialize (h);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
260 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
261
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
262 // Notifies graphics toolkit that object was destroyed.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
263 // This is called only for explicitly deleted object.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
264 // Children are deleted implicitly and graphics toolkit isn't notified.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
265 void finalize (const graphics_object& go)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
266 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
267 m_rep->finalize (go);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
268 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
269
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
270 void finalize (const graphics_handle& h)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
271 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
272 m_rep->finalize (h);
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
273 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
274
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
275 // Close the graphics toolkit.
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
276 void close (void)
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
277 {
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
278 m_rep->close ();
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
279 }
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
280
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
281 private:
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
282
27734
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
283 std::shared_ptr<base_graphics_toolkit> m_rep;
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
284 };
a9780be9ecbc move graphics_toolkit class inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27733
diff changeset
285 }
23774
41795b504a8b don't use singleton for gtk_manager
John W. Eaton <jwe@octave.org>
parents:
diff changeset
286
29954
4c88a452519c rename OCTAVE_USE_DEPRECATED_FUNCTIONS macro and attempt to make it work
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
287 #endif