From 08680429a25d66e284c75f69f14fe8ca6ab15f72 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 20 Nov 2004 14:46:25 +0000 Subject: [PATCH] Made wxPageSetupDialog a pimpl implementation. Added a few clean-ups. Added native GNOME page setup dialog. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30669 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/prntdlgg.h | 10 ++-- include/wx/gtk/gnome/gprint.h | 41 ++++++++++++- include/wx/gtk1/gnome/gprint.h | 41 ++++++++++++- include/wx/mac/carbon/printdlg.h | 38 +++++++------ include/wx/msw/printdlg.h | 31 +++++----- include/wx/printdlg.h | 72 ++++++++++++++--------- include/wx/prntbase.h | 10 +++- src/generic/prntdlgg.cpp | 98 ++++++++++++++++++-------------- src/gtk/gnome/gprint.cpp | 92 ++++++++++++++++++++++++++++++ src/gtk1/gnome/gprint.cpp | 92 ++++++++++++++++++++++++++++++ src/mac/carbon/printdlg.cpp | 35 ++++++------ src/mac/carbon/printmac.cpp | 1 + src/msw/dcprint.cpp | 1 + src/msw/printdlg.cpp | 19 ++++--- 14 files changed, 448 insertions(+), 133 deletions(-) diff --git a/include/wx/generic/prntdlgg.h b/include/wx/generic/prntdlgg.h index 229886a97a..2e22465981 100644 --- a/include/wx/generic/prntdlgg.h +++ b/include/wx/generic/prntdlgg.h @@ -221,20 +221,20 @@ private: #endif // wxUSE_POSTSCRIPT -class WXDLLEXPORT wxGenericPageSetupDialog : public wxDialog +class WXDLLEXPORT wxGenericPageSetupDialog : public wxPageSetupDialogBase { public: wxGenericPageSetupDialog(wxWindow *parent = NULL, - wxPageSetupData* data = NULL); + wxPageSetupDialogData* data = NULL); virtual ~wxGenericPageSetupDialog(); virtual bool TransferDataFromWindow(); virtual bool TransferDataToWindow(); - void OnPrinter(wxCommandEvent& event); + virtual wxPageSetupDialogData& GetPageSetupDialogData(); + void OnPrinter(wxCommandEvent& event); wxComboBox *CreatePaperTypeChoice(int* x, int* y); - wxPageSetupData& GetPageSetupData() { return m_pageData; } public: wxButton* m_printerButton; @@ -245,7 +245,7 @@ public: wxTextCtrl* m_marginBottomText; wxComboBox* m_paperTypeChoice; - wxPageSetupData m_pageData; + wxPageSetupDialogData m_pageData; private: DECLARE_EVENT_TABLE() diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h index 77e924d711..0c107301d4 100644 --- a/include/wx/gtk/gnome/gprint.h +++ b/include/wx/gtk/gnome/gprint.h @@ -77,7 +77,10 @@ public: wxPrintDialogData *data = NULL ); virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, wxPrintData *data ); - + + virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData * data = NULL ); + virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); virtual bool HasOwnPrintToFile(); @@ -97,7 +100,7 @@ class wxGnomePrintDialog: public wxPrintDialogBase { public: wxGnomePrintDialog( wxWindow *parent, - wxPrintDialogData* data = (wxPrintDialogData*)NULL ); + wxPrintDialogData* data = NULL ); wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); ~wxGnomePrintDialog(); @@ -130,6 +133,40 @@ private: DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) }; +//---------------------------------------------------------------------------- +// wxGnomePageSetupDialog +//---------------------------------------------------------------------------- + +class wxGnomePageSetupDialog: public wxPageSetupDialogBase +{ +public: + wxGnomePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData* data = NULL ); + ~wxGnomePageSetupDialog(); + + virtual wxPageSetupDialogData& GetPageSetupDialogData(); + + virtual int ShowModal(); + + virtual bool Validate(); + virtual bool TransferDataToWindow(); + virtual bool TransferDataFromWindow(); + +private: + // Implement some base class methods to do nothing to avoid asserts and + // GTK warnings, since this is not a real wxDialog. + virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), + int WXUNUSED(width), int WXUNUSED(height), + int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} + virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), + int WXUNUSED(width), int WXUNUSED(height)) {} + + wxPageSetupDialogData m_pageDialogData; + +private: + DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) +}; + //---------------------------------------------------------------------------- // wxGnomePrinter //---------------------------------------------------------------------------- diff --git a/include/wx/gtk1/gnome/gprint.h b/include/wx/gtk1/gnome/gprint.h index 77e924d711..0c107301d4 100644 --- a/include/wx/gtk1/gnome/gprint.h +++ b/include/wx/gtk1/gnome/gprint.h @@ -77,7 +77,10 @@ public: wxPrintDialogData *data = NULL ); virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, wxPrintData *data ); - + + virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData * data = NULL ); + virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); virtual bool HasOwnPrintToFile(); @@ -97,7 +100,7 @@ class wxGnomePrintDialog: public wxPrintDialogBase { public: wxGnomePrintDialog( wxWindow *parent, - wxPrintDialogData* data = (wxPrintDialogData*)NULL ); + wxPrintDialogData* data = NULL ); wxGnomePrintDialog( wxWindow *parent, wxPrintData* data); ~wxGnomePrintDialog(); @@ -130,6 +133,40 @@ private: DECLARE_DYNAMIC_CLASS(wxGnomePrintDialog) }; +//---------------------------------------------------------------------------- +// wxGnomePageSetupDialog +//---------------------------------------------------------------------------- + +class wxGnomePageSetupDialog: public wxPageSetupDialogBase +{ +public: + wxGnomePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData* data = NULL ); + ~wxGnomePageSetupDialog(); + + virtual wxPageSetupDialogData& GetPageSetupDialogData(); + + virtual int ShowModal(); + + virtual bool Validate(); + virtual bool TransferDataToWindow(); + virtual bool TransferDataFromWindow(); + +private: + // Implement some base class methods to do nothing to avoid asserts and + // GTK warnings, since this is not a real wxDialog. + virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), + int WXUNUSED(width), int WXUNUSED(height), + int WXUNUSED(sizeFlags) = wxSIZE_AUTO) {} + virtual void DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), + int WXUNUSED(width), int WXUNUSED(height)) {} + + wxPageSetupDialogData m_pageDialogData; + +private: + DECLARE_DYNAMIC_CLASS(wxGnomePageSetupDialog) +}; + //---------------------------------------------------------------------------- // wxGnomePrinter //---------------------------------------------------------------------------- diff --git a/include/wx/mac/carbon/printdlg.h b/include/wx/mac/carbon/printdlg.h index c7f92db66c..5ea4400098 100644 --- a/include/wx/mac/carbon/printdlg.h +++ b/include/wx/mac/carbon/printdlg.h @@ -40,8 +40,8 @@ public: }; /* - * wxPrinterDialog - * The common dialog for printing. + * wxMacPrintDialog + * The Mac dialog for printing */ class WXDLLEXPORT wxDC; @@ -70,22 +70,28 @@ private: DECLARE_DYNAMIC_CLASS(wxPrintDialog) }; -class WXDLLEXPORT wxPageSetupDialog: public wxDialog -{ - DECLARE_DYNAMIC_CLASS(wxPageSetupDialog) - - public: - wxPageSetupDialog(); - wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL); - ~wxPageSetupDialog(); +/* + * wxMacPageSetupDialog + * The Mac page setup dialog + */ - bool Create(wxWindow *parent, wxPageSetupData *data = NULL); - virtual int ShowModal(); +class WXDLLEXPORT wxMacPageSetupDialog: public wxPageSetupDialogBase +{ +public: + wxMacPageSetupDialog(wxWindow *parent, wxPageSetupDialogData *data = NULL); + ~wxMacPageSetupDialog(); - inline wxPageSetupData& GetPageSetupData() { return m_pageSetupData; } - private: - wxPageSetupData m_pageSetupData; - wxWindow* m_dialogParent; + virtual wxPageSetupData& GetPageSetupDialogData(); + + bool Create(wxWindow *parent, wxPageSetupDialogData *data = NULL); + virtual int ShowModal(); + +private: + wxPageSetupDialogData m_pageSetupData; + wxWindow* m_dialogParent; + +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacPageSetupDialog) }; #endif diff --git a/include/wx/msw/printdlg.h b/include/wx/msw/printdlg.h index 1396ddc026..dba9a45412 100644 --- a/include/wx/msw/printdlg.h +++ b/include/wx/msw/printdlg.h @@ -54,7 +54,7 @@ private: }; // --------------------------------------------------------------------------- -// wxPrinterDialog: the common dialog for printing. +// wxWindowsPrintDialog: the MSW dialog for printing // --------------------------------------------------------------------------- class WXDLLEXPORT wxWindowsPrintDialog : public wxPrintDialogBase @@ -89,28 +89,33 @@ private: DECLARE_CLASS(wxWindowsPrintDialog) }; -class WXDLLEXPORT wxPageSetupDialog: public wxDialog -{ - DECLARE_DYNAMIC_CLASS(wxPageSetupDialog) +// --------------------------------------------------------------------------- +// wxWindowsPageSetupDialog: the MSW page setup dialog +// --------------------------------------------------------------------------- +class WXDLLEXPORT wxWindowsPageSetupDialog: public wxPageSetupDialogBase +{ public: - wxPageSetupDialog(); - wxPageSetupDialog(wxWindow *parent, wxPageSetupData *data = NULL); - virtual ~wxPageSetupDialog(); + wxWindowsPageSetupDialog(); + wxWindowsPageSetupDialog(wxWindow *parent, wxPageSetupDialogData *data = NULL); + virtual ~wxWindowsPageSetupDialog(); - bool Create(wxWindow *parent, wxPageSetupData *data = NULL); + bool Create(wxWindow *parent, wxPageSetupDialogData *data = NULL); virtual int ShowModal(); bool ConvertToNative( wxPageSetupDialogData &data ); bool ConvertFromNative( wxPageSetupDialogData &data ); - wxPageSetupData& GetPageSetupData() { return m_pageSetupData; } + virtual wxPageSetupData& GetPageSetupDialogData() { return m_pageSetupData; } private: - wxPageSetupData m_pageSetupData; - wxWindow* m_dialogParent; - void* m_pageDlg; + wxPageSetupDialogData m_pageSetupData; + wxWindow* m_dialogParent; + + // holds MSW handle + void* m_pageDlg; - DECLARE_NO_COPY_CLASS(wxPageSetupDialog) +private: + DECLARE_DYNAMIC_CLASS_NO_COPY(wxWindowsPageSetupDialog) }; #endif // wxUSE_PRINTING_ARCHITECTURE diff --git a/include/wx/printdlg.h b/include/wx/printdlg.h index dfe34ac267..4486ab3233 100644 --- a/include/wx/printdlg.h +++ b/include/wx/printdlg.h @@ -16,7 +16,7 @@ // --------------------------------------------------------------------------- -// wxPrintDialogBase: interface for the common dialog for printing. +// wxPrintDialogBase: interface for the dialog for printing // --------------------------------------------------------------------------- class WXDLLEXPORT wxPrintDialogBase : public wxDialog @@ -30,8 +30,6 @@ public: const wxSize &size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE); - virtual int ShowModal() = 0; - virtual wxPrintDialogData& GetPrintDialogData() = 0; virtual wxPrintData& GetPrintData() = 0; virtual wxDC *GetPrintDC() = 0; @@ -42,7 +40,7 @@ private: }; // --------------------------------------------------------------------------- -// wxPrintDialog: the common dialog for printing. +// wxPrintDialog: the dialog for printing. // --------------------------------------------------------------------------- class WXDLLEXPORT wxPrintDialog : public wxObject @@ -66,31 +64,51 @@ private: DECLARE_NO_COPY_CLASS(wxPrintDialog) }; -#endif +// --------------------------------------------------------------------------- +// wxPageSetupDialogBase: interface for the page setup dialog +// --------------------------------------------------------------------------- -#if defined(__WXUNIVERSAL__) && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) -#include "wx/generic/prntdlgg.h" -#elif defined(__PALMOS__) -#include "wx/palmos/printdlg.h" -#elif defined(__WXMSW__) -#include "wx/msw/printdlg.h" -#elif defined(__WXMOTIF__) -#include "wx/generic/prntdlgg.h" -#elif defined(__WXGTK__) -#include "wx/generic/prntdlgg.h" -#elif defined(__WXX11__) -#include "wx/generic/prntdlgg.h" -#elif defined(__WXMGL__) -#include "wx/generic/prntdlgg.h" -#elif defined(__WXMAC__) -#include "wx/mac/printdlg.h" -#elif defined(__WXPM__) -#include "wx/generic/prntdlgg.h" -#endif +class WXDLLEXPORT wxPageSetupDialogBase: public wxDialog +{ +public: + wxPageSetupDialogBase() { } + wxPageSetupDialogBase(wxWindow *parent, + wxWindowID id = wxID_ANY, + const wxString &title = wxEmptyString, + const wxPoint &pos = wxDefaultPosition, + const wxSize &size = wxDefaultSize, + long style = wxDEFAULT_DIALOG_STYLE); + + virtual wxPageSetupDialogData& GetPageSetupDialogData() = 0; + +private: + DECLARE_ABSTRACT_CLASS(wxPageSetupDialogBase) + DECLARE_NO_COPY_CLASS(wxPageSetupDialogBase) +}; + +// --------------------------------------------------------------------------- +// wxPageSetupDialog: the page setup dialog +// --------------------------------------------------------------------------- + +class WXDLLEXPORT wxPageSetupDialog: public wxObject +{ +public: + wxPageSetupDialog(wxWindow *parent, wxPageSetupDialogData *data = NULL); + ~wxPageSetupDialog(); + + int ShowModal(); + wxPageSetupDialogData& GetPageSetupDialogData(); + // old name + wxPageSetupDialogData& GetPageSetupData(); + +private: + wxPageSetupDialogBase *m_pimpl; + +private: + DECLARE_DYNAMIC_CLASS(wxPageSetupDialog) + DECLARE_NO_COPY_CLASS(wxPageSetupDialog) +}; -#if (defined(__WXUNIVERSAL__) && (!defined(__WXMSW__) || wxUSE_POSTSCRIPT_ARCHITECTURE_IN_MSW) ) || (!defined(__WXMSW__) && !defined(__WXMAC__)) -#define wxPrintSetupDialog wxGenericPrintSetupDialog -#define wxPageSetupDialog wxGenericPageSetupDialog #endif #endif diff --git a/include/wx/prntbase.h b/include/wx/prntbase.h index 95bbc62916..3307ba26af 100644 --- a/include/wx/prntbase.h +++ b/include/wx/prntbase.h @@ -32,8 +32,10 @@ class WXDLLEXPORT wxButton; class WXDLLEXPORT wxChoice; class WXDLLEXPORT wxPrintout; class WXDLLEXPORT wxPrinterBase; -class WXDLLEXPORT wxPrintDialog; class WXDLLEXPORT wxPrintDialogBase; +class WXDLLEXPORT wxPrintDialog; +class WXDLLEXPORT wxPageSetupDialogBase; +class WXDLLEXPORT wxPageSetupDialog; class WXDLLEXPORT wxPrintPreviewBase; class WXDLLEXPORT wxPreviewCanvas; class WXDLLEXPORT wxPreviewControlBar; @@ -76,6 +78,9 @@ public: virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, wxPrintData *data ) = 0; + virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData * data = NULL ) = 0; + // What to do and what to show in the wxPrintDialog // a) Use the generic print setup dialog or a native one? virtual bool HasPrintSetupDialog() = 0; @@ -114,6 +119,9 @@ public: virtual wxPrintDialogBase *CreatePrintDialog( wxWindow *parent, wxPrintData *data ); + virtual wxPageSetupDialogBase *CreatePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData * data = NULL ); + virtual bool HasPrintSetupDialog(); virtual wxDialog *CreatePrintSetupDialog( wxWindow *parent, wxPrintData *data ); virtual bool HasOwnPrintToFile(); diff --git a/src/generic/prntdlgg.cpp b/src/generic/prntdlgg.cpp index d9e5b92604..9b9e3846c0 100644 --- a/src/generic/prntdlgg.cpp +++ b/src/generic/prntdlgg.cpp @@ -810,49 +810,15 @@ wxComboBox *wxGenericPrintSetupDialog::CreatePaperTypeChoice() // Generic page setup dialog // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxDialog) +IMPLEMENT_CLASS(wxGenericPageSetupDialog, wxPageSetupDialogBase) -BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxDialog) +BEGIN_EVENT_TABLE(wxGenericPageSetupDialog, wxPageSetupDialogBase) EVT_BUTTON(wxPRINTID_SETUP, wxGenericPageSetupDialog::OnPrinter) END_EVENT_TABLE() -void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event)) -{ - // We no longer query GetPrintMode, so we can eliminate the need - // to call SetPrintMode. - // This has the limitation that we can't explicitly call the PostScript - // print setup dialog from the generic Page Setup dialog under Windows, - // but since this choice would only happen when trying to do PostScript - // printing under Windows (and only in 16-bit Windows which - // doesn't have a Windows-specific page setup dialog) it's worth it. - - // First save the current settings, so the wxPrintData object is up to date. - TransferDataFromWindow(); - - // Transfer the current print settings from this dialog to the page setup dialog. - -#if 0 - // Use print factory later - - wxPrintDialogData data; - data = GetPageSetupData().GetPrintData(); - data.SetSetupDialog(true); - wxPrintDialog printDialog(this, & data); - printDialog.ShowModal(); - - // Transfer the page setup print settings from the page dialog to this dialog again, in case - // the page setup dialog changed something. - GetPageSetupData().GetPrintData() = printDialog.GetPrintDialogData().GetPrintData(); - GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData - - // Now update the dialog in case the page setup dialog changed some of our settings. - TransferDataToWindow(); -#endif -} - wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent, - wxPageSetupData* data) - : wxDialog( parent, + wxPageSetupDialogData* data) + : wxPageSetupDialogBase( parent, wxID_ANY, _("Page Setup"), wxPoint(0, 0), @@ -939,10 +905,19 @@ wxGenericPageSetupDialog::wxGenericPageSetupDialog( wxWindow *parent, // 6) buttons wxSizer* buttonsizer = CreateButtonSizer( wxOK|wxCANCEL); - m_printerButton = new wxButton(this, wxPRINTID_SETUP, _("Printer...") ); - buttonsizer->Add( m_printerButton, 0, wxLEFT|wxRIGHT, 10 ); - if ( !m_pageData.GetEnablePrinter() ) - m_printerButton->Enable(false); + + if (wxPrintFactory::GetFactory()->HasPrintSetupDialog()) + { + m_printerButton = new wxButton(this, wxPRINTID_SETUP, _("Printer...") ); + buttonsizer->Add( m_printerButton, 0, wxLEFT|wxRIGHT, 10 ); + if ( !m_pageData.GetEnablePrinter() ) + m_printerButton->Enable(false); + } + else + { + m_printerButton = NULL; + } + // if (m_printData.GetEnableHelp()) // wxButton *helpButton = new wxButton(this, (wxFunction)wxGenericPageSetupHelpProc, _("Help"), wxDefaultCoord, wxDefaultCoord, buttonWidth, buttonHeight); mainsizer->Add( buttonsizer, 0, wxCENTER|wxALL, 10 ); @@ -964,6 +939,11 @@ wxGenericPageSetupDialog::~wxGenericPageSetupDialog() { } +wxPageSetupDialogData& wxGenericPageSetupDialog::GetPageSetupDialogData() +{ + return m_pageData; +} + bool wxGenericPageSetupDialog::TransferDataToWindow() { if (m_marginLeftText) @@ -1080,5 +1060,39 @@ wxComboBox *wxGenericPageSetupDialog::CreatePaperTypeChoice(int *x, int *y) return choice; } +void wxGenericPageSetupDialog::OnPrinter(wxCommandEvent& WXUNUSED(event)) +{ + // We no longer query GetPrintMode, so we can eliminate the need + // to call SetPrintMode. + // This has the limitation that we can't explicitly call the PostScript + // print setup dialog from the generic Page Setup dialog under Windows, + // but since this choice would only happen when trying to do PostScript + // printing under Windows (and only in 16-bit Windows which + // doesn't have a Windows-specific page setup dialog) it's worth it. + + // First save the current settings, so the wxPrintData object is up to date. + TransferDataFromWindow(); + + // Transfer the current print settings from this dialog to the page setup dialog. + +#if 0 + // Use print factory later + + wxPrintDialogData data; + data = GetPageSetupData().GetPrintData(); + data.SetSetupDialog(true); + wxPrintDialog printDialog(this, & data); + printDialog.ShowModal(); + + // Transfer the page setup print settings from the page dialog to this dialog again, in case + // the page setup dialog changed something. + GetPageSetupData().GetPrintData() = printDialog.GetPrintDialogData().GetPrintData(); + GetPageSetupData().CalculatePaperSizeFromId(); // Make sure page size reflects the id in wxPrintData + + // Now update the dialog in case the page setup dialog changed some of our settings. + TransferDataToWindow(); +#endif +} + #endif diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp index 2f35e43987..152ff9c32a 100644 --- a/src/gtk/gnome/gprint.cpp +++ b/src/gtk/gnome/gprint.cpp @@ -27,11 +27,13 @@ #include "wx/fontutil.h" #include "wx/printdlg.h" #include "wx/gtk/private.h" +#include "wx/module.h" #include #include #include #include +#include //---------------------------------------------------------------------------- // wxGnomePrintNativeData @@ -98,6 +100,12 @@ wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, return new wxGnomePrintDialog( parent, data ); } +wxPageSetupDialogBase *wxGnomePrintFactory::CreatePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData * data ) +{ + return new wxGnomePageSetupDialog( parent, data ); +} + bool wxGnomePrintFactory::HasPrintSetupDialog() { return false; @@ -270,6 +278,90 @@ bool wxGnomePrintDialog::TransferDataFromWindow() return true; } +//---------------------------------------------------------------------------- +// wxGnomePageSetupDialog +//---------------------------------------------------------------------------- + +IMPLEMENT_CLASS(wxGnomePageSetupDialog, wxPageSetupDialogBase) + +wxGnomePageSetupDialog::wxGnomePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData* data ) +{ + if (data) + m_pageDialogData = *data; + + wxGnomePrintNativeData *native = + (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); + + m_widget = gtk_dialog_new(); + + gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( _("Page setup") ) ); + + GtkWidget *main = gnome_paper_selector_new_with_flags( native->GetPrintConfig(), + GNOME_PAPER_SELECTOR_MARGINS|GNOME_PAPER_SELECTOR_FEED_ORIENTATION ); + gtk_container_set_border_width (GTK_CONTAINER (main), 8); + gtk_widget_show (main); + + gtk_container_add( GTK_CONTAINER (GTK_DIALOG (m_widget)->vbox), main ); + + gtk_dialog_set_has_separator (GTK_DIALOG (m_widget), TRUE); + + gtk_dialog_add_buttons (GTK_DIALOG (m_widget), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_dialog_set_default_response (GTK_DIALOG (m_widget), + GTK_RESPONSE_OK); +} + +wxGnomePageSetupDialog::~wxGnomePageSetupDialog() +{ +} + +wxPageSetupDialogData& wxGnomePageSetupDialog::GetPageSetupDialogData() +{ + return m_pageDialogData; +} + +int wxGnomePageSetupDialog::ShowModal() +{ + // Transfer data from m_pageDialogData to native dialog + + int ret = gtk_dialog_run( GTK_DIALOG(m_widget) ); + + if (ret == GTK_RESPONSE_OK) + { + // Transfer data back to m_pageDialogData + + ret = wxID_OK; + } + else + { + ret = wxID_CANCEL; + } + + gtk_widget_destroy( m_widget ); + m_widget = NULL; + + return ret; +} + +bool wxGnomePageSetupDialog::Validate() +{ + return true; +} + +bool wxGnomePageSetupDialog::TransferDataToWindow() +{ + return true; +} + +bool wxGnomePageSetupDialog::TransferDataFromWindow() +{ + return true; +} + //---------------------------------------------------------------------------- // wxGnomePrinter //---------------------------------------------------------------------------- diff --git a/src/gtk1/gnome/gprint.cpp b/src/gtk1/gnome/gprint.cpp index 2f35e43987..152ff9c32a 100644 --- a/src/gtk1/gnome/gprint.cpp +++ b/src/gtk1/gnome/gprint.cpp @@ -27,11 +27,13 @@ #include "wx/fontutil.h" #include "wx/printdlg.h" #include "wx/gtk/private.h" +#include "wx/module.h" #include #include #include #include +#include //---------------------------------------------------------------------------- // wxGnomePrintNativeData @@ -98,6 +100,12 @@ wxPrintDialogBase *wxGnomePrintFactory::CreatePrintDialog( wxWindow *parent, return new wxGnomePrintDialog( parent, data ); } +wxPageSetupDialogBase *wxGnomePrintFactory::CreatePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData * data ) +{ + return new wxGnomePageSetupDialog( parent, data ); +} + bool wxGnomePrintFactory::HasPrintSetupDialog() { return false; @@ -270,6 +278,90 @@ bool wxGnomePrintDialog::TransferDataFromWindow() return true; } +//---------------------------------------------------------------------------- +// wxGnomePageSetupDialog +//---------------------------------------------------------------------------- + +IMPLEMENT_CLASS(wxGnomePageSetupDialog, wxPageSetupDialogBase) + +wxGnomePageSetupDialog::wxGnomePageSetupDialog( wxWindow *parent, + wxPageSetupDialogData* data ) +{ + if (data) + m_pageDialogData = *data; + + wxGnomePrintNativeData *native = + (wxGnomePrintNativeData*) m_pageDialogData.GetPrintData().GetNativeData(); + + m_widget = gtk_dialog_new(); + + gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( _("Page setup") ) ); + + GtkWidget *main = gnome_paper_selector_new_with_flags( native->GetPrintConfig(), + GNOME_PAPER_SELECTOR_MARGINS|GNOME_PAPER_SELECTOR_FEED_ORIENTATION ); + gtk_container_set_border_width (GTK_CONTAINER (main), 8); + gtk_widget_show (main); + + gtk_container_add( GTK_CONTAINER (GTK_DIALOG (m_widget)->vbox), main ); + + gtk_dialog_set_has_separator (GTK_DIALOG (m_widget), TRUE); + + gtk_dialog_add_buttons (GTK_DIALOG (m_widget), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + + gtk_dialog_set_default_response (GTK_DIALOG (m_widget), + GTK_RESPONSE_OK); +} + +wxGnomePageSetupDialog::~wxGnomePageSetupDialog() +{ +} + +wxPageSetupDialogData& wxGnomePageSetupDialog::GetPageSetupDialogData() +{ + return m_pageDialogData; +} + +int wxGnomePageSetupDialog::ShowModal() +{ + // Transfer data from m_pageDialogData to native dialog + + int ret = gtk_dialog_run( GTK_DIALOG(m_widget) ); + + if (ret == GTK_RESPONSE_OK) + { + // Transfer data back to m_pageDialogData + + ret = wxID_OK; + } + else + { + ret = wxID_CANCEL; + } + + gtk_widget_destroy( m_widget ); + m_widget = NULL; + + return ret; +} + +bool wxGnomePageSetupDialog::Validate() +{ + return true; +} + +bool wxGnomePageSetupDialog::TransferDataToWindow() +{ + return true; +} + +bool wxGnomePageSetupDialog::TransferDataFromWindow() +{ + return true; +} + //---------------------------------------------------------------------------- // wxGnomePrinter //---------------------------------------------------------------------------- diff --git a/src/mac/carbon/printdlg.cpp b/src/mac/carbon/printdlg.cpp index 5ea1a82e02..38aa9582ae 100644 --- a/src/mac/carbon/printdlg.cpp +++ b/src/mac/carbon/printdlg.cpp @@ -15,6 +15,7 @@ #include "wx/object.h" #include "wx/printdlg.h" +#include "wx/mac/printdlg.h" #include "wx/dcprint.h" #include "wx/msgdlg.h" #include "wx/mac/private/print.h" @@ -22,7 +23,6 @@ // Use generic page setup dialog: use your own native one if one exists. IMPLEMENT_DYNAMIC_CLASS(wxMacPrintDialog, wxPrintDialogBase) -IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog) wxMacPrintDialog::wxMacPrintDialog() { @@ -81,22 +81,18 @@ wxDC *wxMacPrintDialog::GetPrintDC() } /* -* wxPageSetupDialog +* wxMacPageSetupDialog */ -wxPageSetupDialog::wxPageSetupDialog(): -wxDialog() -{ - m_dialogParent = NULL; -} +IMPLEMENT_CLASS(wxMacPageSetupDialog, wxPageSetupDialogBase) -wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupData *data): -wxDialog() +wxMacPageSetupDialog::wxMacPageSetupDialog(wxWindow *p, wxPageSetupDialogData *data) : +wxPageSetupDialogBase() { Create(p, data); } -bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data) +bool wxMacPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data) { m_dialogParent = p; @@ -106,17 +102,24 @@ bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupData *data) return TRUE; } -wxPageSetupDialog::~wxPageSetupDialog() +wxMacPageSetupDialog::~wxMacPageSetupDialog() { } -int wxPageSetupDialog::ShowModal() +wxPageSetupData& wxMacPageSetupDialog::GetPageSetupDialogData() +{ + return m_pageSetupData; +} + +int wxMacPageSetupDialog::ShowModal() { - m_pageSetupData.ConvertToNative() ; - int result = m_pageSetupData.GetPrintData().m_nativePrintData->ShowPageSetupDialog() ; + m_pageSetupData.ConvertToNative(); + + int result = m_pageSetupData.GetPrintData().m_nativePrintData->ShowPageSetupDialog(); + if (result == wxID_OK ) - m_pageSetupData.ConvertFromNative() ; + m_pageSetupData.ConvertFromNative(); - return result ; + return result; } diff --git a/src/mac/carbon/printmac.cpp b/src/mac/carbon/printmac.cpp index 5befe63b86..bb1901b3eb 100644 --- a/src/mac/carbon/printmac.cpp +++ b/src/mac/carbon/printmac.cpp @@ -39,6 +39,7 @@ #include "wx/dcprint.h" #include "wx/printdlg.h" +#include "wx/mac/printdlg.h" #include diff --git a/src/msw/dcprint.cpp b/src/msw/dcprint.cpp index 4de8e69a93..91e48e9c5e 100644 --- a/src/msw/dcprint.cpp +++ b/src/msw/dcprint.cpp @@ -45,6 +45,7 @@ #include "wx/dcprint.h" #include "wx/printdlg.h" +#include "wx/msw/printdlg.h" #include "math.h" #if wxUSE_COMMON_DIALOGS diff --git a/src/msw/printdlg.cpp b/src/msw/printdlg.cpp index 6a5a7e4fd5..5198ea044a 100644 --- a/src/msw/printdlg.cpp +++ b/src/msw/printdlg.cpp @@ -38,6 +38,7 @@ #include "wx/cmndata.h" #include "wx/printdlg.h" +#include "wx/msw/printdlg.h" #include "wx/dcprint.h" #include "wx/paper.h" @@ -756,23 +757,23 @@ bool wxWindowsPrintDialog::ConvertFromNative( wxPrintDialogData &data ) } // --------------------------------------------------------------------------- -// wxPageSetupDialog +// wxWidnowsPageSetupDialog // --------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxPageSetupDialog, wxDialog) +IMPLEMENT_CLASS(wxWindowsPageSetupDialog, wxPageSetupDialogBase) -wxPageSetupDialog::wxPageSetupDialog() +wxWindowsPageSetupDialog::wxWindowsPageSetupDialog() { m_dialogParent = NULL; m_pageDlg = NULL; } -wxPageSetupDialog::wxPageSetupDialog(wxWindow *p, wxPageSetupDialogData *data) +wxWindowsPageSetupDialog::wxWindowsPageSetupDialog(wxWindow *p, wxPageSetupDialogData *data) { Create(p, data); } -bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data) +bool wxWindowsPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data) { m_dialogParent = p; m_pageDlg = NULL; @@ -783,7 +784,7 @@ bool wxPageSetupDialog::Create(wxWindow *p, wxPageSetupDialogData *data) return true; } -wxPageSetupDialog::~wxPageSetupDialog() +wxWindowsPageSetupDialog::~wxWindowsPageSetupDialog() { PAGESETUPDLG *pd = (PAGESETUPDLG *)m_pageDlg; if ( pd && pd->hDevMode ) @@ -794,7 +795,7 @@ wxPageSetupDialog::~wxPageSetupDialog() delete pd; } -int wxPageSetupDialog::ShowModal() +int wxWindowsPageSetupDialog::ShowModal() { ConvertToNative( m_pageSetupData ); @@ -816,7 +817,7 @@ int wxPageSetupDialog::ShowModal() return wxID_CANCEL; } -bool wxPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data ) +bool wxWindowsPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data ) { wxWindowsPrintNativeData *native_data = (wxWindowsPrintNativeData *) data.GetPrintData().GetNativeData(); @@ -920,7 +921,7 @@ bool wxPageSetupDialog::ConvertToNative( wxPageSetupDialogData &data ) return true; } -bool wxPageSetupDialog::ConvertFromNative( wxPageSetupDialogData &data ) +bool wxWindowsPageSetupDialog::ConvertFromNative( wxPageSetupDialogData &data ) { PAGESETUPDLG *pd = (PAGESETUPDLG *) m_pageDlg; if ( !pd ) -- 2.45.2