您的位置:首页 > 其它

How to Learn wxWidgets Programming

2009-07-10 16:33 344 查看
As an overview I would look at the "Alphabetical class reference" section of the reference manual. I find the HTML version to be the easiest to use: you can browse very quickly through it. Here's how to read this (very large) reference:

Get an overview of the kinds of classes involved. The class names will tell you a lot about what each class does. Open some of the classes, in particular, wxApp (the main application object), wxFrame, wxControl (the base class for all controls) and one or two controls, like wxButton.

When scanning a class for the first several times, read the introductory remarks and quickly scan the list of methods of the class to get a general idea about what kinds of operations can be done to objects of the class. You are not looking for detail at this stage, just for the big picture. In particular, what classes exist and how do they work together.

Pay particular attention to the classes from which a class is derived. For example, a button (an object of type wxButton) is derived from the wxControl, wxWindow, wxEvtHandler and wxObject classes. What does this mean? It means that a button _is_ a control, and a button _is_ a window, and a button _is_ an event handler and a button _is_ an object. So you must understand the parent classes of an object to understand the object itself. For example, if b is a button you can invoke b.m for any of method m of the wxControl, wxWindow, wxEvtHandler or wxObject classes. You are not limited to just the methods of wxButton! This is one of the keys of object oriented programming.

Some other tips:

Read some sample code. You will find that almost none of the C++ language is actually being used; it's just endlessly creating objects and then calling methods using those objects.

Learn as much as you can about the String class; after using a good String class you'll never want to use C's string functions again. wxWidgets contains other nifty utilty classes as well.

The application class, wxApp, contains the main event loop. Learn about event handling and event tables (reading sample code will help). Almost everything in this kind of application framework happens as the result of an event and your app is essentially doing nothing but responding to events. Having the event loop written for you is a major, major benefit.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: