annotate src/DLD-FUNCTIONS/__init_fltk__.cc @ 12306:eedeed3ee849 release-3-4-x

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