X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d854fa93f8f5a48e383395060063a7931bf0207..c9e352726232feaa1085f9950cddfa6c98fdda95:/src/os2/window.cpp diff --git a/src/os2/window.cpp b/src/os2/window.cpp index c43e2576a0..ce16cbc0c7 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -2654,78 +2654,113 @@ bool wxWindow::OS2OnDrawItem( , WXDRAWITEMSTRUCT* pItemStruct ) { - // - // I'll get to owner drawn stuff later - // + wxDC vDc; // - // is it a menu item or control? + // Is it a menu item? // - wxWindow* pItem = FindItem(vId); + if (vId == 0) + { #if wxUSE_OWNER_DRAWN - if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) - { - return ((wxControl *)pItem)->OS2OnDraw(pItemStruct); - } - else if (pItem && pItem->IsKindOf(CLASSINFO(wxMenu))) - { - /* - // TODO: draw a menu item + POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct; + wxMenuItem vMenuItem; + HDC hDC = ::GpiQueryDevice(pMeasureStruct->hps); + + vDc.SetHDC( hDC + ,FALSE + ); + vDc.SetHPS(pMeasureStruct->hps); + + // + // We stored the CMenuItem itself into the menuitem text field so now + // we need to extract it. // - POWNERITEM pDrawStruct = (OWNERITEM *)pItemStruct; - wxMenuItem* pMenuItem = (wxMenuItem *)(pDrawStruct->pItemData); + ::WinSendMsg( pMeasureStruct->hItem + ,MM_QUERYITEMTEXT + ,MPFROM2SHORT( (USHORT)pMeasureStruct->idItem + ,(SHORT)(sizeof(wxMenuItem)) + ) + ,(PSZ)&vMenuItem + ); + + wxRect vRect( pMeasureStruct->rclItem.xLeft + ,pMeasureStruct->rclItem.yTop + ,pMeasureStruct->rclItem.xRight + ,pMeasureStruct->rclItem.yBottom + ); - wxCHECK(pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE); + wxOwnerDrawn::wxODAction eAction; // - // Prepare to call OnDrawItem() + // Attribute applies to menuitems, fsState to listbox and other controls + // + if (pMeasureStruct->fsAttribute == pMeasureStruct->fsAttributeOld) + eAction = wxOwnerDrawn::wxODDrawAll; + else + eAction = wxOwnerDrawn::wxODSelectChanged; + + return(vMenuItem.OnDrawItem( vDc + ,vRect + ,eAction + ,(wxOwnerDrawn::wxODStatus)pMeasureStruct->fsAttribute + )); + // + // leave the fsAttribute and fsOldAttribute unchanged. If different, + // the system will do the highlight or fraeming or disabling for us, + // otherwise, we'd have to do it ourselves. // - HPSdc; - dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE); - wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, - pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, - pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); - - return pMenuItem->OnDrawItem - ( - dc, rect, - (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, - (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState - ); - */ } - else - return FALSE; + wxWindow* pItem = FindItem(vId); + + if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) + { + return ((wxControl *)pItem)->OS2OnDraw(pItemStruct); + } #endif - return TRUE; + return FALSE; } // end of wxWindow::OS2OnDrawItem -bool wxWindow::OS2OnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) +bool wxWindow::OS2OnMeasureItem( + int lId +, WXMEASUREITEMSTRUCT* pItemStruct +) { - // TODO: more owner drawn menu related stuff, get to it later -/* -#if wxUSE_OWNER_DRAWN - // is it a menu item? - if ( id == 0 ) + // + // Is it a menu item? + // + if (lId == 0) { - MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; - wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); + POWNERITEM pMeasureStruct = (POWNERITEM)pItemStruct; + wxMenuItem vMenuItem; - wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); + // + // We stored the CMenuItem itself into the menuitem text field so now + // we need to extract it. + // + ::WinSendMsg( pMeasureStruct->hItem + ,MM_QUERYITEMTEXT + ,MPFROM2SHORT( (USHORT)pMeasureStruct->idItem + ,(SHORT)(sizeof(wxMenuItem)) + ) + ,(PSZ)&vMenuItem + ); + wxCHECK(vMenuItem.IsKindOf(CLASSINFO(wxMenuItem)), FALSE); + + size_t lWidth = (size_t)(pMeasureStruct->rclItem.xRight - pMeasureStruct->rclItem.xLeft); + size_t lHeight = (size_t)(pMeasureStruct->rclItem.yTop - pMeasureStruct->rclItem.yBottom); - return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, - &pMeasureStruct->itemHeight); + return(vMenuItem.OnMeasureItem( &lWidth + ,&lHeight + )); } + wxWindow* pItem = FindItem(id); - wxWindow *item = FindItem(id); - if ( item && item->IsKindOf(CLASSINFO(wxControl)) ) + if (pItem && pItem->IsKindOf(CLASSINFO(wxControl))) { - return ((wxControl *)item)->MSWOnMeasure(itemStruct); + return ((wxControl *)pItem)->OS2OnMeasure(pItemStruct); } -#endif // owner-drawn menus -*/ return FALSE; } @@ -2845,6 +2880,35 @@ bool wxWindow::HandlePaint() m_updateRegion = wxRegion(hRgn); vEvent.SetEventObject(this); + if (!GetEventHandler()->ProcessEvent(vEvent)) + { + HPS hPS; + + hPS = ::WinBeginPaint( GetHwnd() + ,NULLHANDLE + ,&vRect + ); + if(hPS) + { + ::GpiCreateLogColorTable( hPS + ,0L + ,LCOLF_CONSECRGB + ,0L + ,(LONG)wxTheColourDatabase->m_nSize + ,(PLONG)wxTheColourDatabase->m_palTable + ); + ::GpiCreateLogColorTable( hPS + ,0L + ,LCOLF_RGB + ,0L + ,0L + ,NULL + ); + + ::WinFillRect(hPS, &vRect, GetBackgroundColour().GetPixel()); + ::WinEndPaint(hPS); + } + } return (GetEventHandler()->ProcessEvent(vEvent)); } // end of wxWindow::HandlePaint