Esempio n. 1
0
void wxToolBar::DrawTool(
  wxToolBarToolBase*                pTool
)
{
    wxClientDC                      vDc(this);

    DrawTool( vDc
             ,pTool
            );
} // end of wxToolBar::DrawTool
Esempio n. 2
0
void wxStaticBitmap::OnPaint ( wxPaintEvent& WXUNUSED(rEvent) )
{
    wxPaintDC vDc(this);
    wxBitmap* pBitmap;

    if (m_pImage->IsKindOf(CLASSINFO(wxIcon)))
    {
        wxIcon*                     pIcon;

        pIcon = wxDynamicCast(m_pImage, wxIcon);
        pBitmap = new wxBitmap(*pIcon);
        vDc.DrawBitmap(*pBitmap, 0, 0);
        delete pBitmap;
    }
    else
    {
        pBitmap = wxDynamicCast(m_pImage, wxBitmap);
        vDc.DrawBitmap(*pBitmap, 0, 0);
    }
} // end of wxStaticBitmap::OnPaint
Esempio n. 3
0
void wxToolBar::OnPaint (
  wxPaintEvent&                     WXUNUSED(rEvent)
)
{
    wxPaintDC                       vDc(this);

    PrepareDC(vDc);

    static int                      nCount = 0;

    //
    // Prevent reentry of OnPaint which would cause wxMemoryDC errors.
    //
    if (nCount > 0)
        return;
    nCount++;

    wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl();
    ::WinFillRect(impl->GetHPS(), &impl->m_vRclPaint, GetBackgroundColour().GetPixel());
    for ( wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst();
          node;
          node = node->GetNext() )
    {
        wxToolBarTool*              pTool = (wxToolBarTool*)node->GetData();

        if (pTool->IsButton() )
            DrawTool(vDc, pTool);
        if (pTool->IsSeparator())
        {
            wxColour gray85(85, 85, 85);
            wxPen vDarkGreyPen( gray85, 1, wxSOLID );
            int nX;
            int nY;
            int nHeight = 0;
            int nWidth = 0;

            vDc.SetPen(vDarkGreyPen);
            if (HasFlag(wxTB_TEXT))
            {
                if (HasFlag(wxTB_TOP) || HasFlag(wxTB_BOTTOM))
                {
                    nX = pTool->m_vX;
                    nY = pTool->m_vY - (m_vTextY - 6);
                    nHeight = (m_vTextY - 2) + pTool->GetHeight();
                }
                else
                {
                    nX = pTool->m_vX + m_xMargin + 10;
                    nY = pTool->m_vY + m_vTextY + m_toolSeparation;
                    nWidth = pTool->GetWidth() > m_vTextX ? pTool->GetWidth() : m_vTextX;
                }
            }
            else
            {
                nX = pTool->m_vX;
                nY = pTool->m_vY;
                if (HasFlag(wxTB_TOP) || HasFlag(wxTB_BOTTOM))
                    nHeight = pTool->GetHeight() - 2;
                else
                {
                    nX += m_xMargin + 10;
                    nY +=  m_yMargin + m_toolSeparation;
                    nWidth = pTool->GetWidth();
                }
            }
            vDc.DrawLine(nX, nY, nX + nWidth, nY + nHeight);
        }
    }
    nCount--;
} // end of wxToolBar::OnPaint
Esempio n. 4
0
bool wxListBox::OS2OnDraw (
  WXDRAWITEMSTRUCT*                 pItem
)
{
    POWNERITEM                      pDrawStruct = (POWNERITEM)pItem;
    int                             eAction = 0;
    int                             eStatus = 0;

    //
    // Only owner-drawn control should receive this message
    //
    wxCHECK(((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false);


    //
    // The item may be -1 for an empty listbox
    //
    if (pDrawStruct->idItem == -1L)
        return false;

    wxListBoxItem* pData = (wxListBoxItem*)m_aItems[pDrawStruct->idItem];

    wxClientDC    vDc(this);
    wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl();
    wxPoint pt1( pDrawStruct->rclItem.xLeft, pDrawStruct->rclItem.yTop );
    wxPoint pt2( pDrawStruct->rclItem.xRight, pDrawStruct->rclItem.yBottom );
    wxRect  vRect( pt1, pt2 );

    impl->SetHPS(pDrawStruct->hps);

    if (pDrawStruct->fsAttribute == pDrawStruct->fsAttributeOld)
    {
        //
        // Entire Item needs to be redrawn (either it has reappeared from
        // behind another window or is being displayed for the first time
        //
        eAction = wxOwnerDrawn::wxODDrawAll;

        if (pDrawStruct->fsAttribute & MIA_HILITED)
        {
            //
            // If it is currently selected we let the system handle it
            //
            eStatus |= wxOwnerDrawn::wxODSelected;
        }
        if (pDrawStruct->fsAttribute & MIA_CHECKED)
        {
            //
            // If it is currently checked we draw our own
            //
            eStatus |= wxOwnerDrawn::wxODChecked;
            pDrawStruct->fsAttributeOld = pDrawStruct->fsAttribute &= ~MIA_CHECKED;
        }
        if (pDrawStruct->fsAttribute & MIA_DISABLED)
        {
            //
            // If it is currently disabled we let the system handle it
            //
            eStatus |= wxOwnerDrawn::wxODDisabled;
        }
        //
        // Don't really care about framed (indicationg focus) or NoDismiss
        //
    }
    else
    {
        if (pDrawStruct->fsAttribute & MIA_HILITED)
        {
            eAction = wxOwnerDrawn::wxODDrawAll;
            eStatus |= wxOwnerDrawn::wxODSelected;
            //
            // Keep the system from trying to highlight with its bogus colors
            //
            pDrawStruct->fsAttributeOld = pDrawStruct->fsAttribute &= ~MIA_HILITED;
        }
        else if (!(pDrawStruct->fsAttribute & MIA_HILITED))
        {
            eAction = wxOwnerDrawn::wxODDrawAll;
            eStatus = 0;
            //
            // Keep the system from trying to highlight with its bogus colors
            //
            pDrawStruct->fsAttribute = pDrawStruct->fsAttributeOld &= ~MIA_HILITED;
        }
        else
        {
            //
            // For now we don't care about anything else
            // just ignore the entire message!
            //
            return true;
        }
    }
    return pData->OnDrawItem( vDc
                             ,vRect
                             ,(wxOwnerDrawn::wxODAction)eAction
                             ,(wxOwnerDrawn::wxODStatus)(eStatus | wxOwnerDrawn::wxODHidePrefix)
                            );
} // end of wxListBox::OS2OnDraw
Esempio n. 5
0
bool wxBitmapButton::OS2OnDraw( WXDRAWITEMSTRUCT* pItem)
{
    PUSERBUTTON  pUser     = (PUSERBUTTON)pItem;
    bool         bAutoDraw = (GetWindowStyleFlag() & wxBU_AUTODRAW) != 0;

    if (!pUser)
        return false;

    wxBitmap   bitmap;
    bool       bIsSelected = pUser->fsState & BDS_HILITED;
    wxClientDC vDc(this);

    if (bIsSelected)
        bitmap = GetBitmapPressed();
    else if (pUser->fsState & BDS_DEFAULT)
        bitmap = GetBitmapFocus();
    else if (pUser->fsState & BDS_DISABLED)
        bitmap = GetBitmapDisabled();

    if (!bitmap.IsOk() )
    {
        bitmap = GetBitmapLabel();
        if (!bitmap.IsOk() )
            return false;
    }


    //
    // Centre the bitmap in the control area
    //
    int                             nX1        = 0;
    int                             nY1        = 0;
    wxPMDCImpl                      *impl = (wxPMDCImpl*) vDc.GetImpl();
    int                             nWidth     = impl->m_vRclPaint.xRight - impl->m_vRclPaint.xLeft;
    int                             nHeight    = impl->m_vRclPaint.yTop - impl->m_vRclPaint.yBottom;
    int                             nBmpWidth  = bitmap.GetWidth();
    int                             nBmpHeight = bitmap.GetHeight();

    nX1 = (nWidth - nBmpWidth) / 2;
    nY1 = (nHeight - nBmpHeight) / 2;

    if (bIsSelected && bAutoDraw)
    {
        nX1++;
        nY1++;
    }

    //
    // Draw the button face
    //
    DrawFace( vDc, bIsSelected );

    //
    // Draw the bitmap
    //
    vDc.DrawBitmap( bitmap, nX1, nY1, true );

    //
    // Draw focus / disabled state, if auto-drawing
    //
    if ((pUser->fsState == BDS_DISABLED) && bAutoDraw)
    {
        DrawButtonDisable( vDc, bitmap );
    }
    else if ((pUser->fsState == BDS_DEFAULT) && bAutoDraw)
    {
        DrawButtonFocus(vDc);
    }
    return true;
} // end of wxBitmapButton::OS2OnDraw
Esempio n. 6
0
bool wxBitmapButton::OS2OnDraw(
  WXDRAWITEMSTRUCT*                 pItem
)
{
    PUSERBUTTON                     pUser     = (PUSERBUTTON)pItem;
    bool                            bAutoDraw = (GetWindowStyleFlag() & wxBU_AUTODRAW) != 0;

    if (!pUser)
        return FALSE;

    wxBitmap*                       pBitmap;
    bool                            bIsSelected = pUser->fsState & BDS_HILITED;
    wxClientDC                      vDc(this);

    if (bIsSelected && m_bmpSelected.Ok())
        pBitmap = &m_bmpSelected;
    else if ((pUser->fsState & BDS_DEFAULT) && m_bmpFocus.Ok())
        pBitmap = &m_bmpFocus;
    else if ((pUser->fsState & BDS_DISABLED) && m_bmpDisabled.Ok())
        pBitmap = &m_bmpDisabled;
    else
        pBitmap = &m_bmpNormal;

    if (!pBitmap->Ok() )
        return FALSE;


    //
    // Centre the bitmap in the control area
    //
    int                             nX         = 0;
    int                             nX1        = 0;
    int                             nY1        = 0;
    int                             nWidth     = vDc.m_vRclPaint.xRight - vDc.m_vRclPaint.xLeft;
    int                             nHeight    = vDc.m_vRclPaint.xRight - vDc.m_vRclPaint.xLeft;
    int                             nBmpWidth  = pBitmap->GetWidth();
    int                             nBmpHeight = pBitmap->GetHeight();

    nX1 = nX + (nWidth - nBmpWidth) / 2;
    nY1 = nX + (nHeight - nBmpHeight) / 2;

    if (bIsSelected && bAutoDraw)
    {
        nX1++;
        nY1++;
    }

    //
    // Draw the button face
    //
    {
        DrawFace( vDc
                 ,bIsSelected
                );
    }

    //
    // Draw the bitmap
    //
    vDc.DrawBitmap( *pBitmap
                   ,nX1
                   ,nY1
                   ,TRUE
                  );

    //
    // Draw focus / disabled state, if auto-drawing
    //
    if ((pUser->fsState == BDS_DISABLED) && bAutoDraw)
    {
        DrawButtonDisable( vDc
                          ,*pBitmap
                         );
    }
    else if ((pUser->fsState == BDS_DEFAULT) && bAutoDraw)
    {
        DrawButtonFocus(vDc);
    }
    return TRUE;
} // end of wxBitmapButton::OS2OnDraw