void wxDFBDCImpl::DFBInit(const wxIDirectFBSurfacePtr& surface) { m_surface = surface; wxCHECK_RET( surface != NULL, "invalid surface" ); m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / (double)wxGetDisplaySizeMM().GetWidth(); m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / (double)wxGetDisplaySizeMM().GetHeight(); SetFont(DEFAULT_FONT); SetPen(DEFAULT_PEN); SetBrush(DEFAULT_BRUSH); }
double OCPNPlatform::GetDisplaySizeMM() { double ret = wxGetDisplaySizeMM().GetWidth(); #ifdef __WXMSW__ int w,h; bool GetWindowsMonitorSize( int *w, int *h ); if( GetWindowsMonitorSize( &w, &h) ){ if(w > 100) // sanity check ret = w; } #endif #ifdef __WXOSX__ ret = GetMacMonitorSize(); #endif #ifdef __OCPN__ANDROID__ ret = GetAndroidDisplaySize(); #endif wxString msg; msg.Printf(_T("Detected display size (horizontal): %d mm"), (int) ret); wxLogMessage(msg); return ret; }
void wxDisplaySizeMM(int *width, int *height) { const wxSize size = wxGetDisplaySizeMM(); if ( width ) *width = size.x; if ( height ) *height = size.y; }
wxSize wxGetDisplayPPI() { const wxSize pixels = wxGetDisplaySize(); const wxSize mm = wxGetDisplaySizeMM(); return wxSize((int)((pixels.x * inches2mm) / mm.x), (int)((pixels.y * inches2mm) / mm.y)); }
wxDC::wxDC() { m_ok = FALSE; m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / (double)wxGetDisplaySizeMM().GetWidth(); m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / (double)wxGetDisplaySizeMM().GetHeight(); m_needComputeScaleX = FALSE; /* not used yet */ m_needComputeScaleY = FALSE; /* not used yet */ m_logicalFunction = wxCOPY; m_pen = *wxBLACK_PEN; m_font = *wxNORMAL_FONT; m_brush = *wxWHITE_BRUSH; }
void wxPostScriptPrintPreview::DetermineScaling() { wxPaperSize paperType = m_printDialogData.GetPrintData().GetPaperId(); if (paperType == wxPAPER_NONE) paperType = wxPAPER_NONE; wxPrintPaperType *paper = wxThePrintPaperDatabase->FindPaperType(paperType); if (!paper) paper = wxThePrintPaperDatabase->FindPaperType(wxPAPER_A4); if (paper) { wxSize ScreenPixels = wxGetDisplaySize(); wxSize ScreenMM = wxGetDisplaySizeMM(); int resolution = 600; // TODO, this is correct, but get this from wxPSDC somehow m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); m_previewPrintout->SetPPIPrinter( resolution, resolution ); wxSize sizeDevUnits(paper->GetSizeDeviceUnits()); sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * resolution / 72.0); sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * resolution / 72.0); wxSize sizeTenthsMM(paper->GetSize()); wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10); // If in landscape mode, we need to swap the width and height. if ( m_printDialogData.GetPrintData().GetOrientation() == wxLANDSCAPE ) { m_pageWidth = sizeDevUnits.y; m_pageHeight = sizeDevUnits.x; m_previewPrintout->SetPageSizeMM(sizeMM.y, sizeMM.x); } else { m_pageWidth = sizeDevUnits.x; m_pageHeight = sizeDevUnits.y; m_previewPrintout->SetPageSizeMM(sizeMM.x, sizeMM.y); } m_previewPrintout->SetPageSizePixels(m_pageWidth, m_pageHeight); m_previewPrintout->SetPaperRectPixels(wxRect(0, 0, m_pageWidth, m_pageHeight)); // At 100%, the page should look about page-size on the screen. m_previewScaleX = (float)0.8 * 72.0 / (float)resolution; m_previewScaleY = m_previewScaleX; } }
// update device_window size data when size changes void view::OnSize(wxSizeEvent & event) { this->GetClientSize( &this->m_device_window.m_size_px.x, &this->m_device_window.m_size_px.y ); // find window size in mm by getting size of pixel on display // may be an ondisplay change function so dont need to continaully update vect2_i display_size_in_px; wxDisplaySize(&display_size_in_px.x,&display_size_in_px.y); wxSize detail_display_size_mm = wxGetDisplaySizeMM(); vect2_mm display_size_in_mm{mm{detail_display_size_mm.x},mm{detail_display_size_mm.y}}; this->m_device_window.m_size_mm.x = (this->m_device_window.m_size_px.x * display_size_in_mm.x) / display_size_in_px.x; this->m_device_window.m_size_mm.y = (this->m_device_window.m_size_px.y * display_size_in_mm.y) / display_size_in_px.y; this->Refresh(); }
bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt) { sm_abortIt = false; sm_abortWindow = NULL; if (!printout) { sm_lastError = wxPRINTER_ERROR; return false; } if (m_printDialogData.GetMinPage() < 1) m_printDialogData.SetMinPage(1); if (m_printDialogData.GetMaxPage() < 1) m_printDialogData.SetMaxPage(9999); // Create a suitable device context wxDC *dc; if (prompt) { dc = PrintDialog(parent); if (!dc) return false; } else { dc = new wxPostScriptDC(GetPrintDialogData().GetPrintData()); } // May have pressed cancel. if (!dc || !dc->IsOk()) { if (dc) delete dc; sm_lastError = wxPRINTER_ERROR; return false; } wxSize ScreenPixels = wxGetDisplaySize(); wxSize ScreenMM = wxGetDisplaySizeMM(); printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()), (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) ); printout->SetPPIPrinter( dc->GetResolution(), dc->GetResolution() ); // Set printout parameters printout->SetDC(dc); int w, h; dc->GetSize(&w, &h); printout->SetPageSizePixels((int)w, (int)h); printout->SetPaperRectPixels(wxRect(0, 0, w, h)); int mw, mh; dc->GetSizeMM(&mw, &mh); printout->SetPageSizeMM((int)mw, (int)mh); // Create an abort window wxBeginBusyCursor(); printout->OnPreparePrinting(); // Get some parameters from the printout, if defined int fromPage, toPage; int minPage, maxPage; printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage); if (maxPage == 0) { sm_lastError = wxPRINTER_ERROR; wxEndBusyCursor(); return false; } // Only set min and max, because from and to have been // set by the user m_printDialogData.SetMinPage(minPage); m_printDialogData.SetMaxPage(maxPage); if (m_printDialogData.GetFromPage() < minPage) m_printDialogData.SetFromPage( minPage ); if (m_printDialogData.GetToPage() > maxPage) m_printDialogData.SetToPage( maxPage ); int pagesPerCopy = m_printDialogData.GetToPage()-m_printDialogData.GetFromPage()+1, totalPages = pagesPerCopy * m_printDialogData.GetNoCopies(), printedPages = 0; // Open the progress bar dialog wxProgressDialog *progressDialog = new wxProgressDialog ( printout->GetTitle(), _("Printing..."), totalPages, parent, wxPD_CAN_ABORT|wxPD_AUTO_HIDE|wxPD_APP_MODAL); printout->OnBeginPrinting(); sm_lastError = wxPRINTER_NO_ERROR; bool keepGoing = true; int copyCount; for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++) { if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage())) { wxEndBusyCursor(); wxLogError(_("Could not start printing.")); sm_lastError = wxPRINTER_ERROR; break; } if (sm_abortIt) { sm_lastError = wxPRINTER_CANCELLED; break; } int pn; for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn); pn++) { if (sm_abortIt) { keepGoing = false; sm_lastError = wxPRINTER_CANCELLED; break; } else { wxString msg; msg.Printf(_("Printing page %d..."), printedPages+1); if(progressDialog->Update(printedPages++, msg)) { dc->StartPage(); printout->OnPrintPage(pn); dc->EndPage(); } else { sm_abortIt = true; sm_lastError = wxPRINTER_CANCELLED; keepGoing = false; } } wxYield(); } printout->OnEndDocument(); } printout->OnEndPrinting(); delete progressDialog; wxEndBusyCursor(); delete dc; return (sm_lastError == wxPRINTER_NO_ERROR); }
//--------------------------------------------------------------- IsoLine::IsoLine(double val, double coeff, double offset, const GribRecord *rec_) { if(wxGetDisplaySize().x > 0){ m_pixelMM = (double)wxGetDisplaySizeMM().x / wxGetDisplaySize().x; m_pixelMM = wxMax(.02, m_pixelMM); // protect against bad data } else m_pixelMM = 0.27; // semi-standard number... value = val/coeff-offset; rec = rec_; W = rec_->getNi(); H = rec_->getNj(); //--------------------------------------------------------- // Génère la liste des segments. extractIsoLine(rec_); value = val; if(trace.size() == 0) return; // Join the isoline segments into a nice list // Which is end-to-end continuous and unidirectional // Create a master wxList of the trace list std::list<Segment *>::iterator it; for (it=trace.begin(); it!=trace.end(); it++) { Segment *seg = *it; seg->bUsed = false; m_seglist.Append(*it); } // Isoline may be discontinuous.... // So build a list of continuous segments bool bdone = false; while(!bdone) { MySegList *ps = BuildContinuousSegment(); m_SegListList.Append(ps); MySegList::Node *node; Segment *seg; // recreate the master list, removing used segs node = m_seglist.GetFirst(); while(node) { seg = node->GetData(); if(seg->bUsed) { m_seglist.Erase(node); node = m_seglist.GetFirst(); } else node = node->GetNext(); } if(0 == m_seglist.GetCount()) bdone = true; } ///printf("create Isobar : press=%4.0f long=%d\n", pressure/100, trace.size()); }