]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/dcprint.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxPrinterDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
14 #pragma implementation "dcprint.h"
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
27 #include "wx/dcprint.h"
33 #if USE_COMMON_DIALOGS
53 #if !USE_SHARED_LIBRARY
54 IMPLEMENT_CLASS(wxPrinterDC
, wxDC
)
57 wxPrinterDC::wxPrinterDC(const wxString
& driver_name
, const wxString
& device_name
, const wxString
& file
, const bool interactive
, const int orientation
)
59 m_isInteractive
= interactive
;
61 if (!file
.IsNull() && file
!= "")
64 #if USE_COMMON_DIALOGS
69 pd
.lStructSize
= sizeof( PRINTDLG
);
71 pd
.hDevMode
=(HANDLE
)NULL
;
72 pd
.hDevNames
=(HANDLE
)NULL
;
73 pd
.Flags
=PD_RETURNDC
| PD_NOSELECTION
| PD_NOPAGENUMS
;
79 pd
.hInstance
=(HINSTANCE
)NULL
;
81 if ( PrintDlg( &pd
) != 0 )
83 m_hDC
= (WXHDC
) pd
.hDC
;
92 // m_dontDelete = TRUE;
96 if ((!driver_name
.IsNull() && driver_name
!= "") &&
97 (!device_name
.IsNull() && device_name
!= "") &&
98 (!file
.IsNull() && file
!= ""))
100 m_hDC
= (WXHDC
) CreateDC((char *) (const char *) driver_name
, (char *) (const char *) device_name
, (char *) (const char *) file
, NULL
);
101 m_ok
= m_hDC
? TRUE
: FALSE
;
105 m_hDC
= wxGetPrinterDC(orientation
);
106 m_ok
= m_hDC
? TRUE
: FALSE
;
111 // int width = GetDeviceCaps(m_hDC, VERTRES);
112 // int height = GetDeviceCaps(m_hDC, HORZRES);
115 SetBrush(*wxBLACK_BRUSH
);
116 SetPen(*wxBLACK_PEN
);
119 wxPrinterDC::wxPrinterDC(WXHDC theDC
)
121 m_isInteractive
= FALSE
;
127 // int width = GetDeviceCaps(m_hDC, VERTRES);
128 // int height = GetDeviceCaps(m_hDC, HORZRES);
131 SetBrush(*wxBLACK_BRUSH
);
132 SetPen(*wxBLACK_PEN
);
135 wxPrinterDC::~wxPrinterDC(void)
139 WXHDC
wxGetPrinterDC(int orientation
)
142 LPDEVMODE lpDevMode
= NULL
;
143 LPDEVNAMES lpDevNames
;
144 LPSTR lpszDriverName
;
145 LPSTR lpszDeviceName
;
149 // __GNUWIN32__ has trouble believing PRINTDLG is 66 bytes - thinks it is 68
150 pd
.lStructSize
= 66; // sizeof(PRINTDLG);
151 pd
.hwndOwner
= (HWND
)NULL
;
152 pd
.hDevMode
= NULL
; // Will be created by PrintDlg
153 pd
.hDevNames
= NULL
; // Ditto
154 pd
.Flags
= PD_RETURNDEFAULT
;
157 if (!PrintDlg((LPPRINTDLG
)&pd
))
160 GlobalFree(pd
.hDevMode
);
162 GlobalFree(pd
.hDevNames
);
170 GlobalFree(pd
.hDevMode
);
173 lpDevNames
= (LPDEVNAMES
)GlobalLock(pd
.hDevNames
);
174 lpszDriverName
= (LPSTR
)lpDevNames
+ lpDevNames
->wDriverOffset
;
175 lpszDeviceName
= (LPSTR
)lpDevNames
+ lpDevNames
->wDeviceOffset
;
176 lpszPortName
= (LPSTR
)lpDevNames
+ lpDevNames
->wOutputOffset
;
177 GlobalUnlock(pd
.hDevNames
);
181 lpDevMode
= (DEVMODE
*) GlobalLock(pd
.hDevMode
);
182 lpDevMode
->dmOrientation
= orientation
;
183 lpDevMode
->dmFields
|= DM_ORIENTATION
;
187 hDC
= CreateDC(lpszDriverName
, lpszDeviceName
, lpszPortName
, (DEVMODE
*)lpDevMode
);
189 hDC
= CreateDC(lpszDriverName
, lpszDeviceName
, lpszPortName
, (LPSTR
)lpDevMode
);
192 if (pd
.hDevMode
&& lpDevMode
)
193 GlobalUnlock(pd
.hDevMode
);
197 GlobalFree(pd
.hDevNames
);
202 GlobalFree(pd
.hDevMode
);