Qt 4.8
Classes | Macros | Functions
qprintdialog_win.cpp File Reference
#include "qprintdialog.h"
#include <qwidget.h>
#include <qapplication.h>
#include <qmessagebox.h>
#include <private/qapplication_p.h>
#include <private/qabstractprintdialog_p.h>
#include <private/qprintengine_win_p.h>
#include <private/qprinter_p.h>
#include "moc_qprintdialog.cpp"

Go to the source code of this file.

Classes

class  QPrintDialogPrivate
 

Macros

#define PD_NOCURRENTPAGE   0x00800000
 
#define PD_RESULT_APPLY   2
 
#define PD_RESULT_PRINT   1
 
#define START_PAGE_GENERAL   0XFFFFFFFF
 

Functions

void qt_win_eatMouseMove ()
 
static void qt_win_read_back_PRINTDLGEX (PRINTDLGEX *pd, QPrintDialog *pdlg, QPrintDialogPrivate *d)
 
static void qt_win_setup_PRINTDLGEX (PRINTDLGEX *pd, QWidget *parent, QPrintDialog *pdlg, QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
 
static bool warnIfNotNative (QPrinter *printer)
 

Macro Definition Documentation

◆ PD_NOCURRENTPAGE

#define PD_NOCURRENTPAGE   0x00800000

Definition at line 56 of file qprintdialog_win.cpp.

Referenced by qt_win_setup_PRINTDLGEX().

◆ PD_RESULT_APPLY

#define PD_RESULT_APPLY   2

◆ PD_RESULT_PRINT

#define PD_RESULT_PRINT   1

◆ START_PAGE_GENERAL

#define START_PAGE_GENERAL   0XFFFFFFFF

Definition at line 59 of file qprintdialog_win.cpp.

Referenced by qt_win_setup_PRINTDLGEX().

Function Documentation

◆ qt_win_eatMouseMove()

void qt_win_eatMouseMove ( )

Definition at line 3016 of file qapplication_win.cpp.

Referenced by QPrintDialogPrivate::openWindowsPrintDialogModally().

3017 {
3018  // after closing a windows dialog with a double click (i.e. open a file)
3019  // the message queue still contains a dubious WM_MOUSEMOVE message where
3020  // the left button is reported to be down (wParam != 0).
3021  // remove all those messages (usually 1) and post the last one with a
3022  // reset button state
3023 
3024  MSG msg = {0, 0, 0, 0, 0, {0, 0} };
3025  while (PeekMessage(&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE))
3026  ;
3027  if (msg.message == WM_MOUSEMOVE)
3028  PostMessage(msg.hwnd, msg.message, 0, msg.lParam);
3029 }
struct tagMSG MSG

◆ qt_win_read_back_PRINTDLGEX()

static void qt_win_read_back_PRINTDLGEX ( PRINTDLGEX *  pd,
QPrintDialog pdlg,
QPrintDialogPrivate d 
)
static

Definition at line 153 of file qprintdialog_win.cpp.

Referenced by QPrintDialogPrivate::openWindowsPrintDialogModally().

154 {
155  if (pd->Flags & PD_SELECTION) {
157  pdlg->setFromTo(0, 0);
158  } else if (pd->Flags & PD_PAGENUMS) {
160  pdlg->setFromTo(pd->lpPageRanges[0].nFromPage, pd->lpPageRanges[0].nToPage);
161  } else if (pd->Flags & PD_CURRENTPAGE) {
163  pdlg->setFromTo(0, 0);
164  } else { // PD_ALLPAGES
166  pdlg->setFromTo(0, 0);
167  }
168 
169  d->ep->printToFile = (pd->Flags & PD_PRINTTOFILE) != 0;
170 
171  d->ep->readDevnames(pd->hDevNames);
172  d->ep->readDevmode(pd->hDevMode);
173  d->ep->updateCustomPaperSize();
174 
175  if (d->ep->printToFile && d->ep->fileName.isEmpty())
176  d->ep->fileName = d->ep->port;
177  else if (!d->ep->printToFile && d->ep->fileName == QLatin1String("FILE:"))
178  d->ep->fileName.clear();
179 }
QMacPrintEnginePrivate * ep
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
void setFromTo(int fromPage, int toPage)
Sets the range in the print dialog to be from from to to.
if(void) toggleToolbarShown
void setPrintRange(PrintRange range)
Sets the print range option in to be range.

◆ qt_win_setup_PRINTDLGEX()

static void qt_win_setup_PRINTDLGEX ( PRINTDLGEX *  pd,
QWidget parent,
QPrintDialog pdlg,
QPrintDialogPrivate d,
HGLOBAL *  tempDevNames 
)
static

Definition at line 87 of file qprintdialog_win.cpp.

Referenced by QPrintDialogPrivate::openWindowsPrintDialogModally().

90 {
91  DEVMODE *devMode = d->ep->devMode;
92 
93  if (devMode) {
94  int size = sizeof(DEVMODE) + devMode->dmDriverExtra;
95  pd->hDevMode = GlobalAlloc(GHND, size);
96  {
97  void *dest = GlobalLock(pd->hDevMode);
98  memcpy(dest, devMode, size);
99  GlobalUnlock(pd->hDevMode);
100  }
101  } else {
102  pd->hDevMode = NULL;
103  }
104  pd->hDevNames = tempDevNames;
105 
106  pd->Flags = PD_RETURNDC;
107  pd->Flags |= PD_USEDEVMODECOPIESANDCOLLATE;
108 
110  pd->Flags |= PD_NOSELECTION;
112  pd->nMinPage = pdlg->minPage();
113  pd->nMaxPage = pdlg->maxPage();
114  }
115 
117  pd->Flags |= PD_DISABLEPRINTTOFILE;
118 
120  pd->Flags |= PD_SELECTION;
122  pd->Flags |= PD_PAGENUMS;
124  pd->Flags |= PD_CURRENTPAGE;
125  else
126  pd->Flags |= PD_ALLPAGES;
127 
128  // As stated by MSDN, to enable collate option when minpage==maxpage==0
129  // set the PD_NOPAGENUMS flag
130  if (pd->nMinPage==0 && pd->nMaxPage==0)
131  pd->Flags |= PD_NOPAGENUMS;
132 
133  // Disable Current Page option if not required as default is Enabled
135  pd->Flags |= PD_NOCURRENTPAGE;
136 
137  // Default to showing the General tab first
138  pd->nStartPage = START_PAGE_GENERAL;
139 
140  // We don't support more than one page range in the QPrinter API yet.
141  pd->nPageRanges = 1;
142  pd->nMaxPageRanges = 1;
143 
144  if (d->ep->printToFile)
145  pd->Flags |= PD_PRINTTOFILE;
146  Q_ASSERT(parent);
147  pd->hwndOwner = parent->window()->winId();
148  pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
149  pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
150  pd->nCopies = d->ep->num_copies;
151 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
QMacPrintEnginePrivate * ep
bool isOptionEnabled(PrintDialogOption option) const
Use QPrintDialog::testOption(option) instead.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int minPage() const
Returns the minimum page in the page range.
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
#define PD_NOPAGENUMS
#define PD_NOSELECTION
PrintRange printRange() const
Returns the print range.
int fromPage() const
Returns the first page to be printed By default, this value is set to 0.
int toPage() const
Returns the last page to be printed.
#define PD_ALLPAGES
#define START_PAGE_GENERAL
int maxPage() const
Returns the maximum page in the page range.
if(void) toggleToolbarShown
QWidget * window() const
Returns the window for this widget, i.e.
Definition: qwidget.cpp:4492
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
#define PD_NOCURRENTPAGE

◆ warnIfNotNative()

static bool warnIfNotNative ( QPrinter printer)
static

Definition at line 181 of file qprintdialog_win.cpp.

Referenced by QPrintDialogPrivate::openWindowsPrintDialogModally().

182 {
183  if (printer->outputFormat() != QPrinter::NativeFormat) {
184  qWarning("QPrintDialog: Cannot be used on non-native printers");
185  return false;
186  }
187  return true;
188 }
OutputFormat outputFormat() const
Returns the output format for this printer.
Definition: qprinter.cpp:813
Q_CORE_EXPORT void qWarning(const char *,...)