X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/34da0970a018b4b0828248028040ca339868ed4e..634903fd0431c5f09372a9ad99005cb4b2c5cd34:/src/common/prntbase.cpp?ds=sidebyside diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index 9a16bf0eff..23e49e721e 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -22,10 +22,6 @@ #include "wx/defs.h" -#ifdef __WXMSW__ -#define __GOOD_COMPILER__ -#endif - #ifndef WX_PRECOMP #include "wx/utils.h" #include "wx/dc.h" @@ -193,7 +189,7 @@ wxPreviewCanvas::wxPreviewCanvas(wxPrintPreviewBase *preview, wxWindow *parent, m_printPreview = preview; SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); - SetScrollbars(40, 40, 100, 100); + SetScrollbars(15, 18, 100, 100); } wxPreviewCanvas::~wxPreviewCanvas() @@ -203,6 +199,7 @@ wxPreviewCanvas::~wxPreviewCanvas() void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); + PrepareDC( dc ); if (m_printPreview) { @@ -225,7 +222,7 @@ void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event) */ 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) @@ -262,7 +259,7 @@ void wxPreviewControlBar::OnPaint(wxPaintEvent& WXUNUSED(event)) 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); @@ -313,10 +310,9 @@ void wxPreviewControlBar::OnZoom(wxCommandEvent& WXUNUSED(event)) void wxPreviewControlBar::CreateButtons() { -#ifdef __GOOD_COMPILER__ // Robert Roebling - SetSize(0, 0, 400, 40); + /* #ifdef __WXMSW__ int fontSize = 9; #else @@ -324,14 +320,24 @@ void wxPreviewControlBar::CreateButtons() #endif wxFont buttonFont(fontSize, wxSWISS, wxNORMAL, wxBOLD); - SetButtonFont(buttonFont); + SetFont(buttonFont); + */ int buttonWidth = 65; - int buttonHeight = 24; +#ifdef __WXGTK__ + int buttonHeight = -1; +#else + int buttonHeight = 24; +#endif 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)); @@ -359,9 +365,33 @@ void wxPreviewControlBar::CreateButtons() x += gap + buttonWidth; } - static wxString choices[] = { "10%", "20%", "25%", "30%", "35%", "40%", "45%", "50%", "55%", "60%", - "65%", "70%", "75%", "80%", "85%", "90%", "95%", "100%", "110%", "120%", "150%", "200%" }; - int n = 22; + // Yes, this look stupid, but this is because gcc gives up otherwise. + wxString *choices = new wxString[23]; + choices[0] = "10%"; + choices[1] = "15%"; + choices[2] = "20%"; + choices[3] = "25%"; + choices[4] = "30%"; + choices[5] = "35%"; + choices[6] = "40%"; + choices[7] = "45%"; + choices[8] = "50%"; + choices[9] = "55%"; + choices[10] = "60%"; + choices[11] = "65%"; + choices[12] = "70%"; + choices[13] = "75%"; + choices[14] = "80%"; + choices[15] = "85%"; + choices[16] = "90%"; + choices[17] = "95%"; + choices[18] = "100%"; + choices[19] = "110%"; + choices[20] = "120%"; + choices[21] = "150%"; + choices[22] = "200%"; + + int n = 23; if (m_buttonFlags & wxPREVIEW_ZOOM) { m_zoomControl = new wxChoice(this, wxID_PREVIEW_ZOOM, wxPoint(x, y), @@ -369,35 +399,29 @@ void wxPreviewControlBar::CreateButtons() SetZoomControl(m_printPreview->GetZoom()); } - m_closeButton->SetDefault(); - -#endif + delete[] choices; + + // m_closeButton->SetDefault(); } void wxPreviewControlBar::SetZoomControl(int zoom) { -#ifdef __GOOD_COMPILER__ // Robert Roebling char buf[20]; sprintf(buf, "%d%%", zoom); if (m_zoomControl) m_zoomControl->SetStringSelection(buf); -#endif } int wxPreviewControlBar::GetZoomControl() { -#ifdef __GOOD_COMPILER__ // Robert Roebling 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; return (int)atoi(buf); } else return 0; -#else - return 0; -#endif } @@ -405,25 +429,25 @@ int wxPreviewControlBar::GetZoomControl() * 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) { -#ifdef __GOOD_COMPILER__ // Robert Roebling m_printPreview = preview; m_controlBar = NULL; m_previewCanvas = NULL; -#endif } wxPreviewFrame::~wxPreviewFrame() { } -bool wxPreviewFrame::OnClose() +void wxPreviewFrame::OnCloseWindow(wxCloseEvent& event) { -#ifdef __GOOD_COMPILER__ // Robert Roebling - MakeModal(FALSE); // Need to delete the printout and the print preview @@ -436,17 +460,12 @@ bool wxPreviewFrame::OnClose() m_printPreview->SetFrame(NULL); } delete m_printPreview; - return TRUE; -#else - return FALSE; -#endif + + Destroy(); } void wxPreviewFrame::Initialize() { - -#ifdef __GOOD_COMPILER__ // Robert Roebling - CreateStatusBar(); CreateCanvas(); @@ -462,7 +481,7 @@ void wxPreviewFrame::Initialize() // int w, h; // m_controlBar->GetSize(&w, &h); int h; -#ifdef __WXMSW__ +#if (defined(__WXMSW__) || defined(__WXGTK__)) h = 40; #else h = 60; @@ -490,30 +509,21 @@ void wxPreviewFrame::Initialize() MakeModal(TRUE); Layout(); - -#endif } void wxPreviewFrame::CreateCanvas() { -#ifdef __GOOD_COMPILER__ // Robert Roebling - m_previewCanvas = new wxPreviewCanvas(m_printPreview, this); - -#endif } void wxPreviewFrame::CreateControlBar() { -#ifdef __GOOD_COMPILER__ // Robert Roebling - long buttons = wxPREVIEW_DEFAULT; if (m_printPreview->GetPrintoutForPrinting()) buttons |= wxPREVIEW_PRINT; m_controlBar = new wxPreviewControlBar(m_printPreview, buttons, this, wxPoint(0, 0), wxSize(400, 40)); m_controlBar->CreateButtons(); -#endif } /* @@ -522,9 +532,6 @@ void wxPreviewFrame::CreateControlBar() wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printoutForPrinting, wxPrintData *data) { - -#ifdef __GOOD_COMPILER__ // Robert Roebling - m_isOk = TRUE; m_previewPrintout = printout; if (m_previewPrintout) @@ -549,27 +556,20 @@ wxPrintPreviewBase::wxPrintPreviewBase(wxPrintout *printout, wxPrintout *printou // Get some parameters from the printout, if defined int selFrom, selTo; printout->GetPageInfo(&m_minPage, &m_maxPage, &selFrom, &selTo); - -#endif } wxPrintPreviewBase::~wxPrintPreviewBase() { -#ifdef __GOOD_COMPILER__ // Robert Roebling - if (m_previewPrintout) delete m_previewPrintout; if (m_previewBitmap) delete m_previewBitmap; if (m_printPrintout) delete m_printPrintout; - -#endif } bool wxPrintPreviewBase::SetCurrentPage(int pageNum) { -#ifdef __GOOD_COMPILER__ // Robert Roebling if (m_currentPage == pageNum) return TRUE; @@ -585,16 +585,11 @@ bool wxPrintPreviewBase::SetCurrentPage(int pageNum) RenderPage(pageNum); m_previewCanvas->Refresh(); } - -#endif return TRUE; } bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc) { - -#ifdef __GOOD_COMPILER__ // Robert Roebling - DrawBlankPage(canvas, dc); if (!m_previewBitmap) @@ -613,7 +608,7 @@ bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc) double actualWidth = (zoomScale*m_pageWidth*m_previewScale); // float actualHeight = (float)(zoomScale*m_pageHeight*m_previewScale); - int x = ((canvasWidth - actualWidth)/2.0); + int x = (int) ((canvasWidth - actualWidth)/2.0); if (x < m_leftMargin) x = m_leftMargin; int y = m_topMargin; @@ -625,8 +620,6 @@ bool wxPrintPreviewBase::PaintPage(wxWindow *canvas, wxDC& dc) temp_dc.SelectObject(wxNullBitmap); -#endif - return TRUE; } @@ -634,8 +627,6 @@ bool wxPrintPreviewBase::RenderPage(int pageNum) { int canvasWidth, canvasHeight; -#ifdef __GOOD_COMPILER__ // Robert Roebling - if (!m_previewCanvas) { wxMessageBox(_("wxPrintPreviewBase::RenderPage: must use wxPrintPreviewBase::SetCanvas to let me know about the canvas!"), @@ -694,7 +685,6 @@ bool wxPrintPreviewBase::RenderPage(int pageNum) m_previewPrintout->SetDC(NULL); memoryDC.SelectObject(wxNullBitmap); -#endif char buf[200]; if (m_maxPage != 0) @@ -711,9 +701,6 @@ bool wxPrintPreviewBase::RenderPage(int pageNum) bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc) { - -#ifdef __GOOD_COMPILER__ // Robert Roebling - int canvasWidth, canvasHeight; canvas->GetSize(&canvasWidth, &canvasHeight); @@ -730,23 +717,30 @@ bool wxPrintPreviewBase::DrawBlankPage(wxWindow *canvas, wxDC& dc) int shadowOffset = 4; dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxBLACK_BRUSH); - dc.DrawRectangle(x-1 + shadowOffset, y-1 + shadowOffset, actualWidth+2, actualHeight+2); +/* + dc.DrawRectangle((int)(x-1 + shadowOffset), (int)(y-1 + shadowOffset), (int)(actualWidth+2), (int)(actualHeight+2)); +*/ + dc.DrawRectangle((int)(x + shadowOffset), (int)(y + actualHeight+1), (int)(actualWidth), shadowOffset); + dc.DrawRectangle((int)(x + actualWidth), (int)(y + shadowOffset), shadowOffset, (int)(actualHeight)); // Draw blank page allowing for 1-pixel border AROUND the actual page dc.SetPen(*wxBLACK_PEN); dc.SetBrush(*wxWHITE_BRUSH); - - dc.DrawRectangle(x-1, y-1, actualWidth+2, actualHeight+2); +/* + wxRegion update_region = canvas->GetUpdateRegion(); + wxRect r = update_region.GetBox(); + + printf( "x: %d y: %d w: %d h: %d.\n", (int)r.x, (int)r.y, (int)r.width, (int)r.height ); +*/ + + dc.DrawRectangle((int)(x-2), (int)(y-1), (int)(actualWidth+3), (int)(actualHeight+2)); -#endif - return TRUE; } void wxPrintPreviewBase::SetZoom(int percent) { -#ifdef __GOOD_COMPILER__ // Robert Roebling if (m_currentZoom == percent) return; @@ -763,6 +757,4 @@ void wxPrintPreviewBase::SetZoom(int percent) m_previewCanvas->Clear(); m_previewCanvas->Refresh(); } -#endif - }