From 0329fe3e0a54d4554d5fad6b66cc3af990fa1e35 Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Sat, 18 Jul 2015 02:17:38 +0200 Subject: [PATCH] Fix initial position of controls with layout insets in wxOSX. For such controls (e.g. wxButton, wxChoice, wxGauge), their initial position was different from the one specified when creating them, even though calling SetPosition() later did position them at exactly the position passed as argument. Closes #16780. (this is a backport of a4681572cc04e89e02743999897051c5442533e6 from master) --- docs/changes.txt | 1 + src/osx/window_osx.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index 6a89aa0139..0f856e8653 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -643,6 +643,7 @@ wxOSX: - Generate wxEVT_TEXT_ENTER for wxTE_PASSWORD controls too (mj_smoker). - Send wxIconizeEvent when a window is iconized/restore (Rob Krakora). - Use correct colour for disabled wxStaticText (sbrowne). +- Fix initial position of controls with layout insets (Tim Kosse). - Fix printing all pages non-interactively (John Roberts). - Fix custom paper support (tijsv). - Return false from wxSound::Create()/IsOk() if the file doesn't exist. diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 6bfe8e2a17..5148658209 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -457,9 +457,16 @@ void wxWindowMac::MacChildAdded() #endif } -void wxWindowMac::MacPostControlCreate(const wxPoint& WXUNUSED(pos), +void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& WXUNUSED(size)) { + // Some controls may have a nonzero layout inset, + // so we may need to adjust control position. + if ( pos.IsFullySpecified() && GetPosition() != pos ) + { + SetPosition(pos); + } + // todo remove if refactoring works correctly #if 0 wxASSERT_MSG( GetPeer() != NULL && GetPeer()->IsOk() , wxT("No valid mac control") ) ;