source: trunk/NewView/PrintDialogUnit.pas@ 465

Last change on this file since 465 was 465, checked in by ataylor, 3 years ago

Finish(?) implementing scale-to-font logic for NewView dialogs.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1Unit 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
7Interface
8
9Uses
10 Classes,
11 Forms,
12 Buttons,
13 ExtCtrls,
14 StdCtrls,
15 ACLLanguageUnit;
16
17Type
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
47Var
48 NewViewPrintDialog: TNewViewPrintDialog;
49
50Implementation
51
52uses
53 SysUtils,
54 Printers,
55 ACLDialogs,
56 ControlsUtility,
57 DebugUnit,
58 StringUtilsUnit;
59
60Procedure TNewViewPrintDialog.OKButtonOnClick (Sender: TObject);
61Begin
62
63End;
64
65Procedure TNewViewPrintDialog.NewViewPrintDialogOnSetupShow (Sender: TObject);
66Begin
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;
70End;
71
72Procedure TNewViewPrintDialog.NewViewPrintDialogOnCreate (Sender: TObject);
73Begin
74 RegisterForLanguages( OnLanguageEvent );
75End;
76
77Procedure TNewViewPrintDialog.OnLanguageEvent( Language: TLanguageFile;
78 const Apply: boolean );
79begin
80 LogEvent(LogI18n, 'TNewViewPrintDialog.OnLanguageEvent apply: "' + BoolToStr(Apply) + '"');
81 Language.LoadComponentLanguage( self, Apply );
82
83 Language.LL( Apply, SetupPrinterErrorTitle, 'SetupPrinterErrorTitle', 'Setup Printer' );
84 Language.LL( Apply, SetupPrinterError, 'SetupPrinterError', 'Error displaying printer options: ' );
85end;
86
87Procedure TNewViewPrintDialog.PrinterComboBoxOnItemSelect (Sender: TObject;
88 Index: LongInt);
89Begin
90 Printer.PrinterIndex := PrinterComboBox.ItemIndex;
91End;
92
93Procedure TNewViewPrintDialog.SetupPrinterButtonOnClick (Sender: TObject);
94Begin
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;
104End;
105
106Procedure TNewViewPrintDialog.PrintDialogOnShow (Sender: TObject);
107Begin
108 PrinterComboBox.Items.Assign( Printer.Printers );
109 PrinterComboBox.ItemIndex := Printer.PrinterIndex;
110 OKButton.Default := true;
111End;
112
113Initialization
114 RegisterClasses ([TNewViewPrintDialog, TComboBox, TLabel, TButton, TRadioGroup]);
115End.
Note: See TracBrowser for help on using the repository browser.