IBSimu
1.0.4
|
00001 00005 /* Copyright (c) 2005-2010 Taneli Kalvas. All rights reserved. 00006 * 00007 * You can redistribute this software and/or modify it under the terms 00008 * of the GNU General Public License as published by the Free Software 00009 * Foundation; either version 2 of the License, or (at your option) 00010 * any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this library (file "COPYING" included in the package); 00019 * if not, write to the Free Software Foundation, Inc., 51 Franklin 00020 * Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 * If you have questions about your rights to use or distribute this 00023 * software, please contact Berkeley Lab's Technology Transfer 00024 * Department at TTD@lbl.gov. Other questions, comments and bug 00025 * reports should be sent directly to the author via email at 00026 * taneli.kalvas@jyu.fi. 00027 * 00028 * NOTICE. This software was developed under partial funding from the 00029 * U.S. Department of Energy. As such, the U.S. Government has been 00030 * granted for itself and others acting on its behalf a paid-up, 00031 * nonexclusive, irrevocable, worldwide license in the Software to 00032 * reproduce, prepare derivative works, and perform publicly and 00033 * display publicly. Beginning five (5) years after the date 00034 * permission to assert copyright is obtained from the U.S. Department 00035 * of Energy, and subject to any subsequent five (5) year renewals, 00036 * the U.S. Government is granted for itself and others acting on its 00037 * behalf a paid-up, nonexclusive, irrevocable, worldwide license in 00038 * the Software to reproduce, prepare derivative works, distribute 00039 * copies to the public, perform publicly and display publicly, and to 00040 * permit others to do so. 00041 */ 00042 00043 #ifndef GTKWINDOW_HPP 00044 #define GTKWINDOW_HPP 1 00045 00046 00047 #include <cairo.h> 00048 #include <gtk/gtk.h> 00049 00050 #include "gtkplotter.hpp" 00051 #include "frame.hpp" 00052 #include "graph3d.hpp" 00053 00054 00055 00061 class GTKWindow { 00062 00063 size_t _width; 00064 size_t _height; 00065 00066 GtkWidget *_trackwindow; 00067 GtkWidget *_tracklabel; 00068 00069 cairo_t *_cairo; 00070 cairo_surface_t *_surface; 00071 00072 int _start[2]; 00073 int _end[2]; 00074 int _tool; 00075 00076 void hardcopy( void ); 00077 void move( int action, double x, double y ); 00078 void track( int action, double x, double y ); 00079 void zoom_out( double x, double y ); 00080 void zoom_in( double x, double y ); 00081 void zoom_window( int action, double x, double y ); 00082 00083 void darea_motion( GdkEventMotion *event ); 00084 void darea_enter( GdkEventCrossing *event ); 00085 void darea_leave( GdkEventCrossing *event ); 00086 void darea_button( GdkEventButton *event ); 00087 void configure( void ); 00088 void derea_button( GdkEventButton *event ); 00089 void delete_window( void ); 00090 void menuitem_tool_change( GtkToolButton *button ); 00091 void menuitem_preferences( GtkMenuItem *menuitem ); 00092 00093 static gboolean window_delete_signal( GtkWidget *widget, 00094 GdkEventExpose *event, 00095 gpointer object ); 00096 00097 static void menuitem_quit_signal( GtkMenuItem *menuitem, 00098 gpointer object ); 00099 static void menuitem_tool_change_signal( GtkToolButton *button, 00100 gpointer object ); 00101 static void menuitem_hardcopy_signal( GtkToolButton *button, 00102 gpointer object ); 00103 static void menuitem_zoom_fit_signal( GtkToolButton *button, 00104 gpointer object ); 00105 static void menuitem_preferences_signal( GtkMenuItem *menuitem, 00106 gpointer object ); 00107 00108 static gboolean darea_configure_signal( GtkWidget *widget, 00109 GdkEventConfigure *event, 00110 gpointer object ); 00111 static gboolean darea_expose_signal( GtkWidget *widget, 00112 GdkEventExpose *event, 00113 gpointer object ); 00114 static gboolean darea_button_signal( GtkWidget *widget, 00115 GdkEventButton *event, 00116 gpointer object ); 00117 static gboolean darea_motion_signal( GtkWidget *widget, 00118 GdkEventMotion *event, 00119 gpointer object ); 00120 static gboolean darea_enter_signal( GtkWidget *widget, 00121 GdkEventCrossing *event, 00122 gpointer object ); 00123 static gboolean darea_leave_signal( GtkWidget *widget, 00124 GdkEventCrossing *event, 00125 gpointer object ); 00126 00127 protected: 00128 00129 GTKPlotter *_plotter; 00130 00131 Frame _frame; 00132 GtkWidget *_window; 00133 GtkWidget *_darea; 00134 GtkWidget *_menubar; 00135 GtkWidget *_menu_file; 00136 GtkWidget *_toolbar; 00137 GtkWidget *_statusbar; 00138 00139 GtkToolItem *_radioitem; 00140 00141 double _track_px; // Track x coordinate in pixels 00142 double _track_py; // Track y coordinate in pixels 00143 00144 00145 GTKWindow( GTKPlotter *plotter ); 00146 00147 virtual void zoom_fit( void ); 00148 00154 virtual std::string track_text( double x, double y ); 00155 00156 void expose( int x, int y, int width, int height ); 00157 00158 public: 00159 00160 virtual ~GTKWindow(); 00161 00162 virtual void *build_preferences( GtkWidget *notebook ); 00163 virtual void read_preferences( GtkWidget *notebook, void *pdata ); 00164 00165 void draw_and_expose( void ); 00166 void show( void ); 00167 }; 00168 00169 00170 00171 00172 00173 #endif 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191