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
24 #include <libgeda/libgeda.h>
26 #include "../include/x_states.h"
27 #include "../include/prototype.h"
29 #ifdef HAVE_LIBDMALLOC
33 typedef struct st_stroke_point STROKE_POINT
;
35 struct st_stroke_point
{
40 static STROKE_POINT
*stroke_points
= NULL
;
42 /*! \todo Finish function documentation!!!
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
));
56 if (stroke_points
== NULL
) {
57 stroke_points
= new_point
;
58 stroke_points
->next
= NULL
;
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!!!
72 * \par Function Description
75 * traverse list as well as free each point as you go along
77 void x_stroke_erase_all(TOPLEVEL
*w_current
)
81 while(stroke_points
!= NULL
) {
84 printf("%d %d\n", stroke_points
->x
, stroke_points
->y
);
87 /* was xor, wasn't working out... see above note */
88 gdk_gc_set_foreground(
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
);
96 stroke_points
= stroke_points
->next
;
100 stroke_points
= NULL
;
103 /*! \todo Finish function documentation!!!
105 * \par Function Description
108 void x_stroke_free_all(void)
112 while(stroke_points
!= NULL
) {
114 printf("%d %d\n", stroke_points
->x
, stroke_points
->y
);
117 temp
= stroke_points
;
118 stroke_points
= stroke_points
->next
;
122 stroke_points
= NULL
;
125 /*! \todo Finish function documentation!!!
127 * \par Function Description
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
)
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;