+/////////////////////////////////////////////////////////////////////////////
// Name: windows.cpp
// Purpose: wxWindow
// Author: David Webster
wxMenu* wxCurrentPopupMenu = NULL;
#endif // wxUSE_MENUS_NATIVE
-wxList* wxWinHandleList = NULL;
-
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
}
#endif // wxUSE_CONTROLS
- wxWindowList::Node* pCurrent = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
- while (pCurrent)
+ while (current)
{
- wxWindow* pChildWin = pCurrent->GetData();
+ wxWindow* pChildWin = current->GetData();
wxWindow* pWnd = pChildWin->FindItem(lId);
if (pWnd)
return pWnd;
- pCurrent = pCurrent->GetNext();
+ current = current->GetNext();
}
return(NULL);
} // end of wxWindowOS2::FindItem
, bool bControlOnly
) const
{
- wxWindowList::Node* pCurrent = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator current = GetChildren().GetFirst();
- while (pCurrent)
+ while (current)
{
- wxWindow* pParent = pCurrent->GetData();
+ wxWindow* pParent = current->GetData();
//
// Do a recursive search.
#endif // wxUSE_CONTROLS
)
{
- wxWindow* pItem = pCurrent->GetData();
+ wxWindow* pItem = current->GetData();
if (pItem->GetHWND() == hWnd)
return(pItem);
return(pItem);
}
}
- pCurrent = pCurrent->GetNext();
+ current = current->GetNext();
}
return(NULL);
} // end of wxWindowOS2::FindItemByHWND
//
// Default command handler
//
-bool wxWindowOS2::OS2Command(
- WXUINT WXUNUSED(uParam)
-, WXWORD WXUNUSED(uId)
-)
+bool wxWindowOS2::OS2Command( WXUINT WXUNUSED(uParam),
+ WXWORD WXUNUSED(uId) )
{
- return(FALSE);
+ return false;
}
// ----------------------------------------------------------------------------
//
// PM specific
//
- m_bWinCaptured = FALSE;
+ m_bWinCaptured = false;
m_fnOldWndProc = NULL;
- m_bUseCtl3D = FALSE;
- m_bMouseInWindow = FALSE;
- m_bLastKeydownProcessed = FALSE;
+ m_bUseCtl3D = false;
+ m_bMouseInWindow = false;
+ m_bLastKeydownProcessed = false;
m_pChildrenDisabled = NULL;
//
m_nXThumbSize = 0;
m_nYThumbSize = 0;
- m_bBackgroundTransparent = FALSE;
+ m_bBackgroundTransparent = false;
//
// As all windows are created with WS_VISIBLE style...
//
- m_isShown = TRUE;
+ m_isShown = true;
#if wxUSE_MOUSEEVENT_HACK
m_lLastMouseX =
//
wxWindowOS2::~wxWindowOS2()
{
- m_isBeingDeleted = TRUE;
+ m_isBeingDeleted = true;
for (wxWindow* pWin = GetParent(); pWin; pWin = pWin->GetParent())
{
} // end of wxWindowOS2::~wxWindowOS2
// real construction (Init() must have been called before!)
-bool wxWindowOS2::Create(
- wxWindow* pParent
-, wxWindowID vId
-, const wxPoint& rPos
-, const wxSize& rSize
-, long lStyle
-, const wxString& rName
-)
+bool wxWindowOS2::Create( wxWindow* pParent,
+ wxWindowID vId,
+ const wxPoint& rPos,
+ const wxSize& rSize,
+ long lStyle,
+ const wxString& rName )
{
- HWND hParent = NULLHANDLE;
- ULONG ulCreateFlags = 0;
- WXDWORD dwExStyle = 0;
+ HWND hParent = NULLHANDLE;
+ ULONG ulCreateFlags = 0;
+ WXDWORD dwExStyle = 0;
- wxCHECK_MSG(pParent, FALSE, wxT("can't create wxWindow without parent"));
+ wxCHECK_MSG(pParent, false, wxT("can't create wxWindow without parent"));
#if wxUSE_STATBOX
//
_T("wxStaticBox can't be used as a window parent!") );
#endif // wxUSE_STATBOX
+ // Ensure groupbox backgrounds are painted
+ if (IsKindOf(CLASSINFO(wxPanel)))
+ lStyle &= ~wxCLIP_CHILDREN;
+
if ( !CreateBase( pParent
,vId
,rPos
,wxDefaultValidator
,rName
))
- return(FALSE);
+ return false;
if (pParent)
{
if (lStyle & wxPOPUP_WINDOW)
{
ulCreateFlags &= ~WS_VISIBLE;
- m_isShown = FALSE;
+ m_isShown = false;
}
else
{
,rSize
,NULL // Control Data
,dwExStyle
- ,TRUE // Child
+ ,true // Child
));
} // end of wxWindowOS2::Create
wxWindowBase::SetFocusFromKbd();
} // end of wxWindowOS2::SetFocus
-wxWindow* wxWindowBase::FindFocus()
+wxWindow* wxWindowBase::DoFindFocus()
{
HWND hWnd = ::WinQueryFocus(HWND_DESKTOP);
return wxFindWinFromHandle((WXHWND)hWnd);
}
return NULL;
-} // wxWindowBase::FindFocus
+} // wxWindowBase::DoFindFocus
-bool wxWindowOS2::Enable(
- bool bEnable
-)
+bool wxWindowOS2::Enable( bool bEnable )
{
if (!wxWindowBase::Enable(bEnable))
- return(FALSE);
+ return false;
HWND hWnd = GetHwnd();
// out later) of everything which would be really ugly
//
if (IsTopLevel())
- return TRUE;
+ return true;
- wxWindowList::Node* pNode = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
- while (pNode)
+ while (node)
{
- wxWindow* pChild = pNode->GetData();
+ wxWindow* pChild = node->GetData();
if (bEnable)
{
m_pChildrenDisabled->Append(pChild);
}
}
- pNode = pNode->GetNext();
+ node = node->GetNext();
}
if (bEnable && m_pChildrenDisabled)
{
delete m_pChildrenDisabled;
m_pChildrenDisabled = NULL;
}
- return TRUE;
+ return true;
} // end of wxWindowOS2::Enable
-bool wxWindowOS2::Show(
- bool bShow
-)
+bool wxWindowOS2::Show( bool bShow )
{
if (!wxWindowBase::Show(bShow))
- return(FALSE);
+ return false;
HWND hWnd = GetHwnd();
{
::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER);
}
- return TRUE;
+ return true;
} // end of wxWindowOS2::Show
void wxWindowOS2::Raise()
::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE);
} // end of wxWindowOS2::Lower
-void wxWindowOS2::SetTitle(
- const wxString& rTitle
-)
+void wxWindowOS2::SetTitle( const wxString& rTitle )
{
- ::WinSetWindowText(GetHwnd(), rTitle.c_str());
+ ::WinSetWindowText(GetHwnd(), (PSZ)rTitle.c_str());
} // end of wxWindowOS2::SetTitle
wxString wxWindowOS2::GetTitle() const
void wxWindowOS2::DoCaptureMouse()
{
- HWND hWnd = GetHwnd();
+ HWND hWnd = GetHwnd();
if (hWnd && !m_bWinCaptured)
{
::WinSetCapture(HWND_DESKTOP, hWnd);
- m_bWinCaptured = TRUE;
+ m_bWinCaptured = true;
}
} // end of wxWindowOS2::GetTitle
if (m_bWinCaptured)
{
::WinSetCapture(HWND_DESKTOP, NULLHANDLE);
- m_bWinCaptured = FALSE;
+ m_bWinCaptured = false;
}
} // end of wxWindowOS2::ReleaseMouse
return hwnd ? wxFindWinFromHandle((WXHWND)hwnd) : (wxWindow *)NULL;
} // end of wxWindowBase::GetCapture
-bool wxWindowOS2::SetFont(
- const wxFont& rFont
-)
+bool wxWindowOS2::SetFont( const wxFont& rFont )
{
if (!wxWindowBase::SetFont(rFont))
{
// nothing to do
- return(FALSE);
+ return false;
}
- HWND hWnd = GetHwnd();
+ HWND hWnd = GetHwnd();
- wxOS2SetFont( hWnd
- ,rFont
- );
- return(TRUE);
+ wxOS2SetFont( hWnd, rFont );
+ return true;
} // end of wxWindowOS2::SetFont
-bool wxWindowOS2::SetCursor(
- const wxCursor& rCursor
-) // check if base implementation is OK
+// check if base implementation is OK
+bool wxWindowOS2::SetCursor( const wxCursor& rCursor)
{
if ( !wxWindowBase::SetCursor(rCursor))
{
// no change
- return FALSE;
+ return false;
}
if ( m_cursor.Ok() ) {
::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR());
}
}
- return TRUE;
+ return true;
} // end of wxWindowOS2::SetCursor
void wxWindowOS2::WarpPointer(
::WinSendMsg(m_hWndScrollBarVert, SBM_SETPOS, (MPARAM)nPos, (MPARAM)NULL);
} // end of wxWindowOS2::SetScrollPos
-void wxWindowOS2::SetScrollbar(
- int nOrient
-, int nPos
-, int nThumbVisible
-, int nRange
-, bool WXUNUSED(bRefresh)
-)
+void wxWindowOS2::SetScrollbar( int nOrient,
+ int nPos,
+ int nThumbVisible,
+ int nRange,
+ bool WXUNUSED(bRefresh) )
{
HWND hWnd = GetHwnd();
int nOldRange = nRange - nThumbVisible;
vInfo.cb = sizeof(SBCDATA);
vInfo.posFirst = 0;
vInfo.posLast = (SHORT)nRange1;
- vInfo.posThumb = nPos;
+ vInfo.posThumb = (SHORT)nPos;
if (nOrient == wxHORIZONTAL )
{
}
} // end of wxWindowOS2::SetScrollbar
-void wxWindowOS2::ScrollWindow(
- int nDx
-, int nDy
-, const wxRect* pRect
-)
+
+void wxWindowOS2::ScrollWindow( int nDx,
+ int nDy,
+ const wxRect* pRect )
{
- RECTL vRect;
+ RECTL vRect;
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
+ int height = vRect.yTop;
if (pRect)
{
vRect.xLeft = pRect->x;
- vRect.yTop = pRect->y + pRect->height;
+ vRect.yTop = height - pRect->y;
vRect.xRight = pRect->x + pRect->width;
- vRect.yBottom = pRect->y;
- }
- else
- {
- ::WinQueryWindowRect(GetHwnd(), &vRect);
+ vRect.yBottom = vRect.yTop - pRect->height;
}
nDy *= -1; // flip the sign of Dy as OS/2 is opposite Windows.
::WinScrollWindow( GetHwnd()
,(LONG)nDy
,&vRect
,&vRect
- ,NULLHANDLE
+ ,NULL
,NULL
,SW_SCROLLCHILDREN | SW_INVALIDATERGN
);
- Refresh();
} // end of wxWindowOS2::ScrollWindow
// ---------------------------------------------------------------------------
}
} // end of wxWindowOS2::SetWindowStyleFlag
-WXDWORD wxWindowOS2::OS2GetStyle(
- long lFlags
-, WXDWORD* pdwExstyle
-) const
+WXDWORD wxWindowOS2::OS2GetStyle( long lFlags,
+ WXDWORD* WXUNUSED(pdwExstyle) ) const
{
WXDWORD dwStyle = 0L;
dwStyle |= WS_CLIPSIBLINGS;
return dwStyle;
-} // end of wxWindowMSW::MSWGetStyle
+} // end of wxWindowOS2::OS2GetStyle
//
// Make a Windows extended style from the given wxWidgets window style
//
// Generate a LEAVE event
//
- m_bMouseInWindow = FALSE;
+ m_bMouseInWindow = false;
//
// Unfortunately the mouse button and keyboard state may have changed
//
// Set this window to be the child of 'parent'.
//
-bool wxWindowOS2::Reparent(
- wxWindow* pParent
-)
+bool wxWindowOS2::Reparent( wxWindow* pParent)
{
if (!wxWindowBase::Reparent(pParent))
- return FALSE;
+ return false;
- HWND hWndChild = GetHwnd();
- HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
+ HWND hWndChild = GetHwnd();
+ HWND hWndParent = GetParent() ? GetWinHwnd(GetParent()) : (HWND)0;
::WinSetParent(hWndChild, hWndParent, TRUE);
- return TRUE;
+ return true;
} // end of wxWindowOS2::Reparent
void wxWindowOS2::Update()
Refresh();
} // end of wxWindowOS2::Thaw
-void wxWindowOS2::Refresh(
- bool bEraseBack
-, const wxRect* pRect
-)
+void wxWindowOS2::Refresh( bool bEraseBack,
+ const wxRect* pRect )
{
- HWND hWnd = GetHwnd();
+ HWND hWnd = GetHwnd();
if (hWnd)
{
if (pRect)
{
- RECTL vOs2Rect;
+ RECTL vOs2Rect;
+ int height;
+ ::WinQueryWindowRect(GetHwnd(), &vOs2Rect);
+ height = vOs2Rect.yTop;
vOs2Rect.xLeft = pRect->x;
- vOs2Rect.yBottom = pRect->y;
+ vOs2Rect.yTop = height - pRect->y;
vOs2Rect.xRight = pRect->x + pRect->width;
- vOs2Rect.yTop = pRect->y + pRect->height;
+ vOs2Rect.yBottom = vOs2Rect.yTop - pRect->height;
::WinInvalidateRect(hWnd, &vOs2Rect, bEraseBack);
}
RECTL vRect;
wxWindow* pParent = GetParent();
+ /* Due to OS/2's inverted coordinate system, changing the height
+ of a window requires repositioning all it's children, e.g. if
+ you want a child of height 100 to be at the top left corner of
+ the parent you need to position the lower left corner of the
+ child at (0, (height of parent - 100)), so, obviously, if the
+ height of the parent changes, the child needs to be repositioned. */
+ int nHeightDelta;
+ GetSize(0, &nHeightDelta);
+ nHeightDelta = nHeight - nHeightDelta;
+
if (pParent && !IsKindOf(CLASSINFO(wxDialog)))
{
int nOS2Height = GetOS2ParentHeight(pParent);
,vSwpScroll.cy - nAdjustHeight
,SWP_MOVE | SWP_SIZE
);
- nYDiff += nAdjustHeight;
+ nYDiff -= nAdjustHeight;
}
MoveChildren(nYDiff);
::WinQueryWindowPos(GetHwnd(), &m_vWinSwp);
}
+#if 0
+ // FIXME: By my logic, the next line should be needed as it moves child
+ // windows when resizing the parent (see comment at beginning of
+ // function). However, this seems to cause lots of problems. At
+ // least, e.g. the grid sample almost works with this line
+ // commented out but crashes badly with it.
+ MoveChildren(nHeightDelta);
+#endif
} // end of wxWindowOS2::DoMoveWindow
//
// the width/height to best suit our contents, otherwise we reuse the current
// width/height
//
-void wxWindowOS2::DoSetSize(
- int nX
-, int nY
-, int nWidth
-, int nHeight
-, int nSizeFlags
-)
+void wxWindowOS2::DoSetSize( int nX,
+ int nY,
+ int nWidth,
+ int nHeight,
+ int nSizeFlags )
{
//
// Get the current size and position...
//
- int nCurrentX;
- int nCurrentY;
- int nCurrentWidth;
- int nCurrentHeight;
- wxSize vSize(-1, -1);
+ int nCurrentX;
+ int nCurrentY;
+ int nCurrentWidth;
+ int nCurrentHeight;
+ wxSize vSize = wxDefaultSize;
GetPosition(&nCurrentX, &nCurrentY);
GetSize(&nCurrentWidth, &nCurrentHeight);
return;
}
- if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ if (nX == wxDefaultCoord && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
nX = nCurrentX;
- if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ if (nY == wxDefaultCoord && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
nY = nCurrentY;
AdjustForParentClientOrigin(nX, nY, nSizeFlags);
- if (nWidth == -1)
+ if (nWidth == wxDefaultCoord)
{
if (nSizeFlags & wxSIZE_AUTO_WIDTH)
{
}
}
- if (nHeight == -1)
+ if (nHeight == wxDefaultCoord)
{
if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
{
- if (vSize.x == -1)
+ if (vSize.x == wxDefaultCoord)
{
vSize = DoGetBestSize();
}
}
}
- DoMoveWindow( nX
- ,nY
- ,nWidth
- ,nHeight
- );
+ DoMoveWindow( nX, nY, nWidth, nHeight );
} // end of wxWindowOS2::DoSetSize
-void wxWindowOS2::DoSetClientSize(
- int nWidth
-, int nHeight
-)
+void wxWindowOS2::DoSetClientSize( int nWidth,
+ int nHeight )
{
- POINTL vPoint;
- int nActualWidth;
- int nActualHeight;
- wxWindow* pParent = (wxWindow*)GetParent();
- HWND hParentWnd = (HWND)0;
+ POINTL vPoint;
+ int nActualWidth;
+ int nActualHeight;
+ wxWindow* pParent = (wxWindow*)GetParent();
+ HWND hParentWnd = (HWND)0;
if (pParent)
hParentWnd = (HWND)pParent->GetHWND();
if (IsKindOf(CLASSINFO(wxFrame)))
{
- wxFrame* pFrame = wxDynamicCast(this, wxFrame);
- HWND hFrame = pFrame->GetFrame();
- RECTL vRect;
- RECTL vRect2;
- RECTL vRect3;
+ wxFrame* pFrame = wxDynamicCast(this, wxFrame);
+ HWND hFrame = pFrame->GetFrame();
+ RECTL vRect;
+ RECTL vRect2;
+ RECTL vRect3;
::WinQueryWindowRect(GetHwnd(), &vRect2);
::WinQueryWindowRect(hFrame, &vRect);
}
else
{
- int nX;
- int nY;
+ int nX;
+ int nY;
GetPosition(&nX, &nY);
nActualWidth = nWidth;
vPoint.x = nX;
vPoint.y = nY;
}
- DoMoveWindow( vPoint.x
- ,vPoint.y
- ,nActualWidth
- ,nActualHeight
- );
-
- wxSizeEvent vEvent( wxSize( nWidth
- ,nHeight
- )
- ,m_windowId
- );
+ DoMoveWindow( vPoint.x, vPoint.y, nActualWidth, nActualHeight );
+ wxSize size( nWidth, nHeight );
+ wxSizeEvent vEvent( size, m_windowId );
vEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::DoSetClientSize
-wxPoint wxWindowOS2::GetClientAreaOrigin() const
-{
- return wxPoint(0, 0);
-} // end of wxWindowOS2::GetClientAreaOrigin
-
// ---------------------------------------------------------------------------
// text metrics
// ---------------------------------------------------------------------------
return(vFontMetrics.lAveCharWidth);
} // end of wxWindowOS2::GetCharWidth
-void wxWindowOS2::GetTextExtent(
- const wxString& rString
-, int* pX
-, int* pY
-, int* pDescent
-, int* pExternalLeading
-, const wxFont* pTheFont
-) const
+void wxWindowOS2::GetTextExtent( const wxString& rString,
+ int* pX,
+ int* pY,
+ int* pDescent,
+ int* pExternalLeading,
+ const wxFont* WXUNUSED(pTheFont) ) const
{
- POINTL avPoint[TXTBOX_COUNT];
- POINTL vPtMin;
- POINTL vPtMax;
- int i;
- int l;
- FONTMETRICS vFM; // metrics structure
- BOOL bRc = FALSE;
- char* pStr;
- HPS hPS;
-
+ POINTL avPoint[TXTBOX_COUNT];
+ POINTL vPtMin;
+ POINTL vPtMax;
+ int i;
+ int l;
+ FONTMETRICS vFM; // metrics structure
+ BOOL bRc = FALSE;
+ char* pStr;
+ HPS hPS;
hPS = ::WinGetPS(GetHwnd());
{
//
// Get the mouse position
- POINTL vPt;
+ POINTL vPt;
::WinQueryPointerPos(HWND_DESKTOP, &vPt);
// Find the window which currently has the cursor and go up the window
// chain until we find this window - or exhaust it
//
- HWND hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE);
+ HWND hWnd = ::WinWindowFromPoint(HWND_DESKTOP, &vPt, TRUE);
while (hWnd && (hWnd != GetHwnd()))
hWnd = ::WinQueryWindow(hWnd, QW_PARENT);
// ---------------------------------------------------------------------------
//
#if wxUSE_MENUS_NATIVE
-bool wxWindowOS2::DoPopupMenu(
- wxMenu* pMenu
-, int nX
-, int nY
-)
+bool wxWindowOS2::DoPopupMenu( wxMenu* pMenu,
+ int nX,
+ int nY )
{
- HWND hWndOwner = GetHwnd();
- HWND hWndParent = GetHwnd();
- HWND hMenu = GetHmenuOf(pMenu);
- bool bIsWaiting = TRUE;
+ HWND hWndOwner = GetHwnd();
+ HWND hWndParent = GetHwnd();
+ HWND hMenu = GetHmenuOf(pMenu);
+ bool bIsWaiting = true;
+ int nHeight;
+
+ // Protect against recursion
+ if (wxCurrentPopupMenu)
+ return false;
pMenu->SetInvokingWindow(this);
pMenu->UpdateUI();
-
- if ( x == -1 && y == -1 )
+
+ if ( nX == -1 && nY == -1 )
{
wxPoint mouse = wxGetMousePosition();
nX = mouse.x; nY = mouse.y;
DoClientToScreen( &nX
,&nY
);
+ DoGetSize(0,&nHeight);
+ nY = nHeight - nY;
}
wxCurrentPopupMenu = pMenu;
{
QMSG vMsg;
- if (vMsg.msg == WM_MENUEND || vMsg.msg == WM_COMMAND)
- {
- bIsWaiting = FALSE;
- }
+ ::WinGetMsg(vHabmain,&vMsg, (HWND)0, 0, 0);
+ if (vMsg.msg == WM_COMMAND)
+ bIsWaiting = false;
::WinDispatchMsg(vHabmain, (PQMSG)&vMsg);
-
}
+
wxCurrentPopupMenu = NULL;
pMenu->SetInvokingWindow(NULL);
- return TRUE;
+ return true;
} // end of wxWindowOS2::DoPopupMenu
#endif // wxUSE_MENUS_NATIVE
// pre/post message processing
// ===========================================================================
-MRESULT wxWindowOS2::OS2DefWindowProc(
- WXUINT uMsg
-, WXWPARAM wParam
-, WXLPARAM lParam
-)
+MRESULT wxWindowOS2::OS2DefWindowProc( WXUINT uMsg,
+ WXWPARAM wParam,
+ WXLPARAM lParam )
{
if (m_fnOldWndProc)
return (MRESULT)m_fnOldWndProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
return ::WinDefWindowProc(GetHWND(), uMsg, (MPARAM)wParam, (MPARAM)lParam);
} // end of wxWindowOS2::OS2DefWindowProc
-bool wxWindowOS2::OS2ProcessMessage(
- WXMSG* pMsg
-)
+bool wxWindowOS2::OS2ProcessMessage( WXMSG* pMsg )
{
// wxUniversal implements tab traversal itself
#ifndef __WXUNIVERSAL__
//
// Intercept dialog navigation keys
//
- bool bProcess = TRUE;
- USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1);
+ bool bProcess = true;
+ USHORT uKeyFlags = SHORT1FROMMP(pQMsg->mp1);
if (uKeyFlags & KC_KEYUP)
- bProcess = FALSE;
+ bProcess = false;
if (uKeyFlags & KC_ALT)
- bProcess = FALSE;
+ bProcess = false;
if (!(uKeyFlags & KC_VIRTUALKEY))
- bProcess = FALSE;
+ bProcess = false;
if (bProcess)
{
ulDlgCode = (ULONG)::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0);
}
- bool bForward = TRUE;
- bool bWindowChange = FALSE;
+ bool bForward = true;
+ bool bWindowChange = false;
switch (SHORT2FROMMP(pQMsg->mp2))
{
//
if (!bShiftDown)
{
- bProcess = FALSE;
+ bProcess = false;
}
else
{
{
case DLGC_ENTRYFIELD:
case DLGC_MLE:
- bProcess = TRUE;
+ bProcess = true;
break;
default:
- bProcess = FALSE;
+ bProcess = false;
}
//
case VK_UP:
case VK_LEFT:
if (bCtrlDown)
- bProcess = FALSE;
+ bProcess = false;
else
- bForward = FALSE;
+ bForward = false;
break;
case VK_DOWN:
case VK_RIGHT:
if (bCtrlDown)
- bProcess = FALSE;
+ bProcess = false;
break;
case VK_ENTER:
//
// ctrl-enter is not processed
//
- return FALSE;
+ return false;
}
else if (ulDlgCode & DLGC_BUTTON)
{
//
// buttons want process Enter themselevs
//
- bProcess = FALSE;
+ bProcess = false;
}
else
{
// If we do have a default button, do press it
//
pBtn->OS2Command(BN_CLICKED, 0 /* unused */);
- return TRUE;
+ return true;
}
else if (!IsTopLevel())
{
// if not a top level window, let parent
// handle it
//
- return FALSE;
+ return false;
}
// else: but if it does not it makes sense to make
// it work like a TAB - and that's what we do.
break;
default:
- bProcess = FALSE;
+ bProcess = false;
}
if (bProcess)
//
pBtn->SetDefault();
}
- return TRUE;
+ return true;
}
}
}
// Let Dialogs process
//
if (::WinSendMsg(pQMsg->hwnd, WM_QUERYDLGCODE, pQMsg, 0));
- return TRUE;
+ return true;
}
#else
pMsg = pMsg; // just shut up the compiler
#endif // __WXUNIVERSAL__
- return FALSE;
+ return false;
} // end of wxWindowOS2::OS2ProcessMessage
-bool wxWindowOS2::OS2TranslateMessage(
- WXMSG* pMsg
-)
+bool wxWindowOS2::OS2TranslateMessage( WXMSG* pMsg )
{
#if wxUSE_ACCEL && !defined(__WXUNIVERSAL__)
- return m_acceleratorTable.Translate(m_hWnd, pMsg);
+ return m_acceleratorTable.Translate(m_hWnd, pMsg);
#else
- pMsg = pMsg;
- return FALSE;
+ pMsg = pMsg;
+ return false;
#endif //wxUSE_ACCEL
} // end of wxWindowOS2::OS2TranslateMessage
-bool wxWindowOS2::OS2ShouldPreProcessMessage(
- WXMSG* pMsg
-)
+bool wxWindowOS2::OS2ShouldPreProcessMessage( WXMSG* WXUNUSED(pMsg) )
{
// preprocess all messages by default
- return TRUE;
+ return true;
} // end of wxWindowOS2::OS2ShouldPreProcessMessage
// ---------------------------------------------------------------------------
// We will add (or delete) messages we need to handle at this default
// level as we go
//
-MRESULT wxWindowOS2::OS2WindowProc(
- WXUINT uMsg
-, WXWPARAM wParam
-, WXLPARAM lParam
-)
+MRESULT wxWindowOS2::OS2WindowProc( WXUINT uMsg,
+ WXWPARAM wParam,
+ WXLPARAM lParam )
{
//
// Did we process the uMsg?
//
- bool bProcessed = FALSE;
- MRESULT mResult;
+ bool bProcessed = false;
+ MRESULT mResult;
//
// For most messages we should return 0 when we do process the message
case WM_DESTROY:
HandleDestroy();
- bProcessed = TRUE;
+ bProcessed = true;
break;
case WM_MOVE:
bProcessed = HandleActivate( wState
,(WXHWND)hWnd
);
- bProcessed = FALSE;
+ bProcessed = false;
}
break;
// Don't let the DefWindowProc() destroy our window - we'll do it
// ourselves in ~wxWindow
//
- bProcessed = TRUE;
+ bProcessed = true;
mResult = (MRESULT)TRUE;
break;
if ( m_lDlgCode )
{
mResult = (MRESULT)m_lDlgCode;
- bProcessed = TRUE;
+ bProcessed = true;
}
}
//
}
else // keydown event
{
- m_bLastKeydownProcessed = FALSE;
+ m_bLastKeydownProcessed = false;
//
// If this has been processed by an event handler,
// return 0 now (we've handled it). DON't RETURN
case VK_CAPSLOCK:
case VK_NUMLOCK:
case VK_SCRLLOCK:
- bProcessed = TRUE;
+ bProcessed = true;
break;
// Avoid duplicate messages to OnChar for these ASCII keys: they
case VK_ENTER:
case VK_BACKSPACE:
case VK_TAB:
- // But set processed to FALSE, not TRUE to still pass them to
+ // But set processed to false, not true to still pass them to
// the control's default window proc - otherwise built-in
// keyboard handling won't work
- bProcessed = FALSE;
+ bProcessed = false;
break;
default:
// a key in an EVT_KEY_DOWN handler is meant, by
// design, to prevent EVT_CHARs from happening
//
- m_bLastKeydownProcessed = FALSE;
- bProcessed = TRUE;
+ m_bLastKeydownProcessed = false;
+ bProcessed = true;
}
else // do generate a CHAR event
{
- bProcessed = HandleChar(wParam, lParam, TRUE);
+ bProcessed = HandleChar(wParam, lParam, true);
break;
}
}
if (!pWin)
{
- bProcessed = FALSE;
+ bProcessed = false;
break;
}
if (pWin->IsKindOf(CLASSINFO(wxBitmapButton)))
}
return 0;
}
- break;
+ // break;
case BKN_PAGESELECTEDPENDING:
{
);
if (!pWin)
{
- bProcessed = FALSE;
+ bProcessed = false;
break;
}
if (pWin->IsKindOf(CLASSINFO(wxNotebook)))
vEvent.SetEventObject(pWin);
pNotebook->OnSelChange(vEvent);
- bProcessed = TRUE;
+ bProcessed = true;
}
else
- bProcessed = FALSE;
+ bProcessed = false;
}
else
- bProcessed = FALSE;
+ bProcessed = false;
}
break;
if (!pWin)
{
- bProcessed = FALSE;
+ bProcessed = false;
break;
}
//
wxRadioBox* pRadioBox = wxDynamicCast(pWin, wxRadioBox);
pRadioBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
}
if (pWin->IsKindOf(CLASSINFO(wxRadioButton)))
wxRadioButton* pRadioButton = wxDynamicCast(pWin, wxRadioButton);
pRadioButton->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
}
if (pWin->IsKindOf(CLASSINFO(wxCheckBox)))
wxCheckBox* pCheckBox = wxDynamicCast(pWin, wxCheckBox);
pCheckBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
}
if (pWin->IsKindOf(CLASSINFO(wxListBox)))
wxListBox* pListBox = wxDynamicCast(pWin, wxListBox);
pListBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
if (pListBox->GetWindowStyle() & wxLB_OWNERDRAW)
Refresh();
wxComboBox* pComboBox = wxDynamicCast(pWin, wxComboBox);
pComboBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
}
return 0;
}
- break;
+ // break;
case LN_ENTER: /* dups as CBN_EFCHANGE */
{
if (!pWin)
{
- bProcessed = FALSE;
+ bProcessed = false;
break;
}
//
wxListBox* pListBox = wxDynamicCast(pWin, wxListBox);
pListBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
if (pListBox->GetWindowStyle() & wxLB_OWNERDRAW)
Refresh();
wxComboBox* pComboBox = wxDynamicCast(pWin, wxComboBox);
pComboBox->OS2Command( (WXUINT)SHORT2FROMMP(wParam)
- ,(WXUINT)SHORT1FROMMP(wParam)
+ ,(WXWORD)SHORT1FROMMP(wParam)
);
}
return 0;
}
- break;
+ // break;
case SPBN_UPARROW:
case SPBN_DOWNARROW:
case SPBN_CHANGE:
{
- char zVal[10];
- long lVal;
+ char zVal[10];
+ long lVal;
::WinSendMsg( HWNDFROMMP(lParam)
,SPBM_QUERYVALUE
- ,&zVal
+ ,&zVal[0]
,MPFROM2SHORT( (USHORT)10
,(USHORT)SPBQ_UPDATEIFVALID
)
);
lVal = atol(zVal);
bProcessed = OS2OnScroll( wxVERTICAL
- ,(int)SHORT2FROMMP(wParam)
- ,(int)lVal
+ ,(WXWORD)SHORT2FROMMP(wParam)
+ ,(WXWORD)lVal
,HWNDFROMMP(lParam)
);
}
case SLN_SLIDERTRACK:
{
- HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
- wxWindowOS2* pChild = wxFindWinFromHandle(hWnd);
+ HWND hWnd = ::WinWindowFromID(GetHWND(), SHORT1FROMMP(wParam));
+ wxWindowOS2* pChild = wxFindWinFromHandle(hWnd);
if (!pChild)
{
- bProcessed = FALSE;
+ bProcessed = false;
break;
}
if (pChild->IsKindOf(CLASSINFO(wxSlider)))
bProcessed = OS2OnScroll( wxVERTICAL
- ,(int)SHORT2FROMMP(wParam)
- ,(int)LONGFROMMP(lParam)
+ ,(WXWORD)SHORT2FROMMP(wParam)
+ ,(WXWORD)LONGFROMMP(lParam)
,hWnd
);
}
mResult = (MRESULT)TRUE;
}
break;
+
+#if wxUSE_MENUS_NATIVE
+ case WM_MENUEND:
+ if (wxCurrentPopupMenu)
+ {
+ if (GetHmenuOf(wxCurrentPopupMenu) == (HWND)lParam)
+ {
+ // Break out of msg loop in DoPopupMenu
+ ::WinPostMsg((HWND)lParam,WM_COMMAND,wParam,0);
+ }
+ }
+ break;
+#endif // wxUSE_MENUS_NATIVE
+
}
if (!bProcessed)
{
return mResult;
} // end of wxWindowOS2::OS2WindowProc
+// ----------------------------------------------------------------------------
+// wxWindow <-> HWND map
+// ----------------------------------------------------------------------------
+
+wxWinHashTable *wxWinHandleHash = NULL;
+
wxWindow* wxFindWinFromHandle(
WXHWND hWnd
)
{
- wxNode* pNode = wxWinHandleList->Find((long)hWnd);
-
- if (!pNode)
- return NULL;
- return (wxWindow *)pNode->GetData();
+ return (wxWindow *)wxWinHandleHash->Get((long)hWnd);
} // end of wxFindWinFromHandle
void wxAssociateWinWithHandle(
if (pOldWin && (pOldWin != pWin))
{
wxString str(pWin->GetClassInfo()->GetClassName());
- wxLogError( "Bug! Found existing HWND %X for new window of class %s"
+
+ wxLogError( _T("Bug! Found existing HWND %X for new window of class %s")
,(int)hWnd
- ,(const char*)str
+ ,str.c_str()
);
}
else if (!pOldWin)
{
- wxWinHandleList->Append( (long)hWnd
- ,pWin
- );
+ wxWinHandleHash->Put( (long)hWnd
+ ,(wxWindow *)pWin
+ );
}
} // end of wxAssociateWinWithHandle
-void wxRemoveHandleAssociation(
- wxWindowOS2* pWin
-)
+void wxRemoveHandleAssociation( wxWindowOS2* pWin )
{
- wxWinHandleList->DeleteObject(pWin);
+ wxWinHandleHash->Delete((long)pWin->GetHWND());
} // end of wxRemoveHandleAssociation
//
{
}
-bool wxWindowOS2::OS2GetCreateWindowCoords(
- const wxPoint& rPos
-, const wxSize& rSize
-, int& rnX
-, int& rnY
-, int& rnWidth
-, int& rnHeight
-) const
+bool wxWindowOS2::OS2GetCreateWindowCoords( const wxPoint& rPos,
+ const wxSize& rSize,
+ int& rnX,
+ int& rnY,
+ int& rnWidth,
+ int& rnHeight ) const
{
- bool bNonDefault = FALSE;
- static const int DEFAULT_Y = 200;
- static const int DEFAULT_H = 250;
+ bool bNonDefault = false;
+ static const int DEFAULT_Y = 200;
+ static const int DEFAULT_H = 250;
- if (rPos.x == -1)
+ if (rPos.x == wxDefaultCoord)
{
rnX = rnY = CW_USEDEFAULT;
}
else
{
rnX = rPos.x;
- rnY = rPos.y == -1 ? DEFAULT_Y : rPos.y;
- bNonDefault = TRUE;
+ rnY = rPos.y == wxDefaultCoord ? DEFAULT_Y : rPos.y;
+ bNonDefault = true;
}
- if (rSize.x == -1)
+ if (rSize.x == wxDefaultCoord)
{
rnWidth = rnHeight = CW_USEDEFAULT;
}
else
{
rnWidth = rSize.x;
- rnHeight = rSize.y == -1 ? DEFAULT_H : rSize.y;
- bNonDefault = TRUE;
+ rnHeight = rSize.y == wxDefaultCoord ? DEFAULT_H : rSize.y;
+ bNonDefault = true;
}
return bNonDefault;
} // end of wxWindowOS2::OS2GetCreateWindowCoords
return m_parent ? m_parent->GetHWND() : NULL;
}
-bool wxWindowOS2::OS2Create(
- PSZ zClass
-, const char* zTitle
-, WXDWORD dwStyle
-, const wxPoint& rPos
-, const wxSize& rSize
-, void* pCtlData
-, WXDWORD dwExStyle
-, bool bIsChild
-)
+bool wxWindowOS2::OS2Create( PSZ zClass,
+ const wxChar* zTitle,
+ WXDWORD dwStyle,
+ const wxPoint& rPos,
+ const wxSize& rSize,
+ void* pCtlData,
+ WXDWORD WXUNUSED(dwExStyle),
+ bool bIsChild )
{
- ERRORID vError;
- wxString sError;
- int nX = 0L;
- int nY = 0L;
- int nWidth = 0L;
- int nHeight = 0L;
- long lControlId = 0L;
- wxWindowCreationHook vHook(this);
- wxString sClassName((wxChar*)zClass);
+ ERRORID vError;
+ wxString sError;
+ int nX = 0L;
+ int nY = 0L;
+ int nWidth = 0L;
+ int nHeight = 0L;
+ long lControlId = 0L;
+ wxWindowCreationHook vHook(this);
+ wxString sClassName((wxChar*)zClass);
OS2GetCreateWindowCoords( rPos
,rSize
}
m_hWnd = (WXHWND)::WinCreateWindow( (HWND)OS2GetParent()
,(PSZ)sClassName.c_str()
- ,(PSZ)zTitle ? zTitle : ""
+ ,(PSZ)(zTitle ? zTitle : wxEmptyString)
,(ULONG)dwStyle
,(LONG)0L
,(LONG)0L
{
vError = ::WinGetLastError(wxGetInstance());
sError = wxPMErrorToStr(vError);
- return FALSE;
+ return false;
}
SubclassWin(m_hWnd);
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
- m_backgroundColour.Set(wxString("GREY"));
+ m_backgroundColour.Set(wxString(wxT("GREY")));
- LONG lColor = (LONG)m_backgroundColour.GetPixel();
+ LONG lColor = (LONG)m_backgroundColour.GetPixel();
if (!::WinSetPresParam( m_hWnd
,PP_BACKGROUNDCOLOR
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
- wxLogError("Error creating frame. Error: %s\n", sError.c_str());
- return FALSE;
+ wxLogError(_T("Error creating frame. Error: %s\n"), sError.c_str());
+ return false;
}
SetSize( nX
,nY
,nWidth
,nHeight
);
- return TRUE;
+ return true;
} // end of WinGuiBase_Window::OS2Create
// ===========================================================================
// window creation/destruction
// ---------------------------------------------------------------------------
-bool wxWindowOS2::HandleCreate(
- WXLPCREATESTRUCT WXUNUSED(vCs)
-, bool* pbMayCreate
-)
+bool wxWindowOS2::HandleCreate( WXLPCREATESTRUCT WXUNUSED(vCs),
+ bool* pbMayCreate )
{
wxWindowCreateEvent vEvent((wxWindow*)this);
(void)GetEventHandler()->ProcessEvent(vEvent);
- *pbMayCreate = TRUE;
- return TRUE;
+ *pbMayCreate = true;
+ return true;
} // end of wxWindowOS2::HandleCreate
bool wxWindowOS2::HandleDestroy()
//
// WM_DESTROY handled
//
- return TRUE;
+ return true;
} // end of wxWindowOS2::HandleDestroy
// ---------------------------------------------------------------------------
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleActivate
-bool wxWindowOS2::HandleSetFocus(
- WXHWND WXUNUSED(hWnd)
-)
+bool wxWindowOS2::HandleSetFocus( WXHWND WXUNUSED(hWnd) )
{
//
// Notify the parent keeping track of focus for the kbd navigation
// after the control gets to process it from EN_FOCUS handler
if ( wxDynamicCastThis(wxTextCtrl) )
{
- return FALSE;
+ return false;
}
#endif // wxUSE_TEXTCTRL
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleSetFocus
-bool wxWindowOS2::HandleKillFocus(
- WXHWND hWnd
-)
+bool wxWindowOS2::HandleKillFocus( WXHWND hWnd )
{
#if wxUSE_CARET
//
if (pCtrl)
{
- return FALSE;
+ return false;
}
#endif
//
if ( m_isBeingDeleted )
{
- return FALSE;
+ return false;
}
wxFocusEvent vEvent( wxEVT_KILL_FOCUS
{
wxShowEvent vEvent(GetId(), bShow);
- vEvent.m_eventObject = this;
+ vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleShow
-bool wxWindowOS2::HandleInitDialog(
- WXHWND WXUNUSED(hWndFocus)
-)
+bool wxWindowOS2::HandleInitDialog( WXHWND WXUNUSED(hWndFocus) )
{
wxInitDialogEvent vEvent(GetId());
- vEvent.m_eventObject = this;
+ vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleInitDialog
bool wxWindowOS2::HandleEndDrag(WXWPARAM WXUNUSED(wParam))
{
// TODO: We'll handle drag and drop later
- return FALSE;
+ return false;
}
-bool wxWindowOS2::HandleSetCursor(
- USHORT WXUNUSED(vId)
-, WXHWND hPointer
-)
+bool wxWindowOS2::HandleSetCursor( USHORT WXUNUSED(vId),
+ WXHWND hPointer )
{
//
// Under OS/2 PM this allows the pointer to be changed
// as it passes over a control
//
::WinSetPointer(HWND_DESKTOP, (HPOINTER)hPointer);
- return TRUE;
+ return true;
} // end of wxWindowOS2::HandleSetCursor
// ---------------------------------------------------------------------------
// owner drawn stuff
// ---------------------------------------------------------------------------
-bool wxWindowOS2::OS2OnDrawItem(
- int vId
-, WXDRAWITEMSTRUCT* pItemStruct
-)
+bool wxWindowOS2::OS2OnDrawItem( int vId,
+ WXDRAWITEMSTRUCT* pItemStruct )
{
#if wxUSE_OWNER_DRAWN
wxDC vDc;
,pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft
,pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom
);
- vDc.SetHDC( hDC
- ,FALSE
- );
- vDc.SetHPS(pMeasureStruct->hps);
+ vDc.SetHDC( hDC, false );
+ vDc.SetHPS( pMeasureStruct->hps );
//
// Load the wxWidgets Pallete and set to RGB mode
//
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
- wxLogError("Unable to set current color table. Error: %s\n", sError.c_str());
+ wxLogError(_T("Unable to set current color table. Error: %s\n"), sError.c_str());
}
//
// Set the color table to RGB mode
{
vError = ::WinGetLastError(vHabmain);
sError = wxPMErrorToStr(vError);
- wxLogError("Unable to set current color table. Error: %s\n", sError.c_str());
+ wxLogError(_T("Unable to set current color table. Error: %s\n"), sError.c_str());
}
wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE );
-
- int eAction = 0;
- int eStatus = 0;
+ int eAction = 0;
+ int eStatus = 0;
if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld)
{
// For now we don't care about anything else
// just ignore the entire message!
//
- return TRUE;
+ return true;
}
}
//
vId = vId;
pItemStruct = pItemStruct;
#endif
- return FALSE;
+ return false;
} // end of wxWindowOS2::OS2OnDrawItem
-long wxWindowOS2::OS2OnMeasureItem(
- int lId
-, WXMEASUREITEMSTRUCT* pItemStruct
-)
+long wxWindowOS2::OS2OnMeasureItem( int lId,
+ WXMEASUREITEMSTRUCT* pItemStruct )
{
#if wxUSE_OWNER_DRAWN
//
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleSysColorChange
-bool wxWindowOS2::HandleCtlColor(
- WXHBRUSH* WXUNUSED(phBrush)
-)
+bool wxWindowOS2::HandleCtlColor( WXHBRUSH* WXUNUSED(phBrush) )
{
//
// Not much provided with message. So not sure I can do anything with it
//
- return TRUE;
+ return true;
} // end of wxWindowOS2::HandleCtlColor
wxSysColourChangedEvent& rEvent
)
{
- wxWindowListNode* pNode = GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
- while (pNode)
+ while (node)
{
//
// Only propagate to non-top-level windows
//
- wxWindow* pWin = (wxWindow *)pNode->GetData();
+ wxWindow* pWin = (wxWindow *)node->GetData();
if (pWin->GetParent())
{
wxSysColourChangedEvent vEvent;
- rEvent.m_eventObject = pWin;
+ rEvent.SetEventObject(pWin);
pWin->GetEventHandler()->ProcessEvent(vEvent);
}
- pNode = pNode->GetNext();
+ node = node->GetNext();
}
} // end of wxWindowOS2::OnSysColourChanged
if (::WinQueryUpdateRegion(GetHwnd(), hRgn) == RGN_ERROR)
{
- wxLogLastError("CreateRectRgn");
- return FALSE;
+ wxLogLastError(wxT("CreateRectRgn"));
+ return false;
+ }
+
+ // Get all the rectangles from the region, convert the individual
+ // rectangles to "the other" coordinate system and reassemble a
+ // region from the rectangles, to be feed into m_updateRegion.
+ //
+ // FIXME: This is a bad hack since OS/2 API specifies that rectangles
+ // passed into GpiSetRegion must not have Bottom > Top,
+ // however, at first sight, it _seems_ to work nonetheless.
+ //
+ RGNRECT vRgnData;
+ PRECTL pUpdateRects = NULL;
+ vRgnData.ulDirection = RECTDIR_LFRT_TOPBOT;
+ if (::GpiQueryRegionRects( hPS // Pres space
+ ,hRgn // Handle of region to query
+ ,NULL // Return all RECTs
+ ,&vRgnData // Will contain number or RECTs in region
+ ,NULL // NULL to return number of RECTs
+ ))
+ {
+ pUpdateRects = new RECTL[vRgnData.crcReturned];
+ vRgnData.crc = vRgnData.crcReturned;
+ vRgnData.ircStart = 1;
+ if (::GpiQueryRegionRects( hPS // Pres space of source
+ ,hRgn // Handle of source region
+ ,NULL // Return all RECTs
+ ,&vRgnData // Operations set to return rects
+ ,pUpdateRects // Will contain the actual RECTS
+ ))
+ {
+ int height;
+ RECT vRect;
+ ::WinQueryWindowRect(GetHwnd(), &vRect);
+ height = vRect.yTop;
+
+ for(size_t i = 0; i < vRgnData.crc; i++)
+ {
+ int rectHeight;
+ rectHeight = pUpdateRects[i].yTop - pUpdateRects[i].yBottom;
+ pUpdateRects[i].yTop = height - pUpdateRects[i].yTop;
+ pUpdateRects[i].yBottom = pUpdateRects[i].yTop + rectHeight;
+ }
+ ::GpiSetRegion(hPS, hRgn, vRgnData.crc, pUpdateRects);
+ delete [] pUpdateRects;
+ }
}
m_updateRegion = wxRegion(hRgn, hPS);
}
}
::WinEndPaint(hPS);
- bProcessed = TRUE;
+ bProcessed = true;
}
else if (!bProcessed &&
IsKindOf(CLASSINFO(wxPanel))
//
// Panel with children, usually fills a frame client so no borders.
//
- HPS hPS;
- RECTL vRect;
+ HPS hPS;
+ RECTL vRect;
hPS = ::WinBeginPaint( GetHwnd()
,NULLHANDLE
::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel());
}
::WinEndPaint(hPS);
- bProcessed = TRUE;
+ bProcessed = true;
}
return bProcessed;
} // end of wxWindowOS2::HandlePaint
-bool wxWindowOS2::HandleEraseBkgnd(
- WXHDC hDC
-)
+bool wxWindowOS2::HandleEraseBkgnd( WXHDC hDC )
{
- SWP vSwp;
- bool rc;
+ SWP vSwp;
+ bool rc;
::WinQueryWindowPos(GetHwnd(), &vSwp);
if (vSwp.fl & SWP_MINIMIZE)
- return TRUE;
+ return true;
- wxDC vDC;
+ wxDC vDC;
vDC.m_hPS = (HPS)hDC; // this is really a PS
vDC.SetWindow((wxWindow*)this);
vDC.BeginDrawing();
- wxEraseEvent vEvent(m_windowId, &vDC);
+ wxEraseEvent vEvent(m_windowId, &vDC);
vEvent.SetEventObject(this);
vDC.EndDrawing();
vDC.m_hPS = NULLHANDLE;
- return TRUE;
+ return true;
} // end of wxWindowOS2::HandleEraseBkgnd
void wxWindowOS2::OnEraseBackground(
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleMaximize
-bool wxWindowOS2::HandleMove(
- int nX
-, int nY
-)
+bool wxWindowOS2::HandleMove( int nX, int nY )
{
- wxMoveEvent vEvent(wxPoint(nX, nY), m_windowId);
+ wxPoint pt(nX, nY);
+ wxMoveEvent vEvent(pt, m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleMove
-bool wxWindowOS2::HandleSize(
- int nWidth
-, int nHeight
-, WXUINT WXUNUSED(nFlag)
-)
+bool wxWindowOS2::HandleSize( int nWidth,
+ int nHeight,
+ WXUINT WXUNUSED(nFlag) )
{
- wxSizeEvent vEvent(wxSize(nWidth, nHeight), m_windowId);
+ wxSize sz(nWidth, nHeight);
+ wxSizeEvent vEvent(sz, m_windowId);
vEvent.SetEventObject(this);
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::HandleSize
-bool wxWindowOS2::HandleGetMinMaxInfo(
- PSWP pSwp
-)
+bool wxWindowOS2::HandleGetMinMaxInfo( PSWP pSwp )
{
POINTL vPoint;
switch(pSwp->fl)
{
case SWP_MAXIMIZE:
+#if !(defined(__WATCOMC__) && __WATCOMC__ < 1240 )
+// Open Watcom 1.3 had incomplete headers
+// that's reported and should be fixed for OW 1.4
::WinGetMaxPosition(GetHwnd(), pSwp);
m_maxWidth = pSwp->cx;
m_maxHeight = pSwp->cy;
+#endif
break;
case SWP_MINIMIZE:
+#if !(defined(__WATCOMC__) && __WATCOMC__ < 1240 )
+// Open Watcom 1.3 had incomplete headers
+// that's reported and should be fixed for OW 1.4
::WinGetMinPosition(GetHwnd(), pSwp, &vPoint);
m_minWidth = pSwp->cx;
m_minHeight = pSwp->cy;
+#else
+ wxUnusedVar(vPoint);
+#endif
break;
default:
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
} // end of wxWindowOS2::HandleGetMinMaxInfo
// ---------------------------------------------------------------------------
// command messages
// ---------------------------------------------------------------------------
-bool wxWindowOS2::HandleCommand(
- WXWORD wId
-, WXWORD wCmd
-, WXHWND hControl
-)
+bool wxWindowOS2::HandleCommand( WXWORD wId,
+ WXWORD wCmd,
+ WXHWND hControl )
{
#if wxUSE_MENUS_NATIVE
if (wxCurrentPopupMenu)
if (pWin)
return pWin->OS2Command(wCmd, wId);
- return FALSE;
+ return false;
} // end of wxWindowOS2::HandleCommand
-bool wxWindowOS2::HandleSysCommand(
- WXWPARAM wParam
-, WXLPARAM WXUNUSED(lParam)
-)
+bool wxWindowOS2::HandleSysCommand( WXWPARAM wParam,
+ WXLPARAM WXUNUSED(lParam) )
{
//
// 4 bits are reserved
case SC_MINIMIZE:
return HandleMinimize();
}
- return FALSE;
+ return false;
} // end of wxWindowOS2::HandleSysCommand
// ---------------------------------------------------------------------------
rEvent.m_controlDown = ((uFlags & KC_CTRL) != 0);
rEvent.m_altDown = ((uFlags & KC_ALT) != 0);
rEvent.m_leftDown = (::WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) &
- 0x8000) != 0;
+ 0x8000) != 0;
rEvent.m_middleDown = (::WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) &
- 0x8000) != 0;
+ 0x8000) != 0;
rEvent.m_rightDown = (::WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) &
- 0x8000) != 0;
+ 0x8000) != 0;
rEvent.SetTimestamp(s_currentMsg.time);
- rEvent.m_eventObject = this;
+ rEvent.SetEventObject(this);
rEvent.SetId(GetId());
#if wxUSE_MOUSEEVENT_HACK
#endif // wxUSE_MOUSEEVENT_HACK
} // end of wxWindowOS2::InitMouseEvent
-bool wxWindowOS2::HandleMouseEvent(
- WXUINT uMsg
-, int nX
-, int nY
-, WXUINT uFlags
-)
+bool wxWindowOS2::HandleMouseEvent( WXUINT uMsg,
+ int nX,
+ int nY,
+ WXUINT uFlags )
{
- bool bProcessed = FALSE;
+ 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
+ // WM_MOUSELAST, so it's enough to subtract WM_MOUSEMOVE == WM_MOUSEFIRST
// from the message id and take the value in the table to get wxWin event
// id
//
wxEVT_MIDDLE_DCLICK
};
- wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]);
-
- InitMouseEvent( vEvent
- ,nX
- ,nY
- ,uFlags
- );
-
- bProcessed = GetEventHandler()->ProcessEvent(vEvent);
- if (!bProcessed)
+ // Bounds check
+ if ((uMsg >= WM_MOUSEMOVE) && (uMsg <= WM_BUTTON3DBLCLK))
{
- HPOINTER hCursor = (HPOINTER)GetCursor().GetHCURSOR();
+ wxMouseEvent vEvent(eventsMouse[uMsg - WM_MOUSEMOVE]);
- if (hCursor != NULLHANDLE)
+ InitMouseEvent( vEvent
+ ,nX
+ ,nY
+ ,uFlags
+ );
+
+ bProcessed = GetEventHandler()->ProcessEvent(vEvent);
+ if (!bProcessed)
{
- ::WinSetPointer(HWND_DESKTOP, hCursor);
- bProcessed = TRUE;
+ HPOINTER hCursor = (HPOINTER)GetCursor().GetHCURSOR();
+
+ if (hCursor != NULLHANDLE)
+ {
+ ::WinSetPointer(HWND_DESKTOP, hCursor);
+ bProcessed = true;
+ }
}
}
- return GetEventHandler()->ProcessEvent(vEvent);
+ return bProcessed;
} // end of wxWindowOS2::HandleMouseEvent
-bool wxWindowOS2::HandleMouseMove(
- int nX
-, int nY
-, WXUINT uFlags
-)
+bool wxWindowOS2::HandleMouseMove( int nX,
+ int nY,
+ WXUINT uFlags )
{
if (!m_bMouseInWindow)
{
//
// Generate an ENTER event
//
- m_bMouseInWindow = TRUE;
+ m_bMouseInWindow = true;
- wxMouseEvent vEvent(wxEVT_ENTER_WINDOW);
+ wxMouseEvent vEvent(wxEVT_ENTER_WINDOW);
InitMouseEvent( vEvent
,nX
vEvent.m_controlDown = IsCtrlDown();
vEvent.m_altDown = (HIWORD(lParam) & KC_ALT) == KC_ALT;
- vEvent.m_eventObject = (wxWindow *)this; // const_cast
+ vEvent.SetEventObject((wxWindow *)this); // const_cast
vEvent.m_keyCode = nId;
vEvent.m_rawCode = (wxUint32)wParam;
vEvent.m_rawFlags = (wxUint32)lParam;
} // end of wxWindowOS2::CreateKeyEvent
//
-// isASCII is TRUE only when we're called from WM_CHAR handler and not from
+// isASCII is true only when we're called from WM_CHAR handler and not from
// WM_KEYDOWN one
//
-bool wxWindowOS2::HandleChar(
- WXWPARAM wParam
-, WXLPARAM lParam
-, bool isASCII
-)
+bool wxWindowOS2::HandleChar( WXWPARAM WXUNUSED(wParam),
+ WXLPARAM lParam,
+ bool isASCII )
{
- bool bCtrlDown = FALSE;
- int vId;
+ bool bCtrlDown = false;
+ int vId;
if (m_bLastKeydownProcessed)
{
// EVT_KEY_DOWN handler is meant, by design, to prevent EVT_CHARs
// from happening, so just bail out at this point.
//
- m_bLastKeydownProcessed = FALSE;
- return TRUE;
+ m_bLastKeydownProcessed = false;
+ return true;
}
if (isASCII)
{
//
// If 1 -> 26, translate to either special keycode or just set
// ctrlDown. IOW, Ctrl-C should result in keycode == 3 and
- // ControlDown() == TRUE.
+ // ControlDown() == true.
//
vId = SHORT1FROMMP(lParam);
if ((vId > 0) && (vId < 27))
break;
default:
- bCtrlDown = TRUE;
+ bCtrlDown = true;
break;
}
}
{
vId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
if (vId == 0)
- return FALSE;
+ return false;
}
- wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR
- ,vId
- ,lParam
- ));
+ wxKeyEvent vEvent(CreateKeyEvent( wxEVT_CHAR, vId, lParam ));
if (bCtrlDown)
{
- vEvent.m_controlDown = TRUE;
+ vEvent.m_controlDown = true;
}
+
return (GetEventHandler()->ProcessEvent(vEvent));
}
-bool wxWindowOS2::HandleKeyDown(
- WXWPARAM wParam
-, WXLPARAM lParam
-)
+bool wxWindowOS2::HandleKeyDown( WXWPARAM wParam,
+ WXLPARAM lParam )
{
- int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
+ int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
if (!nId)
{
if (nId != -1)
{
- wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
- ,nId
- ,(MPARAM)lParam
- ,(MPARAM)wParam
- ));
+ wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_DOWN
+ ,nId
+ ,(MPARAM)lParam
+ ,(MPARAM)wParam
+ ));
if (GetEventHandler()->ProcessEvent(vEvent))
{
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
} // end of wxWindowOS2::HandleKeyDown
-bool wxWindowOS2::HandleKeyUp(
- WXWPARAM wParam
-, WXLPARAM lParam
-)
+bool wxWindowOS2::HandleKeyUp( WXWPARAM wParam,
+ WXLPARAM lParam )
{
- int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
+ int nId = wxCharCodeOS2ToWX((int)SHORT2FROMMP(lParam));
if (!nId)
{
//
// Normal ASCII char
//
- nId = (int)wParam;
+ nId = CHAR1FROMMP(lParam);
}
if (nId != -1)
{
- wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP
- ,nId
- ,lParam
- ,wParam
- ));
+ wxKeyEvent vEvent(CreateKeyEvent( wxEVT_KEY_UP
+ ,nId
+ ,(MPARAM)lParam
+ ,(MPARAM)wParam
+ ));
if (GetEventHandler()->ProcessEvent(vEvent))
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
} // end of wxWindowOS2::HandleKeyUp
// ---------------------------------------------------------------------------
// scrolling
// ---------------------------------------------------------------------------
-bool wxWindowOS2::OS2OnScroll(
- int nOrientation
-, WXWORD wParam
-, WXWORD wPos
-, WXHWND hControl
-)
+bool wxWindowOS2::OS2OnScroll( int nOrientation,
+ WXWORD wParam,
+ WXWORD wPos,
+ WXHWND hControl )
{
if (hControl)
{
vEvent.SetPosition(wPos);
vEvent.SetOrientation(nOrientation);
- vEvent.m_eventObject = this;
+ vEvent.SetEventObject(this);
switch (wParam)
{
case SB_LINEUP:
- vEvent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
+ vEvent.SetEventType(wxEVT_SCROLLWIN_LINEUP);
break;
case SB_LINEDOWN:
- vEvent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
+ vEvent.SetEventType(wxEVT_SCROLLWIN_LINEDOWN);
break;
case SB_PAGEUP:
- vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
+ vEvent.SetEventType(wxEVT_SCROLLWIN_PAGEUP);
break;
case SB_PAGEDOWN:
- vEvent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
+ vEvent.SetEventType(wxEVT_SCROLLWIN_PAGEDOWN);
break;
case SB_SLIDERPOSITION:
- vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBRELEASE;
+ vEvent.SetEventType(wxEVT_SCROLLWIN_THUMBRELEASE);
break;
case SB_SLIDERTRACK:
- vEvent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
+ vEvent.SetEventType(wxEVT_SCROLLWIN_THUMBTRACK);
break;
default:
- return FALSE;
+ return false;
}
return GetEventHandler()->ProcessEvent(vEvent);
} // end of wxWindowOS2::OS2OnScroll
{
SWP vSwp;
- for (wxWindowList::Node* pNode = GetChildren().GetFirst();
- pNode;
- pNode = pNode->GetNext())
+ for (wxWindowList::compatibility_iterator node = GetChildren().GetFirst();
+ node;
+ node = node->GetNext())
{
- wxWindow* pWin = pNode->GetData();
+ wxWindow* pWin = node->GetData();
::WinQueryWindowPos( GetHwndOf(pWin)
,&vSwp
);
+ // Actually, only move children that already are placed on the
+ // frame, not ones which are still at wxDefaultCoord.
+ if (vSwp.y == wxDefaultCoord)
+ continue;
if (pWin->IsKindOf(CLASSINFO(wxControl)))
{
wxControl* pCtrl;
// as that will be the eventual size of the panel after the frame resizes
// it!
//
-int wxWindowOS2::GetOS2ParentHeight(
- wxWindowOS2* pParent
-)
+int wxWindowOS2::GetOS2ParentHeight( wxWindowOS2* pParent )
{
//
// Case 1
// and it's height must be different. Otherwise the standard
// applies.
//
- else
- {
- return(pParent->GetClientSize().y);
- }
- return(0L);
+ // else
+ // {
+
+ return(pParent->GetClientSize().y);
+
+ // }
} // end of wxWindowOS2::GetOS2ParentHeight
//
case VK_CTRL: nId = WXK_CONTROL; break;
case VK_PAUSE: nId = WXK_PAUSE; break;
case VK_SPACE: nId = WXK_SPACE; break;
+ case VK_PAGEUP: nId = WXK_PRIOR; break;
+ case VK_PAGEDOWN: nId = WXK_NEXT; break;
case VK_ESC: nId = WXK_ESCAPE; break;
case VK_END: nId = WXK_END; break;
case VK_HOME : nId = WXK_HOME; break;
return nId;
} // end of wxCharCodeOS2ToWX
-int wxCharCodeWXToOS2(
- int nId
-, bool* bIsVirtual
-)
+int wxCharCodeWXToOS2( int nId,
+ bool* bIsVirtual)
{
- int nKeySym = 0;
+ int nKeySym = 0;
- *bIsVirtual = TRUE;
+ *bIsVirtual = true;
switch (nId)
{
case WXK_CLEAR: nKeySym = VK_CLEAR; break;
case WXK_SHIFT: nKeySym = VK_SHIFT; break;
case WXK_CONTROL: nKeySym = VK_CTRL; break;
case WXK_PAUSE: nKeySym = VK_PAUSE; break;
+ case WXK_PRIOR: nKeySym = VK_PAGEUP; break;
+ case WXK_NEXT : nKeySym = VK_PAGEDOWN; break;
case WXK_END: nKeySym = VK_END; break;
case WXK_HOME : nKeySym = VK_HOME; break;
case WXK_LEFT : nKeySym = VK_LEFT; break;
case WXK_SCROLL: nKeySym = VK_SCRLLOCK; break;
default:
{
- *bIsVirtual = FALSE;
+ *bIsVirtual = false;
nKeySym = nId;
break;
}
} // end of wxGetActiveWindow
#ifdef __WXDEBUG__
-const char* wxGetMessageName(
- int nMessage)
+const char* wxGetMessageName( int nMessage )
{
switch (nMessage)
{
case WM_USER+1000+60: return "TB_SETMAXTEXTROWS";
case WM_USER+1000+61: return "TB_GETTEXTROWS";
case WM_USER+1000+41: return "TB_GETBITMAPFLAGS";
-
- default:
- static char s_szBuf[128];
- sprintf(s_szBuf, "<unknown message = %d>", nMessage);
- return s_szBuf;
}
- return NULL;
+
+ static char s_szBuf[128];
+ sprintf(s_szBuf, "<unknown message = %d>", nMessage);
+ return s_szBuf;
+
} // end of wxGetMessageName
#endif // __WXDEBUG__
return wxPoint(vPt.x, vPt.y);
}
-wxWindowOS2* FindWindowForMouseEvent(
- wxWindow* pWin
-, short* pnX
-, short* pnY
-)
+wxWindowOS2* FindWindowForMouseEvent( wxWindow* pWin,
+ short* WXUNUSED(pnX),
+ short* WXUNUSED(pnY) )
{
- HWND hWnd = GetHwndOf(pWin);
- HWND hWndUnderMouse;
- POINTL vPoint;
- BOOL rcEnabled = FALSE;
- BOOL rcVisible = FALSE;
+ HWND hWnd = GetHwndOf(pWin);
+ HWND hWndUnderMouse;
+ POINTL vPoint;
+ BOOL rcEnabled = FALSE;
+ BOOL rcVisible = FALSE;
::WinQueryPointerPos(HWND_DESKTOP, &vPoint);
hWndUnderMouse = ::WinWindowFromPoint(HWND_DESKTOP, &vPoint, TRUE);
if (pWinUnderMouse)
{
- wxWindowList::Node* pCurrent = pWinUnderMouse->GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator current = pWinUnderMouse->GetChildren().GetFirst();
wxWindow* pGrandChild = NULL;
RECTL vRect;
POINTL vPoint2;
//
// Find a child window mouse might be under
//
- while (pCurrent)
+ while (current)
{
- wxWindow* pChild = pCurrent->GetData();
+ wxWindow* pChild = current->GetData();
vPoint2.x = vPoint.x;
vPoint2.y = vPoint.y;
if (pChild->IsTopLevel())
{
POINTL vPoint3;
- wxWindowList::Node* pCurrent2 =pChild->GetChildren().GetFirst();
+ wxWindowList::compatibility_iterator current2 =pChild->GetChildren().GetFirst();
- while (pCurrent2)
+ while (current2)
{
- wxWindow* pGrandChild = pCurrent2->GetData();
+ wxWindow* pGrandChild = current2->GetData();
vPoint3.x = vPoint2.x;
vPoint3.y = vPoint2.y;
pWinUnderMouse = pGrandChild;
break;
}
- pCurrent2 = pCurrent2->GetNext();
+ current2 = current2->GetNext();
}
if (pGrandChild)
break;
if (rcVisible && rcEnabled)
break;
}
- pCurrent = pCurrent->GetNext();
+ current = current->GetNext();
}
}
}
}
return pWin;
} // end of FindWindowForMouseEvent
-