From 0c00c86faf8e49a329a7234d9fc331b05fb8239f Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Mon, 28 Mar 2005 09:28:44 +0000 Subject: [PATCH] fixed dialog units in toplevel windows (bug #1170234) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/xrc/xmlres.h | 8 +++++--- src/xrc/xh_dlg.cpp | 2 +- src/xrc/xh_frame.cpp | 2 +- src/xrc/xmlres.cpp | 23 +++++++++++++++++++---- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/include/wx/xrc/xmlres.h b/include/wx/xrc/xmlres.h index 2525bf733d..737ed87f21 100644 --- a/include/wx/xrc/xmlres.h +++ b/include/wx/xrc/xmlres.h @@ -389,7 +389,7 @@ protected: // Gets an integer value from the parameter. long GetLong(const wxString& param, long defaultv = 0); - + // Gets a float value from the parameter. float GetFloat(const wxString& param, float defaultv = 0); @@ -397,13 +397,15 @@ protected: wxColour GetColour(const wxString& param); // Gets the size (may be in dialog units). - wxSize GetSize(const wxString& param = wxT("size")); + wxSize GetSize(const wxString& param = wxT("size"), + wxWindow *windowToUse = NULL); // Gets the position (may be in dialog units). wxPoint GetPosition(const wxString& param = wxT("pos")); // Gets a dimension (may be in dialog units). - wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0); + wxCoord GetDimension(const wxString& param, wxCoord defaultv = 0, + wxWindow *windowToUse = NULL); // Gets a bitmap. wxBitmap GetBitmap(const wxString& param = wxT("bitmap"), diff --git a/src/xrc/xh_dlg.cpp b/src/xrc/xh_dlg.cpp index df59a766a1..4cab711187 100644 --- a/src/xrc/xh_dlg.cpp +++ b/src/xrc/xh_dlg.cpp @@ -66,7 +66,7 @@ wxObject *wxDialogXmlHandler::DoCreateResource() GetName()); if (HasParam(wxT("size"))) - dlg->SetClientSize(GetSize()); + dlg->SetClientSize(GetSize(wxT("size"), dlg)); if (HasParam(wxT("pos"))) dlg->Move(GetPosition()); if (HasParam(wxT("icon"))) diff --git a/src/xrc/xh_frame.cpp b/src/xrc/xh_frame.cpp index f5b59ef01c..98d996fd13 100644 --- a/src/xrc/xh_frame.cpp +++ b/src/xrc/xh_frame.cpp @@ -69,7 +69,7 @@ wxObject *wxFrameXmlHandler::DoCreateResource() GetName()); if (HasParam(wxT("size"))) - frame->SetClientSize(GetSize()); + frame->SetClientSize(GetSize(wxT("size"), frame)); if (HasParam(wxT("pos"))) frame->Move(GetPosition()); if (HasParam(wxT("icon"))) diff --git a/src/xrc/xmlres.cpp b/src/xrc/xmlres.cpp index 0e1b2943ab..3cda8546b1 100644 --- a/src/xrc/xmlres.cpp +++ b/src/xrc/xmlres.cpp @@ -1092,7 +1092,8 @@ wxString wxXmlResourceHandler::GetParamValue(const wxString& param) -wxSize wxXmlResourceHandler::GetSize(const wxString& param) +wxSize wxXmlResourceHandler::GetSize(const wxString& param, + wxWindow *windowToUse) { wxString s = GetParamValue(param); if (s.empty()) s = wxT("-1,-1"); @@ -1111,8 +1112,14 @@ wxSize wxXmlResourceHandler::GetSize(const wxString& param) if (is_dlg) { - if (m_parentAsWindow) + if (windowToUse) + { + return wxDLG_UNIT(windowToUse, wxSize(sx, sy)); + } + else if (m_parentAsWindow) + { return wxDLG_UNIT(m_parentAsWindow, wxSize(sx, sy)); + } else { wxLogError(_("Cannot convert dialog units: dialog unknown.")); @@ -1133,7 +1140,9 @@ wxPoint wxXmlResourceHandler::GetPosition(const wxString& param) -wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, wxCoord defaultv) +wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, + wxCoord defaultv, + wxWindow *windowToUse) { wxString s = GetParamValue(param); if (s.empty()) return defaultv; @@ -1151,8 +1160,14 @@ wxCoord wxXmlResourceHandler::GetDimension(const wxString& param, wxCoord defaul if (is_dlg) { - if (m_parentAsWindow) + if (windowToUse) + { + return wxDLG_UNIT(windowToUse, wxSize(sx, 0)).x; + } + else if (m_parentAsWindow) + { return wxDLG_UNIT(m_parentAsWindow, wxSize(sx, 0)).x; + } else { wxLogError(_("Cannot convert dialog units: dialog unknown.")); -- 2.45.2