4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
64 print_filerequester_gadget
[]={
65 {RO_Type
,OBJECT_GADGET
},
66 {RO_GadgetType
,GADGET_TINYGLASS
},
67 {RO_GadgetID
,PRINT_FILEREQUESTER
},
73 {RO_TextNum
,STR_FILE
},
74 {RO_TextPos
,TEXTPOS_LEFT
},
78 {RO_Type
,OBJECT_GADGET
},
79 {RO_GadgetType
,GADGET_STRING
},
80 {RO_GadgetID
,PRINT_FILE
},
90 print_topmargin_gadget
[]={
91 {RO_Type
,OBJECT_GADGET
},
92 {RO_GadgetType
,GADGET_INTEGER
},
93 {RO_GadgetID
,PRINT_TOPMARGIN
},
100 {RO_TextNum
,STR_TOP_MARGIN
},
101 {RO_TextPos
,TEXTPOS_LEFT
},
104 print_bottommargin_gadget
[]={
105 {RO_Type
,OBJECT_GADGET
},
106 {RO_GadgetType
,GADGET_INTEGER
},
107 {RO_GadgetID
,PRINT_BOTTOMMARGIN
},
114 {RO_TextNum
,STR_BOTTOM_MARGIN
},
115 {RO_TextPos
,TEXTPOS_LEFT
},
118 print_leftmargin_gadget
[]={
119 {RO_Type
,OBJECT_GADGET
},
120 {RO_GadgetType
,GADGET_INTEGER
},
121 {RO_GadgetID
,PRINT_LEFTMARGIN
},
128 {RO_TextNum
,STR_LEFT_MARGIN
},
129 {RO_TextPos
,TEXTPOS_LEFT
},
132 print_rightmargin_gadget
[]={
133 {RO_Type
,OBJECT_GADGET
},
134 {RO_GadgetType
,GADGET_INTEGER
},
135 {RO_GadgetID
,PRINT_RIGHTMARGIN
},
142 {RO_TextNum
,STR_RIGHT_MARGIN
},
143 {RO_TextPos
,TEXTPOS_LEFT
},
147 print_tabsize_gadget
[]={
148 {RO_Type
,OBJECT_GADGET
},
149 {RO_GadgetType
,GADGET_INTEGER
},
150 {RO_GadgetID
,PRINT_TABSIZE
},
156 {RO_TextNum
,STR_TAB_SIZE
},
157 {RO_TextPos
,TEXTPOS_LEFT
},
160 print_pitch_gadget
[]={
161 {RO_Type
,OBJECT_GADGET
},
162 {RO_GadgetType
,GADGET_CYCLE
},
163 {RO_GadgetID
,PRINT_PITCH
},
172 {RO_TextNum
,STR_PRINT_PITCH
},
173 {RO_TextPos
,TEXTPOS_LEFT
},
174 {RO_HighRecess
,TRUE
},
176 print_quality_gadget
[]={
177 {RO_Type
,OBJECT_GADGET
},
178 {RO_GadgetType
,GADGET_CYCLE
},
179 {RO_GadgetID
,PRINT_QUALITY
},
188 {RO_TextNum
,STR_QUALITY
},
189 {RO_TextPos
,TEXTPOS_LEFT
},
190 {RO_HighRecess
,TRUE
},
192 print_ejectpage_gadget
[]={
193 {RO_Type
,OBJECT_GADGET
},
194 {RO_GadgetType
,GADGET_CHECK
},
195 {RO_GadgetID
,PRINT_EJECTPAGE
},
199 {RO_TextNum
,STR_EJECT
},
200 {RO_TextPos
,TEXTPOS_RIGHT
},
205 print_headerfooter_gadget
[]={
206 {RO_Type
,OBJECT_GADGET
},
207 {RO_GadgetType
,GADGET_CYCLE
},
208 {RO_GadgetID
,PRINT_HEADERFOOTER
},
215 {RO_TextNum
,STR_CONFIGURATION
},
216 {RO_TextPos
,TEXTPOS_RIGHT
},
217 {RO_HighRecess
,TRUE
},
219 headfoot_title_gadget
[]={
220 {RO_Type
,OBJECT_GADGET
},
221 {RO_GadgetType
,GADGET_CHECK
},
222 {RO_GadgetID
,HEADFOOT_TITLE
},
226 {RO_TextNum
,STR_TITLE
},
227 {RO_TextPos
,TEXTPOS_RIGHT
},
230 headfoot_date_gadget
[]={
231 {RO_Type
,OBJECT_GADGET
},
232 {RO_GadgetType
,GADGET_CHECK
},
233 {RO_GadgetID
,HEADFOOT_DATE
},
237 {RO_TextNum
,STR_DATE
},
238 {RO_TextPos
,TEXTPOS_RIGHT
},
241 headfoot_pagenumber_gadget
[]={
242 {RO_Type
,OBJECT_GADGET
},
243 {RO_GadgetType
,GADGET_CHECK
},
244 {RO_GadgetID
,HEADFOOT_PAGENUMBER
},
248 {RO_TextNum
,STR_PAGE_NUMBER
},
249 {RO_TextPos
,TEXTPOS_RIGHT
},
252 headfoot_titlestring_gadget
[]={
253 {RO_Type
,OBJECT_GADGET
},
254 {RO_GadgetType
,GADGET_STRING
},
255 {RO_GadgetID
,HEADFOOT_TITLESTRING
},
265 headfoot_textstyle_gadget
[]={
266 {RO_Type
,OBJECT_GADGET
},
267 {RO_GadgetType
,GADGET_CYCLE
},
268 {RO_GadgetID
,HEADFOOT_TEXTSTYLE
},
277 {RO_TextNum
,STR_TEXT_STYLE
},
278 {RO_TextPos
,TEXTPOS_LEFT
},
279 {RO_HighRecess
,TRUE
},
282 output_printer_gadget
[]={
283 {RO_Type
,OBJECT_GADGET
},
284 {RO_GadgetType
,GADGET_RADIO
},
285 {RO_GadgetID
,OUTPUT_PRINTER
},
289 {RO_TextNum
,STR_PRINTER
},
290 {RO_TextPos
,TEXTPOS_RIGHT
},
293 output_file_gadget
[]={
294 {RO_Type
,OBJECT_GADGET
},
295 {RO_GadgetType
,GADGET_RADIO
},
296 {RO_GadgetID
,OUTPUT_FILE
},
300 {RO_TextNum
,STR_FILE
},
301 {RO_TextPos
,TEXTPOS_RIGHT
},
304 output_filerequester_gadget
[]={
305 {RO_Type
,OBJECT_GADGET
},
306 {RO_GadgetType
,GADGET_TINYGLASS
},
307 {RO_GadgetID
,OUTPUT_FILEREQUESTER
},
315 {RO_HighRecess
,TRUE
},
317 output_filestring_gadget
[]={
318 {RO_Type
,OBJECT_GADGET
},
319 {RO_GadgetType
,GADGET_STRING
},
320 {RO_GadgetID
,OUTPUT_FILESTRING
},
331 print_print_gadget
[]={
332 {RO_Type
,OBJECT_GADGET
},
333 {RO_GadgetType
,GADGET_BOOLEAN
},
334 {RO_GadgetID
,PRINT_PRINT
},
340 {RO_TextNum
,STR_PRINT
},
341 {RO_TextPos
,TEXTPOS_CENTER
},
342 {RO_HighRecess
,TRUE
},
344 print_exit_gadget
[]={
345 {RO_Type
,OBJECT_GADGET
},
346 {RO_GadgetType
,GADGET_BOOLEAN
},
347 {RO_GadgetID
,PRINT_EXIT
},
355 {RO_TextNum
,STR_EXIT
},
356 {RO_TextPos
,TEXTPOS_CENTER
},
357 {RO_HighRecess
,TRUE
},
360 print_output_text
[]={
361 {RO_Type
,OBJECT_TEXT
},
365 {RO_TextNum
,STR_OUTPUT_TO
},
369 print_filerequester_gadget
,
371 print_topmargin_gadget
,
372 print_bottommargin_gadget
,
373 print_leftmargin_gadget
,
374 print_rightmargin_gadget
,
375 print_tabsize_gadget
,
377 print_quality_gadget
,
378 print_ejectpage_gadget
,
379 print_headerfooter_gadget
,
380 headfoot_title_gadget
,
381 headfoot_date_gadget
,
382 headfoot_pagenumber_gadget
,
383 headfoot_titlestring_gadget
,
384 headfoot_textstyle_gadget
,
385 output_printer_gadget
,
387 output_filerequester_gadget
,
388 output_filestring_gadget
,
397 *header_footer_text
[2];
399 void do_print(vis
,portname
,argslist
,argc
,argv
)
402 struct DOpusArgsList
*argslist
;
406 struct RequesterBase printreq
;
407 struct IntuiMessage
*msg
;
408 struct Window
*window
;
409 struct Gadget
**gadgets
,*refgad
;
410 struct AppWindow
*appwindow
=NULL
;
411 struct MsgPort
*appport
=NULL
;
412 struct AppMessage
*appmsg
;
414 UWORD code
,gadgetid
,qual
;
416 struct StringExtend stringex
;
417 PrintData
*printdata
;
418 int a
,headerfooter
=0,waitbits
;
419 struct Requester busyreq
;
420 char *print_file_buffer
,
421 *print_topmargin_buffer
,
422 *print_bottommargin_buffer
,
423 *print_leftmargin_buffer
,
424 *print_rightmargin_buffer
,
425 *print_tabsize_buffer
,
426 *output_filestring_buffer
;
428 for (a
=0;a
<3;a
++) text_pitch
[a
]=string_table
[STR_PICA
+a
];
429 for (a
=0;a
<6;a
++) text_styles
[a
]=string_table
[STR_NORMAL
+a
];
431 text_quality
[a
]=string_table
[STR_DRAFT
+a
];
432 header_footer_text
[a
]=string_table
[STR_HEADER
+a
];
435 printreq
.rb_width
=40;
436 printreq
.rb_height
=13;
439 fill_out_req(&printreq
,vis
);
441 printreq
.rb_privateflags
=0;
442 printreq
.rb_screenname
=NULL
;
444 if (printreq
.rb_screen
&& !(vis
->vi_flags
&VISF_BORDERS
)) {
445 printreq
.rb_flags
|=RBF_STRINGS
;
446 printreq
.rb_title
=NULL
;
447 printreq
.rb_widthfine
=45;
448 printreq
.rb_heightfine
=86;
449 printreq
.rb_leftoffset
=13;
450 printreq
.rb_topoffset
=9;
453 printreq
.rb_flags
|=RBF_BORDERS
|RBF_CLOSEGAD
|RBF_STRINGS
;
454 printreq
.rb_title
=string_table
[STR_PRINT
];
455 printreq
.rb_widthfine
=41;
456 printreq
.rb_heightfine
=83;
457 printreq
.rb_leftoffset
=11;
458 printreq
.rb_topoffset
=7;
461 printreq
.rb_extend
=&stringex
;
462 printreq
.rb_idcmpflags
=0;
463 printreq
.rb_string_table
=string_table
;
466 stringex
.Pens
[a
]=vis
->vi_stringcol
[a
];
467 stringex
.ActivePens
[a
]=vis
->vi_activestringcol
[a
];
469 stringex
.InitialModes
=0;
470 stringex
.EditHook
=NULL
;
471 stringex
.WorkBuffer
=NULL
;
472 for (a
=0;a
<4;a
++) stringex
.Reserved
[a
]=0;
474 if (!(printdata
=AllocMem(sizeof(PrintData
),MEMF_CLEAR
))) return;
476 get_print_default(printdata
);
477 get_print_env(printdata
);
480 if (window
=OpenRequester(&printreq
)) break;
481 CloseRequester(&printreq
);
485 printreq
.rb_flags
&=~RBF_BORDERS
;
486 printreq
.rb_title
=NULL
;
490 FreeMem(printdata
,sizeof(PrintData
));
495 if (!(gadgets
=LAllocRemember(&printreq
.rb_memory
,sizeof(struct Gadget
*)*PRINT_NUM_GADGETS
,0)) ||
496 !(addreqgadgets(&printreq
,print_gadgets
,gadgets
)) ||
497 !(AddRequesterObject(&printreq
,print_output_text
))) {
498 CloseRequester(&printreq
);
499 FreeMem(printdata
,sizeof(PrintData
));
503 RefreshRequesterObject(&printreq
,NULL
);
506 ((struct StringInfo
*)gadgets
[PRINT_FILE
]->SpecialInfo
)->Buffer
;
507 print_topmargin_buffer
=
508 ((struct StringInfo
*)gadgets
[PRINT_TOPMARGIN
]->SpecialInfo
)->Buffer
;
509 print_bottommargin_buffer
=
510 ((struct StringInfo
*)gadgets
[PRINT_BOTTOMMARGIN
]->SpecialInfo
)->Buffer
;
511 print_leftmargin_buffer
=
512 ((struct StringInfo
*)gadgets
[PRINT_LEFTMARGIN
]->SpecialInfo
)->Buffer
;
513 print_rightmargin_buffer
=
514 ((struct StringInfo
*)gadgets
[PRINT_RIGHTMARGIN
]->SpecialInfo
)->Buffer
;
515 print_tabsize_buffer
=
516 ((struct StringInfo
*)gadgets
[PRINT_TABSIZE
]->SpecialInfo
)->Buffer
;
517 output_filestring_buffer
=
518 ((struct StringInfo
*)gadgets
[OUTPUT_FILESTRING
]->SpecialInfo
)->Buffer
;
521 argslist
->file_data
=print_file_buffer
;
522 dopus_message(DOPUSMSG_GETNEXTFILE
,(APTR
)argslist
,portname
);
524 else if (argc
>0) strcpy(print_file_buffer
,argv
[0]);
525 else print_file_buffer
[0]=0;
527 if (printdata
->top_margin
<1) printdata
->top_margin
=1;
528 lsprintf(print_topmargin_buffer
,"%ld",(long int)printdata
->top_margin
);
529 lsprintf(print_bottommargin_buffer
,"%ld",(long int)printdata
->bottom_margin
);
530 if (printdata
->left_margin
<1) printdata
->left_margin
=1;
531 lsprintf(print_leftmargin_buffer
,"%ld",(long int)printdata
->left_margin
);
532 lsprintf(print_rightmargin_buffer
,"%ld",(long int)printdata
->right_margin
);
533 lsprintf(print_tabsize_buffer
,"%ld",(long int)printdata
->tab_size
);
535 strcpy(output_filestring_buffer
,printdata
->output_file
);
537 DoCycleGadget(gadgets
[PRINT_PITCH
],window
,text_pitch
,printdata
->print_pitch
);
538 DoCycleGadget(gadgets
[PRINT_QUALITY
],window
,text_quality
,printdata
->text_quality
);
540 if (printdata
->print_flags
&PRINTFLAG_EJECT
)
541 gadgets
[PRINT_EJECTPAGE
]->Flags
|=GFLG_SELECTED
;
542 else gadgets
[PRINT_EJECTPAGE
]->Flags
&=~GFLG_SELECTED
;
544 if (printdata
->print_flags
&PRINTFLAG_FILE
) {
545 gadgets
[OUTPUT_PRINTER
]->Flags
&=~GFLG_SELECTED
;
546 gadgets
[OUTPUT_FILE
]->Flags
|=GFLG_SELECTED
;
549 gadgets
[OUTPUT_PRINTER
]->Flags
|=GFLG_SELECTED
;
550 gadgets
[OUTPUT_FILE
]->Flags
&=~GFLG_SELECTED
;
553 show_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
);
556 OffGadget(gadgets
[PRINT_FILEREQUESTER
],window
,NULL
);
557 OffGadget(gadgets
[PRINT_FILE
],window
,NULL
);
560 if (!portname
&& WorkbenchBase
&&
561 (appport
=LCreatePort(NULL
,0)))
562 appwindow
=AddAppWindowA(0,0,window
,appport
,NULL
);
566 while (appmsg
=(struct AppMessage
*)GetMsg(appport
)) {
567 if (appmsg
->am_Type
==AMTYPE_APPWINDOW
) {
568 if (appmsg
->am_NumArgs
>0 && appmsg
->am_ArgList
[0].wa_Lock
) {
571 PathName(appmsg
->am_ArgList
[0].wa_Lock
,buf
,256);
572 TackOn(buf
,appmsg
->am_ArgList
[0].wa_Name
,256);
573 if (CheckExist(buf
,NULL
)<0) {
574 strcpy(print_file_buffer
,buf
);
575 RefreshStrGad(gadgets
[PRINT_FILE
],window
);
577 else DisplayBeep(NULL
);
579 else DisplayBeep(NULL
);
581 ReplyMsg((struct Message
*)appmsg
);
584 while (msg
=(struct IntuiMessage
*)GetMsg(window
->UserPort
)) {
585 class=msg
->Class
; code
=msg
->Code
; qual
=msg
->Qualifier
;
586 iaddress
=msg
->IAddress
;
587 ReplyMsg((struct Message
*)msg
);
590 case IDCMP_GADGETDOWN
:
591 gadgetid
=((struct Gadget
*)iaddress
)->GadgetID
;
595 if (!(gadgets
[OUTPUT_PRINTER
]->Flags
&GFLG_SELECTED
)) {
596 gadgets
[OUTPUT_PRINTER
]->Flags
|=GFLG_SELECTED
;
597 RefreshGList(gadgets
[OUTPUT_PRINTER
],window
,NULL
,1);
599 gadgets
[OUTPUT_FILE
]->Flags
&=~GFLG_SELECTED
;
600 RefreshGList(gadgets
[OUTPUT_FILE
],window
,NULL
,1);
601 printdata
->print_flags
&=~PRINTFLAG_FILE
;
605 if (!(gadgets
[OUTPUT_FILE
]->Flags
&GFLG_SELECTED
)) {
606 gadgets
[OUTPUT_FILE
]->Flags
|=GFLG_SELECTED
;
607 RefreshGList(gadgets
[OUTPUT_FILE
],window
,NULL
,1);
609 gadgets
[OUTPUT_PRINTER
]->Flags
&=~GFLG_SELECTED
;
610 RefreshGList(gadgets
[OUTPUT_PRINTER
],window
,NULL
,1);
611 printdata
->print_flags
|=PRINTFLAG_FILE
;
617 gadgetid
=((struct Gadget
*)iaddress
)->GadgetID
;
621 case PRINT_TOPMARGIN
:
622 if (check_print_gadget(window
,gadgets
[PRINT_TOPMARGIN
],
623 1,atoi(print_bottommargin_buffer
)-5,code
))
624 refgad
=(struct Gadget
*)iaddress
;
625 printdata
->top_margin
=atoi(print_topmargin_buffer
);
627 case PRINT_BOTTOMMARGIN
:
628 if (check_print_gadget(window
,gadgets
[PRINT_BOTTOMMARGIN
],
629 atoi(print_topmargin_buffer
)+5,999,code
))
630 refgad
=(struct Gadget
*)iaddress
;
631 printdata
->bottom_margin
=atoi(print_bottommargin_buffer
);
633 case PRINT_LEFTMARGIN
:
634 if (check_print_gadget(window
,gadgets
[PRINT_LEFTMARGIN
],
635 1,atoi(print_rightmargin_buffer
)-1,code
))
636 refgad
=(struct Gadget
*)iaddress
;
637 printdata
->left_margin
=atoi(print_leftmargin_buffer
);
639 case PRINT_RIGHTMARGIN
:
640 if (check_print_gadget(window
,gadgets
[PRINT_RIGHTMARGIN
],
641 atoi(print_leftmargin_buffer
)+1,999,code
))
642 refgad
=(struct Gadget
*)iaddress
;
643 printdata
->right_margin
=atoi(print_rightmargin_buffer
);
647 if (check_print_gadget(window
,gadgets
[PRINT_TABSIZE
],
649 ActivateStrGad(gadgets
[PRINT_TOPMARGIN
],window
);
650 printdata
->tab_size
=atoi(print_tabsize_buffer
);
654 if (qual
&(IEQUALIFIER_LSHIFT
|IEQUALIFIER_RSHIFT
)) {
655 if ((printdata
->print_pitch
--)==0)
656 printdata
->print_pitch
=PITCH_COUNT
-1;
659 if ((++printdata
->print_pitch
)==PITCH_COUNT
)
660 printdata
->print_pitch
=0;
662 DoCycleGadget(gadgets
[PRINT_PITCH
],window
,
663 text_pitch
,printdata
->print_pitch
);
667 printdata
->text_quality
=1-printdata
->text_quality
;
668 DoCycleGadget(gadgets
[PRINT_QUALITY
],window
,
669 text_quality
,printdata
->text_quality
);
672 case PRINT_HEADERFOOTER
:
673 read_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
);
674 headerfooter
=1-headerfooter
;
675 show_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
);
678 case HEADFOOT_TEXTSTYLE
:
679 if (qual
&(IEQUALIFIER_LSHIFT
|IEQUALIFIER_RSHIFT
)) {
680 if ((printdata
->headfoot
[headerfooter
].text_style
--)==0)
681 printdata
->headfoot
[headerfooter
].text_style
=STYLE_COUNT
-1;
684 if ((++printdata
->headfoot
[headerfooter
].text_style
)==STYLE_COUNT
)
685 printdata
->headfoot
[headerfooter
].text_style
=0;
687 DoCycleGadget(gadgets
[HEADFOOT_TEXTSTYLE
],window
,
688 text_styles
,printdata
->headfoot
[headerfooter
].text_style
);
691 case HEADFOOT_TITLESTRING
:
692 RefreshStrGad(gadgets
[HEADFOOT_TITLESTRING
],window
);
695 case OUTPUT_FILEREQUESTER
:
696 if (!(get_file_byrequest(gadgets
[OUTPUT_FILESTRING
],window
,1)))
698 case OUTPUT_FILESTRING
:
699 strcpy(printdata
->output_file
,output_filestring_buffer
);
700 RefreshStrGad(gadgets
[OUTPUT_FILESTRING
],window
);
701 if (gadgets
[OUTPUT_PRINTER
]->Flags
&GFLG_SELECTED
) {
702 gadgets
[OUTPUT_PRINTER
]->Flags
&=~GFLG_SELECTED
;
703 gadgets
[OUTPUT_FILE
]->Flags
|=GFLG_SELECTED
;
704 RefreshGList(gadgets
[OUTPUT_PRINTER
],window
,NULL
,2);
705 printdata
->print_flags
|=PRINTFLAG_FILE
;
709 case PRINT_FILEREQUESTER
:
710 get_file_byrequest(gadgets
[PRINT_FILE
],window
,0);
713 case PRINT_EJECTPAGE
:
714 if (gadgets
[PRINT_EJECTPAGE
]->Flags
&GFLG_SELECTED
)
715 printdata
->print_flags
|=PRINTFLAG_EJECT
;
716 else printdata
->print_flags
&=~PRINTFLAG_EJECT
;
720 read_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
);
722 SetBusyPointer(window
);
723 if (appwindow
) RemoveAppWindow(appwindow
);
725 while (print_file_buffer
[0]) {
726 InitRequester(&busyreq
);
727 busyreq
.Width
=window
->RPort
->Font
->tf_XSize
*22;
728 busyreq
.Height
=window
->RPort
->Font
->tf_YSize
*7;
729 busyreq
.LeftEdge
=(window
->Width
-busyreq
.Width
)/2;
730 busyreq
.TopEdge
=(window
->Height
-busyreq
.Height
)/2;
731 busyreq
.Flags
=NOISYREQ
;
732 busyreq
.BackFill
=printreq
.rb_bg
;
734 if (!(printfile(&printreq
,print_file_buffer
,printdata
,&busyreq
)))
738 dopus_message(DOPUSMSG_UNSELECTFILE
,(APTR
)argslist
,portname
);
739 dopus_message(DOPUSMSG_GETNEXTFILE
,(APTR
)argslist
,portname
);
745 appwindow
=AddAppWindowA(0,0,window
,appport
,NULL
);
747 ClearPointer(window
);
759 RefreshStrGad(refgad
,window
);
760 if (code
!=0x9) activate_next_gadget(refgad
,window
);
762 if (gadgetid
!=PRINT_EXIT
) break;
764 case IDCMP_VANILLAKEY
:
765 if (code
!=0x1b) break;
767 case IDCMP_CLOSEWINDOW
:
768 if (appwindow
) RemoveAppWindow(appwindow
);
769 if (appport
) LDeletePort(appport
);
770 read_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
);
771 CloseRequester(&printreq
);
772 set_print_env(printdata
);
773 FreeMem(printdata
,sizeof(PrintData
));
777 waitbits
=1<<window
->UserPort
->mp_SigBit
;
778 if (appwindow
) waitbits
|=1<<appport
->mp_SigBit
;
783 void get_print_default(printdata
)
784 PrintData
*printdata
;
786 struct Preferences prefs
;
788 GetPrefs(&prefs
,sizeof(struct Preferences
));
790 printdata
->top_margin
=1;
791 printdata
->bottom_margin
=prefs
.PaperLength
;
792 printdata
->left_margin
=prefs
.PrintLeftMargin
;
793 printdata
->right_margin
=prefs
.PrintRightMargin
;
795 printdata
->tab_size
=8;
796 switch (prefs
.PrintPitch
) {
798 printdata
->print_pitch
=PITCH_ELITE
;
801 printdata
->print_pitch
=PITCH_FINE
;
805 printdata
->print_flags
=PRINTFLAG_EJECT
;
808 void show_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
)
809 struct Gadget
**gadgets
;
810 struct Window
*window
;
811 PrintData
*printdata
;
814 DoCycleGadget(gadgets
[PRINT_HEADERFOOTER
],window
,header_footer_text
,
816 DoCycleGadget(gadgets
[HEADFOOT_TEXTSTYLE
],window
,text_styles
,
817 printdata
->headfoot
[headerfooter
].text_style
);
818 strcpy(((struct StringInfo
*)gadgets
[HEADFOOT_TITLESTRING
]->SpecialInfo
)->Buffer
,
819 printdata
->headfoot
[headerfooter
].headfoot_title
);
821 if (printdata
->headfoot
[headerfooter
].headfoot_flags
&HEADFOOTFLAG_TITLE
)
822 gadgets
[HEADFOOT_TITLE
]->Flags
|=GFLG_SELECTED
;
823 else gadgets
[HEADFOOT_TITLE
]->Flags
&=~GFLG_SELECTED
;
825 if (printdata
->headfoot
[headerfooter
].headfoot_flags
&HEADFOOTFLAG_DATE
)
826 gadgets
[HEADFOOT_DATE
]->Flags
|=GFLG_SELECTED
;
827 else gadgets
[HEADFOOT_DATE
]->Flags
&=~GFLG_SELECTED
;
829 if (printdata
->headfoot
[headerfooter
].headfoot_flags
&HEADFOOTFLAG_PAGE
)
830 gadgets
[HEADFOOT_PAGENUMBER
]->Flags
|=GFLG_SELECTED
;
831 else gadgets
[HEADFOOT_PAGENUMBER
]->Flags
&=~GFLG_SELECTED
;
833 RefreshGList(gadgets
[0],window
,NULL
,-1);
836 void read_headerfooter_gadgets(gadgets
,window
,printdata
,headerfooter
)
837 struct Gadget
**gadgets
;
838 struct Window
*window
;
839 PrintData
*printdata
;
842 strcpy(printdata
->headfoot
[headerfooter
].headfoot_title
,
843 ((struct StringInfo
*)gadgets
[HEADFOOT_TITLESTRING
]->SpecialInfo
)->Buffer
);
845 if (gadgets
[HEADFOOT_TITLE
]->Flags
&GFLG_SELECTED
)
846 printdata
->headfoot
[headerfooter
].headfoot_flags
|=HEADFOOTFLAG_TITLE
;
847 else printdata
->headfoot
[headerfooter
].headfoot_flags
&=~HEADFOOTFLAG_TITLE
;
849 if (gadgets
[HEADFOOT_DATE
]->Flags
&GFLG_SELECTED
)
850 printdata
->headfoot
[headerfooter
].headfoot_flags
|=HEADFOOTFLAG_DATE
;
851 else printdata
->headfoot
[headerfooter
].headfoot_flags
&=~HEADFOOTFLAG_DATE
;
853 if (gadgets
[HEADFOOT_PAGENUMBER
]->Flags
&GFLG_SELECTED
)
854 printdata
->headfoot
[headerfooter
].headfoot_flags
|=HEADFOOTFLAG_PAGE
;
855 else printdata
->headfoot
[headerfooter
].headfoot_flags
&=~HEADFOOTFLAG_PAGE
;
858 int check_print_gadget(window
,gad
,min
,max
,code
)
859 struct Window
*window
;
864 if (CheckNumGad(gad
,window
,min
,max
)) {
866 if (code
!=0x9) ActivateStrGad(gad
,window
);