annotate libinterp/dldfcn/__init_fltk__.cc @ 21196:bd96c2efd4fe

move include statements for OpenGL headers to a single file * oct-opengl.h: New file. * libinterp/corefcn/module.mk: Update. * Canvas.cc, gl-select.cc, gl-select.h, gl-render.cc, gl-render.h, gl2ps-renderer.cc, __init_fltk__.cc, __osmesa_print__.cc: Update include statements.
author John W. Eaton <jwe@octave.org>
date Thu, 04 Feb 2016 16:56:02 -0500
parents 538b57866b90
children dd6605e1eaea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1 /*
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
3
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
4 Copyright (C) 2007-2015 Shai Ayal
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19663
diff changeset
5 Copyright (C) 2014-2015 Andreas Weber
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
6
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
7 This file is part of Octave.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
8
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
12 option) any later version.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
13
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
17 for more details.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
18
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
20 along with Octave; see the file COPYING. If not, see
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
21 <http://www.gnu.org/licenses/>.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
22
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
23 */
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
24
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
25 /*
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
26
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
27 To initialize:
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
28
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
29 graphics_toolkit ("fltk");
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
30 plot (randn (1e3, 1));
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
31
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
32 */
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
33
17842
7533f4482006 use gnuplot as default graphics toolkit if display is unavailable (bug #40423)
John W. Eaton <jwe@octave.org>
parents: 17797
diff changeset
34 // PKG_ADD: if (__have_fltk__ () && have_window_system ()) register_graphics_toolkit ("fltk"); endif
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
35
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
36 #ifdef HAVE_CONFIG_H
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
37 #include <config.h>
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
38 #endif
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
39
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
40 #include "builtin-defun-decls.h"
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
41 #include "defun-dld.h"
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
42 #include "error.h"
21126
ba0a4b4f021d include errwarn.h in files that use err_disabled_feature conditionally
John W. Eaton <jwe@octave.org>
parents: 21109
diff changeset
43 #include "errwarn.h"
21196
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
44 #include "oct-opengl.h"
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
45 #include "ov-fcn-handle.h"
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
46
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
47 #ifdef HAVE_FLTK
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
48
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
49 #if defined (HAVE_X_WINDOWS)
21196
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
50 # include <X11/Xlib.h>
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
51 #endif
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
52
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
53 #include <map>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
54 #include <set>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
55 #include <sstream>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
56 #include <iostream>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
57
21196
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
58 #if defined (WIN32)
bd96c2efd4fe move include statements for OpenGL headers to a single file
John W. Eaton <jwe@octave.org>
parents: 21139
diff changeset
59 # define WIN32_LEAN_AND_MEAN
13721
ca90a6d59ab6 Prevent auto-inclusion of winsock.h in WIN32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
60 #endif
ca90a6d59ab6 Prevent auto-inclusion of winsock.h in WIN32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
61
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
62 #include <FL/Fl.H>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
63 #include <FL/Fl_Box.H>
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
64 #include <FL/Fl_Button.H>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
65 #include <FL/Fl_Choice.H>
12565
0f71b9639207 Correct typo in #include path for FLTK header files (bug #32972).
Rik <octave@nomad.inbox5.com>
parents: 12539
diff changeset
66 #include <FL/Fl_File_Chooser.H>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
67 #include <FL/Fl_Gl_Window.H>
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
68 #include <FL/names.h>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
69 #include <FL/Fl_Menu_Bar.H>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
70 #include <FL/Fl_Menu_Button.H>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
71 #include <FL/Fl_Output.H>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
72 #include <FL/Fl_Window.H>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
73 #include <FL/fl_ask.H>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
74 #include <FL/fl_draw.H>
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
75 #include <FL/gl.h>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
76
12205
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
77 // FLTK headers may include X11/X.h which defines Complex, and that
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
78 // conflicts with Octave's Complex typedef. We don't need the X11
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
79 // Complex definition in this file, so remove it before including Octave
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
80 // headers which may require Octave's Complex typedef.
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
81 #undef Complex
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
82
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
83 #include "cmd-edit.h"
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
84 #include "lo-ieee.h"
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
85 #include "oct-env.h"
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
86
17881
7aadb87f599a Display warning and don't init FLTK toolkit if no DISPLAY available (bug #40423).
Rik <rik@octave.org>
parents: 17861
diff changeset
87 #include "display.h"
11590
4ced6b90fffb style fixes for warning and error messages in source files
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
88 #include "file-ops.h"
19657
0cdda69dc2b4 Fix compilation error when building with FLTK but without gl2ps
Mike Miller <mtmiller@ieee.org>
parents: 19639
diff changeset
89 #include "gl-render.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
90 #include "gl2ps-renderer.h"
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
91 #include "graphics.h"
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
92 #include "parse.h"
9991
1300d9ced492 F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents: 9974
diff changeset
93 #include "toplev.h"
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
94 #include "variables.h"
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
95
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
96 #define FLTK_GRAPHICS_TOOLKIT_NAME "fltk"
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
97
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
98 const char* help_text = "\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
99 Keyboard Shortcuts\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
100 a - autoscale\n\
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
101 p - pan/zoom\n\
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
102 r - rotate\n\
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
103 g - toggle grid\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
104 \n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
105 Mouse\n\
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
106 left drag - pan\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
107 mouse wheel - zoom\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
108 right drag - rectangle zoom\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
109 left double click - autoscale\n\
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
110 ";
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
111
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
112 class OpenGL_fltk : public Fl_Gl_Window
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
113 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
114 public:
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
115 OpenGL_fltk (int xx, int yy, int ww, int hh, double num)
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
116 : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), renderer (),
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
117 in_zoom (false), zoom_box ()
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
118 {
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
119 // Ask for double buffering and a depth buffer.
18293
c6e5466d74fe Ensure anti-aliasing in fltk plots (patch #8259)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 17945
diff changeset
120 mode (FL_DEPTH | FL_DOUBLE | FL_MULTISAMPLE);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
121 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
122
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
123 ~OpenGL_fltk (void) { }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
124
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
125 void zoom (bool z)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
126 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
127 in_zoom = z;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
128 if (! in_zoom)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
129 hide_overlay ();
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
130 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
131
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
132 bool zoom (void) { return in_zoom; }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
133 void set_zoom_box (const Matrix& zb) { zoom_box = zb; }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
134
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
135 void print (const std::string& cmd, const std::string& term)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
136 {
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
137 //std::cout << "OpenGL_fltk::print(cmd=" << cmd << ", term=" << term << ") canvas size = " << w () << "x" << h () << std::endl;
19639
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19456
diff changeset
138
61cc00ebac60 move opengl printing code from __init_fltk__.cc to gl2ps-renderer.cc
John W. Eaton <jwe@octave.org>
parents: 19456
diff changeset
139 gl2ps_print (gh_manager::get_object (number), cmd, term);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
140 }
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
141
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
142 void resize (int xx, int yy, int ww, int hh)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
143 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
144 Fl_Gl_Window::resize (xx, yy, ww, hh);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
145 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
146
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
147 bool renumber (double new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
148 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
149 bool retval = false;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
150
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
151 if (number != new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
152 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
153 number = new_number;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
154 retval = true;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
155 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
156
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
157 return retval;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
158 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
159
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
160 private:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
161 double number;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
162 opengl_renderer renderer;
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
163 bool in_zoom;
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
164 // (x1,y1,x2,y2)
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
165 Matrix zoom_box;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
166
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
167 void draw (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
168 {
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
169 if (! valid ())
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
170 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
171 glMatrixMode (GL_PROJECTION);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
172 glLoadIdentity ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
173 glViewport (0, 0, w (), h ());
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
174 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
175
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
176 renderer.draw (gh_manager::get_object (number));
12323
c8da31f12c1d avoid using new to create temporary gl2ps_renderer object
John W. Eaton <jwe@octave.org>
parents: 12226
diff changeset
177
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
178 if (zoom ())
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
179 overlay ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
180 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
181
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
182 void zoom_box_vertex (void)
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
183 {
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
184 glVertex2d (zoom_box(0), h () - zoom_box(1));
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
185 glVertex2d (zoom_box(0), h () - zoom_box(3));
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
186 glVertex2d (zoom_box(2), h () - zoom_box(3));
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
187 glVertex2d (zoom_box(2), h () - zoom_box(1));
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
188 glVertex2d (zoom_box(0), h () - zoom_box(1));
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
189 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
190
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
191 void overlay (void)
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
192 {
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
193 glPushMatrix ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
194
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
195 glMatrixMode (GL_MODELVIEW);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
196 glLoadIdentity ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
197
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
198 glMatrixMode (GL_PROJECTION);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
199 glLoadIdentity ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
200 gluOrtho2D (0.0, w (), 0.0, h ());
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
201
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
202 glPushAttrib (GL_DEPTH_BUFFER_BIT | GL_CURRENT_BIT);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
203 glDisable (GL_DEPTH_TEST);
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
204
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
205 glBegin (GL_POLYGON);
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
206 glColor4f (0.45, 0.62, 0.81, 0.1);
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
207 zoom_box_vertex ();
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
208 glEnd ();
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
209
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
210 glBegin (GL_LINE_STRIP);
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
211 glLineWidth (1.5);
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
212 glColor4f (0.45, 0.62, 0.81, 0.9);
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
213 zoom_box_vertex ();
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
214 glEnd ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
215
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
216 glPopAttrib ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
217 glPopMatrix ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
218 }
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
219
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
220 int handle (int event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
221 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
222 switch (event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
223 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
224 case FL_ENTER:
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
225 cursor (FL_CURSOR_CROSS);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
226 return 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
227
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
228 case FL_LEAVE:
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
229 cursor (FL_CURSOR_DEFAULT);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
230 return 1;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
231 }
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
232 return Fl_Gl_Window::handle (event);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
233 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
234 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
235
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
236 void script_cb (Fl_Widget*, void* data)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
237 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
238 static_cast<uimenu::properties*> (data)->execute_callback ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
239 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
240
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
241
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
242 class fltk_uimenu
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
243 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
244 public:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
245 fltk_uimenu (int xx, int yy, int ww, int hh)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
246 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
247 menubar = new Fl_Menu_Bar (xx, yy, ww, hh);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
248 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
249
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
250 int items_to_show (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
251 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
252 //returns the number of visible menu items
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
253 int len = menubar->size ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
254 int n = 0;
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18618
diff changeset
255 for (int t = 0; t < len; t++)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
256 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
257 const Fl_Menu_Item *m = static_cast<const Fl_Menu_Item*> (&
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
258 (menubar->menu ()[t]));
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
259 if (m->label () && m->visible ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
260 n++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
261 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
262
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
263 return n;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
264 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
265
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
266 void show (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
267 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
268 menubar->show ();
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
269 menubar->redraw ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
270 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
271
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
272 void hide (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
273 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
274 menubar->hide ();
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
275 menubar->redraw ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
276 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
277
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
278 bool is_visible (void)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
279 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
280 return menubar->visible ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
281 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
282
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
283 int find_index_by_name (const std::string& findname)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
284 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
285 // This function is derived from Greg Ercolano's function
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
286 // int GetIndexByName(...), see:
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
287 // http://seriss.com/people/erco/fltk/#Menu_ChangeLabel
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
288 // He agreed via PM that it can be included in octave using GPLv3
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
289 // Kai Habel (14.10.2010)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
290
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
291 std::string menupath;
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18618
diff changeset
292 for (int t = 0; t < menubar->size (); t++)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
293 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
294 Fl_Menu_Item *m = const_cast<Fl_Menu_Item*> (&(menubar->menu ()[t]));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
295 if (m->submenu ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
296 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
297 // item has submenu
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
298 if (! menupath.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
299 menupath += "/";
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
300 menupath += m->label ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
301
21021
a5b99b09f8fd maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents: 21006
diff changeset
302 if (menupath == findname)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
303 return (t);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
304 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
305 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
306 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
307 // End of submenu? Pop back one level.
17900
8e9532632838 * __init_fltk__.cc: Fix typo in previous change.
John W. Eaton <jwe@octave.org>
parents: 17898
diff changeset
308 if (! m->label ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
309 {
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19867
diff changeset
310 size_t idx = menupath.find_last_of ("/");
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
311 if (idx != std::string::npos)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
312 menupath.erase (idx);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
313 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
314 menupath.clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
315 continue;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
316 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
317 // Menu item?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
318 std::string itempath = menupath;
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
319 if (! itempath.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
320 itempath += "/";
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
321 itempath += m->label ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
322
21021
a5b99b09f8fd maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents: 21006
diff changeset
323 if (itempath == findname)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
324 return (t);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
325 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
326 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
327 return (-1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
328 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
329
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
330 Matrix find_uimenu_children (uimenu::properties& uimenup) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
331 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
332 Matrix uimenu_childs = uimenup.get_all_children ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
333 Matrix retval = do_find_uimenu_children (uimenu_childs);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
334 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
335 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
336
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
337 Matrix find_uimenu_children (figure::properties& figp) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
338 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
339 Matrix uimenu_childs = figp.get_all_children ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
340 Matrix retval = do_find_uimenu_children (uimenu_childs);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
341 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
342 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
343
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
344 Matrix do_find_uimenu_children (Matrix uimenu_childs) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
345 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
346 octave_idx_type k = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
347
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
348
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
349 Matrix pos = Matrix (uimenu_childs.numel (), 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
350
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
351 for (octave_idx_type ii = 0; ii < uimenu_childs.numel (); ii++)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
352 {
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
353 graphics_object kidgo = gh_manager::get_object (uimenu_childs (ii));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
354
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
355 if (kidgo.valid_object () && kidgo.isa ("uimenu"))
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
356 {
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
357 uimenu_childs(k) = uimenu_childs(ii);
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
358 pos(k++) =
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
359 dynamic_cast<uimenu::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
360 (kidgo.get_properties ()).get_position ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
361 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
362 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
363
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
364 uimenu_childs.resize (k, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
365 pos.resize (k, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
366 Matrix retval = Matrix (k, 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
367 // Don't know if this is the best method to sort.
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
368 // Can we avoid the for loop?
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
369 Array<octave_idx_type> sidx = pos.sort_rows_idx (DESCENDING);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
370 for (octave_idx_type ii = 0; ii < k; ii++)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
371 retval(ii) = uimenu_childs (sidx(ii));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
372
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
373 return retval;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
374 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
375
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
376 void delete_entry (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
377 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
378 std::string fltk_label = uimenup.get_fltk_label ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
379 int idx = find_index_by_name (fltk_label.c_str ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
380
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
381 if (idx >= 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
382 menubar->remove (idx);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
383 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
384
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
385 void update_accelerator (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
386 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
387 std::string fltk_label = uimenup.get_fltk_label ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
388 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
389 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
390 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
391 fltk_label.c_str ()));
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
392 if (item)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
393 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
394 std::string acc = uimenup.get_accelerator ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
395 if (acc.length () > 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
396 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
397 int key = FL_CTRL + acc[0];
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
398 item->shortcut (key);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
399 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
400 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
401 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
402 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
403
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
404 void update_callback (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
405 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
406 std::string fltk_label = uimenup.get_fltk_label ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
407 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
408 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
409 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
410 fltk_label.c_str ()));
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
411 if (item)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
412 {
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
413 if (! uimenup.get_callback ().is_empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
414 item->callback (static_cast<Fl_Callback*> (script_cb),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
415 static_cast<void*> (&uimenup));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
416 else
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
417 item->callback (0, static_cast<void*> (0));
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
418 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
419 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
420 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
421
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
422 void update_enable (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
423 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
424 std::string fltk_label = uimenup.get_fltk_label ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
425 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
426 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
427 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
428 fltk_label.c_str ()));
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
429 if (item)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
430 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
431 if (uimenup.is_enable ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
432 item->activate ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
433 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
434 item->deactivate ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
435 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
436 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
437 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
438
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
439 void update_foregroundcolor (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
440 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
441 std::string fltk_label = uimenup.get_fltk_label ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
442 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
443 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
444 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
445 fltk_label.c_str ()));
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
446 if (item)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
447 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
448 Matrix rgb = uimenup.get_foregroundcolor_rgb ();
12539
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
449
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
450 uchar r = static_cast<uchar> (gnulib::floor (rgb (0) * 255));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
451 uchar g = static_cast<uchar> (gnulib::floor (rgb (1) * 255));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
452 uchar b = static_cast<uchar> (gnulib::floor (rgb (2) * 255));
12539
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
453
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
454 item->labelcolor (fl_rgb_color (r, g, b));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
455 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
456 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
457 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
458
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
459 void update_seperator (const uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
460 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
461 // Matlab places the separator before the current
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
462 // menu entry, while fltk places it after. So we need to find
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
463 // the previous item in this menu/submenu. (Kai)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
464 std::string fltk_label = uimenup.get_fltk_label ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
465 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
466 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
467 int itemflags = 0, idx;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
468 int curr_idx = find_index_by_name (fltk_label.c_str ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
469
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
470 for (idx = curr_idx - 1; idx >= 0; idx--)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
471 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
472 Fl_Menu_Item* item
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
473 = const_cast<Fl_Menu_Item*> (&menubar->menu () [idx]);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
474 itemflags = item->flags;
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
475 if (item->label ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
476 break;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
477 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
478
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
479 if (idx >= 0 && idx < menubar->size ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
480 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
481 if (uimenup.is_separator ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
482 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
483 if (idx >= 0 && !(itemflags & FL_SUBMENU))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
484 menubar->mode (idx, itemflags | FL_MENU_DIVIDER);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
485 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
486 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
487 menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
488 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
489 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
490 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
491
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
492 void update_visible (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
493 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
494 std::string fltk_label = uimenup.get_fltk_label ();
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
495 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
496 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
497 Fl_Menu_Item* item
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
498 = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ()));
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
499 if (item)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
500 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
501 if (uimenup.is_visible ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
502 item->show ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
503 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
504 item->hide ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
505 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
506 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
507 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
508
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
509 void update_position (uimenu::properties& uimenup, int pos)
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
510 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
511 uimenup.get_property ("position").set (octave_value (static_cast<double> (pos)), true, false);
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
512 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
513
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
514 void add_entry (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
515 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
516
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
517 std::string fltk_label = uimenup.get_fltk_label ();
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
518
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
519 if (! fltk_label.empty ())
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
520 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
521 bool item_added = false;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
522 do
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
523 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
524 const Fl_Menu_Item* item
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
525 = menubar->find_item (fltk_label.c_str ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
526
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
527 if (item)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
528 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
529 //avoid duplicate menulabels
19872
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19867
diff changeset
530 size_t idx1 = fltk_label.find_last_of ("(");
d575cd1e0da7 Replace std::size_t with bare size_t for conformity to rest of code.
Rik <rik@octave.org>
parents: 19867
diff changeset
531 size_t idx2 = fltk_label.find_last_of (")");
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
532 int len = idx2 - idx1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
533 int val = 1;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
534 if (len > 0)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
535 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
536 std::string valstr = fltk_label.substr (idx1 + 1, len - 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
537 fltk_label.erase (idx1, len + 1);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
538 val = atoi (valstr.c_str ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
539 if (val > 0 && val < 99)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
540 val++;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
541 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
542 std::ostringstream valstream;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
543 valstream << val;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
544 fltk_label += "(" + valstream.str () + ")";
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
545 }
17898
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
546 else
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
547 {
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
548 Matrix uimenu_ch = find_uimenu_children (uimenup);
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
549 int len = uimenu_ch.numel ();
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
550 int flags = 0;
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
551 if (len > 0)
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
552 flags = FL_SUBMENU;
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
553 if (len == 0 && uimenup.is_checked ())
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
554 flags += FL_MENU_TOGGLE + FL_MENU_VALUE;
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
555 menubar->add (fltk_label.c_str (), 0, 0, 0, flags);
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
556 item_added = true;
8c33abdd2f9a maint: Avoid using NULL in C++ code.
John W. Eaton <jwe@octave.org>
parents: 17881
diff changeset
557 }
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
558 }
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
559 while (! item_added);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
560 uimenup.set_fltk_label (fltk_label);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
561 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
562 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
563
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
564 void add_to_menu (uimenu::properties& uimenup)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
565 {
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
566 std::vector<int> delayed_menus;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
567 Matrix kids = find_uimenu_children (uimenup);
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20181
diff changeset
568 int len = kids.numel ();
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
569 std::string fltk_label = uimenup.get_fltk_label ();
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
570 int count = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
571
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
572 add_entry (uimenup);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
573 update_foregroundcolor (uimenup);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
574 update_callback (uimenup);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
575 update_accelerator (uimenup);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
576 update_enable (uimenup);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
577 update_visible (uimenup);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
578 update_seperator (uimenup);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
579
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
580 for (octave_idx_type ii = 0; ii < len; ii++)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
581 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
582 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1)));
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
583 if (kgo.valid_object ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
584 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
585 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
586 (kgo.get_properties ());
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
587
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
588 // if no pos yet, delay adding menu until after other menus
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
589 int pos = kprop.get_position ();
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
590 if (pos <= 0)
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20119
diff changeset
591 delayed_menus.push_back ((len - (ii + 1)));
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
592 else
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
593 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
594 add_to_menu (kprop);
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
595 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
596 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
597 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
598
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
599 // create any delayed menus
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
600 for (size_t ii = 0; ii < delayed_menus.size (); ii++)
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
601 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
602 graphics_object kgo = gh_manager::get_object (kids (delayed_menus[ii]));
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
603
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
604 if (kgo.valid_object ())
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
605 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
606 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
607 (kgo.get_properties ());
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
608 add_to_menu (kprop);
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
609 update_position (kprop, ++count);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
610 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
611 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
612 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
613
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
614 void add_to_menu (figure::properties& figp)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
615 {
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
616 std::vector<int> delayed_menus;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
617 Matrix kids = find_uimenu_children (figp);
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20181
diff changeset
618 int len = kids.numel ();
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
619 int count = 0;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
620 menubar->clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
621 for (octave_idx_type ii = 0; ii < len; ii++)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
622 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
623 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1)));
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
624
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
625 if (kgo.valid_object ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
626 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
627 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
628 (kgo.get_properties ());
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
629
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
630 // if no pos yet, delay adding menu until after other menus
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
631 int pos = kprop.get_position ();
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
632 if (pos <= 0)
20181
aa36fb998a4d maint: Remove unnecessary whitespace at end of lines.
Rik <rik@octave.org>
parents: 20119
diff changeset
633 delayed_menus.push_back ((len - (ii + 1)));
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
634 else
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
635 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
636 add_to_menu (kprop);
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
637 update_position (kprop, ++count);
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
638 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
639 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
640 }
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
641
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
642 // create any delayed menus
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
643 for (size_t ii = 0; ii < delayed_menus.size (); ii++)
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
644 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
645 graphics_object kgo = gh_manager::get_object (kids (delayed_menus[ii]));
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
646
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
647 if (kgo.valid_object ())
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
648 {
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
649 uimenu::properties& kprop = dynamic_cast<uimenu::properties&>
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
650 (kgo.get_properties ());
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
651 add_to_menu (kprop);
20053
ac59136f1f10 update fltk uimenu position when adding to figure
John Donoghue <john.donoghue@ieee.org>
parents: 19998
diff changeset
652 update_position (kprop, ++count);
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
653 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
654 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
655 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
656
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21126
diff changeset
657 template <typename T_prop>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
658 void remove_from_menu (T_prop& prop)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
659 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
660 Matrix kids;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
661 std::string type = prop.get_type ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
662 kids = find_uimenu_children (prop);
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20181
diff changeset
663 int len = kids.numel ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
664
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
665 for (octave_idx_type ii = 0; ii < len; ii++)
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
666 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
667 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1)));
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
668
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
669 if (kgo.valid_object ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
670 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
671 uimenu::properties kprop = dynamic_cast<uimenu::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
672 (kgo.get_properties ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
673 remove_from_menu (kprop);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
674 }
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
675 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
676
21021
a5b99b09f8fd maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents: 21006
diff changeset
677 if (type == "uimenu")
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
678 delete_entry (dynamic_cast<uimenu::properties&> (prop));
21021
a5b99b09f8fd maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents: 21006
diff changeset
679 else if (type == "figure")
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
680 menubar->clear ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
681 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
682
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
683 ~fltk_uimenu (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
684 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
685 delete menubar;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
686 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
687
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
688 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
689
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
690 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
691
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
692 fltk_uimenu (const fltk_uimenu&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
693
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
694 fltk_uimenu operator = (const fltk_uimenu&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
695
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
696 Fl_Menu_Bar* menubar;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
697 };
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
698
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
699 #if defined (HAVE_X_WINDOWS)
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
700 static int
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
701 xerror_handler (Display *, XErrorEvent *)
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
702 {
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
703 return 0;
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
704 }
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
705 #endif
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
706
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
707 class plot_window : public Fl_Window
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
708 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
709 friend class fltk_uimenu;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
710 public:
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
711 plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
712 bool internal)
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
713 : Fl_Window (xx, yy, ww, hh + menu_h + status_h + 2, "octave"),
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
714 window_label (), fp (xfp), canvas (0),
17131
ea19ea629a09 Proper placement of the menubar, the toolbar and plot canvas.
Ben Abbott <bpabbott@mac.com>
parents: 17079
diff changeset
715 autoscale (0), togglegrid (0), panzoom (0), rotate (0), help (0),
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
716 status (0), resize_dummy (0), ax_obj (), pos_x (0), pos_y (0)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
717 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
718 callback (window_close, static_cast<void*> (this));
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
719
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
720 // The size of the resize_dummy box also determines the minimum window size
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
721 resize_dummy = new Fl_Box (5 * status_h + 1, menu_h + 1,
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
722 ww - 5 * status_h - 1, hh);
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
723 // See http://fltk.org/articles.php?L415+I0+T+M1000+P1
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
724 // for how resizable works
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
725 resizable (resize_dummy);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
726
14447
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
727 // FIXME: The function below is only available in FLTK >= 1.3
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
728 // At some point support for FLTK 1.1 will be dropped in Octave.
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
729 // At that point this function should be uncommented.
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
730 // The current solution is to call xclass() before show() for each window.
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
731 // Set WM_CLASS which allows window managers to properly group related
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
732 // windows. Otherwise, the class is just "FLTK"
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
733 //default_xclass ("Octave");
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
734
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
735 uimenu = new fltk_uimenu (0, 0, ww, menu_h);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
736 canvas = new OpenGL_fltk (0, menu_h, ww, hh, number ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
737
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
738 // The bottom toolbar is a composite of "autoscale", "togglegrid",
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
739 // "panzoom", "rotate", "help", and "status".
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
740 // Only "status" should be resized.
12621
c99d6785a27e instantiate canvas before menubar
Kai Habel <kai.habel@gmx.de>
parents: 12565
diff changeset
741
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
742 int toolbar_y = menu_h + hh + 1;
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
743 status = new Fl_Output (5 * status_h + 1, toolbar_y,
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
744 ww - 5 * status_h - 1, status_h, "");
17131
ea19ea629a09 Proper placement of the menubar, the toolbar and plot canvas.
Ben Abbott <bpabbott@mac.com>
parents: 17079
diff changeset
745
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
746 status->textcolor (FL_BLACK);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
747 status->color (FL_GRAY);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
748 status->textfont (FL_COURIER);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
749 status->textsize (10);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
750 status->box (FL_ENGRAVED_BOX);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
751
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
752 autoscale = new Fl_Button (0, toolbar_y, status_h, status_h, "A");
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
753 autoscale->callback (button_callback, static_cast<void*> (this));
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
754 autoscale->tooltip ("Autoscale");
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
755
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
756 togglegrid = new Fl_Button (status_h, toolbar_y, status_h, status_h, "G");
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
757 togglegrid->callback (button_callback, static_cast<void*> (this));
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
758 togglegrid->tooltip ("Toggle Grid");
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
759
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
760 panzoom = new Fl_Button (2* status_h, toolbar_y, status_h, status_h, "P");
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
761 panzoom->callback (button_callback, static_cast<void*> (this));
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
762 panzoom->tooltip ("Mouse Pan/Zoom");
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
763
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
764 rotate = new Fl_Button (3 * status_h, toolbar_y, status_h, status_h, "R");
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
765 rotate->callback (button_callback, static_cast<void*> (this));
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
766 rotate->tooltip ("Mouse Rotate");
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
767
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
768 help = new Fl_Button (4 * status_h, toolbar_y, status_h, status_h, "?");
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
769 help->callback (button_callback, static_cast<void*> (this));
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
770 help->tooltip ("Help");
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
771
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
772 end ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
773
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
774 set_name ();
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
775 uimenu->add_to_menu (fp);
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
776 if (fp.menubar_is ("none") || ! uimenu->items_to_show ())
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
777 hide_menubar ();
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
778
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
779 update_boundingbox (internal);
12507
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
780
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
781 if (fp.is_visible ())
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
782 {
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
783 // FIXME: This code should be removed when Octave drops support
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
784 // for FLTK 1.1. Search for default_xclass in this file to find
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
785 // code that should be uncommented to take its place.
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
786 //
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
787 // Set WM_CLASS which allows window managers to properly group
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
788 // related windows. Otherwise, the class is just "FLTK"
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
789 xclass ("Octave");
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
790
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
791 show ();
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
792
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
793 #if defined (HAVE_X_WINDOWS)
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
794 std::string show_gui_msgs
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
795 = octave_env::getenv ("OCTAVE_SHOW_GUI_MESSAGES");
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
796
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
797 // Installing our handler suppresses the messages.
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
798 if (show_gui_msgs.empty ())
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
799 XSetErrorHandler (xerror_handler);
18618
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
800 #endif
c644cfa9cb3b suppress all X11 and Qt error messages by default
John W. Eaton <jwe@octave.org>
parents: 18293
diff changeset
801
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
802 if (fp.get_currentaxes ().ok ())
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
803 show_canvas ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
804 else
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
805 hide_canvas ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
806 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
807 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
808
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
809 ~plot_window (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
810 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
811 this->hide ();
19020
d74cdfc5d5c3 Fix problem that FLTK figure stays visible after "close"
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19013
diff changeset
812 Fl::check ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
813 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
814
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
815 double number (void) { return fp.get___myhandle__ ().value (); }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
816
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
817 void renumber (double new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
818 {
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20957
diff changeset
819 if (! canvas)
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
820 error ("unable to renumber figure");
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20957
diff changeset
821
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20957
diff changeset
822 if (canvas->renumber (new_number))
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20957
diff changeset
823 mark_modified ();
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
824 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
825
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
826 void print (const std::string& cmd, const std::string& term)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
827 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
828 canvas->print (cmd, term);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
829 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
830
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
831 void show_menubar (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
832 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
833 uimenu->show ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
834 update_toolbar_position ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
835 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
836
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
837 void hide_menubar (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
838 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
839 uimenu->hide ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
840 update_toolbar_position ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
841 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
842
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
843 void uimenu_update (const graphics_handle& gh, int id)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
844 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
845 graphics_object uimenu_obj = gh_manager::get_object (gh);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
846
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
847 if (uimenu_obj.valid_object () && uimenu_obj.isa ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
848 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
849 uimenu::properties& uimenup =
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
850 dynamic_cast<uimenu::properties&> (uimenu_obj.get_properties ());
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
851 std::string fltk_label = uimenup.get_fltk_label ();
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
852 graphics_object fig = uimenu_obj.get_ancestor ("figure");
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
853 figure::properties& figp =
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
854 dynamic_cast<figure::properties&> (fig.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
855
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
856 switch (id)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
857 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
858 case base_properties::ID_BEINGDELETED:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
859 uimenu->remove_from_menu (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
860 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
861
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
862 case base_properties::ID_VISIBLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
863 uimenu->update_visible (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
864 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
865
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
866 case uimenu::properties::ID_ACCELERATOR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
867 uimenu->update_accelerator (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
868 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
869
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
870 case uimenu::properties::ID_CALLBACK:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
871 uimenu->update_callback (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
872 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
873
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
874 case uimenu::properties::ID_CHECKED:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
875 uimenu->add_to_menu (figp);//rebuilding entire menu
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
876 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
877
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
878 case uimenu::properties::ID_ENABLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
879 uimenu->update_enable (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
880 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
881
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
882 case uimenu::properties::ID_FOREGROUNDCOLOR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
883 uimenu->update_foregroundcolor (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
884 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
885
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
886 case uimenu::properties::ID_LABEL:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
887 uimenu->add_to_menu (figp);//rebuilding entire menu
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
888 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
889
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
890 case uimenu::properties::ID_POSITION:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
891 uimenu->add_to_menu (figp);//rebuilding entire menu
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
892 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
893
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
894 case uimenu::properties::ID_SEPARATOR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
895 uimenu->update_seperator (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
896 break;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
897 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
898
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
899 if (uimenu->items_to_show ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
900 show_menubar ();
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
901 else
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
902 hide_menubar ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
903 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
904 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
905
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
906 void show_canvas (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
907 {
19454
8dbd55742112 Prevent segfault when video card has insufficient OpenGL support (bug #41747).
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18618
diff changeset
908 if (! canvas->can_do ())
8dbd55742112 Prevent segfault when video card has insufficient OpenGL support (bug #41747).
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18618
diff changeset
909 error ("unable to plot due to insufficient OpenGL support");
8dbd55742112 Prevent segfault when video card has insufficient OpenGL support (bug #41747).
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18618
diff changeset
910 else if (fp.is_visible ())
12903
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
911 {
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
912 canvas->show ();
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
913 canvas->make_current ();
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
914 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
915 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
916
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
917 void hide_canvas (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
918 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
919 canvas->hide ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
920 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
921
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
922 // Move the toolbar at the bottom of the plot_window.
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
923 // The only reason for moving the toolbar is hiding and
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
924 // showing the menubar. All other resizing is done by fltk.
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
925
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
926 void update_toolbar_position ()
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
927 {
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
928 int old_canvas_h = canvas->h ();
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
929
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
930 // keep position fix, change outerposition accordingly
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
931 update_boundingbox (true);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
932 canvas->resize (0, menu_dy (), w (), old_canvas_h);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
933
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
934 int toolbar_y = canvas->h () + menu_dy () + 1;
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
935 autoscale->position (0, toolbar_y);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
936 togglegrid->position (status_h, toolbar_y);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
937 panzoom->position (2 * status_h, toolbar_y);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
938 rotate->position (3 * status_h, toolbar_y);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
939 help->position (4 * status_h, toolbar_y);
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
940 status->resize (5 * status_h + 1, toolbar_y,
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
941 w () - 5 * status_h - 1, status_h);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
942
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
943 init_sizes ();
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
944 redraw ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
945 }
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
946
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
947 Matrix outerposition2position (const Matrix& outerpos)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
948 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
949 Matrix pos = outerpos;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
950 pos(1) += menu_dy ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
951 pos(3) -= menu_dy () + status_h + 2;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
952 return pos;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
953 }
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
954
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
955 Matrix position2outerposition (const Matrix& pos)
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
956 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
957 Matrix outerpos = pos;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
958 outerpos(1) -= menu_dy ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
959 outerpos(3) += menu_dy () + status_h + 2;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
960 return outerpos;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
961 }
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
962
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
963 // Called from figure::properties::ID_POSITION if internal = true
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
964 // or ID_OUTERPOSITION if false.
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
965 // (someone has requested a position change with set (h, "position", [...])
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
966 // or set (h, "outerposition", [...])
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
967
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
968 void update_boundingbox (bool internal)
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
969 {
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
970 Matrix bb = fp.get_boundingbox (internal);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
971 if (internal)
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
972 bb = position2outerposition (bb);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
973 resize (bb(0), bb(1), bb(2), bb(3));
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
974 }
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
975
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
976 void mark_modified (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
977 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
978 canvas->redraw ();
7840
2c8f693c32fd convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents: 7839
diff changeset
979 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
980
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
981 void set_name (void)
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
982 {
10009
360de61b2722 corrected redundency in title setting introduced in previous changeset
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10008
diff changeset
983 window_label = fp.get_title ();
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
984 label (window_label.c_str ());
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
985 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
986
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
987 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
988
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
989 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
990
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
991 plot_window (const plot_window&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
992
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
993 plot_window& operator = (const plot_window&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
994
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
995 // window name -- this must exists for the duration of the window's
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
996 // life
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
997 std::string window_label;
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
998
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
999 // Figure properties.
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1000 figure::properties& fp;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1001
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1002 // Status area height.
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1003 static const int status_h = 20;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1004
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1005 // Menu height
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
1006 static const int menu_h = 25;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1007
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1008 // Window callback.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1009 static void window_close (Fl_Widget*, void* data)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1010 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1011 octave_value_list args;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1012 args(0) = static_cast<plot_window*> (data)->number ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1013 feval ("close", args);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1014 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1015
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1016 // Button callbacks.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1017 static void button_callback (Fl_Widget* ww, void* data)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1018 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1019 static_cast<plot_window*> (data)->button_press (ww, data);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1020 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1021
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1022 void button_press (Fl_Widget* widg, void*)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1023 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1024 if (widg == autoscale)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1025 axis_auto ();
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1026 else if (widg == togglegrid)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1027 toggle_grid ();
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1028 else if (widg == panzoom)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1029 fp.set___mouse_mode__ ("pan");
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1030 else if (widg == rotate)
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1031 fp.set___mouse_mode__ ("rotate");
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1032 else if (widg == help)
9060
de7cef39f505 fltk_backend.cc: don't pass arbitrary string as format
John W. Eaton <jwe@octave.org>
parents: 8333
diff changeset
1033 fl_message ("%s", help_text);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1034 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1035
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1036 void set_on_ax_obj (const std::string& name, const std::string& value)
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1037 {
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1038 // ax_obj is the last clicked axes object
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1039 if (ax_obj && ax_obj.isa ("axes"))
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1040 {
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
1041 axes::properties& ap =
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
1042 dynamic_cast<axes::properties&>(ax_obj.get_properties ());
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1043 ap.set (name, value);
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1044 }
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1045 else // no axes object clicked so far, take currentaxes
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1046 {
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1047 graphics_handle gh = fp.get_currentaxes ();
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1048 if (gh.ok ())
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1049 {
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1050 graphics_object go = gh_manager::get_object (gh);
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
1051 axes::properties& ap =
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
1052 dynamic_cast<axes::properties&>(go.get_properties ());
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1053 ap.set (name, value);
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1054 }
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1055 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1056 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1057
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1058 fltk_uimenu* uimenu;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1059 OpenGL_fltk* canvas;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1060 Fl_Button* autoscale;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1061 Fl_Button* togglegrid;
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1062 Fl_Button* panzoom;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1063 Fl_Button* rotate;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1064 Fl_Button* help;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1065 Fl_Output* status;
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
1066 Fl_Box* resize_dummy;
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1067 graphics_object ax_obj;
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1068 int pos_x;
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1069 int pos_y;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1070
18968
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1071
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1072 void axis_auto (void)
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
1073 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1074 octave_value_list args;
18968
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1075 if (fp.get_currentaxes ().ok ())
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1076 {
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1077 args(0) = fp.get_currentaxes ().as_octave_value ();
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1078 args(1) = "auto";
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1079 feval ("axis", args);
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1080 mark_modified ();
0257a936dc4a Fix FLTK redraw and event issue
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18966
diff changeset
1081 }
7852
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
1082 }
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
1083
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1084 void toggle_grid (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1085 {
9974
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
1086 octave_value_list args;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1087 if (fp.get_currentaxes ().ok ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1088 args(0) = fp.get_currentaxes ().as_octave_value ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1089
9974
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
1090 feval ("grid", args);
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
1091 mark_modified ();
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
1092 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1093
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1094 void pixel2pos (const graphics_handle& ax, int px, int py, double& xx,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1095 double& yy) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1096 {
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18618
diff changeset
1097 pixel2pos (gh_manager::get_object (ax), px, py, xx, yy);
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1098 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1099
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1100 void pixel2pos (graphics_object ax, int px, int py, double& xx,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1101 double& yy) const
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1102 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1103 if (ax && ax.isa ("axes"))
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1104 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1105 axes::properties& ap =
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1106 dynamic_cast<axes::properties&> (ax.get_properties ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1107 ColumnVector pp = ap.pixel2coord (px, py);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1108 xx = pp(0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1109 yy = pp(1);
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1110 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1111 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1112
18678
6113e0c6920b maint: Clean up extra spaces before/after parentheses.
Rik <rik@octave.org>
parents: 18618
diff changeset
1113 graphics_handle pixel2axes_or_ca (int px, int py)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1114 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1115 Matrix kids = fp.get_children ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20181
diff changeset
1116 int len = kids.numel ();
9442
2d73b19c5507 improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
1117
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1118 for (int k = 0; k < len; k++)
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
1119 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1120 graphics_handle hnd = gh_manager::lookup (kids(k));
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1121
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1122 if (hnd.ok ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1123 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1124 graphics_object kid = gh_manager::get_object (hnd);
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1125
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1126 if (kid.valid_object () && kid.isa ("axes"))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1127 {
19296
8ba8f3d22189 __init_fltk__.cc: Allow selection of axes from whole plot area
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19152
diff changeset
1128 Matrix bb = kid.get_properties ().get_boundingbox (false);
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1129
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1130 if (bb(0) <= px && px < (bb(0)+bb(2))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1131 && bb(1) <= py && py < (bb(1)+bb(3)))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1132 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1133 return hnd;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1134 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1135 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1136 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1137 }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1138 return fp.get_currentaxes ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1139 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1140
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1141 void pixel2status (const graphics_handle& ax, int px0, int py0,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1142 int px1 = -1, int py1 = -1)
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1143 {
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1144 pixel2status (gh_manager::get_object (ax), px0, py0, px1, py1);
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1145 }
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
1146
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
1147 void pixel2status (graphics_object ax, int px0, int py0,
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1148 int px1 = -1, int py1 = -1)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1149 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1150 double x0, y0, x1, y1;
17945
265f9186e543 Fix uninitialised parameters in pixel2status
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 17900
diff changeset
1151 x0 = y0 = x1 = y1 = octave_NaN;
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1152 std::stringstream cbuf;
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1153 cbuf.precision (4);
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1154 cbuf.width (6);
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1155 pixel2pos (ax, px0, py0, x0, y0);
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1156 cbuf << "[" << x0 << ", " << y0 << "]";
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1157 if (px1 >= 0)
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1158 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1159 pixel2pos (ax, px1, py1, x1, y1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1160 cbuf << " -> ["<< x1 << ", " << y1 << "]";
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1161 }
7840
2c8f693c32fd convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents: 7839
diff changeset
1162
7842
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1163 status->value (cbuf.str ().c_str ());
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1164 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1165
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1166 void view2status (graphics_object ax)
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1167 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1168 if (ax && ax.isa ("axes"))
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1169 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1170 axes::properties& ap =
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1171 dynamic_cast<axes::properties&> (ax.get_properties ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1172 std::stringstream cbuf;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1173 cbuf.precision (4);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1174 cbuf.width (6);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1175 Matrix v (1,2,0);
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1176 v = ap.get ("view").matrix_value ();
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1177 cbuf << "[azimuth: " << v(0) << ", elevation: " << v(1) << "]";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1178
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1179 status->value (cbuf.str ().c_str ());
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1180 }
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1181 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1182
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1183 void set_currentpoint (int px, int py)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1184 {
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
1185 if (! fp.is_beingdeleted ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1186 {
19028
c419e5487d0d Fix set_currentpoint in FLTK that figures units property is respected.
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19027
diff changeset
1187 Matrix pos = fp.map_from_boundingbox (px, py);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1188 fp.set_currentpoint (pos);
17144
88616c872933 Set the root property "currentfigure", and figure property "currentaxes".
Ben Abbott <bpabbott@mac.com>
parents: 17143
diff changeset
1189 graphics_object robj = gh_manager::get_object (fp.get_parent ());
88616c872933 Set the root property "currentfigure", and figure property "currentaxes".
Ben Abbott <bpabbott@mac.com>
parents: 17143
diff changeset
1190 root_figure::properties& rp =
88616c872933 Set the root property "currentfigure", and figure property "currentaxes".
Ben Abbott <bpabbott@mac.com>
parents: 17143
diff changeset
1191 dynamic_cast<root_figure::properties&> (robj.get_properties ());
88616c872933 Set the root property "currentfigure", and figure property "currentaxes".
Ben Abbott <bpabbott@mac.com>
parents: 17143
diff changeset
1192 rp.set_currentfigure (fp.get___myhandle__ ().value ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1193 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1194 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1195
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1196 void set_axes_currentpoint (graphics_object ax, int px, int py)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1197 {
19027
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1198 if (ax.valid_object () && ax.isa ("axes"))
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1199 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1200 axes::properties& ap =
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1201 dynamic_cast<axes::properties&> (ax.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1202
19027
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1203 Matrix x_zlim = ap.get_transform_zlim ();
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1204 Matrix pos (2, 3, 0.0);
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1205
19027
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1206 // front point (nearest to the viewer)
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1207 ColumnVector tmp = ap.get_transform ().untransform (px, py, x_zlim(0));
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1208 pos(0,0) = tmp(0);
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1209 pos(0,1) = tmp(1);
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1210 pos(0,2) = tmp(2);
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1211
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1212 // back point (furthest from the viewer)
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1213 tmp = ap.get_transform ().untransform (px, py, x_zlim(1));
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1214 pos(1,0) = tmp(0);
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1215 pos(1,1) = tmp(1);
0ee9daa71273 Fix axes property "currentpoint" for FLTK, extend documentation
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19021
diff changeset
1216 pos(1,2) = tmp(2);
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1217
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1218 ap.set_currentpoint (pos);
17144
88616c872933 Set the root property "currentfigure", and figure property "currentaxes".
Ben Abbott <bpabbott@mac.com>
parents: 17143
diff changeset
1219 fp.set_currentaxes (ap.get___myhandle__ ().value ());
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1220 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1221 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1222
17213
4407606d0939 FLTK toolkit: Simplify conditionals for uimenu presence.
Ben Abbott <bpabbott@mac.com>
parents: 17201
diff changeset
1223 int menu_dy ()
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1224 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1225 if (uimenu->is_visible ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1226 return menu_h;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1227 else
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1228 return 0;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
1229 }
17213
4407606d0939 FLTK toolkit: Simplify conditionals for uimenu presence.
Ben Abbott <bpabbott@mac.com>
parents: 17201
diff changeset
1230
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1231 octave_scalar_map format_key_event (int e_key, const char* e_text, int e_state)
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1232 {
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1233 octave_scalar_map evt;
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1234
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1235 evt.assign ("Character", octave_value (e_text));
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1236 evt.assign ("Modifier", octave_value (modifier2cell (e_state)));
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1237
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1238 std::string key_str;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1239 std::ostringstream tmp_str;
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1240
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1241 if (e_key == FL_Escape)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1242 key_str = "escape";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1243 else if (e_key == FL_Tab)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1244 key_str = "tab";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1245 else if (e_key == FL_Caps_Lock)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1246 key_str = "capslock";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1247 else if (e_key == FL_Shift_L || e_key == FL_Shift_R)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1248 key_str = "shift";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1249 else if (e_key == FL_Control_L || e_key == FL_Control_R)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1250 key_str = "control";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1251 else if (e_key == FL_Meta_L || e_key == FL_Meta_R)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1252 key_str = "windows";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1253 else if (e_key == FL_Alt_L || e_key == FL_Alt_R)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1254 key_str = "alt";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1255 else if (e_key == 32)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1256 key_str = "space";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1257 else if (e_key == FL_Enter)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1258 key_str = "return";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1259 else if (e_key == FL_BackSpace)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1260 key_str = "backspace";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1261 else if (e_key == FL_Print)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1262 key_str = "printscreen";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1263 else if (e_key == FL_Pause)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1264 key_str = "pause";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1265 else if (e_key == FL_Home)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1266 key_str = "home";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1267 else if (e_key == FL_End)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1268 key_str = "end";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1269 else if (e_key == FL_Insert)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1270 key_str = "insert";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1271 else if (e_key == FL_Page_Up)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1272 key_str = "pageup";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1273 else if (e_key == FL_Delete)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1274 key_str = "delete";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1275 else if (e_key == FL_Page_Down)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1276 key_str = "pagedown";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1277 else if (e_key == FL_Left)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1278 key_str = "leftarrow";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1279 else if (e_key == FL_Up)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1280 key_str = "uparrow";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1281 else if (e_key == FL_Right)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1282 key_str = "rightarrow";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1283 else if (e_key == FL_Down)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1284 key_str = "downarrow";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1285 else if (e_key == FL_Num_Lock)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1286 key_str = "numlock";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1287 else if (e_key == 0xffaf)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1288 key_str = "divide";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1289 else if (e_key == 0xffaa)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1290 key_str = "multiply";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1291 else if (e_key == 0xffad)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1292 key_str = "subtract";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1293 else if (e_key == 0xffab)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1294 key_str = "add";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1295 else if (e_key == 0xff8d)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1296 key_str = "return";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1297 else if (e_key == 0xffac)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1298 key_str = "separator";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1299 else if (e_key >= 0xffb0 && e_key <= 0xffb9)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1300 {
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1301 tmp_str << "numpad" << (e_key - 0xffb0);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1302 key_str = tmp_str.str ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1303 }
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1304 else if (e_key >= (FL_F + 1) && e_key <= (FL_F + 12))
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1305 {
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1306 tmp_str << "f" << (e_key - FL_F);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1307 key_str = tmp_str.str ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1308 }
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1309 else if (e_key == ',')
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1310 key_str = "comma";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1311 else if (e_key == '.')
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1312 key_str = "period";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1313 else if (e_key == '-')
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1314 key_str = "hyphen";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1315 else if (e_key == '^' || e_key == '+' || e_key == '#'
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1316 || e_key == '<' || e_key == 0xfe03 /*AltGr*/)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1317 key_str = "0";
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1318 else if (isalnum (e_key))
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1319 key_str = std::tolower (e_key);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1320 else if (isprint (e_text[0]))
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1321 key_str = "0";
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1322
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1323 evt.assign ("Key", octave_value (key_str));
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1324 return evt;
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1325 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1326
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1327 Cell modifier2cell (int e_state)
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1328 {
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1329 string_vector mod;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1330
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1331 if (e_state & FL_SHIFT)
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1332 mod.append (std::string ("shift"));
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1333 if (e_state & FL_CTRL)
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1334 mod.append (std::string ("control"));
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1335 if (e_state & FL_ALT)
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1336 mod.append (std::string ("alt"));
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1337 if (e_state & FL_COMMAND)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1338 mod.append (std::string ("command"));
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1339 return Cell (mod);
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1340 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1341
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
1342 void resize (int xx, int yy, int ww, int hh)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1343 {
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
1344 Fl_Window::resize (xx, yy, ww, hh);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1345
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1346 Matrix bb (1, 4);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1347 bb(0) = xx;
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1348 bb(1) = yy;
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1349 bb(2) = ww;
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1350 bb(3) = hh;
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14314
diff changeset
1351
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1352 // update outerposition
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1353 fp.set_boundingbox (bb, false, false);
17131
ea19ea629a09 Proper placement of the menubar, the toolbar and plot canvas.
Ben Abbott <bpabbott@mac.com>
parents: 17079
diff changeset
1354
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1355 // update position
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1356 fp.set_boundingbox (outerposition2position (bb), true, false);
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1357 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1358
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1359 bool pan_enabled (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1360 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1361 // Getting pan mode property:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1362 octave_value ov_pm = fp.get___pan_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1363
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1364 octave_scalar_map pm = ov_pm.scalar_map_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1365
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1366 return pm.contents ("Enable").string_value () == "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1367 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1368
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1369 std::string pan_mode (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1370 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1371 // Getting pan mode property:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1372 octave_value ov_pm = fp.get___pan_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1373
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1374 octave_scalar_map pm = ov_pm.scalar_map_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1375
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1376 return pm.contents ("Motion").string_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1377 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1378
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1379 bool rotate_enabled (void)
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1380 {
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1381 // Getting rotate mode property:
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1382 octave_value ov_rm = fp.get___rotate_mode__ ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1383
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1384 octave_scalar_map rm = ov_rm.scalar_map_value ();
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1385
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1386 return rm.contents ("Enable").string_value () == "on";
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1387 }
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1388
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1389 int handle (int event)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1390 {
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1391 if (event == FL_FOCUS)
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1392 return 1;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1393
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1394 graphics_handle gh;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1395
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20845
diff changeset
1396 if (! fp.is_beingdeleted ())
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1397 {
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1398 //std::cout << "plot_window::handle event = " << fl_eventnames[event] << std::endl;
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1399
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1400 // FLTK resends keyboard events with flipped case if all
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1401 // widgets rejects the event.
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1402 // See Event Propagation http://www.fltk.org/doc-1.3/events.html
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1403 static bool key_resent_detected = false;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1404
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1405 switch (event)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1406 {
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1407 case FL_SHORTCUT:
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1408 {
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1409 // check if it a resent event with switched case
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1410 static int last_event_key = 0;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1411 static char last_event_text = 0;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1412
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1413 int e_key = Fl::event_key ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1414 char e_text = Fl::event_text ()[0];
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1415 key_resent_detected = (e_key == last_event_key
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1416 && std::tolower (last_event_text) == std::tolower (e_text)
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1417 && ((islower (last_event_text) && isupper (e_text))
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1418 || (isupper (last_event_text) && islower (e_text))));
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1419
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1420 last_event_key = e_key;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1421 last_event_text = e_text;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1422 }
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1423 break;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1424
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1425 case FL_KEYDOWN:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1426 {
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1427 int e_key = Fl::event_key ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1428 const char *e_text = Fl::event_text ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1429 int e_state = Fl::event_state ();
20118
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1430 octave_scalar_map evt = format_key_event (e_key, e_text, e_state);
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1431
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1432 fp.set_currentcharacter (std::string (e_text));
20118
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1433
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1434 if (! fp.get_keypressfcn ().is_empty ()
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1435 && (evt.contents ("Key").length () > 0))
20118
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1436 {
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1437 // Update CurrentPoint before callback
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1438 if (Fl::event_inside (canvas))
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1439 {
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1440 pos_x = Fl::event_x ();
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1441 pos_y = Fl::event_y () - menu_dy ();
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1442
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1443 set_currentpoint (pos_x, pos_y);
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1444
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1445 gh = pixel2axes_or_ca (pos_x, pos_y);
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1446
20118
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1447 if (gh.ok ())
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1448 {
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1449 ax_obj = gh_manager::get_object (gh);
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1450 set_axes_currentpoint (ax_obj, pos_x, pos_y);
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1451 }
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1452 }
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1453
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1454 fp.execute_keypressfcn (evt);
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1455 }
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1456
144498565de9 Return correct x,y coordinates for keystroke with ginput in FLTK (bug #44834).
Rik <rik@octave.org>
parents: 20108
diff changeset
1457 // Handle special keys used in toolbar
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1458 switch (e_key)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1459 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1460 case 'a':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1461 case 'A':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1462 axis_auto ();
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1463 return 1;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1464
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1465 case 'g':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1466 case 'G':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1467 toggle_grid ();
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1468 return 1;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1469
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1470 case 'p':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1471 case 'P':
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1472 fp.set___mouse_mode__ ("pan");
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1473 return 1;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1474
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1475 case 'r':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1476 case 'R':
19663
dfea01b3425f more mouse interaction features for Qt plotting widget
John W. Eaton <jwe@octave.org>
parents: 19657
diff changeset
1477 fp.set___mouse_mode__ ("rotate");
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1478 return 1;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1479 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1480 }
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1481 break;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1482
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1483 case FL_KEYUP:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1484 {
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1485 int e_key = Fl::event_key ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1486 int e_state = Fl::event_state ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1487 octave_scalar_map evt;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1488 if (key_resent_detected && Fl::event_length () == 1)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1489 {
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1490 // FLTK flipped the case of Fl::event_text because no
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1491 // widget wanted the FL_KEYDOWN event.
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1492 char tmp_e_text[2];
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1493 tmp_e_text[0] = Fl::event_text ()[0];
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1494 tmp_e_text[1] = 0;
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1495 // Undo the case flip
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1496 if (std::islower (tmp_e_text[0]))
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1497 tmp_e_text[0] = std::toupper (tmp_e_text[0]);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1498 else
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1499 tmp_e_text[0] = std::tolower (tmp_e_text[0]);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1500 evt = format_key_event (e_key, tmp_e_text, e_state);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1501 }
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1502 else
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1503 {
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1504 const char *e_text = Fl::event_text ();
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1505 evt = format_key_event (e_key, e_text, e_state);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1506 }
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1507
20119
f46f6d906654 Avoid unnecessarily calling graphics callbacks in FLTK.
Rik <rik@octave.org>
parents: 20118
diff changeset
1508 if (! fp.get_keyreleasefcn ().is_empty ()
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1509 && (evt.contents ("Key").length () > 0))
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1510 fp.execute_keyreleasefcn (evt);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
1511 return 1;
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1512 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1513 break;
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1514 }
7856
cf672485be43 Add toggle grid button & handle the 'a' & 'g' keys for auto axis and toggle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7852
diff changeset
1515
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1516 // Events we only handle if they are in the canvas area.
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1517 if (Fl::event_inside (canvas))
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1518 switch (event)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1519 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1520 case FL_MOVE:
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1521 pixel2status (pixel2axes_or_ca (Fl::event_x (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1522 Fl::event_y () - menu_dy ()),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1523 Fl::event_x (), Fl::event_y () - menu_dy ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1524 return 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1525
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1526 case FL_PUSH:
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1527 pos_x = Fl::event_x ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1528 pos_y = Fl::event_y () - menu_dy ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1529
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1530 set_currentpoint (pos_x, pos_y);
19021
9609f345823e Implement figure property SelectionType for FLTK
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19020
diff changeset
1531
19998
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1532 if (Fl::event_clicks ())
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1533 fp.set_selectiontype ("open");
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1534 else if (Fl::event_button () == FL_MIDDLE_MOUSE
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1535 || (Fl::event_button () == FL_LEFT_MOUSE
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1536 && Fl::event_shift ()))
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1537 fp.set_selectiontype ("extend");
19998
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1538 else if (Fl::event_button () == FL_RIGHT_MOUSE
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1539 || (Fl::event_button () == FL_LEFT_MOUSE
91e2212b060d Fix FLTK SelectionType for Middle Button and double clicks (bug #44669).
Rik <rik@octave.org>
parents: 19976
diff changeset
1540 && Fl::event_ctrl ()))
19976
f902855f870a Fix right click zoom in fltk after cset f134ee404041 (bug #44522)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 19946
diff changeset
1541 fp.set_selectiontype ("alt");
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1542 else
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1543 fp.set_selectiontype ("normal");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1544
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1545 gh = pixel2axes_or_ca (pos_x, pos_y);
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1546
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1547 if (gh.ok ())
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1548 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1549 ax_obj = gh_manager::get_object (gh);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1550 set_axes_currentpoint (ax_obj, pos_x, pos_y);
19946
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1551 }
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
1552
19946
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1553 // Ensure windowbuttondownfcn is called after currentpoint
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1554 // is updated but before calling buttondownfcn.
20119
f46f6d906654 Avoid unnecessarily calling graphics callbacks in FLTK.
Rik <rik@octave.org>
parents: 20118
diff changeset
1555 if (! fp.get_windowbuttondownfcn ().is_empty ())
19946
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1556 fp.execute_windowbuttondownfcn (Fl::event_button ());
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1557
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1558 if (gh.ok ())
4910b70d7328 Ensure correct coordinates are available in windowbuttondownfcn callback
Mike Miller <mtmiller@octave.org>
parents: 19891
diff changeset
1559 {
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1560 int ndim = calc_dimensions (ax_obj);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1561
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1562 if (ndim == 3)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1563 rotate->activate ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1564 else // ndim == 2
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1565 rotate->deactivate ();
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1566
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1567 fp.set_currentobject (ax_obj.get_handle ().value ());
19013
60e54be64f37 Fix ginput for FLTK toolkit
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19012
diff changeset
1568
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1569 base_properties& props = ax_obj.get_properties ();
20119
f46f6d906654 Avoid unnecessarily calling graphics callbacks in FLTK.
Rik <rik@octave.org>
parents: 20118
diff changeset
1570 if (! props.get_buttondownfcn ().is_empty ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1571 props.execute_buttondownfcn (Fl::event_button ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1572
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1573 return 1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1574 }
20119
f46f6d906654 Avoid unnecessarily calling graphics callbacks in FLTK.
Rik <rik@octave.org>
parents: 20118
diff changeset
1575 else if (! fp.get_buttondownfcn ().is_empty ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1576 fp.execute_buttondownfcn (Fl::event_button ());
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1577
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1578 break;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1579
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1580 case FL_DRAG:
20119
f46f6d906654 Avoid unnecessarily calling graphics callbacks in FLTK.
Rik <rik@octave.org>
parents: 20118
diff changeset
1581 if (! fp.get_windowbuttonmotionfcn ().is_empty ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1582 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1583 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1584 fp.execute_windowbuttonmotionfcn ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1585 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1586
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1587 if (Fl::event_button () == 1)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1588 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1589 if (ax_obj && ax_obj.isa ("axes"))
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1590 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1591 axes::properties& ap =
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1592 dynamic_cast<axes::properties&>
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1593 (ax_obj.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1594
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1595 // Don't pan or rotate legend
21021
a5b99b09f8fd maint: Use comparison operators rather than compare() for strings.
Rik <rik@octave.org>
parents: 21006
diff changeset
1596 if (ap.get_tag () == "legend")
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1597 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1598 if (rotate_enabled ())
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1599 view2status (ax_obj);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1600 else
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1601 pixel2status (ax_obj, pos_x, pos_y,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1602 Fl::event_x (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1603 Fl::event_y () - menu_dy ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1604
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1605 double x0, y0, x1, y1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1606 Matrix pos = fp.get_boundingbox (true);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1607 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1608 pixel2pos (ax_obj, Fl::event_x (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1609 Fl::event_y () - menu_dy (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1610 x1, y1);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1611
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1612 if (pan_enabled ())
19891
fa290c42197e Implement x- and y-only panning for FLTK (bug #44408).
Rik <rik@octave.org>
parents: 19872
diff changeset
1613 {
fa290c42197e Implement x- and y-only panning for FLTK (bug #44408).
Rik <rik@octave.org>
parents: 19872
diff changeset
1614 std::string mode = pan_mode ();
fa290c42197e Implement x- and y-only panning for FLTK (bug #44408).
Rik <rik@octave.org>
parents: 19872
diff changeset
1615
fa290c42197e Implement x- and y-only panning for FLTK (bug #44408).
Rik <rik@octave.org>
parents: 19872
diff changeset
1616 ap.translate_view (mode, x0, x1, y0, y1);
fa290c42197e Implement x- and y-only panning for FLTK (bug #44408).
Rik <rik@octave.org>
parents: 19872
diff changeset
1617 }
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1618 else if (rotate_enabled ())
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1619 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1620 double daz, del;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1621 daz = (Fl::event_x () - pos_x) / pos(2) * 360;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1622 del = (Fl::event_y () - menu_dy () - pos_y)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1623 / pos(3) * 360;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1624 ap.rotate_view (del, daz);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1625 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1626 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1627 else
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1628 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1629 // move the position of the legend
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1630 Matrix pos = ap.get_position ().matrix_value ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1631 pos(0) += double (Fl::event_x () - pos_x)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1632 / canvas->w ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1633 pos(1) -= double (Fl::event_y () - menu_dy () - pos_y)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1634 / canvas->h ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1635 ap.set_position (pos);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1636 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1637
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1638 pos_x = Fl::event_x ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1639 pos_y = Fl::event_y () - menu_dy ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1640 mark_modified ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1641 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1642 return 1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1643 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1644 else if (Fl::event_button () == 3)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1645 {
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1646 pixel2status (ax_obj, pos_x, pos_y,
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1647 Fl::event_x (), Fl::event_y () - menu_dy ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1648 Matrix zoom_box (1,4,0);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1649 zoom_box (0) = pos_x;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1650 zoom_box (1) = pos_y;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1651 zoom_box (2) = Fl::event_x ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1652 zoom_box (3) = Fl::event_y () - menu_dy ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1653 canvas->set_zoom_box (zoom_box);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1654 canvas->zoom (true);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1655 mark_modified ();
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1656 return 1;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1657 }
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1658
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1659 break;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1660
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1661 case FL_MOUSEWHEEL:
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1662 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1663 graphics_object ax =
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1664 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1665 Fl::event_y ()
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1666 - menu_dy ()));
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1667 if (ax && ax.isa ("axes"))
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1668 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1669 axes::properties& ap =
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1670 dynamic_cast<axes::properties&> (ax.get_properties ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1671
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1672 // Control how fast to zoom when using scroll wheel.
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1673 double wheel_zoom_speed = ap.get_mousewheelzoom ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1674
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1675 // Determine if we're zooming in or out.
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1676 const double factor = (Fl::event_dy () < 0
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1677 ? 1 / (1.0 - wheel_zoom_speed)
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1678 : 1.0 - wheel_zoom_speed);
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1679
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1680
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1681 // Get the point we're zooming about.
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1682 double x1, y1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1683 pixel2pos (ax, Fl::event_x (), Fl::event_y () - menu_dy (),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1684 x1, y1);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1685
19867
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1686 // FIXME: should we only zoom about point for 2D plots?
6ba3d0f7c6e8 improve mouse zooming for Qt plotting (bug #44302)
John W. Eaton <jwe@octave.org>
parents: 19861
diff changeset
1687
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1688 ap.zoom_about_point ("both", x1, y1, factor, false);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1689 mark_modified ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1690 return 1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1691 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1692 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1693
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1694 case FL_RELEASE:
20119
f46f6d906654 Avoid unnecessarily calling graphics callbacks in FLTK.
Rik <rik@octave.org>
parents: 20118
diff changeset
1695 if (! fp.get_windowbuttonupfcn ().is_empty ())
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1696 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1697 set_currentpoint (Fl::event_x (), Fl::event_y () - menu_dy ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1698 fp.execute_windowbuttonupfcn ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1699 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1700
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1701 if ((Fl::event_button () == 1) && Fl::event_clicks ())
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1702 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1703 // Double click
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1704 set_on_ax_obj ("xlimmode", "auto");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1705 set_on_ax_obj ("ylimmode", "auto");
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1706 set_on_ax_obj ("zlimmode", "auto");
20061
402e6678673b Redraw FLTK figure after double-click "zoom out".
Rik <rik@octave.org>
parents: 20060
diff changeset
1707 mark_modified ();
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1708 return 1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1709 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1710 if (Fl::event_button () == 3)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1711 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1712 // End of drag -- zoom.
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1713 if (canvas->zoom ())
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1714 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1715 canvas->zoom (false);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1716 double x0,y0,x1,y1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1717 if (ax_obj && ax_obj.isa ("axes"))
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1718 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1719 axes::properties& ap = dynamic_cast<axes::properties&>
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1720 (ax_obj.get_properties ());
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1721 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1722 int pos_x1 = Fl::event_x ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1723 int pos_y1 = Fl::event_y () - menu_dy ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1724 pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1725 Matrix xl (1,2,0);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1726 Matrix yl (1,2,0);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1727 int dx = abs (pos_x - pos_x1);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1728 int dy = abs (pos_y - pos_y1);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1729 // Smallest zoom box must be 4 pixels square
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1730 if ((dx > 4) && (dy > 4))
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1731 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1732 if (x0 < x1)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1733 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1734 xl(0) = x0;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1735 xl(1) = x1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1736 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1737 else
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1738 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1739 xl(0) = x1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1740 xl(1) = x0;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1741 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1742 if (y0 < y1)
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1743 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1744 yl(0) = y0;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1745 yl(1) = y1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1746 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1747 else
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1748 {
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1749 yl(0) = y1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1750 yl(1) = y0;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1751 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1752 ap.zoom ("both", xl, yl);
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1753 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1754 mark_modified ();
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1755 return 1;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1756 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1757 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1758 }
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1759 break;
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1760 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1761 }
18966
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1762 //std::cout << "plot_window::handle wasn't interested in event " << fl_eventnames[event] << std::endl;
b2db129c664d Fix FLTK event handling for shortcuts and mouse cursor change
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18961
diff changeset
1763 return Fl_Window::handle (event);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1764 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1765 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1766
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1767 class figure_manager
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1768 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1769 public:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1770
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1771 static bool instance_ok (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1772 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1773 bool retval = true;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1774
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1775 if (! instance)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1776 instance = new figure_manager ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1777
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1778 if (! instance)
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
1779 error ("unable to create figure_manager object!");
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1780
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1781 return retval;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1782 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1783
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1784 ~figure_manager (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1785 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1786 close_all ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1787 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1788
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1789 static void close_all (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1790 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1791 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1792 instance->do_close_all ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1793 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1794
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1795 static void new_window (figure::properties& fp)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1796 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1797 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1798 instance->do_new_window (fp);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1799 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1800
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1801 static void delete_window (int idx)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1802 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1803 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1804 instance->do_delete_window (idx);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1805 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1806
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1807 static void delete_window (const std::string& idx_str)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1808 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1809 delete_window (str2idx (idx_str));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1810 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1811
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1812 static void renumber_figure (const std::string& idx_str, double new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1813 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1814 if (instance_ok ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1815 instance->do_renumber_figure (str2idx (idx_str), new_number);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1816 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1817
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1818 static void toggle_window_visibility (int idx, bool is_visible)
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1819 {
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1820 if (instance_ok ())
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1821 instance->do_toggle_window_visibility (idx, is_visible);
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1822 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1823
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1824 static void toggle_window_visibility (const std::string& idx_str,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1825 bool is_visible)
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1826 {
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1827 toggle_window_visibility (str2idx (idx_str), is_visible);
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1828 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1829
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1830 static void mark_modified (int idx)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1831 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1832 if (instance_ok ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1833 instance->do_mark_modified (idx);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1834 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1835
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1836 static void mark_modified (const graphics_handle& gh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1837 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1838 mark_modified (hnd2idx (gh));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1839 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1840
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1841 static void set_name (int idx)
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1842 {
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1843 if (instance_ok ())
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1844 instance->do_set_name (idx);
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1845 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1846
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1847 static void set_name (const std::string& idx_str)
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1848 {
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1849 set_name (str2idx (idx_str));
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1850 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1851
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1852 static Matrix get_size (int idx)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1853 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1854 return instance_ok () ? instance->do_get_size (idx) : Matrix ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1855 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1856
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1857 static Matrix get_size (const graphics_handle& gh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1858 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1859 return get_size (hnd2idx (gh));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1860 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1861
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1862 static void print (const graphics_handle& gh, const std::string& cmd,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1863 const std::string& term)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1864 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1865 if (instance_ok ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1866 instance->do_print (hnd2idx (gh), cmd, term);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1867 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1868
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1869 static void uimenu_update (const graphics_handle& figh,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1870 const graphics_handle& uimenuh, int id)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1871 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1872 if (instance_ok ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1873 instance->do_uimenu_update (hnd2idx (figh), uimenuh, id);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1874 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1875
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1876 static void update_canvas (const graphics_handle& gh,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1877 const graphics_handle& ca)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1878 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1879 if (instance_ok ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1880 instance->do_update_canvas (hnd2idx (gh), ca);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1881 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1882
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1883 static void update_boundingbox (const std::string& fig_idx_str,
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1884 bool internal)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1885 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1886 if (instance_ok ())
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1887 instance->do_update_boundingbox (str2idx (fig_idx_str), internal);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1888 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1889
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1890 static void toggle_menubar_visibility (const std::string& fig_idx_str,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1891 bool menubar_is_figure)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1892 {
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
1893 if (instance_ok ())
18985
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
1894 instance->do_toggle_menubar_visibility (str2idx (fig_idx_str),
f84361735a40 maint: Use Octave coding conventions for some recent patches.
Rik <rik@octave.org>
parents: 18968
diff changeset
1895 menubar_is_figure);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1896 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1897
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1898 private:
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1899
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1900 static figure_manager *instance;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1901
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1902 figure_manager (void) { }
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1903
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1904 // No copying!
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1905 figure_manager (const figure_manager&);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1906 figure_manager& operator = (const figure_manager&);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1907
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1908 // Singelton -- hide all of the above.
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1909
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1910 static int curr_index;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1911 typedef std::map<int, plot_window*> window_map;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1912 typedef window_map::iterator wm_iterator;;
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1913 window_map windows;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1914
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1915 static std::string fltk_idx_header;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1916
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1917 void do_close_all (void)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1918 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1919 wm_iterator win;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1920 for (win = windows.begin (); win != windows.end (); win++)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1921 delete win->second;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1922 windows.clear ();
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1923 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1924
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1925 void do_new_window (figure::properties& fp)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1926 {
13798
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1927 int idx = figprops2idx (fp);
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1928
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1929 if (idx >= 0 && windows.find (idx) == windows.end ())
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1930 {
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1931 Matrix pos = fp.get_outerposition ().matrix_value ();
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1932 bool internal = false;
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1933 // check if figure::properties::outerposition is default -1.0
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1934 if (pos(2) != -1.0 && pos(3) != -1.0)
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1935 {
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1936 pos = fp.get_boundingbox (internal);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1937 }
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1938 else
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1939 {
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1940 // use position
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1941 internal = true;
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1942 pos = fp.get_boundingbox (internal);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
1943 }
13798
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1944
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1945 idx2figprops (curr_index, fp);
13798
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1946
19861
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1947 windows[curr_index++] = new plot_window (pos(0), pos(1), pos(2), pos(3),
19755f4fc851 maint: Cleanup C++ code to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19758
diff changeset
1948 fp, internal);
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1949 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1950 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1951
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1952 void do_delete_window (int idx)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1953 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1954 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1955
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1956 if (win != windows.end ())
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1957 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1958 delete win->second;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1959 windows.erase (win);
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1960 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1961 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
1962
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1963 void do_renumber_figure (int idx, double new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1964 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1965 wm_iterator win = windows.find (idx);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1966
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1967 if (win != windows.end ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1968 win->second->renumber (new_number);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1969 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1970
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1971 void do_toggle_window_visibility (int idx, bool is_visible)
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1972 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1973 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1974
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1975 if (win != windows.end ())
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1976 {
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1977 if (is_visible)
19453
728873ccd637 Show canvas if figure was created with visible off (bug #41895)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19296
diff changeset
1978 {
728873ccd637 Show canvas if figure was created with visible off (bug #41895)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19296
diff changeset
1979 win->second->show ();
728873ccd637 Show canvas if figure was created with visible off (bug #41895)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19296
diff changeset
1980 win->second->show_canvas ();
728873ccd637 Show canvas if figure was created with visible off (bug #41895)
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19296
diff changeset
1981 }
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1982 else
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1983 win->second->hide ();
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1984
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1985 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1986 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1987
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1988 void do_toggle_menubar_visibility (int fig_idx, bool menubar_is_figure)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1989 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1990 wm_iterator win = windows.find (fig_idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1991
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1992 if (win != windows.end ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1993 {
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
1994 if (menubar_is_figure)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1995 win->second->show_menubar ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1996 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1997 win->second->hide_menubar ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1998
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1999 win->second->redraw ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2000 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2001 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2002
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2003 void do_mark_modified (int idx)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2004 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2005 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2006
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2007 if (win != windows.end ())
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2008 {
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2009 win->second->mark_modified ();
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2010 }
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2011 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2012
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
2013 void do_set_name (int idx)
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
2014 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2015 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2016
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2017 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2018 win->second->set_name ();
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
2019 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
2020
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2021 Matrix do_get_size (int idx)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2022 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2023 Matrix sz (1, 2, 0.0);
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2024
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2025 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2026
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2027 if (win != windows.end ())
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2028 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2029 sz(0) = win->second->w ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2030 sz(1) = win->second->h ();
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2031 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2032
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2033 return sz;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2034 }
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2035
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
2036 void do_print (int idx, const std::string& cmd, const std::string& term)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
2037 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2038 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2039
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2040 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2041 win->second->print (cmd, term);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
2042 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
2043
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2044 void do_uimenu_update (int idx, const graphics_handle& gh, int id)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2045 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2046 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2047
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2048 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2049 win->second->uimenu_update (gh, id);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2050 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2051
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2052 void do_update_canvas (int idx, const graphics_handle& ca)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2053 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2054 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2055
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2056 if (win != windows.end ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2057 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2058 if (ca.ok ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2059 win->second->show_canvas ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2060 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2061 win->second->hide_canvas ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2062 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2063 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2064
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2065 void do_update_boundingbox (int idx, bool internal)
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2066 {
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2067 wm_iterator win = windows.find (idx);
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2068
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2069 if (win != windows.end ())
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2070 win->second->update_boundingbox (internal);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2071 }
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2072
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2073 static int str2idx (const caseless_str& clstr)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2074 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2075 int ind;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2076 if (clstr.find (fltk_idx_header,0) == 0)
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2077 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2078 std::istringstream istr (clstr.substr (fltk_idx_header.size ()));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2079 if (istr >> ind)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2080 return ind;
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2081 }
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
2082
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2083 error ("figure_manager: could not recognize fltk index");
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2084 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2085
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2086 void idx2figprops (int idx, figure::properties& fp)
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2087 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2088 std::ostringstream ind_str;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2089 ind_str << fltk_idx_header << idx;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2090 fp.set___plot_stream__ (ind_str.str ());
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2091 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2092
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2093 static int figprops2idx (const figure::properties& fp)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2094 {
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2095 if (fp.get___graphics_toolkit__ () == FLTK_GRAPHICS_TOOLKIT_NAME)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2096 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2097 octave_value ps = fp.get___plot_stream__ ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2098 if (ps.is_string ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2099 return str2idx (ps.string_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2100 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2101 return 0;
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2102 }
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
2103
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2104 error ("figure_manager: figure is not fltk");
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2105 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2106
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2107 static int hnd2idx (double h)
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2108 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2109 graphics_object fobj = gh_manager::get_object (h);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2110 if (fobj && fobj.isa ("figure"))
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2111 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2112 figure::properties& fp =
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2113 dynamic_cast<figure::properties&> (fobj.get_properties ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2114 return figprops2idx (fp);
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2115 }
20825
66cd994d1b79 eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents: 20711
diff changeset
2116
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2117 error ("figure_manager: H (= %g) is not a figure", h);
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2118 }
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2119
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2120 static int hnd2idx (const graphics_handle& fh)
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2121 {
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2122 return hnd2idx (fh.value ());
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2123 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2124 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2125
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2126 figure_manager *figure_manager::instance = 0;
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2127
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2128 std::string figure_manager::fltk_idx_header="fltk index=";
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
2129 int figure_manager::curr_index = 1;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2130
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
2131 static bool toolkit_loaded = false;
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
2132
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2133 class fltk_graphics_toolkit : public base_graphics_toolkit
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2134 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2135 public:
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2136 fltk_graphics_toolkit (void)
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2137 : base_graphics_toolkit (FLTK_GRAPHICS_TOOLKIT_NAME),
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2138 input_event_hook_fcn_id ()
19012
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
2139 {
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
2140 Fl::visual (FL_RGB);
7f73293d8423 Revise FLTK keypressfcn and keyreleasefcn callbacks
Andreas Weber <andy.weber.aw@gmail.com>
parents: 19010
diff changeset
2141 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2142
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2143 ~fltk_graphics_toolkit (void) { }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2144
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2145 bool is_valid (void) const { return true; }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2146
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12968
diff changeset
2147 bool initialize (const graphics_object& go)
17079
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2148 {
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2149 if (go.isa ("figure")
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2150 || go.isa ("uimenu"))
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2151 {
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2152 if (go.isa ("uimenu"))
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2153 update (go, uimenu::properties::ID_LABEL);
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2154
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2155 return true;
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2156 }
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2157
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2158 return false;
7a67ab7c4771 Initialize uimenu objects for the fltk toolkit.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 16871
diff changeset
2159 }
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12968
diff changeset
2160
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10972
diff changeset
2161 void finalize (const graphics_object& go)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2162 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2163 if (go.isa ("figure"))
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2164 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2165 octave_value ov = go.get (caseless_str ("__plot_stream__"));
10972
14d16530ad59 fltk_backend::object_destroyed: don't call delete_window if __plot_stream__ is empty
John W. Eaton <jwe@octave.org>
parents: 10955
diff changeset
2166
14d16530ad59 fltk_backend::object_destroyed: don't call delete_window if __plot_stream__ is empty
John W. Eaton <jwe@octave.org>
parents: 10955
diff changeset
2167 if (! ov.is_empty ())
14d16530ad59 fltk_backend::object_destroyed: don't call delete_window if __plot_stream__ is empty
John W. Eaton <jwe@octave.org>
parents: 10955
diff changeset
2168 figure_manager::delete_window (ov.string_value ());
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2169 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2170 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2171
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2172 void uimenu_set_fltk_label (graphics_object uimenu_obj)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2173 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2174 if (uimenu_obj.valid_object ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2175 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2176 uimenu::properties& uimenup =
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2177 dynamic_cast<uimenu::properties&> (uimenu_obj.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2178 std::string fltk_label = uimenup.get_label ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2179 graphics_object go = gh_manager::get_object (uimenu_obj.get_parent ());
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2180 if (go.isa ("uimenu"))
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2181 fltk_label = dynamic_cast<const uimenu::properties&>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2182 (go.get_properties ()).get_fltk_label ()
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2183 + "/"
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2184 + fltk_label;
20108
de1377a638d7 Let annotation work with fltk again
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 20061
diff changeset
2185 else if (go.isa ("figure") || go.isa ("uicontextmenu"))
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2186 ;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2187 else
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20428
diff changeset
2188 error ("invalid parent object\n");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2189
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2190 uimenup.set_fltk_label (fltk_label);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2191 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2192 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2193
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10972
diff changeset
2194 void update (const graphics_object& go, int id)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2195 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2196 if (go.isa ("figure"))
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2197 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2198 octave_value ov = go.get (caseless_str ("__plot_stream__"));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2199
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2200 if (! ov.is_empty ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2201 {
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
2202 const figure::properties& fp =
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
2203 dynamic_cast<const figure::properties&> (go.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2204
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2205 switch (id)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2206 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2207 case base_properties::ID_VISIBLE:
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2208 figure_manager::toggle_window_visibility (ov.string_value (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2209 fp.is_visible ());
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2210 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2211
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2212 case figure::properties::ID_MENUBAR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2213 figure_manager::toggle_menubar_visibility
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2214 (ov.string_value (), fp.menubar_is ("figure"));
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2215 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2216
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2217 case figure::properties::ID_CURRENTAXES:
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2218 figure_manager::update_canvas (go.get_handle (),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2219 fp.get_currentaxes ());
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2220 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2221
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2222 case figure::properties::ID_NAME:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2223 case figure::properties::ID_NUMBERTITLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2224 figure_manager::set_name (ov.string_value ());
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2225 break;
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2226
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2227 case figure::properties::ID_INTEGERHANDLE:
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2228 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2229 std::string tmp = ov.string_value ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2230 graphics_handle gh = fp.get___myhandle__ ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2231 figure_manager::renumber_figure (tmp, gh.value ());
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2232 figure_manager::set_name (tmp);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2233 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
2234 break;
18961
52e01aa1fe8b Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18958
diff changeset
2235
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2236 case figure::properties::ID_POSITION:
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2237 figure_manager::update_boundingbox (ov.string_value (), true);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2238 break;
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2239
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2240 case figure::properties::ID_OUTERPOSITION:
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2241 figure_manager::update_boundingbox (ov.string_value (), false);
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2242 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2243 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
2244 }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
2245 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2246 else if (go.isa ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2247 {
11239
5fa7667f90e5 Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents: 11224
diff changeset
2248 if (id == uimenu::properties::ID_LABEL)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2249 uimenu_set_fltk_label (go);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2250
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2251 graphics_object fig = go.get_ancestor ("figure");
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
2252 figure_manager::uimenu_update (fig.get_handle (), go.get_handle (), id);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
2253 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2254 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2255
8077
a4e03f9b4b8a Fix FLTK backend update
Michael Goffioul
parents: 8060
diff changeset
2256 void redraw_figure (const graphics_object& go) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2257 {
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2258 // We scan all figures and add those which use FLTK.
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2259 graphics_object obj = gh_manager::get_object (0);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2260 if (obj && obj.isa ("root"))
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2261 {
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2262 base_properties& props = obj.get_properties ();
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2263 Matrix children = props.get_all_children ();
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
2264
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2265 for (octave_idx_type n = 0; n < children.numel (); n++)
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2266 {
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2267 graphics_object fobj = gh_manager::get_object (children (n));
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2268 if (fobj && fobj.isa ("figure"))
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2269 {
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2270 figure::properties& fp =
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2271 dynamic_cast<figure::properties&> (fobj.get_properties ());
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2272 if (fp.get___graphics_toolkit__ ()
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2273 == FLTK_GRAPHICS_TOOLKIT_NAME)
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2274 figure_manager::new_window (fp);
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2275 }
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2276 }
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2277 }
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2278
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2279 figure_manager::mark_modified (go.get_handle ());
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2280 Fl::check ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2281 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2282
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
2283 void print_figure (const graphics_object& go,
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10809
diff changeset
2284 const std::string& term,
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
2285 const std::string& file_cmd, bool /*mono*/,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2286 const std::string& /*debug_file*/) const
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2287 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
2288 figure_manager::print (go.get_handle (), file_cmd, term);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
2289 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2290
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2291 Matrix get_canvas_size (const graphics_handle& fh) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2292 {
8267
f2f1d07a7f0f fltk_backend.cc (class figure_manager): implement in way consistent with other singleton classes in Octave
John W. Eaton <jwe@octave.org>
parents: 8263
diff changeset
2293 return figure_manager::get_size (fh);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2294 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2295
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2296 /*
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2297 double get_screen_resolution (void) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2298 {
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2299 // FLTK doesn't give this info.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2300 return 72.0;
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2301
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2302 // FIXME: FLTK >= 1.3.0 could do this with Fl::screen_dpi (h, v, n)
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2303 // but do we need it?
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2304 }
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2305 */
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2306
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2307 Matrix get_screen_size (void) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2308 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2309 Matrix sz (1, 2, 0.0);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2310 sz(0) = Fl::w ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2311 sz(1) = Fl::h ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2312 return sz;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2313 }
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2314
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2315 void close (void)
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2316 {
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
2317 if (toolkit_loaded)
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2318 {
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2319 munlock ("__init_fltk__");
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2320
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2321 octave_value_list args = input_event_hook_fcn_id;
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2322 args.append (false);
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2323 Fremove_input_event_hook (args, 0);
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2324 input_event_hook_fcn_id = octave_value_list ();
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2325
18958
c9f960441513 Overhaul FLTK plotting and printing
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18678
diff changeset
2326 figure_manager::close_all ();
14014
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2327 }
907d03def9d5 explicitly close figures in clean_up_and_exit instead of using an atexit function
John W. Eaton <jwe@octave.org>
parents: 14002
diff changeset
2328 }
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2329
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2330 void set_input_event_hook_id (const octave_value_list& id)
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2331 {
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2332 input_event_hook_fcn_id = id;
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2333 }
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2334
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2335 private:
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2336 octave_value_list input_event_hook_fcn_id;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2337 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2338
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2339 #endif
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2340
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2341 DEFUN_DLD (__fltk_check__, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2342 "-*- texinfo -*-\n\
20845
0bb9b4e99ea0 __init_fltk__.cc:codesprint: Remove class of fcn and return after error
Andreas Weber <andy.weber.aw@gmail.com>
parents: 20825
diff changeset
2343 @deftypefn {} {} __fltk_check__ ()\n\
19152
0f9c5a15c8fa doc: Periodic grammarcheck of documentation.
Rik <rik@octave.org>
parents: 19028
diff changeset
2344 Undocumented internal function. Calls Fl::check ()\n\
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2345 @end deftypefn")
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2346 {
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2347 #ifdef HAVE_FLTK
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2348 Fl::check ();
20060
76b1168342c0 Redraw FLTK figure after zoom operations on linked axes (bug #44719).
Rik <rik@octave.org>
parents: 20053
diff changeset
2349
76b1168342c0 Redraw FLTK figure after zoom operations on linked axes (bug #44719).
Rik <rik@octave.org>
parents: 20053
diff changeset
2350 if (Vdrawnow_requested)
76b1168342c0 Redraw FLTK figure after zoom operations on linked axes (bug #44719).
Rik <rik@octave.org>
parents: 20053
diff changeset
2351 Fdrawnow ();
20957
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2352
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2353 return ovl ();
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2354 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21021
diff changeset
2355 err_disabled_feature ("__fltk_check__", "OpenGL and FLTK");
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2356 #endif
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2357 }
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2358
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2359 // Initialize the fltk graphics toolkit.
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2360
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2361 DEFUN_DLD (__init_fltk__, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2362 "-*- texinfo -*-\n\
20845
0bb9b4e99ea0 __init_fltk__.cc:codesprint: Remove class of fcn and return after error
Andreas Weber <andy.weber.aw@gmail.com>
parents: 20825
diff changeset
2363 @deftypefn {} {} __init_fltk__ ()\n\
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2364 Undocumented internal function.\n\
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2365 @end deftypefn")
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2366 {
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2367 #ifdef HAVE_FLTK
17881
7aadb87f599a Display warning and don't init FLTK toolkit if no DISPLAY available (bug #40423).
Rik <rik@octave.org>
parents: 17861
diff changeset
2368 if (! display_info::display_available ())
7aadb87f599a Display warning and don't init FLTK toolkit if no DISPLAY available (bug #40423).
Rik <rik@octave.org>
parents: 17861
diff changeset
2369 error ("__init_fltk__: no graphics DISPLAY available");
7aadb87f599a Display warning and don't init FLTK toolkit if no DISPLAY available (bug #40423).
Rik <rik@octave.org>
parents: 17861
diff changeset
2370 else if (! toolkit_loaded)
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2371 {
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
2372 mlock ();
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
2373
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2374 fltk_graphics_toolkit *fltk = new fltk_graphics_toolkit ();
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2375 graphics_toolkit tk (fltk);
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
2376 gtk_manager::load_toolkit (tk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
2377 toolkit_loaded = true;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2378
19010
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2379 octave_value fcn (new octave_builtin (F__fltk_check__));
c3af040956df fix FLTK position/outerposition properties, respect units
Andreas Weber <andy.weber.aw@gmail.com>
parents: 18985
diff changeset
2380 octave_value fcn_handle (new octave_fcn_handle (fcn, "@__fltk_check__"));
16348
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2381 octave_value_list id = Fadd_input_event_hook (fcn_handle, 1);
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2382
072b3e6504c4 use function handle for fltk input event hook function
John W. Eaton <jwe@octave.org>
parents: 15507
diff changeset
2383 fltk->set_input_event_hook_id (id);
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2384 }
20957
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2385
9db35d2042be maint: eliminate special cases of statements after error.
Rik <rik@octave.org>
parents: 20955
diff changeset
2386 return ovl ();
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21021
diff changeset
2387
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2388 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 21021
diff changeset
2389 err_disabled_feature ("__init_fltk__", "OpenGL and FLTK");
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2390 #endif
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2391 }
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2392
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2393 DEFUN_DLD (__have_fltk__, , ,
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
2394 "-*- texinfo -*-\n\
20845
0bb9b4e99ea0 __init_fltk__.cc:codesprint: Remove class of fcn and return after error
Andreas Weber <andy.weber.aw@gmail.com>
parents: 20825
diff changeset
2395 @deftypefn {} {@var{FLTK_available} =} __have_fltk__ ()\n\
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2396 Undocumented internal function.\n\
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2397 @end deftypefn")
15503
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2398 {
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2399 octave_value retval;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2400
15507
b9b9795a7cd9 build: Build FLTK-associated DOCSTRINGS even when HAVE_FLTK is 0 (bug #37541).
Rik <rik@octave.org>
parents: 15506
diff changeset
2401 #ifdef HAVE_FLTK
15503
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2402 retval = true;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2403 #else
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2404 retval = false;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2405 #endif
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2406
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2407 return retval;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2408 }