From e5053ade6b00922decc47f2cf143ef08b5d0cfbb Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Tue, 12 Feb 2002 12:59:14 +0000 Subject: [PATCH] Attempts to get client origin working. Work in progress. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14153 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/x11/colour.h | 3 ++- include/wx/x11/toplevel.h | 7 +++++ src/univ/framuniv.cpp | 1 + src/x11/dcclient.cpp | 4 +++ src/x11/toplevel.cpp | 54 ++++++++++++++++++++++++++++++++++++++- src/x11/window.cpp | 5 +++- 6 files changed, 71 insertions(+), 3 deletions(-) diff --git a/include/wx/x11/colour.h b/include/wx/x11/colour.h index 884b849c57..3e1db7ddd6 100644 --- a/include/wx/x11/colour.h +++ b/include/wx/x11/colour.h @@ -94,4 +94,5 @@ private: #endif -// _WX_COLOUR_H_ \ No newline at end of file +// _WX_COLOUR_H_ + diff --git a/include/wx/x11/toplevel.h b/include/wx/x11/toplevel.h index 2f05fec508..de89221ca1 100644 --- a/include/wx/x11/toplevel.h +++ b/include/wx/x11/toplevel.h @@ -72,6 +72,13 @@ protected: // common part of all ctors void Init(); + // For implementation purposes - sometimes decorations make the client area + // smaller + virtual wxPoint GetClientAreaOrigin() const; + + virtual void DoGetClientSize( int *width, int *height ) const; + virtual void DoSetClientSize(int width, int height); + // is the frame currently iconized? bool m_iconized; diff --git a/src/univ/framuniv.cpp b/src/univ/framuniv.cpp index 2ea330be1d..ae8f7cf221 100644 --- a/src/univ/framuniv.cpp +++ b/src/univ/framuniv.cpp @@ -96,6 +96,7 @@ void wxFrame::PositionMenuBar() // the menubar is positioned above the client size, hence the negative // y coord wxCoord heightMbar = m_frameMenuBar->GetSize().y; + m_frameMenuBar->SetSize(0, #ifdef __WXPM__ // FIXME -- remove this, make wxOS2/Univ behave as // the rest of the world!!! diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp index f367f145fe..53a0311a55 100644 --- a/src/x11/dcclient.cpp +++ b/src/x11/dcclient.cpp @@ -342,6 +342,8 @@ void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) CalcBoundingBox(x1, y1); CalcBoundingBox(x2, y2); + + wxLogDebug("Drawing line at %d, %d -> %d, %d", XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); } } @@ -749,6 +751,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h CalcBoundingBox( x, y ); CalcBoundingBox( x + width, y + height ); + wxLogDebug("Drawing rectangle at %d, %d (%dx%d)", x, y, width, height); } void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) @@ -1246,6 +1249,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) { XDrawString( (Display*) m_display, (Window) m_window, (GC) m_textGC, x, y, text.c_str(), text.Len() ); + wxLogDebug("Drawing text %s at %d, %d", text.c_str(), x, y); } #if 0 diff --git a/src/x11/toplevel.cpp b/src/x11/toplevel.cpp index e139ee21a4..101ef8e446 100644 --- a/src/x11/toplevel.cpp +++ b/src/x11/toplevel.cpp @@ -35,11 +35,12 @@ #include "wx/log.h" #include "wx/intl.h" #include "wx/frame.h" + #include "wx/menu.h" + #include "wx/statusbr.h" #endif //WX_PRECOMP #include "wx/x11/private.h" - bool wxMWMIsRunning(Window w); // ---------------------------------------------------------------------------- @@ -396,3 +397,54 @@ bool wxMWMIsRunning(Window w) return (ret == Success); } +// For implementation purposes - sometimes decorations make the client area +// smaller +wxPoint wxTopLevelWindowX11::GetClientAreaOrigin() const +{ + if (this->IsKindOf(CLASSINFO(wxFrame))) + { + wxFrame* frame = (wxFrame*) this; + if (frame->GetMenuBar()) + return wxPoint(0, frame->GetMenuBar()->GetSize().y); + } + return wxPoint(0, 0); +} + +void wxTopLevelWindowX11::DoGetClientSize( int *width, int *height ) const +{ + wxWindowX11::DoGetClientSize(width, height); + if (this->IsKindOf(CLASSINFO(wxFrame))) + { + wxFrame* frame = (wxFrame*) this; + if (frame->GetMenuBar()) + (*height) -= frame->GetMenuBar()->GetSize().y; + if (frame->GetStatusBar()) + (*height) -= frame->GetStatusBar()->GetSize().y; + } +} + +void wxTopLevelWindowX11::DoSetClientSize(int width, int height) +{ + // TODO - take menubar and status line into account + wxWindowX11::DoSetClientSize(width, height); +#if 0 + if (!GetMainWindow()) + return; + + XWindowChanges windowChanges; + int valueMask = 0; + + if (width != -1) + { + windowChanges.width = width ; + valueMask |= CWWidth; + } + if (height != -1) + { + windowChanges.height = height ; + valueMask |= CWHeight; + } + XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(), + valueMask, & windowChanges); +#endif +} diff --git a/src/x11/window.cpp b/src/x11/window.cpp index da1a164a6d..a9bb558858 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -719,11 +719,15 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) if (x != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { + int yy = 0; + AdjustForParentClientOrigin( x, yy, sizeFlags); windowChanges.x = x; valueMask |= CWX; } if (y != -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) { + int xx = 0; + AdjustForParentClientOrigin( xx, y, sizeFlags); windowChanges.y = y; valueMask |= CWY; } @@ -737,7 +741,6 @@ void wxWindowX11::DoSetSize(int x, int y, int width, int height, int sizeFlags) windowChanges.height = height /* -m_borderSize*2*/; valueMask |= CWHeight; } - AdjustForParentClientOrigin( x, y, sizeFlags); XConfigureWindow(wxGlobalDisplay(), (Window) GetMainWindow(), valueMask, & windowChanges); -- 2.45.2