| [18] | 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 | 
|---|
| [33] | 10 | Classes, | 
|---|
|  | 11 | Forms, | 
|---|
|  | 12 | Buttons, | 
|---|
|  | 13 | ExtCtrls, | 
|---|
|  | 14 | StdCtrls, | 
|---|
| [18] | 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, | 
|---|
| [33] | 54 | Printers, | 
|---|
| [18] | 55 | ACLDialogs, | 
|---|
| [94] | 56 | ControlsUtility, | 
|---|
|  | 57 | DebugUnit, | 
|---|
|  | 58 | StringUtilsUnit; | 
|---|
| [18] | 59 |  | 
|---|
|  | 60 | Procedure TNewViewPrintDialog.OKButtonOnClick (Sender: TObject); | 
|---|
|  | 61 | Begin | 
|---|
|  | 62 |  | 
|---|
|  | 63 | End; | 
|---|
|  | 64 |  | 
|---|
|  | 65 | Procedure TNewViewPrintDialog.NewViewPrintDialogOnSetupShow (Sender: TObject); | 
|---|
|  | 66 | Begin | 
|---|
| [465] | 67 | ScaleForm( self, 8, 16 ); | 
|---|
|  | 68 | // ScaleForm seems to misposition the combo-box, so fix it here | 
|---|
|  | 69 | PrinterComboBox.Bottom := PrinterLabel.Bottom - PrinterComboBox.Height - 1; | 
|---|
| [18] | 70 | End; | 
|---|
|  | 71 |  | 
|---|
|  | 72 | Procedure TNewViewPrintDialog.NewViewPrintDialogOnCreate (Sender: TObject); | 
|---|
|  | 73 | Begin | 
|---|
|  | 74 | RegisterForLanguages( OnLanguageEvent ); | 
|---|
|  | 75 | End; | 
|---|
|  | 76 |  | 
|---|
|  | 77 | Procedure TNewViewPrintDialog.OnLanguageEvent( Language: TLanguageFile; | 
|---|
|  | 78 | const Apply: boolean ); | 
|---|
|  | 79 | begin | 
|---|
| [94] | 80 | LogEvent(LogI18n, 'TNewViewPrintDialog.OnLanguageEvent apply: "' + BoolToStr(Apply) + '"'); | 
|---|
| [18] | 81 | Language.LoadComponentLanguage( self, Apply ); | 
|---|
|  | 82 |  | 
|---|
|  | 83 | Language.LL( Apply, SetupPrinterErrorTitle, 'SetupPrinterErrorTitle', 'Setup Printer' ); | 
|---|
|  | 84 | Language.LL( Apply, SetupPrinterError, 'SetupPrinterError', 'Error displaying printer options: ' ); | 
|---|
|  | 85 | end; | 
|---|
|  | 86 |  | 
|---|
|  | 87 | Procedure TNewViewPrintDialog.PrinterComboBoxOnItemSelect (Sender: TObject; | 
|---|
|  | 88 | Index: LongInt); | 
|---|
|  | 89 | Begin | 
|---|
|  | 90 | Printer.PrinterIndex := PrinterComboBox.ItemIndex; | 
|---|
|  | 91 | End; | 
|---|
|  | 92 |  | 
|---|
|  | 93 | Procedure TNewViewPrintDialog.SetupPrinterButtonOnClick (Sender: TObject); | 
|---|
|  | 94 | Begin | 
|---|
|  | 95 | try | 
|---|
|  | 96 | Printer.OptionsDlg; | 
|---|
|  | 97 | except | 
|---|
|  | 98 | on E: Exception do | 
|---|
|  | 99 | begin | 
|---|
|  | 100 | DoErrorDlg( SetupPrinterErrorTitle, | 
|---|
|  | 101 | SetupPrinterError + E.Message ); | 
|---|
|  | 102 | end; | 
|---|
|  | 103 | end; | 
|---|
|  | 104 | End; | 
|---|
|  | 105 |  | 
|---|
|  | 106 | Procedure TNewViewPrintDialog.PrintDialogOnShow (Sender: TObject); | 
|---|
|  | 107 | Begin | 
|---|
|  | 108 | PrinterComboBox.Items.Assign( Printer.Printers ); | 
|---|
|  | 109 | PrinterComboBox.ItemIndex := Printer.PrinterIndex; | 
|---|
|  | 110 | OKButton.Default := true; | 
|---|
|  | 111 | End; | 
|---|
|  | 112 |  | 
|---|
|  | 113 | Initialization | 
|---|
|  | 114 | RegisterClasses ([TNewViewPrintDialog, TComboBox, TLabel, TButton, TRadioGroup]); | 
|---|
|  | 115 | End. | 
|---|