#include "wx/prntbase.h"
#include "wx/dcprint.h"
#include "wx/printdlg.h"
+#include "wx/module.h"
#include <stdlib.h>
#include <string.h>
IMPLEMENT_CLASS(wxPreviewControlBar, wxWindow)
IMPLEMENT_CLASS(wxPreviewFrame, wxFrame)
IMPLEMENT_CLASS(wxPrintPreviewBase, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperType, wxObject)
BEGIN_EVENT_TABLE(wxPrintAbortDialog, wxDialog)
EVT_BUTTON(wxID_CANCEL, wxPrintAbortDialog::OnCancel)
*/
BEGIN_EVENT_TABLE(wxPreviewControlBar, wxPanel)
- EVT_BUTTON(wxID_PREVIEW_CLOSE, wxPreviewControlBar::OnClose)
+ EVT_BUTTON(wxID_PREVIEW_CLOSE, wxPreviewControlBar::OnWindowClose)
EVT_BUTTON(wxID_PREVIEW_PRINT, wxPreviewControlBar::OnPrint)
EVT_BUTTON(wxID_PREVIEW_PREVIOUS, wxPreviewControlBar::OnPrevious)
EVT_BUTTON(wxID_PREVIEW_NEXT, wxPreviewControlBar::OnNext)
dc.DrawLine( 0, h-1, w, h-1 );
}
-void wxPreviewControlBar::OnClose(wxCommandEvent& WXUNUSED(event))
+void wxPreviewControlBar::OnWindowClose(wxCommandEvent& WXUNUSED(event))
{
wxPreviewFrame *frame = (wxPreviewFrame *)GetParent();
frame->Close(TRUE);
{
SetSize(0, 0, 400, 40);
+ /*
#ifdef __WXMSW__
int fontSize = 9;
#else
wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD);
SetFont(buttonFont);
+ */
int buttonWidth = 65;
#ifdef __WXGTK__
int x = 5;
int y = 5;
+
+#ifdef __WXMOTIF__
+ int gap = 15;
+#else
int gap = 5;
+#endif
m_closeButton = new wxButton(this, wxID_PREVIEW_CLOSE, _("Close"),
wxPoint(x, y), wxSize(buttonWidth, buttonHeight));
delete[] choices;
- m_closeButton->SetDefault();
+ // m_closeButton->SetDefault();
}
void wxPreviewControlBar::SetZoomControl(int zoom)
int wxPreviewControlBar::GetZoomControl()
{
char buf[20];
- if (m_zoomControl && m_zoomControl->GetStringSelection())
+ if (m_zoomControl && (m_zoomControl->GetStringSelection() != ""))
{
strcpy(buf, m_zoomControl->GetStringSelection());
buf[strlen(buf) - 1] = 0;
* Preview frame
*/
+BEGIN_EVENT_TABLE(wxPreviewFrame, wxFrame)
+ EVT_CLOSE(wxPreviewFrame::OnCloseWindow)
+END_EVENT_TABLE()
+
wxPreviewFrame::wxPreviewFrame(wxPrintPreviewBase *preview, wxFrame *parent, const wxString& title,
const wxPoint& pos, const wxSize& size, long style, const wxString& name):
wxFrame(parent, -1, title, pos, size, style, name)
{
}
-bool wxPreviewFrame::OnClose()
+void wxPreviewFrame::OnCloseWindow(wxCloseEvent& event)
{
MakeModal(FALSE);
m_printPreview->SetFrame(NULL);
}
delete m_printPreview;
- return TRUE;
+
+ Destroy();
}
void wxPreviewFrame::Initialize()
m_previewCanvas->Refresh();
}
}
+
+/*
+ * Paper size database for PostScript or where the generic page setup dialog is
+ * needed
+ */
+
+wxPrintPaperType::wxPrintPaperType(const char *name, int wmm, int hmm, int wp, int hp)
+{
+ widthMM = wmm;
+ heightMM = hmm;
+ widthPixels = wp;
+ heightPixels = hp;
+ pageName = copystring(name);
+}
+
+wxPrintPaperType::~wxPrintPaperType()
+{
+ delete[] pageName;
+}
+
+/*
+ * Print paper database for PostScript
+ */
+
+wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase*) NULL;
+
+#if !USE_SHARED_LIBRARIES
+IMPLEMENT_DYNAMIC_CLASS(wxPrintPaperDatabase, wxList)
+#endif
+
+wxPrintPaperDatabase::wxPrintPaperDatabase():wxList(wxKEY_STRING)
+{
+ DeleteContents(TRUE);
+}
+
+wxPrintPaperDatabase::~wxPrintPaperDatabase()
+{
+}
+
+void wxPrintPaperDatabase::CreateDatabase()
+{
+ // Need correct values for page size in pixels.
+ // Each unit is one 'point' = 1/72 of an inch.
+ // NOTE: WE NEED ALSO TO MAKE ADJUSTMENTS WHEN TRANSLATING
+ // in wxPostScriptDC code, so we can start from top left.
+ // So access this database and translate by appropriate number
+ // of points for this paper size. OR IS IT OK ALREADY?
+ // Can't remember where the PostScript origin is by default.
+ // Heck, someone will know how to make it hunky-dory...
+ // JACS 25/5/95
+
+ AddPaperType(_("A4 210 x 297 mm"), 210, 297, 595, 842);
+ AddPaperType(_("A3 297 x 420 mm"), 297, 420, 842, 1191);
+ AddPaperType(_("Letter 8 1/2 x 11 in"), 216, 279, 612, 791);
+ AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 612, 1009);
+
+/*
+ This is for 100 ppi
+
+ AddPaperType(_("A4 210 x 297 mm"), 210, 297, 210*4, 297*4 );
+ AddPaperType(_("A3 297 x 420 mm"), 297, 420, 297*4, 420*4 );
+ AddPaperType(_("Letter 8 1/2 x 11 in"), 216, 279, 216*4, 279*4 );
+ AddPaperType(_("Legal 8 1/2 x 14 in"), 216, 356, 216*4, 356*4 );
+*/
+}
+
+void wxPrintPaperDatabase::ClearDatabase()
+{
+ Clear();
+}
+
+void wxPrintPaperDatabase::AddPaperType(const char *name, int wmm, int hmm, int wp, int hp)
+{
+ Append(name, new wxPrintPaperType(name, wmm, hmm, wp, hp));
+}
+
+wxPrintPaperType *wxPrintPaperDatabase::FindPaperType(const char *name)
+{
+ wxNode *node = Find(name);
+ if (node)
+ return (wxPrintPaperType *)node->Data();
+ else
+ return (wxPrintPaperType *) NULL;
+}
+
+// A module to allow initialization/cleanup of print paper
+// things without calling these functions from app.cpp.
+
+class WXDLLEXPORT wxPrintBaseModule: public wxModule
+{
+DECLARE_DYNAMIC_CLASS(wxPrintBaseModule)
+public:
+ wxPrintBaseModule() {}
+ bool OnInit();
+ void OnExit();
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxPrintBaseModule, wxModule)
+
+/*
+ * Initialization/cleanup module
+ */
+
+bool wxPrintBaseModule::OnInit()
+{
+ wxThePrintPaperDatabase = new wxPrintPaperDatabase;
+ wxThePrintPaperDatabase->CreateDatabase();
+
+ return TRUE;
+}
+
+void wxPrintBaseModule::OnExit()
+{
+ delete wxThePrintPaperDatabase;
+ wxThePrintPaperDatabase = NULL;
+}
+
+