Changeset 561 for trunk/src/gui/dialogs/qprintdialog_win.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/dialogs/qprintdialog_win.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 52 52 #include <private/qprintengine_win_p.h> 53 53 #include <private/qprinter_p.h> 54 55 #if defined(Q_CC_MINGW) && !defined(PD_NOCURRENTPAGE) 56 #define PD_NOCURRENTPAGE 0x00800000 57 #define PD_RESULT_PRINT 1 58 #define PD_RESULT_APPLY 2 59 #define START_PAGE_GENERAL 0XFFFFFFFF 60 #endif 54 61 55 62 QT_BEGIN_NAMESPACE … … 78 85 }; 79 86 80 #ifndef Q_OS_WINCE 81 // If you change this function, make sure you also change the unicode equivalent 82 template <class PrintDialog, class DeviceMode> 83 static PrintDialog *qt_win_make_PRINTDLG(QWidget *parent, 84 QPrintDialog *pdlg, 85 QPrintDialogPrivate *d, HGLOBAL *tempDevNames) 86 { 87 PrintDialog *pd = new PrintDialog; 88 memset(pd, 0, sizeof(PrintDialog)); 89 pd->lStructSize = sizeof(PrintDialog); 90 91 void *devMode = sizeof(DeviceMode) == sizeof(DEVMODEA) 92 ? (void *) d->ep->devModeA() 93 : (void *) d->ep->devModeW(); 87 static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent, 88 QPrintDialog *pdlg, 89 QPrintDialogPrivate *d, HGLOBAL *tempDevNames) 90 { 91 DEVMODE *devMode = d->ep->devMode; 94 92 95 93 if (devMode) { 96 int size = sizeof(D eviceMode) + ((DeviceMode *) devMode)->dmDriverExtra;94 int size = sizeof(DEVMODE) + devMode->dmDriverExtra; 97 95 pd->hDevMode = GlobalAlloc(GHND, size); 98 96 { 99 97 void *dest = GlobalLock(pd->hDevMode); 100 memcpy(dest, d ->ep->devMode, size);98 memcpy(dest, devMode, size); 101 99 GlobalUnlock(pd->hDevMode); 102 100 } … … 131 129 pd->Flags |= PD_NOPAGENUMS; 132 130 131 // we don't have a 'current page' notion in the QPrinter API yet. 132 // Neither do we support more than one page range, so limit those 133 // options 134 pd->Flags |= PD_NOCURRENTPAGE; 135 pd->nStartPage = START_PAGE_GENERAL; 136 pd->nPageRanges = 1; 137 pd->nMaxPageRanges = 1; 138 133 139 if (d->ep->printToFile) 134 140 pd->Flags |= PD_PRINTTOFILE; 135 Q_ASSERT( !parent ||parent->testAttribute(Qt::WA_WState_Created));136 pd->hwndOwner = parent ? parent->winId() : 0;137 pd-> nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());138 pd-> nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;141 Q_ASSERT(parent != 0 && parent->testAttribute(Qt::WA_WState_Created)); 142 pd->hwndOwner = parent->window()->winId(); 143 pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage()); 144 pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1; 139 145 pd->nCopies = d->ep->num_copies; 140 141 return pd; 142 } 143 #endif // Q_OS_WINCE 144 145 // If you change this function, make sure you also change the ansi equivalent 146 template <typename T> 147 static void qt_win_clean_up_PRINTDLG(T **pd) 148 { 149 delete *pd; 150 *pd = 0; 151 } 152 153 154 // If you change this function, make sure you also change the ansi equivalent 155 template <typename T> 156 static void qt_win_read_back_PRINTDLG(T *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d) 146 } 147 148 static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d) 157 149 { 158 150 if (pd->Flags & PD_SELECTION) { … … 161 153 } else if (pd->Flags & PD_PAGENUMS) { 162 154 pdlg->setPrintRange(QPrintDialog::PageRange); 163 pdlg->setFromTo(pd-> nFromPage, pd->nToPage);155 pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage); 164 156 } else { 165 157 pdlg->setPrintRange(QPrintDialog::AllPages); … … 226 218 parent = parent->window(); 227 219 else 228 parent = qApp->activeWindow(); 220 parent = QApplication::activeWindow(); 221 222 // If there is no window, fall back to the print dialog itself 223 if (parent == 0) 224 parent = q; 229 225 230 226 QWidget modal_widget; … … 235 231 HGLOBAL *tempDevNames = ep->createDevNames(); 236 232 233 bool done; 237 234 bool result; 238 bool done; 239 void *pd = QT_WA_INLINE( 240 (void*)(qt_win_make_PRINTDLG<PRINTDLGW, DEVMODEW>(parent, q, this, tempDevNames)), 241 (void*)(qt_win_make_PRINTDLG<PRINTDLGA, DEVMODEA>(parent, q, this, tempDevNames)) 242 ); 235 bool doPrinting; 236 237 PRINTPAGERANGE pageRange; 238 PRINTDLGEX pd; 239 memset(&pd, 0, sizeof(PRINTDLGEX)); 240 pd.lStructSize = sizeof(PRINTDLGEX); 241 pd.lpPageRanges = &pageRange; 242 qt_win_setup_PRINTDLGEX(&pd, parent, q, this, tempDevNames); 243 243 244 244 do { 245 245 done = true; 246 QT_WA({ 247 PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd); 248 result = PrintDlgW(pdw); 249 if ((pdw->Flags & PD_PAGENUMS) && (pdw->nFromPage > pdw->nToPage)) 246 doPrinting = false; 247 result = (PrintDlgEx(&pd) == S_OK); 248 if (result && (pd.dwResultAction == PD_RESULT_PRINT 249 || pd.dwResultAction == PD_RESULT_APPLY)) 250 { 251 doPrinting = (pd.dwResultAction == PD_RESULT_PRINT); 252 if ((pd.Flags & PD_PAGENUMS) 253 && (pd.lpPageRanges[0].nFromPage > pd.lpPageRanges[0].nToPage)) 254 { 255 pd.lpPageRanges[0].nFromPage = 1; 256 pd.lpPageRanges[0].nToPage = 1; 250 257 done = false; 251 if (result && pdw->hDC == 0) 258 } 259 if (pd.hDC == 0) 252 260 result = false; 253 else if (!result) 254 done = true; 255 }, { 256 PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd); 257 result = PrintDlgA(pda); 258 if ((pda->Flags & PD_PAGENUMS) && (pda->nFromPage > pda->nToPage)) 259 done = false; 260 if (result && pda->hDC == 0) 261 result = false; 262 else if (!result) 263 done = true; 264 }); 261 } 262 265 263 if (!done) { 266 264 QMessageBox::warning(0, QPrintDialog::tr("Print"), … … 275 273 276 274 // write values back... 277 if (result) { 278 QT_WA({ 279 PRINTDLGW *pdw = reinterpret_cast<PRINTDLGW *>(pd); 280 qt_win_read_back_PRINTDLG(pdw, q, this); 281 qt_win_clean_up_PRINTDLG(&pdw); 282 }, { 283 PRINTDLGA *pda = reinterpret_cast<PRINTDLGA *>(pd); 284 qt_win_read_back_PRINTDLG(pda, q, this); 285 qt_win_clean_up_PRINTDLG(&pda); 286 }); 275 if (result && (pd.dwResultAction == PD_RESULT_PRINT 276 || pd.dwResultAction == PD_RESULT_APPLY)) 277 { 278 qt_win_read_back_PRINTDLGEX(&pd, q, this); 287 279 // update printer validity 288 280 printer->d_func()->validPrinter = !ep->name.isEmpty(); … … 292 284 GlobalFree(tempDevNames); 293 285 294 q->done(result );295 296 return result ;286 q->done(result && doPrinting); 287 288 return result && doPrinting; 297 289 } 298 290
Note:
See TracChangeset
for help on using the changeset viewer.