Line data Source code
1 : /* Copyright (C) 2000-2012 by George Williams */
2 : /*
3 : * Redistribution and use in source and binary forms, with or without
4 : * modification, are permitted provided that the following conditions are met:
5 :
6 : * Redistributions of source code must retain the above copyright notice, this
7 : * list of conditions and the following disclaimer.
8 :
9 : * Redistributions in binary form must reproduce the above copyright notice,
10 : * this list of conditions and the following disclaimer in the documentation
11 : * and/or other materials provided with the distribution.
12 :
13 : * The name of the author may not be used to endorse or promote products
14 : * derived from this software without specific prior written permission.
15 :
16 : * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 : * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 : * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 : * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 : * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 : * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 : * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 : * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 : * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 : * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 : */
27 : #include "autohint.h"
28 : #include "cvundoes.h"
29 : #include "fontforgeui.h"
30 : #include "ustring.h"
31 : #include <math.h>
32 :
33 : #define CID_Base 1001
34 : #define CID_Width 1002
35 : #define CID_Label 1003
36 : #define CID_HStem 1004
37 : #define CID_VStem 1005
38 : #define CID_Next 1006
39 : #define CID_Prev 1007
40 : #define CID_Remove 1008
41 : #define CID_Add 1009
42 : #define CID_Overlap 1010
43 : #define CID_Count 1011
44 : #define CID_MovePoints 1012
45 : #define CID_RegenHM 1013
46 : #define CID_TopBox 1014
47 :
48 : typedef struct reviewhintdata {
49 : unsigned int done: 1;
50 : unsigned int ishstem: 1;
51 : unsigned int oldmanual: 1;
52 : unsigned int undocreated: 1;
53 : unsigned int changed: 1;
54 : CharView *cv;
55 : GWindow gw;
56 : StemInfo *active;
57 : StemInfo *lastactive;
58 : StemInfo *oldh, *oldv;
59 : } ReviewHintData;
60 :
61 0 : static void RH_SetNextPrev(ReviewHintData *hd) {
62 0 : if ( hd->active==NULL ) {
63 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Next),false);
64 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Prev),false);
65 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Remove),false);
66 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Base),false);
67 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Width),false);
68 : } else {
69 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Remove),true);
70 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Base),true);
71 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Width),true);
72 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Next),hd->active->next!=NULL);
73 0 : if ( hd->ishstem )
74 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Prev),hd->active!=hd->cv->b.sc->hstem);
75 : else
76 0 : GGadgetSetEnabled(GWidgetGetControl(hd->gw,CID_Prev),hd->active!=hd->cv->b.sc->vstem);
77 : }
78 0 : GDrawRequestExpose(hd->gw,NULL,false);
79 0 : }
80 :
81 0 : static void RH_SetupHint(ReviewHintData *hd) {
82 : char buffer[20]; unichar_t ubuf[20];
83 : static unichar_t nullstr[] = {'\0'};
84 : StemInfo *h;
85 : int pos,cnt;
86 :
87 0 : if ( hd->lastactive!=NULL )
88 0 : hd->lastactive->active = false;
89 :
90 0 : pos = cnt = 0;
91 0 : for ( h=hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem; h!=NULL; h=h->next ) {
92 0 : ++cnt;
93 0 : if ( h==hd->active ) pos=cnt;
94 : }
95 0 : sprintf( buffer,"%d/%d", pos, cnt );
96 0 : if ( cnt==3 ) {
97 : StemInfo *h2, *h3;
98 0 : h = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem;
99 0 : h2 = h->next; h3 = h2->next;
100 0 : if ( h->width == h2->width && h2->width==h3->width &&
101 0 : h2->start-h->start == h3->start-h2->start )
102 0 : strcat( buffer, hd->ishstem ? " hstem3" : " vstem3" );
103 : }
104 0 : uc_strcpy(ubuf,buffer);
105 0 : GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Count),ubuf);
106 :
107 0 : if ( hd->active==NULL ) {
108 0 : GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Base),nullstr);
109 0 : GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Width),nullstr);
110 0 : GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),false);
111 : } else {
112 0 : hd->active->active = true;
113 0 : sprintf( buffer,"%g", (double) (!hd->active->ghost ? hd->active->start : hd->active->start+hd->active->width) );
114 0 : uc_strcpy(ubuf,buffer);
115 0 : GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Base),ubuf);
116 0 : GTextFieldShow(GWidgetGetControl(hd->gw,CID_Base),0);
117 0 : sprintf( buffer,"%g", (double) (!hd->active->ghost ? hd->active->width : -hd->active->width) );
118 0 : uc_strcpy(ubuf,buffer);
119 0 : GGadgetSetTitle(GWidgetGetControl(hd->gw,CID_Width),ubuf);
120 0 : GTextFieldShow(GWidgetGetControl(hd->gw,CID_Width),0);
121 0 : GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),hd->active->hasconflicts);
122 : }
123 0 : if ( hd->lastactive!=hd->active ) {
124 0 : hd->lastactive = hd->active;
125 0 : SCOutOfDateBackground(hd->cv->b.sc);
126 0 : SCUpdateAll(hd->cv->b.sc); /* Changing the active Hint means we should redraw everything */
127 : }
128 0 : RH_SetNextPrev(hd);
129 0 : }
130 :
131 0 : static int OnHint(StemInfo *hint,real major,real minor) {
132 : HintInstance *hi;
133 :
134 : if ( true /*hint->hasconflicts*/ ) {
135 0 : for ( hi=hint->where; hi!=NULL; hi=hi->next ) {
136 0 : if ( minor>=hi->begin && minor<=hi->end )
137 0 : break;
138 : }
139 0 : if ( hi==NULL )
140 0 : return( 0 );
141 : /* Ok, it's active */
142 : }
143 0 : if ( major==hint->start )
144 0 : return( 1 );
145 0 : else if ( major==hint->start+hint->width )
146 0 : return( 2 );
147 :
148 0 : return( 0 );
149 : }
150 :
151 0 : static void RH_MovePoints(ReviewHintData *hd,StemInfo *active,int start,int width) {
152 0 : SplineChar *sc = hd->cv->b.sc;
153 : SplineSet *spl;
154 : SplinePoint *sp;
155 : int which;
156 0 : int layer = CVLayer( (CharViewBase *) (hd->cv));
157 :
158 0 : if ( !hd->undocreated ) {
159 0 : SCPreserveLayer(sc,layer,true);
160 0 : hd->undocreated = true;
161 : }
162 :
163 0 : for ( spl=sc->layers[layer].splines; spl!=NULL; spl=spl->next ) {
164 0 : for ( sp = spl->first ; ; ) {
165 0 : if ( hd->ishstem ) {
166 0 : switch ((which = OnHint(active,sp->me.y,sp->me.x)) ) {
167 : case 1:
168 0 : sp->nextcp.y += start-sp->me.y;
169 0 : sp->prevcp.y += start-sp->me.y;
170 0 : sp->me.y = start;
171 0 : break;
172 : case 2:
173 0 : sp->nextcp.y += start+width-sp->me.y;
174 0 : sp->prevcp.y += start+width-sp->me.y;
175 0 : sp->me.y = start+width;
176 0 : break;
177 : case 0:
178 : /* Not on hint */;
179 0 : break;
180 : }
181 : } else {
182 0 : switch ( (which = OnHint(active,sp->me.x,sp->me.y)) ) {
183 : case 1:
184 0 : sp->nextcp.x += start-sp->me.x;
185 0 : sp->prevcp.x += start-sp->me.x;
186 0 : sp->me.x = start;
187 0 : break;
188 : case 2:
189 0 : sp->nextcp.x += start+width-sp->me.x;
190 0 : sp->prevcp.x += start+width-sp->me.x;
191 0 : sp->me.x = start+width;
192 0 : break;
193 : case 0:
194 : /* Not on hint */;
195 0 : break;
196 : }
197 : }
198 0 : if ( which ) {
199 0 : if ( sp->prev )
200 0 : SplineRefigure(sp->prev);
201 0 : if ( sp->next )
202 0 : SplineRefigure(sp->next);
203 : }
204 0 : if ( sp->next==NULL )
205 0 : break;
206 0 : sp = sp->next->to;
207 0 : if ( sp== spl->first )
208 0 : break;
209 0 : }
210 : }
211 0 : }
212 :
213 0 : static int RH_TextChanged(GGadget *g, GEvent *e) {
214 : int wasconflict;
215 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_textchanged ) {
216 0 : ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
217 0 : if ( hd->active!=NULL ) {
218 0 : int cid = GGadgetGetCid(g);
219 0 : int err=0;
220 0 : real start = GetCalmReal8(hd->gw,CID_Base,_("Base:"),&err);
221 0 : real width = GetCalmReal8(hd->gw,CID_Width,_("Size:"),&err);
222 0 : if ( err )
223 0 : return( true );
224 0 : if ( GGadgetIsChecked(GWidgetGetControl(GGadgetGetWindow(g),CID_MovePoints)) ) {
225 0 : if ( width<0 )
226 0 : RH_MovePoints(hd,hd->active,start+width,-width);
227 : else
228 0 : RH_MovePoints(hd,hd->active,start,width);
229 : }
230 0 : if ( cid==CID_Base )
231 0 : hd->active->start = start;
232 : else
233 0 : hd->active->width = width;
234 0 : if ( width<0 ) {
235 0 : hd->active->ghost = true;
236 0 : hd->active->width = -width;
237 0 : hd->active->start = start+width;
238 : } else
239 0 : hd->active->ghost = false;
240 0 : wasconflict = hd->active->hasconflicts;
241 0 : if ( hd->ishstem )
242 0 : hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem);
243 : else
244 0 : hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem);
245 0 : hd->cv->b.sc->manualhints = true;
246 0 : hd->changed = true;
247 0 : if ( wasconflict!=hd->active->hasconflicts ) {
248 0 : GGadgetSetVisible(GWidgetGetControl(hd->gw,CID_Overlap),hd->active->hasconflicts);
249 0 : if ( hd->active->hasconflicts )
250 0 : GHVBoxFitWindow(GWidgetGetControl(hd->gw,CID_TopBox));
251 : }
252 0 : SCOutOfDateBackground(hd->cv->b.sc);
253 0 : SCUpdateAll(hd->cv->b.sc);
254 : }
255 : }
256 0 : return( true );
257 : }
258 :
259 0 : static void Do_OKRegen(ReviewHintData *hd) {
260 0 : SplineChar *sc = hd->cv->b.sc;
261 0 : StemInfo *curh = sc->hstem, *curv = sc->vstem;
262 0 : int do_regen = GGadgetIsChecked(GWidgetGetControl(hd->gw,CID_RegenHM));
263 :
264 : /* We go backwards here, but not for long. The point is to go back to */
265 : /* the original hint state so we can preserve it, now that we know we*/
266 : /* are going to modify it */
267 0 : sc->hstem = hd->oldh; sc->vstem = hd->oldv;
268 0 : SCPreserveHints(sc,CVLayer((CharViewBase *) hd->cv));
269 0 : sc->hstem = curh; sc->vstem = curv;
270 :
271 0 : StemInfosFree(hd->oldh);
272 0 : StemInfosFree(hd->oldv);
273 0 : if ( hd->lastactive!=NULL )
274 0 : hd->lastactive->active = false;
275 0 : if ( hd->changed ) {
276 0 : SCClearHintMasks(hd->cv->b.sc,CVLayer((CharViewBase *) (hd->cv)),true);
277 0 : if ( do_regen )
278 0 : SCFigureHintMasks(hd->cv->b.sc,CVLayer((CharViewBase *) (hd->cv)));
279 : }
280 : /* Everything else got done as we went along... */
281 0 : SCOutOfDateBackground(hd->cv->b.sc);
282 0 : SCUpdateAll(hd->cv->b.sc);
283 0 : SCHintsChanged(hd->cv->b.sc);
284 0 : hd->done = true;
285 0 : }
286 :
287 0 : static int RH_OK(GGadget *g, GEvent *e) {
288 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
289 0 : ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
290 0 : Do_OKRegen(hd);
291 : }
292 0 : return( true );
293 : }
294 :
295 0 : static void DoCancel(ReviewHintData *hd) {
296 0 : StemInfosFree(hd->cv->b.sc->hstem);
297 0 : StemInfosFree(hd->cv->b.sc->vstem);
298 0 : hd->cv->b.sc->hstem = hd->oldh;
299 0 : hd->cv->b.sc->vstem = hd->oldv;
300 0 : hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem);
301 0 : hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem);
302 0 : hd->cv->b.sc->manualhints = hd->oldmanual;
303 0 : if ( hd->undocreated )
304 0 : SCDoUndo(hd->cv->b.sc,ly_fore);
305 0 : SCOutOfDateBackground(hd->cv->b.sc);
306 0 : SCUpdateAll(hd->cv->b.sc);
307 0 : hd->done = true;
308 0 : }
309 :
310 0 : static int RH_Cancel(GGadget *g, GEvent *e) {
311 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
312 0 : DoCancel( GDrawGetUserData(GGadgetGetWindow(g)));
313 : }
314 0 : return( true );
315 : }
316 :
317 0 : static int RH_Remove(GGadget *g, GEvent *e) {
318 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
319 0 : ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
320 : StemInfo *prev;
321 0 : if ( hd->active==NULL )
322 0 : return( true ); /* Eh? */
323 0 : if ( hd->active==hd->cv->b.sc->hstem ) {
324 0 : hd->cv->b.sc->hstem = hd->active->next;
325 0 : prev = hd->cv->b.sc->hstem;
326 0 : } else if ( hd->active==hd->cv->b.sc->vstem ) {
327 0 : hd->cv->b.sc->vstem = hd->active->next;
328 0 : prev = hd->cv->b.sc->vstem;
329 : } else {
330 0 : prev = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem;
331 0 : for ( ; prev->next!=hd->active && prev->next!=NULL; prev = prev->next );
332 0 : prev->next = hd->active->next;
333 : }
334 0 : if ( hd->ishstem )
335 0 : hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem);
336 : else
337 0 : hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem);
338 0 : hd->cv->b.sc->manualhints = true;
339 0 : hd->changed = true;
340 0 : StemInfoFree( hd->active );
341 0 : hd->active = prev;
342 0 : SCOutOfDateBackground(hd->cv->b.sc);
343 0 : RH_SetupHint(hd);
344 : /*SCUpdateAll(hd->cv->b.sc);*/ /* Done in RH_SetupHint now */
345 : }
346 0 : return( true );
347 : }
348 :
349 0 : static int RH_Add(GGadget *g, GEvent *e) {
350 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
351 0 : ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
352 0 : CVCreateHint(hd->cv,hd->ishstem,false);
353 0 : hd->active = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem;
354 0 : RH_SetupHint(hd);
355 : }
356 0 : return( true );
357 : }
358 :
359 0 : static int RH_NextPrev(GGadget *g, GEvent *e) {
360 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
361 0 : ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
362 : StemInfo *prev;
363 0 : if ( GGadgetGetCid(g)==CID_Next ) {
364 0 : if ( hd->active->next !=NULL )
365 0 : hd->active = hd->active->next;
366 : } else {
367 0 : prev = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem;
368 0 : for ( ; prev->next!=hd->active && prev->next!=NULL; prev = prev->next );
369 0 : hd->active = prev;
370 : }
371 0 : RH_SetupHint(hd);
372 : }
373 0 : return( true );
374 : }
375 :
376 0 : static int RH_HVStem(GGadget *g, GEvent *e) {
377 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_radiochanged ) {
378 0 : ReviewHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
379 0 : hd->ishstem = GGadgetIsChecked(GWidgetGetControl(GGadgetGetWindow(g),CID_HStem));
380 0 : hd->active = hd->ishstem ? hd->cv->b.sc->hstem : hd->cv->b.sc->vstem;
381 0 : RH_SetupHint(hd);
382 : }
383 0 : return( true );
384 : }
385 :
386 0 : static int rh_e_h(GWindow gw, GEvent *event) {
387 0 : if ( event->type==et_close ) {
388 0 : DoCancel( GDrawGetUserData(gw));
389 0 : } else if ( event->type == et_char ) {
390 0 : return( false );
391 0 : } else if ( event->type == et_map ) {
392 : /* Above palettes */
393 0 : GDrawRaise(gw);
394 : }
395 0 : return( true );
396 : }
397 :
398 0 : void CVReviewHints(CharView *cv) {
399 : GRect pos;
400 : GWindow gw;
401 : GWindowAttrs wattrs;
402 : GGadgetCreateData gcd[18], *harray1[6], *harray2[6], *harray3[6], *harray4[6],
403 : *varray[7][2], boxes[8], *barray[6][6];
404 : GTextInfo label[18];
405 : static ReviewHintData hd;
406 : int k;
407 :
408 0 : hd.done = false;
409 0 : hd.cv = cv;
410 :
411 0 : if ( hd.gw==NULL ) {
412 0 : memset(&wattrs,0,sizeof(wattrs));
413 0 : wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
414 0 : wattrs.event_masks = ~(1<<et_charup);
415 0 : wattrs.restrict_input_to_me = 1;
416 0 : wattrs.undercursor = 1;
417 0 : wattrs.cursor = ct_pointer;
418 0 : wattrs.utf8_window_title = _("Review Hints");
419 0 : wattrs.is_dlg = true;
420 0 : pos.x = pos.y = 0;
421 0 : pos.width = GGadgetScale(GDrawPointsToPixels(NULL,170));
422 0 : pos.height = GDrawPointsToPixels(NULL,178);
423 0 : hd.gw = gw = GDrawCreateTopWindow(NULL,&pos,rh_e_h,&hd,&wattrs);
424 :
425 0 : memset(&label,0,sizeof(label));
426 0 : memset(&gcd,0,sizeof(gcd));
427 0 : memset(&boxes,0,sizeof(boxes));
428 :
429 0 : k=0;
430 :
431 0 : label[k].text = (unichar_t *) _("_HStem");
432 0 : label[k].text_is_1byte = true;
433 0 : label[k].text_in_resource = true;
434 0 : gcd[k].gd.label = &label[k];
435 0 : gcd[k].gd.flags = gg_enabled|gg_visible|gg_cb_on;
436 0 : gcd[k].gd.cid = CID_HStem;
437 0 : gcd[k].gd.handle_controlevent = RH_HVStem;
438 0 : gcd[k].creator = GRadioCreate;
439 0 : harray2[0] = &gcd[k++];
440 :
441 0 : label[k].text = (unichar_t *) _("_VStem");
442 0 : label[k].text_is_1byte = true;
443 0 : label[k].text_in_resource = true;
444 0 : gcd[k].gd.label = &label[k];
445 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
446 0 : gcd[k].gd.cid = CID_VStem;
447 0 : gcd[k].gd.handle_controlevent = RH_HVStem;
448 0 : gcd[k].creator = GRadioCreate;
449 0 : harray2[1] = &gcd[k++];
450 :
451 0 : label[k].text = (unichar_t *) "999/999 hstem3";
452 0 : label[k].text_is_1byte = true;
453 0 : gcd[k].gd.label = &label[k];
454 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
455 0 : gcd[k].gd.cid = CID_Count;
456 0 : gcd[k].creator = GLabelCreate;
457 0 : harray2[2] = GCD_HPad10; harray2[3] = &gcd[k++]; harray2[4] = GCD_Glue; harray2[5] = NULL;
458 :
459 0 : label[k].text = (unichar_t *) _("_Move Points");
460 0 : label[k].text_is_1byte = true;
461 0 : label[k].text_in_resource = true;
462 0 : gcd[k].gd.label = &label[k];
463 0 : gcd[k].gd.flags = gg_enabled|gg_visible|gg_utf8_popup;
464 0 : gcd[k].gd.cid = CID_MovePoints;
465 0 : gcd[k].gd.popup_msg = (unichar_t *) _("When the hint's position is changed\nadjust the postion of any points\nwhich lie on that hint");
466 0 : gcd[k].creator = GCheckBoxCreate;
467 0 : harray3[0] = &gcd[k++]; harray3[1] = GCD_Glue; harray3[2] = NULL;
468 :
469 0 : label[k].text = (unichar_t *) _("_Base:");
470 0 : label[k].text_is_1byte = true;
471 0 : label[k].text_in_resource = true;
472 0 : gcd[k].gd.label = &label[k];
473 0 : gcd[k].gd.pos.x = 5; gcd[k].gd.pos.y = 14+17+5+3;
474 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
475 0 : gcd[k].creator = GLabelCreate;
476 0 : harray1[0] = &gcd[k++];
477 :
478 0 : gcd[k].gd.pos.width = 40;
479 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
480 0 : gcd[k].gd.cid = CID_Base;
481 0 : gcd[k].gd.handle_controlevent = RH_TextChanged;
482 0 : gcd[k].creator = GTextFieldCreate;
483 0 : harray1[1] = &gcd[k++];
484 :
485 0 : label[k].text = (unichar_t *) _("_Size:");
486 0 : label[k].text_is_1byte = true;
487 0 : label[k].text_in_resource = true;
488 0 : gcd[k].gd.label = &label[k];
489 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
490 0 : gcd[k].creator = GLabelCreate;
491 0 : harray1[2] = &gcd[k++];
492 :
493 0 : gcd[k].gd.pos.width = 40;
494 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
495 0 : gcd[k].gd.cid = CID_Width;
496 0 : gcd[k].gd.handle_controlevent = RH_TextChanged;
497 0 : gcd[k].creator = GTextFieldCreate;
498 0 : harray1[3] = &gcd[k++]; harray1[4] = GCD_Glue; harray1[5] = NULL;
499 :
500 0 : gcd[k].gd.flags = gg_visible | gg_enabled;
501 0 : label[k].text = (unichar_t *) "Overlaps another hint";
502 0 : label[k].text_is_1byte = true;
503 0 : label[k].fg = 0xff0000; label[k].bg = COLOR_DEFAULT; /* Doesn't work, needs to be in box */
504 0 : gcd[k].gd.label = &label[k];
505 0 : gcd[k].gd.cid = CID_Overlap;
506 0 : gcd[k].creator = GLabelCreate;
507 0 : harray4[0] = GCD_Glue; harray4[1] = &gcd[k++]; harray4[2] = GCD_Glue; harray4[3] = NULL;
508 :
509 :
510 0 : gcd[k].gd.flags = gg_visible | gg_enabled;
511 0 : label[k].text = (unichar_t *) _("Cr_eate");
512 0 : label[k].text_is_1byte = true;
513 0 : label[k].text_in_resource = true;
514 0 : gcd[k].gd.label = &label[k];
515 0 : gcd[k].gd.cid = CID_Add;
516 0 : gcd[k].gd.handle_controlevent = RH_Add;
517 0 : gcd[k].creator = GButtonCreate;
518 0 : barray[0][0] = GCD_Glue; barray[0][1] = &gcd[k++]; barray[0][2] = GCD_Glue;
519 :
520 0 : gcd[k].gd.flags = gg_visible | gg_enabled;
521 0 : label[k].text = (unichar_t *) _("Re_move");
522 0 : label[k].text_is_1byte = true;
523 0 : label[k].text_in_resource = true;
524 0 : gcd[k].gd.label = &label[k];
525 0 : gcd[k].gd.cid = CID_Remove;
526 0 : gcd[k].gd.handle_controlevent = RH_Remove;
527 0 : gcd[k].creator = GButtonCreate;
528 0 : barray[0][3] = &gcd[k++]; barray[0][4] = GCD_Glue; barray[0][5] = NULL;
529 :
530 0 : gcd[k].gd.pos.width = 170-10;
531 0 : gcd[k].gd.flags = gg_enabled|gg_visible;
532 0 : gcd[k].creator = GLineCreate;
533 0 : barray[1][0] = GCD_Glue; barray[1][1] = &gcd[k++]; barray[1][2] = barray[1][3] = GCD_ColSpan; barray[1][4] = GCD_Glue; barray[1][5] = NULL;
534 :
535 0 : gcd[k].gd.flags = gg_visible | gg_enabled | gg_utf8_popup;
536 0 : label[k].text = (unichar_t *) _("< _Prev");
537 0 : label[k].text_is_1byte = true;
538 0 : label[k].text_in_resource = true;
539 0 : gcd[k].gd.label = &label[k];
540 0 : gcd[k].gd.cid = CID_Prev;
541 0 : gcd[k].gd.popup_msg = (unichar_t *) _("Previous Hint.");
542 0 : gcd[k].gd.handle_controlevent = RH_NextPrev;
543 0 : gcd[k].creator = GButtonCreate;
544 0 : barray[2][0] = GCD_Glue; barray[2][1] = &gcd[k++]; barray[2][2] = GCD_Glue;
545 :
546 0 : gcd[k].gd.flags = gg_visible | gg_enabled | gg_utf8_popup;
547 0 : label[k].text = (unichar_t *) _("_Next >");
548 0 : label[k].text_is_1byte = true;
549 0 : label[k].text_in_resource = true;
550 0 : gcd[k].gd.label = &label[k];
551 0 : gcd[k].gd.cid = CID_Next;
552 0 : gcd[k].gd.popup_msg = (unichar_t *) _("Next Hint.");
553 0 : gcd[k].gd.handle_controlevent = RH_NextPrev;
554 0 : gcd[k].creator = GButtonCreate;
555 0 : barray[2][3] = &gcd[k++]; barray[2][4] = GCD_Glue; barray[2][5] = NULL;
556 :
557 0 : label[k].text = (unichar_t *) _("Regenerate Hint Substitution Points");
558 0 : label[k].text_is_1byte = true;
559 0 : label[k].text_in_resource = true;
560 0 : gcd[k].gd.label = &label[k];
561 0 : gcd[k].gd.flags = gg_enabled|gg_visible|gg_cb_on|gg_utf8_popup;
562 0 : gcd[k].gd.cid = CID_RegenHM;
563 0 : gcd[k].gd.popup_msg = (unichar_t *) _("If you have made any changes to the hints,\nthen in addition to changing the glyph's hints\nrefigure it's hint masks and substitution points.");
564 0 : gcd[k].creator = GCheckBoxCreate;
565 0 : barray[3][0] = &gcd[k++]; barray[3][1] = barray[3][2] = barray[3][3] = barray[3][4] = GCD_ColSpan; barray[3][5] = NULL;
566 :
567 0 : gcd[k].gd.flags = gg_visible | gg_enabled;
568 0 : label[k].text = (unichar_t *) _("_OK");
569 0 : label[k].text_is_1byte = true;
570 0 : label[k].text_in_resource = true;
571 0 : gcd[k].gd.label = &label[k];
572 0 : gcd[k].gd.handle_controlevent = RH_OK;
573 0 : gcd[k].creator = GButtonCreate;
574 0 : barray[4][0] = GCD_Glue; barray[4][1] = &gcd[k++]; barray[4][2] = GCD_Glue;
575 :
576 0 : gcd[k].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
577 0 : label[k].text = (unichar_t *) _("_Cancel");
578 0 : label[k].text_is_1byte = true;
579 0 : label[k].text_in_resource = true;
580 0 : gcd[k].gd.label = &label[k];
581 0 : gcd[k].gd.handle_controlevent = RH_Cancel;
582 0 : gcd[k].creator = GButtonCreate;
583 0 : barray[4][3] = &gcd[k++]; barray[4][4] = GCD_Glue; barray[4][5] = NULL;
584 0 : barray[5][0] = NULL;
585 :
586 0 : boxes[2].gd.flags = gg_enabled|gg_visible;
587 0 : boxes[2].gd.u.boxelements = harray2;
588 0 : boxes[2].creator = GHBoxCreate;
589 :
590 0 : boxes[3].gd.flags = gg_enabled|gg_visible;
591 0 : boxes[3].gd.u.boxelements = harray3;
592 0 : boxes[3].creator = GHBoxCreate;
593 :
594 0 : boxes[4].gd.flags = gg_enabled|gg_visible;
595 0 : boxes[4].gd.u.boxelements = harray1;
596 0 : boxes[4].creator = GHBoxCreate;
597 :
598 0 : boxes[5].gd.flags = gg_enabled|gg_visible;
599 0 : boxes[5].gd.u.boxelements = harray4;
600 0 : boxes[5].creator = GHBoxCreate;
601 :
602 0 : boxes[6].gd.flags = gg_enabled|gg_visible;
603 0 : boxes[6].gd.u.boxelements = barray[0];
604 0 : boxes[6].creator = GHVBoxCreate;
605 :
606 0 : varray[0][0] = &boxes[2]; varray[0][1] = NULL;
607 0 : varray[1][0] = &boxes[3]; varray[1][1] = NULL;
608 0 : varray[2][0] = &boxes[4]; varray[2][1] = NULL;
609 0 : varray[3][0] = &boxes[5]; varray[3][1] = NULL;
610 0 : varray[4][0] = &boxes[6]; varray[4][1] = NULL;
611 0 : varray[5][0] = NULL;
612 :
613 0 : boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
614 0 : boxes[0].gd.flags = gg_enabled|gg_visible;
615 0 : boxes[0].gd.u.boxelements = varray[0];
616 0 : boxes[0].gd.cid = CID_TopBox;
617 0 : boxes[0].creator = GHVGroupCreate;
618 :
619 :
620 0 : GGadgetsCreate(gw,boxes);
621 :
622 0 : GHVBoxSetExpandableRow(boxes[0].ret,3);
623 0 : GHVBoxSetExpandableCol(boxes[2].ret,gb_expandglue);
624 0 : GHVBoxSetExpandableCol(boxes[3].ret,gb_expandglue);
625 0 : GHVBoxSetExpandableCol(boxes[4].ret,gb_expandglue);
626 0 : GHVBoxSetExpandableCol(boxes[5].ret,gb_expandglue);
627 0 : GHVBoxSetExpandableCol(boxes[6].ret,gb_expandglue);
628 0 : GHVBoxFitWindow(boxes[0].ret);
629 : } else {
630 0 : gw = hd.gw;
631 0 : GDrawSetTransientFor(gw,(GWindow) -1);
632 : }
633 0 : if ( cv->b.sc->hstem==NULL && cv->b.sc->vstem==NULL )
634 0 : hd.active = NULL;
635 0 : else if ( cv->b.sc->hstem!=NULL && cv->b.sc->vstem!=NULL ) {
636 0 : if ( GGadgetIsChecked(GWidgetGetControl(gw,CID_HStem)))
637 0 : hd.active = cv->b.sc->hstem;
638 : else
639 0 : hd.active = cv->b.sc->vstem;
640 0 : } else if ( cv->b.sc->hstem!=NULL ) {
641 0 : GGadgetSetChecked(GWidgetGetControl(gw,CID_HStem),true);
642 0 : hd.active = cv->b.sc->hstem;
643 : } else {
644 0 : GGadgetSetChecked(GWidgetGetControl(gw,CID_VStem),true);
645 0 : hd.active = cv->b.sc->vstem;
646 : }
647 0 : hd.ishstem = (hd.active==cv->b.sc->hstem);
648 0 : hd.oldh = StemInfoCopy(cv->b.sc->hstem);
649 0 : hd.oldv = StemInfoCopy(cv->b.sc->vstem);
650 0 : hd.oldmanual = cv->b.sc->manualhints;
651 0 : hd.changed = false;
652 0 : RH_SetupHint(&hd);
653 0 : if ( hd.active!=NULL ) {
654 0 : GWidgetIndicateFocusGadget(GWidgetGetControl(gw,CID_Base));
655 0 : GTextFieldSelect(GWidgetGetControl(gw,CID_Base),0,-1);
656 : }
657 :
658 0 : GWidgetHidePalettes();
659 0 : GDrawSetVisible(gw,true);
660 0 : while ( !hd.done )
661 0 : GDrawProcessOneEvent(NULL);
662 0 : GDrawSetVisible(gw,false);
663 0 : }
664 :
665 : typedef struct createhintdata {
666 : unsigned int done: 1;
667 : unsigned int ishstem: 1;
668 : unsigned int preservehints: 1;
669 : CharView *cv;
670 : GWindow gw;
671 : } CreateHintData;
672 :
673 0 : static int CH_OK(GGadget *g, GEvent *e) {
674 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
675 0 : CreateHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
676 : real base, width;
677 0 : int err = 0;
678 : StemInfo *h;
679 0 : int layer = CVLayer((CharViewBase *) hd->cv);
680 :
681 0 : base = GetReal8(hd->gw,CID_Base,_("Base:"),&err);
682 0 : width = GetReal8(hd->gw,CID_Width,_("Size:"),&err);
683 0 : if ( err )
684 0 : return(true);
685 0 : if ( hd->preservehints ) {
686 0 : SCPreserveHints(hd->cv->b.sc,layer);
687 0 : SCHintsChanged(hd->cv->b.sc);
688 : }
689 0 : h = chunkalloc(sizeof(StemInfo));
690 0 : if ( width==-21 || width==-20 ) {
691 0 : base += width;
692 0 : width = -width;
693 0 : h->ghost = true;
694 : }
695 0 : h->start = base;
696 0 : h->width = width;
697 0 : if ( hd->ishstem ) {
698 0 : SCGuessHHintInstancesAndAdd(hd->cv->b.sc,layer,h,0x80000000,0x80000000);
699 0 : hd->cv->b.sc->hconflicts = StemListAnyConflicts(hd->cv->b.sc->hstem);
700 : } else {
701 0 : SCGuessVHintInstancesAndAdd(hd->cv->b.sc,layer,h,0x80000000,0x80000000);
702 0 : hd->cv->b.sc->vconflicts = StemListAnyConflicts(hd->cv->b.sc->vstem);
703 : }
704 0 : hd->cv->b.sc->manualhints = true;
705 0 : if ( h!=NULL && hd->cv->b.sc->parent->mm==NULL )
706 0 : SCModifyHintMasksAdd(hd->cv->b.sc,layer,h);
707 : else
708 0 : SCClearHintMasks(hd->cv->b.sc,layer,true);
709 0 : SCOutOfDateBackground(hd->cv->b.sc);
710 0 : SCUpdateAll(hd->cv->b.sc);
711 0 : hd->done = true;
712 : }
713 0 : return( true );
714 : }
715 :
716 0 : static int CH_Cancel(GGadget *g, GEvent *e) {
717 0 : if ( e->type==et_controlevent && e->u.control.subtype == et_buttonactivate ) {
718 0 : CreateHintData *hd = GDrawGetUserData(GGadgetGetWindow(g));
719 0 : hd->done = true;
720 : }
721 0 : return( true );
722 : }
723 :
724 0 : static int chd_e_h(GWindow gw, GEvent *event) {
725 0 : if ( event->type==et_close ) {
726 0 : CreateHintData *hd = GDrawGetUserData(gw);
727 0 : hd->done = true;
728 0 : } else if ( event->type == et_char ) {
729 0 : return( false );
730 0 : } else if ( event->type == et_map ) {
731 : /* Above palettes */
732 0 : GDrawRaise(gw);
733 : }
734 0 : return( true );
735 : }
736 :
737 0 : void CVCreateHint(CharView *cv,int ishstem,int preservehints) {
738 : GRect pos;
739 : GWindow gw;
740 : GWindowAttrs wattrs;
741 : GGadgetCreateData gcd[9], *harray1[4], *harray2[9], *barray[7], *varray[5][2], boxes[5];
742 : GTextInfo label[9];
743 : static CreateHintData chd;
744 : char buffer[20]; unichar_t ubuf[20];
745 :
746 0 : chd.done = false;
747 0 : chd.ishstem = ishstem;
748 0 : chd.preservehints = preservehints;
749 0 : chd.cv = cv;
750 :
751 0 : if ( chd.gw==NULL ) {
752 0 : memset(&wattrs,0,sizeof(wattrs));
753 0 : wattrs.mask = wam_events|wam_cursor|wam_utf8_wtitle|wam_undercursor|wam_isdlg|wam_restrict;
754 0 : wattrs.event_masks = ~(1<<et_charup);
755 0 : wattrs.restrict_input_to_me = 1;
756 0 : wattrs.undercursor = 1;
757 0 : wattrs.cursor = ct_pointer;
758 0 : wattrs.utf8_window_title = _("Create Hint");
759 0 : wattrs.is_dlg = true;
760 0 : pos.x = pos.y = 0;
761 0 : pos.width = GGadgetScale(GDrawPointsToPixels(NULL,170));
762 0 : pos.height = GDrawPointsToPixels(NULL,90);
763 0 : chd.gw = gw = GDrawCreateTopWindow(NULL,&pos,chd_e_h,&chd,&wattrs);
764 :
765 0 : memset(&label,0,sizeof(label));
766 0 : memset(&gcd,0,sizeof(gcd));
767 0 : memset(&boxes,0,sizeof(boxes));
768 :
769 0 : label[0].text = (unichar_t *) _("_Base:");
770 0 : label[0].text_is_1byte = true;
771 0 : label[0].text_in_resource = true;
772 0 : gcd[0].gd.label = &label[0];
773 0 : gcd[0].gd.pos.x = 5; gcd[0].gd.pos.y = 17+5+6;
774 0 : gcd[0].gd.flags = gg_enabled|gg_visible;
775 0 : gcd[0].creator = GLabelCreate;
776 0 : harray2[0] = GCD_Glue; harray2[1] = &gcd[0];
777 :
778 0 : sprintf( buffer, "%g", (double) (ishstem ? cv->p.cy : cv->p.cx) );
779 0 : label[1].text = (unichar_t *) buffer;
780 0 : label[1].text_is_1byte = true;
781 0 : gcd[1].gd.label = &label[1];
782 0 : gcd[1].gd.pos.x = 37; gcd[1].gd.pos.y = 17+5; gcd[1].gd.pos.width = 40;
783 0 : gcd[1].gd.flags = gg_enabled|gg_visible;
784 0 : gcd[1].gd.cid = CID_Base;
785 0 : gcd[1].creator = GTextFieldCreate;
786 0 : harray2[2] = &gcd[1];
787 :
788 0 : label[2].text = (unichar_t *) _("_Size:");
789 0 : label[2].text_is_1byte = true;
790 0 : label[2].text_in_resource = true;
791 0 : gcd[2].gd.label = &label[2];
792 0 : gcd[2].gd.pos.x = 90; gcd[2].gd.pos.y = 17+5+6;
793 0 : gcd[2].gd.flags = gg_enabled|gg_visible;
794 0 : gcd[2].creator = GLabelCreate;
795 0 : harray2[3] = GCD_Glue; harray2[4] = &gcd[2];
796 :
797 0 : label[3].text = (unichar_t *) "60";
798 0 : label[3].text_is_1byte = true;
799 0 : gcd[3].gd.label = &label[3];
800 0 : gcd[3].gd.pos.x = 120; gcd[3].gd.pos.y = 17+5; gcd[3].gd.pos.width = 40;
801 0 : gcd[3].gd.flags = gg_enabled|gg_visible;
802 0 : gcd[3].gd.cid = CID_Width;
803 0 : gcd[3].creator = GTextFieldCreate;
804 0 : harray2[5] = &gcd[3]; harray2[6] = GCD_Glue; harray2[7] = NULL;
805 :
806 0 : gcd[4].gd.pos.x = 20-3; gcd[4].gd.pos.y = 17+37;
807 0 : gcd[4].gd.pos.width = -1; gcd[4].gd.pos.height = 0;
808 0 : gcd[4].gd.flags = gg_visible | gg_enabled | gg_but_default;
809 0 : label[4].text = (unichar_t *) _("_OK");
810 0 : label[4].text_is_1byte = true;
811 0 : label[4].text_in_resource = true;
812 0 : gcd[4].gd.mnemonic = 'O';
813 0 : gcd[4].gd.label = &label[4];
814 0 : gcd[4].gd.handle_controlevent = CH_OK;
815 0 : gcd[4].creator = GButtonCreate;
816 0 : barray[0] = GCD_Glue; barray[1] = &gcd[4]; barray[2] = GCD_Glue;
817 :
818 0 : gcd[5].gd.pos.x = -20; gcd[5].gd.pos.y = 17+37+3;
819 0 : gcd[5].gd.pos.width = -1; gcd[5].gd.pos.height = 0;
820 0 : gcd[5].gd.flags = gg_visible | gg_enabled | gg_but_cancel;
821 0 : label[5].text = (unichar_t *) _("_Cancel");
822 0 : label[5].text_is_1byte = true;
823 0 : label[5].text_in_resource = true;
824 0 : gcd[5].gd.label = &label[5];
825 0 : gcd[5].gd.mnemonic = 'C';
826 0 : gcd[5].gd.handle_controlevent = CH_Cancel;
827 0 : gcd[5].creator = GButtonCreate;
828 0 : barray[3] = GCD_Glue; barray[4] = &gcd[5]; barray[5] = GCD_Glue; barray[6] = NULL;
829 :
830 0 : label[6].text = (unichar_t *) _("Create Horizontal Stem Hint"); /* Initialize to bigger size */
831 0 : label[6].text_is_1byte = true;
832 0 : gcd[6].gd.label = &label[6];
833 0 : gcd[6].gd.pos.x = 17; gcd[6].gd.pos.y = 5;
834 0 : gcd[6].gd.flags = gg_enabled|gg_visible;
835 0 : gcd[6].gd.cid = CID_Label;
836 0 : gcd[6].creator = GLabelCreate;
837 0 : harray1[0] = GCD_Glue; harray1[1] = &gcd[6]; harray1[2] = GCD_Glue; harray1[3] = NULL;
838 :
839 0 : gcd[7].gd.pos.x = 5; gcd[7].gd.pos.y = 17+31;
840 0 : gcd[7].gd.pos.width = 170-10;
841 0 : gcd[7].gd.flags = gg_enabled|gg_visible;
842 0 : gcd[7].creator = GLineCreate;
843 :
844 0 : boxes[2].gd.flags = gg_enabled|gg_visible;
845 0 : boxes[2].gd.u.boxelements = harray1;
846 0 : boxes[2].creator = GHBoxCreate;
847 :
848 0 : boxes[3].gd.flags = gg_enabled|gg_visible;
849 0 : boxes[3].gd.u.boxelements = harray2;
850 0 : boxes[3].creator = GHBoxCreate;
851 :
852 0 : boxes[4].gd.flags = gg_enabled|gg_visible;
853 0 : boxes[4].gd.u.boxelements = barray;
854 0 : boxes[4].creator = GHBoxCreate;
855 :
856 0 : varray[0][0] = &boxes[2]; varray[0][1] = NULL;
857 0 : varray[1][0] = &boxes[3]; varray[1][1] = NULL;
858 0 : varray[2][0] = &gcd[7]; varray[2][1] = NULL;
859 0 : varray[3][0] = &boxes[4]; varray[3][1] = NULL;
860 0 : varray[4][0] = NULL;
861 :
862 0 : boxes[0].gd.pos.x = boxes[0].gd.pos.y = 2;
863 0 : boxes[0].gd.flags = gg_enabled|gg_visible;
864 0 : boxes[0].gd.u.boxelements = varray[0];
865 0 : boxes[0].creator = GHVGroupCreate;
866 :
867 :
868 0 : GGadgetsCreate(gw,boxes);
869 0 : GHVBoxSetExpandableCol(boxes[2].ret,gb_expandglue);
870 0 : GHVBoxSetExpandableCol(boxes[3].ret,gb_expandglue);
871 0 : GHVBoxSetExpandableCol(boxes[4].ret,gb_expandgluesame);
872 0 : GHVBoxFitWindow(boxes[0].ret);
873 : } else {
874 0 : gw = chd.gw;
875 0 : sprintf( buffer, "%g", (double) (ishstem ? cv->p.cy : cv->p.cx) );
876 0 : uc_strcpy(ubuf,buffer);
877 0 : GGadgetSetTitle(GWidgetGetControl(gw,CID_Base),ubuf);
878 0 : GDrawSetTransientFor(gw,(GWindow) -1);
879 : }
880 0 : GGadgetSetTitle8(GWidgetGetControl(gw,CID_Label),
881 : ishstem ? _("Create Horizontal Stem Hint") :
882 : _("Create Vertical Stem Hint"));
883 0 : GWidgetIndicateFocusGadget(GWidgetGetControl(gw,CID_Base));
884 0 : GTextFieldSelect(GWidgetGetControl(gw,CID_Base),0,-1);
885 :
886 0 : GWidgetHidePalettes();
887 0 : GDrawSetVisible(gw,true);
888 0 : while ( !chd.done )
889 0 : GDrawProcessOneEvent(NULL);
890 0 : GDrawSetVisible(gw,false);
891 0 : }
892 :
893 0 : void SCRemoveSelectedMinimumDistances(SplineChar *sc,int inx) {
894 : /* Remove any minimum distance where at least one of the two points is */
895 : /* selected */
896 : MinimumDistance *md, *prev, *next;
897 : SplineSet *ss;
898 : SplinePoint *sp;
899 :
900 0 : prev = NULL;
901 0 : for ( md = sc->md; md!=NULL; md = next ) {
902 0 : next = md->next;
903 0 : if ( (inx==2 || inx==md->x) &&
904 0 : ((md->sp1!=NULL && md->sp1->selected) ||
905 0 : (md->sp2!=NULL && md->sp2->selected))) {
906 0 : if ( prev==NULL )
907 0 : sc->md = next;
908 : else
909 0 : prev->next = next;
910 0 : chunkfree(md,sizeof(MinimumDistance));
911 : } else
912 0 : prev = md;
913 : }
914 :
915 0 : for ( ss=sc->layers[ly_fore].splines; ss!=NULL; ss=ss->next ) {
916 0 : for ( sp=ss->first; ; ) {
917 0 : if ( sp->selected ) {
918 0 : if ( inx==2 ) sp->roundx = sp->roundy = false;
919 0 : else if ( inx==1 ) sp->roundx = false;
920 0 : else sp->roundy = false;
921 : }
922 0 : if ( sp->next==NULL )
923 0 : break;
924 0 : sp = sp->next->to;
925 0 : if ( sp==ss->first )
926 0 : break;
927 0 : }
928 : }
929 0 : }
|