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 | RegisterEventForLanguages( OnLanguageEvent );
|
---|
73 | End;
|
---|
74 |
|
---|
75 | Procedure TNewViewPrintDialog.OnLanguageEvent( Language: TLanguageFile;
|
---|
76 | const Apply: boolean );
|
---|
77 | var
|
---|
78 | tmpPrefix : String;
|
---|
79 | begin
|
---|
80 | // LogEvent(LogI18n, 'TNewViewPrintDialog.OnLanguageEvent apply: "' + BoolToStr(Apply) + '"');
|
---|
81 | Language.LoadComponentLanguage( self, Apply );
|
---|
82 |
|
---|
83 | tmpPrefix := 'NewViewPrintDialog' + LANGUAGE_LABEL_DELIMITER;
|
---|
84 |
|
---|
85 | Language.LL( Apply, SetupPrinterErrorTitle, tmpPrefix + 'SetupPrinterErrorTitle', 'Setup Printer' );
|
---|
86 | Language.LL( Apply, SetupPrinterError, tmpPrefix + 'SetupPrinterError', 'Error displaying printer options: ' );
|
---|
87 | end;
|
---|
88 |
|
---|
89 | Procedure TNewViewPrintDialog.PrinterComboBoxOnItemSelect (Sender: TObject;
|
---|
90 | Index: LongInt);
|
---|
91 | Begin
|
---|
92 | Printer.PrinterIndex := PrinterComboBox.ItemIndex;
|
---|
93 | End;
|
---|
94 |
|
---|
95 | Procedure TNewViewPrintDialog.SetupPrinterButtonOnClick (Sender: TObject);
|
---|
96 | Begin
|
---|
97 | try
|
---|
98 | Printer.OptionsDlg;
|
---|
99 | except
|
---|
100 | on E: Exception do
|
---|
101 | begin
|
---|
102 | DoErrorDlg( SetupPrinterErrorTitle,
|
---|
103 | SetupPrinterError + E.Message );
|
---|
104 | end;
|
---|
105 | end;
|
---|
106 | End;
|
---|
107 |
|
---|
108 | Procedure TNewViewPrintDialog.PrintDialogOnShow (Sender: TObject);
|
---|
109 | Begin
|
---|
110 | PrinterComboBox.Items.Assign( Printer.Printers );
|
---|
111 | PrinterComboBox.ItemIndex := Printer.PrinterIndex;
|
---|
112 | OKButton.Default := true;
|
---|
113 | End;
|
---|
114 |
|
---|
115 | Initialization
|
---|
116 | RegisterClasses ([TNewViewPrintDialog, TComboBox, TLabel, TButton, TRadioGroup]);
|
---|
117 | End.
|
---|