/// Create all pages, under the dialog's book control, also calling AddPage
bool wxRichTextFormattingDialogFactory::CreatePages(long pages, wxRichTextFormattingDialog* dialog)
{
    if (dialog->GetImageList())
        dialog->GetBookCtrl()->SetImageList(dialog->GetImageList());

    int availablePageCount = GetPageIdCount();
    int i;
    bool selected = false;
    for (i = 0; i < availablePageCount; i ++)
    {
        int pageId = GetPageId(i);
        if (pageId != -1 && (pages & pageId))
        {
            wxString title;
            wxPanel* panel = CreatePage(pageId, title, dialog);
            wxASSERT( panel != NULL );
            if (panel)
            {
                int imageIndex = GetPageImage(pageId);
                dialog->GetBookCtrl()->AddPage(panel, title, !selected, imageIndex);
                selected = true;

                dialog->AddPageId(pageId);
            }
        }
    }

    return true;
}
Example #2
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
}
Example #3
0
void wxListbook::SetImageList(wxImageList *imageList)
{
    wxListView * const list = GetListView();

#ifdef CAN_USE_REPORT_VIEW
    // If imageList presence has changed, we update the list control view
    if ( (imageList != NULL) != (GetImageList() != NULL) )
    {
        wxArrayString labels;
        labels.Alloc(GetPageCount());

        wxArrayInt imageIds;
        imageIds.Alloc(GetPageCount());

        const int oldSel = GetSelection();
        size_t i;

        // Grab snapshot of all list control items before changing the window
        // style (which deletes the items)
        for ( i = 0; i < GetPageCount(); i++ )
        {
            labels.Add(GetPageText(i));
            imageIds.Add(GetPageImage(i));
        }

        // Update the style to use icon view for images, report view otherwise
        long style = wxLC_SINGLE_SEL;
        if ( imageList )
        {
            style |= GetListCtrlIconViewFlags();
        }
        else // no image list
        {
            style |= GetListCtrlReportViewFlags();
        }

        list->SetWindowStyleFlag(style);
        if ( !imageList )
            list->InsertColumn(0, wxT("Pages"));

        // Add back the list control items
        for ( i = 0; i < GetPageCount(); i++ )
        {
            list->InsertItem(i, labels[i], imageIds[i]);
        }

        // Restore selection
        if ( oldSel != wxNOT_FOUND )
            SetSelection(oldSel);
    }

    list->SetImageList(imageList, wxIMAGE_LIST_NORMAL);
#endif // CAN_USE_REPORT_VIEW

    wxBookCtrlBase::SetImageList(imageList);
}
Example #4
0
const wxNotebookPageInfoList& wxNotebookBase::GetPageInfos() const
{
    wxNotebookPageInfoList* list = const_cast< wxNotebookPageInfoList* >( &m_pageInfos );
    WX_CLEAR_LIST( wxNotebookPageInfoList, *list );
    for( size_t i = 0; i < GetPageCount(); ++i )
    {
        wxNotebookPageInfo *info = new wxNotebookPageInfo();
        info->Create( const_cast<wxNotebookBase*>(this)->GetPage(i), GetPageText(i),
                     GetSelection() == int(i), GetPageImage(i) );
        list->Append( info );
    }
    return m_pageInfos;
}