Moved the wxPageSetupDialogData <-> native conversion

code for MSW to the appropriate file in src/msw/printdlg.cpp
  Removed the now obsolete printer setup dialog code.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30210 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2004-10-31 23:43:41 +00:00
parent 072a99f431
commit b45dfd0a8b
10 changed files with 206 additions and 305 deletions

View File

@ -275,8 +275,9 @@ public:
bool GetSelection() const { return m_printSelection; };
bool GetCollate() const { return m_printCollate; };
bool GetPrintToFile() const { return m_printToFile; };
#if WXWIN_COMPATIBILITY_2_4
bool GetSetupDialog() const { return m_printSetupDialog; };
#endif
void SetFromPage(int v) { m_printFromPage = v; };
void SetToPage(int v) { m_printToPage = v; };
void SetMinPage(int v) { m_printMinPage = v; };
@ -286,8 +287,9 @@ public:
void SetSelection(bool flag) { m_printSelection = flag; };
void SetCollate(bool flag) { m_printCollate = flag; };
void SetPrintToFile(bool flag) { m_printToFile = flag; };
#if WXWIN_COMPATIBILITY_2_4
void SetSetupDialog(bool flag) { m_printSetupDialog = flag; };
#endif
void EnablePrintToFile(bool flag) { m_printEnablePrintToFile = flag; };
void EnableSelection(bool flag) { m_printEnableSelection = flag; };
void EnablePageNumbers(bool flag) { m_printEnablePageNumbers = flag; };
@ -326,7 +328,9 @@ private:
bool m_printEnablePageNumbers;
bool m_printEnableHelp;
bool m_printEnablePrintToFile;
#if WXWIN_COMPATIBILITY_2_4
bool m_printSetupDialog;
#endif
wxPrintData m_printData;
private:
@ -388,13 +392,7 @@ public:
void EnablePrinter(bool flag) { m_enablePrinter = flag; };
void EnableHelp(bool flag) { m_enableHelp = flag; };
#if defined(__WIN95__)
// Convert to/from the PAGESETUPDLG structure
void ConvertToNative();
void ConvertFromNative();
void SetOwnerWindow(wxWindow* win);
void* GetNativeData() const { return m_pageSetupData; }
#elif defined(__WXMAC__)
#if defined(__WXMAC__)
void ConvertToNative();
void ConvertFromNative();
#endif
@ -412,10 +410,6 @@ public:
wxPrintData& GetPrintData() { return m_printData; }
void SetPrintData(const wxPrintData& printData) { m_printData = printData; }
#if defined(__WIN95__)
void* m_pageSetupData;
#endif
private:
wxSize m_paperSize; // The dimensions selected by the user (on return, same as in wxPrintData?)
wxPoint m_minMarginTopLeft;

View File

@ -331,7 +331,6 @@ public:
void OnFileSave(wxCommandEvent& event);
void OnFileSaveAs(wxCommandEvent& event);
void OnPrint(wxCommandEvent& event);
void OnPrintSetup(wxCommandEvent& event);
void OnPreview(wxCommandEvent& event);
void OnUndo(wxCommandEvent& event);
void OnRedo(wxCommandEvent& event);
@ -347,7 +346,6 @@ public:
void OnUpdateRedo(wxUpdateUIEvent& event);
void OnUpdatePrint(wxUpdateUIEvent& event);
void OnUpdatePrintSetup(wxUpdateUIEvent& event);
void OnUpdatePreview(wxUpdateUIEvent& event);
// Extend event processing to search the view's event table

View File

@ -232,7 +232,6 @@ public:
bool PrintText(const wxString &htmltext, const wxString& basepath = wxEmptyString);
// Print file / html-text w/o preview
void PrinterSetup();
void PageSetup();
// pop up printer or page setup dialog

View File

