implemented wxWindowDC and wxClientDC::GetSize() properly (fixes bug #503022)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -123,6 +123,7 @@ wxMSW:
|
|||||||
- showing a dialog from EVT_RADIOBUTTON handler doesn't lead to an infinite
|
- showing a dialog from EVT_RADIOBUTTON handler doesn't lead to an infinite
|
||||||
recursion any more
|
recursion any more
|
||||||
- wxTextCtrl with wxTE_RICH flag scrolls to the end when text is appended to it
|
- wxTextCtrl with wxTE_RICH flag scrolls to the end when text is appended to it
|
||||||
|
- wxWindowDC and wxClientDC::GetSize() works correctly now
|
||||||
|
|
||||||
wxGTK:
|
wxGTK:
|
||||||
|
|
||||||
|
@@ -49,6 +49,9 @@ protected:
|
|||||||
// intiialize the newly created DC
|
// intiialize the newly created DC
|
||||||
void InitDC();
|
void InitDC();
|
||||||
|
|
||||||
|
// override some base class virtuals
|
||||||
|
virtual void DoGetSize(int *width, int *height) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
DECLARE_DYNAMIC_CLASS(wxWindowDC)
|
||||||
};
|
};
|
||||||
@@ -67,6 +70,9 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void InitDC();
|
void InitDC();
|
||||||
|
|
||||||
|
// override some base class virtuals
|
||||||
|
virtual void DoGetSize(int *width, int *height) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
DECLARE_DYNAMIC_CLASS(wxClientDC)
|
||||||
};
|
};
|
||||||
|
@@ -1923,8 +1923,30 @@ void wxDC::DoGetSizeMM(int *w, int *h) const
|
|||||||
if (!GetHDC()) return;
|
if (!GetHDC()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( w ) *w = ::GetDeviceCaps(GetHdc(), HORZSIZE);
|
// if we implement it in terms of DoGetSize() instead of directly using the
|
||||||
if ( h ) *h = ::GetDeviceCaps(GetHdc(), VERTSIZE);
|
// results returned by GetDeviceCaps(HORZ/VERTSIZE) as was done before, it
|
||||||
|
// will also work for wxWindowDC and wxClientDC even though their size is
|
||||||
|
// not the same as the total size of the screen
|
||||||
|
int wPixels, hPixels;
|
||||||
|
DoGetSize(&wPixels, &hPixels);
|
||||||
|
|
||||||
|
if ( w )
|
||||||
|
{
|
||||||
|
int wTotal = ::GetDeviceCaps(GetHdc(), HORZRES);
|
||||||
|
|
||||||
|
wxCHECK_RET( wTotal, _T("0 width device?") );
|
||||||
|
|
||||||
|
*w = (wPixels * ::GetDeviceCaps(GetHdc(), HORZSIZE)) / wTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( h )
|
||||||
|
{
|
||||||
|
int hTotal = ::GetDeviceCaps(GetHdc(), VERTRES);
|
||||||
|
|
||||||
|
wxCHECK_RET( hTotal, _T("0 height device?") );
|
||||||
|
|
||||||
|
*h = (hPixels * ::GetDeviceCaps(GetHdc(), VERTSIZE)) / hTotal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxDC::GetPPI() const
|
wxSize wxDC::GetPPI() const
|
||||||
|
@@ -120,6 +120,13 @@ void wxWindowDC::InitDC()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxWindowDC::DoGetSize(int *width, int *height) const
|
||||||
|
{
|
||||||
|
wxCHECK_RET( m_canvas, _T("wxWindowDC without a window?") );
|
||||||
|
|
||||||
|
m_canvas->GetSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxClientDC
|
// wxClientDC
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -165,6 +172,13 @@ wxClientDC::~wxClientDC()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxClientDC::DoGetSize(int *width, int *height) const
|
||||||
|
{
|
||||||
|
wxCHECK_RET( m_canvas, _T("wxClientDC without a window?") );
|
||||||
|
|
||||||
|
m_canvas->GetClientSize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxPaintDC
|
// wxPaintDC
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user