Use parents client size and origin in placement of controls.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31914 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-02-11 06:56:47 +00:00
parent 6bee5ffba4
commit be4e4e27aa
4 changed files with 45 additions and 16 deletions

View File

@@ -138,7 +138,7 @@ bool wxButton::Create(wxWindow *parent,
wxPoint palmPos(pos); wxPoint palmPos(pos);
if((palmPos.x==wxDefaultCoord)||(palmPos.y==wxDefaultCoord)) if((palmPos.x==wxDefaultCoord)||(palmPos.y==wxDefaultCoord))
{ {
wxSize parentSize(parent->GetSize()); wxSize parentSize(parent->GetClientSize());
wxWindow* parentTLW = parent; wxWindow* parentTLW = parent;
while ( parentTLW && !parentTLW->IsTopLevel() ) while ( parentTLW && !parentTLW->IsTopLevel() )
{ {
@@ -148,14 +148,14 @@ bool wxButton::Create(wxWindow *parent,
if(wxDynamicCast(parentTLW, wxFrame)!=NULL) if(wxDynamicCast(parentTLW, wxFrame)!=NULL)
{ {
if(palmPos.x==wxDefaultCoord) if(palmPos.x==wxDefaultCoord)
palmPos.x = 1; palmPos.x = 0;
if(palmPos.y==wxDefaultCoord) if(palmPos.y==wxDefaultCoord)
palmPos.y = parentSize.y-palmSize.y; palmPos.y = parentSize.y-palmSize.y;
} }
else if(wxDynamicCast(parentTLW, wxDialog)!=NULL) else if(wxDynamicCast(parentTLW, wxDialog)!=NULL)
{ {
if(palmPos.x==wxDefaultCoord) if(palmPos.x==wxDefaultCoord)
palmPos.x = 5; palmPos.x = 4;
if(palmPos.y==wxDefaultCoord) if(palmPos.y==wxDefaultCoord)
palmPos.y = parentSize.y-palmSize.y-5; palmPos.y = parentSize.y-palmSize.y-5;
} }

View File

@@ -117,15 +117,23 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
if(form==NULL) if(form==NULL)
return false; return false;
wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x,
y = pos.y == wxDefaultCoord ? 0 : pos.y,
w = size.x == wxDefaultCoord ? 1 : size.x,
h = size.y == wxDefaultCoord ? 1 : size.y;
AdjustForParentClientOrigin(x, y);
ControlType *control = CtlNewControl( ControlType *control = CtlNewControl(
(void **)&form, (void **)&form,
GetId(), GetId(),
style, style,
wxEmptyString, wxEmptyString,
( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x, x,
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, y,
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, w,
( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, h,
stdFont, stdFont,
groupID, groupID,
true true
@@ -136,6 +144,7 @@ bool wxControl::PalmCreateControl(ControlStyleType style,
m_palmControl = true; m_palmControl = true;
SetInitialBestSize(size);
SetLabel(label); SetLabel(label);
Show(); Show();
return true; return true;
@@ -154,13 +163,20 @@ bool wxControl::PalmCreateField(const wxString& label,
m_label = label; m_label = label;
wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x,
y = pos.y == wxDefaultCoord ? 0 : pos.y,
w = size.x == wxDefaultCoord ? 1 : size.x,
h = size.y == wxDefaultCoord ? 1 : size.y;
AdjustForParentClientOrigin(x, y);
FieldType *field = FldNewField( FieldType *field = FldNewField(
(void **)&form, (void **)&form,
GetId(), GetId(),
( pos.x == wxDefaultCoord ) ? winUndefConstraint : pos.x, x,
( pos.y == wxDefaultCoord ) ? winUndefConstraint : pos.y, y,
( size.x == wxDefaultCoord ) ? winUndefConstraint : size.x, w,
( size.y == wxDefaultCoord ) ? winUndefConstraint : size.y, h,
stdFont, stdFont,
10, 10,
editable, editable,
@@ -178,8 +194,9 @@ bool wxControl::PalmCreateField(const wxString& label,
m_palmField = true; m_palmField = true;
Show(); SetInitialBestSize(size);
SetLabel(label); SetLabel(label);
Show();
return true; return true;
} }

View File

@@ -183,6 +183,10 @@ void wxFrame::DoSetClientSize(int width, int height)
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc. // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
void wxFrame::DoGetClientSize(int *x, int *y) const void wxFrame::DoGetClientSize(int *x, int *y) const
{ {
wxSize size = GetSize();
wxPoint pos = GetClientAreaOrigin();
*x = size.x - pos.x - 1;
*y = size.y - pos.y - 1;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -130,6 +130,13 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
m_oldValue = m_oldPos = value; m_oldValue = m_oldPos = value;
wxCoord x = pos.x == wxDefaultCoord ? 0 : pos.x,
y = pos.y == wxDefaultCoord ? 0 : pos.y,
w = size.x == wxDefaultCoord ? 1 : size.x,
h = size.y == wxDefaultCoord ? 1 : size.y;
AdjustForParentClientOrigin(x, y);
SliderControlType *slider = CtlNewSliderControl ( SliderControlType *slider = CtlNewSliderControl (
(void **)&form, (void **)&form,
GetId(), GetId(),
@@ -137,10 +144,10 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
NULL, NULL,
0, 0,
0, 0,
pos.x, x,
pos.y, y,
size.x, w,
size.y, h,
minValue, minValue,
maxValue, maxValue,
1, 1,
@@ -150,6 +157,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
if(slider==NULL) if(slider==NULL)
return false; return false;
SetInitialBestSize(size);
Show(); Show();
return true; return true;
} }