1 /* decorate.c */
2 /* COPYRIGHT (C) 2000 THE VICTORIA UNIVERSITY OF MANCHESTER and John Levon
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation; either version 2 of the License, or (at your option)
6 * any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15 * Place - Suite 330, Boston, MA 02111-1307, USA.
16 */
17 /*
18 * $Log: decorate.c,v $
19 * Revision 1.3 2000/12/17 00:57:41 moz
20 * examples, filled open splines, highlight_objects
21 *
22 * Revision 1.2 2000/12/06 20:56:01 moz
23 * GPL stuff.
24 *
25 * Revision 1.1.1.1 2000/08/21 01:05:30 moz
26 *
27 *
28 * Revision 1.1.1.1 2000/07/19 22:45:30 moz
29 * CVS Import
30 *
31 * Revision 1.9 2000/03/08 01:07:21 moz
32 * Compile fixes.
33 *
34 * Revision 1.8 2000/02/18 21:18:14 moz
35 * polyline.pic usage changed.
36 *
37 * Revision 1.7 1999/11/15 02:07:53 moz
38 * Name change.
39 *
40 * Revision 1.6 1999/08/06 23:34:44 moz
41 * Don't show rotate or scale handles for picture objects.
42 *
43 * Revision 1.5 1999/07/29 20:45:00 moz
44 * Draw resize handle for text.
45 *
46 * Revision 1.4 1999/05/19 17:06:17 moz
47 * 1.0 Checkin.
48 *
49 * Revision 1.3 1999/04/25 19:39:49 moz
50 * Fixes for text handles.
51 *
52 * Revision 1.2 1999/04/25 00:18:33 moz
53 * Place rotate handle differently for TEXT objects.
54 *
55 * Revision 1.1 1999/04/04 03:12:04 moz
56 * Initial revision
57 *
58 */
59
60 /* drawing of various things */
61
62 #include "include/figurine.h"
63 #include "include/extern.h"
64
65 void
toggle_guidelines(View * v)66 toggle_guidelines(View *v)
67 {
68 XDrawLine(display,v->draw_window->win, blackxorgc, mouse_x, 0, mouse_x, mouse_y - GUIDE_LINE_GAP);
69 XDrawLine(display,v->draw_window->win, blackxorgc, 0, mouse_y, mouse_x - GUIDE_LINE_GAP, mouse_y);
70 XDrawLine(display,v->draw_window->win, blackxorgc, mouse_x + GUIDE_LINE_GAP, mouse_y,
71 (int)v->draw_window->w-1, (int)mouse_y);
72 XDrawLine(display,v->draw_window->win, blackxorgc, mouse_x, mouse_y + GUIDE_LINE_GAP,
73 mouse_x, (int)v->draw_window->h-1);
74 v->guide_x = mouse_x;
75 v->guide_y = mouse_y;
76 }
77
78 /* for when moving objects etc. */
79 void
toggle(View * v,int x,int y)80 toggle(View *v, int x, int y)
81 {
82 switch (state.current_icon)
83 {
84 case ARCICON:
85 toggle_arc(v,x,y);
86 break;
87
88 case SPLINEICON:
89 toggle_spline_line(v,x,y);
90 break;
91
92 case POLYLINEICON:
93 toggle_polyline(v,x,y);
94 break;
95
96 case ELLIPSEICON:
97 case BOXELLIPSEICON:
98 toggle_ellipse(v,x,y);
99 break;
100
101 case ARCELLIPSEICON:
102 toggle_arcellipse(v,x,y);
103 break;
104
105 case RECTANGLEICON:
106 toggle_rectangle(v,x,y);
107 break;
108
109 case POLYGONICON:
110 toggle_polygon(v,x,y);
111 break;
112
113 default:
114 v_error(state.current_icon);
115 break;
116 };
117 }
118
119 void
draw_handle(View * v,long x,long y)120 draw_handle(View *v, long x, long y)
121 {
122 XFillRectangle(display,v->draw_window->win, handlegc, x, y, HANDLE_PIXEL_SIZE,HANDLE_PIXEL_SIZE);
123 }
124
125 /* draw handles on an object */
126 void
draw_bbox_handles(View * v)127 draw_bbox_handles(View *v)
128 {
129 long x1, x2, y1,y2;
130
131 if (v->highlighted_object==NULL || (v->selected_object==NULL && !v->highlight_objects))
132 return;
133
134 x1 = XD2P(v->highlighted_object->ob->bbox.x1,v);
135 y1 = YD2P(v->highlighted_object->ob->bbox.y1,v);
136 x2 = XD2P(v->highlighted_object->ob->bbox.x2,v);
137 y2 = YD2P(v->highlighted_object->ob->bbox.y2,v);
138 set_clip(handlegc,x1,y1,(x2-x1)+1,(y2-y1)+1);
139
140 XDrawRectangle(display,v->draw_window->win, handlegc, x1, y1, (uint)(x2-x1), (uint)(y2-y1));
141
142 if (v->highlighted_object->ob->type==POLYGON && v->highlighted_object->ob->ob.polyline.pic)
143 return;
144
145 if ((x2-x1)>=16 && (y2-y1)>=16 &&
146 (v->highlighted_object->ob->type!=TEXT || !v->highlighted_object->ob->ob.text.node))
147 {
148 draw_handle(v,x2-HANDLE_PIXEL_SIZE, y2-HANDLE_PIXEL_SIZE);
149 if (v->highlighted_object->ob->type!=COMPOUND
150 && v->highlighted_object->ob->type!=TEXT)
151 {
152 draw_handle(v,x1+1,y1+1);
153 draw_handle(v,x2-HANDLE_PIXEL_SIZE, y1+1);
154 draw_handle(v,x1+1, y2-HANDLE_PIXEL_SIZE);
155 };
156 };
157
158 if (v->highlighted_object->ob->type==TEXT && !v->highlighted_object->ob->ob.text.node)
159 XFillArc(display,v->draw_window->win, handlegc, x2-(2*HANDLE_PIXEL_SIZE), y2-(HANDLE_PIXEL_SIZE),
160 HANDLE_PIXEL_SIZE, HANDLE_PIXEL_SIZE, 0, 270*64);
161 else if (((x2-x1)>=32 && (y2-y1)>=32 && v->highlighted_object->ob->type!=ELLIPSE &&
162 v->highlighted_object->ob->type!=ARCELLIPSE && v->highlighted_object->ob->type!=COMPOUND &&
163 v->highlighted_object->ob->type!=TEXT && v->highlighted_object->ob->type!=ROUNDBOX))
164 XFillArc(display,v->draw_window->win, handlegc, x2-(2*HANDLE_PIXEL_SIZE), y2-(2*HANDLE_PIXEL_SIZE),
165 HANDLE_PIXEL_SIZE, HANDLE_PIXEL_SIZE, 0, 270*64);
166
167
168 }
169