1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: adddlg.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _PAD_ADDDLG_HXX_
32 #define _PAD_ADDDLG_HXX_
35 #include "titlectrl.hxx"
37 #include "vcl/dialog.hxx"
38 #include "vcl/tabpage.hxx"
39 #include "vcl/button.hxx"
40 #include "vcl/fixed.hxx"
41 #include "vcl/combobox.hxx"
42 #include "vcl/printerinfomanager.hxx"
47 class AddPrinterDialog
;
49 namespace DeviceKind
{ enum type
{ Printer
, Fax
, Pdf
}; }
51 class APTabPage
: public TabPage
55 AddPrinterDialog
* m_pParent
;
57 APTabPage( AddPrinterDialog
* pParent
, const ResId
& rResId
);
59 // returns false if information is incomplete or invalid
60 virtual bool check() = 0;
61 virtual void fill( ::psp::PrinterInfo
& rInfo
) = 0;
62 const String
& getTitle() const { return m_aTitle
; }
65 class APChooseDevicePage
: public APTabPage
67 RadioButton m_aPrinterBtn
;
68 RadioButton m_aFaxBtn
;
69 RadioButton m_aPDFBtn
;
70 RadioButton m_aOldBtn
;
73 APChooseDevicePage( AddPrinterDialog
* pParent
);
74 ~APChooseDevicePage();
76 bool isPrinter() { return m_aPrinterBtn
.IsChecked(); }
77 bool isFax() { return m_aFaxBtn
.IsChecked(); }
78 bool isPDF() { return m_aPDFBtn
.IsChecked(); }
79 bool isOld() { return m_aOldBtn
.IsChecked(); }
83 virtual void fill( ::psp::PrinterInfo
& rInfo
);
86 class APChooseDriverPage
: public APTabPage
88 FixedText m_aDriverTxt
;
89 DelListBox m_aDriverBox
;
94 String m_aLastPrinterName
;
96 DECL_LINK( ClickBtnHdl
, PushButton
* );
97 DECL_LINK( DelPressedHdl
, ListBox
* );
101 APChooseDriverPage( AddPrinterDialog
* pParent
);
102 ~APChooseDriverPage();
104 virtual bool check();
105 virtual void fill( ::psp::PrinterInfo
& rInfo
);
108 class APNamePage
: public APTabPage
110 FixedText m_aNameTxt
;
112 CheckBox m_aDefaultBox
;
113 CheckBox m_aFaxSwallowBox
;
115 APNamePage( AddPrinterDialog
* pParent
, const String
& rInitName
, DeviceKind::type eKind
);
118 bool isDefault() { return m_aDefaultBox
.IsChecked(); }
119 bool isFaxSwallow() { return m_aFaxSwallowBox
.IsChecked(); }
121 void setText( const String
& rText
) { m_aNameEdt
.SetText( rText
); }
123 virtual bool check();
124 virtual void fill( ::psp::PrinterInfo
& rInfo
);
127 class APCommandPage
: public APTabPage
129 FixedText m_aCommandTxt
;
130 ComboBox m_aCommandBox
;
131 PushButton m_aHelpBtn
;
133 FixedText m_aPdfDirTxt
;
135 PushButton m_aPdfDirBtn
;
137 DeviceKind::type m_eKind
;
139 DECL_LINK( ClickBtnHdl
, PushButton
* );
140 DECL_LINK( ModifyHdl
, ComboBox
* );
143 APCommandPage( AddPrinterDialog
* pParent
, DeviceKind::type eKind
);
146 virtual bool check();
147 virtual void fill( ::psp::PrinterInfo
& rInfo
);
149 String
getPdfDir() { return m_aPdfDirEdt
.GetText(); }
152 class APOldPrinterPage
: public APTabPage
154 FixedText m_aOldPrinterTxt
;
155 MultiListBox m_aOldPrinterBox
;
156 PushButton m_aSelectAllBtn
;
158 ::std::list
< ::psp::PrinterInfo
> m_aOldPrinters
;
160 DECL_LINK( ClickBtnHdl
, PushButton
* );
162 APOldPrinterPage( AddPrinterDialog
* pParent
);
165 virtual bool check();
166 virtual void fill( ::psp::PrinterInfo
& rInfo
);
168 void addOldPrinters();
171 class APFaxDriverPage
: public APTabPage
174 RadioButton m_aDefBtn
;
175 RadioButton m_aSelectBtn
;
177 APFaxDriverPage( AddPrinterDialog
* pParent
);
180 virtual bool check();
181 virtual void fill( ::psp::PrinterInfo
& rInfo
);
183 bool isDefault() { return m_aDefBtn
.IsChecked(); }
186 class APPdfDriverPage
: public APTabPage
189 RadioButton m_aDefBtn
;
190 RadioButton m_aDistBtn
;
191 RadioButton m_aSelectBtn
;
193 APPdfDriverPage( AddPrinterDialog
* pParent
);
196 virtual bool check();
197 virtual void fill( ::psp::PrinterInfo
& rInfo
);
199 bool isDefault() { return m_aDefBtn
.IsChecked(); }
200 bool isDist() { return m_aDistBtn
.IsChecked(); }
203 class AddPrinterDialog
: public ModalDialog
205 CancelButton m_aCancelPB
;
206 PushButton m_aPrevPB
;
207 PushButton m_aNextPB
;
208 OKButton m_aFinishPB
;
210 TitleImage m_aTitleImage
;
212 ::psp::PrinterInfo m_aPrinter
;
214 APTabPage
* m_pCurrentPage
;
216 APChooseDevicePage
* m_pChooseDevicePage
;
217 APCommandPage
* m_pCommandPage
;
218 APChooseDriverPage
* m_pChooseDriverPage
;
219 APNamePage
* m_pNamePage
;
220 APOldPrinterPage
* m_pOldPrinterPage
;
221 APFaxDriverPage
* m_pFaxDriverPage
;
222 APChooseDriverPage
* m_pFaxSelectDriverPage
;
223 APNamePage
* m_pFaxNamePage
;
224 APCommandPage
* m_pFaxCommandPage
;
225 APPdfDriverPage
* m_pPdfDriverPage
;
226 APChooseDriverPage
* m_pPdfSelectDriverPage
;
227 APNamePage
* m_pPdfNamePage
;
228 APCommandPage
* m_pPdfCommandPage
;
230 DECL_LINK( ClickBtnHdl
, PushButton
* );
236 void updateSettings();
237 virtual void DataChanged( const DataChangedEvent
& rEv
);
240 AddPrinterDialog( Window
* pParent
);
243 static String
uniquePrinterName( const String
& rString
);
244 static String
getOldPrinterLocation();
246 void enableNext( bool bEnable
) { m_aNextPB
.Enable( bEnable
); }