Wxwidgets Interface design Tool dialogblocks (reprint)

Source: Internet
Author: User
Tags wxwidgets

Wxwidgets Interface design Tool dialogblocks//* Create by ZYZX//* 2009-3-12//* Reprint please indicate source:http://www.cppblog.com/zyzx

工欲善其事, its prerequisite.          Developed on MFC, there are powerful visual Tools vs Series, WX-based development tools are not as powerful as the interface designer of VS and Qt, but the interface designer of VS is not comparable in flexibility (QT has no use, no comment). If you choose the WX Library, it will greatly improve the development efficiency by understanding several interface design tools based on them.

I. Introduction to WX interface design tools

Collection of official recommended tools: Http://wiki.wxwidgets.org/Tools

In the beginning, I also tried several tools (Wxformbuilder, wxdev-c++, Wxdesigner, etc.), but later chose DialogBlocks-4.18. The choice of these tools is unique. The choice of dialogblocks, mainly because of its flexibility is very large, of course, the disadvantage is the need to manually write code to combine the use of tools. But this is no longer a disadvantage after being familiar with WX, but her greatest advantage.

Ii. introduction of Dialogblocks

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

Iii. Dialogblocks Getting Started Guide

After the installation is complete, Dialogblocks has a few examples of engineering can be consulted for everyone.

1. New HelloWorld Project

Close these and then click File->new Project to enter the Project Wizard.

Click Next to go to the next selection page

There are 3 options in mode: Generate for C + +: Indicates that the tool does not generate a *.XRC (XML format file) configuration file, directly writes some information about the window (such as style, size, whether it is visible, etc.) directly in the source code, with the corresponding markup difference, by the tool to maintain the area of the code.          If the tag information is broken manually, the tool will not be recognized. Generate C + + for XRC: Represents a tool that will window information (... Write the code in the corresponding *.XRC configuration file, which only loads the configuration in the code block. This method is very suitable, the interface size is inconsistent, need to configure the interface flexibly.          The code block event associates a unique ID for each window control. Generate XRC only: Indicates that no source code is generated and only *.XRC configuration files are generated. More flexibility to separate the code from the configuration file of the interface design. Code blocks only need to control their behavior through the window control ID.

Next, the default option. Save the project to get the Helloworld\helloworld.pjd file, and then just open from this file.

2. New Master Wxframe or Wxdialog

3. Add other controls

Modify the Startup main frame:main window option to modify the ID number of the HelloWorld frame.

3. Add other controls

such as menus, toolbars, status bars, control elements inside the window, and so on.

Note that the window elements are not arbitrarily added, you must first understand the relationship between WX's window elements.             For example: Wxframe/wxdialog directly inclusive Wxmenubar, Wxtoolbar, Wxstatusbar, and Wxtextctrl, Wxcombobox, Wxstatictext and so on best built in Wxboxsizer. Wxboxsizer is one of the features of WX, which can automatically adjust the controls it contains. Of course, you need to set its auto-adjust properties. The default properties are used above.

Iv. HelloWorld vs. Engineering configuration

Complete the above section to show that the most basic interface framework has been done. We also need to create a new Win32-based empty HelloWorld project to add dialogblocks generated *.h *.cpp files to the HelloWorld project.

Set up this project according to the previous configuration of the Win32 section.

Compile and run (don't forget to put the WX Library's *.dll file ... The results will be reported wxwidgets assert ignored, because the above established Wxtoolbar\tool did not find the corresponding icon, add the icon and set the WX resource load path.

V. Bound Control Event Control

In Dialogblock, select Wxbutton:id_button1 Toggle right view to event handlers, click Button_Click Event, and save. There are two ways to bind events, dialogblocks in the way of static bindings, and with dynamic binding events.

Find the HelloWorld class again and add the header file # include <wx/msgdlg.h> void Helloworld::onbutton1click (wxcommandevent& event) {Wxmessagebox (WxT ("Hello world! \ r \ n Click button1click! "));}

You can get the following effect:

Wxwidgets Interface design Tool dialogblocks (reprint)

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.