| 1 | Unit PrintDialogUnit;
 | 
|---|
| 2 | 
 | 
|---|
| 3 | // NewView - a new OS/2 Help Viewer
 | 
|---|
| 4 | // Copyright 2003 Aaron Lawrence (aaronl at consultant dot com)
 | 
|---|
| 5 | // This software is released under the Gnu Public License - see readme.txt
 | 
|---|
| 6 | 
 | 
|---|
| 7 | Interface
 | 
|---|
| 8 | 
 | 
|---|
| 9 | Uses
 | 
|---|
| 10 |   Classes, Forms, Graphics, Buttons, ExtCtrls, StdCtrls,
 | 
|---|
| 11 |   ACLLanguageUnit;
 | 
|---|
| 12 | 
 | 
|---|
| 13 | Type
 | 
|---|
| 14 |   TPrintSelection =
 | 
|---|
| 15 |   (
 | 
|---|
| 16 |     ptCurrentTopic,
 | 
|---|
| 17 |     ptVisibleTopics,
 | 
|---|
| 18 |     ptAllTopics
 | 
|---|
| 19 |   );
 | 
|---|
| 20 | 
 | 
|---|
| 21 |   TNewViewPrintDialog = Class (TForm)
 | 
|---|
| 22 |     PrinterComboBox: TComboBox;
 | 
|---|
| 23 |     PrinterLabel: TLabel;
 | 
|---|
| 24 |     WhatToPrintRadioGroup: TRadioGroup;
 | 
|---|
| 25 |     OKButton: TButton;
 | 
|---|
| 26 |     SetupPrinterButton: TButton;
 | 
|---|
| 27 |     CancelButton: TButton;
 | 
|---|
| 28 |     Procedure OKButtonOnClick (Sender: TObject);
 | 
|---|
| 29 |     Procedure NewViewPrintDialogOnSetupShow (Sender: TObject);
 | 
|---|
| 30 |     Procedure NewViewPrintDialogOnCreate (Sender: TObject);
 | 
|---|
| 31 |     Procedure PrinterComboBoxOnItemSelect (Sender: TObject; Index: LongInt);
 | 
|---|
| 32 |     Procedure SetupPrinterButtonOnClick (Sender: TObject);
 | 
|---|
| 33 |     Procedure PrintDialogOnShow (Sender: TObject);
 | 
|---|
| 34 |   Public
 | 
|---|
| 35 |   Protected
 | 
|---|
| 36 |     Procedure OnLanguageEvent( Language: TLanguageFile;
 | 
|---|
| 37 |                                const Apply: boolean );
 | 
|---|
| 38 | 
 | 
|---|
| 39 |     SetupPrinterErrorTitle: string;
 | 
|---|
| 40 |     SetupPrinterError: string;
 | 
|---|
| 41 |   End;
 | 
|---|
| 42 | 
 | 
|---|
| 43 | Var
 | 
|---|
| 44 |   NewViewPrintDialog: TNewViewPrintDialog;
 | 
|---|
| 45 | 
 | 
|---|
| 46 | Implementation
 | 
|---|
| 47 | 
 | 
|---|
| 48 | uses
 | 
|---|
| 49 |   SysUtils,
 | 
|---|
| 50 |   Dialogs, Printers,
 | 
|---|
| 51 |   ACLDialogs,
 | 
|---|
| 52 |   ControlsUtility;
 | 
|---|
| 53 | 
 | 
|---|
| 54 | Procedure TNewViewPrintDialog.OKButtonOnClick (Sender: TObject);
 | 
|---|
| 55 | Begin
 | 
|---|
| 56 | 
 | 
|---|
| 57 | End;
 | 
|---|
| 58 | 
 | 
|---|
| 59 | Procedure TNewViewPrintDialog.NewViewPrintDialogOnSetupShow (Sender: TObject);
 | 
|---|
| 60 | Begin
 | 
|---|
| 61 |   ScaleForm( self, 11, 16 );
 | 
|---|
| 62 | End;
 | 
|---|
| 63 | 
 | 
|---|
| 64 | Procedure TNewViewPrintDialog.NewViewPrintDialogOnCreate (Sender: TObject);
 | 
|---|
| 65 | Begin
 | 
|---|
| 66 |   RegisterForLanguages( OnLanguageEvent );
 | 
|---|
| 67 | End;
 | 
|---|
| 68 | 
 | 
|---|
| 69 | Procedure TNewViewPrintDialog.OnLanguageEvent( Language: TLanguageFile;
 | 
|---|
| 70 |                                                const Apply: boolean );
 | 
|---|
| 71 | begin
 | 
|---|
| 72 |   Language.LoadComponentLanguage( self, Apply );
 | 
|---|
| 73 | 
 | 
|---|
| 74 |   Language.LL( Apply, SetupPrinterErrorTitle, 'SetupPrinterErrorTitle', 'Setup Printer' );
 | 
|---|
| 75 |   Language.LL( Apply, SetupPrinterError, 'SetupPrinterError', 'Error displaying printer options: ' );
 | 
|---|
| 76 | end;
 | 
|---|
| 77 | 
 | 
|---|
| 78 | Procedure TNewViewPrintDialog.PrinterComboBoxOnItemSelect (Sender: TObject;
 | 
|---|
| 79 |   Index: LongInt);
 | 
|---|
| 80 | Begin
 | 
|---|
| 81 |   Printer.PrinterIndex := PrinterComboBox.ItemIndex;
 | 
|---|
| 82 | End;
 | 
|---|
| 83 | 
 | 
|---|
| 84 | Procedure TNewViewPrintDialog.SetupPrinterButtonOnClick (Sender: TObject);
 | 
|---|
| 85 | Begin
 | 
|---|
| 86 |   try
 | 
|---|
| 87 |     Printer.OptionsDlg;
 | 
|---|
| 88 |   except
 | 
|---|
| 89 |     on E: Exception do
 | 
|---|
| 90 |     begin
 | 
|---|
| 91 |       DoErrorDlg( SetupPrinterErrorTitle,
 | 
|---|
| 92 |                   SetupPrinterError + E.Message );
 | 
|---|
| 93 |     end;
 | 
|---|
| 94 |   end;
 | 
|---|
| 95 | End;
 | 
|---|
| 96 | 
 | 
|---|
| 97 | Procedure TNewViewPrintDialog.PrintDialogOnShow (Sender: TObject);
 | 
|---|
| 98 | Begin
 | 
|---|
| 99 |   PrinterComboBox.Items.Assign( Printer.Printers );
 | 
|---|
| 100 |   PrinterComboBox.ItemIndex := Printer.PrinterIndex;
 | 
|---|
| 101 |   OKButton.Default := true;
 | 
|---|
| 102 | End;
 | 
|---|
| 103 | 
 | 
|---|
| 104 | Initialization
 | 
|---|
| 105 |   RegisterClasses ([TNewViewPrintDialog, TComboBox, TLabel, TButton, TRadioGroup]);
 | 
|---|
| 106 | End.
 | 
|---|