added wxGetDisplayPPI() convenience function and wxPrintout::SetPPI*() overloads accepting single wxSize argument
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55761 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -819,6 +819,7 @@ extern void WXDLLIMPEXP_CORE wxDisplaySize(int *width, int *height);
|
||||
extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySize();
|
||||
extern void WXDLLIMPEXP_CORE wxDisplaySizeMM(int *width, int *height);
|
||||
extern wxSize WXDLLIMPEXP_CORE wxGetDisplaySizeMM();
|
||||
extern wxSize WXDLLIMPEXP_CORE wxGetDisplayPPI();
|
||||
|
||||
// Get position and size of the display workarea
|
||||
extern void WXDLLIMPEXP_CORE wxClientDisplayRect(int *x, int *y, int *width, int *height);
|
||||
|
@@ -284,8 +284,10 @@ public:
|
||||
void GetPageSizeMM(int *w, int *h) const { *w = m_pageWidthMM; *h = m_pageHeightMM; }
|
||||
|
||||
void SetPPIScreen(int x, int y) { m_PPIScreenX = x; m_PPIScreenY = y; }
|
||||
void SetPPIScreen(const wxSize& ppi) { SetPPIScreen(ppi.x, ppi.y); }
|
||||
void GetPPIScreen(int *x, int *y) const { *x = m_PPIScreenX; *y = m_PPIScreenY; }
|
||||
void SetPPIPrinter(int x, int y) { m_PPIPrinterX = x; m_PPIPrinterY = y; }
|
||||
void SetPPIPrinter(const wxSize& ppi) { SetPPIPrinter(ppi.x, ppi.y); }
|
||||
void GetPPIPrinter(int *x, int *y) const { *x = m_PPIPrinterX; *y = m_PPIPrinterY; }
|
||||
|
||||
void SetPaperRectPixels(const wxRect& paperRectPixels) { m_paperRectPixels = paperRectPixels; }
|
||||
|
@@ -852,6 +852,18 @@ void wxClientDisplayRect(int* x, int* y, int* width, int* height);
|
||||
wxRect wxGetClientDisplayRect();
|
||||
//@}
|
||||
|
||||
/** @ingroup group_funcmacro_gdi */
|
||||
//@{
|
||||
/**
|
||||
Returns the display resolution in pixels per inch.
|
||||
|
||||
@header{wx/gdicmn.h}
|
||||
|
||||
@since 2.9.0
|
||||
*/
|
||||
wxSize wxGetDisplayPPI();
|
||||
//@}
|
||||
|
||||
/** @ingroup group_funcmacro_gdi */
|
||||
//@{
|
||||
/**
|
||||
|
@@ -880,6 +880,15 @@ wxSize wxGetDisplaySizeMM()
|
||||
return wxSize(x, y);
|
||||
}
|
||||
|
||||
wxSize wxGetDisplayPPI()
|
||||
{
|
||||
const wxSize pixels = wxGetDisplaySize();
|
||||
const wxSize mm = wxGetDisplaySizeMM();
|
||||
|
||||
return wxSize((pixels.x * 25.4) / mm.x,
|
||||
(pixels.y * 25.4) / mm.y);
|
||||
}
|
||||
|
||||
wxResourceCache::~wxResourceCache ()
|
||||
{
|
||||
wxList::compatibility_iterator node = GetFirst ();
|
||||
|
@@ -872,11 +872,7 @@ bool wxGnomePrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt )
|
||||
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->SetPPIScreen(wxGetDisplayPPI());
|
||||
printout->SetPPIPrinter( dc->GetResolution(),
|
||||
dc->GetResolution() );
|
||||
|
||||
@@ -2099,12 +2095,8 @@ void wxGnomePrintPreview::DetermineScaling()
|
||||
|
||||
if (paper)
|
||||
{
|
||||
wxSize ScreenPixels = wxGetDisplaySize();
|
||||
wxSize ScreenMM = wxGetDisplaySizeMM();
|
||||
m_previewPrintout->SetPPIScreen(wxGetDisplayPPI());
|
||||
|
||||
m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
|
||||
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
|
||||
|
||||
int resolution = DPI;
|
||||
m_previewPrintout->SetPPIPrinter( resolution, resolution );
|
||||
|
||||
|
@@ -926,11 +926,8 @@ void wxGtkPrinter::BeginPrint(wxPrintout *printout, GtkPrintOperation *operation
|
||||
}
|
||||
return;
|
||||
}
|
||||
wxSize ScreenPixels = wxGetDisplaySize();
|
||||
wxSize ScreenMM = wxGetDisplaySizeMM();
|
||||
|
||||
printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
|
||||
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
|
||||
printout->SetPPIScreen(wxGetDisplayPPI());
|
||||
printout->SetPPIPrinter( printDC->GetResolution(),
|
||||
printDC->GetResolution() );
|
||||
|
||||
@@ -2366,12 +2363,7 @@ void wxGtkPrintPreview::DetermineScaling()
|
||||
|
||||
if (paper)
|
||||
{
|
||||
wxSize ScreenPixels = wxGetDisplaySize();
|
||||
wxSize ScreenMM = wxGetDisplaySizeMM();
|
||||
|
||||
m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
|
||||
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
|
||||
|
||||
m_previewPrintout->SetPPIScreen(wxGetDisplayPPI());
|
||||
m_previewPrintout->SetPPIPrinter( m_resolution, m_resolution );
|
||||
|
||||
// Get width and height in points (1/72th of an inch)
|
||||
|
Reference in New Issue
Block a user