1 /************************************************************************/
2 /*									*/
3 /*  A tool to manage the style of notes in the document.		*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"tedConfig.h"
8 
9 #   include	<stdio.h>
10 #   include	<stddef.h>
11 #   include	<limits.h>
12 
13 #   include	"tedNotesTool.h"
14 #   include	"tedAppFront.h"
15 #   include	<docTreeType.h>
16 #   include	<guiToolUtil.h>
17 #   include	<guiTextUtil.h>
18 #   include	<docTreeNode.h>
19 #   include	<docNodeTree.h>
20 #   include	<docEditCommand.h>
21 
22 #   include	<appDebugon.h>
23 
24 /************************************************************************/
25 /*									*/
26 /*  What property values are relevant for footnotes/endnotes?		*/
27 /*									*/
28 /************************************************************************/
29 
30 static const int TED_FootnoteRestarts[]=
31     {
32     FTN_RST_CONTINUOUS,
33     FTN_RST_PER_SECTION,
34     FTN_RST_PER_PAGE,
35     };
36 
37 static const int TED_FootnoteRestartCount= sizeof(TED_FootnoteRestarts)/sizeof(int);
38 
39 static const int TED_EndnoteRestarts[]=
40     {
41     FTN_RST_CONTINUOUS,
42     FTN_RST_PER_SECTION,
43     };
44 
45 static const int TED_EndnoteRestartCount= sizeof(TED_EndnoteRestarts)/sizeof(int);
46 
47 static const int TED_EndnotePlacements[]=
48     {
49     /*
50     FTNplacePAGE_END,
51     */
52     FTNplaceSECT_END,
53     FTNplaceDOC_END,
54     };
55 
56 static const int TED_EndnotePlacementCount= sizeof(TED_EndnotePlacements)/sizeof(int);
57 
58 /************************************************************************/
59 /*									*/
60 /*  Refresh the 'Notes' page of the format tool.			*/
61 /*									*/
62 /************************************************************************/
63 
tedSetNotesMenu(AppOptionmenu * aom,int val,const int * values,int valueCount)64 static void tedSetNotesMenu(	AppOptionmenu *		aom,
65 				int			val,
66 				const int *		values,
67 				int			valueCount )
68     {
69     int		i;
70 
71     for ( i= 0; i < valueCount; i++ )
72 	{
73 	if  ( values[i] == val )
74 	    { appSetOptionmenu( aom, i ); return;	}
75 	}
76 
77     LLDEB(val,valueCount);
78     appSetOptionmenu( aom, -1 );
79     return;
80     }
81 
tedNotesRefreshNotesStartNumber(NotesTool * nt,const NotesProperties * np)82 static void tedNotesRefreshNotesStartNumber(	NotesTool *		nt,
83 						const NotesProperties *	np )
84     {
85     if  ( np->npRestart == FTN_RST_CONTINUOUS )
86 	{
87 	appIntegerToTextWidget( nt->ntStartNumberText, np->npStartNumber );
88 	guiEnableText( nt->ntStartNumberText, 1 );
89 	}
90     else{
91 	appStringToTextWidget( nt->ntStartNumberText, "" );
92 	guiEnableText( nt->ntStartNumberText, 0 );
93 	}
94 
95     return;
96     }
97 
tedNotesRefreshNotePropertiesTool(NotesTool * nt,const NotesProperties * np,const int * restarts,int restartCount,const int * placements,int placementCount)98 static void tedNotesRefreshNotePropertiesTool(
99 					NotesTool *		nt,
100 					const NotesProperties *	np,
101 					const int *		restarts,
102 					int			restartCount,
103 					const int *		placements,
104 					int			placementCount )
105     {
106     tedNotesRefreshNotesStartNumber( nt, np );
107 
108     if  ( placements )
109 	{
110 	guiEnableWidget( nt->ntPlacementRow,
111 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
112 	appGuiEnableOptionmenu( &(nt->ntPlacementOptionmenu),
113 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
114 	tedSetNotesMenu( &(nt->ntPlacementOptionmenu),
115 					    np->npPlacement,
116 					    placements, placementCount );
117 	}
118     else{
119 	if  ( nt->ntPlacementOptionmenu.aomInplace )
120 	    {
121 	    guiEnableWidget( nt->ntPlacementRow, 0 );
122 	    appGuiEnableOptionmenu( &(nt->ntPlacementOptionmenu), 0 );
123 	    appSetOptionmenu( &(nt->ntPlacementOptionmenu), -1 );
124 	    }
125 	}
126 
127     tedSetNotesMenu( &(nt->ntRestartOptionmenu),
128 					    np->npRestart,
129 					    restarts, restartCount );
130 
131     appSetOptionmenu( &(nt->ntJustifyOptionmenu),
132 					    np->npJustification );
133     appSetOptionmenu( &(nt->ntStyleOptionmenu),
134 					    np->npNumberStyle );
135 
136     return;
137     }
138 
tedNotesToolRefreshNotesWidgets(NotesTool * nt)139 static void tedNotesToolRefreshNotesWidgets(	NotesTool *	nt )
140     {
141     if  ( nt->ntNoteTreeType == DOCinFOOTNOTE )
142 	{
143 	tedNotesRefreshNotePropertiesTool( nt,
144 			&(nt->ntNotesPropertiesChosen.fepFootnotesProps),
145 			TED_FootnoteRestarts,
146 			TED_FootnoteRestartCount,
147 			(int *)0, 0 );
148 	}
149 
150     if  ( nt->ntNoteTreeType == DOCinENDNOTE )
151 	{
152 	tedNotesRefreshNotePropertiesTool( nt,
153 			&(nt->ntNotesPropertiesChosen.fepEndnotesProps),
154 			TED_EndnoteRestarts,
155 			TED_EndnoteRestartCount,
156 			TED_EndnotePlacements,
157 			TED_EndnotePlacementCount );
158 	}
159 
160     return;
161     }
162 
tedRefreshNotesTool(NotesTool * nt,int * pEnabled,int * pPref,InspectorSubject * is,const DocumentSelection * ds,const SelectionDescription * sd,BufferDocument * bd,const unsigned char * cmdEnabled)163 void tedRefreshNotesTool(	NotesTool *			nt,
164 				int *				pEnabled,
165 				int *				pPref,
166 				InspectorSubject *		is,
167 				const DocumentSelection *	ds,
168 				const SelectionDescription *	sd,
169 				BufferDocument *		bd,
170 				const unsigned char *		cmdEnabled )
171     {
172     const DocumentProperties *	dp= &(bd->bdProperties);
173 
174     const BufferItem *		bodySectNode= (BufferItem *)0;
175 
176     if  ( ds )
177 	{
178 	bodySectNode= docGetBodySectNode( ds->dsHead.dpNode, bd );
179 	if  ( ! bodySectNode )
180 	    { XDEB(bodySectNode);	}
181 	}
182 
183     nt->ntNotesPropertiesSetDocument= dp->dpNotesProps;
184     nt->ntNotesPropertiesSetSelection= dp->dpNotesProps;
185 
186     if  ( bodySectNode )
187 	{
188 	nt->ntNotesPropertiesSetSelection=
189 			    bodySectNode->biSectProperties.spNotesProperties;
190 	}
191 
192     nt->ntNotesPropertiesChosen= nt->ntNotesPropertiesSetSelection;
193 
194     nt->ntCanChangeSelection= cmdEnabled[EDITcmdUPD_SECT_PROPS];
195     nt->ntCanChangeDocument= cmdEnabled[EDITcmdUPD_SECTDOC_PROPS];
196 
197     tedNotesToolRefreshNotesWidgets( nt );
198 
199     guiEnableWidget( nt->ntJustifyRow,
200 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
201     if  ( nt->ntPlacementRow )
202 	{
203 	guiEnableWidget( nt->ntPlacementRow,
204 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
205 	}
206 
207     guiEnableWidget( nt->ntRestartRow,
208 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
209     guiEnableWidget( nt->ntStyleRow,
210 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
211     guiEnableWidget( nt->ntStartNumberRow,
212 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
213     guiEnableText( nt->ntStartNumberText,
214 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
215 
216     guiEnableWidget( nt->ntRevertSelectionWidget,
217 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
218     guiEnableWidget( nt->ntChangeSelectionWidget,
219 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
220 
221     guiEnableWidget( is->isRevertButton,
222 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
223     guiEnableWidget( is->isApplyButton,
224 			nt->ntCanChangeSelection || nt->ntCanChangeDocument );
225 
226     *pEnabled= 1;
227     return;
228     }
229 
230 /************************************************************************/
231 /*									*/
232 /*  Set/Revert buttons for the document properties have been pushed.	*/
233 /*									*/
234 /************************************************************************/
235 
tedNotesToolGetStartNumber(NotesTool * nt,NotesProperties * np)236 static int tedNotesToolGetStartNumber(	NotesTool *		nt,
237 					NotesProperties *	np )
238     {
239     if  ( np->npRestart == FTN_RST_CONTINUOUS )
240 	{
241 	if  ( appGetIntegerFromTextWidget( nt->ntStartNumberText,
242 				    &(np->npStartNumber), 1, 0, INT_MAX, 0 ) )
243 	    { return -1;	}
244 	}
245 
246     return 0;
247     }
248 
APP_TXACTIVATE_CALLBACK_H(tedNotesFootRestartChanged,w,voidnt)249 static APP_TXACTIVATE_CALLBACK_H( tedNotesFootRestartChanged, w, voidnt )
250     {
251     NotesTool *		nt= (NotesTool *)voidnt;
252     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepFootnotesProps);
253 
254     if  ( np->npRestart != FTN_RST_CONTINUOUS		||
255 	  tedNotesToolGetStartNumber( nt, np )		)
256 	{ return;	}
257 
258     return;
259     }
260 
APP_TXACTIVATE_CALLBACK_H(tedNotesEndRestartChanged,w,voidnt)261 static APP_TXACTIVATE_CALLBACK_H( tedNotesEndRestartChanged, w, voidnt )
262     {
263     NotesTool *			nt= (NotesTool *)voidnt;
264     NotesProperties *		np= &(nt->ntNotesPropertiesChosen.fepEndnotesProps);
265 
266     if  ( np->npRestart != FTN_RST_CONTINUOUS		||
267 	  tedNotesToolGetStartNumber( nt, np )		)
268 	{ return;	}
269 
270     return;
271     }
272 
tedNotesToolSetProperties(NotesTool * nt,int wholeDocument)273 static int tedNotesToolSetProperties(	NotesTool *	nt,
274 					int		wholeDocument )
275     {
276     int				rval= 0;
277 
278     PropertyMask		dpSetMask;
279     PropertyMask		spSetMask;
280 
281     DocumentProperties		dpNew;
282     SectionProperties		spNew;
283 
284     docInitSectionProperties( &spNew );
285     docInitDocumentProperties( &dpNew );
286 
287     utilPropMaskClear( &dpSetMask );
288     utilPropMaskClear( &spSetMask );
289 
290     if  ( nt->ntNoteTreeType == DOCinFOOTNOTE )
291 	{
292 	tedNotesToolGetStartNumber( nt,
293 		    &(nt->ntNotesPropertiesChosen.fepFootnotesProps) );
294 	}
295 
296     if  ( nt->ntNoteTreeType == DOCinENDNOTE )
297 	{
298 	tedNotesToolGetStartNumber( nt,
299 		    &(nt->ntNotesPropertiesChosen.fepEndnotesProps) );
300 	}
301 
302     /**/
303     dpNew.dpNotesProps= nt->ntNotesPropertiesChosen;
304     spNew.spNotesProperties= nt->ntNotesPropertiesChosen;
305 
306     {
307     PropertyMask	cmpMask;
308 
309     utilPropMaskClear( &cmpMask );
310     docFillDocNotesMask( &cmpMask );
311 
312     docFootEndNotesPropertyDifference( &dpSetMask,
313 				&(dpNew.dpNotesProps), &cmpMask,
314 				&(nt->ntNotesPropertiesSetDocument),
315 				DOCdocNOTE_PROP_MAP );
316 
317     }
318 
319     {
320     PropertyMask	cmpMask;
321 
322     utilPropMaskClear( &cmpMask );
323     docFillSectNotesMask( &cmpMask );
324 
325     docFootEndNotesPropertyDifference( &spSetMask,
326 				&(spNew.spNotesProperties), &cmpMask,
327 				&(nt->ntNotesPropertiesSetSelection),
328 				DOCsectNOTE_PROP_MAP );
329     }
330 
331     if  ( wholeDocument )
332 	{
333 	if  ( tedAppChangeAllSectionProperties( nt->ntApplication,
334 							&spSetMask, &spNew,
335 							&dpSetMask, &dpNew ) )
336 	    { LDEB(1); rval= -1; goto ready;	}
337 	}
338     else{
339 	if  ( tedAppChangeSectionProperties( nt->ntApplication,
340 							&spSetMask, &spNew ) )
341 	    { LDEB(1); rval= -1; goto ready;	}
342 	}
343 
344   ready:
345 
346     docCleanSectionProperties( &spNew );
347     docCleanDocumentProperties( &dpNew );
348 
349     return rval;
350     }
351 
APP_BUTTON_CALLBACK_H(tedNotesToolChangeDocumentPushed,w,voidnt)352 static APP_BUTTON_CALLBACK_H( tedNotesToolChangeDocumentPushed, w, voidnt )
353     {
354     NotesTool *			nt= (NotesTool *)voidnt;
355     const int			wholeDocument= 1;
356 
357     tedNotesToolSetProperties( nt, wholeDocument );
358     }
359 
APP_BUTTON_CALLBACK_H(tedNotesToolChangeSelectionPushed,w,voidnt)360 static APP_BUTTON_CALLBACK_H( tedNotesToolChangeSelectionPushed, w, voidnt )
361     {
362     NotesTool *			nt= (NotesTool *)voidnt;
363     const int			wholeDocument= 0;
364 
365     tedNotesToolSetProperties( nt, wholeDocument );
366     }
367 
APP_BUTTON_CALLBACK_H(tedNotesToolRevertDocumentPushed,w,voidnt)368 static APP_BUTTON_CALLBACK_H( tedNotesToolRevertDocumentPushed, w, voidnt )
369     {
370     NotesTool *		nt= (NotesTool *)voidnt;
371 
372     nt->ntNotesPropertiesChosen= nt->ntNotesPropertiesSetDocument;
373     tedNotesToolRefreshNotesWidgets( nt );
374 
375     return;
376     }
377 
APP_BUTTON_CALLBACK_H(tedNotesToolRevertSelectionPushed,w,voidnt)378 static APP_BUTTON_CALLBACK_H( tedNotesToolRevertSelectionPushed, w, voidnt )
379     {
380     NotesTool *		nt= (NotesTool *)voidnt;
381 
382     nt->ntNotesPropertiesChosen= nt->ntNotesPropertiesSetSelection;
383     tedNotesToolRefreshNotesWidgets( nt );
384 
385     return;
386     }
387 
388 /************************************************************************/
389 /*									*/
390 /*  Menu callbacks.							*/
391 /*									*/
392 /************************************************************************/
393 
tedFootnoteStyleChosen(int n,void * voidnt)394 static void tedFootnoteStyleChosen(	int		n,
395 					void *		voidnt )
396     {
397     NotesTool *		nt= (NotesTool *)voidnt;
398     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepFootnotesProps);
399 
400     if  ( n < 0 || n >= FTNstyle_COUNT )
401 	{ LDEB(n); return;	}
402 
403     np->npNumberStyle= n;
404 
405     return;
406     }
407 
tedEndnoteStyleChosen(int n,void * voidnt)408 static void tedEndnoteStyleChosen(	int		n,
409 					void *		voidnt )
410     {
411     NotesTool *		nt= (NotesTool *)voidnt;
412     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepEndnotesProps);
413 
414     if  ( n < 0 || n >= FTNstyle_COUNT )
415 	{ LDEB(n); return;	}
416 
417     np->npNumberStyle= n;
418 
419     return;
420     }
421 
tedFootnoteRestartChosen(int n,void * voidnt)422 static void tedFootnoteRestartChosen(	int		n,
423 					void *		voidnt )
424     {
425     NotesTool *		nt= (NotesTool *)voidnt;
426     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepFootnotesProps);
427 
428     if  ( n < 0 || n >= TED_FootnoteRestartCount )
429 	{ LLDEB(n,TED_FootnoteRestartCount); return;	}
430 
431     np->npRestart= TED_FootnoteRestarts[n];
432 
433     tedNotesRefreshNotesStartNumber( nt, np );
434 
435     return;
436     }
437 
tedEndnoteRestartChosen(int n,void * voidnt)438 static void tedEndnoteRestartChosen(	int		n,
439 					void *		voidnt )
440     {
441     NotesTool *		nt= (NotesTool *)voidnt;
442     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepEndnotesProps);
443 
444     if  ( n < 0 || n >= TED_EndnoteRestartCount )
445 	{ LLDEB(n,TED_EndnoteRestartCount); return;	}
446 
447     np->npRestart= TED_EndnoteRestarts[n];
448 
449     tedNotesRefreshNotesStartNumber( nt, np );
450 
451     return;
452     }
453 
tedEndnotePlacementChosen(int n,void * voidnt)454 static void tedEndnotePlacementChosen(	int		n,
455 					void *		voidnt )
456     {
457     NotesTool *		nt= (NotesTool *)voidnt;
458     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepEndnotesProps);
459 
460     if  ( n < 0 || n >= TED_EndnotePlacementCount )
461 	{ LLDEB(n,TED_EndnotePlacementCount); return;	}
462 
463     if  ( TED_EndnotePlacements[n] < 0			||
464 	  TED_EndnotePlacements[n] >= FTNplace_COUNT	)
465 	{ LDEB(TED_EndnotePlacements[n]); return;	}
466 
467     np->npPlacement= TED_EndnotePlacements[n];
468 
469     return;
470     }
471 
tedFootnoteJustifyChosen(int n,void * voidnt)472 static void tedFootnoteJustifyChosen(	int		n,
473 					void *		voidnt )
474     {
475     NotesTool *		nt= (NotesTool *)voidnt;
476     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepFootnotesProps);
477 
478     if  ( n < 0 || n >= FTNjustify_COUNT )
479 	{ LDEB(n); return;	}
480 
481     np->npJustification= n;
482 
483     return;
484     }
485 
tedEndnoteJustifyChosen(int n,void * voidnt)486 static void tedEndnoteJustifyChosen(	int		n,
487 					void *		voidnt )
488     {
489     NotesTool *		nt= (NotesTool *)voidnt;
490     NotesProperties *	np= &(nt->ntNotesPropertiesChosen.fepEndnotesProps);
491 
492     if  ( n < 0 || n >= FTNjustify_COUNT )
493 	{ LDEB(n); return;	}
494 
495     np->npJustification= n;
496 
497     return;
498     }
499 
500 /************************************************************************/
501 /*									*/
502 /*  Make the 'Notes' page of the format tool.				*/
503 /*									*/
504 /************************************************************************/
505 
tedNotesMakeNotePropertiesTool(APP_WIDGET pageWidget,const char * title,NotesTool * nt,const NotesPageResources * npr,APP_TXACTIVATE_CALLBACK_T startCB,OptionmenuCallback justifyCB,OptionmenuCallback placementCB,OptionmenuCallback restartCB,OptionmenuCallback styleCB)506 static void tedNotesMakeNotePropertiesTool(
507 				APP_WIDGET			pageWidget,
508 				const char *			title,
509 				NotesTool *			nt,
510 				const NotesPageResources *	npr,
511 				APP_TXACTIVATE_CALLBACK_T	startCB,
512 				OptionmenuCallback		justifyCB,
513 				OptionmenuCallback		placementCB,
514 				OptionmenuCallback		restartCB,
515 				OptionmenuCallback		styleCB )
516     {
517     const int	textColumns= 6;
518 
519     guiToolMakeLabelAndMenuRow( &(nt->ntJustifyRow), &(nt->ntJustifyOptionmenu),
520 			    &(nt->ntJustifyLabel),
521 			    pageWidget, npr->nprJustifyText,
522 			    justifyCB, (void *)nt );
523 
524     if  ( placementCB )
525 	{
526 	guiToolMakeLabelAndMenuRow( &(nt->ntPlacementRow),
527 			    &(nt->ntPlacementOptionmenu),
528 			    &(nt->ntPlacementLabel),
529 			    pageWidget, npr->nprPositionText,
530 			    placementCB, (void *)nt );
531 	}
532 
533     guiToolMakeLabelAndMenuRow( &(nt->ntRestartRow), &(nt->ntRestartOptionmenu),
534 			    &(nt->ntRestartLabel),
535 			    pageWidget, npr->nprRestartText,
536 			    restartCB, (void *)nt );
537 
538     guiToolMakeLabelAndMenuRow( &(nt->ntStyleRow), &(nt->ntStyleOptionmenu),
539 			    &(nt->ntStyleLabel), pageWidget, npr->nprStyleText,
540 			    styleCB, (void *)nt );
541 
542     guiToolMakeLabelAndTextRow( &(nt->ntStartNumberRow),
543 			&(nt->ntStartNumberLabel), &(nt->ntStartNumberText),
544 			pageWidget, npr->nprFirstNumberText,
545 			textColumns, 1 );
546 
547     if  ( startCB )
548 	{
549 	appGuiSetGotValueCallbackForText( nt->ntStartNumberText,
550 						    startCB, (void *)nt );
551 	}
552 
553     return;
554     }
555 
tedFormatFillNotesPage(NotesTool * nt,const NotesPageResources * npr,InspectorSubject * is,APP_WIDGET pageWidget,const InspectorSubjectResources * isr,int treeType)556 void tedFormatFillNotesPage(	NotesTool *			nt,
557 				const NotesPageResources *	npr,
558 				InspectorSubject *		is,
559 				APP_WIDGET			pageWidget,
560 				const InspectorSubjectResources * isr,
561 				int				treeType )
562     {
563     APP_WIDGET	row= (APP_WIDGET )0;
564 
565     /**/
566     nt->ntPageResources= npr;
567     nt->ntInProgrammaticChange= 0;
568 
569     nt->ntRevertSelectionWidget= (APP_WIDGET)0;
570     nt->ntChangeSelectionWidget= (APP_WIDGET)0;
571 
572 
573     docInitFootEndNotesProperties( &(nt->ntNotesPropertiesSetDocument) );
574     docInitFootEndNotesProperties( &(nt->ntNotesPropertiesSetSelection) );
575     docInitFootEndNotesProperties( &(nt->ntNotesPropertiesChosen) );
576 
577     nt->ntNoteTreeType= treeType;
578 
579     /**************/
580 
581     if  ( nt->ntNoteTreeType == DOCinFOOTNOTE )
582 	{
583 	tedNotesMakeNotePropertiesTool( pageWidget, npr->nprFootnotesText, nt,
584 					npr, tedNotesFootRestartChanged,
585 					tedFootnoteJustifyChosen,
586 					(OptionmenuCallback)0,
587 					tedFootnoteRestartChosen,
588 					tedFootnoteStyleChosen );
589 	}
590 
591     if  ( nt->ntNoteTreeType == DOCinENDNOTE )
592 	{
593 	tedNotesMakeNotePropertiesTool( pageWidget, npr->nprEndnotesText, nt,
594 					npr, tedNotesEndRestartChanged,
595 					tedEndnoteJustifyChosen,
596 					tedEndnotePlacementChosen,
597 					tedEndnoteRestartChosen,
598 					tedEndnoteStyleChosen );
599 	}
600 
601     /**************/
602 
603     guiToolMake2BottonRow( &row, pageWidget,
604 				&(nt->ntRevertSelectionWidget),
605 				&(nt->ntChangeSelectionWidget),
606 				npr->nprRevertSelectionText,
607 				npr->nprChangeSelectionText,
608 				tedNotesToolRevertSelectionPushed,
609 				tedNotesToolChangeSelectionPushed,
610 				(void *)nt );
611 
612     guiToolMake2BottonRow( &(is->isApplyRow), pageWidget,
613 				&(is->isRevertButton),
614 				&(is->isApplyButton),
615 				isr->isrRevert,
616 				isr->isrApplyToSubject,
617 				tedNotesToolRevertDocumentPushed,
618 				tedNotesToolChangeDocumentPushed,
619 				(void *)nt );
620 
621     return;
622     }
623 
tedNotePropertiesToolFillStyleChooser(NotesTool * nt,const NotesPageResources * npr)624 static void tedNotePropertiesToolFillStyleChooser(
625 				NotesTool *			nt,
626 				const NotesPageResources *	npr )
627     {
628     appFillInspectorMenu( FTNjustify_COUNT, FTNjustifyBELOW_TEXT,
629 		    nt->ntJustifyOptions, npr->nprJustifyMenuTexts,
630 		    &(nt->ntJustifyOptionmenu) );
631 
632     appFillInspectorMenu( FTNstyle_COUNT, FTNstyleNAR,
633 		    nt->ntStyleOptions, npr->nprNumberStyleMenuTexts,
634 		    &(nt->ntStyleOptionmenu) );
635 
636     return;
637     }
638 
tedNotePropertiesToolFillChoosers(NotesTool * nt,const NotesPageResources * npr,const int * restarts,int restartCount,const int * placements,int placementCount)639 static void tedNotePropertiesToolFillChoosers(
640 			NotesTool *			nt,
641 			const NotesPageResources *	npr,
642 			const int *			restarts,
643 			int				restartCount,
644 			const int *			placements,
645 			int				placementCount )
646     {
647     int		i;
648 
649     for ( i= 0; i < restartCount; i++ )
650 	{
651 	nt->ntRestartOptions[i]=
652 		appAddItemToOptionmenu( &(nt->ntRestartOptionmenu),
653 			npr->nprRestartMenuTexts[restarts[i]] );
654 	}
655 
656     for ( i= 0; i < placementCount; i++ )
657 	{
658 	nt->ntPlacementOptions[i]=
659 		appAddItemToOptionmenu( &(nt->ntPlacementOptionmenu),
660 			npr->nprPlacementMenuTexts[placements[i]] );
661 	}
662 
663     return;
664     }
665 
tedFormatFillNotesChoosers(NotesTool * nt,const NotesPageResources * npr)666 void tedFormatFillNotesChoosers(	NotesTool *			nt,
667 					const NotesPageResources *	npr )
668     {
669     tedNotePropertiesToolFillStyleChooser( nt, npr );
670 
671     if  ( nt->ntNoteTreeType == DOCinFOOTNOTE )
672 	{
673 	tedNotePropertiesToolFillChoosers( nt, npr,
674 				TED_FootnoteRestarts,
675 				TED_FootnoteRestartCount,
676 				(int *)0, 0 );
677 	}
678 
679     if  ( nt->ntNoteTreeType == DOCinENDNOTE )
680 	{
681 	tedNotePropertiesToolFillChoosers( nt, npr,
682 				TED_EndnoteRestarts,
683 				TED_EndnoteRestartCount,
684 				TED_EndnotePlacements,
685 				TED_EndnotePlacementCount );
686 	}
687     }
688 
tedFormatFinishNotesPage(NotesTool * nt,const NotesPageResources * npr)689 void tedFormatFinishNotesPage(		NotesTool *			nt,
690 					const NotesPageResources *	npr )
691     {
692     if  ( nt->ntJustifyOptionmenu.aomInplace )
693 	{ appOptionmenuRefreshWidth( &(nt->ntJustifyOptionmenu) );	}
694 
695     if  ( nt->ntPlacementOptionmenu.aomInplace )
696 	{ appOptionmenuRefreshWidth( &(nt->ntPlacementOptionmenu) );	}
697 
698     if  ( nt->ntRestartOptionmenu.aomInplace )
699 	{ appOptionmenuRefreshWidth( &(nt->ntRestartOptionmenu) );	}
700 
701     if  ( nt->ntStyleOptionmenu.aomInplace )
702 	{ appOptionmenuRefreshWidth( &(nt->ntStyleOptionmenu) );	}
703 
704     return;
705     }
706 
707 /************************************************************************/
708 /*									*/
709 /*  Clean the notes tool.						*/
710 /*									*/
711 /************************************************************************/
712 
tedFormatCleanNotesTool(NotesTool * nt)713 void tedFormatCleanNotesTool(	NotesTool *	nt )
714     {
715     /* clean ntNotesPropertiesSetDocument */
716     /* clean ntNotesPropertiesSetSelection */
717     /* clean ntNotesPropertiesChosen */
718 
719     return;
720     }
721 
tedFormatInitNotesTool(NotesTool * nt)722 void tedFormatInitNotesTool(	NotesTool *		nt )
723     {
724     int		i;
725 
726     nt->ntNoteTreeType= DOCinBODY;
727 
728     nt->ntApplication= (EditApplication *)0;
729     nt->ntInspector= (AppInspector *)0;
730     nt->ntPageResources= (NotesPageResources *)0;
731 
732     nt->ntInProgrammaticChange= 0;
733 
734     docInitFootEndNotesProperties( &(nt->ntNotesPropertiesSetDocument) );
735     docInitFootEndNotesProperties( &(nt->ntNotesPropertiesSetSelection) );
736     docInitFootEndNotesProperties( &(nt->ntNotesPropertiesChosen) );
737 
738     nt->ntRevertSelectionWidget= (APP_WIDGET)0;
739     nt->ntChangeSelectionWidget= (APP_WIDGET)0;
740 
741     nt->ntJustifyRow= (APP_WIDGET)0;
742     appInitOptionmenu( &(nt->ntJustifyOptionmenu) );
743     for ( i= 0; i < FTNjustify_COUNT; i++ )
744 	{ nt->ntJustifyOptions[i]= (APP_WIDGET)0;	}
745 
746     nt->ntPlacementRow= (APP_WIDGET)0;
747     appInitOptionmenu( &(nt->ntPlacementOptionmenu) );
748     for ( i= 0; i < FTNplace_COUNT; i++ )
749 	{ nt->ntPlacementOptions[i]= (APP_WIDGET)0;	}
750 
751     nt->ntRestartRow= (APP_WIDGET)0;
752     appInitOptionmenu( &(nt->ntRestartOptionmenu) );
753     for ( i= 0; i < FTN_RST__COUNT; i++ )
754 	{ nt->ntRestartOptions[i]= (APP_WIDGET)0;	}
755 
756     nt->ntStyleRow= (APP_WIDGET)0;
757     appInitOptionmenu( &(nt->ntStyleOptionmenu) );
758     for ( i= 0; i < FTNstyle_COUNT; i++ )
759 	{ nt->ntStyleOptions[i]= (APP_WIDGET)0;	}
760 
761     nt->ntStartNumberText= (APP_WIDGET)0;
762 
763     return;
764     }
765 
766 /************************************************************************/
767 /*									*/
768 /*  Get notes tool resources.						*/
769 /*									*/
770 /************************************************************************/
771 
772 static AppConfigurableResource TED_TedNotesSubjectResourceTable[]=
773     {
774     APP_RESOURCE( "formatToolNotes",
775 		offsetof(InspectorSubjectResources,isrSubjectName),
776 		"Notes" ),
777     APP_RESOURCE( "formatToolChangeNotes",
778 		offsetof(InspectorSubjectResources,isrApplyToSubject),
779 		"Apply to Document" ),
780     APP_RESOURCE( "tableToolRevertDocumentNotesProperties",
781 		offsetof(InspectorSubjectResources,isrRevert),
782 		"Revert to Document" ),
783     };
784 
785 static AppConfigurableResource TED_TedNotesToolResourceTable[]=
786     {
787     APP_RESOURCE( "tableToolRevertSection",
788 		offsetof(NotesPageResources,nprRevertSelectionText),
789 		"Revert to Selection" ),
790     APP_RESOURCE( "tableToolChangeSelection",
791 		offsetof(NotesPageResources,nprChangeSelectionText),
792 		"Apply to Selection" ),
793     /**/
794 #   if 0
795     APP_RESOURCE( "formatToolThisNote",
796 		offsetof(NotesPageResources,nprCurrentNoteText),
797 		"This Note" ),
798 #   endif
799 
800     APP_RESOURCE( "formatToolFootnotes",
801 		offsetof(NotesPageResources,nprFootnotesText),
802 		"Footnotes" ),
803     APP_RESOURCE( "formatToolEndnotes",
804 		offsetof(NotesPageResources,nprEndnotesText),
805 		"Endnotes" ),
806 
807     /**/
808     APP_RESOURCE( "formatToolNotesFirstNumber",
809 		offsetof(NotesPageResources,nprFirstNumberText),
810 		"First Number" ),
811     APP_RESOURCE( "formatToolNotesJustify",
812 		offsetof(NotesPageResources,nprJustifyText),
813 		"Justify" ),
814     APP_RESOURCE( "formatToolNotesPosition",
815 		offsetof(NotesPageResources,nprPositionText),
816 		"Position" ),
817     APP_RESOURCE( "formatToolNotesRestart",
818 		offsetof(NotesPageResources,nprRestartText),
819 		"Numbering" ),
820     APP_RESOURCE( "formatToolNotesNumberStyle",
821 		offsetof(NotesPageResources,nprStyleText),
822 		"Number Format" ),
823     /**/
824     APP_RESOURCE( "formatToolNoteNumberStyleNar",
825 	    offsetof(NotesPageResources,nprNumberStyleMenuTexts[FTNstyleNAR]),
826 	    "1, 2, 3" ),
827     APP_RESOURCE( "formatToolNoteNumberStyleNalc",
828 	    offsetof(NotesPageResources,nprNumberStyleMenuTexts[FTNstyleNALC]),
829 	    "a, b, c" ),
830     APP_RESOURCE( "formatToolNoteNumberStyleNauc",
831 	    offsetof(NotesPageResources,nprNumberStyleMenuTexts[FTNstyleNAUC]),
832 	    "A, B, C" ),
833     APP_RESOURCE( "formatToolNoteNumberStyleNrlc",
834 	    offsetof(NotesPageResources,nprNumberStyleMenuTexts[FTNstyleNRLC]),
835 	    "i, ii, iii" ),
836     APP_RESOURCE( "formatToolNoteNumberStyleNruc",
837 	    offsetof(NotesPageResources,nprNumberStyleMenuTexts[FTNstyleNRUC]),
838 	    "I, II, III" ),
839     APP_RESOURCE( "formatToolNoteNumberStyleNchi",
840 	    offsetof(NotesPageResources,nprNumberStyleMenuTexts[FTNstyleNCHI]),
841 	    "*, +, #, $" ),
842     /**/
843     APP_RESOURCE( "formatToolNoteNumberingContinuous",
844 	offsetof(NotesPageResources,nprRestartMenuTexts[FTN_RST_CONTINUOUS]),
845 	"Continuous" ),
846     APP_RESOURCE( "formatToolNoteNumberingPerSection",
847 	offsetof(NotesPageResources,nprRestartMenuTexts[FTN_RST_PER_SECTION]),
848 	"Per Section" ),
849     APP_RESOURCE( "formatToolNoteNumberingPerPage",
850 	offsetof(NotesPageResources,nprRestartMenuTexts[FTN_RST_PER_PAGE]),
851 	"Per Page" ),
852     /**/
853     APP_RESOURCE( "formatToolNotePlacementSectEnd",
854 	offsetof(NotesPageResources,nprPlacementMenuTexts[FTNplaceSECT_END]),
855 	"End of Section" ),
856     APP_RESOURCE( "formatToolNotePlacementDocEnd",
857 	offsetof(NotesPageResources,nprPlacementMenuTexts[FTNplaceDOC_END]),
858 	"End of Document" ),
859 
860     APP_RESOURCE( "formatToolNoteJustifyBelowText",
861 	offsetof(NotesPageResources,nprJustifyMenuTexts[FTNjustifyBELOW_TEXT]),
862 	"Below Text" ),
863     APP_RESOURCE( "formatToolNoteJustifyPageBottom",
864 	offsetof(NotesPageResources,nprJustifyMenuTexts[FTNjustifyPAGE_BOTTOM]),
865 	"Page Bottom" ),
866     };
867 
tedFormatToolGetNotesResourceTable(EditApplication * ea,NotesPageResources * npr,InspectorSubjectResources * isr)868 void tedFormatToolGetNotesResourceTable( EditApplication *		ea,
869 					NotesPageResources *		npr,
870 					InspectorSubjectResources *	isr )
871     {
872     static int	gotToolResources= 0;
873     static int	gotSubjectResources= 0;
874 
875     if  ( ! gotToolResources )
876 	{
877 	appGuiGetResourceValues( &gotToolResources, ea, (void *)npr,
878 				TED_TedNotesToolResourceTable,
879 				sizeof(TED_TedNotesToolResourceTable)/
880 				sizeof(AppConfigurableResource) );
881 	}
882 
883     if  ( ! gotSubjectResources )
884 	{
885 	appGuiGetResourceValues( &gotSubjectResources, ea, (void *)isr,
886 				TED_TedNotesSubjectResourceTable,
887 				sizeof(TED_TedNotesSubjectResourceTable)/
888 				sizeof(AppConfigurableResource) );
889 	}
890 
891     return;
892     }
893