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
25 #include <libgeda/libgeda.h>
27 #include "../include/x_states.h"
28 #include "../include/prototype.h"
30 #ifdef HAVE_LIBDMALLOC
34 /*! \todo Finish function documentation!!!
36 * \par Function Description
39 gboolean
o_find_object(TOPLEVEL
*w_current
, int screen_x
, int screen_y
,
40 gboolean change_selection
)
42 OBJECT
*o_current
=NULL
;
43 gboolean object_found
= FALSE
;
44 int w_x
, w_y
, w_slack
;
46 SCREENtoWORLD( w_current
, screen_x
, screen_y
, &w_x
, &w_y
);
47 w_slack
= WORLDabs( w_current
, w_current
->select_slack_pixels
);
49 if (w_current
->page_current
->object_lastplace
== NULL
) {
50 o_current
= w_current
->page_current
->object_head
;
52 o_current
= w_current
->page_current
->object_lastplace
;
56 while (o_current
!= NULL
) {
57 if (inside_region(o_current
->w_left
- w_slack
, o_current
->w_top
- w_slack
,
58 o_current
->w_right
+ w_slack
, o_current
->w_bottom
+ w_slack
,
60 if (o_current
->sel_func
!= NULL
&&
61 o_current
->type
!= OBJ_HEAD
&&
62 (o_current
->visibility
== VISIBLE
||
63 (o_current
->visibility
== INVISIBLE
&&
64 w_current
->show_hidden_text
))) {
65 if (change_selection
) {
66 (*o_current
->sel_func
)(
68 SINGLE
, 0); /* 0 is count */
71 w_current
->page_current
-> object_lastplace
=
73 i_update_menus(w_current
);
77 o_current
= o_current
->next
;
81 printf("SEARCHING AGAIN\n");
84 /* now search again since we didn't find anything starting at start
85 just in case we started last time at object_lastplace */
86 o_current
= w_current
->page_current
->object_head
;
87 while (o_current
!= NULL
&&
88 o_current
!= w_current
->page_current
->object_lastplace
) {
89 if (inside_region(o_current
->w_left
- w_slack
, o_current
->w_top
- w_slack
,
90 o_current
->w_right
+ w_slack
, o_current
->w_bottom
+ w_slack
,
93 if (o_current
->sel_func
!= NULL
&&
94 o_current
->type
!= OBJ_HEAD
&&
95 (o_current
->visibility
== VISIBLE
||
96 (o_current
->visibility
== INVISIBLE
&&
97 w_current
->show_hidden_text
))) {
98 if (change_selection
) {
100 (*o_current
->sel_func
)(w_current
, o_current
, SINGLE
, 0);
102 w_current
->page_current
->object_lastplace
= o_current
;
105 i_update_menus(w_current
);
109 o_current
= o_current
->next
;
112 /* didn't find anything.... reset lastplace */
113 w_current
->page_current
->object_lastplace
= NULL
;
115 /* deselect everything only if shift key isn't pressed and
116 the caller allows it */
117 if (change_selection
&& (!w_current
->SHIFTKEY
)) {
118 o_select_run_hooks(w_current
, NULL
, 2);
119 o_selection_unselect_list (w_current
, w_current
->page_current
->selection_list
);
122 i_update_menus(w_current
);
124 return (object_found
);
127 /*! \todo Finish function documentation!!!
129 * \par Function Description
132 gboolean
o_find_selected_object(TOPLEVEL
*w_current
,
133 int screen_x
, int screen_y
)
135 OBJECT
*o_current
=NULL
;
137 int w_x
, w_y
, w_slack
;
139 SCREENtoWORLD( w_current
, screen_x
, screen_y
, &w_x
, &w_y
);
140 w_slack
= WORLDabs( w_current
, w_current
->select_slack_pixels
);
142 s_current
= geda_list_get_glist( w_current
->page_current
->selection_list
);
143 /* do first search */
144 while (s_current
!= NULL
) {
145 o_current
= (OBJECT
*) s_current
->data
;
146 if (inside_region(o_current
->w_left
- w_slack
, o_current
->w_top
- w_slack
,
147 o_current
->w_right
+ w_slack
, o_current
->w_bottom
+ w_slack
,
151 printf("o_find_selected_object:\n");
152 printf("Object bounds:\n\tL: %i\tR: %i\n\tT: %i\tB: %i.\n",
153 o_current
->w_left
, o_current
->w_right
, o_current
->w_top
, o_current
->w_bottom
);
154 printf("Screen pointer at: (%i,%i)\n", screen_x
, screen_y
);
156 if (o_current
->sel_func
!= NULL
&&
157 o_current
->type
!= OBJ_HEAD
&&
158 (o_current
->visibility
== VISIBLE
||
159 (o_current
->visibility
== INVISIBLE
&&
160 w_current
->show_hidden_text
))) {
165 s_current
= s_current
->next
;