@ -90,7 +90,6 @@ bool MyApp::OnInit(void)
wxMenu *file_menu = new wxMenu;
file_menu->Append(WXPRINT_PRINT, _T("&Print..."), _T("Print"));
file_menu->Append(WXPRINT_PRINT_SETUP, _T("Print &Setup..."), _T("Setup printer properties"));
file_menu->Append(WXPRINT_PAGE_SETUP, _T("Page Set&up..."), _T("Page setup"));
file_menu->Append(WXPRINT_PREVIEW, _T("Print Pre&view"), _T("Preview"));
@ -105,7 +104,6 @@ bool MyApp::OnInit(void)
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
file_menu->AppendSeparator();
file_menu->Append(WXPRINT_PRINT_PS, _T("Print PostScript..."), _T("Print (PostScript)"));
file_menu->Append(WXPRINT_PRINT_SETUP_PS, _T("Print Setup PostScript..."), _T("Setup printer properties (PostScript)"));
file_menu->Append(WXPRINT_PAGE_SETUP_PS, _T("Page Setup PostScript..."), _T("Page setup (PostScript)"));
file_menu->Append(WXPRINT_PREVIEW_PS, _T("Print Preview PostScript"), _T("Preview (PostScript)"));
#endif
@ -153,13 +151,11 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(WXPRINT_QUIT, MyFrame::OnExit)
EVT_MENU(WXPRINT_PRINT, MyFrame::OnPrint)
EVT_MENU(WXPRINT_PREVIEW, MyFrame::OnPrintPreview)
EVT_MENU(WXPRINT_PRINT_SETUP, MyFrame::OnPrintSetup)
EVT_MENU(WXPRINT_PAGE_SETUP, MyFrame::OnPageSetup)
EVT_MENU(WXPRINT_ABOUT, MyFrame::OnPrintAbout)
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
EVT_MENU(WXPRINT_PRINT_PS, MyFrame::OnPrintPS)
EVT_MENU(WXPRINT_PREVIEW_PS, MyFrame::OnPrintPreviewPS)
EVT_MENU(WXPRINT_PRINT_SETUP_PS, MyFrame::OnPrintSetupPS)
EVT_MENU(WXPRINT_PAGE_SETUP_PS, MyFrame::OnPageSetupPS)
#endif
END_EVENT_TABLE()
@ -213,17 +209,6 @@ void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
frame->Show();
}
void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
{
wxPrintDialogData printDialogData(* g_printData);
wxPrintDialog printerDialog(this, & printDialogData);
printerDialog.GetPrintDialogData().SetSetupDialog(true /*show print setup dialog*/);
printerDialog.ShowModal();
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
}
void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
(*g_pageSetupData) = * g_printData;
@ -256,17 +241,6 @@ void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
frame->Show();
}
void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxPrintDialogData printDialogData(* g_printData);
wxGenericPrintDialog printerDialog(this, & printDialogData);
printerDialog.GetPrintDialogData().SetSetupDialog(true /*show print setup dialog*/);
printerDialog.ShowModal();
(*g_printData) = printerDialog.GetPrintDialogData().GetPrintData();
}
void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
{
(*g_pageSetupData) = * g_printData;

View File

@ -40,12 +40,10 @@ class MyFrame: public wxFrame
void OnSize(wxSizeEvent& event);
void OnPrint(wxCommandEvent& event);
void OnPrintPreview(wxCommandEvent& event);
void OnPrintSetup(wxCommandEvent& event);
void OnPageSetup(wxCommandEvent& event);
#if defined(__WXMSW__) && wxTEST_POSTSCRIPT_IN_MSW
void OnPrintPS(wxCommandEvent& event);
void OnPrintPreviewPS(wxCommandEvent& event);
void OnPrintSetupPS(wxCommandEvent& event);
void OnPageSetupPS(wxCommandEvent& event);
#endif
@ -82,12 +80,10 @@ class MyPrintout: public wxPrintout
#define WXPRINT_QUIT 100
#define WXPRINT_PRINT 101
#define WXPRINT_PRINT_SETUP 102
#define WXPRINT_PAGE_SETUP 103
#define WXPRINT_PREVIEW 104
#define WXPRINT_PRINT_PS 105
#define WXPRINT_PRINT_SETUP_PS 106
#define WXPRINT_PAGE_SETUP_PS 107
#define WXPRINT_PREVIEW_PS 108

View File

@ -276,7 +276,9 @@ wxPrintDialogData::wxPrintDialogData()
m_printEnablePrintToFile = ! factory->HasOwnPrintToFile();
m_printEnableHelp = false;
#if WXWIN_COMPATIBILITY_2_4
m_printSetupDialog = false;
#endif
}
wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
@ -300,8 +302,9 @@ wxPrintDialogData::wxPrintDialogData(const wxPrintData& printData)
m_printEnablePageNumbers = true;
m_printEnablePrintToFile = true;
m_printEnableHelp = false;
#if WXWIN_COMPATIBILITY_2_4
m_printSetupDialog = false;
#endif
m_printData = printData;
}
@ -341,8 +344,9 @@ void wxPrintDialogData::operator=(const wxPrintDialogData& data)
m_printEnablePageNumbers = data.m_printEnablePageNumbers;
m_printEnableHelp = data.m_printEnableHelp;
m_printEnablePrintToFile = data.m_printEnablePrintToFile;
#if WXWIN_COMPATIBILITY_2_4
m_printSetupDialog = data.m_printSetupDialog;
#endif
m_printData = data.m_printData;
}
@ -357,9 +361,6 @@ void wxPrintDialogData::operator=(const wxPrintData& data)
wxPageSetupDialogData::wxPageSetupDialogData()
{
#if defined(__WIN95__)
m_pageSetupData = NULL;
#endif
m_paperSize = wxSize(0, 0);
CalculatePaperSizeFromId();
@ -382,17 +383,11 @@ wxPageSetupDialogData::wxPageSetupDialogData()
wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData)
: wxObject()
{
#if defined(__WIN95__)
m_pageSetupData = NULL;
#endif
(*this) = dialogData;
}
wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
{
#if defined(__WIN95__)
m_pageSetupData = NULL;
#endif
m_paperSize = wxSize(0, 0);
m_minMarginTopLeft = wxPoint(0, 0);
m_minMarginBottomRight = wxPoint(0, 0);
@ -417,15 +412,6 @@ wxPageSetupDialogData::wxPageSetupDialogData(const wxPrintData& printData)
wxPageSetupDialogData::~wxPageSetupDialogData()
{
#if defined(__WIN95__) && defined(__WXMSW__)
PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageSetupData;
if ( pd && pd->hDevMode )
GlobalFree(pd->hDevMode);
if ( pd && pd->hDevNames )
GlobalFree(pd->hDevNames);
if ( pd )
delete pd;
#endif
}
wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPageSetupDialogData& data)
@ -455,188 +441,6 @@ wxPageSetupDialogData& wxPageSetupDialogData::operator=(const wxPrintData& data)
return *this;
}
#if defined(__WIN95__)
void wxPageSetupDialogData::ConvertToNative()
{
wxWindowsPrintNativeData *data =
(wxWindowsPrintNativeData *) m_printData.GetNativeData();
data->TransferFrom( m_printData );
PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageSetupData;
if ( m_pageSetupData == NULL )
{
pd = new PAGESETUPDLG;
pd->hDevMode = NULL;
pd->hDevNames = NULL;
m_pageSetupData = (void *)pd;
}
// Pass the devmode data (created in m_printData.ConvertToNative)
// to the PRINTDLG structure, since it'll
// be needed when PrintDlg is called.
if (pd->hDevMode)
{
GlobalFree(pd->hDevMode);
pd->hDevMode = NULL;
}
pd->hDevMode = (HGLOBAL) data->GetDevMode();
data->SetDevMode( (void*) NULL );
// Shouldn't assert; we should be able to test Ok-ness at a higher level
//wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
// Pass the devnames data (created in m_printData.ConvertToNative)
// to the PRINTDLG structure, since it'll
// be needed when PrintDlg is called.
if (pd->hDevNames)
{
GlobalFree(pd->hDevNames);
pd->hDevNames = NULL;
}
pd->hDevNames = (HGLOBAL) data->GetDevNames();
data->SetDevNames((void*) NULL);
// pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
if ( m_defaultMinMargins )
pd->Flags |= PSD_DEFAULTMINMARGINS;
if ( !m_enableMargins )
pd->Flags |= PSD_DISABLEMARGINS;
if ( !m_enableOrientation )
pd->Flags |= PSD_DISABLEORIENTATION;
if ( !m_enablePaper )
pd->Flags |= PSD_DISABLEPAPER;
if ( !m_enablePrinter )
pd->Flags |= PSD_DISABLEPRINTER;
if ( m_getDefaultInfo )
pd->Flags |= PSD_RETURNDEFAULT;
if ( m_enableHelp )
pd->Flags |= PSD_SHOWHELP;
// We want the units to be in hundredths of a millimetre
pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
pd->lStructSize = sizeof( PAGESETUPDLG );
pd->hwndOwner=(HWND)NULL;
// pd->hDevNames=(HWND)NULL;
pd->hInstance=(HINSTANCE)NULL;
// PAGESETUPDLG is in hundreds of a mm
pd->ptPaperSize.x = m_paperSize.x * 100;
pd->ptPaperSize.y = m_paperSize.y * 100;
pd->rtMinMargin.left = m_minMarginTopLeft.x * 100;
pd->rtMinMargin.top = m_minMarginTopLeft.y * 100;
pd->rtMinMargin.right = m_minMarginBottomRight.x * 100;
pd->rtMinMargin.bottom = m_minMarginBottomRight.y * 100;
pd->rtMargin.left = m_marginTopLeft.x * 100;
pd->rtMargin.top = m_marginTopLeft.y * 100;
pd->rtMargin.right = m_marginBottomRight.x * 100;
pd->rtMargin.bottom = m_marginBottomRight.y * 100;
pd->lCustData = 0;
pd->lpfnPageSetupHook = NULL;
pd->lpfnPagePaintHook = NULL;
pd->hPageSetupTemplate = NULL;
pd->lpPageSetupTemplateName = NULL;
/*
if ( pd->hDevMode )
{
DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
memset(devMode, 0, sizeof(DEVMODE));
devMode->dmSize = sizeof(DEVMODE);
devMode->dmOrientation = m_orientation;
devMode->dmFields = DM_ORIENTATION;
GlobalUnlock(pd->hDevMode);
}
*/
}
void wxPageSetupDialogData::ConvertFromNative()
{
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData;
if ( !pd )
return;
wxWindowsPrintNativeData *data =
(wxWindowsPrintNativeData *) m_printData.GetNativeData();
// Pass the devmode data back to the wxPrintData structure where it really belongs.
if (pd->hDevMode)
{
if (data->GetDevMode())
{
// Make sure we don't leak memory
GlobalFree((HGLOBAL) data->GetDevMode());
}
data->SetDevMode( (void*) pd->hDevMode );
pd->hDevMode = NULL;
}
data->TransferTo( m_printData );
// Pass the devnames data back to the wxPrintData structure where it really belongs.
if (pd->hDevNames)
{
if (data->GetDevNames())
{
// Make sure we don't leak memory
GlobalFree((HGLOBAL) data->GetDevNames());
}
data->SetDevNames((void*) pd->hDevNames);
pd->hDevNames = NULL;
}
data->TransferTo( m_printData );
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
m_defaultMinMargins = ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS);
m_enableMargins = ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS);
m_enableOrientation = ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION);
m_enablePaper = ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER);
m_enablePrinter = ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER);
m_getDefaultInfo = ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT);
m_enableHelp = ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP);
// PAGESETUPDLG is in hundreds of a mm
m_paperSize.x = pd->ptPaperSize.x / 100;
m_paperSize.y = pd->ptPaperSize.y / 100;
m_minMarginTopLeft.x = pd->rtMinMargin.left / 100;
m_minMarginTopLeft.y = pd->rtMinMargin.top / 100;
m_minMarginBottomRight.x = pd->rtMinMargin.right / 100;
m_minMarginBottomRight.y = pd->rtMinMargin.bottom / 100;
m_marginTopLeft.x = pd->rtMargin.left / 100;
m_marginTopLeft.y = pd->rtMargin.top / 100;
m_marginBottomRight.x = pd->rtMargin.right / 100;
m_marginBottomRight.y = pd->rtMargin.bottom / 100;
}
void wxPageSetupDialogData::SetOwnerWindow(wxWindow* win)
{
if ( m_pageSetupData == NULL )
ConvertToNative();
if ( m_pageSetupData != NULL && win != NULL)
{
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageSetupData;
pd->hwndOwner=(HWND) win->GetHWND();
}
}
#endif // Win95
#ifdef __WXMAC__
void wxPageSetupDialogData::ConvertToNative()
{

View File

@ -837,11 +837,9 @@ BEGIN_EVENT_TABLE(wxDocManager, wxEvtHandler)
#if wxUSE_PRINTING_ARCHITECTURE
EVT_MENU(wxID_PRINT, wxDocManager::OnPrint)
EVT_MENU(wxID_PRINT_SETUP, wxDocManager::OnPrintSetup)
EVT_MENU(wxID_PREVIEW, wxDocManager::OnPreview)
EVT_UPDATE_UI(wxID_PRINT, wxDocManager::OnUpdatePrint)
EVT_UPDATE_UI(wxID_PRINT_SETUP, wxDocManager::OnUpdatePrintSetup)
EVT_UPDATE_UI(wxID_PREVIEW, wxDocManager::OnUpdatePreview)
#endif
END_EVENT_TABLE()
@ -1005,22 +1003,6 @@ void wxDocManager::OnPrint(wxCommandEvent& WXUNUSED(event))
#endif // wxUSE_PRINTING_ARCHITECTURE
}
void wxDocManager::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_PRINTING_ARCHITECTURE
wxWindow *parentWin = wxTheApp->GetTopWindow();
wxView *view = GetCurrentView();
if (view)
parentWin = view->GetFrame();
wxPrintDialogData data;
wxPrintDialog printerDialog(parentWin, &data);
printerDialog.GetPrintDialogData().SetSetupDialog(true);
printerDialog.ShowModal();
#endif // wxUSE_PRINTING_ARCHITECTURE
}
void wxDocManager::OnPreview(wxCommandEvent& WXUNUSED(event))
{
#if wxUSE_PRINTING_ARCHITECTURE
@ -1141,11 +1123,6 @@ void wxDocManager::OnUpdatePrint(wxUpdateUIEvent& event)
event.Enable( (doc != (wxDocument*) NULL) );
}
void wxDocManager::OnUpdatePrintSetup(wxUpdateUIEvent& event)
{
event.Enable( true );
}
void wxDocManager::OnUpdatePreview(wxUpdateUIEvent& event)
{
wxDocument *doc = GetCurrentDocument();

View File

@ -591,18 +591,6 @@ bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout)
void wxHtmlEasyPrinting::PrinterSetup()
{
wxPrintDialogData printDialogData(*GetPrintData());
wxPrintDialog printerDialog(m_ParentWindow, &printDialogData);
printerDialog.GetPrintDialogData().SetSetupDialog(true);
if (printerDialog.ShowModal() == wxID_OK)
(*GetPrintData()) = printerDialog.GetPrintDialogData().GetPrintData();
}
void wxHtmlEasyPrinting::PageSetup()
{

View File

@ -690,8 +690,10 @@ bool wxWindowsPrintDialog::ConvertToNative( wxPrintDialogData &data )
pd->Flags |= PD_PAGENUMS;
if ( data.GetEnableHelp() )
pd->Flags |= PD_SHOWHELP;
#if WXWIN_COMPATIBILITY_2_4
if ( data.GetSetupDialog() )
pd->Flags |= PD_PRINTSETUP;
#endif
return true;
}
@ -747,8 +749,9 @@ bool wxWindowsPrintDialog::ConvertFromNative( wxPrintDialogData &data )
data.EnableSelection( ((pd->Flags & PD_NOSELECTION) != PD_NOSELECTION) );
data.EnablePageNumbers( ((pd->Flags & PD_NOPAGENUMS) != PD_NOPAGENUMS) );
data.EnableHelp( ((pd->Flags & PD_SHOWHELP) == PD_SHOWHELP) );
#if WXWIN_COMPATIBILITY_2_4
data.SetSetupDialog( ((pd->Flags & PD_PRINTSETUP) == PD_PRINTSETUP) );
#endif
return true;
}
@ -761,57 +764,220 @@ IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog)
wxPageSetupDialog::wxPageSetupDialog()
{
m_dialogParent = NULL;
m_pageDlg = NULL;
}
wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data)
wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupDialogData *data)
{
Create(p, data);
}
bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data)
bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data)
{
m_dialogParent = p;
m_pageDlg = NULL;
if (data)
m_pageSetupData = (*data);
#if defined(__WIN95__)
m_pageSetupData.SetOwnerWindow(p);
#endif
return true;
}
wxPageSetupDialog::~wxPageSetupDialog()
{
PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageDlg;
if ( pd && pd->hDevMode )
GlobalFree(pd->hDevMode);
if ( pd && pd->hDevNames )
GlobalFree(pd->hDevNames);
if ( pd )
delete pd;
}
int wxPageSetupDialog::ShowModal()
{
#ifdef __WIN95__
m_pageSetupData.ConvertToNative();
PAGESETUPDLG *p = (PAGESETUPDLG *)m_pageSetupData.GetNativeData();
ConvertToNative( m_pageSetupData );
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageDlg;
if (m_dialogParent)
p->hwndOwner = (HWND) m_dialogParent->GetHWND();
pd->hwndOwner = (HWND) m_dialogParent->GetHWND();
else if (wxTheApp->GetTopWindow())
p->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
pd->hwndOwner = (HWND) wxTheApp->GetTopWindow()->GetHWND();
else
p->hwndOwner = 0;
BOOL retVal = PageSetupDlg( p ) ;
p->hwndOwner = 0;
pd->hwndOwner = 0;
BOOL retVal = PageSetupDlg( pd ) ;
pd->hwndOwner = 0;
if (retVal)
{
m_pageSetupData.ConvertFromNative();
ConvertFromNative( m_pageSetupData );
return wxID_OK;
}
else
return wxID_CANCEL;
#else
wxGenericPageSetupDialog *genericPageSetupDialog = new wxGenericPageSetupDialog(GetParent(), & m_pageSetupData);
int ret = genericPageSetupDialog->ShowModal();
m_pageSetupData = genericPageSetupDialog->GetPageSetupData();
genericPageSetupDialog->Close(true);
return ret;
#endif
}
bool wxPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data )
{
wxWindowsPrintNativeData *native_data =
(wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData();
data.GetPrintData().ConvertToNative();
PAGESETUPDLG *pd = (PAGESETUPDLG*) m_pageDlg;
// Shouldn't have been defined anywhere
if (pd)
return false;
pd = new PAGESETUPDLG;
pd->hDevMode = NULL;
pd->hDevNames = NULL;
m_pageDlg = (void *)pd;
// Pass the devmode data (created in m_printData.ConvertToNative)
// to the PRINTDLG structure, since it'll
// be needed when PrintDlg is called.
if (pd->hDevMode)
{
GlobalFree(pd->hDevMode);
pd->hDevMode = NULL;
}
pd->hDevMode = (HGLOBAL) native_data->GetDevMode();
native_data->SetDevMode( (void*) NULL );
// Shouldn't assert; we should be able to test Ok-ness at a higher level
//wxASSERT_MSG( (pd->hDevMode), wxT("hDevMode must be non-NULL in ConvertToNative!"));
// Pass the devnames data (created in m_printData.ConvertToNative)
// to the PRINTDLG structure, since it'll
// be needed when PrintDlg is called.
if (pd->hDevNames)
{
GlobalFree(pd->hDevNames);
pd->hDevNames = NULL;
}
pd->hDevNames = (HGLOBAL) native_data->GetDevNames();
native_data->SetDevNames((void*) NULL);
// pd->hDevMode = GlobalAlloc(GMEM_MOVEABLE, sizeof(DEVMODE));
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
if ( data.GetDefaultMinMargins() )
pd->Flags |= PSD_DEFAULTMINMARGINS;
if ( !data.GetEnableMargins() )
pd->Flags |= PSD_DISABLEMARGINS;
if ( !data.GetEnableOrientation() )
pd->Flags |= PSD_DISABLEORIENTATION;
if ( !data.GetEnablePaper() )
pd->Flags |= PSD_DISABLEPAPER;
if ( !data.GetEnablePrinter() )
pd->Flags |= PSD_DISABLEPRINTER;
if ( data.GetDefaultInfo() )
pd->Flags |= PSD_RETURNDEFAULT;
if ( data.GetEnableHelp() )
pd->Flags |= PSD_SHOWHELP;
// We want the units to be in hundredths of a millimetre
pd->Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
pd->lStructSize = sizeof( PAGESETUPDLG );
pd->hwndOwner=(HWND)NULL;
// pd->hDevNames=(HWND)NULL;
pd->hInstance=(HINSTANCE)NULL;
// PAGESETUPDLG is in hundreds of a mm
pd->ptPaperSize.x = data.GetPaperSize().x * 100;
pd->ptPaperSize.y = data.GetPaperSize().y * 100;
pd->rtMinMargin.left = data.GetMinMarginTopLeft().x * 100;
pd->rtMinMargin.top = data.GetMinMarginTopLeft().y * 100;
pd->rtMinMargin.right = data.GetMinMarginBottomRight().x * 100;
pd->rtMinMargin.bottom = data.GetMinMarginBottomRight().y * 100;
pd->rtMargin.left = data.GetMarginTopLeft().x * 100;
pd->rtMargin.top = data.GetMarginTopLeft().y * 100;
pd->rtMargin.right = data.GetMarginBottomRight().x * 100;
pd->rtMargin.bottom = data.GetMarginBottomRight().y * 100;
pd->lCustData = 0;
pd->lpfnPageSetupHook = NULL;
pd->lpfnPagePaintHook = NULL;
pd->hPageSetupTemplate = NULL;
pd->lpPageSetupTemplateName = NULL;
/*
if ( pd->hDevMode )
{
DEVMODE *devMode = (DEVMODE*) GlobalLock(pd->hDevMode);
memset(devMode, 0, sizeof(DEVMODE));
devMode->dmSize = sizeof(DEVMODE);
devMode->dmOrientation = m_orientation;
devMode->dmFields = DM_ORIENTATION;
GlobalUnlock(pd->hDevMode);
}
*/
return true;
}
bool wxPageSetupDialog::ConvertFromNative( wxPageSetupDialogData &data )
{
PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageDlg;
if ( !pd )
return false;
wxWindowsPrintNativeData *native_data =
(wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData();
// Pass the devmode data back to the wxPrintData structure where it really belongs.
if (pd->hDevMode)
{
if (native_data->GetDevMode())
{
// Make sure we don't leak memory
GlobalFree((HGLOBAL) native_data->GetDevMode());
}
native_data->SetDevMode( (void*) pd->hDevMode );
pd->hDevMode = NULL;
}
// Isn't this superfluous? It's called again below.
// data.GetPrintData().ConvertFromNative();
// Pass the devnames data back to the wxPrintData structure where it really belongs.
if (pd->hDevNames)
{
if (native_data->GetDevNames())
{
// Make sure we don't leak memory
GlobalFree((HGLOBAL) native_data->GetDevNames());
}
native_data->SetDevNames((void*) pd->hDevNames);
pd->hDevNames = NULL;
}
data.GetPrintData().ConvertFromNative();
pd->Flags = PSD_MARGINS|PSD_MINMARGINS;
data.SetDefaultMinMargins( ((pd->Flags & PSD_DEFAULTMINMARGINS) == PSD_DEFAULTMINMARGINS) );
data.EnableMargins( ((pd->Flags & PSD_DISABLEMARGINS) != PSD_DISABLEMARGINS) );
data.EnableOrientation( ((pd->Flags & PSD_DISABLEORIENTATION) != PSD_DISABLEORIENTATION) );
data.EnablePaper( ((pd->Flags & PSD_DISABLEPAPER) != PSD_DISABLEPAPER) );
data.EnablePrinter( ((pd->Flags & PSD_DISABLEPRINTER) != PSD_DISABLEPRINTER) );
data.SetDefaultInfo( ((pd->Flags & PSD_RETURNDEFAULT) == PSD_RETURNDEFAULT) );
data.EnableHelp( ((pd->Flags & PSD_SHOWHELP) == PSD_SHOWHELP) );
// PAGESETUPDLG is in hundreds of a mm
data.SetPaperSize( wxSize(pd->ptPaperSize.x / 100, pd->ptPaperSize.y / 100) );
data.SetMinMarginTopLeft( wxPoint(pd->rtMinMargin.left / 100, pd->rtMinMargin.top / 100) );
data.SetMinMarginBottomRight( wxPoint(pd->rtMinMargin.right / 100, pd->rtMinMargin.bottom / 100) );
data.SetMarginTopLeft( wxPoint(pd->rtMargin.left / 100, pd->rtMargin.top / 100) );
data.SetMarginBottomRight( wxPoint(pd->rtMargin.right / 100, pd->rtMargin.bottom / 100) );
return true;
}
#endif

View File

@ -308,6 +308,8 @@ wxDC* wxWindowsPrinter::PrintDialog(wxWindow *parent)
bool wxWindowsPrinter::Setup(wxWindow *parent)
{
#if 0
// We no longer expose that dialog
wxPrintDialog dialog(parent, & m_printDialogData);
dialog.GetPrintDialogData().SetSetupDialog(true);
@ -319,6 +321,9 @@ bool wxWindowsPrinter::Setup(wxWindow *parent)
}
return (ret == wxID_OK);
#else
return wxID_CANCEL;
#endif
}
/*