summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs
diff options
context:
space:
mode:
authorTrond Kjernaasen <trond@trolltech.com>2009-07-03 11:29:43 (GMT)
committerTrond Kjernaasen <trond@trolltech.com>2009-07-03 11:59:22 (GMT)
commit460e204c5b96cb67244bd9463ca0dfa56ad02564 (patch)
treefcc497139a3801395d6e03fd823720a8a35af159 /src/gui/dialogs
parent9b4234d567804e8f503951e8d0c96e95f5dbec48 (diff)
downloadQt-460e204c5b96cb67244bd9463ca0dfa56ad02564.zip
Qt-460e204c5b96cb67244bd9463ca0dfa56ad02564.tar.gz
Qt-460e204c5b96cb67244bd9463ca0dfa56ad02564.tar.bz2
Replace usage of the old, obsolete PrintDlg with PrintDlgEx.
Since we don't support Windows versions < Win 2000, we can just go ahead and replace usage of the old compat dialog. Task-number: 222417 Reviewed-by: Prasanth
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r--src/gui/dialogs/qprintdialog_win.cpp79
1 files changed, 46 insertions, 33 deletions
diff --git a/src/gui/dialogs/qprintdialog_win.cpp b/src/gui/dialogs/qprintdialog_win.cpp
index 6022a66..115cd8d 100644
--- a/src/gui/dialogs/qprintdialog_win.cpp
+++ b/src/gui/dialogs/qprintdialog_win.cpp
@@ -77,14 +77,10 @@ public:
QWin32PrintEnginePrivate *ep;
};
-static PRINTDLG* qt_win_make_PRINTDLG(QWidget *parent,
- QPrintDialog *pdlg,
- QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
+static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
+ QPrintDialog *pdlg,
+ QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
{
- PRINTDLG *pd = new PRINTDLG;
- memset(pd, 0, sizeof(PRINTDLG));
- pd->lStructSize = sizeof(PRINTDLG);
-
DEVMODE *devMode = d->ep->devMode;
if (devMode) {
@@ -125,31 +121,31 @@ static PRINTDLG* qt_win_make_PRINTDLG(QWidget *parent,
if (pd->nMinPage==0 && pd->nMaxPage==0)
pd->Flags |= PD_NOPAGENUMS;
+ // we don't have a 'current page' notion in the QPrinter API yet.
+ // Neither do we support more than one page range, so limit those
+ // options
+ pd->Flags |= PD_NOCURRENTPAGE;
+ pd->nStartPage = START_PAGE_GENERAL;
+ pd->nPageRanges = 1;
+ pd->nMaxPageRanges = 1;
+
if (d->ep->printToFile)
pd->Flags |= PD_PRINTTOFILE;
Q_ASSERT(!parent ||parent->testAttribute(Qt::WA_WState_Created));
pd->hwndOwner = parent ? parent->winId() : 0;
- pd->nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
- pd->nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
+ pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
+ pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
pd->nCopies = d->ep->num_copies;
-
- return pd;
-}
-
-static void qt_win_clean_up_PRINTDLG(PRINTDLG **pd)
-{
- delete *pd;
- *pd = 0;
}
-static void qt_win_read_back_PRINTDLG(PRINTDLG *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d)
+static void qt_win_read_back_PRINTDLGEX(PRINTDLGEX *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d)
{
if (pd->Flags & PD_SELECTION) {
pdlg->setPrintRange(QPrintDialog::Selection);
pdlg->setFromTo(0, 0);
} else if (pd->Flags & PD_PAGENUMS) {
pdlg->setPrintRange(QPrintDialog::PageRange);
- pdlg->setFromTo(pd->nFromPage, pd->nToPage);
+ pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage);
} else {
pdlg->setPrintRange(QPrintDialog::AllPages);
pdlg->setFromTo(0, 0);
@@ -223,19 +219,35 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
HGLOBAL *tempDevNames = ep->createDevNames();
- bool result;
bool done;
- PRINTDLG *pd = qt_win_make_PRINTDLG(parent, q, this, tempDevNames);
+ bool result;
+ bool doPrinting;
+
+ PRINTPAGERANGE pageRange;
+ PRINTDLGEX pd;
+ memset(&pd, 0, sizeof(PRINTDLGEX));
+ pd.lStructSize = sizeof(PRINTDLGEX);
+ pd.lpPageRanges = &pageRange;
+ qt_win_setup_PRINTDLGEX(&pd, parent, q, this, tempDevNames);
do {
done = true;
- result = PrintDlg(pd);
- if ((pd->Flags & PD_PAGENUMS) && (pd->nFromPage > pd->nToPage))
- done = false;
- if (result && pd->hDC == 0)
- result = false;
- else if (!result)
- done = true;
+ doPrinting = false;
+ result = (PrintDlgEx(&pd) == S_OK);
+ if (result && (pd.dwResultAction == PD_RESULT_PRINT
+ || pd.dwResultAction == PD_RESULT_APPLY))
+ {
+ doPrinting = (pd.dwResultAction == PD_RESULT_PRINT);
+ if ((pd.Flags & PD_PAGENUMS)
+ && (pd.lpPageRanges[0].nFromPage > pd.lpPageRanges[0].nToPage))
+ {
+ pd.lpPageRanges[0].nFromPage = 1;
+ pd.lpPageRanges[0].nToPage = 1;
+ done = false;
+ }
+ if (pd.hDC == 0)
+ result = false;
+ }
if (!done) {
QMessageBox::warning(0, QPrintDialog::tr("Print"),
@@ -249,9 +261,10 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
qt_win_eatMouseMove();
// write values back...
- if (result) {
- qt_win_read_back_PRINTDLG(pd, q, this);
- qt_win_clean_up_PRINTDLG(&pd);
+ if (result && (pd.dwResultAction == PD_RESULT_PRINT
+ || pd.dwResultAction == PD_RESULT_APPLY))
+ {
+ qt_win_read_back_PRINTDLGEX(&pd, q, this);
// update printer validity
printer->d_func()->validPrinter = !ep->name.isEmpty();
}
@@ -259,9 +272,9 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
// Cleanup...
GlobalFree(tempDevNames);
- q->done(result);
+ q->done(result && doPrinting);
- return result;
+ return result && doPrinting;
}
void QPrintDialog::setVisible(bool visible)