Take page as input and take advantage of s_visit_page.
[geda-gaf/berndj.git] / gschem / src / x_basic.c
blobae3eef3c612611ff4004194fc40a73b445c71926
1 /* gEDA - GPL Electronic Design Automation
2 * gschem - gEDA Schematic Capture
3 * Copyright (C) 1998-2007 Ales Hvezda
4 * Copyright (C) 1998-2007 gEDA Contributors (see ChangeLog for details)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
20 #include <config.h>
22 #include <stdio.h>
23 #include <math.h>
25 #include "gschem.h"
27 #ifdef HAVE_LIBDMALLOC
28 #include <dmalloc.h>
29 #endif
31 /*! \todo Finish function documentation!!!
32 * \brief
33 * \par Function Description
36 void x_repaint_background(GSCHEM_TOPLEVEL *w_current)
38 TOPLEVEL *toplevel = w_current->toplevel;
39 if (!w_current->inside_redraw) {
40 gdk_gc_set_foreground(
41 w_current->gc,
42 x_get_color(toplevel->background_color));
44 gdk_draw_rectangle(w_current->backingstore,
45 w_current->gc, TRUE, 0, 0,
46 w_current->win_width,
47 w_current->win_height);
48 o_invalidate_all (w_current);
50 x_grid_draw(w_current);
56 /*! \todo Finish function documentation!!!
57 * \brief
58 * \par Function Description
61 void x_hscrollbar_update(GSCHEM_TOPLEVEL *w_current)
63 TOPLEVEL *toplevel = w_current->toplevel;
64 GtkAdjustment *hadjustment;
66 if (w_current->scrollbars_flag == FALSE) {
67 return;
70 if (w_current->h_scrollbar == NULL) {
71 return;
74 hadjustment = gtk_range_get_adjustment (GTK_RANGE (
75 w_current->h_scrollbar));
77 hadjustment->value = toplevel->page_current->left;
79 hadjustment->page_size = fabs(toplevel->page_current->right -
80 toplevel->page_current->left);
82 hadjustment->page_increment = hadjustment->page_size - 100.0;
84 #if DEBUG
85 printf("H %f %f\n", hadjustment->lower, hadjustment->upper);
86 printf("Hp %f\n", hadjustment->page_size);
87 #endif
89 gtk_signal_emit_by_name(GTK_OBJECT(hadjustment), "changed");
90 gtk_signal_emit_by_name(GTK_OBJECT(hadjustment), "value_changed");
93 /*! \todo Finish function documentation!!!
94 * \brief
95 * \par Function Description
98 void x_vscrollbar_update(GSCHEM_TOPLEVEL *w_current)
100 TOPLEVEL *toplevel = w_current->toplevel;
101 GtkAdjustment *vadjustment;
103 if (w_current->scrollbars_flag == FALSE) {
104 return;
107 if (w_current->v_scrollbar == NULL) {
108 return;
111 vadjustment =
112 gtk_range_get_adjustment(GTK_RANGE(w_current->v_scrollbar));
114 vadjustment->page_size = fabs(toplevel->page_current->bottom -
115 toplevel->page_current->top);
117 vadjustment->page_increment = vadjustment->page_size - 100.0;
119 vadjustment->value =
120 toplevel->init_bottom - toplevel->page_current->bottom;
122 #if DEBUG
123 printf("V %f %f\n", vadjustment->lower, vadjustment->upper);
124 printf("Vp %f\n", vadjustment->page_size);
125 #endif
127 gtk_signal_emit_by_name(GTK_OBJECT(vadjustment), "changed");
128 gtk_signal_emit_by_name(GTK_OBJECT(vadjustment), "value_changed");
131 /*! \todo Finish function documentation!!!
132 * \brief
133 * \par Function Description
136 void x_scrollbars_update(GSCHEM_TOPLEVEL *w_current)
138 TOPLEVEL *toplevel = w_current->toplevel;
139 if (w_current->scrollbars_flag == FALSE) {
140 return;
143 toplevel->DONT_REDRAW = 1;
144 x_hscrollbar_update(w_current);
145 x_vscrollbar_update(w_current);
146 toplevel->DONT_REDRAW = 0;
150 /*! \todo Finish function documentation!!!
151 * \brief
152 * \par Function Description
155 void x_basic_warp_cursor (GtkWidget* widget, gint x, gint y)
157 GdkScreen *screen;
158 GdkDisplay *display;
159 int window_x, window_y;
161 gdk_window_get_origin (widget->window, &window_x, &window_y);
163 screen = gtk_widget_get_screen (widget);
164 display = gdk_screen_get_display (screen);
166 gdk_display_warp_pointer (display, screen, window_x + x, window_y + y);