Exemplo n.º 1
0
// Added by Mark Newsam
// When a page is added or deleted to the notebook this function updates
// information held in the control so that it matches the order
// the user would expect.
//
void wxNotebook::MacSetupTabs()
{
    m_peer->SetMaximum( GetPageCount() ) ;

    wxNotebookPage *page;
    ControlTabInfoRecV1 info;

    const size_t countPages = GetPageCount();
    for (size_t ii = 0; ii < countPages; ii++)
    {
        page = m_pages[ii];
        info.version = kControlTabInfoVersionOne;
        info.iconSuiteID = 0;
        wxMacCFStringHolder cflabel( page->GetLabel(), m_font.GetEncoding() ) ;
        info.name = cflabel ;
        m_peer->SetData<ControlTabInfoRecV1>( ii + 1, kControlTabInfoTag, &info ) ;

        if ( GetImageList() && GetPageImage(ii) >= 0 && UMAGetSystemVersion() >= 0x1020 )
        {
            const wxBitmap bmap = GetImageList()->GetBitmap( GetPageImage( ii ) ) ;
            if ( bmap.Ok() )
            {
                ControlButtonContentInfo info ;

                wxMacCreateBitmapButton( &info, bmap ) ;

                OSStatus err = m_peer->SetData<ControlButtonContentInfo>( ii + 1, kControlTabImageContentTag, &info );
                wxASSERT_MSG( err == noErr , wxT("Error when setting icon on tab") ) ;

                wxMacReleaseBitmapButton( &info ) ;
            }
        }

        m_peer->SetTabEnabled( ii + 1, true ) ;
    }

#if wxMAC_USE_CORE_GRAPHICS
    Refresh();
#else
    Rect bounds;
    m_peer->GetRectInWindowCoords( &bounds ) ;
    InvalWindowRect( (WindowRef)MacGetTopLevelWindowRef(), &bounds );
#endif
}
Exemplo n.º 2
0
void wxMacControl::SetupTabs( const wxNotebook& notebook)
{
    const size_t countPages = notebook.GetPageCount();
    SetMaximum( countPages ) ;

    wxNotebookPage *page;
    ControlTabInfoRecV1 info;

    for (size_t ii = 0; ii < countPages; ii++)
    {
        page = (wxNotebookPage*) notebook.GetPage(ii);
        info.version = kControlTabInfoVersionOne;
        info.iconSuiteID = 0;
        wxCFStringRef cflabel( page->GetLabel(), page->GetFont().GetEncoding() ) ;
        info.name = cflabel ;
        SetData<ControlTabInfoRecV1>( ii + 1, kControlTabInfoTag, &info ) ;

        if ( notebook.GetImageList() && notebook.GetPageImage(ii) >= 0 )
        {
            const wxBitmap bmap = notebook.GetImageList()->GetBitmap( notebook.GetPageImage( ii ) ) ;
            if ( bmap.IsOk() )
            {
                ControlButtonContentInfo info ;

                wxMacCreateBitmapButton( &info, bmap ) ;

                OSStatus err = SetData<ControlButtonContentInfo>( ii + 1, kControlTabImageContentTag, &info );
                if ( err != noErr )
                {
                    wxFAIL_MSG("Error when setting icon on tab");
                }

                wxMacReleaseBitmapButton( &info ) ;
            }
        }
        SetTabEnabled( ii + 1, true ) ;
    }
}