]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed dialog units in toplevel windows (bug #1170234)
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 28 Mar 2005 09:28:44 +0000 (09:28 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 28 Mar 2005 09:28:44 +0000 (09:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/xrc/xmlres.h
src/xrc/xh_dlg.cpp
src/xrc/xh_frame.cpp
src/xrc/xmlres.cpp

index 2525bf733d61666191bfdac2a2a0a551daa04d15..737ed87f216af262e219bc6ac34bda6e639d15f8 100644 (file)
@@ -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"),
index df59a766a108e16278330cc26cb43ead9b416a4d..4cab7111876ae9bde9fa49005e49da7f1ef045d5 100644 (file)
@@ -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")))
index f5b59ef01ce89a21e506b00b8528485ea6d8cc3b..98d996fd1347d467b647b47c107730d7bdc3e1e2 100644 (file)
@@ -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")))
index 0e1b2943abae40a074fa889bbf4e3cf050ef76e7..3cda8546b15f7a2e8bd1ee740a869d14c8d1def2 100644 (file)
@@ -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."));