wxToolBar

From WxWiki
Jump to: navigation, search
Official Classes SmallBlocks.png Archive Containers Controls Data Structures Database Date & Time Debug Device Contexts Dialogs Document & Views Drag & Drop Events Filesystem Frames Graphics Grid Cell Help HTML Logging Miscellaneous Networking Printing Sizers Streams Threading Windows

A toolbar is a bar of buttons and/or other controls usually placed below the menu bar in a wxFrame.

You may create a toolbar that is managed by a frame calling wxFrame::CreateToolBar(). Under Pocket PC, you should always use this function for creating the toolbar to be managed by the frame, so that wxWidgets can use a combined menubar and toolbar. Where you manage your own toolbars, create wxToolBar as usual.

There are several different types of tools you can add to a toolbar. These types are controlled by the wxItemKind enumeration.

Note that many methods in wxToolBar such as wxToolBar::AddTool return a wxToolBarToolBase* object. This should be regarded as an opaque handle representing the newly added toolbar item, providing access to its id and position within the toolbar. Changes to the item's state should be made through calls to wxToolBar methods, for example wxToolBar::EnableTool. Calls to wxToolBarToolBase methods (undocumented by purpose) will not change the visible state of the item within the tool bar.

wxMSW note: Note that under wxMSW toolbar paints tools to reflect system-wide colours. If you use more than 16 colours in your tool bitmaps, you may wish to suppress this behaviour, otherwise system colours in your bitmaps will inadvertently be mapped to system colours. To do this, set the msw.remap system option before creating the toolbar:

wxSystemOptions::SetOption("msw.remap", 0);

If you wish to use 32-bit images (which include an alpha channel for transparency) use:

wxSystemOptions::SetOption("msw.remap", 2);

Then colour remapping is switched off, and a transparent background used. But only use this option under Windows XP with true colour:

if (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32)

See Also