Exemplo n.º 1
0
void CBOINCBitmapChoice::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) {
    MenuHandle mhandle = (MenuHandle) m_macPopUpMenuHandle;
    unsigned int index = n + 1;
    
    if ( mhandle == NULL || index == 0)
        return ;

    if ( bitmap.Ok() )
    {
        CGImageRef imageRef = (CGImageRef)( bitmap.CGImageCreate() ) ;
        SetMenuItemIconHandle( mhandle , index ,
                    kMenuCGImageRefType , (Handle) imageRef ) ;

#if 0// wxUSE_BMPBUTTON
        ControlButtonContentInfo info ;
        wxMacCreateBitmapButton( &info , bitmap ) ;
        if ( info.contentType != kControlNoContent )
        {
            if ( info.contentType == kControlContentIconRef )
                SetMenuItemIconHandle( mhandle , index ,
                    kMenuIconRefType , (Handle) info.u.iconRef ) ;
            else if ( info.contentType == kControlContentCGImageRef )
               SetMenuItemIconHandle( mhandle , index ,
                    kMenuCGImageRefType , (Handle) info.u.imageRef ) ;
        }
        wxMacReleaseBitmapButton( &info ) ;
#endif
    }
}
Exemplo n.º 2
0
void wxMenuItem::DoUpdateItemBitmap( WXHMENU menu, wxUint16 index)
{
    MenuHandle mhandle = (MenuHandle) menu;

    if ( mhandle == NULL || index == 0)
        return ;

    if ( m_bitmap.Ok() )
    {
#if wxUSE_BMPBUTTON
        ControlButtonContentInfo info ;
        wxMacCreateBitmapButton( &info , m_bitmap ) ;
        if ( info.contentType != kControlNoContent )
        {
            if ( info.contentType == kControlContentIconRef )
                SetMenuItemIconHandle( mhandle , index ,
                    kMenuIconRefType , (Handle) info.u.iconRef ) ;
            else if ( info.contentType == kControlContentCGImageRef )
               SetMenuItemIconHandle( mhandle , index ,
                    kMenuCGImageRefType , (Handle) info.u.imageRef ) ;
        }
        wxMacReleaseBitmapButton( &info ) ;
#endif
    }
}
Exemplo n.º 3
0
void wxMenuItem::UpdateItemBitmap()
{
    if ( !m_parentMenu )
        return ;

    MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
    MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
    if ( mhandle == NULL || index == 0)
        return ;

    if ( m_bitmap.Ok() )
    {
#if wxUSE_BMPBUTTON
        ControlButtonContentInfo info ;
        wxMacCreateBitmapButton( &info , m_bitmap ) ;
        if ( info.contentType != kControlNoContent )
        {
            if ( info.contentType == kControlContentIconRef )
                SetMenuItemIconHandle( mhandle , index ,
                    kMenuIconRefType , (Handle) info.u.iconRef ) ;
        }
        wxMacReleaseBitmapButton( &info ) ;
#endif
    }
}
Exemplo n.º 4
0
  for_each(BumpTopCommand* option, ordered_context_menu_items) {
    err = InsertMenuItemTextWithCFString(carbon_context_menu,
                                         CFStringFromQString(option->name()),
                                         menu_size,   // MenuItemIndex inAfterItem
                                         option->isSeparator() ? kMenuItemAttrSeparator : 0,  // MenuItemAttributes inAttributes
                                         0);  // MenuCommand inCommandID
    if (option->has_subcommands()) {
      QStringList subcommand_names = option->subcommand_names(actors);
      err = CreateNibReference(CFSTR("ContextMenu"), &nib_ref);
      MenuRef carbon_context_sub_menu;
      err = CreateMenuFromNib(nib_ref, CFSTR("ItemContextMenu"), &carbon_context_sub_menu);
      err = ChangeMenuAttributes(carbon_context_sub_menu, kMenuAttrCondenseSeparators, NULL);
      DisposeNibReference(nib_ref);


      int sub_menu_size = 0;
      for_each(QString subcommand, subcommand_names) {
        err = InsertMenuItemTextWithCFString(carbon_context_sub_menu,
                                             CFStringFromQString(subcommand),
                                             sub_menu_size,   // MenuItemIndex inAfterItem
                                             subcommand == "" ? kMenuItemAttrSeparator : 0,  // MenuItemAttributes inAttributes
                                             0); // MenuCommand inCommandID

        CGImageRef icon = option->iconForSubcommand(actors, sub_menu_size);
        if (icon) {
          err = SetMenuItemIconHandle (carbon_context_sub_menu,
                                       sub_menu_size+1,
                                       kMenuCGImageRefType,
                                       (Handle) icon);
          CGImageRelease(icon);
        }
        sub_menu_size++;

      }
Exemplo n.º 5
0
    void SetBitmap( const wxBitmap& bitmap )
    {
        MenuItemIndex i = FindMenuItemIndex() ;
        if ( i > 0 )
        {
            if ( bitmap.IsOk() )
            {
#if wxUSE_BMPBUTTON
                ControlButtonContentInfo info ;
                wxMacCreateBitmapButton( &info , bitmap ) ;
                if ( info.contentType != kControlNoContent )
                {
                    if ( info.contentType == kControlContentIconRef )
                        SetMenuItemIconHandle( m_parentMenuRef, i ,
                            kMenuIconRefType , (Handle) info.u.iconRef ) ;
                    else if ( info.contentType == kControlContentCGImageRef )
                       SetMenuItemIconHandle( m_parentMenuRef, i ,
                            kMenuCGImageRefType , (Handle) info.u.imageRef ) ;
                }
                wxMacReleaseBitmapButton( &info ) ;
#endif
            }
        }
    }