gtkwindow.hpp
Go to the documentation of this file.
1 
5 /* Copyright (c) 2005-2010 Taneli Kalvas. All rights reserved.
6  *
7  * You can redistribute this software and/or modify it under the terms
8  * of the GNU General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this library (file "COPYING" included in the package);
19  * if not, write to the Free Software Foundation, Inc., 51 Franklin
20  * Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  * If you have questions about your rights to use or distribute this
23  * software, please contact Berkeley Lab's Technology Transfer
24  * Department at TTD@lbl.gov. Other questions, comments and bug
25  * reports should be sent directly to the author via email at
26  * taneli.kalvas@jyu.fi.
27  *
28  * NOTICE. This software was developed under partial funding from the
29  * U.S. Department of Energy. As such, the U.S. Government has been
30  * granted for itself and others acting on its behalf a paid-up,
31  * nonexclusive, irrevocable, worldwide license in the Software to
32  * reproduce, prepare derivative works, and perform publicly and
33  * display publicly. Beginning five (5) years after the date
34  * permission to assert copyright is obtained from the U.S. Department
35  * of Energy, and subject to any subsequent five (5) year renewals,
36  * the U.S. Government is granted for itself and others acting on its
37  * behalf a paid-up, nonexclusive, irrevocable, worldwide license in
38  * the Software to reproduce, prepare derivative works, distribute
39  * copies to the public, perform publicly and display publicly, and to
40  * permit others to do so.
41  */
42 
43 #ifndef GTKWINDOW_HPP
44 #define GTKWINDOW_HPP 1
45 
46 
47 #include <cairo.h>
48 #include <gtk/gtk.h>
49 
50 #include "gtkplotter.hpp"
51 #include "frame.hpp"
52 #include "graph3d.hpp"
53 
54 
55 
61 class GTKWindow {
62 
63  size_t _width;
64  size_t _height;
65 
66  GtkWidget *_trackwindow;
67  GtkWidget *_tracklabel;
68 
69  cairo_t *_cairo;
70  cairo_surface_t *_surface;
71 
72  int _start[2];
73  int _end[2];
74  int _tool;
75 
76  void hardcopy( void );
77  void move( int action, double x, double y );
78  void track( int action, double x, double y );
79  void zoom_out( double x, double y );
80  void zoom_in( double x, double y );
81  void zoom_window( int action, double x, double y );
82 
83  void darea_motion( GdkEventMotion *event );
84  void darea_enter( GdkEventCrossing *event );
85  void darea_leave( GdkEventCrossing *event );
86  void darea_button( GdkEventButton *event );
87  void configure( void );
88  void derea_button( GdkEventButton *event );
89  void delete_window( void );
90  void menuitem_tool_change( GtkToolButton *button );
91  void menuitem_preferences( GtkMenuItem *menuitem );
92 
93  static gboolean window_delete_signal( GtkWidget *widget,
94  GdkEventExpose *event,
95  gpointer object );
96 
97  static void menuitem_quit_signal( GtkMenuItem *menuitem,
98  gpointer object );
99  static void menuitem_tool_change_signal( GtkToolButton *button,
100  gpointer object );
101  static void menuitem_hardcopy_signal( GtkToolButton *button,
102  gpointer object );
103  static void menuitem_zoom_fit_signal( GtkToolButton *button,
104  gpointer object );
105  static void menuitem_preferences_signal( GtkMenuItem *menuitem,
106  gpointer object );
107 
108  static gboolean darea_configure_signal( GtkWidget *widget,
109  GdkEventConfigure *event,
110  gpointer object );
111  static gboolean darea_expose_signal( GtkWidget *widget,
112  GdkEventExpose *event,
113  gpointer object );
114  static gboolean darea_button_signal( GtkWidget *widget,
115  GdkEventButton *event,
116  gpointer object );
117  static gboolean darea_motion_signal( GtkWidget *widget,
118  GdkEventMotion *event,
119  gpointer object );
120  static gboolean darea_enter_signal( GtkWidget *widget,
121  GdkEventCrossing *event,
122  gpointer object );
123  static gboolean darea_leave_signal( GtkWidget *widget,
124  GdkEventCrossing *event,
125  gpointer object );
126 
127 protected:
128 
130 
132  GtkWidget *_window;
133  GtkWidget *_darea;
134  GtkWidget *_menubar;
135  GtkWidget *_menu_file;
136  GtkWidget *_toolbar;
137  GtkWidget *_statusbar;
138 
139  GtkToolItem *_radioitem;
140 
141  double _track_px; // Track x coordinate in pixels
142  double _track_py; // Track y coordinate in pixels
143 
144 
145  GTKWindow( GTKPlotter *plotter );
146 
147  virtual void zoom_fit( void );
148 
154  virtual std::string track_text( double x, double y );
155 
156  void expose( int x, int y, int width, int height );
157 
158 public:
159 
160  virtual ~GTKWindow();
161 
162  virtual void *build_preferences( GtkWidget *notebook );
163  virtual void read_preferences( GtkWidget *notebook, void *pdata );
164 
165  void draw_and_expose( void );
166  void show( void );
167 };
168 
169 
170 
171 
172 
173 #endif
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
void show(void)
void draw_and_expose(void)
virtual void read_preferences(GtkWidget *notebook, void *pdata)
Frame for plots
void expose(int x, int y, int width, int height)
virtual std::string track_text(double x, double y)
Function which providies tracking text at (x,y)
GtkWidget * _window
Definition: gtkwindow.hpp:132
double _track_px
Definition: gtkwindow.hpp:141
GTK Plotter class.
Definition: gtkplotter.hpp:66
GtkToolItem * _radioitem
Definition: gtkwindow.hpp:139
Base class for interactive plotters.
Definition: gtkwindow.hpp:61
GtkWidget * _menubar
Definition: gtkwindow.hpp:134
GtkWidget * _menu_file
Definition: gtkwindow.hpp:135
GTKWindow(GTKPlotter *plotter)
virtual ~GTKWindow()
GtkWidget * _statusbar
Definition: gtkwindow.hpp:137
Base for three dimensional plottable graphs.
GtkWidget * _toolbar
Definition: gtkwindow.hpp:136
GTK based plotters.
General purpose plotter frame for cairographics surfaces.
Definition: frame.hpp:107
GtkWidget * _darea
Definition: gtkwindow.hpp:133
Frame _frame
Definition: gtkwindow.hpp:131
double _track_py
Definition: gtkwindow.hpp:142
virtual void * build_preferences(GtkWidget *notebook)
virtual void zoom_fit(void)
GTKPlotter * _plotter
Definition: gtkwindow.hpp:129