1 /************************************************************************/
2 /* */
3 /* A Border Tool. Used on the pages of the format tool. */
4 /* */
5 /************************************************************************/
6
7 # include "tedConfig.h"
8
9 # include <stdio.h>
10 # include <stddef.h>
11
12 # include "tedDraw.h"
13 # include "tedBorderTool.h"
14 # include <guiToolUtil.h>
15 # include <guiTextUtil.h>
16
17 # include <guiWidgetDrawingSurface.h>
18 # include <guiDrawingWidget.h>
19 # include <appUnit.h>
20 # include <appDebugon.h>
21
22 # define MAKE_COLOR_ROW 0
23
24 # define USE_FRAME 0
25 # define USE_FRAME_TITLE 0
26 # define USE_TOGGLE_TITLE 1
27
28 # define THICK_CHARS 8
29
30 # if USE_FRAME
31 # define ONOFF_COLUMN 0
32 # define ONOFF_COLSPAN 1
33
34 # define THICK_COLUMN (ONOFF_COLUMN+ONOFF_COLSPAN)
35 # define THICK_COLSPAN 3
36
37 # define COLOR_COLUMN (THICK_COLUMN+THICK_COLSPAN)
38 # define COLOR_COLSPAN 7
39 # else
40 # define ONOFF_COLUMN 0
41 # define ONOFF_COLSPAN 1
42
43 # define THICK_COLUMN (ONOFF_COLUMN+ONOFF_COLSPAN)
44 # define THICK_COLSPAN 1
45
46 # define COLOR_COLUMN (THICK_COLUMN+THICK_COLSPAN)
47 # define COLOR_COLSPAN 2
48 # endif
49
50 # define ONOFF_ROW_COLUMNS (ONOFF_COLSPAN+THICK_COLSPAN+COLOR_COLSPAN)
51
52 /************************************************************************/
53 /* */
54 /* Show the border width in a border tool. */
55 /* */
56 /************************************************************************/
57
tedBorderToolShowWide(BorderTool * bt)58 static void tedBorderToolShowWide( BorderTool * bt )
59 {
60 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
61
62 guiEnableText( bt->btWideText,
63 bt->btEnabled && ebp->ebpStyle != DOCbsNONE );
64
65 if ( ebp->ebpStyle != DOCbsNONE )
66 {
67 appLengthToTextWidget( bt->btWideText,
68 ebp->ebpPenWideTwips, UNITtyPOINTS );
69 }
70 else{ appStringToTextWidget( bt->btWideText, "" ); }
71
72 return;
73 }
74
75 /************************************************************************/
76
tedEnableBorderTool(BorderTool * bt,int enabled)77 void tedEnableBorderTool( BorderTool * bt,
78 int enabled )
79 {
80 if ( bt->btEnabled != enabled )
81 {
82 bt->btEnabled= enabled;
83
84 appEnableColorChooser( &(bt->btColorChooser), enabled );
85 guiEnableWidget( bt->btOnOffToggle, enabled );
86
87 tedBorderToolShowWide( bt );
88
89 # if USE_FRAME
90 guiEnableWidget( bt->btFrame, enabled );
91 # else
92 guiEnableWidget( bt->btOnOffRow, enabled );
93 # endif
94 }
95 }
96
97 /************************************************************************/
98 /* */
99 /* Conform to border settings from the application. */
100 /* */
101 /************************************************************************/
102
tedBorderToolSetProperties(BorderTool * bt,const DocumentProperties * dp,const BorderProperties * bpSet)103 static void tedBorderToolSetProperties( BorderTool * bt,
104 const DocumentProperties * dp,
105 const BorderProperties * bpSet )
106 {
107 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
108 int set= 0;
109
110 const int avoidZero= 1;
111
112 docExpandBorderProperties( ebp, bpSet, dp->dpColorPalette );
113
114 if ( ebp->ebpStyle != DOCbsNONE )
115 { set= 1; }
116
117 appGuiSetToggleState( bt->btOnOffToggle, set );
118 tedBorderToolShowWide( bt );
119
120 if ( bt->btStyleRow )
121 {
122 appExposeDrawnPulldownInplace( &(bt->btStylePulldown) );
123 }
124
125 appColorChooserSuggestPalette( &(bt->btColorChooser),
126 avoidZero, dp->dpColorPalette );
127 appColorChooserSetColor( &(bt->btColorChooser),
128 ebp->ebpColorExplicit,
129 &(ebp->ebpColor) );
130 appShowColorChooser( &(bt->btColorChooser), set );
131 if ( bt->btColorRow != bt->btOnOffRow )
132 { guiEnableWidget( bt->btColorRow, set ); }
133
134 utilPropMaskClear( &(bt->btPropertiesChanged) );
135
136 return;
137 }
138
tedBorderToolSetPropertiesByNumber(BorderTool * bt,const BufferDocument * bd,int num)139 void tedBorderToolSetPropertiesByNumber( BorderTool * bt,
140 const BufferDocument * bd,
141 int num )
142 {
143 const DocumentProperties * dp= &(bd->bdProperties);
144 BorderProperties bp;
145
146 docGetBorderPropertiesByNumber( &bp, bd, num );
147
148 tedBorderToolSetProperties( bt, dp, &bp );
149
150 return;
151 }
152
153 /************************************************************************/
154 /* */
155 /* Draw the widgets of a border tool. */
156 /* */
157 /************************************************************************/
158
tedDrawBorderStyle(DrawingSurface ds,BorderTool * bt,int style,const DocumentRectangle * drI)159 static void tedDrawBorderStyle( DrawingSurface ds,
160 BorderTool * bt,
161 int style,
162 const DocumentRectangle * drI )
163 {
164 if ( style != DOCbsNONE )
165 {
166 const int minThick= 1;
167
168 tedDrawHorizontalBorderLine( ds, style, minThick,
169 drI->drX0,
170 drI->drX1, ( drI->drY0+ drI->drY1 )/ 2 );
171 }
172
173 /* NO.. Confuses
174 drawLine( ds, drI->drX0, drI->drY0, drI->drX1, drI->drY0 );
175 drawLine( ds, drI->drX1, drI->drY0, drI->drX1, drI->drY1 );
176 drawLine( ds, drI->drX1, drI->drY1, drI->drX0, drI->drY1 );
177 drawLine( ds, drI->drX0, drI->drY1, drI->drX0, drI->drY0 );
178 */
179
180 return;
181 }
182
APP_EVENT_HANDLER_H(tedBorderToolRedrawInplace,w,voidbt,exposeEvent)183 static APP_EVENT_HANDLER_H( tedBorderToolRedrawInplace, w, voidbt, exposeEvent )
184 {
185 BorderTool * bt= (BorderTool *)voidbt;
186 DrawingSurface dsI= bt->btStylePulldown.adpInplaceDrawingSurface;
187
188 int wide;
189 int high;
190
191 DocumentRectangle drClip;
192 DocumentRectangle drI;
193
194 guiCollectExposures( &drClip, bt->btStylePulldown.adpInplaceDrawing,
195 exposeEvent );
196
197 drawSetClipRect( dsI, &drClip );
198
199 appDrawnPulldownDrawArrow( &drClip, &wide, &high, w,
200 &(bt->btStylePulldown) );
201
202 drawNoClipping( dsI );
203
204 drI.drX0= 0; drI.drX1= wide- 1;
205 drI.drY0= 0; drI.drY1= high- 1;
206 drawSetForegroundColorWhite( dsI );
207 drawFillRectangle( dsI, &drI );
208
209 drI.drX0= 3; drI.drX1= wide- 3;
210 drI.drY0= 3; drI.drY1= high- 3;
211 drawSetForegroundColorBlack( dsI );
212 tedDrawBorderStyle( dsI, bt, bt->btPropertiesChosen.ebpStyle, &drI );
213
214 return;
215 }
216
APP_EVENT_HANDLER_H(tedBorderToolRedrawPulldown,w,voidbt,exposeEvent)217 static APP_EVENT_HANDLER_H( tedBorderToolRedrawPulldown, w, voidbt, exposeEvent )
218 {
219 BorderTool * bt= (BorderTool *)voidbt;
220 DrawingSurface dsP;
221
222 int inplaceWide;
223 int inplaceHigh;
224 int pulldownWide;
225 int pulldownHigh;
226
227 DocumentRectangle drClip;
228 DocumentRectangle drBox;
229
230 int i;
231
232 if ( appFinishDrawnPulldownPulldown( &(bt->btStylePulldown) ) )
233 { LDEB(1); return; }
234
235 dsP= bt->btStylePulldown.adpPulldownDrawingSurface;
236
237 guiDrawGetSizeOfWidget( &pulldownWide, &pulldownHigh, w );
238 guiDrawGetSizeOfWidget( &inplaceWide, &inplaceHigh,
239 bt->btStylePulldown.adpInplaceDrawing );
240
241 guiCollectExposures( &drClip, bt->btStylePulldown.adpPulldownDrawing,
242 exposeEvent );
243
244 drawSetForegroundColorWhite( dsP );
245 drawFillRectangle( dsP, &drClip );
246
247 drBox.drX0= 0;
248 drBox.drY0= 0;
249 drBox.drX1= pulldownWide- 1;
250 drBox.drY1= pulldownHigh- 1;
251
252 drawSetForegroundColorBlack( dsP );
253 drawRectangle( dsP, &drBox );
254
255 for ( i= DOCbsNONE+ 1; i < DOCbs_COUNT; i++ )
256 {
257 DocumentRectangle drI;
258 DocumentRectangle drX;
259
260 drI.drX0= 3;
261 drI.drX1= pulldownWide- 3;
262 drI.drY0= ( i+ 0 )* inplaceHigh+ 3;
263 drI.drY1= ( i+ 1 )* inplaceHigh- 3;
264
265 if ( ! geoIntersectRectangle( &drX, &drI, &drClip ) )
266 { continue; }
267
268 tedDrawBorderStyle( dsP, bt, i, &drI );
269 }
270
271 return;
272 }
273
274
275 /************************************************************************/
276 /* */
277 /* One of the border on/off toggles has been activated by a user. */
278 /* */
279 /************************************************************************/
280
APP_TOGGLE_CALLBACK_H(tedBorderToolOnOffToggled,w,voidbt,voidtbcs)281 static APP_TOGGLE_CALLBACK_H( tedBorderToolOnOffToggled, w, voidbt, voidtbcs )
282 {
283 BorderTool * bt= (BorderTool *)voidbt;
284 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
285
286 int set;
287
288 PropertyMask bpSetMask;
289
290 utilPropMaskClear( &bpSetMask );
291
292 set= appGuiGetToggleStateFromCallback( w, voidtbcs );
293
294 if ( set )
295 {
296 if ( ebp->ebpStyle == DOCbsNONE )
297 {
298 ebp->ebpStyle= DOCbsS;
299 PROPmaskADD( &bpSetMask, BRDRpropSTYLE );
300 PROPmaskADD( &(bt->btPropertiesChanged), BRDRpropSTYLE );
301 /*changed= 1;*/
302 }
303
304 if ( ebp->ebpPenWideTwips == 0 )
305 {
306 ebp->ebpPenWideTwips= 15;
307 PROPmaskADD( &bpSetMask, BRDRpropPEN_WIDE );
308 PROPmaskADD( &(bt->btPropertiesChanged), BRDRpropPEN_WIDE );
309 /*changed= 1;*/
310 }
311 }
312 else{
313 if ( ebp->ebpStyle != DOCbsNONE )
314 {
315 ebp->ebpStyle= DOCbsNONE;
316 PROPmaskADD( &bpSetMask, BRDRpropSTYLE );
317 PROPmaskADD( &(bt->btPropertiesChanged), BRDRpropSTYLE );
318 /*changed= 1;*/
319 }
320 }
321
322 /*
323 if ( changed && bt->btCallback )
324 { (*bt->btCallback)( bt, bt->btTarget, &bpSetMask, bp ); }
325 */
326
327 tedBorderToolShowWide( bt );
328 appShowColorChooser( &(bt->btColorChooser), set );
329 if ( bt->btColorRow != bt->btOnOffRow )
330 { guiEnableWidget( bt->btColorRow, set ); }
331
332 return;
333 }
334
335 /************************************************************************/
336 /* */
337 /* A border style was chosen. */
338 /* */
339 /* 1) Determine strip. */
340 /* 2) Value in range? */
341 /* 3) If the value changed.. */
342 /* 4) Remember new value */
343 /* 5) Provoke a redraw of the image */
344 /* */
345 /************************************************************************/
346
APP_EVENT_HANDLER_H(tedBorderToolClickedPulldown,w,voidbt,mouseEvent)347 static APP_EVENT_HANDLER_H( tedBorderToolClickedPulldown, w, voidbt, mouseEvent )
348 {
349 BorderTool * bt= (BorderTool *)voidbt;
350 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
351
352 int style;
353
354 /* 1 */
355 if ( appGuiDrawnPulldownGetStrip( &style,
356 &(bt->btStylePulldown), w, mouseEvent ) )
357 { return; }
358
359 /* 2 */
360 if ( style < 0 || style >= DOCbs_COUNT )
361 { LLDEB(style,DOCbs_COUNT); return; }
362
363 /* 3 */
364 if ( ebp->ebpStyle != style )
365 {
366 /* 4 */
367 ebp->ebpStyle= style;
368 PROPmaskADD( &(bt->btPropertiesChanged), BRDRpropSTYLE );
369
370 /* 5 */
371 appExposeDrawnPulldownInplace( &(bt->btStylePulldown) );
372 }
373
374 return;
375 }
376
377 /************************************************************************/
378 /* */
379 /* 1) The user typed Something in the 'Width' text box. */
380 /* 2) The user typed 'Enter' in the 'Width' text box. */
381 /* */
382 /************************************************************************/
383
384 /* 1 */
APP_TXTYPING_CALLBACK_H(tedFormatBorderWidthTyped,w,voidbt)385 static APP_TXTYPING_CALLBACK_H( tedFormatBorderWidthTyped, w, voidbt )
386 {
387 BorderTool * bt= (BorderTool *)voidbt;
388
389 PROPmaskADD( &(bt->btPropertiesChanged), BRDRpropPEN_WIDE );
390
391 return;
392 }
393
394 /* 2 */
APP_TXACTIVATE_CALLBACK_H(tedFormatBorderWidthChanged,w,voidbt)395 static APP_TXACTIVATE_CALLBACK_H( tedFormatBorderWidthChanged, w, voidbt )
396 {
397 BorderTool * bt= (BorderTool *)voidbt;
398 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
399
400 int wide= 0;
401 int changed= 0;
402
403 const int minValue= 1;
404 const int adaptToMin= 0;
405 const int maxValue= 75;
406 const int adaptToMax= 0;
407
408 PropertyMask bpSetMask;
409
410 utilPropMaskClear( &bpSetMask );
411
412 wide= ebp->ebpPenWideTwips;
413 if ( appGetLengthFromTextWidget( bt->btWideText,
414 &wide, &changed, UNITtyPOINTS,
415 minValue, adaptToMin, maxValue, adaptToMax ) )
416 { return; }
417
418 appLengthToTextWidget( bt->btWideText, wide, UNITtyPOINTS );
419
420 if ( changed )
421 {
422 ebp->ebpPenWideTwips= wide;
423 PROPmaskADD( &bpSetMask, BRDRpropPEN_WIDE );
424 PROPmaskADD( &(bt->btPropertiesChanged), BRDRpropPEN_WIDE );
425 }
426
427 /*
428 if ( changed && bt->btCallback )
429 { (*bt->btCallback)( bt, bt->btTarget, &bpSetMask, bp ); }
430 */
431
432 return;
433 }
434
435 /************************************************************************/
436 /* */
437 /* A color for the border was chosen. */
438 /* */
439 /* 1) Actually.. No color was selected but the user wants to use a */
440 /* more detailed tool. */
441 /* 2) color chosen. */
442 /* */
443 /************************************************************************/
444
tedBorderColorChosen(ColorChooser * cc,int which,void * voidbt,int choice,const RGB8Color * rgb8Set)445 static void tedBorderColorChosen(
446 ColorChooser * cc,
447 int which,
448 void * voidbt,
449 int choice,
450 const RGB8Color * rgb8Set )
451 {
452 BorderTool * bt= (BorderTool *)voidbt;
453 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
454 int changed= 0;
455
456 /* 1 */
457 if ( choice == CHOICEccMORE )
458 {
459 appInspectorShowRgbPage( bt->btInspector,
460 bt->btSubjectPage, which, &(ebp->ebpColor) );
461 return;
462 }
463
464 /* 2 */
465 appColorChooserColorChosen( &(bt->btPropertiesChanged), &changed,
466 &(ebp->ebpColor), &(ebp->ebpColorExplicit),
467 rgb8Set, choice != CHOICEccDEFAULT, BRDRpropCOLOR );
468
469 return;
470 }
471
tedBorderSetExplicitColorChoice(BorderTool * bt,const RGB8Color * rgb8Set)472 void tedBorderSetExplicitColorChoice( BorderTool * bt,
473 const RGB8Color * rgb8Set )
474 {
475 const int colorExplicit= 1;
476 ExpandedBorderProperties * ebp= &(bt->btPropertiesChosen);
477 int changed= 0;
478
479 appColorChooserColorChosen( &(bt->btPropertiesChanged), &changed,
480 &(ebp->ebpColor), &(ebp->ebpColorExplicit),
481 rgb8Set, colorExplicit, BRDRpropCOLOR );
482
483 if ( changed )
484 {
485 appColorChooserSetColor( &(bt->btColorChooser),
486 ebp->ebpColorExplicit, &(ebp->ebpColor) );
487 }
488
489 return;
490 }
491
492 /************************************************************************/
493 /* */
494 /* Make a BorderTool. */
495 /* */
496 /************************************************************************/
497
tedInitBorderTool(BorderTool * bt)498 void tedInitBorderTool( BorderTool * bt )
499 {
500 bt->btInspector= (AppInspector *)0;
501 bt->btSubjectPage= -1;
502 bt->btWhich= -1;
503
504 bt->btLabel= (const char *)0;
505
506 bt->btEnabled= 0;
507
508 bt->btFrame= (APP_WIDGET)0;
509 bt->btPaned= (APP_WIDGET)0;
510
511 bt->btOnOffRow= (APP_WIDGET)0;
512 bt->btOnOffToggle= (APP_WIDGET)0;
513 bt->btWideText= (APP_WIDGET)0;
514
515 bt->btStyleRow= (APP_WIDGET)0;
516 bt->btStyleLabel= (APP_WIDGET)0;
517 appInitDrawnPulldown( &(bt->btStylePulldown) );
518
519 bt->btColorRow= (APP_WIDGET)0;
520 bt->btColorLabel= (APP_WIDGET)0;
521 appInitColorChooser( &(bt->btColorChooser) );
522
523 docInitExpandedBorderProperties( &(bt->btPropertiesChosen) );
524 utilPropMaskClear( &(bt->btPropertiesChanged) );
525
526 return;
527 }
528
tedCleanBorderTool(BorderTool * bt)529 void tedCleanBorderTool( BorderTool * bt )
530 {
531 appCleanDrawnPulldown( &(bt->btStylePulldown) );
532
533 return;
534 }
535
tedMakeBorderTool(BorderTool * bt,AppInspector * ai,APP_WIDGET pageWidget,const char * title,const BorderToolResources * btr,int subjectPage,int which)536 void tedMakeBorderTool( BorderTool * bt,
537 AppInspector * ai,
538 APP_WIDGET pageWidget,
539 const char * title,
540 const BorderToolResources * btr,
541 int subjectPage,
542 int which )
543 {
544 const int bordersHaveAutomaticColor= 1;
545
546 const int heightResizable= 0;
547
548 const int textEnabled= 0;
549
550 const int labelColumn= 0;
551 const int labelColspan= 1;
552
553 const int valueColumn= 1;
554 const int valueColspan= 1;
555
556 APP_WIDGET rowParent= pageWidget;
557
558 /**/
559 bt->btInspector= ai;
560 bt->btSubjectPage= subjectPage;
561 bt->btWhich= which;
562
563 bt->btEnabled= 1;
564
565 /**/
566 docInitExpandedBorderProperties( &(bt->btPropertiesChosen) );
567
568 /**/
569 # if USE_FRAME
570 # if USE_FRAME_TITLE
571 appMakeColumnFrameInColumn( &(bt->btFrame), &(bt->btPaned), pageWidget,
572 title );
573 # else
574 appMakeColumnFrameInColumn( &(bt->btFrame), &(bt->btPaned), pageWidget,
575 (const char *)0 );
576 # endif
577
578 rowParent= bt->btPaned;
579
580 # else
581 rowParent= pageWidget;
582 # endif
583
584 /**/
585 bt->btOnOffRow= appMakeRowInColumn( rowParent,
586 ONOFF_ROW_COLUMNS, heightResizable );
587
588 # if USE_TOGGLE_TITLE
589 bt->btOnOffToggle= appMakeToggleInRow( bt->btOnOffRow, title,
590 tedBorderToolOnOffToggled, (void *)bt,
591 ONOFF_COLUMN, ONOFF_COLSPAN );
592 # else
593 bt->btOnOffToggle= appMakeToggleInRow( bt->btOnOffRow, (const char *)0,
594 tedBorderToolOnOffToggled, (void *)bt,
595 ONOFF_COLUMN, ONOFF_COLSPAN );
596 # endif
597
598 appMakeTextInRow( &(bt->btWideText), bt->btOnOffRow,
599 THICK_COLUMN, THICK_COLSPAN, THICK_CHARS,
600 textEnabled );
601
602 appGuiSetGotValueCallbackForText( bt->btWideText,
603 tedFormatBorderWidthChanged, (void *)bt );
604 appGuiSetTypingCallbackForText( bt->btWideText,
605 tedFormatBorderWidthTyped, (void *)bt );
606
607 # if MAKE_COLOR_ROW
608 appMakeLabelAndColorChooserRow( &(bt->btColorRow), &(bt->btColorLabel),
609 &(bt->btColorChooser),
610 bt->btPaned, btr->btrColor,
611 &(btr->btrColorChooserResources),
612 tedBorderColorChosen, which, (void *)bt );
613 # else
614 bt->btColorRow= bt->btOnOffRow;
615
616 appMakeColorChooserInRow( &(bt->btColorChooser), bordersHaveAutomaticColor,
617 bt->btColorRow,
618 COLOR_COLUMN, COLOR_COLSPAN,
619 &(btr->btrColorChooserResources),
620 tedBorderColorChosen, which, (void *)bt );
621 # endif
622
623 /**/
624 # if 0
625 bt->btStyleRow= appMakeRowInColumn( bt->btPaned, 2, heightResizable );
626 # else
627 bt->btStyleRow= (APP_WIDGET)0;
628 # endif
629
630 if ( bt->btStyleRow )
631 {
632 appMakeLabelInRow( &(bt->btStyleLabel), bt->btStyleRow,
633 labelColumn, labelColspan, btr->btrStyle );
634
635 appMakeDrawnPulldownInRow( &(bt->btStylePulldown),
636 tedBorderToolRedrawInplace,
637 tedBorderToolRedrawPulldown,
638 tedBorderToolClickedPulldown,
639 (AppDrawnPulldownPuldown)0,
640 bt->btStyleRow, valueColumn, valueColspan,
641 (void *)bt );
642 }
643
644 return;
645 }
646
tedFinishBorderTool(BorderTool * bt,const PostScriptFontList * psfl)647 void tedFinishBorderTool( BorderTool * bt,
648 const PostScriptFontList * psfl )
649 {
650 if ( bt->btStyleRow )
651 {
652 if ( appFinishDrawnPulldownInplace( &(bt->btStylePulldown) ) )
653 { LDEB(1); return; }
654
655 appGuiSetDrawnPulldownStrips( &(bt->btStylePulldown), DOCbs_COUNT );
656 }
657
658 if ( bt->btColorLabel )
659 {
660 appFinishColorChooser( &(bt->btColorChooser), psfl, bt->btColorLabel );
661 }
662 else{
663 appFinishColorChooser( &(bt->btColorChooser), psfl, bt->btOnOffToggle );
664 }
665
666 return;
667 }
668
669 /************************************************************************/
670 /* */
671 /* Retrieve the border properties from the border tool. */
672 /* */
673 /* The properties managed by the toggle and the various option menus */
674 /* or pulldowns are already stored in bt->btPropertiesChosen. */
675 /* The typing callback sets the changed flag for the pen width. */
676 /* */
677 /* Retrieve the pen width if its changed flag is set. */
678 /* */
679 /************************************************************************/
680
tedBorderToolGetProperties(BorderProperties * bpSet,PropertyMask * pSetMask,const BorderTool * bt,DocumentProperties * dp)681 static int tedBorderToolGetProperties( BorderProperties * bpSet,
682 PropertyMask * pSetMask,
683 const BorderTool * bt,
684 DocumentProperties * dp )
685 {
686 const ExpandedBorderProperties * ebpChosen= &(bt->btPropertiesChosen);
687
688 int changed= 0;
689
690 const int minValue= 1;
691 const int adaptToMin= 0;
692 const int maxValue= 75;
693 const int adaptToMax= 0;
694
695 int wide= ebpChosen->ebpPenWideTwips;
696
697 PropertyMask bpDoneMask;
698
699 if ( PROPmaskISSET( &(bt->btPropertiesChanged), BRDRpropPEN_WIDE ) &&
700 ebpChosen->ebpStyle != DOCbsNONE )
701 {
702 if ( appGetLengthFromTextWidget( bt->btWideText,
703 &wide, &changed, UNITtyPOINTS,
704 minValue, adaptToMin, maxValue, adaptToMax ) )
705 { return -1; }
706 }
707
708 docIndirectBorderProperties( &bpDoneMask, bpSet,
709 &(bt->btPropertiesChanged), ebpChosen,
710 dp->dpColorPalette );
711 if ( PROPmaskISSET( &(bt->btPropertiesChanged), BRDRpropPEN_WIDE ) &&
712 changed )
713 { bpSet->bpPenWideTwips= wide; }
714
715 *pSetMask= bt->btPropertiesChanged;
716
717 return 0;
718 }
719
tedBorderToolGetNumber(int * pNum,int * pChanged,const BorderTool * bt,BufferDocument * bd)720 int tedBorderToolGetNumber( int * pNum,
721 int * pChanged,
722 const BorderTool * bt,
723 BufferDocument * bd )
724 {
725 int num;
726 PropertyMask doneMask;
727 BorderProperties bp;
728
729 docGetBorderPropertiesByNumber( &bp, bd, *pNum );
730
731 utilPropMaskClear( &doneMask );
732
733 if ( tedBorderToolGetProperties( &bp, &doneMask, bt,
734 &(bd->bdProperties) ) )
735 { LDEB(1); return -1; }
736
737 if ( ! DOCisBORDER( &bp ) )
738 {
739 docCleanBorderProperties( &bp );
740 docInitBorderProperties( &bp );
741 }
742
743 num= docBorderPropertiesNumber( bd, &bp );
744 if ( num < 0 )
745 { LDEB(num); return -1; }
746
747 if ( pChanged )
748 { *pChanged= ( *pNum != num ); }
749 *pNum= num;
750
751 return 0;
752 }
753
754