+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_BOTTOM
+ ,vSwp.x
+ ,vSwp.y - nDiff
+ ,vSwp.cx
+ ,vSwp.cy
+ ,SWP_MOVE | SWP_ZORDER
+ );
+ 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->GetClientSize().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
+
+//
+// OS/2 needs a lot extra manipulation to deal with layouts
+// for canvas windows, particularly scrolled ones.
+//
+void wxWindowOS2::OS2Layout(
+ int nWidth
+, int nHeight
+)
+{
+ //
+ // Frames laying out canvas windows need the held.
+ // Dialogs or Frames laying out child controls do not.
+ //
+ if (IsKindOf(CLASSINFO(wxFrame)))
+ {
+ RECTL vRectFrame;
+ RECTL vRectClient;
+ RECTL vRectChild;
+ RECTL vRectHorz;
+ RECTL vRectVert;
+ SWP vSwpFrame;
+ SWP vSwpClient;
+ SWP vSwpChild;
+ SWP vSwpHorz;
+ SWP vSwpVert;
+ wxFrame* pFrame = wxDynamicCast(this, wxFrame);
+ bool bNewYSize = FALSE;
+ bool bNewXSize = FALSE;
+
+ ::WinQueryWindowPos(pFrame->GetFrame(), &vSwpFrame);
+ ::WinQueryWindowPos(GetHwnd(), &vSwpClient);
+
+ if (vSwpClient.cy != pFrame->GetSwpClient()->cy)
+ bNewYSize = TRUE;
+ if (vSwpClient.cx != pFrame->GetSwpClient()->cx)
+ bNewXSize = TRUE;
+
+ for (wxWindowList::Node* pNode = GetChildren().GetFirst();
+ pNode;
+ pNode = pNode->GetNext())
+ {
+ wxWindow* pChild = pNode->GetData();
+ int nWidthAdjust = 0;
+ int nHeightAdjust = 0;
+
+ if ( pChild->IsKindOf(CLASSINFO(wxGenericScrolledWindow)) ||
+ pChild->IsKindOf(CLASSINFO(wxScrolledWindow))
+ )
+ {
+ if(bNewYSize)
+ {
+ //
+ // This is needed SetSize will mess up the OS/2 child window
+ // positioning because we position in wxWindows coordinates,
+ // not OS/2 coordinates.
+ //
+ pChild->MoveChildren(pFrame->GetSwpClient()->cy - vSwpClient.cy);
+ pChild->Refresh();
+ }
+ ::WinQueryWindowPos(pChild->GetHWND(), &vSwpChild);
+
+ //
+ // Reset the child window size to account for scrollbars
+ //
+ if (pChild->GetScrollBarHorz() != NULLHANDLE)
+ nHeightAdjust = 20;
+ if (pChild->GetScrollBarVert() != NULLHANDLE)
+ nWidthAdjust = 20;
+ ::WinSetWindowPos( pChild->GetHWND()
+ ,HWND_TOP
+ ,vSwpChild.x
+ ,vSwpChild.y + nHeightAdjust
+ ,vSwpChild.cx - nWidthAdjust
+ ,vSwpChild.cy - nHeightAdjust
+ ,SWP_MOVE | SWP_SIZE
+ );
+
+ //
+ // Reset the scrollbar sizes...they will be all messed up after
+ // auto layouts
+ //
+ if (pChild->GetScrollBarHorz() != NULLHANDLE)
+ {
+ ::WinSetWindowPos( pChild->GetScrollBarHorz()
+ ,HWND_TOP
+ ,vSwpClient.x + vSwpChild.x
+ ,vSwpClient.y + vSwpChild.y
+ ,vSwpChild.cx - 20
+ ,20
+ ,SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER
+ );
+ }
+ if (pChild->GetScrollBarVert() != NULLHANDLE)
+ {
+ ::WinSetWindowPos( pChild->GetScrollBarVert()
+ ,HWND_TOP
+ ,vSwpClient.x + vSwpChild.x + vSwpChild.cx - 20
+ ,vSwpClient.y + vSwpChild.y + 20
+ ,20
+ ,vSwpChild.cy - 20
+ ,SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER
+ );
+ }
+ }
+ }
+ ::WinQueryWindowPos(GetHwnd(), pFrame->GetSwpClient());
+ }
+} // end of wxWindowOS2::OS2Layout
+
+wxWindowCreationHook::wxWindowCreationHook(
+ wxWindow* pWinBeingCreated
+)
+{
+ gpWinBeingCreated = pWinBeingCreated;
+} // end of wxWindowCreationHook::wxWindowCreationHook
+
+wxWindowCreationHook::~wxWindowCreationHook()
+{
+ gpWinBeingCreated = NULL;
+} // end of wxWindowCreationHook::~wxWindowCreationHook
+