[Post] wxWidgets AuI usage experience

Source: Internet
Author: User
Tags wxwidgets

After using wxWidgets 2.8 for a period of time, we found that the AuI object in it is really useful for managing user interfaces. However, there seems to be few Chinese introductions on the Internet. So here I will record some of my experiences.

Assume that the GUI framework is myframe. Now we need to use AuI to manage it.
First, define a wxauimanager object:

Wxauimanager m_auimanager;

When the framework is initialized, use the setmanagedwindow () method to obtain the management right of the framework.

Myframe: myframe (wxwindow * parent,
Const wxwindowid ID,
Const wxstring & title,
Const wxpoint & Pos,
Const wxsize & size,
Const long style)
: Wxmdiparentframe (parent, ID, title, POs, size, style)
{
M_auimanager.setmanagedwindow (this );

...

}

To add an object to the managed GUI framework, use the addpane () of AuI to add the object to the sub-window of AuI. Otherwise, the interface will be messy and all objects will be mixed together. For example, create a toolbar.

Wxtoolbar * toolbar = new wxtoolbar (this, wxid_any, wxdefaultposition, wxdefaultsize, wxtb_flat | wxtb_nodivider );

When creating a toolbar, wxtb_nodivider is used most. Otherwise, an edge appears around the toolbar, which is not very nice. Then, add several buttons to him.

Toolbar-> addtool (101, wxt ("test"), toolbmp 1 );
Toolbar-> addtool (101, wxt ("test"), toolbmp 1 );
Toolbar-> addtool (101, wxt ("test"), toolbmp 1 );
Toolbar-> addseparator ();
Toolbar-> addtool (101, wxt ("test"), toolbmp 1 );

Toolbar-> realize ();

Then add the toolbar object to the AuI panel. The simplest method is:

M_auimanager.addpane (toolbar );

However, in this way, this Toolbar will be added to the leftmost of the window, and will appear in the form of a subwindow with a title bar. This is obviously not the toolbar we want. It is best to use wxauipaneinfo () to control the added object in more detail. Now we are like this:

M_auimanager.addpane (toolbar, wxauipaneinfo ().
Name (wxt ("toolbar"). Caption (wxt ("toolbar 1 ")).
Toolbarpane (). Top (). Row (1 ).
Leftdockable (false). rightdockable (false ));

Name () specifies the name of the Panel. If it is not set, the Manager will give it a random name. Caption () is the title of the subwindow. If you drag this toolbar from its original position into an independent subwindow, the title will be displayed. Toolbarpane () is specially set for the toolbar, so the title bar is not displayed when you dock. The default position of top () is above. If there are multiple rows, use row () to set their relationships. When leftdockable (false) is set, This toolbar cannot be docked on the left (right) side.

After joining the Panel version, you must update the manager. If it is not updated, the interface is also messy.

M_auimanager.update ();

The same applies to adding other controls, such as adding a text control.

Textwindow = new wxtextctrl (this, wxid_any, _ T ("A Help Window"), wxdefaultposition, wxdefaultsize, wxte_multiline | wxsunken_border );

Then add the facial version:

M_auimanager.addpane (textwindow, wxauipaneinfo (). Name (wxt ("Help Window"). Caption (wxt ("help"). Left ());

Then update:

M_auimanager.update ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.