annotate libinterp/corefcn/gh-manager.cc @ 31771:21f9b34eb893

maint: Eliminate "(void)" in C++ function prototypes/declarations. * mk-opts.pl, external.txi, embedded.cc, make_int.cc, standalone.cc, standalonebuiltin.cc, BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, FigureWindow.cc, FigureWindow.h, GLCanvas.cc, GLCanvas.h, GenericEventNotify.h, KeyMap.cc, ListBoxControl.cc, ListBoxControl.h, Logger.cc, Logger.h, Menu.cc, Menu.h, MenuContainer.h, Object.cc, Object.h, ObjectProxy.cc, ObjectProxy.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, TextEdit.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, gl-select.cc, gl-select.h, qopengl-functions.h, qt-graphics-toolkit.h, qdialog.cpp, qfontdialog.cpp, qprintdialog_win.cpp, liboctgui-build-info.h, liboctgui-build-info.in.cc, color-picker.cc, color-picker.h, command-widget.cc, command-widget.h, community-news.cc, community-news.h, dialog.cc, dialog.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation-dock-widget.cc, documentation-dock-widget.h, documentation.cc, documentation.h, dw-main-window.cc, dw-main-window.h, external-editor-interface.cc, external-editor-interface.h, files-dock-widget.cc, files-dock-widget.h, find-files-dialog.cc, find-files-dialog.h, find-files-model.cc, find-files-model.h, gui-preferences.cc, gui-preferences.h, gui-settings.cc, gui-settings.h, history-dock-widget.cc, history-dock-widget.h, interpreter-qobject.cc, interpreter-qobject.h, file-editor-interface.h, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, file-editor.h, find-dialog.cc, find-dialog.h, marker.cc, marker.h, octave-qscintilla.cc, octave-qscintilla.h, octave-txt-lexer.cc, octave-txt-lexer.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-dock-widget.cc, octave-dock-widget.h, octave-qobject.cc, octave-qobject.h, qt-application.cc, qt-application.h, qt-interpreter-events.cc, qt-interpreter-events.h, release-notes.cc, release-notes.h, set-path-dialog.cc, set-path-dialog.h, set-path-model.cc, set-path-model.h, settings-dialog.cc, settings-dialog.h, shortcuts-tree-widget.cc, shortcuts-tree-widget.h, tab-bar.cc, tab-bar.h, terminal-dock-widget.cc, terminal-dock-widget.h, variable-editor-model.cc, variable-editor-model.h, variable-editor.cc, variable-editor.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h, build-env.h, Cell.cc, Cell.h, __contourc__.cc, __magick_read__.cc, auto-shlib.cc, auto-shlib.h, base-text-renderer.h, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, debug.cc, defaults.cc, defaults.h, defun.cc, display.cc, display.h, dynamic-ld.cc, dynamic-ld.h, environment.cc, environment.h, error.cc, error.h, errwarn.cc, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, ft-text-renderer.cc, ft-text-renderer.h, genprops.awk, gh-manager.cc, gh-manager.h, gl-render.cc, gl-render.h, gl2ps-print.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, jsondecode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, ls-hdf5.cc, ls-hdf5.h, mxarray.h, oct-errno.h, oct-errno.in.cc, oct-fstrm.cc, oct-fstrm.h, oct-handle.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, pager.cc, pager.h, pr-flt-fmt.cc, pr-flt-fmt.h, pr-output.cc, pr-output.h, procstream.cc, procstream.h, settings.cc, settings.h, sighandlers.cc, sighandlers.h, stack-frame.cc, stack-frame.h, svd.cc, syminfo.cc, syminfo.h, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, toplev.cc, url-handle-manager.cc, url-handle-manager.h, variables.cc, xpow.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, audiodevinfo.cc, gzip.cc, liboctinterp-build-info.h, liboctinterp-build-info.in.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-diag.h, ov-base-int.cc, ov-base-int.h, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base-scalar.h, ov-base-sparse.cc, ov-base-sparse.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-builtin.cc, ov-builtin.h, ov-cell.cc, ov-cell.h, ov-ch-mat.cc, ov-ch-mat.h, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-colon.h, ov-complex.cc, ov-complex.h, ov-cs-list.h, ov-cx-diag.cc, ov-cx-diag.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.cc, ov-fcn.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-diag.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-diag.cc, ov-flt-re-diag.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-java.h, ov-lazy-idx.cc, ov-lazy-idx.h, ov-legacy-range.cc, ov-legacy-range.h, ov-magic-int.cc, ov-magic-int.h, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-null-mat.h, ov-oncleanup.cc, ov-oncleanup.h, ov-perm.cc, ov-perm.h, ov-range.cc, ov-range.h, ov-re-diag.cc, ov-re-diag.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.cc, ovl.h, octave.cc, octave.h, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.h, pt-cbinop.h, pt-cell.h, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.h, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.h, pt.cc, pt.h, token.cc, token.h, usage.h, Array-base.cc, Array.h, CColVector.cc, CColVector.h, CDiagMatrix.cc, CDiagMatrix.h, CMatrix.cc, CMatrix.h, CNDArray.cc, CNDArray.h, CRowVector.cc, CRowVector.h, CSparse.cc, CSparse.h, DiagArray2.cc, DiagArray2.h, MArray.cc, MArray.h, MDiagArray2.h, MSparse.h, MatrixType.cc, MatrixType.h, PermMatrix.cc, PermMatrix.h, Range.cc, Range.h, Sparse-b.cc, Sparse.cc, Sparse.h, boolMatrix.cc, boolMatrix.h, boolNDArray.cc, boolNDArray.h, boolSparse.cc, boolSparse.h, chMatrix.h, chNDArray.h, dColVector.cc, dColVector.h, dDiagMatrix.cc, dDiagMatrix.h, dMatrix.cc, dMatrix.h, dNDArray.cc, dNDArray.h, dRowVector.cc, dRowVector.h, dSparse.cc, dSparse.h, dim-vector.cc, dim-vector.h, fCColVector.cc, fCColVector.h, fCDiagMatrix.cc, fCDiagMatrix.h, fCMatrix.cc, fCMatrix.h, fCNDArray.cc, fCNDArray.h, fCRowVector.cc, fCRowVector.h, fColVector.cc, fColVector.h, fDiagMatrix.cc, fDiagMatrix.h, fMatrix.cc, fMatrix.h, fNDArray.cc, fNDArray.h, fRowVector.cc, fRowVector.h, idx-vector.cc, idx-vector.h, intNDArray.cc, intNDArray.h, liboctave-build-info.h, liboctave-build-info.in.cc, CollocWt.cc, CollocWt.h, DAE.h, DAEFunc.h, DAERT.h, DAERTFunc.h, DASPK.cc, DASPK.h, DASRT.cc, DASRT.h, DASSL.cc, DASSL.h, DET.h, EIG.h, LSODE.cc, LSODE.h, ODE.h, ODEFunc.h, ODES.h, ODESFunc.h, Quad.h, aepbalance.cc, aepbalance.h, base-dae.h, base-de.h, chol.cc, chol.h, eigs-base.cc, fEIG.h, gepbalance.h, gsvd.cc, gsvd.h, hess.h, lu.cc, lu.h, oct-fftw.cc, oct-fftw.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randmtzig.cc, randmtzig.h, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.h, base-list.h, caseless-str.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, data-conv.cc, file-info.h, glob-match.cc, glob-match.h, kpse.cc, kpse.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-regexp.h, oct-inttypes.cc, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sort.cc, oct-sort.h, oct-sparse.cc, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, singleton-cleanup.cc, singleton-cleanup.h, str-vec.cc, str-vec.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h, version.cc, version.in.h, cxx-signal-helpers.cc, acinclude.m4, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.h, octave-build-info.in.cc, octave-config.in.cc, octave-svgconvert.cc, shared-fcns.h: maint: Eliminate "(void)" in C++ function prototypes/declarations.
author Rik <rik@octave.org>
date Tue, 24 Jan 2023 17:19:44 -0800
parents 610a85b0ff62
children 2e484f9f1f18
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
1 ////////////////////////////////////////////////////////////////////////
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
2 //
31708
93744e3823a6 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 31663
diff changeset
3 // Copyright (C) 2007-2023 The Octave Project Developers
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
4 //
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
6 // distribution or <https://octave.org/copyright/>.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
7 //
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
8 // This file is part of Octave.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
9 //
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
11 // under the terms of the GNU General Public License as published by
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
13 // (at your option) any later version.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
14 //
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
18 // GNU General Public License for more details.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
19 //
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
20 // You should have received a copy of the GNU General Public License
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
21 // along with Octave; see the file COPYING. If not, see
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
22 // <https://www.gnu.org/licenses/>.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
23 //
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
24 ////////////////////////////////////////////////////////////////////////
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
26 #if defined (HAVE_CONFIG_H)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
27 # include "config.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include "cmd-edit.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include "builtin-defun-decls.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include "gh-manager.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include "graphics-utils.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "input.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "interpreter-private.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include "interpreter.h"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39 OCTAVE_BEGIN_NAMESPACE(octave)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 static double
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31730
diff changeset
42 make_handle_fraction ()
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
44 static double maxrand = RAND_MAX + 2.0;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
45
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46 return (rand () + 1.0) / maxrand;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
49 graphics_handle
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
50 gh_manager::get_handle (bool integer_figure_handle)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
52 graphics_handle retval;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
53
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
54 if (integer_figure_handle)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
55 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
56 // Figure handles are positive integers corresponding
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57 // to the figure number.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
58
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59 // We always want the lowest unused figure number.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
60
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
61 retval = 1;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
63 while (m_handle_map.find (retval) != m_handle_map.end ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64 retval++;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
65 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
66 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68 // Other graphics handles are negative integers plus some random
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
69 // fractional part. To avoid running out of integers, we recycle the
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70 // integer part but tack on a new random part each time.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
71
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72 auto p = m_handle_free_list.begin ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
73
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
74 if (p != m_handle_free_list.end ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
75 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76 retval = *p;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77 m_handle_free_list.erase (p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
78 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
79 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
81 retval = graphics_handle (m_next_handle);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
82
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
83 m_next_handle = std::ceil (m_next_handle) - 1.0 - make_handle_fraction ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
84 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
86
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87 return retval;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
89
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
90 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
91 gh_manager::free (const graphics_handle& h, bool from_root)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
92 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
93 if (h.ok ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
95 if (h.value () == 0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
96 error ("graphics_handle::free: can't delete root object");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
97
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
98 auto p = m_handle_map.find (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
99
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100 if (p == m_handle_map.end ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
101 error ("graphics_handle::free: invalid object %g", h.value ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
103 base_properties& bp = p->second.get_properties ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
104
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105 if (! p->second.valid_object () || bp.is_beingdeleted ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106 return;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
107
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108 graphics_handle parent_h = p->second.get_parent ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109 graphics_object parent_go = nullptr;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
110 if (! from_root || isfigure (h.value ()))
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111 parent_go = get_object (parent_h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
113 bp.set_beingdeleted (true);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
114
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115 // delete listeners before invalidating object
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
116 p->second.remove_all_listeners ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
117
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
118 bp.delete_children (true, from_root);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
119
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
120 // NOTE: Call the delete function while the object's state is still valid.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121 octave_value val = bp.get_deletefcn ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
122
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123 bp.execute_deletefcn ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
124
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
125 // Notify graphics toolkit.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
126 p->second.finalize ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
127
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
128
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
129 // NOTE: Call remove_child before erasing the go from the map if not
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
130 // removing from groot.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
131 // A callback function might have already deleted the parent
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
132 if ((! from_root || isfigure (h.value ())) && parent_go.valid_object ()
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133 && h.ok ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134 parent_go.remove_child (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
135
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136 // Note: this will be valid only for first explicitly deleted
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
137 // object. All its children will then have an
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
138 // unknown graphics toolkit.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
139
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
140 // Graphics handles for non-figure objects are negative
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
141 // integers plus some random fractional part. To avoid
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
142 // running out of integers, we recycle the integer part
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
143 // but tack on a new random part each time.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
144
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
145 m_handle_map.erase (p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
146
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147 if (h.value () < 0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
148 m_handle_free_list.insert
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149 (std::ceil (h.value ()) - make_handle_fraction ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
150 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
151 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
152
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
154 gh_manager::renumber_figure (const graphics_handle& old_gh,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
155 const graphics_handle& new_gh)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
156 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
157 auto p = m_handle_map.find (old_gh);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
158
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
159 if (p == m_handle_map.end ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
160 error ("graphics_handle::free: invalid object %g", old_gh.value ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
162 graphics_object go = p->second;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
163
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164 m_handle_map.erase (p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
165
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
166 m_handle_map[new_gh] = go;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168 if (old_gh.value () < 0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
169 m_handle_free_list.insert (std::ceil (old_gh.value ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
170 - make_handle_fraction ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
172 for (auto& hfig : m_figure_list)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
174 if (hfig == old_gh)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
175 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
176 hfig = new_gh;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177 break;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
178 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
179 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
180 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
181
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
182 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31730
diff changeset
183 gh_manager::close_all_figures ()
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
185 // FIXME: should we process or discard pending events?
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
186
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
187 m_event_queue.clear ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
188
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189 // Don't use m_figure_list_iterator because we'll be removing elements
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
190 // from the list elsewhere.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
191
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
192 Matrix hlist = figure_handle_list (true);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
193
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
194 for (octave_idx_type i = 0; i < hlist.numel (); i++)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
195 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
196 graphics_handle h = lookup (hlist(i));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
197
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
198 if (h.ok ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
199 close_figure (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
200 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
201
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
202 // They should all be closed now. If not, force them to close.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
203
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
204 hlist = figure_handle_list (true);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
205
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
206 for (octave_idx_type i = 0; i < hlist.numel (); i++)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
207 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
208 graphics_handle h = lookup (hlist(i));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
209
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
210 if (h.ok ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
211 force_close_figure (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
212 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
213
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
214 // None left now, right?
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
215
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
216 hlist = figure_handle_list (true);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
217
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
218 if (hlist.numel () != 0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
219 warning ("gh_manager::close_all_figures: some graphics elements failed to close");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
220
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
221 // Clear all callback objects from our list.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
222
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
223 m_callback_objects.clear ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
224 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
225
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
226 // We use a random value for the handle to avoid issues with plots and
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
227 // scalar values for the first argument.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
228 gh_manager::gh_manager (octave::interpreter& interp)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
229 : m_interpreter (interp), m_handle_map (), m_handle_free_list (),
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
230 m_next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)),
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
231 m_figure_list (), m_graphics_lock (), m_event_queue (),
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
232 m_callback_objects (), m_event_processing (0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
233 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
234 m_handle_map[0] = graphics_object (new root_figure ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
235
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
236 octave::gtk_manager& gtk_mgr = octave::__get_gtk_manager__ ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
237
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
238 // Make sure the default graphics toolkit is registered.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
239 gtk_mgr.default_toolkit ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
240 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
241
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
242 graphics_handle
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
243 gh_manager::make_graphics_handle (const std::string& go_name,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
244 const graphics_handle& p,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
245 bool integer_figure_handle,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
246 bool call_createfcn, bool notify_toolkit)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
247 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
248 graphics_handle h = get_handle (integer_figure_handle);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
249
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
250 base_graphics_object *bgo = make_graphics_object_from_type (go_name, h, p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
251
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
252 if (! bgo)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
253 error ("gh_manager::make_graphics_handle: invalid object type '%s'",
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
254 go_name.c_str ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
255
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
256 graphics_object go (bgo);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
257
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
258 m_handle_map[h] = go;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
259
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
260 if (go_name == "axes")
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
261 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
262 // Handle defaults for labels since overriding defaults for
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
263 // them can't work before the axes object is fully
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
264 // constructed.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
265
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
266 axes::properties& props
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
267 = dynamic_cast<axes::properties&> (go.get_properties ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
268
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
269 graphics_object tgo;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
270
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
271 tgo = get_object (props.get_xlabel ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
272 tgo.override_defaults ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
273
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
274 tgo = get_object (props.get_ylabel ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
275 tgo.override_defaults ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
277 tgo = get_object (props.get_zlabel ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
278 tgo.override_defaults ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
279
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
280 tgo = get_object (props.get_title ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
281 tgo.override_defaults ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
282 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
283
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
284 // Overriding defaults will work now because the handle is valid
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
285 // and we can find parent objects (not just handles).
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
286 go.override_defaults ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
287
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
288 if (call_createfcn)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
289 bgo->get_properties ().execute_createfcn ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
290
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
291 // Notify graphics toolkit.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292 if (notify_toolkit)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
293 go.initialize ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
294
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
295 return h;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
296 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
298 graphics_handle
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
299 gh_manager::make_figure_handle (double val, bool notify_toolkit)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
300 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
301 graphics_handle h = val;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
302
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303 base_graphics_object *bgo = new figure (h, 0);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
304 graphics_object go (bgo);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
305
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
306 m_handle_map[h] = go;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
307
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
308 // Notify graphics toolkit.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
309 if (notify_toolkit)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
310 go.initialize ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
311
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
312 go.override_defaults ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
313
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
314 return h;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
315 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
316
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
317 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
318 gh_manager::push_figure (const graphics_handle& h)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
319 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
320 pop_figure (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
321
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
322 m_figure_list.push_front (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
323 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
324
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
325 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326 gh_manager::pop_figure (const graphics_handle& h)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
327 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
328 for (auto it = m_figure_list.begin (); it != m_figure_list.end (); it++)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
329 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
330 if (*it == h)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
332 m_figure_list.erase (it);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
333 break;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
334 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
335 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
336 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
338 static void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
339 xset_gcbo (const graphics_handle& h)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
340 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
341 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
342
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
343 graphics_object go = gh_mgr.get_object (0);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
344
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
345 root_figure::properties& props
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
346 = dynamic_cast<root_figure::properties&> (go.get_properties ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
347
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
348 props.set_callbackobject (h.as_octave_value ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
349 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
350
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
351 void
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31730
diff changeset
352 gh_manager::restore_gcbo ()
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
353 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
354 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
355
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
356 m_callback_objects.pop_front ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
357
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
358 xset_gcbo (m_callback_objects.empty ()
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
359 ? graphics_handle () : m_callback_objects.front ().get_handle ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
360 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
361
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
362 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
363 gh_manager::execute_listener (const graphics_handle& h, const octave_value& l)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
364 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
365 if (octave::thread::is_thread ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
366 execute_callback (h, l, octave_value ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
367 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
368 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
369 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
370
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
371 post_event (graphics_event::create_callback_event (h, l));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
372 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
373 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
374
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
375 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
376 gh_manager::execute_callback (const graphics_handle& h,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
377 const octave_value& cb_arg,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
378 const octave_value& data)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
379 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
380 if (cb_arg.is_defined () && ! cb_arg.isempty ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
381 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
382 octave_value_list args;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
383 octave_value ov_fcn;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
384 octave_function *fcn = nullptr;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
385
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
386 args(0) = h.as_octave_value ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
387 if (data.is_defined ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
388 args(1) = data;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
389 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
390 args(1) = Matrix ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
391
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
392 octave::unwind_action_safe restore_gcbo_action
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
393 (&gh_manager::restore_gcbo, this);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
394
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
395 graphics_object go (get_object (h));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
396 if (go)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
397 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
398 // FIXME: Is the lock necessary when we're only calling a
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
399 // const "get" method?
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
400 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
401 m_callback_objects.push_front (go);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
402 xset_gcbo (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
403 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
404
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
405 // Copy CB because "function_value" method is non-const.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
406 octave_value cb = cb_arg;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
407
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
408 if (cb.is_function ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
409 fcn = cb.function_value ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
410 else if (cb.is_function_handle ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
411 ov_fcn = cb;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
412 else if (cb.is_string ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
413 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
414 int status;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
415 std::string s = cb.string_value ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
416
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
417 try
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
418 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
419 m_interpreter.eval_string (s, false, status, 0);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
420 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
421 catch (const octave::execution_exception& ee)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
422 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
423 m_interpreter.handle_exception (ee);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
424 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
425 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
426 else if (cb.iscell () && cb.length () > 0
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
427 && (cb.rows () == 1 || cb.columns () == 1)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
428 && (cb.cell_value ()(0).is_function ()
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
429 || cb.cell_value ()(0).is_function_handle ()))
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
430 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
431 Cell c = cb.cell_value ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
432
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
433 ov_fcn = c(0);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
434
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
435 for (int i = 1; i < c.numel () ; i++)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
436 args(1+i) = c(i);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
437 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
438 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
439 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
440 std::string nm = cb.class_name ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
441 error ("trying to execute non-executable object (class = %s)",
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
442 nm.c_str ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
443 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
444
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
445 if (fcn || ov_fcn.is_defined ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
446 try
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
447 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
448 if (ov_fcn.is_defined ())
31730
610a85b0ff62 use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents: 31708
diff changeset
449 m_interpreter.feval (ov_fcn, args);
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
450 else
31730
610a85b0ff62 use interpreter::feval instead of global feval function
John W. Eaton <jwe@octave.org>
parents: 31708
diff changeset
451 m_interpreter.feval (fcn, args);
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
452 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
453 catch (const octave::execution_exception& ee)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
454 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
455 m_interpreter.handle_exception (ee);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
456 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
457
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
458 // Redraw after interacting with a user-interface (ui*) object.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
459 if (Vdrawnow_requested)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
460 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
461 if (go)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
462 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
463 std::string go_name
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
464 = go.get_properties ().graphics_object_name ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
465
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
466 if (go_name.length () > 1
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
467 && go_name[0] == 'u' && go_name[1] == 'i')
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
468 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
469 Fdrawnow (m_interpreter);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
470 Vdrawnow_requested = false;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
471 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
472 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
473 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
474 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
475 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
476
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
477 static int
31771
21f9b34eb893 maint: Eliminate "(void)" in C++ function prototypes/declarations.
Rik <rik@octave.org>
parents: 31730
diff changeset
478 process_graphics_events ()
31663
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
479 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
480 gh_manager& gh_mgr = octave::__get_gh_manager__ ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
481
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
482 return gh_mgr.process_events ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
483 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
484
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
485 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
486 gh_manager::post_event (const graphics_event& e)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
487 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
488 m_event_queue.push_back (e);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
489
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
490 octave::command_editor::add_event_hook (process_graphics_events);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
491 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
492
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
493 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
494 gh_manager::post_callback (const graphics_handle& h, const std::string& name,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
495 const octave_value& data)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
496 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
497 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
498
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
499 graphics_object go = get_object (h);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
500
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
501 if (go.valid_object ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
502 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
503 caseless_str cname (name);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
504 int busyaction = base_graphics_event::QUEUE;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
505
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
506 if (cname == "deletefcn" || cname == "createfcn"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
507 || cname == "closerequestfcn"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
508 || ((go.isa ("figure") || go.isa ("uipanel")
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
509 || go.isa ("uibuttongroup"))
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
510 && (cname == "resizefcn" || cname == "sizechangedfcn")))
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
511 busyaction = base_graphics_event::INTERRUPT;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
512 else if (go.get_properties ().get_busyaction () == "cancel")
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
513 busyaction = base_graphics_event::CANCEL;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
514
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
515 // The "closerequestfcn" callback must be executed once the figure has
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
516 // been made current. Let "close" do the job.
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
517 if (cname == "closerequestfcn")
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
518 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
519 std::string cmd ("close (gcbf ());");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
520 post_event (graphics_event::create_mcode_event (h, cmd, busyaction));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
521 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
522 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
523 post_event (graphics_event::create_callback_event (h, name, data,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
524 busyaction));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
525 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
526 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
527
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
528 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
529 gh_manager::post_function (graphics_event::event_fcn fcn, void *fcn_data)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
530 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
531 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
532
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
533 post_event (graphics_event::create_function_event (fcn, fcn_data));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
534 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
535
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
536 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
537 gh_manager::post_set (const graphics_handle& h, const std::string& name,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
538 const octave_value& value, bool notify_toolkit,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
539 bool redraw_figure)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
540 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
541 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
542
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
543 post_event (graphics_event::create_set_event (h, name, value, notify_toolkit,
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
544 redraw_figure));
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
545 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
546
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
547 int
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
548 gh_manager::process_events (bool force)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
549 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
550 graphics_event e;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
551 bool old_Vdrawnow_requested = Vdrawnow_requested;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
552 bool events_executed = false;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
553
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
554 do
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
555 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
556 e = graphics_event ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
557
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
558 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
559 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
560
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
561 if (! m_event_queue.empty ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
562 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
563 if (m_callback_objects.empty () || force)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
564 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
565 e = m_event_queue.front ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
566
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
567 m_event_queue.pop_front ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
568 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
569 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
570 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
571 const graphics_object& go = m_callback_objects.front ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
572
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
573 if (go.get_properties ().is_interruptible ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
574 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
575 e = m_event_queue.front ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
576
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
577 m_event_queue.pop_front ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
578 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
579 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
580 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
581 std::list<graphics_event>::iterator p = m_event_queue.begin ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
582
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
583 while (p != m_event_queue.end ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
584 if (p->get_busyaction () == base_graphics_event::CANCEL)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
585 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
586 p = m_event_queue.erase (p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
587 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
588 else if (p->get_busyaction ()
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
589 == base_graphics_event::INTERRUPT)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
590 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
591 e = (*p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
592 m_event_queue.erase (p);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
593 break;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
594 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
595 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
596 p++;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
597 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
598 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
599 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
600 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
601
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
602 if (e.ok ())
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
603 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
604 e.execute ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
605 events_executed = true;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
606 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
607 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
608 while (e.ok ());
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
609
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
610 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
611 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
612
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
613 if (m_event_queue.empty () && m_event_processing == 0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
614 octave::command_editor::remove_event_hook (process_graphics_events);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
615 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
616
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
617 if (events_executed)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
618 octave::flush_stdout ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
619
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
620 if (Vdrawnow_requested && ! old_Vdrawnow_requested)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
621 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
622 Fdrawnow (m_interpreter);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
623
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
624 Vdrawnow_requested = false;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
625 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
626
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
627 return 0;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
628 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
629
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
630
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
631 /*
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
632 ## Test interruptible/busyaction properties
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
633 %!function cb (h, ~)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
634 %! setappdata (gcbf (), "cb_exec", [getappdata(gcbf (), "cb_exec") h]);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
635 %! drawnow ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
636 %! setappdata (gcbf (), "cb_exec", [getappdata(gcbf (), "cb_exec") h]);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
637 %!endfunction
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
638 %!
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
639 %!testif HAVE_OPENGL, HAVE_QT; have_window_system () && any (strcmp ("qt", available_graphics_toolkits ()))
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
640 %! hf = figure ("visible", "off", "resizefcn", @cb);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
641 %! graphics_toolkit (hf, "qt");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
642 %! unwind_protect
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
643 %! ## Default
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
644 %! hui1 = uicontrol ("parent", hf, "interruptible", "on", "callback", @cb);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
645 %! hui2 = uicontrol ("parent", hf, "busyaction", "queue", "callback", @cb);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
646 %! hui3 = uicontrol ("parent", hf, "busyaction", "queue", "callback", @cb);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
647 %! __go_post_callback__ (hui1, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
648 %! __go_post_callback__ (hui2, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
649 %! __go_post_callback__ (hui3, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
650 %!
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
651 %! assert (getappdata (hf, "cb_exec"), []);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
652 %! drawnow ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
653 %! assert (getappdata (hf, "cb_exec"), [hui1 hui2 hui3 hui3 hui2 hui1]);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
654 %!
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
655 %! ## Interruptible off
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
656 %! setappdata (hf, "cb_exec", []);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
657 %! set (hui1, "interruptible", "off");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
658 %! __go_post_callback__ (hui1, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
659 %! __go_post_callback__ (hui2, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
660 %! __go_post_callback__ (hui3, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
661 %! drawnow ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
662 %! assert (getappdata (hf, "cb_exec"), [hui1 hui1 hui2 hui3 hui3 hui2]);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
663 %!
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
664 %! ## "resizefcn" callback interrupts regardless of interruptible property
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
665 %! setappdata (hf, "cb_exec", []);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
666 %! __go_post_callback__ (hui1, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
667 %! __go_post_callback__ (hf, "resizefcn");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
668 %! drawnow ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
669 %! assert (getappdata (hf, "cb_exec"), [hui1 hf hf hui1]);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
670 %!
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
671 %! ## test "busyaction" "cancel"
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
672 %! setappdata (hf, "cb_exec", []);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
673 %! set (hui2, "busyaction", "cancel");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
674 %! __go_post_callback__ (hui1, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
675 %! __go_post_callback__ (hui2, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
676 %! __go_post_callback__ (hui3, "callback");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
677 %! __go_post_callback__ (hf, "resizefcn");
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
678 %! drawnow ();
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
679 %! assert (getappdata (hf, "cb_exec"), [hui1 hf hui3 hui3 hf hui1]);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
680 %! unwind_protect_cleanup
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
681 %! close (hf)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
682 %! end_unwind_protect
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
683 */
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
684
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
685 void
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
686 gh_manager::enable_event_processing (bool enable)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
687 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
688 octave::autolock guard (m_graphics_lock);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
689
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
690 if (enable)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
691 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
692 m_event_processing++;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
693
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
694 octave::command_editor::add_event_hook (process_graphics_events);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
695 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
696 else
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
697 {
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
698 m_event_processing--;
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
699
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
700 if (m_event_queue.empty () && m_event_processing == 0)
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
701 octave::command_editor::remove_event_hook (process_graphics_events);
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
702 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
703 }
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
704
a74935a6cc75 move gh_manager class out of graphics.in.h and graphics.cc to separate files
John W. Eaton <jwe@octave.org>
parents:
diff changeset
705 OCTAVE_END_NAMESPACE(octave)