Bumped versions to 1.1.2/20070818/30:2:0 for the next development snapshot
[geda-gaf/whiteaudio.git] / gschem / src / x_stroke.c
blob1351ba2b74ae34536e86e372b297787aa020900c
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 <math.h>
24 #include <libgeda/libgeda.h>
26 #include "../include/x_states.h"
27 #include "../include/prototype.h"
29 #ifdef HAVE_LIBDMALLOC
30 #include <dmalloc.h>
31 #endif
33 typedef struct st_stroke_point STROKE_POINT;
35 struct st_stroke_point {
36 int x, y;
37 STROKE_POINT *next;
40 static STROKE_POINT *stroke_points = NULL;
42 /*! \todo Finish function documentation!!!
43 * \brief
44 * \par Function Description
47 void x_stroke_add_point(TOPLEVEL *w_current, int x, int y)
49 STROKE_POINT *new_point;
51 new_point = (STROKE_POINT *) g_malloc(sizeof(STROKE_POINT));
53 new_point->x = x;
54 new_point->y = y;
56 if (stroke_points == NULL) {
57 stroke_points = new_point;
58 stroke_points->next = NULL;
59 } else {
60 new_point->next = stroke_points;
61 stroke_points = new_point;
64 gdk_gc_set_foreground(w_current->gc,
65 x_get_color(w_current->stroke_color));
67 gdk_draw_point(w_current->window, w_current->gc, x, y);
70 /*! \todo Finish function documentation!!!
71 * \brief
72 * \par Function Description
74 * \note
75 * traverse list as well as free each point as you go along
77 void x_stroke_erase_all(TOPLEVEL *w_current)
79 STROKE_POINT *temp;
81 while(stroke_points != NULL) {
83 #if DEBUG
84 printf("%d %d\n", stroke_points->x, stroke_points->y);
85 #endif
87 /* was xor, wasn't working out... see above note */
88 gdk_gc_set_foreground(
89 w_current->gc,
90 x_get_color(w_current->background_color));
92 gdk_draw_point(w_current->window, w_current->gc,
93 stroke_points->x, stroke_points->y);
95 temp = stroke_points;
96 stroke_points = stroke_points->next;
97 g_free(temp);
100 stroke_points = NULL;
103 /*! \todo Finish function documentation!!!
104 * \brief
105 * \par Function Description
108 void x_stroke_free_all(void)
110 STROKE_POINT *temp;
112 while(stroke_points != NULL) {
113 #if DEBUG
114 printf("%d %d\n", stroke_points->x, stroke_points->y);
115 #endif
117 temp = stroke_points;
118 stroke_points = stroke_points->next;
119 g_free(temp);
122 stroke_points = NULL;
125 /*! \todo Finish function documentation!!!
126 * \brief
127 * \par Function Description
129 * \note
130 * this is the function that does the actual work of the strokes
131 * by executing the right guile function which is associated with the stroke
133 int x_stroke_search_execute(char *sequence)
135 gchar *guile_string;
136 SCM eval;
138 guile_string = g_strdup_printf("(eval-stroke \"%s\")", sequence);
140 eval = scm_c_eval_string (guile_string);
141 g_free(guile_string);
143 return (SCM_FALSEP (eval)) ? 0 : 1;