#include "wx/scrolwin.h"
#include "wx/radiobox.h"
#include "wx/slider.h"
+ #include "wx/statbox.h"
#include "wx/statusbr.h"
#include "wx/toolbar.h"
#include "wx/settings.h"
const char *wxGetMessageName(int message);
#endif //__WXDEBUG__
-void wxRemoveHandleAssociation(wxWindowOS2* pWin);
-void wxAssociateWinWithHandle( HWND hWnd
- ,wxWindowOS2* pWin
- );
+wxWindowOS2* FindWindowForMouseEvent( wxWindow* pWin
+ ,short* pnX
+ ,short* pnY
+ );
+void wxRemoveHandleAssociation(wxWindowOS2* pWin);
+void wxAssociateWinWithHandle( HWND hWnd
+ ,wxWindowOS2* pWin
+ );
wxWindow* wxFindWinFromHandle(WXHWND hWnd);
//
//
// PM specific
//
- m_bDoubleClickAllowed = 0;
m_bWinCaptured = FALSE;
m_isBeingDeleted = FALSE;
- m_fnOldWndProc = 0;
+ m_fnOldWndProc = NULL;
m_bUseCtl3D = FALSE;
m_bMouseInWindow = FALSE;
m_bLastKeydownProcessed = FALSE;
for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
{
- wxFrame* pFrame = wxDynamicCast(pWin, wxFrame);
+ wxTopLevelWindow* pFrame = wxDynamicCast(pWin, wxTopLevelWindow);
if (pFrame)
{
if (pFrame->GetLastFocus() == this)
- pFrame->SetLastFocus((wxWindow*)NULL);
+ pFrame->SetLastFocus(NULL);
}
}
// Generic OS/2 Windows have no Control Data but other classes
// that call OS2Create may have some.
//
- OS2Create( (PSZ)wxCanvasClassName
- ,rName.c_str()
- ,ulCreateFlags
- ,rPos
- ,rSize
- ,NULL // Control Data
- ,dwExStyle
- ,TRUE // Child
- );
-
- return(TRUE);
+ return(OS2Create( (PSZ)wxCanvasClassName
+ ,rName.c_str()
+ ,ulCreateFlags
+ ,rPos
+ ,rSize
+ ,NULL // Control Data
+ ,dwExStyle
+ ,TRUE // Child
+ ));
} // end of wxWindowOS2::Create
// ---------------------------------------------------------------------------
::WinSetFocus(HWND_DESKTOP, hWnd);
} // end of wxWindowOS2::SetFocus
+void wxWindowOS2::SetFocusFromKbd()
+{
+ //
+ // Nothing else to do under OS/2
+ //
+ wxWindowBase::SetFocusFromKbd();
+} // end of wxWindowOS2::SetFocus
+
wxWindow* wxWindowBase::FindFocus()
{
HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
int nY2 = nY;
wxWindow* pParent = (wxWindow*)GetParent();
- if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
- {
- 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)
{
, int nHeight
)
{
- wxWindow* pParent = GetParent();
- HWND hWnd = GetHwnd();
- HWND hParentWnd = (HWND)0;
POINTL vPoint;
- RECTL vRect;
- RECTL vRect2;
- RECTL vRect3;
- HWND hClientWnd = (HWND)0;
+ int nActualWidth;
+ int nActualHeight;
+ wxWindow* pParent = (wxWindow*)GetParent();
+ HWND hParentWnd = (HWND)0;
- hClientWnd = ::WinWindowFromID(hWnd, FID_CLIENT);
- ::WinQueryWindowRect(hClientWnd, &vRect2);
- ::WinQueryWindowRect(hWnd, &vRect);
- ::WinQueryWindowRect(hParentWnd, &vRect3);
+ if (pParent)
+ hParentWnd = (HWND)pParent->GetHWND();
- int nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
- int nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
+ if (IsKindOf(CLASSINFO(wxFrame)))
+ {
+ wxFrame* pFrame = wxDynamicCast(this, wxFrame);
+ HWND hFrame = pFrame->GetFrame();
+ RECTL vRect;
+ RECTL vRect2;
+ RECTL vRect3;
- vPoint.x = vRect2.xLeft;
- vPoint.y = vRect2.yBottom;
- if (pParent)
+ ::WinQueryWindowRect(GetHwnd(), &vRect2);
+ ::WinQueryWindowRect(hFrame, &vRect);
+ ::WinQueryWindowRect(hParentWnd, &vRect3);
+ nActualWidth = vRect2.xRight - vRect2.xLeft - vRect.xRight + nWidth;
+ nActualHeight = vRect2.yTop - vRect2.yBottom - vRect.yTop + nHeight;
+
+ vPoint.x = vRect2.xLeft;
+ vPoint.y = vRect2.yBottom;
+ if (pParent)
+ {
+ vPoint.x -= vRect3.xLeft;
+ vPoint.y -= vRect3.yBottom;
+ }
+ }
+ else
{
- vPoint.x -= vRect3.xLeft;
- vPoint.y -= vRect3.yBottom;
+ int nX;
+ int nY;
+
+ GetPosition(&nX, &nY);
+ nActualWidth = nWidth;
+ nActualHeight = nHeight;
+
+ vPoint.x = nX;
+ vPoint.y = nY;
}
+ DoMoveWindow( vPoint.x
+ ,vPoint.y
+ ,nActualWidth
+ ,nActualHeight
+ );
- DoMoveWindow(vPoint.x, vPoint.y, nActualWidth, nActualHeight);
+ wxSizeEvent vEvent( wxSize( nWidth
+ ,nHeight
+ )
+ ,m_windowId
+ );
- wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId);
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::DoSetClientSize
pMsg = pMsg; // just shut up the compiler
#endif // __WXUNIVERSAL__
-#if wxUSE_TOOLTIPS
- if ( m_tooltip )
- {
- // relay mouse move events to the tooltip control
- QMSG* pQMsg = (QMSG*)pMsg;
-
- if (pQMsg->msg == WM_MOUSEMOVE )
- m_tooltip->RelayEvent(pMsg);
- }
-#endif // wxUSE_TOOLTIPS
-
return FALSE;
} // end of wxWindowOS2::OS2ProcessMessage
{
if (pFrame->GetStatusBar())
pFrame->PositionStatusBar();
+ if (pFrame->GetToolBar())
+ pFrame->PositionToolBar();
}
}
}
case WM_BUTTON3MOTIONEND:
case WM_BUTTON3MOTIONSTART:
{
- short x = LOWORD(wParam);
- short y = HIWORD(wParam);
+ if (uMsg == WM_BUTTON1DOWN && AcceptsFocus())
+ SetFocus();
+
+ short nX = LOWORD(wParam);
+ short nY = HIWORD(wParam);
- bProcessed = HandleMouseEvent(uMsg, x, y, (WXUINT)wParam);
+ //
+ // Redirect the event to a static control if necessary
+ //
+ if (this == GetCapture())
+ {
+ bProcessed = HandleMouseEvent( uMsg
+ ,nX
+ ,nY
+ ,(WXUINT)SHORT1FROMMP(wParam)
+ );
+ }
+ else
+ {
+ wxWindow* pWin = FindWindowForMouseEvent( this
+ ,&nX
+ ,&nY
+ );
+ bProcessed = pWin->HandleMouseEvent( uMsg
+ ,nX
+ ,nY
+ ,(WXUINT)SHORT1FROMMP(wParam)
+ );
+ }
}
break;
+
case WM_SYSCOMMAND:
bProcessed = HandleSysCommand(wParam, lParam);
break;
break;
case WM_QUERYDLGCODE:
- if ( m_lDlgCode )
+ if (!IsOfStandardClass())
{
- mResult = (MRESULT)m_lDlgCode;
- bProcessed = TRUE;
+ if ( m_lDlgCode )
+ {
+ mResult = (MRESULT)m_lDlgCode;
+ bProcessed = TRUE;
+ }
}
//
//else: get the dlg code from the DefWindowProc()
HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
wxWindowOS2* pChild = wxFindWinFromHandle(hWnd);
+ if (!pChild)
+ {
+ bProcessed = FALSE;
+ break;
+ }
if (pChild->IsKindOf(CLASSINFO(wxSlider)))
bProcessed = OS2OnScroll( wxVERTICAL
,(int)SHORT2FROMMP(wParam)
if ( bProcessed )
{
// we never set focus from here
- mResult = FALSE;
+ mResult = (MRESULT)FALSE;
}
break;
) const
{
bool bNonDefault = FALSE;
+ static const int DEFAULT_Y = 200;
+ static const int DEFAULT_H = 250;
if (rPos.x == -1)
{
- //
- // If set x to CW_USEDEFAULT, y parameter is ignored anyhow so we can
- // just as well set it to CW_USEDEFAULT as well
rnX = rnY = CW_USEDEFAULT;
}
else
{
rnX = rPos.x;
- rnY = rPos.y == -1 ? CW_USEDEFAULT : rPos.y;
+ rnY = rPos.y == -1 ? DEFAULT_Y : rPos.y;
bNonDefault = TRUE;
}
if (rSize.x == -1)
{
- //
- // As abobe, h is not used at all in this case anyhow
- //
rnWidth = rnHeight = CW_USEDEFAULT;
}
else
{
rnWidth = rSize.x;
- rnHeight = rSize.y == -1 ? CW_USEDEFAULT : rSize.y;
+ rnHeight = rSize.y == -1 ? DEFAULT_H : rSize.y;
bNonDefault = TRUE;
}
return bNonDefault;
} // end of wxWindowOS2::OS2GetCreateWindowCoords
+WXHWND wxWindowOS2::OS2GetParent() const
+{
+ return m_parent ? m_parent->GetHWND() : NULL;
+}
+
bool wxWindowOS2::OS2Create(
PSZ zClass
, const char* zTitle
,nHeight
);
- if (GetWindowStyleFlag() & wxPOPUP_WINDOW)
- hParent = HWND_DESKTOP;
- else
- {
- if ((bIsChild || HasFlag(wxFRAME_TOOL_WINDOW)) && pParent )
- {
- //
- // This is either a normal child window or a top level window with
- // wxFRAME_TOOL_WINDOW style (see below)
- //
- hParent = GetHwndOf(pParent);
- }
- else
- {
- //
- // 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();
{
sClassName += wxT("NR");
}
- 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
- );
+ m_hWnd = (WXHWND)::WinCreateWindow( (HWND)OS2GetParent()
+ ,(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)
{
vError = ::WinGetLastError(wxGetInstance());
} // end of wxWindowOS2::HandleSetFocus
bool wxWindowOS2::HandleKillFocus(
- WXHWND WXUNUSED(hWnd)
+ WXHWND hWnd
)
{
#if wxUSE_CARET
}
#endif // wxUSE_CARET
+#if wxUSE_TEXTCTRL
+ //
+ // If it's a wxTextCtrl don't send the event as it will be done
+ // after the control gets to process it.
+ //
+ wxTextCtrl* pCtrl = wxDynamicCastThis(wxTextCtrl);
+
+ if (pCtrl)
+ {
+ return FALSE;
+ }
+#endif
+
+ //
+ // Don't send the event when in the process of being deleted. This can
+ // only cause problems if the event handler tries to access the object.
+ //
+ if ( m_isBeingDeleted )
+ {
+ return FALSE;
+ }
+
wxFocusEvent vEvent( wxEVT_KILL_FOCUS
,m_windowId
);
vEvent.SetEventObject(this);
+
+ //
+ // wxFindWinFromHandle() may return NULL, it is ok
+ //
+ vEvent.SetWindow(wxFindWinFromHandle(hWnd));
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleKillFocus
rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0);
rEvent.SetTimestamp(s_currentMsg.time);
rEvent.m_eventObject = this;
+ rEvent.SetId(GetId());
#if wxUSE_MOUSEEVENT_HACK
m_lastMouseX = nX;
, WXUINT uFlags
)
{
+ bool bProcessed = FALSE;
+
//
// The mouse events take consecutive IDs from WM_MOUSEFIRST to
// WM_MOUSELAST, so it's enough to substract WM_MOUSEMOVE == WM_MOUSEFIRST
,uFlags
);
+ bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+ if (!bProcessed)
+ {
+ HPOINTER hPtr = ::WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
+ HPOINTER hCursor = (HPOINTER)GetCursor().GetHCURSOR();
+
+ if (hCursor != NULLHANDLE)
+ {
+ ::WinSetPointer(HWND_DESKTOP, hCursor);
+ bProcessed = TRUE;
+ }
+ }
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleMouseEvent
if (isASCII)
{
//
- // If 1 -> 26, translate to CTRL plus a letter.
+ // If 1 -> 26, translate to either special keycode or just set
+ // ctrlDown. IOW, Ctrl-C should result in keycode == 3 and
+ // ControlDown() == TRUE.
//
vId = (int)wParam;
if ((vId > 0) && (vId < 27))
default:
bCtrlDown = TRUE;
- vId = vId + 'a' - 1;
+ break;
}
}
}
IsKindOf(CLASSINFO(wxMenuBar)) ||
IsKindOf(CLASSINFO(wxToolBar))
)
- return(pParent->GetSize().y);
+ {
+ if (IsKindOf(CLASSINFO(wxToolBar)))
+ {
+ wxFrame* pFrame = wxDynamicCast(GetParent(), wxFrame);
+
+ if (pFrame->GetToolBar() == this)
+ return(pParent->GetSize().y);
+ else
+ return(pParent->GetClientSize().y);
+ }
+ else
+ return(pParent->GetSize().y);
+ }
else
return(pParent->GetClientSize().y);
}
return wxPoint(vPt.x, vPt.y);
}
+wxWindowOS2* FindWindowForMouseEvent(
+ wxWindow* pWin
+, short* pnX
+, short* pnY
+)
+{
+ HWND hWnd = GetHwndOf(pWin);
+ HWND hWndUnderMouse;
+ POINTL vPoint;
+ BOOL rcEnabled = FALSE;
+ BOOL rcVisible = FALSE;
+ HWND hWndDesktop = HWND_DESKTOP;
+
+ ::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
+ hWndUnderMouse = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE);
+ if (hWndUnderMouse != HWND_DESKTOP)
+ {
+ wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse);
+
+ if (pWinUnderMouse)
+ {
+ wxWindowList::Node* pCurrent = pWinUnderMouse->GetChildren().GetFirst();
+ wxWindow* pChild = NULL;
+ wxWindow* pGrandChild = NULL;
+ RECTL vRect;
+ POINTL vPoint2;
+
+ ::WinMapWindowPoints(HWND_DESKTOP, hWndUnderMouse, &vPoint, 1);
+ //
+ // Find a child window mouse might be under
+ //
+ while (pCurrent)
+ {
+ wxWindow* pChild = pCurrent->GetData();
+
+ vPoint2.x = vPoint.x;
+ vPoint2.y = vPoint.y;
+ ::WinMapWindowPoints(hWndUnderMouse, pChild->GetHWND(), &vPoint2, 1);
+ ::WinQueryWindowRect(pChild->GetHWND(), &vRect);
+ if (::WinPtInRect(vHabmain, &vRect, &vPoint2))
+ {
+ if (pChild->IsTopLevel())
+ {
+ POINTL vPoint3;
+ wxWindowList::Node* pCurrent2 =pChild->GetChildren().GetFirst();
+
+ while (pCurrent2)
+ {
+ wxWindow* pGrandChild = pCurrent2->GetData();
+
+ vPoint3.x = vPoint2.x;
+ vPoint3.y = vPoint2.y;
+ ::WinMapWindowPoints( pChild->GetHWND()
+ ,pGrandChild->GetHWND()
+ ,&vPoint3
+ ,1
+ );
+ ::WinQueryWindowRect(pGrandChild->GetHWND(), &vRect);
+ if (::WinPtInRect(vHabmain, &vRect, &vPoint3))
+ {
+ hWndUnderMouse = GetHwndOf(pGrandChild);
+ pWinUnderMouse = pGrandChild;
+ break;
+ }
+ pCurrent2 = pCurrent2->GetNext();
+ }
+ if (pGrandChild)
+ break;
+ }
+ hWndUnderMouse = GetHwndOf(pChild);
+ pWinUnderMouse = pChild;
+ rcVisible = ::WinIsWindowVisible(hWndUnderMouse);
+ rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse);
+ if (rcVisible && rcEnabled)
+ break;
+ }
+ pCurrent = pCurrent->GetNext();
+ }
+ }
+ }
+ rcVisible = ::WinIsWindowVisible(hWndUnderMouse);
+ rcEnabled = ::WinIsWindowEnabled(hWndUnderMouse);
+
+
+ //
+ // Check that we have a child window which is susceptible to receive mouse
+ // events: for this it must be shown and enabled
+ //
+ if ( hWndUnderMouse &&
+ hWndUnderMouse != hWnd &&
+ rcVisible && rcEnabled)
+ {
+ wxWindow* pWinUnderMouse = wxFindWinFromHandle((WXHWND)hWndUnderMouse);
+
+ if (pWinUnderMouse)
+ {
+ //
+ // Translate the mouse coords to the other window coords
+ //
+ pWin = pWinUnderMouse;
+ }
+ }
+ return pWin;
+} // end of FindWindowForMouseEvent
+