annotate libinterp/dldfcn/__init_fltk__.cc @ 15503:dca1f2bcccf3

don't register fltk toolkit if compiling without FLTK (bug #37541) * __init_fltk__.cc (F__have_fltk__): New function. Use it in PKG_ADD line to decide whether to register fltk toolkit.
author John W. Eaton <jwe@octave.org>
date Thu, 11 Oct 2012 14:16:10 -0400
parents 2fc554ffbc28
children b3762b89c3c0
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
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14111
diff changeset
3 Copyright (C) 2007-2012 Shai Ayal
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
4
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
5 This file is part of Octave.
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 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
8 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
9 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
10 option) any later version.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
11
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
12 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
13 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
14 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
15 for more details.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
16
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
17 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
18 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
19 <http://www.gnu.org/licenses/>.
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
20
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
21 */
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
22
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
23 /*
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
24
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
25 To initialize:
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
26
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
27 graphics_toolkit ("fltk");
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
28 plot (randn (1e3, 1));
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
29
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
30 */
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
31
15503
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
32 // PKG_ADD: if (__have_fltk__ ()) register_graphics_toolkit ("fltk"); endif
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
33
7874
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
34 #ifdef HAVE_CONFIG_H
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
35 #include <config.h>
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
36 #endif
e3a502930e2a eliminate src/graphics subdirectory
John W. Eaton <jwe@octave.org>
parents: 7869
diff changeset
37
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
38 #include "defun-dld.h"
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
39 #include "error.h"
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
40
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
41 #if defined (HAVE_FLTK)
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
42
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
43 #include <map>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
44 #include <set>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
45 #include <sstream>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
46 #include <iostream>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
47
13721
ca90a6d59ab6 Prevent auto-inclusion of winsock.h in WIN32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
48 #ifdef WIN32
ca90a6d59ab6 Prevent auto-inclusion of winsock.h in WIN32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
49 #define WIN32_LEAN_AND_MEAN
ca90a6d59ab6 Prevent auto-inclusion of winsock.h in WIN32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
50 #endif
ca90a6d59ab6 Prevent auto-inclusion of winsock.h in WIN32.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13281
diff changeset
51
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
52 #include <FL/Fl.H>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
53 #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
54 #include <FL/Fl_Button.H>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
55 #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
56 #include <FL/Fl_File_Chooser.H>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
57 #include <FL/Fl_Gl_Window.H>
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
58 #include <FL/Fl_Menu_Bar.H>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
59 #include <FL/Fl_Menu_Button.H>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
60 #include <FL/Fl_Output.H>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
61 #include <FL/Fl_Window.H>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
62 #include <FL/fl_ask.H>
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
63 #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
64 #include <FL/gl.h>
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
65
12205
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
66 // 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
67 // 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
68 // 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
69 // 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
70 #undef Complex
be90f9e4548e #undef Complex after including FLTK headers
John W. Eaton <jwe@octave.org>
parents: 12183
diff changeset
71
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
72 #include "cmd-edit.h"
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
73 #include "lo-ieee.h"
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
74
11590
4ced6b90fffb style fixes for warning and error messages in source files
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
75 #include "file-ops.h"
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
76 #include "gl-render.h"
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
77 #include "gl2ps-renderer.h"
7954
3ffc34caec65 configure fixes
John W. Eaton <jwe@octave.org>
parents: 7874
diff changeset
78 #include "graphics.h"
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
79 #include "parse.h"
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
80 #include "sysdep.h"
9991
1300d9ced492 F__init_fltk__: add __remove_fltk__ to atexit function list
John W. Eaton <jwe@octave.org>
parents: 9974
diff changeset
81 #include "toplev.h"
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
82 #include "variables.h"
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
83
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
84 #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
85
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
86 // Give FLTK no more than 0.01 sec to do its stuff.
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
87 static double fltk_maxtime = 1e-2;
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
88
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
89 const char* help_text = "\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
90 Keyboard Shortcuts\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
91 a - autoscale\n\
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
92 p - pan/zoom\n\
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
93 r - rotate\n\
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
94 g - toggle grid\n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
95 \n\
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
96 Mouse\n\
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
97 left drag - pan\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
98 mouse wheel - zoom\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
99 right drag - rectangle zoom\n\
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
100 left double click - autoscale\n\
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
101 ";
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
102
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
103 class OpenGL_fltk : public Fl_Gl_Window
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
104 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
105 public:
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
106 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
107 : Fl_Gl_Window (xx, yy, ww, hh, 0), number (num), renderer (),
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
108 in_zoom (false), zoom_box (), print_mode (false)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
109 {
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
110 // Ask for double buffering and a depth buffer.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
111 mode (FL_DEPTH | FL_DOUBLE);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
112 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
113
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
114 ~OpenGL_fltk (void) { }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
115
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
116 void zoom (bool z)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
117 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
118 in_zoom = z;
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
119 if (! in_zoom)
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
120 hide_overlay ();
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
121 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
122
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
123 bool zoom (void) { return in_zoom; }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
124 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
125
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
126 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
127 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
128 print_mode = true;
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
129 print_cmd = cmd;
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10809
diff changeset
130 print_term = term;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
131 }
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
132
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
133 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
134 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
135 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
136 setup_viewport (ww, hh);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
137 redraw ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
138 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
139
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
140 bool renumber (double new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
141 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
142 bool retval = false;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
143
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
144 if (number != new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
145 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
146 number = new_number;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
147 retval = true;
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
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
150 return retval;
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
151 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
152
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
153 private:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
154 double number;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
155 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
156 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
157 // (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
158 Matrix zoom_box;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
159
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
160 bool print_mode;
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
161 std::string print_cmd;
10857
2224236440c0 add more terminal types to gl2ps-renderer
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10809
diff changeset
162 std::string print_term;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
163
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
164 void setup_viewport (int ww, int hh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
165 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
166 glMatrixMode (GL_PROJECTION);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
167 glLoadIdentity ();
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
168 glViewport (0, 0, ww, hh);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
169 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
170
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
171 void draw (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
172 {
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
173 if (! valid ())
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
174 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
175 valid (1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
176 setup_viewport (w (), h ());
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
177 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
178
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
179 if (print_mode)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
180 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
181 FILE *fp = octave_popen (print_cmd.c_str (), "w");
14418
933101fd5cbb Use file descriptor instead of a FILE pointer for OpenGL printing.
John W. Eaton <jwe@octave.org>
parents: 14366
diff changeset
182 glps_renderer rend (fp, print_term);
12323
c8da31f12c1d avoid using new to create temporary gl2ps_renderer object
John W. Eaton <jwe@octave.org>
parents: 12226
diff changeset
183
12324
85934e0fcce9 gl-renderer.cc and gl2ps-renderer.cc: access objects directly from gh_manager instead of working with handles
John W. Eaton <jwe@octave.org>
parents: 12323
diff changeset
184 rend.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
185
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
186 octave_pclose (fp);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
187 print_mode = false;
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
188 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
189 else
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
190 {
12324
85934e0fcce9 gl-renderer.cc and gl2ps-renderer.cc: access objects directly from gh_manager instead of working with handles
John W. Eaton <jwe@octave.org>
parents: 12323
diff changeset
191 renderer.draw (gh_manager::get_object (number));
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
192
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
193 if (zoom ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
194 overlay ();
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
195 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
196 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
197
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
198 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
199 {
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
200 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
201 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
202 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
203 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
204 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
205 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
206
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
207 void overlay (void)
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
208 {
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
209 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
210
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
211 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
212 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
213
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 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
215 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
216 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
217
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 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
219 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
220
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
221 glBegin (GL_POLYGON);
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
222 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
223 zoom_box_vertex ();
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
224 glEnd ();
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
225
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
226 glBegin (GL_LINE_STRIP);
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
227 glLineWidth (1.5);
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
228 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
229 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
230 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
231
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
232 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
233 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
234 }
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
235
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
236 int handle (int event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
237 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
238 int retval = Fl_Gl_Window::handle (event);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
239
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
240 switch (event)
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
241 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
242 case FL_ENTER:
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
243 window ()->cursor (FL_CURSOR_CROSS);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
244 return 1;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
245
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
246 case FL_LEAVE:
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
247 window ()->cursor (FL_CURSOR_DEFAULT);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
248 return 1;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
249 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
250
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
251 return retval;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
252 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
253 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
254
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
255 // Parameter controlling how fast we zoom when using the scrool wheel.
9668
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
256 static double wheel_zoom_speed = 0.05;
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
257 // Parameter controlling the GUI mode.
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
258 static enum { pan_zoom, rotate_zoom, none } gui_mode;
9668
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
259
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
260 void script_cb (Fl_Widget*, void* data)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
261 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
262 static_cast<uimenu::properties*> (data)->execute_callback ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
263 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
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 class fltk_uimenu
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
267 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
268 public:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
269 fltk_uimenu (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
270 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
271 menubar = new
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
272 Fl_Menu_Bar (xx, yy, ww, hh);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
273 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
274
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
275 int items_to_show (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
276 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
277 //returns the number of visible menu items
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
278 int len = menubar->size ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
279 int n = 0;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
280 for (int t = 0; t < len; t++ )
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
281 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
282 const Fl_Menu_Item *m = static_cast<const Fl_Menu_Item*> (&(menubar->menu ()[t]));
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
283 if ((m->label () != NULL) && m->visible ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
284 n++;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
285 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
286
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
287 return n;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
288 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
289
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
290 void show (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
291 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
292 menubar->show ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
293 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
294
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
295 void hide (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
296 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
297 menubar->hide ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
298 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
299
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
300 bool is_visible (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
301 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
302 return menubar->visible ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
303 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
304
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
305 int find_index_by_name (const std::string& findname)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
306 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
307 // This function is derived from Greg Ercolano's function
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
308 // int GetIndexByName(...), see:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
309 // http://seriss.com/people/erco/fltk/#Menu_ChangeLabel
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
310 // He agreed via PM that it can be included in octave using GPLv3
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
311 // Kai Habel (14.10.2010)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
312
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
313 std::string menupath;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
314 for (int t = 0; t < menubar->size (); t++ )
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
315 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
316 Fl_Menu_Item *m = const_cast<Fl_Menu_Item*> (&(menubar->menu ()[t]));
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
317 if (m->submenu ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
318 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
319 // item has submenu
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
320 if (!menupath.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
321 menupath += "/";
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
322 menupath += m->label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
323
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
324 if (menupath.compare (findname) == 0 )
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
325 return (t);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
326 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
327 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
328 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
329 // End of submenu? Pop back one level.
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
330 if (m->label () == NULL)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
331 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
332 std::size_t idx = menupath.find_last_of ("/");
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
333 if (idx != std::string::npos)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
334 menupath.erase (idx);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
335 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
336 menupath.clear ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
337 continue;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
338 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
339 // Menu item?
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
340 std::string itempath = menupath;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
341 if (!itempath.empty ())
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
342 itempath += "/";
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
343 itempath += m->label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
344
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
345 if (itempath.compare (findname) == 0)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
346 return (t);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
347 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
348 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
349 return (-1);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
350 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
351
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
352 Matrix find_uimenu_children (uimenu::properties& uimenup) const
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
353 {
11301
cc9b8cd5aa87 consider hidden handles in uimenu code
Kai Habel <kai.habel@gmx.de>
parents: 11297
diff changeset
354 Matrix uimenu_childs = uimenup.get_all_children ();
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
355 Matrix retval = do_find_uimenu_children (uimenu_childs);
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
356 return retval;
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
357 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
358
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
359 Matrix find_uimenu_children (figure::properties& figp) const
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
360 {
11301
cc9b8cd5aa87 consider hidden handles in uimenu code
Kai Habel <kai.habel@gmx.de>
parents: 11297
diff changeset
361 Matrix uimenu_childs = figp.get_all_children ();
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
362 Matrix retval = do_find_uimenu_children (uimenu_childs);
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
363 return retval;
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
364 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
365
11170
a2437f70fe6c Remove template to allow compilation for MacOS
Kai Habel <kai.habel@gmx.de>
parents: 11155
diff changeset
366 Matrix do_find_uimenu_children (Matrix uimenu_childs) const
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
367 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
368 octave_idx_type k = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
369
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
370
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
371 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
372
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
373 for (octave_idx_type ii = 0; ii < uimenu_childs.numel (); ii++)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
374 {
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
375 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
376
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
377 if (kidgo.valid_object () && kidgo.isa ("uimenu"))
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
378 {
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
379 uimenu_childs(k) = uimenu_childs(ii);
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
380 pos(k++) =
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
381 dynamic_cast<uimenu::properties&> (kidgo.get_properties ()).get_position ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
382 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
383 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
384
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
385 uimenu_childs.resize (k, 1);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
386 pos.resize (k, 1);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
387 Matrix retval = Matrix (k, 1);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
388 // Don't know if this is the best method to sort.
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
389 // Can we avoid the for loop?
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
390 Array<octave_idx_type> sidx = pos.sort_rows_idx (DESCENDING);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
391 for (octave_idx_type ii = 0; ii < k; ii++)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
392 retval(ii) = uimenu_childs (sidx(ii));
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
393
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
394 return retval;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
395 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
396
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
397 void delete_entry (uimenu::properties& uimenup)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
398 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
399 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
400 int idx = find_index_by_name (fltk_label.c_str ());
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
401
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
402 if (idx >= 0)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
403 menubar->remove (idx);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
404 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
405
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
406 void update_accelerator (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
407 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
408 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
409 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
410 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
411 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ()));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
412 if (item != NULL)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
413 {
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
414 std::string acc = uimenup.get_accelerator ();
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
415 if (acc.length () > 0)
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
416 {
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
417 int key = FL_CTRL + acc[0];
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
418 item->shortcut (key);
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
419 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
420 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
421 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
422 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
423
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
424 void update_callback (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
425 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
426 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
427 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
428 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
429 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ()));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
430 if (item != NULL)
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
431 {
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
432 if (!uimenup.get_callback ().is_empty ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
433 item->callback (static_cast<Fl_Callback*> (script_cb),
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
434 static_cast<void*> (&uimenup));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
435 else
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
436 item->callback (NULL, static_cast<void*> (0));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
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 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
440
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
441 void update_enable (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
442 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
443 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
444 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
445 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
446 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ()));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
447 if (item != NULL)
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
448 {
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
449 if (uimenup.is_enable ())
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
450 item->activate ();
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
451 else
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
452 item->deactivate ();
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
453 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
454 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
455 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
456
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
457 void update_foregroundcolor (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
458 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
459 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
460 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
461 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
462 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ()));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
463 if (item != NULL)
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
464 {
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
465 Matrix rgb = uimenup.get_foregroundcolor_rgb ();
12539
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
466
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
467 uchar r = static_cast<uchar> (gnulib::floor (rgb (0) * 255));
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
468 uchar g = static_cast<uchar> (gnulib::floor (rgb (1) * 255));
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
469 uchar b = static_cast<uchar> (gnulib::floor (rgb (2) * 255));
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
470
ccd0572e5e93 use gnulib:: functions as needed
John W. Eaton <jwe@octave.org>
parents: 12507
diff changeset
471 item->labelcolor (fl_rgb_color (r, g, b));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
472 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
473 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
474 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
475
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
476 void update_seperator (const uimenu::properties& uimenup)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
477 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
478 // Matlab places the separator before the current
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
479 // menu entry, while fltk places it after. So we need to find
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
480 // the previous item in this menu/submenu. (Kai)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
481 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
482 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
483 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
484 int itemflags = 0, idx;
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
485 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
486
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
487 for (idx = curr_idx - 1; idx >= 0; idx--)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
488 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
489 Fl_Menu_Item* item = const_cast<Fl_Menu_Item*> (&menubar->menu () [idx]);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
490 itemflags = item->flags;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
491 if (item->label () != NULL)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
492 break;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
493 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
494
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
495 if (idx >= 0 && idx < menubar->size ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
496 {
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
497 if (uimenup.is_separator ())
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
498 {
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
499 if (idx >= 0 && !(itemflags & FL_SUBMENU))
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
500 menubar->mode (idx, itemflags | FL_MENU_DIVIDER);
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
501 }
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
502 else
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
503 menubar->mode (idx, itemflags & (~FL_MENU_DIVIDER));
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
504 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
505 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
506 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
507
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
508 void update_visible (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
509 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
510 std::string fltk_label = uimenup.get_fltk_label ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
511 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
512 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
513 Fl_Menu_Item* item
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
514 = const_cast<Fl_Menu_Item*> (menubar->find_item (fltk_label.c_str ()));
11224
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
515 if (item != NULL)
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
516 {
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
517 if (uimenup.is_visible ())
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
518 item->show ();
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
519 else
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
520 item->hide ();
e0db3f9e9267 Add more checks for uimeu
Kai Habel <kai.habel@gmx.de>
parents: 11207
diff changeset
521 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
522 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
523 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
524
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
525 void add_entry (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
526 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
527
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
528 std::string fltk_label = uimenup.get_fltk_label ();
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
529
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
530 if (!fltk_label.empty ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
531 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
532 bool item_added = false;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
533 do
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
534 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
535 const Fl_Menu_Item* item
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
536 = 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
537
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
538 if (item == NULL)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
539 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
540 Matrix uimenu_ch = find_uimenu_children (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
541 int len = uimenu_ch.numel ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
542 int flags = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
543 if (len > 0)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
544 flags = FL_SUBMENU;
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
545 if (len == 0 && uimenup.is_checked ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
546 flags += FL_MENU_TOGGLE + FL_MENU_VALUE;
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
547 menubar->add (fltk_label.c_str (), 0, 0, 0, flags);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
548 item_added = true;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
549 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
550 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
551 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
552 //avoid duplicate menulabels
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
553 std::size_t idx1 = fltk_label.find_last_of ("(");
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
554 std::size_t idx2 = fltk_label.find_last_of (")");
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
555 int len = idx2 - idx1;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
556 int val = 1;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
557 if (len > 0)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
558 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
559 std::string valstr = fltk_label.substr (idx1 + 1, len - 1);
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
560 fltk_label.erase (idx1, len + 1);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
561 val = atoi (valstr.c_str ());
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
562 if (val > 0 && val < 99)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
563 val++;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
564 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
565 std::ostringstream valstream;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
566 valstream << val;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
567 fltk_label += "(" + valstream.str () + ")";
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
568 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
569 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
570 while (!item_added);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
571 uimenup.set_fltk_label (fltk_label);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
572 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
573 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
574
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
575 void add_to_menu (uimenu::properties& uimenup)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
576 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
577 Matrix kids = find_uimenu_children (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
578 int len = kids.length ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
579 std::string fltk_label = uimenup.get_fltk_label ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
580
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
581 add_entry (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
582 update_foregroundcolor (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
583 update_callback (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
584 update_accelerator (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
585 update_enable (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
586 update_visible (uimenup);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
587 update_seperator (uimenup);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
588
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
589 for (octave_idx_type ii = 0; ii < len; ii++)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
590 {
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
591 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1)));
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
592 if (kgo.valid_object ())
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
593 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
594 uimenu::properties& kprop = dynamic_cast<uimenu::properties&> (kgo.get_properties ());
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
595 add_to_menu (kprop);
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
596 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
597 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
598 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
599
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
600 void add_to_menu (figure::properties& figp)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
601 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
602 Matrix kids = find_uimenu_children (figp);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
603 int len = kids.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
604 menubar->clear ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
605 for (octave_idx_type ii = 0; ii < len; ii++)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
606 {
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
607 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1)));
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
608
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
609 if (kgo.valid_object ())
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
610 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
611 uimenu::properties& kprop = dynamic_cast<uimenu::properties&> (kgo.get_properties ());
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
612 add_to_menu (kprop);
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
613 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
614 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
615 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
616
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
617 template <class T_prop>
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
618 void remove_from_menu (T_prop& prop)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
619 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
620 Matrix kids;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
621 std::string type = prop.get_type ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
622 kids = find_uimenu_children (prop);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
623 int len = kids.length ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
624
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
625 for (octave_idx_type ii = 0; ii < len; ii++)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
626 {
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
627 graphics_object kgo = gh_manager::get_object (kids (len - (ii + 1)));
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
628
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
629 if (kgo.valid_object ())
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
630 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
631 uimenu::properties kprop = dynamic_cast<uimenu::properties&> (kgo.get_properties ());
11207
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
632 remove_from_menu (kprop);
51e6ac3e5afc Code fixes for uimenu
Kai Habel <kai.habel@gmx.de>
parents: 11170
diff changeset
633 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
634 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
635
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
636 if (type.compare ("uimenu") == 0)
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
637 delete_entry (dynamic_cast<uimenu::properties&> (prop));
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
638 else if (type.compare ("figure") == 0)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
639 menubar->clear ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
640 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
641
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
642 ~fltk_uimenu (void)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
643 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
644 delete menubar;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
645 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
646
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
647 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
648
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
649 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
650
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
651 fltk_uimenu (const fltk_uimenu&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
652
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
653 fltk_uimenu operator = (const fltk_uimenu&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
654
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
655 Fl_Menu_Bar* menubar;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
656 };
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
657
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
658 class plot_window : public Fl_Window
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
659 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
660 friend class fltk_uimenu;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
661 public:
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
662 plot_window (int xx, int yy, int ww, int hh, figure::properties& xfp)
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
663 : Fl_Window (xx, yy, ww, hh, "octave"), window_label (), shift (0),
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
664 ndim (2), fp (xfp), canvas (0), autoscale (0), togglegrid (0),
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
665 panzoom (0), rotate (0), help (0), status (0),
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
666 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
667 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
668 callback (window_close, static_cast<void*> (this));
12465
6b2abcd20fef Call size_range early to allow window resizing for MinGW and MacOS
Kai Habel <kai.habel@gmx.de>
parents: 12449
diff changeset
669 size_range (4*status_h, 2*status_h);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
670
14447
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
671 // 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
672 // 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
673 // 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
674 // 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
675 // 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
676 // 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
677 //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
678
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
679 begin ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
680 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
681
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
682 canvas = new OpenGL_fltk (0, 0, ww, hh - status_h, number ());
12621
c99d6785a27e instantiate canvas before menubar
Kai Habel <kai.habel@gmx.de>
parents: 12565
diff changeset
683
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
684 uimenu = new fltk_uimenu (0, 0, ww, menu_h);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
685 uimenu->hide ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
686
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
687 bottom = new Fl_Box (0, hh - status_h, ww, status_h);
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
688 bottom->box (FL_FLAT_BOX);
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
689
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
690 ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ()));
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
691
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
692 autoscale = new Fl_Button (0, hh - status_h, status_h, status_h, "A");
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
693 autoscale->callback (button_callback, static_cast<void*> (this));
10809
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
694 autoscale->tooltip ("Autoscale");
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
695
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
696 togglegrid = new Fl_Button (status_h, hh - status_h, status_h,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
697 status_h, "G");
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
698 togglegrid->callback (button_callback, static_cast<void*> (this));
10809
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
699 togglegrid->tooltip ("Toggle Grid");
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
700
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
701 panzoom = new Fl_Button (2 * status_h, hh - status_h, status_h,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
702 status_h, "P");
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
703 panzoom->callback (button_callback, static_cast<void*> (this));
10809
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
704 panzoom->tooltip ("Mouse Pan/Zoom");
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
705
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
706 rotate = new Fl_Button (3 * status_h, hh - status_h, status_h,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
707 status_h, "R");
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
708 rotate->callback (button_callback, static_cast<void*> (this));
10809
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
709 rotate->tooltip ("Mouse Rotate");
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
710
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
711 if (ndim == 2)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
712 rotate->deactivate ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
713
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
714 help = new Fl_Button (4 * status_h, hh - status_h, status_h,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
715 status_h, "?");
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
716 help->callback (button_callback, static_cast<void*> (this));
10809
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
717 help->tooltip ("Help");
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
718
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
719 status = new Fl_Output (5 * status_h, hh - status_h,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
720 ww > 2*status_h ? ww - status_h : 0,
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
721 status_h, "");
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
722
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
723 status->textcolor (FL_BLACK);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
724 status->color (FL_GRAY);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
725 status->textfont (FL_COURIER);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
726 status->textsize (10);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
727 status->box (FL_ENGRAVED_BOX);
12507
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
728
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
729 // This allows us to have a valid OpenGL context right away.
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
730 canvas->mode (FL_DEPTH | FL_DOUBLE );
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
731 if (fp.is_visible ())
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
732 {
14447
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
733 // FIXME: This code should be removed when Octave drops support
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
734 // for FLTK 1.1. Search for default_xclass in this file to find
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
735 // code that should be uncommented to take its place.
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
736 //
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
737 // Set WM_CLASS which allows window managers to properly group
c97416a0f657 Allow window managers to group FLTK plot windows (bug #35199)
Colin Macdonald <macdonald@maths.ox.ac.uk>
parents: 14418
diff changeset
738 // related 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
739 xclass ("Octave");
12507
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
740 show ();
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14447
diff changeset
741 if (fp.get_currentaxes ().ok ())
12507
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
742 show_canvas ();
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
743 else
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
744 hide_canvas ();
41d183070c04 revert changes from 2011-02-26
Konstantinos Poulios <logari81@googlemail.com>
parents: 12484
diff changeset
745 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
746 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
747 end ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
748
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
749 status->show ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
750 autoscale->show ();
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
751 togglegrid->show ();
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
752 panzoom->show ();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
753 rotate->show ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
754
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
755 set_name ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
756 resizable (canvas);
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
757 gui_mode = (ndim == 3 ? rotate_zoom : pan_zoom);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
758 uimenu->add_to_menu (fp);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
759 if (uimenu->items_to_show ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
760 show_menubar ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
761 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
762 hide_menubar ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
763 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
764
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
765 ~plot_window (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
766 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
767 canvas->hide ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
768 status->hide ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
769 uimenu->hide ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
770 this->hide ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
771 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
772
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
773 double number (void) { return fp.get___myhandle__ ().value (); }
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
774
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
775 void renumber (double new_number)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
776 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
777 if (canvas)
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
778 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
779 if (canvas->renumber (new_number))
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
780 mark_modified ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
781 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
782 else
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
783 error ("unable to renumber figure");
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
784 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
785
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
786 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
787 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
788 canvas->print (cmd, term);
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
789
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
790 // Print immediately so the output file will exist when the drawnow
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
791 // command is done.
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
792 mark_modified ();
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
793 Fl::wait (fltk_maxtime);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
794 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
795
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
796 void show_menubar (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
797 {
12484
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
798 if (!uimenu->is_visible ())
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
799 {
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
800 canvas->resize (canvas->x (),
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
801 canvas->y () + menu_h,
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
802 canvas->w (),
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
803 canvas->h () - menu_h);
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
804 uimenu->show ();
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
805 mark_modified ();
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
806 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
807 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
808
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
809 void hide_menubar (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
810 {
12484
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
811 if (uimenu->is_visible ())
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
812 {
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
813 canvas->resize (canvas->x (),
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
814 canvas->y () - menu_h,
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
815 canvas->w (),
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
816 canvas->h () + menu_h);
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
817 uimenu->hide ();
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
818 mark_modified ();
9c831d357e6f fix initial canvas size issue
Konstantinos Poulios <logari81@googlemail.com>
parents: 12465
diff changeset
819 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
820 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
821
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
822 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
823 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
824 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
825
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
826 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
827 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
828 uimenu::properties& uimenup =
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
829 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
830 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
831 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
832 figure::properties& figp =
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
833 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
834
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
835 switch (id)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
836 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
837 case base_properties::ID_BEINGDELETED:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
838 uimenu->remove_from_menu (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
839 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
840
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
841 case base_properties::ID_VISIBLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
842 uimenu->update_visible (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
843 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
844
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
845 case uimenu::properties::ID_ACCELERATOR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
846 uimenu->update_accelerator (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
847 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
848
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
849 case uimenu::properties::ID_CALLBACK:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
850 uimenu->update_callback (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
851 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
852
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
853 case uimenu::properties::ID_CHECKED:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
854 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
855 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
856
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
857 case uimenu::properties::ID_ENABLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
858 uimenu->update_enable (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
859 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
860
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
861 case uimenu::properties::ID_FOREGROUNDCOLOR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
862 uimenu->update_foregroundcolor (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
863 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
864
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
865 case uimenu::properties::ID_LABEL:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
866 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
867 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
868
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
869 case uimenu::properties::ID_POSITION:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
870 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
871 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
872
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
873 case uimenu::properties::ID_SEPARATOR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
874 uimenu->update_seperator (uimenup);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
875 break;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
876 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
877
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
878 if (uimenu->items_to_show ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
879 show_menubar ();
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
880 else
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
881 hide_menubar ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
882
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14447
diff changeset
883 mark_modified ();
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
884 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
885 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
886
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
887 void show_canvas (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
888 {
12903
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
889 if (fp.is_visible ())
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
890 {
35ea8b9b2a8e __init_fltk__.cc: show canvas only, when figure is visible (bug #33321)
Kai Habel <kai.habel@gmx.de>
parents: 12621
diff changeset
891 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
892 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
893 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
894 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
895
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
896 void hide_canvas (void)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
897 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
898 canvas->hide ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
899 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
900
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
901 void mark_modified (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
902 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
903 damage (FL_DAMAGE_ALL);
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
904 canvas->damage (FL_DAMAGE_ALL);
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
905 ndim = calc_dimensions (gh_manager::get_object (fp.get___myhandle__ ()));
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
906
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
907 if (ndim == 3)
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
908 rotate->activate ();
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
909 else if (ndim == 2 && gui_mode == rotate_zoom)
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
910 {
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
911 rotate->deactivate ();
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
912 gui_mode = pan_zoom;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
913 }
7840
2c8f693c32fd convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents: 7839
diff changeset
914 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
915
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
916 void set_name (void)
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
917 {
10009
360de61b2722 corrected redundency in title setting introduced in previous changeset
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10008
diff changeset
918 window_label = fp.get_title ();
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
919 label (window_label.c_str ());
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
920 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
921
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
922 private:
12122
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
923
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
924 // No copying!
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
925
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
926 plot_window (const plot_window&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
927
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
928 plot_window& operator = (const plot_window&);
f4689107dd8c Explicitly disallow copying in some classes.
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11590
diff changeset
929
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
930 // 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
931 // life
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
932 std::string window_label;
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
933
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
934 // Mod keys status
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
935 int shift;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
936
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
937 // Number of dimensions, 2 or 3.
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
938 int ndim;
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
939
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
940 // 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
941 figure::properties& fp;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
942
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
943 // Status area height.
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
944 static const int status_h = 20;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
945
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
946 // Menu height
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
947 static const int menu_h = 20;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
948
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
949 // Window callback.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
950 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
951 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
952 octave_value_list args;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
953 args(0) = static_cast<plot_window*> (data)->number ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
954 feval ("close", args);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
955 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
956
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
957 // Button callbacks.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
958 static void button_callback (Fl_Widget* ww, void* data)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
959 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
960 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
961 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
962
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
963 void button_press (Fl_Widget* widg, void*)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
964 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
965 if (widg == autoscale)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
966 axis_auto ();
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
967
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
968 if (widg == togglegrid)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
969 toggle_grid ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
970
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
971 if (widg == panzoom)
10797
d479134f59de fltk_backend.cc: use enum for plot_window::gui_mode instead of int
John W. Eaton <jwe@octave.org>
parents: 10792
diff changeset
972 gui_mode = pan_zoom;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
973
10917
888c75785221 Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents: 10865
diff changeset
974 if (widg == rotate && ndim == 3)
10797
d479134f59de fltk_backend.cc: use enum for plot_window::gui_mode instead of int
John W. Eaton <jwe@octave.org>
parents: 10792
diff changeset
975 gui_mode = rotate_zoom;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
976
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
977 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
978 fl_message ("%s", help_text);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
979 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
980
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
981 fltk_uimenu* uimenu;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
982 OpenGL_fltk* canvas;
10809
85cbd239fce2 try a better status bar for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10797
diff changeset
983 Fl_Box* bottom;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
984 Fl_Button* autoscale;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
985 Fl_Button* togglegrid;
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
986 Fl_Button* panzoom;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
987 Fl_Button* rotate;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
988 Fl_Button* help;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
989 Fl_Output* status;
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
990 graphics_object ax_obj;
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
991 int pos_x;
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
992 int pos_y;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
993
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
994 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
995 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
996 octave_value_list args;
9974
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
997 args(0) = fp.get_currentaxes ().as_octave_value ();
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
998 args(1) = "auto";
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
999 feval ("axis", args);
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
1000 mark_modified ();
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
1001 }
4dc3e0ff730a Added zoombox (mouse button 1) & autoscale (button marked A and mouse button 3)
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7842
diff changeset
1002
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1003 void toggle_grid (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1004 {
9974
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
1005 octave_value_list args;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1006 if (fp.get_currentaxes ().ok ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1007 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
1008
9974
118158f10628 fix fltk backend window buttons
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9973
diff changeset
1009 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
1010 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
1011 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1012
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1013 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
1014 double& yy) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1015 {
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1016 pixel2pos ( gh_manager::get_object (ax), px, py, xx, yy);
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1017 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1018
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1019 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
1020 double& yy) const
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1021 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1022 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
1023 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1024 axes::properties& ap =
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1025 dynamic_cast<axes::properties&> (ax.get_properties ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1026 ColumnVector pp = ap.pixel2coord (px, py);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1027 xx = pp(0);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1028 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
1029 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1030 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1031
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1032 graphics_handle pixel2axes_or_ca (int px, int py )
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1033 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1034 Matrix kids = fp.get_children ();
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1035 int len = kids.length ();
9442
2d73b19c5507 improve behavior of builtin
John W. Eaton <jwe@octave.org>
parents: 9245
diff changeset
1036
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1037 for (int k = 0; k < len; k++)
9443
8f9d8776d11c undo previous commit
John W. Eaton <jwe@octave.org>
parents: 9442
diff changeset
1038 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1039 graphics_handle hnd = gh_manager::lookup (kids(k));
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1040
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1041 if (hnd.ok ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1042 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1043 graphics_object kid = gh_manager::get_object (hnd);
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1044
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1045 if (kid.valid_object () && kid.isa ("axes"))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1046 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1047 Matrix bb = kid.get_properties ().get_boundingbox (true);
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
1048
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1049 if (bb(0) <= px && px < (bb(0)+bb(2))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1050 && bb(1) <= py && py < (bb(1)+bb(3)))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1051 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1052 return hnd;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1053 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1054 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1055 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1056 }
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1057 return fp.get_currentaxes ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1058 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1059
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1060 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
1061 int px1 = -1, int py1 = -1)
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1062 {
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1063 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
1064 }
9802
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
1065
9b4a301d88ed fix for fltk zoom box problems
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9798
diff changeset
1066 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
1067 int px1 = -1, int py1 = -1)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1068 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1069 double x0, y0, 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
1070 std::stringstream cbuf;
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1071 cbuf.precision (4);
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1072 cbuf.width (6);
9640
110863cd3371 more bug fixes in fltk zoom
shaiay@users.sourceforge.net
parents: 9455
diff changeset
1073 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
1074 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
1075 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
1076 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1077 pixel2pos (ax, px1, py1, x1, y1);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1078 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
1079 }
7840
2c8f693c32fd convert_position not static anymore
Shai Ayal <shaiay@sourceforge.net>
parents: 7839
diff changeset
1080
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
1081 status->value (cbuf.str ().c_str ());
1357bcae6e29 added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7841
diff changeset
1082 status->redraw ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1083 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1084
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1085 void view2status (graphics_object ax)
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1086 {
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1087 if (ax && ax.isa ("axes"))
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1088 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1089 axes::properties& ap =
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1090 dynamic_cast<axes::properties&> (ax.get_properties ());
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1091 std::stringstream cbuf;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1092 cbuf.precision (4);
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1093 cbuf.width (6);
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1094 Matrix v (1,2,0);
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1095 v = ap.get ("view").matrix_value ();
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1096 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
1097
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1098 status->value (cbuf.str ().c_str ());
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1099 status->redraw ();
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1100 }
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1101 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1102
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1103 void set_currentpoint (int px, int py)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1104 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1105 if (!fp.is_beingdeleted ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1106 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1107 Matrix pos (1,2,0);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1108 pos(0) = px;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1109 pos(1) = h () - status_h - menu_h - py;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1110 fp.set_currentpoint (pos);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1111 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1112 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1113
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1114 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
1115 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1116 if (ax.valid_object ())
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1117 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1118 axes::properties& ap =
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1119 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
1120
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1121 double xx, yy;
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1122 pixel2pos (ax, px, py, xx, yy);
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1123
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1124 Matrix pos (2,3,0);
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1125 pos(0,0) = xx;
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1126 pos(1,0) = yy;
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1127 pos(0,1) = xx;
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1128 pos(1,1) = yy;
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1129
10593
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1130 ap.set_currentpoint (pos);
26d51c6e1c4c fixed fltk_backend bug when clicking on empty figure
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10555
diff changeset
1131 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1132 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1133
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1134 int key2shift (int key)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1135 {
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1136 if (key == FL_Shift_L || key == FL_Shift_R)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1137 return FL_SHIFT;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1138
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1139 if (key == FL_Control_L || key == FL_Control_R)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1140 return FL_CTRL;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1141
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1142 if (key == FL_Alt_L || key == FL_Alt_R)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1143 return FL_ALT;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1144
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1145 if (key == FL_Meta_L || key == FL_Meta_R)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1146 return FL_META;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1147
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1148 return 0;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1149 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1150
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1151 int key2ascii (int key)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1152 {
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1153 if (key < 256) return key;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1154 if (key == FL_Tab) return '\t';
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1155 if (key == FL_Enter) return 0x0a;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1156 if (key == FL_BackSpace) return 0x08;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1157 if (key == FL_Escape) return 0x1b;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1158
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1159 return 0;
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1160 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1161
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1162 Cell modifier2cell ()
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1163 {
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1164 string_vector mod;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1165
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1166 if (shift & FL_SHIFT)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1167 mod.append (std::string ("shift"));
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1168 if (shift & FL_CTRL)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1169 mod.append (std::string ("control"));
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1170 if (shift & FL_ALT || shift & FL_META)
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1171 mod.append (std::string ("alt"));
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1172
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1173 return Cell (mod);
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1174 }
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1175
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
1176 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
1177 {
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
1178 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
1179
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1180 Matrix pos (1,4,0);
10555
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
1181 pos(0) = xx;
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
1182 pos(1) = yy;
a80207303549 style fixes
John W. Eaton <jwe@octave.org>
parents: 10553
diff changeset
1183 pos(2) = ww;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1184 pos(3) = hh - status_h - menu_h;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1185
14357
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14314
diff changeset
1186 fp.set_boundingbox (pos, true);
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14314
diff changeset
1187 }
e7c74f56cd03 fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents: 14314
diff changeset
1188
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1189 void draw (void)
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1190 {
14358
adb352685ded fltk toolkit: figure position should have its origin at LL not UL.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
1191 Matrix pos = fp.get_boundingbox (true);
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1192 Fl_Window::resize (pos(0), pos(1), pos(2), pos(3) + status_h + menu_h);
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1193
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1194 return Fl_Window::draw ();
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
1195 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1196
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1197 int handle (int event)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1198 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1199 graphics_handle gh;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1200
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1201 graphics_object fig = gh_manager::get_object (fp.get___myhandle__ ());
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1202 int retval = Fl_Window::handle (event);
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1203
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1204 // We only handle events which are in the canvas area.
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1205 if (!Fl::event_inside (canvas))
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1206 return retval;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1207
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1208 if (!fp.is_beingdeleted ())
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1209 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1210 switch (event)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1211 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1212 case FL_KEYDOWN:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1213 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1214 int key = Fl::event_key ();
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1215
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1216 shift |= key2shift (key);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1217 int key_a = key2ascii (key);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1218 if (key_a && fp.get_keypressfcn ().is_defined ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1219 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1220 Octave_map evt;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1221 evt.assign ("Character", octave_value (key_a));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1222 evt.assign ("Key", octave_value (std::tolower (key_a)));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1223 evt.assign ("Modifier", octave_value (modifier2cell ()));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1224 fp.execute_keypressfcn (evt);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1225 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1226 switch (key)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1227 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1228 case 'a':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1229 case 'A':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1230 axis_auto ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1231 break;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1232
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1233 case 'g':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1234 case 'G':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1235 toggle_grid ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1236 break;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1237
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1238 case 'p':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1239 case 'P':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1240 gui_mode = pan_zoom;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1241 break;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1242
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1243 case 'r':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1244 case 'R':
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1245 gui_mode = rotate_zoom;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1246 break;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1247 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1248 }
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1249 break;
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1250
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1251 case FL_KEYUP:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1252 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1253 int key = Fl::event_key ();
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1254
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1255 shift &= (~key2shift (key));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1256 int key_a = key2ascii (key);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1257 if (key_a && fp.get_keyreleasefcn ().is_defined ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1258 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1259 Octave_map evt;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1260 evt.assign ("Character", octave_value (key_a));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1261 evt.assign ("Key", octave_value (std::tolower (key_a)));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1262 evt.assign ("Modifier", octave_value (modifier2cell ()));
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1263 fp.execute_keyreleasefcn (evt);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1264 }
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1265 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1266 break;
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
1267
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1268 case FL_MOVE:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1269 pixel2status (pixel2axes_or_ca (Fl::event_x (), Fl::event_y ()),
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1270 Fl::event_x (), Fl::event_y ());
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1271 break;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1272
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1273 case FL_PUSH:
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1274 pos_x = Fl::event_x ();
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1275 pos_y = Fl::event_y ();
10517
9cdd6c8c05a4 [mq]: fltk_cb
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10346
diff changeset
1276
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1277 set_currentpoint (Fl::event_x (), Fl::event_y ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1278
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1279 gh = pixel2axes_or_ca (pos_x, pos_y);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1280
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1281 if (gh.ok ())
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1282 {
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1283 ax_obj = gh_manager::get_object (gh);
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1284 set_axes_currentpoint (ax_obj, pos_x, pos_y);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1285 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1286
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1287 fp.execute_windowbuttondownfcn ();
10792
91342260063e mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10593
diff changeset
1288
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1289 if (Fl::event_button () == 1 || Fl::event_button () == 3)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1290 return 1;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1291
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1292 break;
9455
ee8a035f3997 imported patch fltk_zoom
shaia@mars.bioc
parents: 9443
diff changeset
1293
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1294 case FL_DRAG:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1295 if (fp.get_windowbuttonmotionfcn ().is_defined ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1296 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1297 set_currentpoint (Fl::event_x (), Fl::event_y ());
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1298 fp.execute_windowbuttonmotionfcn ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1299 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1300
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1301 if (Fl::event_button () == 1)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1302 {
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1303 if (ax_obj && ax_obj.isa ("axes"))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1304 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1305 if (gui_mode == pan_zoom)
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1306 pixel2status (ax_obj, pos_x, pos_y,
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1307 Fl::event_x (), Fl::event_y ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1308 else
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1309 view2status (ax_obj);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1310 axes::properties& ap =
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1311 dynamic_cast<axes::properties&> (ax_obj.get_properties ());
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1312
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1313 double x0, y0, x1, y1;
14358
adb352685ded fltk toolkit: figure position should have its origin at LL not UL.
Ben Abbott <bpabbott@mac.com>
parents: 14357
diff changeset
1314 Matrix pos = fp.get_boundingbox (true);
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1315 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1316 pixel2pos (ax_obj, Fl::event_x (), Fl::event_y (), x1, y1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1317
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1318 if (gui_mode == pan_zoom)
14314
17de694961f5 make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents: 14233
diff changeset
1319 ap.translate_view (x0, x1, y0, y1);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1320 else if (gui_mode == rotate_zoom)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1321 {
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1322 double daz, del;
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1323 daz = (Fl::event_x () - pos_x) / pos(2) * 360;
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1324 del = (Fl::event_y () - pos_y) / pos(3) * 360;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1325 ap.rotate_view (del, daz);
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1326 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1327
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1328 pos_x = Fl::event_x ();
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1329 pos_y = Fl::event_y ();
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1330 mark_modified ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1331 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1332 return 1;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1333 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1334 else if (Fl::event_button () == 3)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1335 {
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1336 pixel2status (ax_obj, pos_x, pos_y,
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1337 Fl::event_x (), Fl::event_y ());
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1338 Matrix zoom_box (1,4,0);
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1339 zoom_box (0) = pos_x;
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1340 zoom_box (1) = pos_y;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1341 zoom_box (2) = Fl::event_x ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1342 zoom_box (3) = Fl::event_y ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1343 canvas->set_zoom_box (zoom_box);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1344 canvas->zoom (true);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1345 canvas->redraw ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1346 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1347
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1348 break;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1349
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1350 case FL_MOUSEWHEEL:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1351 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1352 graphics_object ax =
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1353 gh_manager::get_object (pixel2axes_or_ca (Fl::event_x (),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1354 Fl::event_y ()));
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1355 if (ax && ax.isa ("axes"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1356 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1357 axes::properties& ap =
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1358 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
1359
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1360 // Determine if we're zooming in or out.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1361 const double factor =
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1362 (Fl::event_dy () > 0) ? 1.0 + wheel_zoom_speed : 1.0 - wheel_zoom_speed;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1363
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1364 // Get the point we're zooming about.
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1365 double x1, y1;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1366 pixel2pos (ax, Fl::event_x (), Fl::event_y (), x1, y1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1367
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1368 ap.zoom_about_point (x1, y1, factor, false);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1369 mark_modified ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1370 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1371 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1372 return 1;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1373
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1374 case FL_RELEASE:
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1375 if (fp.get_windowbuttonupfcn ().is_defined ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1376 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1377 set_currentpoint (Fl::event_x (), Fl::event_y ());
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1378 fp.execute_windowbuttonupfcn ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1379 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1380
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1381 if (Fl::event_button () == 1)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1382 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1383 if ( Fl::event_clicks () == 1)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1384 {
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1385 if (ax_obj && ax_obj.isa ("axes"))
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1386 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1387 axes::properties& ap =
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1388 dynamic_cast<axes::properties&> (ax_obj.get_properties ());
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1389 ap.set_xlimmode ("auto");
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1390 ap.set_ylimmode ("auto");
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1391 ap.set_zlimmode ("auto");
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1392 mark_modified ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1393 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1394 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1395 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1396 if (Fl::event_button () == 3)
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1397 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1398 // End of drag -- zoom.
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1399 if (canvas->zoom ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1400 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1401 canvas->zoom (false);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1402 double x0,y0,x1,y1;
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1403 if (ax_obj && ax_obj.isa ("axes"))
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1404 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1405 axes::properties& ap =
14020
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1406 dynamic_cast<axes::properties&> (ax_obj.get_properties ());
caf69ec5b94c eliminate static data from fltk plot_window member function
John W. Eaton <jwe@octave.org>
parents: 14014
diff changeset
1407 pixel2pos (ax_obj, pos_x, pos_y, x0, y0);
14233
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1408 int pos_x1 = Fl::event_x ();
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1409 int pos_y1 = Fl::event_y ();
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1410 pixel2pos (ax_obj, pos_x1, pos_y1, x1, y1);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1411 Matrix xl (1,2,0);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1412 Matrix yl (1,2,0);
14233
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1413 int dx = abs (pos_x - pos_x1);
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1414 int dy = abs (pos_y - pos_y1);
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1415 // Smallest zoom box must be 4 pixels square
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1416 if ((dx > 4) && (dy > 4))
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1417 {
14233
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1418 if (x0 < x1)
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1419 {
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1420 xl(0) = x0;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1421 xl(1) = x1;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1422 }
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1423 else
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1424 {
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1425 xl(0) = x1;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1426 xl(1) = x0;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1427 }
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1428 if (y0 < y1)
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1429 {
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1430 yl(0) = y0;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1431 yl(1) = y1;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1432 }
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1433 else
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1434 {
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1435 yl(0) = y1;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1436 yl(1) = y0;
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1437 }
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
1438 ap.zoom (xl, yl);
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1439 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1440 mark_modified ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1441 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1442 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1443 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1444 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1445 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1446 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1447
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1448 return retval;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1449 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1450 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1451
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1452 class figure_manager
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1453 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1454 public:
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1455
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
1456 static bool instance_ok (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1457 {
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
1458 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
1459
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
1460 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
1461 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
1462
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
1463 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
1464 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1465 ::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
1466
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1467 retval = false;
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
1468 }
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
1469
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
1470 return retval;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1471 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1472
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1473 ~figure_manager (void)
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1474 {
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1475 close_all ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1476 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1477
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
1478 static void close_all (void)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1479 {
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
1480 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
1481 instance->do_close_all ();
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1482 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1483
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
1484 static void new_window (figure::properties& fp)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1485 {
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
1486 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
1487 instance->do_new_window (fp);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1488 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1489
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
1490 static void delete_window (int idx)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1491 {
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
1492 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
1493 instance->do_delete_window (idx);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1494 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1495
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1496 static void delete_window (const std::string& idx_str)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1497 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1498 delete_window (str2idx (idx_str));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1499 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1500
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1501 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
1502 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1503 if (instance_ok ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1504 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
1505 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1506
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1507 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
1508 {
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1509 if (instance_ok ())
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1510 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
1511 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1512
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1513 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
1514 bool is_visible)
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1515 {
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1516 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
1517 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1518
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
1519 static void mark_modified (int idx)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1520 {
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
1521 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
1522 instance->do_mark_modified (idx);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1523 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1524
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
1525 static void mark_modified (const graphics_handle& gh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1526 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1527 mark_modified (hnd2idx (gh));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1528 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1529
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1530 static void set_name (int idx)
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1531 {
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1532 if (instance_ok ())
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1533 instance->do_set_name (idx);
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1534 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1535
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1536 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
1537 {
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1538 set_name (str2idx (idx_str));
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1539 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1540
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
1541 static Matrix get_size (int idx)
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1542 {
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
1543 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
1544 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1545
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
1546 static Matrix get_size (const graphics_handle& gh)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1547 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1548 return get_size (hnd2idx (gh));
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1549 }
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1550
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1551 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
1552 const std::string& term)
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1553 {
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1554 if (instance_ok ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1555 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
1556 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1557
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1558 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
1559 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
1560 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1561 if (instance_ok ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1562 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
1563 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1564
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1565 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
1566 const graphics_handle& ca)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1567 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1568 if (instance_ok ())
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1569 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
1570 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1571
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1572 static void 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
1573 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1574 if (instance_ok ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1575 instance->do_toggle_menubar_visibility (fig_idx, menubar_is_figure);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1576 }
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1577
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1578 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
1579 bool menubar_is_figure)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1580 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1581 toggle_menubar_visibility (str2idx (fig_idx_str), menubar_is_figure);
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1582 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1583
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1584 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
1585
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
1586 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
1587
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1588 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
1589
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
1590 // 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
1591 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
1592 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
1593
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1594 // Singelton -- hide all of the above.
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1595
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1596 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
1597 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
1598 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
1599 window_map windows;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1600
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1601 static std::string fltk_idx_header;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1602
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
1603 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
1604 {
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
1605 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
1606 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
1607 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
1608 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
1609 }
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
1610
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
1611 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
1612 {
13798
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1613 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
1614
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
1615 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
1616 {
13804
4f112bebd474 use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents: 13799
diff changeset
1617 Matrix pos = fp.get_boundingbox (true);
13799
760e4e88dba3 convert units for figure positions
John W. Eaton <jwe@octave.org>
parents: 13798
diff changeset
1618
13798
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1619 int x = pos(0);
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1620 int y = pos(1);
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1621 int w = pos(2);
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1622 int h = pos(3);
718f78b01de1 allow initial position to be set for fltk windows
John W. Eaton <jwe@octave.org>
parents: 13721
diff changeset
1623
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1624 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
1625
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1626 windows[curr_index++] = new plot_window (x, y, w, h, 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
1627 }
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
1628 }
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
1629
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
1630 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
1631 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1632 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1633
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1634 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
1635 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1636 delete win->second;
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1637 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
1638 }
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
1639 }
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
1640
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1641 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
1642 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1643 wm_iterator win = windows.find (idx);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1644
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1645 if (win != windows.end ())
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1646 win->second->renumber (new_number);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1647 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1648
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1649 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
1650 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1651 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1652
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1653 if (win != windows.end ())
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1654 {
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1655 if (is_visible)
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1656 win->second->show ();
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1657 else
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1658 win->second->hide ();
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1659
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1660 win->second->redraw ();
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1661 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1662 }
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1663
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1664 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
1665 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1666 wm_iterator win = windows.find (fig_idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1667
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1668 if (win != windows.end ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1669 {
11585
1473d0cf86d2 untabify source files
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
1670 if (menubar_is_figure)
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1671 win->second->show_menubar ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1672 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1673 win->second->hide_menubar ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1674
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1675 win->second->redraw ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1676 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1677 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1678
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
1679 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
1680 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1681 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1682
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1683 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1684 win->second->mark_modified ();
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
1685 }
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
1686
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1687 void do_set_name (int idx)
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1688 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1689 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1690
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1691 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1692 win->second->set_name ();
10008
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1693 }
b6261d776a82 handle window title correctly in fltk_backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9991
diff changeset
1694
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
1695 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
1696 {
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
1697 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
1698
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1699 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1700
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1701 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
1702 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1703 sz(0) = win->second->w ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1704 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
1705 }
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
1706
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
1707 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
1708 }
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
1709
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
1710 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
1711 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1712 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1713
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1714 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1715 win->second->print (cmd, term);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1716 }
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1717
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1718 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
1719 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1720 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1721
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1722 if (win != windows.end ())
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1723 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
1724 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1725
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1726 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
1727 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1728 wm_iterator win = windows.find (idx);
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1729
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1730 if (win != windows.end ())
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1731 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1732 if (ca.ok ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1733 win->second->show_canvas ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1734 else
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1735 win->second->hide_canvas ();
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1736 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1737 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1738
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1739 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
1740 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1741 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
1742 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
1743 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1744 std::istringstream istr (clstr.substr (fltk_idx_header.size ()));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1745 if (istr >> ind)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1746 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
1747 }
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1748 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
1749 return -1;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1750 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1751
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1752 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
1753 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1754 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
1755 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
1756 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
1757 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1758
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
1759 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
1760 {
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1761 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
1762 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1763 octave_value ps = fp.get___plot_stream__ ();
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1764 if (ps.is_string ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1765 return str2idx (ps.string_value ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1766 else
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1767 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
1768 }
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1769 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
1770 return -1;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1771 }
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1772
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1773 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
1774 {
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1775 graphics_object fobj = gh_manager::get_object (h);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1776 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
1777 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1778 figure::properties& fp =
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1779 dynamic_cast<figure::properties&> (fobj.get_properties ());
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1780 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
1781 }
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1782 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
1783 return -1;
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1784 }
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
1785
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
1786 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
1787 {
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
1788 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
1789 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1790 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1791
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
1792 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
1793
7841
c643e5c520f5 fltk_backend now indexes using an internal index instead of figure handle
Shai Ayal <shaiay@users.sourceforge.net>
parents: 7840
diff changeset
1794 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
1795 int figure_manager::curr_index = 1;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1796
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1797 static bool toolkit_loaded = false;
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1798
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1799 static int
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1800 __fltk_redraw__ (void)
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1801 {
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1802 if (toolkit_loaded)
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1803 {
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1804 // We scan all figures and add those which use FLTK.
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1805 graphics_object obj = gh_manager::get_object (0);
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1806 if (obj && obj.isa ("root"))
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1807 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1808 base_properties& props = obj.get_properties ();
11301
cc9b8cd5aa87 consider hidden handles in uimenu code
Kai Habel <kai.habel@gmx.de>
parents: 11297
diff changeset
1809 Matrix children = props.get_all_children ();
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1810
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1811 for (octave_idx_type n = 0; n < children.numel (); n++)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1812 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1813 graphics_object fobj = gh_manager::get_object (children (n));
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1814 if (fobj && fobj.isa ("figure"))
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1815 {
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1816 figure::properties& fp =
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1817 dynamic_cast<figure::properties&> (fobj.get_properties ());
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1818 if (fp.get___graphics_toolkit__ ()
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1819 == FLTK_GRAPHICS_TOOLKIT_NAME)
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1820 figure_manager::new_window (fp);
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1821 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1822 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1823 }
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1824
10229
02ae72071221 improve __fltk_redraw__
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10155
diff changeset
1825 // it seems that we have to call Fl::check twice to get everything drawn
02ae72071221 improve __fltk_redraw__
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10155
diff changeset
1826 Fl::check ();
02ae72071221 improve __fltk_redraw__
Shai Ayal <shaiay@users.sourceforge.net>
parents: 10155
diff changeset
1827 Fl::check ();
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1828 }
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1829
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1830 return 0;
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1831 }
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1832
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1833 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
1834 {
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1835 public:
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1836 fltk_graphics_toolkit (void)
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1837 : base_graphics_toolkit (FLTK_GRAPHICS_TOOLKIT_NAME) { }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1838
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1839 ~fltk_graphics_toolkit (void) { }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1840
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1841 bool is_valid (void) const { return true; }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1842
13281
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12968
diff changeset
1843 bool initialize (const graphics_object& go)
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12968
diff changeset
1844 { return go.isa ("figure"); }
834f904a3dcb Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents: 12968
diff changeset
1845
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10972
diff changeset
1846 void finalize (const graphics_object& go)
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1847 {
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1848 if (go.isa ("figure"))
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1849 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1850 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
1851
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
1852 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
1853 figure_manager::delete_window (ov.string_value ());
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1854 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1855 }
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1856
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1857 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
1858 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1859 if (uimenu_obj.valid_object ())
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1860 {
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1861 uimenu::properties& uimenup =
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1862 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
1863 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
1864 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
1865 if (go.isa ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1866 fltk_label = dynamic_cast<const uimenu::properties&> (go.get_properties ()).get_fltk_label ()
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1867 + "/"
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1868 + fltk_label;
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1869 else if (go.isa ("figure"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1870 ;
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1871 else
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1872 error ("unexpected parent object\n");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1873
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1874 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
1875 }
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1876 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1877
10973
a8235d26b57a improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents: 10972
diff changeset
1878 void update (const graphics_object& go, int id)
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1879 {
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1880 if (go.isa ("figure"))
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1881 {
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1882 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
1883
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1884 if (! ov.is_empty ())
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1885 {
9973
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1886 const figure::properties& fp =
cd8f355157b8 Handle figure visibility in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9951
diff changeset
1887 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
1888
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1889 switch (id)
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1890 {
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1891 case base_properties::ID_VISIBLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1892 figure_manager::toggle_window_visibility
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1893 (ov.string_value (), fp.is_visible ());
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1894 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1895
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1896 case figure::properties::ID_MENUBAR:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1897 figure_manager::toggle_menubar_visibility
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1898 (ov.string_value (), fp.menubar_is ("figure"));
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1899 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1900
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1901 case figure::properties::ID_CURRENTAXES:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1902 figure_manager::update_canvas
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1903 (go.get_handle (), fp.get_currentaxes ());
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1904 break;
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1905
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1906 case figure::properties::ID_NAME:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1907 case figure::properties::ID_NUMBERTITLE:
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1908 figure_manager::set_name (ov.string_value ());
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
1909 break;
13816
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1910
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1911 case figure::properties::ID_INTEGERHANDLE:
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1912 {
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1913 std::string tmp = ov.string_value ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1914 graphics_handle gh = fp.get___myhandle__ ();
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1915 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
1916 figure_manager::set_name (tmp);
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1917 }
7ee18dc46bbb new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents: 13815
diff changeset
1918 break;
10154
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1919 }
40dfc0c99116 DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents: 10076
diff changeset
1920 }
8059
75c99d3f97d7 Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents: 7965
diff changeset
1921 }
11155
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1922 else if (go.isa ("uimenu"))
f0e9befd6a1c add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents: 11045
diff changeset
1923 {
11239
5fa7667f90e5 Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents: 11224
diff changeset
1924 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
1925 uimenu_set_fltk_label (go);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1926
14854
5ae9f0f77635 maint: Use Octave coding conventions for coddling parenthis is DLD-FUNCTIONS directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
1927 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
1928 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
1929 }
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1930 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1931
8077
a4e03f9b4b8a Fix FLTK backend update
Michael Goffioul
parents: 8060
diff changeset
1932 void redraw_figure (const graphics_object& go) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1933 {
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
1934 figure_manager::mark_modified (go.get_handle ());
9652
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1935
ecdb275bd41b make drawnow work for fltk backend
John W. Eaton <jwe@octave.org>
parents: 9640
diff changeset
1936 __fltk_redraw__ ();
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1937 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1938
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1939 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
1940 const std::string& term,
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
1941 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
1942 const std::string& /*debug_file*/) const
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1943 {
12449
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
1944 figure_manager::print (go.get_handle (), file_cmd, term);
2f0d1e12806d invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents: 12324
diff changeset
1945 redraw_figure (go);
9798
2d6a5af744b6 printing for fltk backend using gl2ps
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9758
diff changeset
1946 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1947
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1948 Matrix get_canvas_size (const graphics_handle& fh) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1949 {
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
1950 return figure_manager::get_size (fh);
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1951 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1952
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1953 double get_screen_resolution (void) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1954 {
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1955 // FLTK doesn't give this info.
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1956 return 72.0;
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1957 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1958
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1959 Matrix get_screen_size (void) const
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1960 {
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1961 Matrix sz (1, 2, 0.0);
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1962 sz(0) = Fl::w ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1963 sz(1) = Fl::h ();
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1964 return sz;
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1965 }
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
1966
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
1967 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
1968 {
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1969 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
1970 {
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
1971 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
1972
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
1973 figure_manager::close_all ();
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1974 gtk_manager::unload_toolkit (FLTK_GRAPHICS_TOOLKIT_NAME);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1975 toolkit_loaded = false;
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
1976
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
1977 octave_value_list args;
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
1978 args(0) = "__fltk_redraw__";
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
1979 feval ("remove_input_event_hook", args, 0);
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
1980
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
1981 // FIXME ???
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
1982 Fl::wait (fltk_maxtime);
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
1983 }
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
1984 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1985 };
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1986
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
1987 // Initialize the fltk graphics toolkit.
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
1988
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
1989 DEFUN_DLD (__init_fltk__, , , "")
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
1990 {
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1991 if (! toolkit_loaded)
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
1992 {
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
1993 mlock ();
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
1994
14021
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1995 graphics_toolkit tk (new fltk_graphics_toolkit ());
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1996 gtk_manager::load_toolkit (tk);
e3bed294b117 refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents: 14020
diff changeset
1997 toolkit_loaded = true;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
1998
9216
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
1999 octave_value_list args;
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
2000 args(0) = "__fltk_redraw__";
9d4b84b14bf0 call mlock in __fltk_init__
John W. Eaton <jwe@octave.org>
parents: 9060
diff changeset
2001 feval ("add_input_event_hook", args, 0);
8060
09f32aac8fbc Interface for backend switch/initialization
John W. Eaton <jwe@octave.org>
parents: 8059
diff changeset
2002 }
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2003
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2004 octave_value retval;
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2005 return retval;
7834
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2006 }
caab78e7e377 added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
diff changeset
2007
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2008 DEFUN_DLD (__fltk_redraw__, , , "")
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2009 {
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2010 __fltk_redraw__ ();
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
2011
11576
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2012 return octave_value ();
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2013 }
8ac9687dbe9f rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents: 11553
diff changeset
2014
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2015 DEFUN_DLD (__fltk_maxtime__, args, ,"")
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2016 {
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2017 octave_value retval = fltk_maxtime;
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2018
7869
e6d5532f760e style fixes
John W. Eaton <jwe@octave.org>
parents: 7861
diff changeset
2019 if (args.length () == 1)
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2020 {
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2021 if (args(0).is_real_scalar ())
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2022 fltk_maxtime = args(0).double_value ();
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2023 else
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2024 error ("argument must be a real scalar");
7839
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2025 }
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2026
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2027 return retval;
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2028 }
71eb1793f0db fltk_backend can now handle figure.position changes
Shai Ayal <shaiay@sourceforge.net>
parents: 7834
diff changeset
2029
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2030 #endif
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2031
15503
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2032 DEFUN_DLD (__have_fltk__, , , "")
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2033 {
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2034 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
2035
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2036 #if defined (HAVE_FLTK)
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2037 retval = true;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2038 #else
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2039 retval = false;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2040 #endif
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2041
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2042 return retval;
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2043 }
dca1f2bcccf3 don't register fltk toolkit if compiling without FLTK (bug #37541)
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
2044
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2045 // FIXME -- This function should be abstracted and made potentially
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2046 // available to all graphics toolkits. This suggests putting it in
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2047 // graphics.cc as is done for drawnow() and having the master
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2048 // mouse_wheel_zoom function call fltk_mouse_wheel_zoom. The same
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2049 // should be done for gui_mode and fltk_gui_mode. For now (2011.01.30),
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2050 // just changing function names and docstrings.
12226
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2051
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2052 DEFUN_DLD (mouse_wheel_zoom, args, ,
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2053 "-*- texinfo -*-\n\
12226
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2054 @deftypefn {Built-in Function} {@var{speed} =} mouse_wheel_zoom ()\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2055 @deftypefnx {Built-in Function} {} mouse_wheel_zoom (@var{speed})\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2056 Query or set the mouse wheel zoom factor.\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2057 \n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2058 This function is currently implemented only for the FLTK graphics toolkit.\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2059 @seealso{gui_mode}\n\
9668
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2060 @end deftypefn")
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2061 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2062 #if defined (HAVE_FLTK)
9668
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2063 octave_value retval = wheel_zoom_speed;
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2064
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2065 if (args.length () == 1)
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2066 {
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2067 if (args(0).is_real_scalar ())
9951
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2068 wheel_zoom_speed = args(0).double_value ();
d64d15e12e6b print immediately in fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9802
diff changeset
2069 else
12226
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2070 error ("mouse_wheel_zoom: SPEED must be a real scalar");
9668
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2071 }
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2072
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2073 return retval;
14233
358b59706656 Stop FLTK plot figure crash with right-mouse zoom (Bug #32592).
Doug Stewart <doug.dastew@gmail.com>
parents: 14138
diff changeset
2074 #else
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2075 error ("mouse_wheel_zoom: not available without OpenGL and FLTK libraries");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2076 return octave_value ();
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2077 #endif
9668
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2078 }
6291b69cf2d2 imported patch fltk_overlay
Shai Ayal <shaiay@users.sourceforge.net>
parents: 9652
diff changeset
2079
12226
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2080 DEFUN_DLD (gui_mode, args, ,
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2081 "-*- texinfo -*-\n\
12226
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2082 @deftypefn {Built-in Function} {@var{mode} =} gui_mode ()\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2083 @deftypefnx {Built-in Function} {} gui_mode (@var{mode})\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2084 Query or set the GUI mode for the current graphics toolkit.\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2085 The @var{mode} argument can be one of the following strings:\n\
14366
b76f0740940e doc: Periodic grammar check of documentation.
Rik <octave@nomad.inbox5.com>
parents: 14358
diff changeset
2086 \n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2087 @table @asis\n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2088 @item '2d'\n\
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2089 Allows panning and zooming of current axes.\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2090 \n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2091 @item '3d'\n\
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2092 Allows rotating and zooming of current axes.\n\
11553
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2093 \n\
01f703952eff Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
2094 @item 'none'\n\
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2095 Mouse inputs have no effect.\n\
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2096 @end table\n\
12226
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2097 \n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2098 This function is currently implemented only for the FLTK graphics toolkit.\n\
8cc154f45e37 Rename fltk_mouse_wheel_zoom, fltk_gui_mode functions to remove fltk_ prefix.
Rik <octave@nomad.inbox5.com>
parents: 12215
diff changeset
2099 @seealso{mouse_wheel_zoom}\n\
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2100 @end deftypefn")
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2101 {
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2102 #if defined (HAVE_FLTK)
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2103 caseless_str mode_str;
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2104
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2105 if (gui_mode == pan_zoom)
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2106 mode_str = "2d";
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2107 else if (gui_mode == rotate_zoom)
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2108 mode_str = "3d";
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2109 else
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2110 mode_str = "none";
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2111
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2112 bool failed = false;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2113
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2114 if (args.length () == 1)
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2115 {
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2116 if (args(0).is_string ())
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2117 {
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2118 mode_str = args(0).string_value ();
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2119
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2120 if (mode_str.compare ("2d"))
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2121 gui_mode = pan_zoom;
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2122 else if (mode_str.compare ("3d"))
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2123 gui_mode = rotate_zoom;
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2124 else if (mode_str.compare ("none"))
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2125 gui_mode = none;
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2126 else
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2127 failed = true;
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2128 }
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2129 else
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2130 failed = true;
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2131 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2132
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2133 if (failed)
12215
4ae2a74ed04c Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12205
diff changeset
2134 error ("MODE must be one of the strings: \"2D\", \"3D\", or \"none\"");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11585
diff changeset
2135
13815
0aba6f90f5f8 maint: __init_fltk__.cc style fixes
John W. Eaton <jwe@octave.org>
parents: 13804
diff changeset
2136 return octave_value (mode_str);
14111
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2137 #else
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2138 error ("mouse_wheel_zoom: not available without OpenGL and FLTK libraries");
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2139 return octave_value ();
c5222658dc3c doc: Build documentation for functions even when they are unavailable
Rik <octave@nomad.inbox5.com>
parents: 14021
diff changeset
2140 #endif
11297
76cf48adfdf7 New function to set GUI mode (fltk)
Kai Habel <kai.habel@gmx.de>
parents: 11283
diff changeset
2141 }