//
static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; }
static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; }
+
+static wxWindow* gpWinBeingCreated = NULL;
+
// ---------------------------------------------------------------------------
// event tables
// ---------------------------------------------------------------------------
)
{
HWND hParent = NULLHANDLE;
- wxPoint vPos = rPos; // The OS/2 position
ULONG ulCreateFlags = 0;
WXDWORD dwExStyle = 0;
}
//
- // Generic OS/2 Windows are created with no owner, no Z Order, no Control data,
- // and no presentation parameters
+ // Generic OS/2 Windows have no Control Data but other classes
+ // that call OS2Create may have some.
//
- OS2Create( hParent
- ,(PSZ)wxCanvasClassName
+ OS2Create( (PSZ)wxCanvasClassName
,rName.c_str()
,ulCreateFlags
- ,vPos.x
- ,vPos.y
- ,WidthDefault(rSize.x)
- ,HeightDefault(rSize.y)
- ,NULLHANDLE
- ,NULLHANDLE
- ,m_windowId
- ,NULL
- ,NULL
+ ,rPos
+ ,rSize
+ ,NULL // Control Data
,dwExStyle
+ ,TRUE // Child
);
return(TRUE);
}
} // end of wxWindowOS2::UnsubclassWin
+bool wxCheckWindowWndProc(
+ WXHWND hWnd
+, WXFARPROC fnWndProc
+)
+{
+ static char zBuffer[512];
+ CLASSINFO vCls;
+
+ ::WinQueryClassName((HWND)hWnd, (LONG)512, (PCH)zBuffer);
+ ::WinQueryClassInfo(wxGetInstance(), (PSZ)zBuffer, &vCls);
+ return(fnWndProc == (WXFARPROC)vCls.pfnWindowProc);
+} // end of WinGuiBase_CheckWindowWndProc
+
//
// Make a Windows extended style from the given wxWindows window style
//
vDc.Clear();
} // end of wxWindowOS2::Clear
+void wxWindowOS2::Update()
+{
+ ::WinUpdateWindow(GetHwnd());
+} // end of wxWindowOS2::Update
+
+void wxWindowOS2::Freeze()
+{
+ ::WinSendMsg(GetHwnd(), WM_VRNDISABLED, (MPARAM)0, (MPARAM)0);
+} // end of wxWindowOS2::Freeze
+
+void wxWindowOS2::Thaw()
+{
+ ::WinSendMsg(GetHwnd(), WM_VRNENABLED, (MPARAM)TRUE, (MPARAM)0);
+
+ //
+ // We need to refresh everything or otherwise he invalidated area is not
+ // repainted.
+ //
+ Refresh();
+} // end of wxWindowOS2::Thaw
+
void wxWindowOS2::Refresh(
bool bEraseBack
, const wxRect* pRect
, int* pHeight
) const
{
- HWND hWnd = GetHwnd();
+ HWND hWnd;
RECTL vRect;
+ if (IsKindOf(CLASSINFO(wxFrame)))
+ {
+ wxFrame* pFrame = wxDynamicCast(this, wxFrame);
+ hWnd = pFrame->GetFrame();
+ }
+ else
+ hWnd = GetHwnd();
+
::WinQueryWindowRect(hWnd, &vRect);
if (pWidth)
) const
{
HWND hWnd = GetHwnd();
- HWND hWndClient;
RECTL vRect;
- if (IsKindOf(CLASSINFO(wxFrame)))
- hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT);
- else
- hWndClient = NULLHANDLE;
- if( hWndClient == NULLHANDLE)
- ::WinQueryWindowRect(GetHwnd(), &vRect);
- else
- ::WinQueryWindowRect(hWndClient, &vRect);
-
+ ::WinQueryWindowRect(hWnd, &vRect);
if (pWidth)
*pWidth = vRect.xRight;
if (pHeight)
GetPosition(&nCurrentX, &nCurrentY);
GetSize(&nCurrentWidth, &nCurrentHeight);
+ //
// ... and don't do anything (avoiding flicker) if it's already ok
- if (nX == nCurrentX && nY == nCurrentY &&
+ //
+ //
+ // Must convert Y coords to test for equality under OS/2
+ //
+ int nY2 = nY;
+ wxWindow* pParent = (wxWindow*)GetParent();
+
+ if (pParent)
+ {
+ int nOS2Height = GetOS2ParentHeight(pParent);
+
+ nY2 = nOS2Height - (nY2 + nHeight);
+ }
+ else
+ {
+ RECTL vRect;
+
+ ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+ nY2 = vRect.yTop - (nY2 + nHeight);
+ }
+ if (nX == nCurrentX && nY2 == nCurrentY &&
nWidth == nCurrentWidth && nHeight == nCurrentHeight)
{
return;
} // end of wxWindowOS2::OS2GetCreateWindowCoords
bool wxWindowOS2::OS2Create(
- WXHWND hParent
-, PSZ zClass
-, const wxChar* zTitle
+ PSZ zClass
+, const char* zTitle
, WXDWORD dwStyle
-, long lX
-, long lY
-, long lWidth
-, long lHeight
-, WXHWND hOwner
-, WXHWND WXUNUSED(hZOrder)
-, unsigned long ulId
+, const wxPoint& rPos
+, const wxSize& rSize
, void* pCtlData
-, void* pPresParams
, WXDWORD dwExStyle
+, bool bIsChild
)
{
ERRORID vError;
wxString sError;
- long lX1 = 0L;
- long lY1 = 0L;
- long lWidth1 = 20L;
- long lHeight1 = 20L;
- int nControlId = 0;
- int nNeedsubclass = 0;
- PCSZ pszClass = zClass;
-
- //
- // Find parent's size, if it exists, to set up a possible default
- // panel size the size of the parent window
- //
- lX1 = lX;
- lY1 = lY;
- if (lWidth > -1L)
- lWidth1 = lWidth;
- if (lHeight > -1L)
- lHeight1 = lHeight;
-
- wxWndHook = this;
+ int nX = 0L;
+ int nY = 0L;
+ int nWidth = 0L;
+ int nHeight = 0L;
+ wxWindow* pParent = GetParent();
+ HWND hWnd = NULLHANDLE;
+ HWND hParent;
+ long lControlId = 0L;
+ wxWindowCreationHook vHook(this);
+ wxString sClassName((wxChar*)zClass);
+
+ OS2GetCreateWindowCoords( rPos
+ ,rSize
+ ,nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
- //
- // check to see if the new window is a standard control
- //
- if ((ULONG)zClass == (ULONG)WC_BUTTON ||
- (ULONG)zClass == (ULONG)WC_COMBOBOX ||
- (ULONG)zClass == (ULONG)WC_CONTAINER ||
- (ULONG)zClass == (ULONG)WC_ENTRYFIELD ||
- (ULONG)zClass == (ULONG)WC_FRAME ||
- (ULONG)zClass == (ULONG)WC_LISTBOX ||
- (ULONG)zClass == (ULONG)WC_MENU ||
- (ULONG)zClass == (ULONG)WC_NOTEBOOK ||
- (ULONG)zClass == (ULONG)WC_SCROLLBAR ||
- (ULONG)zClass == (ULONG)WC_SPINBUTTON ||
- (ULONG)zClass == (ULONG)WC_STATIC ||
- (ULONG)zClass == (ULONG)WC_TITLEBAR ||
- (ULONG)zClass == (ULONG)WC_VALUESET
- )
- {
- nControlId = ulId;
- }
+ if (GetWindowStyleFlag() & wxPOPUP_WINDOW)
+ hParent = HWND_DESKTOP;
else
{
- // no standard controls
- if(wxString (wxT("wxFrameClass")) == wxString(zClass) )
+ if ((bIsChild || HasFlag(wxFRAME_TOOL_WINDOW)) && pParent )
{
- pszClass = WC_FRAME;
- nNeedsubclass = 1;
+ //
+ // This is either a normal child window or a top level window with
+ // wxFRAME_TOOL_WINDOW style (see below)
+ //
+ hParent = GetHwndOf(pParent);
}
else
{
- nControlId = ulId;
- if(nControlId < 0)
- nControlId = FID_CLIENT;
+ //
+ // This is either a window for which no parent was specified (not
+ // much we can do then) or a frame without wxFRAME_TOOL_WINDOW
+ // style: we should use NULL parent HWND for it or it would be
+ // always on top of its parent which is not what we usually want
+ // (in fact, we only want it for frames with the special
+ // wxFRAME_TOOL_WINDOW as above)
+ //
+ hParent = NULL;
+ }
+ }
+ if (bIsChild)
+ {
+ lControlId = GetId();
+ if (GetWindowStyleFlag() & wxCLIP_SIBLINGS)
+ {
+ dwStyle |= WS_CLIPSIBLINGS;
}
}
-
- HWND parent;
- if ( GetWindowStyleFlag() & wxPOPUP_WINDOW )
- {
- // popup windows should have desktop as parent because they shouldn't
- // be limited to the parents client area as child windows usually are
- parent = HWND_DESKTOP;
- }
- else if ( hParent )
- {
- parent = hParent;
- }
- else
- {
- // top level window
- parent = NULL;
- }
-
//
- // We will either have a registered class via string name or a standard PM Class via a long
+ // For each class "Foo" we have we also have "FooNR" ("no repaint") class
+ // which is the same but without CS_[HV]REDRAW class styles so using it
+ // ensures that the window is not fully repainted on each resize
//
- m_hWnd = (WXHWND)::WinCreateWindow(parent, zClass,
- (PSZ)zTitle ? zTitle : wxT(""),
- dwStyle, lX1, lY1, lWidth, lHeight,
- hOwner, HWND_TOP, (ULONG)nControlId,
- pCtlData, pPresParams);
-
- if (!m_hWnd)
+ if (GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE)
{
- vError = ::WinGetLastError(vHabmain);
- sError = wxPMErrorToStr(vError);
- wxLogError("Can't create window of class %s!. Error: %s\n", zClass, sError);
- return FALSE;
+ sClassName += wxT("NR");
}
- m_dwExStyle = dwExStyle;
- ::WinSetWindowULong(m_hWnd, QWL_USER, (ULONG) this);
- wxWndHook = NULL;
-
-#ifdef __WXDEBUG__
- wxNode* pNode = wxWinHandleList->Member(this);
- if (pNode)
+ //
+ // If the window being created is a Frame's Statusbar we need to use
+ // the actual Frame's size, not its client
+ //
+ if (pParent)
{
- HWND hWnd = (HWND)pNode->GetKeyInteger();
-
- if (hWnd != (HWND)m_hWnd)
-
+ if (IsKindOf(CLASSINFO(wxStatusBar)) &&
+ pParent->IsKindOf(CLASSINFO(wxFrame)))
{
- wxLogError("A second HWND association is being added for the same window!");
+ RECTL vRect;
+ wxFrame* pFrame = wxDynamicCast(pParent, wxFrame);
+
+ ::WinQueryWindowRect((HWND)pFrame->GetFrame(), &vRect);
+ nY = vRect.yTop - (nY + nHeight);
}
+ else
+ nY = pParent->GetSize().y - (nY + nHeight);
}
-#endif
- wxAssociateWinWithHandle((HWND)m_hWnd
- ,this
- );
- //
- // Now need to subclass window.
- //
- if(!nNeedsubclass)
+ else
{
- wxAssociateWinWithHandle((HWND)m_hWnd,this);
+ RECTL vRect;
+
+ ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+ nY = vRect.yTop - (nY + nHeight);
}
- else
+ m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent
+ ,(PSZ)sClassName.c_str()
+ ,(PSZ)zTitle ? zTitle : ""
+ ,(ULONG)dwStyle
+ ,(LONG)0L
+ ,(LONG)0L
+ ,(LONG)0L
+ ,(LONG)0L
+ ,NULLHANDLE
+ ,HWND_TOP
+ ,(ULONG)lControlId
+ ,pCtlData
+ ,NULL
+ );
+ if (!m_hWnd)
{
- SubclassWin(GetHWND());
+ vError = ::WinGetLastError(wxGetInstance());
+ sError = wxPMErrorToStr(vError);
+ return FALSE;
}
+ SubclassWin(m_hWnd);
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ SetSize( nX
+ ,nY
+ ,nWidth
+ ,nHeight
+ );
return TRUE;
-} // end of wxWindowOS2::OS2Create
+} // end of WinGuiBase_Window::OS2Create
// ===========================================================================
// OS2 PM message handlers
return(0L);
} // end of wxWindowOS2::GetOS2ParentHeight
+wxWindowCreationHook::wxWindowCreationHook(
+ wxWindow* pWinBeingCreated
+)
+{
+ gpWinBeingCreated = pWinBeingCreated;
+} // end of wxWindowCreationHook::wxWindowCreationHook
+
+wxWindowCreationHook::~wxWindowCreationHook()
+{
+ gpWinBeingCreated = NULL;
+} // end of wxWindowCreationHook::~wxWindowCreationHook
+
// ===========================================================================
// global functions
// ===========================================================================