xref: /aoo41x/main/padmin/source/adddlg.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _PAD_ADDDLG_HXX_
29 #define _PAD_ADDDLG_HXX_
30 
31 #include "helper.hxx"
32 #include "titlectrl.hxx"
33 
34 #include "vcl/dialog.hxx"
35 #include "vcl/tabpage.hxx"
36 #include "vcl/button.hxx"
37 #include "vcl/fixed.hxx"
38 #include "vcl/combobox.hxx"
39 #include "vcl/printerinfomanager.hxx"
40 
41 namespace padmin
42 {
43 
44 class AddPrinterDialog;
45 
46 namespace DeviceKind { enum type { Printer, Fax, Pdf }; }
47 
48 class APTabPage : public TabPage
49 {
50     String				m_aTitle;
51 protected:
52     AddPrinterDialog*	m_pParent;
53 public:
54 	APTabPage( AddPrinterDialog* pParent, const ResId& rResId );
55 
56 	// returns false if information is incomplete or invalid
57 	virtual bool check() = 0;
58 	virtual void fill( ::psp::PrinterInfo& rInfo ) = 0;
59     const String& getTitle() const { return m_aTitle; }
60 };
61 
62 class APChooseDevicePage : public APTabPage
63 {
64 	RadioButton				m_aPrinterBtn;
65 	RadioButton				m_aFaxBtn;
66 	RadioButton				m_aPDFBtn;
67 	RadioButton				m_aOldBtn;
68 	FixedText				m_aOverTxt;
69 public:
70 	APChooseDevicePage( AddPrinterDialog* pParent );
71 	~APChooseDevicePage();
72 
73 	bool isPrinter() { return m_aPrinterBtn.IsChecked(); }
74 	bool isFax() { return m_aFaxBtn.IsChecked(); }
75 	bool isPDF() { return m_aPDFBtn.IsChecked(); }
76 	bool isOld() { return m_aOldBtn.IsChecked(); }
77 
78 
79 	virtual bool check();
80 	virtual void fill( ::psp::PrinterInfo& rInfo );
81 };
82 
83 class APChooseDriverPage : public APTabPage
84 {
85 	FixedText				m_aDriverTxt;
86 	DelListBox				m_aDriverBox;
87 	PushButton				m_aAddBtn;
88 	PushButton				m_aRemBtn;
89 
90 	String					m_aRemStr;
91     String					m_aLastPrinterName;
92 
93 	DECL_LINK( ClickBtnHdl, PushButton* );
94 	DECL_LINK( DelPressedHdl, ListBox* );
95 
96 	void updateDrivers( bool bRefresh = false, const rtl::OUString& rSelectDriver = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SGENPRT" ) ) );
97 public:
98 	APChooseDriverPage( AddPrinterDialog* pParent );
99 	~APChooseDriverPage();
100 
101 	virtual bool check();
102 	virtual void fill( ::psp::PrinterInfo& rInfo );
103 };
104 
105 class APNamePage : public APTabPage
106 {
107 	FixedText				m_aNameTxt;
108 	Edit					m_aNameEdt;
109 	CheckBox				m_aDefaultBox;
110 	CheckBox				m_aFaxSwallowBox;
111 public:
112 	APNamePage( AddPrinterDialog* pParent, const String& rInitName, DeviceKind::type eKind );
113 	~APNamePage();
114 
115 	bool isDefault() { return m_aDefaultBox.IsChecked(); }
116 	bool isFaxSwallow() { return m_aFaxSwallowBox.IsChecked(); }
117 
118     void setText( const String& rText ) { m_aNameEdt.SetText( rText ); }
119 
120 	virtual bool check();
121 	virtual void fill( ::psp::PrinterInfo& rInfo );
122 };
123 
124 class APCommandPage : public APTabPage
125 {
126 	FixedText				m_aCommandTxt;
127 	ComboBox				m_aCommandBox;
128 	PushButton				m_aHelpBtn;
129 	String					m_aHelpTxt;
130 	FixedText				m_aPdfDirTxt;
131 	Edit					m_aPdfDirEdt;
132 	PushButton				m_aPdfDirBtn;
133 
134 	DeviceKind::type		m_eKind;
135 
136 	DECL_LINK( ClickBtnHdl, PushButton* );
137     DECL_LINK( ModifyHdl, ComboBox* );
138 public:
139 
140 	APCommandPage( AddPrinterDialog* pParent, DeviceKind::type eKind );
141 	~APCommandPage();
142 
143 	virtual bool check();
144 	virtual void fill( ::psp::PrinterInfo& rInfo );
145 
146 	String getPdfDir() { return m_aPdfDirEdt.GetText(); }
147 };
148 
149 class APOldPrinterPage : public APTabPage
150 {
151 	FixedText							m_aOldPrinterTxt;
152 	MultiListBox						m_aOldPrinterBox;
153 	PushButton							m_aSelectAllBtn;
154 
155 	::std::list< ::psp::PrinterInfo >	m_aOldPrinters;
156 
157 	DECL_LINK( ClickBtnHdl, PushButton* );
158 public:
159 	APOldPrinterPage( AddPrinterDialog* pParent );
160 	~APOldPrinterPage();
161 
162 	virtual bool check();
163 	virtual void fill( ::psp::PrinterInfo& rInfo );
164 
165 	void addOldPrinters();
166 };
167 
168 class APFaxDriverPage : public APTabPage
169 {
170 	FixedText				m_aFaxTxt;
171 	RadioButton				m_aDefBtn;
172 	RadioButton				m_aSelectBtn;
173 public:
174 	APFaxDriverPage( AddPrinterDialog* pParent );
175 	~APFaxDriverPage();
176 
177 	virtual bool check();
178 	virtual void fill( ::psp::PrinterInfo& rInfo );
179 
180 	bool isDefault() { return m_aDefBtn.IsChecked(); }
181 };
182 
183 class APPdfDriverPage : public APTabPage
184 {
185 	FixedText				m_aPdfTxt;
186 	RadioButton				m_aDefBtn;
187 	RadioButton				m_aDistBtn;
188 	RadioButton				m_aSelectBtn;
189 public:
190 	APPdfDriverPage( AddPrinterDialog* pParent );
191 	~APPdfDriverPage();
192 
193 	virtual bool check();
194 	virtual void fill( ::psp::PrinterInfo& rInfo );
195 
196 	bool isDefault() { return m_aDefBtn.IsChecked(); }
197 	bool isDist() { return m_aDistBtn.IsChecked(); }
198 };
199 
200 class AddPrinterDialog : public ModalDialog
201 {
202 	CancelButton			m_aCancelPB;
203 	PushButton				m_aPrevPB;
204 	PushButton				m_aNextPB;
205 	OKButton				m_aFinishPB;
206 	FixedLine				m_aLine;
207     TitleImage				m_aTitleImage;
208 
209 	::psp::PrinterInfo		m_aPrinter;
210 
211 	APTabPage*				m_pCurrentPage;
212 
213 	APChooseDevicePage*		m_pChooseDevicePage;
214 	APCommandPage*			m_pCommandPage;
215 	APChooseDriverPage*		m_pChooseDriverPage;
216 	APNamePage*				m_pNamePage;
217 	APOldPrinterPage*		m_pOldPrinterPage;
218 	APFaxDriverPage*		m_pFaxDriverPage;
219 	APChooseDriverPage*		m_pFaxSelectDriverPage;
220 	APNamePage*				m_pFaxNamePage;
221 	APCommandPage*			m_pFaxCommandPage;
222 	APPdfDriverPage*		m_pPdfDriverPage;
223 	APChooseDriverPage*		m_pPdfSelectDriverPage;
224 	APNamePage*				m_pPdfNamePage;
225 	APCommandPage*			m_pPdfCommandPage;
226 
227 	DECL_LINK( ClickBtnHdl, PushButton* );
228 
229 	void advance();
230 	void back();
231 	void addPrinter();
232 
233     void updateSettings();
234     virtual void DataChanged( const DataChangedEvent& rEv );
235 
236 public:
237 	AddPrinterDialog( Window* pParent );
238 	~AddPrinterDialog();
239 
240 	static String uniquePrinterName( const String& rString );
241     static String getOldPrinterLocation();
242 
243     void enableNext( bool bEnable ) { m_aNextPB.Enable( bEnable ); }
244 };
245 
246 } // namespace
247 
248 #endif
249