WxWidgets interface design tool dialogblocks

Source: Internet
Author: User
WxWidgets interface design tool dialogblocks

// * Create by zyzx
// * 2009-3-12
// * Indicate the source for reprinting:Http://www.cppblog.com/zyzx

To do well, you must first sharpen your tools. Developed on MFC, there are powerful visual tools in the vs series. However, the WX-based development tools are not as powerful as the Vs and QT interface designers, however, in terms of flexibility, the vs interface designer is incomparable (QT has never been used, and no comments are made ).
If you select the Wx library and learn about several interface design tools based on it, the development efficiency will be greatly improved.

1. Introduction to wx Interface Design Tools

A collection of officially recommended tools: http://wiki.wxwidgets.org/Tools

At the beginning, I also tried several tools (wxformbuilder, wxdev-C ++, wxdesigner, etc.), but later I chose DialogBlocks-4.18. These tools have their own characteristics. The choice of dialogblocks is mainly because of its high flexibility. Of course, the disadvantage is that you need to manually write code to use it with the tool. However, this is not a disadvantage for users who are familiar with wx, but her biggest advantage.

II. Introduction to dialogblocks

Dialogblocks official homepage: http://www.anthemion.co.uk/dialogblocks/

Iii. Getting started with dialogblocks

After the installation is complete, there are several instance projects in dialogblocks for your reference.

1. Create a helloworld Project

Close these items and click File> new project to enter the Project Wizard.

Click Next to go to the next selection page.

Mode has three options:
Generate for C ++: indicates that the tool does not generate *. XRC (XML Format File) configuration file, directly write some window information (such as style, size, whether visible, etc.) in the source code, with the corresponding tag difference, this code segment is maintained by tools. If the tag information is manually damaged, the tool cannot identify it.
Generate C ++ for XRC: indicates that the tool sends window information (...) Write the corresponding *. XRC configuration file, and write only the code that loads these configurations in the code block. This method is very suitable, and the page size is inconsistent, You need to flexibly configure the interface. The event of the code block is associated with the unique ID of each window control.
Generate XRC only: do not generate source code, only generate *. XRC configuration file. More flexible separation of code and interface design configuration files. The code block only needs to control its behavior through the window control ID.

Next, the default option.
Save the project and get the helloworld "helloworld. pjd file. You can open it later.

2. Create a master wxframe or wxdialog

3. Add other controls

Modify the main frame: Main Window option to the ID of the helloworld frame.

3. Add other controls

Such as menus, toolbar, Status Bar, and control elements in the window.

Note that the window elements are not randomly added. you must first understand the relationship between the window elements of Wx. For example, wxframe/wxdialog can directly accommodate wxmenubar, wxtoolbar, and wxstatusbar, while wxtextctrl, wxcombobox, and wxstatictext are best established in wxboxsizer.
Wxboxsizer is one of the characteristics of Wx. It can automatically adjust its contained controls. Of course, you need to set its automatic attribute adjustment. The default attributes are used.



Iv. vs project configuration of helloworld

The above section shows that the most basic interface framework has been completed. We also need to create a Win32-Based Empty helloworld project and add the *. H *. cpp file generated by dialogblocks to the helloworld project.

Configure this project according to the Win32 section in the previous article.

Compile and run (do not forget to include the *. dll file of the Wx library ...) The result shows that wxWidgets assert is ignored because the preceding wxtoolbar "tool does not find the corresponding icon. Add the icon and set the Wx resource loading path.


5. Bind control Event Control

In dialogblock, select wxbutton: id_button1 to switch the right view to event handlers, click the button_click event, and save it. There are two ways to bind events. dialogblocks adopts static binding and dynamic binding.


Find the helloworld class and add the header file # include <wx/msgdlg. h>
Void helloworld: onbutton1click (wxcommandevent & event)
{
Wxmessagebox (wxt ("Hello world! "R" n clicked button1click! "));
}

You can get the following results:

 

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.