Membres inscrits :2359
Membres en ligne : 0
Invités en ligne : 3


|
Menu Snippets (navigation): |
Détails du snippet : [wxAuiToolBar] Les items surchargés de la toolbar. |
Informations sur l'auteur de ce snippet : | |

Hors ligne
| Gandi (Membre)
Lieu: Clermont-Ferrand
Inscrit le : 10-10-2007
Messages: 222
Snippets: 5
Tutoriels: 0
|
Introduction / Description : | |
wxAuiToolbar permet d'ajouter une petite flèche à la fin de la toolbar et d'y associer un tableau de wxAuiToolBarItem. On appel ça les items surchargés.
Lors de la création de la Toolbar on défini le style wxAUI_TB_OVERFLOW.
Une fois la toolbar créée on associe le tableau d'"overflow items" avec SetCustomOverflowItems
Voici un exemple d'utilisation:
Code wxWidgets: wxAuiToolBarItemArray ToolBarItems; wxAuiToolBarItemArray PrependItems; // Sert juste pour l'appel de SetCustomOverflowItems wxAuiToolBarItem Item; wxAuiToolBarItem ItemSeparator; ItemSeparator.SetKind( wxITEM_SEPARATOR ); Item.SetKind( wxITEM_NORMAL ); Item.SetId( Id_MenuNew ); Item.SetLabel( wxT("&New\tCtrl+N") ); Item.SetBitmap( wxArtProvider::GetBitmap( wxART_NEW, wxART_TOOLBAR ) ); ToolBarItems.Add( Item ); Item.SetId( ECaId_MenuOpen ); Item.SetLabel( wxT("&Open...\tCtrl+O") ); Item.SetBitmap( wxArtProvider::GetBitmap( wxART_FILE_OPEN, wxART_TOOLBAR ) ); ToolBarItems.Add( Item ); ToolBarItems.Add( ItemSeparator ); Item.SetId( ECaId_MenuImport ); Item.SetLabel( wxT("&Import...") ); Item.SetBitmap( wxArtProvider::GetBitmap( wxART_FILE_OPEN, wxART_TOOLBAR ) ); ToolBarItems.Add( Item ); Item.SetId( ECaId_MenuExport ); Item.SetLabel( wxT("&Export...") ); Item.SetBitmap( wxArtProvider::GetBitmap( wxART_FILE_SAVE_AS, wxART_TOOLBAR ) ); ToolBarItems.Add( Item ); wxAuiToolBar* ToolBar = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW ); ToolBar->SetToolBitmapSize( wxSize( 48, 48 ) ); ToolBar->AddTool( Id_MenuImport, wxT("Import"), wxArtProvider::GetBitmap( wxART_FILE_OPEN, wxART_TOOLBAR ), wxT("Import") ); ToolBar->SetCustomOverflowItems( Prepend_items, ToolBarItems ); ToolBarItems.Clear(); AuiManager.AddPane( ToolBar, wxAuiPaneInfo().Name( wxT("ToolBar") ).Caption( wxEmptyString ).ToolbarPane().Top() ); AuiManager.Update(); Remarque : En cliquant sur la flèche, si je ne clique pas sur un item surchargé, il me fait quand même New File, cela me le faisait avant même que je ne définisse les OverflowItems.
Il n'y a pas encore de commentaire pour ce snippet.
Menu Snippets (navigation): |
|