From 376aa62a5d8ead9dc9d0ab3af6628862a21137ed Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 30 Oct 2000 16:43:37 +0000 Subject: [PATCH] wxDC::GetSize() should work now in wxGTK git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8655 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/dc.h | 1 - include/wx/gtk/dcclient.h | 25 ++++++++++++++----------- include/wx/gtk/dcscreen.h | 11 +++++++---- include/wx/gtk1/dc.h | 1 - include/wx/gtk1/dcclient.h | 25 ++++++++++++++----------- include/wx/gtk1/dcscreen.h | 11 +++++++---- src/gtk/dc.cpp | 6 ------ src/gtk/dcclient.cpp | 7 +++++++ src/gtk/dcscreen.cpp | 4 ++++ src/gtk1/dc.cpp | 6 ------ src/gtk1/dcclient.cpp | 7 +++++++ src/gtk1/dcscreen.cpp | 4 ++++ 12 files changed, 64 insertions(+), 44 deletions(-) diff --git a/include/wx/gtk/dc.h b/include/wx/gtk/dc.h index 78c421c9c4..8c447ae426 100644 --- a/include/wx/gtk/dc.h +++ b/include/wx/gtk/dc.h @@ -134,7 +134,6 @@ public: protected: // base class pure virtuals implemented here virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSizeMM(int* width, int* height) const; public: diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h index f91eae7dc9..2168e181d7 100644 --- a/include/wx/gtk/dcclient.h +++ b/include/wx/gtk/dcclient.h @@ -40,7 +40,8 @@ public: virtual bool CanDrawBitmap() const { return TRUE; } virtual bool CanGetTextExtent() const { return TRUE; } -//protected: +protected: + virtual void DoGetSize(int *width, int *height) const; virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const; @@ -78,6 +79,8 @@ public: wxCoord *descent = (wxCoord *) NULL, wxCoord *externalLeading = (wxCoord *) NULL, wxFont *theFont = (wxFont *) NULL) const; + +public: virtual wxCoord GetCharWidth() const; virtual wxCoord GetCharHeight() const; @@ -135,31 +138,31 @@ private: }; //----------------------------------------------------------------------------- -// wxPaintDC +// wxClientDC //----------------------------------------------------------------------------- -class wxPaintDC : public wxWindowDC +class wxClientDC : public wxWindowDC { public: - wxPaintDC(); - wxPaintDC( wxWindow *win ); + wxClientDC() { } + wxClientDC( wxWindow *win ); private: - DECLARE_DYNAMIC_CLASS(wxPaintDC) + DECLARE_DYNAMIC_CLASS(wxClientDC) }; //----------------------------------------------------------------------------- -// wxClientDC +// wxPaintDC //----------------------------------------------------------------------------- -class wxClientDC : public wxWindowDC +class wxPaintDC : public wxClientDC { public: - wxClientDC(); - wxClientDC( wxWindow *win ); + wxPaintDC() { } + wxPaintDC( wxWindow *win ); private: - DECLARE_DYNAMIC_CLASS(wxClientDC) + DECLARE_DYNAMIC_CLASS(wxPaintDC) }; #endif // __GTKDCCLIENTH__ diff --git a/include/wx/gtk/dcscreen.h b/include/wx/gtk/dcscreen.h index 64f1dfc6ac..b1cc81a7e6 100644 --- a/include/wx/gtk/dcscreen.h +++ b/include/wx/gtk/dcscreen.h @@ -22,22 +22,25 @@ class wxScreenDC; // wxScreenDC //----------------------------------------------------------------------------- -class wxScreenDC: public wxPaintDC +class wxScreenDC : public wxPaintDC { public: wxScreenDC(); - ~wxScreenDC(); + virtual ~wxScreenDC(); static bool StartDrawingOnTop( wxWindow *window ); static bool StartDrawingOnTop( wxRect *rect = (wxRect *) NULL ); static bool EndDrawingOnTop(); // implementation - + static GdkWindow *sm_overlayWindow; static int sm_overlayWindowX; static int sm_overlayWindowY; - + +protected: + virtual void DoGetSize(int *width, int *height) const; + private: DECLARE_DYNAMIC_CLASS(wxScreenDC) }; diff --git a/include/wx/gtk1/dc.h b/include/wx/gtk1/dc.h index 78c421c9c4..8c447ae426 100644 --- a/include/wx/gtk1/dc.h +++ b/include/wx/gtk1/dc.h @@ -134,7 +134,6 @@ public: protected: // base class pure virtuals implemented here virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSizeMM(int* width, int* height) const; public: diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h index f91eae7dc9..2168e181d7 100644 --- a/include/wx/gtk1/dcclient.h +++ b/include/wx/gtk1/dcclient.h @@ -40,7 +40,8 @@ public: virtual bool CanDrawBitmap() const { return TRUE; } virtual bool CanGetTextExtent() const { return TRUE; } -//protected: +protected: + virtual void DoGetSize(int *width, int *height) const; virtual void DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const; @@ -78,6 +79,8 @@ public: wxCoord *descent = (wxCoord *) NULL, wxCoord *externalLeading = (wxCoord *) NULL, wxFont *theFont = (wxFont *) NULL) const; + +public: virtual wxCoord GetCharWidth() const; virtual wxCoord GetCharHeight() const; @@ -135,31 +138,31 @@ private: }; //----------------------------------------------------------------------------- -// wxPaintDC +// wxClientDC //----------------------------------------------------------------------------- -class wxPaintDC : public wxWindowDC +class wxClientDC : public wxWindowDC { public: - wxPaintDC(); - wxPaintDC( wxWindow *win ); + wxClientDC() { } + wxClientDC( wxWindow *win ); private: - DECLARE_DYNAMIC_CLASS(wxPaintDC) + DECLARE_DYNAMIC_CLASS(wxClientDC) }; //----------------------------------------------------------------------------- -// wxClientDC +// wxPaintDC //----------------------------------------------------------------------------- -class wxClientDC : public wxWindowDC +class wxPaintDC : public wxClientDC { public: - wxClientDC(); - wxClientDC( wxWindow *win ); + wxPaintDC() { } + wxPaintDC( wxWindow *win ); private: - DECLARE_DYNAMIC_CLASS(wxClientDC) + DECLARE_DYNAMIC_CLASS(wxPaintDC) }; #endif // __GTKDCCLIENTH__ diff --git a/include/wx/gtk1/dcscreen.h b/include/wx/gtk1/dcscreen.h index 64f1dfc6ac..b1cc81a7e6 100644 --- a/include/wx/gtk1/dcscreen.h +++ b/include/wx/gtk1/dcscreen.h @@ -22,22 +22,25 @@ class wxScreenDC; // wxScreenDC //----------------------------------------------------------------------------- -class wxScreenDC: public wxPaintDC +class wxScreenDC : public wxPaintDC { public: wxScreenDC(); - ~wxScreenDC(); + virtual ~wxScreenDC(); static bool StartDrawingOnTop( wxWindow *window ); static bool StartDrawingOnTop( wxRect *rect = (wxRect *) NULL ); static bool EndDrawingOnTop(); // implementation - + static GdkWindow *sm_overlayWindow; static int sm_overlayWindowX; static int sm_overlayWindowY; - + +protected: + virtual void DoGetSize(int *width, int *height) const; + private: DECLARE_DYNAMIC_CLASS(wxScreenDC) }; diff --git a/src/gtk/dc.cpp b/src/gtk/dc.cpp index da0b27c97a..57273f2ba5 100644 --- a/src/gtk/dc.cpp +++ b/src/gtk/dc.cpp @@ -69,12 +69,6 @@ void wxDC::DestroyClippingRegion() // get DC capabilities // --------------------------------------------------------------------------- -void wxDC::DoGetSize( int* width, int* height ) const -{ - if (width) *width = m_maxX-m_minX; - if (height) *height = m_maxY-m_minY; -} - void wxDC::DoGetSizeMM( int* width, int* height ) const { int w = 0; diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index f0a96e5694..23efde3470 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -393,6 +393,13 @@ void wxWindowDC::SetUpDC() } } +void wxWindowDC::DoGetSize( int* width, int* height ) const +{ + wxCHECK_RET( m_owner, _T("GetSize() doesn't work without window") ); + + m_owner->GetSize(width, height); +} + void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style) ) { diff --git a/src/gtk/dcscreen.cpp b/src/gtk/dcscreen.cpp index 51a09f4806..a79f479bbf 100644 --- a/src/gtk/dcscreen.cpp +++ b/src/gtk/dcscreen.cpp @@ -101,3 +101,7 @@ bool wxScreenDC::EndDrawingOnTop() return TRUE; } +void wxScreenDC::DoGetSize(int *width, int *height) const +{ + wxDisplaySize(width, height); +} diff --git a/src/gtk1/dc.cpp b/src/gtk1/dc.cpp index da0b27c97a..57273f2ba5 100644 --- a/src/gtk1/dc.cpp +++ b/src/gtk1/dc.cpp @@ -69,12 +69,6 @@ void wxDC::DestroyClippingRegion() // get DC capabilities // --------------------------------------------------------------------------- -void wxDC::DoGetSize( int* width, int* height ) const -{ - if (width) *width = m_maxX-m_minX; - if (height) *height = m_maxY-m_minY; -} - void wxDC::DoGetSizeMM( int* width, int* height ) const { int w = 0; diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index f0a96e5694..23efde3470 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -393,6 +393,13 @@ void wxWindowDC::SetUpDC() } } +void wxWindowDC::DoGetSize( int* width, int* height ) const +{ + wxCHECK_RET( m_owner, _T("GetSize() doesn't work without window") ); + + m_owner->GetSize(width, height); +} + void wxWindowDC::DoFloodFill( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), const wxColour &WXUNUSED(col), int WXUNUSED(style) ) { diff --git a/src/gtk1/dcscreen.cpp b/src/gtk1/dcscreen.cpp index 51a09f4806..a79f479bbf 100644 --- a/src/gtk1/dcscreen.cpp +++ b/src/gtk1/dcscreen.cpp @@ -101,3 +101,7 @@ bool wxScreenDC::EndDrawingOnTop() return TRUE; } +void wxScreenDC::DoGetSize(int *width, int *height) const +{ + wxDisplaySize(width, height); +} -- 2.49.0