1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _PAD_ADDDLG_HXX_ 25 #define _PAD_ADDDLG_HXX_ 26 27 #include "helper.hxx" 28 #include "titlectrl.hxx" 29 30 #include "vcl/dialog.hxx" 31 #include "vcl/tabpage.hxx" 32 #include "vcl/button.hxx" 33 #include "vcl/fixed.hxx" 34 #include "vcl/combobox.hxx" 35 #include "vcl/printerinfomanager.hxx" 36 37 namespace padmin 38 { 39 40 class AddPrinterDialog; 41 42 namespace DeviceKind { enum type { Printer, Fax, Pdf }; } 43 44 class APTabPage : public TabPage 45 { 46 String m_aTitle; 47 protected: 48 AddPrinterDialog* m_pParent; 49 public: 50 APTabPage( AddPrinterDialog* pParent, const ResId& rResId ); 51 52 // returns false if information is incomplete or invalid 53 virtual bool check() = 0; 54 virtual void fill( ::psp::PrinterInfo& rInfo ) = 0; getTitle() const55 const String& getTitle() const { return m_aTitle; } 56 }; 57 58 class APChooseDevicePage : public APTabPage 59 { 60 RadioButton m_aPrinterBtn; 61 RadioButton m_aFaxBtn; 62 RadioButton m_aPDFBtn; 63 RadioButton m_aOldBtn; 64 FixedText m_aOverTxt; 65 public: 66 APChooseDevicePage( AddPrinterDialog* pParent ); 67 ~APChooseDevicePage(); 68 isPrinter()69 bool isPrinter() { return m_aPrinterBtn.IsChecked(); } isFax()70 bool isFax() { return m_aFaxBtn.IsChecked(); } isPDF()71 bool isPDF() { return m_aPDFBtn.IsChecked(); } isOld()72 bool isOld() { return m_aOldBtn.IsChecked(); } 73 74 75 virtual bool check(); 76 virtual void fill( ::psp::PrinterInfo& rInfo ); 77 }; 78 79 class APChooseDriverPage : public APTabPage 80 { 81 FixedText m_aDriverTxt; 82 DelListBox m_aDriverBox; 83 PushButton m_aAddBtn; 84 PushButton m_aRemBtn; 85 86 String m_aRemStr; 87 String m_aLastPrinterName; 88 89 DECL_LINK( ClickBtnHdl, PushButton* ); 90 DECL_LINK( DelPressedHdl, ListBox* ); 91 92 void updateDrivers( bool bRefresh = false, const rtl::OUString& rSelectDriver = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SGENPRT" ) ) ); 93 public: 94 APChooseDriverPage( AddPrinterDialog* pParent ); 95 ~APChooseDriverPage(); 96 97 virtual bool check(); 98 virtual void fill( ::psp::PrinterInfo& rInfo ); 99 }; 100 101 class APNamePage : public APTabPage 102 { 103 FixedText m_aNameTxt; 104 Edit m_aNameEdt; 105 CheckBox m_aDefaultBox; 106 CheckBox m_aFaxSwallowBox; 107 public: 108 APNamePage( AddPrinterDialog* pParent, const String& rInitName, DeviceKind::type eKind ); 109 ~APNamePage(); 110 isDefault()111 bool isDefault() { return m_aDefaultBox.IsChecked(); } isFaxSwallow()112 bool isFaxSwallow() { return m_aFaxSwallowBox.IsChecked(); } 113 setText(const String & rText)114 void setText( const String& rText ) { m_aNameEdt.SetText( rText ); } 115 116 virtual bool check(); 117 virtual void fill( ::psp::PrinterInfo& rInfo ); 118 }; 119 120 class APCommandPage : public APTabPage 121 { 122 FixedText m_aCommandTxt; 123 ComboBox m_aCommandBox; 124 PushButton m_aHelpBtn; 125 String m_aHelpTxt; 126 FixedText m_aPdfDirTxt; 127 Edit m_aPdfDirEdt; 128 PushButton m_aPdfDirBtn; 129 130 DeviceKind::type m_eKind; 131 132 DECL_LINK( ClickBtnHdl, PushButton* ); 133 DECL_LINK( ModifyHdl, ComboBox* ); 134 public: 135 136 APCommandPage( AddPrinterDialog* pParent, DeviceKind::type eKind ); 137 ~APCommandPage(); 138 139 virtual bool check(); 140 virtual void fill( ::psp::PrinterInfo& rInfo ); 141 getPdfDir()142 String getPdfDir() { return m_aPdfDirEdt.GetText(); } 143 }; 144 145 class APOldPrinterPage : public APTabPage 146 { 147 FixedText m_aOldPrinterTxt; 148 MultiListBox m_aOldPrinterBox; 149 PushButton m_aSelectAllBtn; 150 151 ::std::list< ::psp::PrinterInfo > m_aOldPrinters; 152 153 DECL_LINK( ClickBtnHdl, PushButton* ); 154 public: 155 APOldPrinterPage( AddPrinterDialog* pParent ); 156 ~APOldPrinterPage(); 157 158 virtual bool check(); 159 virtual void fill( ::psp::PrinterInfo& rInfo ); 160 161 void addOldPrinters(); 162 }; 163 164 class APFaxDriverPage : public APTabPage 165 { 166 FixedText m_aFaxTxt; 167 RadioButton m_aDefBtn; 168 RadioButton m_aSelectBtn; 169 public: 170 APFaxDriverPage( AddPrinterDialog* pParent ); 171 ~APFaxDriverPage(); 172 173 virtual bool check(); 174 virtual void fill( ::psp::PrinterInfo& rInfo ); 175 isDefault()176 bool isDefault() { return m_aDefBtn.IsChecked(); } 177 }; 178 179 class APPdfDriverPage : public APTabPage 180 { 181 FixedText m_aPdfTxt; 182 RadioButton m_aDefBtn; 183 RadioButton m_aDistBtn; 184 RadioButton m_aSelectBtn; 185 public: 186 APPdfDriverPage( AddPrinterDialog* pParent ); 187 ~APPdfDriverPage(); 188 189 virtual bool check(); 190 virtual void fill( ::psp::PrinterInfo& rInfo ); 191 isDefault()192 bool isDefault() { return m_aDefBtn.IsChecked(); } isDist()193 bool isDist() { return m_aDistBtn.IsChecked(); } 194 }; 195 196 class AddPrinterDialog : public ModalDialog 197 { 198 CancelButton m_aCancelPB; 199 PushButton m_aPrevPB; 200 PushButton m_aNextPB; 201 OKButton m_aFinishPB; 202 FixedLine m_aLine; 203 TitleImage m_aTitleImage; 204 205 ::psp::PrinterInfo m_aPrinter; 206 207 APTabPage* m_pCurrentPage; 208 209 APChooseDevicePage* m_pChooseDevicePage; 210 APCommandPage* m_pCommandPage; 211 APChooseDriverPage* m_pChooseDriverPage; 212 APNamePage* m_pNamePage; 213 APOldPrinterPage* m_pOldPrinterPage; 214 APFaxDriverPage* m_pFaxDriverPage; 215 APChooseDriverPage* m_pFaxSelectDriverPage; 216 APNamePage* m_pFaxNamePage; 217 APCommandPage* m_pFaxCommandPage; 218 APPdfDriverPage* m_pPdfDriverPage; 219 APChooseDriverPage* m_pPdfSelectDriverPage; 220 APNamePage* m_pPdfNamePage; 221 APCommandPage* m_pPdfCommandPage; 222 223 DECL_LINK( ClickBtnHdl, PushButton* ); 224 225 void advance(); 226 void back(); 227 void addPrinter(); 228 229 void updateSettings(); 230 virtual void DataChanged( const DataChangedEvent& rEv ); 231 232 public: 233 AddPrinterDialog( Window* pParent ); 234 ~AddPrinterDialog(); 235 236 static String uniquePrinterName( const String& rString ); 237 static String getOldPrinterLocation(); 238 enableNext(bool bEnable)239 void enableNext( bool bEnable ) { m_aNextPB.Enable( bEnable ); } 240 }; 241 242 } // namespace 243 244 #endif 245