'Y' positioning fixes for OS/2 controls
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13147 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -141,10 +141,10 @@ bool wxControl::OS2CreateControl(
|
|||||||
,(PSZ)zClassname // Window class
|
,(PSZ)zClassname // Window class
|
||||||
,(PSZ)rsLabel.c_str() // Initial Text
|
,(PSZ)rsLabel.c_str() // Initial Text
|
||||||
,(ULONG)dwStyle // Style flags
|
,(ULONG)dwStyle // Style flags
|
||||||
,(LONG)rPos.x // X pos of origin
|
,(LONG)0 // X pos of origin
|
||||||
,(LONG)rPos.y // Y pos of origin
|
,(LONG)0 // Y pos of origin
|
||||||
,(LONG)rSize.x // control width
|
,(LONG)0 // control width
|
||||||
,(LONG)rSize.y // control height
|
,(LONG)0 // control height
|
||||||
,(HWND)GetHwndOf(GetParent()) // owner window handle (same as parent
|
,(HWND)GetHwndOf(GetParent()) // owner window handle (same as parent
|
||||||
,HWND_TOP // initial z position
|
,HWND_TOP // initial z position
|
||||||
,(ULONG)GetId() // Window identifier
|
,(ULONG)GetId() // Window identifier
|
||||||
|
@@ -122,6 +122,7 @@ bool wxGauge::Create(
|
|||||||
int nWidth = rSize.x;
|
int nWidth = rSize.x;
|
||||||
int nHeight = rSize.y;
|
int nHeight = rSize.y;
|
||||||
long lMsStyle = 0L;
|
long lMsStyle = 0L;
|
||||||
|
SWP vSwp;
|
||||||
|
|
||||||
SetName(rsName);
|
SetName(rsName);
|
||||||
#if wxUSE_VALIDATORS
|
#if wxUSE_VALIDATORS
|
||||||
@@ -173,6 +174,9 @@ bool wxGauge::Create(
|
|||||||
);
|
);
|
||||||
::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this);
|
::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this);
|
||||||
fnWndProcGauge = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxGaugeWndProc);
|
fnWndProcGauge = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxGaugeWndProc);
|
||||||
|
::WinQueryWindowPos(m_hWnd, &vSwp);
|
||||||
|
SetXComp(vSwp.x);
|
||||||
|
SetYComp(vSwp.y);
|
||||||
SetFont(pParent->GetFont());
|
SetFont(pParent->GetFont());
|
||||||
if (nWidth == -1L)
|
if (nWidth == -1L)
|
||||||
nWidth = 50L;
|
nWidth = 50L;
|
||||||
|
@@ -86,7 +86,7 @@ void wxRadioBox::AdjustButtons(
|
|||||||
, int nY
|
, int nY
|
||||||
, int nWidth
|
, int nWidth
|
||||||
, int nHeight
|
, int nHeight
|
||||||
, long lSizeFlags
|
, int nSizeFlags
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
wxSize vMaxSize;
|
wxSize vMaxSize;
|
||||||
@@ -480,7 +480,9 @@ void wxRadioBox::DoSetSize(
|
|||||||
|
|
||||||
if (pParent)
|
if (pParent)
|
||||||
{
|
{
|
||||||
nYy = pParent->GetClientSize().y - (nYy + nHeight);
|
int nOS2Height = GetOS2ParentHeight(pParent);
|
||||||
|
|
||||||
|
nYy = nOS2Height - (nYy + nHeight);
|
||||||
nYOffset = nYy + nHeight;
|
nYOffset = nYy + nHeight;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -49,6 +49,80 @@ wxSlider::~wxSlider()
|
|||||||
::WinDestroyWindow((HWND)m_hStaticValue);
|
::WinDestroyWindow((HWND)m_hStaticValue);
|
||||||
} // end of wxSlider::~wxSlider
|
} // end of wxSlider::~wxSlider
|
||||||
|
|
||||||
|
void wxSlider::AdjustSubControls(
|
||||||
|
int nX
|
||||||
|
, int nY
|
||||||
|
, int nWidth
|
||||||
|
, int nHeight
|
||||||
|
, int nSizeFlags
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SWP vSwp;
|
||||||
|
int nXOffset = nX;
|
||||||
|
int nYOffset = nY;
|
||||||
|
int nCx; // slider,min,max sizes
|
||||||
|
int nCy;
|
||||||
|
int nCyf;
|
||||||
|
char zBuf[300];
|
||||||
|
|
||||||
|
wxGetCharSize( GetHWND()
|
||||||
|
,&nCx
|
||||||
|
,&nCy
|
||||||
|
,&this->GetFont()
|
||||||
|
);
|
||||||
|
|
||||||
|
if ((m_windowStyle & wxSL_VERTICAL) != wxSL_VERTICAL)
|
||||||
|
{
|
||||||
|
if (m_windowStyle & wxSL_LABELS )
|
||||||
|
{
|
||||||
|
int nMinLen = 0;
|
||||||
|
int nMaxLen = 0;
|
||||||
|
|
||||||
|
::WinQueryWindowText((HWND)m_hStaticMin, 300, zBuf);
|
||||||
|
GetTextExtent(zBuf, &nMinLen, &nCyf, NULL, NULL, &this->GetFont());
|
||||||
|
|
||||||
|
::WinQueryWindowText((HWND)m_hStaticMax, 300, zBuf);
|
||||||
|
GetTextExtent(zBuf, &nMaxLen, &nCyf, NULL, NULL, &this->GetFont());
|
||||||
|
|
||||||
|
if (m_hStaticValue)
|
||||||
|
{
|
||||||
|
int nNewWidth = wxMax(nMinLen, nMaxLen);
|
||||||
|
int nValueHeight = nCyf;
|
||||||
|
|
||||||
|
::WinSetWindowPos( (HWND)m_hStaticValue
|
||||||
|
,HWND_TOP
|
||||||
|
,(LONG)nXOffset - (nNewWidth + nCx + nMinLen + nCx)
|
||||||
|
,(LONG)nYOffset
|
||||||
|
,(LONG)nNewWidth
|
||||||
|
,(LONG)nValueHeight
|
||||||
|
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
|
||||||
|
);
|
||||||
|
}
|
||||||
|
::WinSetWindowPos( (HWND)m_hStaticMin
|
||||||
|
,HWND_TOP
|
||||||
|
,(LONG)nXOffset - (nMinLen + nCx)
|
||||||
|
,(LONG)nYOffset
|
||||||
|
,(LONG)nMinLen
|
||||||
|
,(LONG)nCy
|
||||||
|
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
|
||||||
|
);
|
||||||
|
nXOffset += nWidth + nCx;
|
||||||
|
|
||||||
|
::WinSetWindowPos( (HWND)m_hStaticMax
|
||||||
|
,HWND_TOP
|
||||||
|
,(LONG)nXOffset
|
||||||
|
,(LONG)nYOffset
|
||||||
|
,(LONG)nMaxLen
|
||||||
|
,(LONG)nCy
|
||||||
|
,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// Now deal with a vertical slider -- OS/2 doesn't have vertical sliders
|
||||||
|
//
|
||||||
|
} // end of wxSlider::AdjustSubControls
|
||||||
|
|
||||||
void wxSlider::ClearSel()
|
void wxSlider::ClearSel()
|
||||||
{
|
{
|
||||||
} // end of wxSlider::ClearSel
|
} // end of wxSlider::ClearSel
|
||||||
@@ -345,24 +419,11 @@ void wxSlider::DoSetSize(
|
|||||||
|
|
||||||
if (pParent)
|
if (pParent)
|
||||||
{
|
{
|
||||||
//
|
int nOS2ParentHeight = GetOS2ParentHeight(pParent);
|
||||||
// Under OS/2, where a frame window is the parent, most child windows
|
|
||||||
// that are not specific frame clients are actually children of the
|
nYOffset = nOS2ParentHeight - (nYOffset + nOS2Height);
|
||||||
// frame's client, not the frame itself, and so position themselves
|
|
||||||
// with regards to the client origin, not the frame.
|
|
||||||
//
|
|
||||||
if (pParent->IsKindOf(CLASSINFO(wxFrame)))
|
|
||||||
{
|
|
||||||
nYOffset = pParent->GetClientSize().y - (nYOffset + nOS2Height);
|
|
||||||
if (nY != -1)
|
if (nY != -1)
|
||||||
nY1 = pParent->GetClientSize().y - (nY1 + nOS2Height);
|
nY1 = nOS2ParentHeight - (nY1 + nOS2Height);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nYOffset = pParent->GetSize().y - (nYOffset + nOS2Height);
|
|
||||||
if (nY != -1)
|
|
||||||
nY1 = pParent->GetSize().y - (nY1 + nOS2Height);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -373,6 +434,7 @@ void wxSlider::DoSetSize(
|
|||||||
if (nY != -1)
|
if (nY != -1)
|
||||||
nY1 = vRect.yTop - (nY1 + nOS2Height);
|
nY1 = vRect.yTop - (nY1 + nOS2Height);
|
||||||
}
|
}
|
||||||
|
m_nSizeFlags = nSizeFlags;
|
||||||
|
|
||||||
GetPosition( &nCurrentX
|
GetPosition( &nCurrentX
|
||||||
,&nCurrentY
|
,&nCurrentY
|
||||||
|
@@ -61,6 +61,7 @@ bool wxSpinButton::Create(
|
|||||||
int nY = rPos.y;
|
int nY = rPos.y;
|
||||||
int nWidth = rSize.x;
|
int nWidth = rSize.x;
|
||||||
int nHeight = rSize.y;
|
int nHeight = rSize.y;
|
||||||
|
SWP vSwp;
|
||||||
|
|
||||||
m_min = 0;
|
m_min = 0;
|
||||||
m_max = 100;
|
m_max = 100;
|
||||||
@@ -128,6 +129,9 @@ bool wxSpinButton::Create(
|
|||||||
if(pParent)
|
if(pParent)
|
||||||
pParent->AddChild((wxSpinButton *)this);
|
pParent->AddChild((wxSpinButton *)this);
|
||||||
|
|
||||||
|
::WinQueryWindowPos(m_hWnd, &vSwp);
|
||||||
|
SetXComp(vSwp.x);
|
||||||
|
SetYComp(vSwp.y);
|
||||||
SetFont(pParent->GetFont());
|
SetFont(pParent->GetFont());
|
||||||
//
|
//
|
||||||
// For OS/2 we want to hide the text portion so we can substitute an
|
// For OS/2 we want to hide the text portion so we can substitute an
|
||||||
|
@@ -129,6 +129,8 @@ bool wxSpinCtrl::Create(
|
|||||||
, const wxString& rsName
|
, const wxString& rsName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
SWP vSwp;
|
||||||
|
|
||||||
if (vId == -1)
|
if (vId == -1)
|
||||||
m_windowId = NewControlId();
|
m_windowId = NewControlId();
|
||||||
else
|
else
|
||||||
@@ -177,6 +179,9 @@ bool wxSpinCtrl::Create(
|
|||||||
if(pParent)
|
if(pParent)
|
||||||
pParent->AddChild((wxSpinButton *)this);
|
pParent->AddChild((wxSpinButton *)this);
|
||||||
SetFont(pParent->GetFont());
|
SetFont(pParent->GetFont());
|
||||||
|
::WinQueryWindowPos(m_hWnd, &vSwp);
|
||||||
|
SetXComp(vSwp.x);
|
||||||
|
SetYComp(vSwp.y);
|
||||||
SetSize( rPos.x
|
SetSize( rPos.x
|
||||||
,rPos.y
|
,rPos.y
|
||||||
,rSize.x
|
,rSize.x
|
||||||
@@ -262,12 +267,9 @@ void wxSpinCtrl::DoMoveWindow(
|
|||||||
|
|
||||||
if (pParent)
|
if (pParent)
|
||||||
{
|
{
|
||||||
if (pParent->IsKindOf(CLASSINFO(wxFrame)))
|
int nOS2Height = GetOS2ParentHeight(pParent);
|
||||||
{
|
|
||||||
nY = pParent->GetClientSize().y - (nY + nHeight);
|
nY = nOS2Height - (nY + nHeight);
|
||||||
}
|
|
||||||
else
|
|
||||||
nY = pParent->GetSize().y - (nY + nHeight);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -67,10 +67,10 @@ bool wxStaticLine::Create(
|
|||||||
,WC_STATIC
|
,WC_STATIC
|
||||||
,""
|
,""
|
||||||
,WS_VISIBLE | SS_TEXT | DT_VCENTER | DT_CENTER
|
,WS_VISIBLE | SS_TEXT | DT_VCENTER | DT_CENTER
|
||||||
,rPos.x
|
,0
|
||||||
,rPos.y
|
,0
|
||||||
,vSizeReal.x
|
,0
|
||||||
,vSizeReal.y
|
,0
|
||||||
,GetWinHwnd(pParent)
|
,GetWinHwnd(pParent)
|
||||||
,HWND_TOP
|
,HWND_TOP
|
||||||
,(ULONG)m_windowId
|
,(ULONG)m_windowId
|
||||||
@@ -83,6 +83,11 @@ bool wxStaticLine::Create(
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
SubclassWin(m_hWnd);
|
SubclassWin(m_hWnd);
|
||||||
|
SetSize( rPos.x
|
||||||
|
,rPos.y
|
||||||
|
,rSize.x
|
||||||
|
,rSize.y
|
||||||
|
);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} // end of wxStaticLine::Create
|
} // end of wxStaticLine::Create
|
||||||
|
|
||||||
|
@@ -1521,19 +1521,9 @@ void wxWindowOS2::DoMoveWindow(
|
|||||||
|
|
||||||
if (pParent)
|
if (pParent)
|
||||||
{
|
{
|
||||||
hParent = GetWinHwnd(pParent);
|
int nOS2Height = GetOS2ParentHeight(pParent);
|
||||||
if (pParent->IsKindOf(CLASSINFO(wxFrame)))
|
|
||||||
{
|
nY = nOS2Height - (nY + nHeight);
|
||||||
if (IsKindOf(CLASSINFO(wxStatusBar)) ||
|
|
||||||
IsKindOf(CLASSINFO(wxMenuBar)) ||
|
|
||||||
IsKindOf(CLASSINFO(wxToolBar))
|
|
||||||
)
|
|
||||||
nY = pParent->GetSize().y - (nY + nHeight);
|
|
||||||
else
|
|
||||||
nY = pParent->GetClientSize().y - (nY + nHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
nY = pParent->GetSize().y - (nY + nHeight);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -3899,6 +3889,162 @@ bool wxWindowOS2::OS2OnScroll(
|
|||||||
return GetEventHandler()->ProcessEvent(vEvent);
|
return GetEventHandler()->ProcessEvent(vEvent);
|
||||||
} // end of wxWindowOS2::OS2OnScroll
|
} // end of wxWindowOS2::OS2OnScroll
|
||||||
|
|
||||||
|
void wxWindowOS2::MoveChildren(
|
||||||
|
int nDiff
|
||||||
|
)
|
||||||
|
{
|
||||||
|
SWP vSwp;
|
||||||
|
|
||||||
|
for (wxWindowList::Node* pNode = GetChildren().GetFirst();
|
||||||
|
pNode;
|
||||||
|
pNode = pNode->GetNext())
|
||||||
|
{
|
||||||
|
wxWindow* pWin = pNode->GetData();
|
||||||
|
|
||||||
|
::WinQueryWindowPos( GetHwndOf(pWin)
|
||||||
|
,&vSwp
|
||||||
|
);
|
||||||
|
if (pWin->IsKindOf(CLASSINFO(wxControl)))
|
||||||
|
{
|
||||||
|
wxControl* pCtrl;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Must deal with controls that have margins like ENTRYFIELD. The SWP
|
||||||
|
// struct of such a control will have and origin offset from its intended
|
||||||
|
// position by the width of the margins.
|
||||||
|
//
|
||||||
|
pCtrl = wxDynamicCast(pWin, wxControl);
|
||||||
|
vSwp.y -= pCtrl->GetYComp();
|
||||||
|
vSwp.x -= pCtrl->GetXComp();
|
||||||
|
}
|
||||||
|
::WinSetWindowPos( GetHwndOf(pWin)
|
||||||
|
,HWND_TOP
|
||||||
|
,vSwp.x
|
||||||
|
,vSwp.y - nDiff
|
||||||
|
,vSwp.cx
|
||||||
|
,vSwp.cy
|
||||||
|
,SWP_MOVE
|
||||||
|
);
|
||||||
|
if (pWin->IsKindOf(CLASSINFO(wxRadioBox)))
|
||||||
|
{
|
||||||
|
wxRadioBox* pRadioBox;
|
||||||
|
|
||||||
|
pRadioBox = wxDynamicCast(pWin, wxRadioBox);
|
||||||
|
pRadioBox->AdjustButtons( (int)vSwp.x
|
||||||
|
,(int)vSwp.y - nDiff
|
||||||
|
,(int)vSwp.cx
|
||||||
|
,(int)vSwp.cy
|
||||||
|
,pRadioBox->GetSizeFlags()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (pWin->IsKindOf(CLASSINFO(wxSlider)))
|
||||||
|
{
|
||||||
|
wxSlider* pSlider;
|
||||||
|
|
||||||
|
pSlider = wxDynamicCast(pWin, wxSlider);
|
||||||
|
pSlider->AdjustSubControls( (int)vSwp.x
|
||||||
|
,(int)vSwp.y - nDiff
|
||||||
|
,(int)vSwp.cx
|
||||||
|
,(int)vSwp.cy
|
||||||
|
,(int)pSlider->GetSizeFlags()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // end of wxWindowOS2::MoveChildren
|
||||||
|
|
||||||
|
//
|
||||||
|
// Getting the Y position for a window, like a control, is a real
|
||||||
|
// pain. There are three sitatuions we must deal with in determining
|
||||||
|
// the OS2 to wxWindows Y coordinate.
|
||||||
|
//
|
||||||
|
// 1) The controls are created in a dialog.
|
||||||
|
// This is the easiest since a dialog is created with its original
|
||||||
|
// size so the standard: Y = ParentHeight - (Y + ControlHeight);
|
||||||
|
//
|
||||||
|
// 2) The controls are direct children of a frame
|
||||||
|
// In this instance the controls are actually children of the Frame's
|
||||||
|
// client. During creation the frame's client resizes several times
|
||||||
|
// during creation of the status bar and toolbars. The CFrame class
|
||||||
|
// will take care of this using its AlterChildPos proc.
|
||||||
|
//
|
||||||
|
// 3) The controls are children of a panel, which in turn is a child of
|
||||||
|
// a frame.
|
||||||
|
// This is the nastiest case. A panel is created as the only child of
|
||||||
|
// the frame and as such, when a frame has only one child, the child is
|
||||||
|
// expanded to fit the entire client area of the frame. Because the
|
||||||
|
// controls are created BEFORE this occurs their positions are totally
|
||||||
|
// whacked and any call to WinQueryWindowPos will return invalid
|
||||||
|
// coordinates. So for this situation we have to compare the size of
|
||||||
|
// the panel at control creation time with that of the frame client. If
|
||||||
|
// they are the same we can use the standard Y position equation. If
|
||||||
|
// not, then we must use the Frame Client's dimensions to position them
|
||||||
|
// as that will be the eventual size of the panel after the frame resizes
|
||||||
|
// it!
|
||||||
|
//
|
||||||
|
int wxWindowOS2::GetOS2ParentHeight(
|
||||||
|
wxWindowOS2* pParent
|
||||||
|
)
|
||||||
|
{
|
||||||
|
wxWindowOS2* pGrandParent = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Case 1
|
||||||
|
//
|
||||||
|
if (pParent->IsKindOf(CLASSINFO(wxDialog)))
|
||||||
|
return(pParent->GetSize().y);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Case 2 -- if we are one of the separately built standard Frame
|
||||||
|
// children, like a statusbar, menubar, or toolbar we want to
|
||||||
|
// use the frame, itself, for positioning. Otherwise we are
|
||||||
|
// child window and want to use the Frame's client.
|
||||||
|
//
|
||||||
|
else if (pParent->IsKindOf(CLASSINFO(wxFrame)))
|
||||||
|
{
|
||||||
|
if (IsKindOf(CLASSINFO(wxStatusBar)) ||
|
||||||
|
IsKindOf(CLASSINFO(wxMenuBar)) ||
|
||||||
|
IsKindOf(CLASSINFO(wxToolBar))
|
||||||
|
)
|
||||||
|
return(pParent->GetSize().y);
|
||||||
|
else
|
||||||
|
return(pParent->GetClientSize().y);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Case 3 -- this is for any window that is the sole child of a Frame.
|
||||||
|
// The grandparent must exist and it must be of type CFrame
|
||||||
|
// and it's height must be different. Otherwise the standard
|
||||||
|
// applies.
|
||||||
|
//
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pGrandParent = pParent->GetParent();
|
||||||
|
if (pGrandParent &&
|
||||||
|
pGrandParent->IsKindOf(CLASSINFO(wxFrame)) &&
|
||||||
|
pGrandParent->GetClientSize().y != pParent->GetSize().y
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int nParentHeight = 0L;
|
||||||
|
int nStatusBarHeight = 0L;
|
||||||
|
wxFrame* pFrame = wxDynamicCast(pGrandParent, wxFrame);
|
||||||
|
wxStatusBar* pStatbar = pFrame->GetStatusBar();
|
||||||
|
|
||||||
|
nParentHeight = pGrandParent->GetClientSize().y;
|
||||||
|
if (pStatbar)
|
||||||
|
nStatusBarHeight = pStatbar->GetSize().y;
|
||||||
|
nParentHeight -= nStatusBarHeight;
|
||||||
|
return(nParentHeight);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
//
|
||||||
|
// Panel is a child of some other kind of window so we'll
|
||||||
|
// just use it's original size
|
||||||
|
//
|
||||||
|
return(pParent->GetClientSize().y);
|
||||||
|
}
|
||||||
|
return(0L);
|
||||||
|
} // end of wxWindowOS2::GetOS2ParentHeight
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// global functions
|
// global functions
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
Reference in New Issue
Block a user