WxWidgets beginner Guide (4) -- wxWidgets learning materials and usage instructions

Source: Internet
Author: User
Tags wxwidgets

WxWidgets full directory for beginnersPDF and attachment download 1 Preface
2. Download and install wxWidgets
3 wxWidgets application initial experience
4 wxWidgets learning materials and usage instructions
5. Use wxSmith for Visual Design
Appendix: learning material list

4 wxWidgets learning materials and usage instructions

Beginners often suffer from finding references. Actually, it cannot be found, not none. Really useful information is often at hand, but I don't know. The ability to use all useful information skillfully is one of the indicators for improving the level. This kind of ability is also obtained in practice, rather than anyone who gives you a lesson.

The learning materials in this chapter begin with the most general-books.


4.1 books about C ++ wxWidgets
4.1.1 use wxWidgets for cross-platform Program Development

WxWidgets books are really rare, from Amazon only find a copy of the "using wxWidgets for cross-platform program development" (http://www.amazon.cn/gp/product/B00A1WDQ30), part of the electronic version (containing the book routine source code, from http://download.csdn.net/detail/cjylg ). Good reading. Please support paper Publishing.

The English version of this book is called Cross Platform GUI Programming With wxWidget (see http://www.wxwidgets.org/docs/book/). I 've browsed some of it and it's not hard to read it.


4.1.2 wxwidgets Wiki Homepage

I recommend reading a tutorial named wxwidgets tutorial (http://wiki.wxwidgets.org/Main_Page) linked to the Guides & Tutorials section (http://wiki.wxwidgets.org/Guides_%26_Tutorials) on the Wiki homepage (http://zetcode.com/gui/wxwidgets/) of wxWidgets ). When I wrote the wxwidgets Wiki homepage again, I found there were too many treasures. Contributors to the open-source community not only provide software sharing, but also extend this sharing spirit to guiding books, which must be liked.


4.1.3 wxWidgets tutorial

WxWidgets tutorial is an online tutorial I strongly recommend. There are few descriptions, and we have been using small examples to inspire readers to understand wxWidgets. I completed a pleasant learning journey while reading code and practicing. In the last chapter of wxWidgets tutorial, a Tetris game was developed. After reading and synchronizing the exercises, the basic path for wxWidgets application development is mastered.

For the convenience of readers, I will organize the document in this tutorial into a Word document, as an attachment of this tutorial, packaged for download and use. Some comments are added to the Word document, which is a clue I can find in my learning.

What makes readers uncomfortable with this article is that wxWidgets tutorial is in English. This is actually a good thing. In this era, secondary documents that rely on translation also want to learn new technologies, and they know that this is just a thing of the dark. Continuous learning of English is the learning form of IT students. I have always encouraged students to "learn English in English" (see http://blog.csdn.net/sxhelijian/article/details/12177147), which is a great time.Whether you can watch it or not depends on your English level, but on your mentality.Furthermore, there are very few descriptive texts in this book. Even if the College Entrance Examination English was captured in the examination room and decided to take ABCD, you can take a look.


4.2 make good use of wxWidgets online documentation

In the Internet era, another type of information must attract the attention of learners, that is, online documents and tutorials.

Go to the wxWidgets homepage http://www.wxwidgets.org/where every chain of documentationinterfaces is connected to a treasure database, for example:


4.2.1 mature platforms often have online documents

When developing programs with Microsoft platform, the best reference is MSDN (http://msdn.microsoft.com/library/), while when developing programs with Java, there are Java SE 6 Documentation (http://docs.oracle.com/javase/6/docs/index.html ), there are also some contents translated into Chinese (http://www.javaweb.cc/JavaAPI1.6 ). The classes, functions, and macros required during software development cannot be remembered. There are online document searches, which professionals do not remember. Most mature platforms provide real online documents, which can be downloaded locally and read through a browser.


4.2.2 online wxWidgets documentation

WxWidgets also has online documentation (http://docs.wxwidgets.org/3.0/ documentation, in section 2.1, ask the reader to download manual(html#.zip.

Select a folder to decompress manual(html#.zip. I decompressed to F: \ wxWidgets-3.0.0-docs-html. Find the index.html file and double-click it to open it, as shown in. This is a useful reference.

It is recommended that you right-click the index.html file and select "send to-> desktop shortcut" from the menu ". You can create a shortcut on the desktop to open online documents for future use.


4.2.3 search for online documents

Online documents organize links between related materials through hyperlinks. As a practice, you will feel a little bit about each link.

For example. In wxWidgets tutorial, the routine in the first section of Menus and Toolbars in Simple menu example contains the following code:

SimpleMenu: SimpleMenu (const wxString & title): wxFrame (NULL, wxID_ANY, title, wxDefaultPosition, wxSize (280,180) // the following example, check the constructor parameter {menubar = new wxMenuBar; file = new wxMenu; file-> Append (wxID_EXIT, wxT ("& Quit") through the online document ")); // exercise: menubar> Append (file, wxT ("& File"); SetMenuBar (menubar); Connect (wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (SimpleMenu: OnQuit); Centre ();}

Now I want to know the meanings of the parameters in the wxFrame constructor. The main link is: Class-> Class Index-> F (classes in wxWidgets all start with wx, take F from wxFrame, for example:

Next, on the "wxFrame Class Reference" page, we can see the inheritance relationship between the wxFrame Class and other classes and other information, such:

Let's take a look at the wxFrame class Constructor. You can see the Constructor definition and description in the "Constructor & Destructor Documentation" section:

WxFrame: wxFrame

(

WxWindow *

Parent,

 

 

WxWindowID

Id,

 

 

Const wxString &

Title,

 

 

Const wxPoint &

Pos = wxDefaultPosition,

 

 

Const wxSize &

Size = wxDefaultSize,

 

 

Long

Style = wxDEFAULT_FRAME_STYLE,

 

 

Const wxString &

Name = wxFrameNameStr

 

)

 

 

Constructor, creating the window.

Parameters

Parent

The window parent. This may be NULL. If it is non-NULL, the frame will always be displayed on top of the parent window on Windows.

Id

The window identifier. It may take a value of-1 to indicate a default value.

Title

The caption to be displayed on the frame's title bar.

Pos

The window position. The value wxDefaultPosition indicates a default position, chosen by either the specified Wing system or wxWidgets, depending on platform.

Size

The window size. The value wxDefaultSize indicates a default size, chosen by either the specified Wing system or wxWidgets, depending on platform.

Style

The window style. See wxFrame class description.

Name

The name of the window. This parameter is used to associate a name with the item, allowing the application user to set Motif resource values for individual windows.

Here, the parameters and return values of the constructor are clear at a glance. The meanings, usage, and default values of each parameter can also be seen.This is the best first-hand development reference.

Next, perform an exercise. When reading the following program, I want to know the Append function. How to use online documentation to find instructions? Find it and try again.

If you have any questions in the above Code, please try to answer them in the online document.


4.2.4 Device Support for viewing online documents

If conditions exist, set the working conditions as shown in. Use a dual screen to read documents and write programs.

For the current study, many electronic reference materials are often used. Reading online documents during development is quite frequent and dual-screen configuration is needed.

Of course, as a school student, when the venue is limited, you don't have to worry too much about such conditions. After all, this is not a must.


4.3 seek help in the programming environment

The programming environment used in this article is Code: Blocks. In the C ++ coding specification, class declaration, constant variable declaration, and macro definition are stored in the header file (. h), and use the source file (. cpp) Save. The header file is actually a very good help document. Developers who meet the requirements of the specifications can always get sufficient information from the original file by allowing readers of the program to "see the document and understand the meaning.

In Code: Blocks, it provides sufficient support for finding this information. In fact, other ides can do this.

For example, for the code section 4.2.3:

SimpleMenu: SimpleMenu (const wxString & title): wxFrame (NULL, wxID_ANY, title, wxDefaultPosition, wxSize (280,180) {menubar = new wxMenuBar; file = new wxMenu; file-> Append (wxID_EXIT, wxT ("& Quit"); // menubar-> Append (file, wxT ("& File ")); // exercise SetMenuBar (menubar); Connect (wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler (SimpleMenu: OnQuit); Centre ();}

Now, I want to know the meanings of parameters of the Append function in file-> Append (wxID_EXIT, wxT ("& Quit. From the previous sentence, we can see that file is an instance of the wxMenu class. You only need to check the wxMenu class declaration. In Code: Blocks, right-click and click the Find declaration of: wxMenu option that appears in the menu,

In Code: Blocks, a new tab is displayed, showing the wxMenu class declaration. However, the wxMenu class does not have a member function such as Append. It is found that the wxMenu class is a derived class of the wxMenuBase class. It is inferred that the Append should be a member function inherited from the wxMenuBase class. With the same operation, right-click the wxMenuBase class name and select the corresponding options. In the displayed tab, four reload declarations of the Append member function are found, as shown in.

 

Now let's do an exercise. Find the declaration of the Append function in menubar-> Append (file, wxT ("& File");, and see the method it calls.


4.4 deep learning route recommendations
4.4.1 reading policy

After completing the work in the first three chapters of this article, we recommend that you read both the books "use wxWidgets for cross-platform program development" and "wxWidgets tutorial" to implement the programs in the book synchronously.

Synchronous viewing means that you can view the data at the same time. You can run the routine before reading the code. It doesn't matter if you don't understand it at one time. You can continue reading it later or read the relevant part of another book. when you read it again, the problem may be solved naturally.

In my learning, I read the first two chapters of "using wxWidgets for cross-platform Program Development", and then read "wxWidgets tutorial" from the beginning, when you look at the back face time in "using wxWidgets for cross-platform Program Development", you can often contact the example that has been run in "wxWidgets tutorial. This kind of arrangement experience is good.

Frequent Project Creation in Code: Block is troublesome. Besides, you must set Build options for each project .... My approach is to create a project that only contains one source file. All the exercises are completed by pasting the code into this file, which saves a lot of time.

The examples in wxWidgets tutorial are well written and strictly enforced the requirements for writing declarations in. h header files and writing implementations in. cpp source files. In practice, I stole a lazy, put the content that should have been put in multiple files, and pasted it into the aforementioned file. Of course, such

#include <wx/wx.h>#include <wx/menu.h>

And so on.

#include "menu.h"

To include commands for custom header files, you must delete them. Because these header files are merged into the same file, they do not exist at all.


4.4.2 more cases

The installed wxWidgets also provides many demo and example projects. X: \ wxWidgets-3.0.0 \ demos is all the demo cases, sample projects in X: \ wxWidgets-3.0.0 \ samples, learn to a certain time, run these programs, read the source code, it is a good learning method.

For example, forty, a project in wxWidgets Demo, is a card game. The running result is as follows:

Shows the source files in this project:

Create a new project in Code: Block, and set all the items in Demo \ forty. cpp and. copy the H file to the project folder, right-click the project name, and select Add file... add files to the project to become the source file and header file of the project. Demo provides a lot of files to adapt to multiple platforms. Generally, you only need. cpp and. H files, as shown in the box section.

If there is a. xpm file in the project (not in each project), copy the file. This is a graphic format file, which is generally used in the program. The forty project contains three such files.

In rare cases, other files may need to be copied. You can read the code to check whether the file name is written in the source program. To run the program, if an error occurs because the file cannot be found, the system will prompt which file is needed. Such as the about.htm file in the fortyproject.

You can copy the last two types of files to the project. You do not have to Add file... to the project.

Run other projects in a similar way.




======================= Author he Lijian CSDN blog = | = Category of IT student growth guidance column (occasionally updated) ==||== C ++ online class column he Lijian Course Teaching Link (by course grade) ==|||== my book-"attacking the university against the normal energy passed to IT students" ==|==== paving the runway for IT cainiao to take off, A university that enjoys happiness and passion with its students ====



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.