| 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, | 
|---|
| 11 | Forms, | 
|---|
| 12 | Buttons, | 
|---|
| 13 | ExtCtrls, | 
|---|
| 14 | StdCtrls, | 
|---|
| 15 | ACLLanguageUnit; | 
|---|
| 16 |  | 
|---|
| 17 | Type | 
|---|
| 18 | TPrintSelection = | 
|---|
| 19 | ( | 
|---|
| 20 | ptCurrentTopic, | 
|---|
| 21 | ptVisibleTopics, | 
|---|
| 22 | ptAllTopics | 
|---|
| 23 | ); | 
|---|
| 24 |  | 
|---|
| 25 | TNewViewPrintDialog = Class (TForm) | 
|---|
| 26 | PrinterComboBox: TComboBox; | 
|---|
| 27 | PrinterLabel: TLabel; | 
|---|
| 28 | WhatToPrintRadioGroup: TRadioGroup; | 
|---|
| 29 | OKButton: TButton; | 
|---|
| 30 | SetupPrinterButton: TButton; | 
|---|
| 31 | CancelButton: TButton; | 
|---|
| 32 | Procedure OKButtonOnClick (Sender: TObject); | 
|---|
| 33 | Procedure NewViewPrintDialogOnSetupShow (Sender: TObject); | 
|---|
| 34 | Procedure NewViewPrintDialogOnCreate (Sender: TObject); | 
|---|
| 35 | Procedure PrinterComboBoxOnItemSelect (Sender: TObject; Index: LongInt); | 
|---|
| 36 | Procedure SetupPrinterButtonOnClick (Sender: TObject); | 
|---|
| 37 | Procedure PrintDialogOnShow (Sender: TObject); | 
|---|
| 38 | Public | 
|---|
| 39 | Protected | 
|---|
| 40 | Procedure OnLanguageEvent( Language: TLanguageFile; | 
|---|
| 41 | const Apply: boolean ); | 
|---|
| 42 |  | 
|---|
| 43 | SetupPrinterErrorTitle: string; | 
|---|
| 44 | SetupPrinterError: string; | 
|---|
| 45 | End; | 
|---|
| 46 |  | 
|---|
| 47 | Var | 
|---|
| 48 | NewViewPrintDialog: TNewViewPrintDialog; | 
|---|
| 49 |  | 
|---|
| 50 | Implementation | 
|---|
| 51 |  | 
|---|
| 52 | uses | 
|---|
| 53 | SysUtils, | 
|---|
| 54 | Printers, | 
|---|
| 55 | ACLDialogs, | 
|---|
| 56 | ControlsUtility, | 
|---|
| 57 | DebugUnit, | 
|---|
| 58 | StringUtilsUnit; | 
|---|
| 59 |  | 
|---|
| 60 | Procedure TNewViewPrintDialog.OKButtonOnClick (Sender: TObject); | 
|---|
| 61 | Begin | 
|---|
| 62 |  | 
|---|
| 63 | End; | 
|---|
| 64 |  | 
|---|
| 65 | Procedure TNewViewPrintDialog.NewViewPrintDialogOnSetupShow (Sender: TObject); | 
|---|
| 66 | Begin | 
|---|
| 67 | ScaleForm( self, 11, 16 ); | 
|---|
| 68 | End; | 
|---|
| 69 |  | 
|---|
| 70 | Procedure TNewViewPrintDialog.NewViewPrintDialogOnCreate (Sender: TObject); | 
|---|
| 71 | Begin | 
|---|
| 72 | RegisterForLanguages( OnLanguageEvent ); | 
|---|
| 73 | End; | 
|---|
| 74 |  | 
|---|
| 75 | Procedure TNewViewPrintDialog.OnLanguageEvent( Language: TLanguageFile; | 
|---|
| 76 | const Apply: boolean ); | 
|---|
| 77 | begin | 
|---|
| 78 | LogEvent(LogI18n, 'TNewViewPrintDialog.OnLanguageEvent apply: "' + BoolToStr(Apply) + '"'); | 
|---|
| 79 | Language.LoadComponentLanguage( self, Apply ); | 
|---|
| 80 |  | 
|---|
| 81 | Language.LL( Apply, SetupPrinterErrorTitle, 'SetupPrinterErrorTitle', 'Setup Printer' ); | 
|---|
| 82 | Language.LL( Apply, SetupPrinterError, 'SetupPrinterError', 'Error displaying printer options: ' ); | 
|---|
| 83 | end; | 
|---|
| 84 |  | 
|---|
| 85 | Procedure TNewViewPrintDialog.PrinterComboBoxOnItemSelect (Sender: TObject; | 
|---|
| 86 | Index: LongInt); | 
|---|
| 87 | Begin | 
|---|
| 88 | Printer.PrinterIndex := PrinterComboBox.ItemIndex; | 
|---|
| 89 | End; | 
|---|
| 90 |  | 
|---|
| 91 | Procedure TNewViewPrintDialog.SetupPrinterButtonOnClick (Sender: TObject); | 
|---|
| 92 | Begin | 
|---|
| 93 | try | 
|---|
| 94 | Printer.OptionsDlg; | 
|---|
| 95 | except | 
|---|
| 96 | on E: Exception do | 
|---|
| 97 | begin | 
|---|
| 98 | DoErrorDlg( SetupPrinterErrorTitle, | 
|---|
| 99 | SetupPrinterError + E.Message ); | 
|---|
| 100 | end; | 
|---|
| 101 | end; | 
|---|
| 102 | End; | 
|---|
| 103 |  | 
|---|
| 104 | Procedure TNewViewPrintDialog.PrintDialogOnShow (Sender: TObject); | 
|---|
| 105 | Begin | 
|---|
| 106 | PrinterComboBox.Items.Assign( Printer.Printers ); | 
|---|
| 107 | PrinterComboBox.ItemIndex := Printer.PrinterIndex; | 
|---|
| 108 | OKButton.Default := true; | 
|---|
| 109 | End; | 
|---|
| 110 |  | 
|---|
| 111 | Initialization | 
|---|
| 112 | RegisterClasses ([TNewViewPrintDialog, TComboBox, TLabel, TButton, TRadioGroup]); | 
|---|
| 113 | End. | 
|---|