1 Architecture
The architecture of the wxwidgets is shown in the following figure. The wxwidgets architecture can be divided into 4 tiers: The Wxwidgets public API layer, each platform port, the APIs for each platform, and the operating system.
2 Libraries List
From version 2.5.0 onwards, wxwidgets can either be compiled into a single large ibrary (monolithic build) or compiled into a few small libraries (multilib build). Wxwidgets default is compiled to Multilib build.
The following figure lists the Wxwidgets libraries and their dependencies.
1) Wxaui
Contains the advanced user interface docking library.
2) Wxbase
All wxwidgets programs must be linked to this library. Contains a number of data structure classes and other common base classes (such as wxstring,wxwindowbase, etc.). The differences between platforms are abstracted. Wxbase can be used to develop console programs and does not require any GUI libraries.
3) wxnet
Network Development related classes:
Wxsocket Class (Wxsocketclient, Wxsocketserver, and other related classes)
Wxsocketoutputstream and Wxsocketinputstream
Sockets-based IPC Class (Wxtcpserver, Wxtcpclient and Wxtcpconnection)
Wxurl
Wxinternetfshandler (a Wxfilesystem handler).
4) Wxrichtext
Generic Rich Text control.
5) Wxxml
Contains classes that parse XML documents. It is not recommended. Future versions will contain new XML processing classes, including Dom-like APIs.
6) Wxcore
A basic GUI class, such as a GDI class or control. All wxwidgets GUI applications must reference this library.
7) wxadvanced
Advanced or infrequently used GUI classes.
Wxbuffereddc
Wxcalendarctrl
Wxgrid classes
Wxjoystick
Wxlayoutalgorithm
Wxsplashscreen
Wxtaskbaricon
Wxsound
Wxwizard
Wxsashlayoutwindow
Wxsashwindow
8) Wxmedia
Multimedia class. Currently, only Wxmediactrl is included and more classes will be added in the future.
9) WXGL
Includes Wxglcanvas integrated OpenGL library. Unlike other classes, this library is not part of the monolithic library, but is always compiled into a separate library.
) wxhtml
HTML renderer and its related classes.
One) Wxodbc
The database class.
WXQA)
Quality Assurance Class Library. There are currently only Wxdebugreport and related classes.
Wxdbgrid)
The Wxdbgridtablebase class combines Wxgrid and wxdbtable.
WXXRC)
Contains the Wxxmlresource class, which reads an XML resource file in the XRC format.
3 Internal Code organizational structure
As the figure, is the wxwidgets source code organization structure, broadly can be divided into six layers:
1) Common Code section (located in the common directory). Used by all versions, including data structures, run-time type information, and some base classes that are inherited by other classes, such as Wxwindowbase.
2) General Code section (located in the generic directory). Achieve platform-independent advanced widgets. such as Wxwizard and Wxcalendarctrl.
3) Wxuniversal section (located in the Univ directory). A basic window control class that can be used for platforms that do not provide local window controls, such as X11 and MGL.
4) Platform-related code (in GTK, MSW and other directories). Implement the class using the local API.
5) The Foreign Code section, placed in a separate directory structure (contrib directory, this figure is not listed, located in the previous level of the directory).
6) third-party code (in directories such as Jpeg,png,regex,zlib), which are independent of wxwidgets projects, but wxwidgets used to implement many important functions.
WxWidgets Libraries and internal code organizations have cross-relationships. If the Wxnet library contains both common code and Platform-related code parts, other libraries may include the General Code section.
Class 4 Inheritance Relationships
As shown in the figure, the inheritance relationship between the wxbase and the central Wxcore classification is enumerated.
Wxobject is the foundation of most other classes, and the first of water. Any class derived from Wxobject can inherit several important object-oriented features, including RTTI (execution period type recognition), dynamic Creation (dynamically generated), and so on.
Where WXWINDOWGTK and WXTOPLEVELWINDOWGTK are platform-related classes, the source code is located in the GTK directory. The corresponding classes under window are WXWINDOWMSW and WXTOPLEVELWINDOWMSW, located in the MSW directory. When compiling the code, how does wxwidgets know which class to compile. The main wxwidgets are implemented by different macro definitions:
in App.h, you can find the following code: #if defined (__wxpalmos__) #include "wx/palmos/app.h" #elif defined (__ wxmsw__) #include "wx/msw/app.h" #elif defined (__wxmotif__) #include "wx/motif/app.h" #elif defined (__wxmgl__) #include "Wx/mgl/app.h" #elif defined (__wxdfb__) #include "wx/dfb/app.h" #elif defined (__wxgtk20__) #include "Wx/gtk/app.h" # Elif defined (__wxgtk__) #include "wx/gtk1/app.h" #elif defined (__wxx11__) #include "wx/x11/app.h" #elif defined (__wxmac __) #include "wx/mac/app.h" #elif defined (__wxcocoa__) #include "wx/cocoa/app.h" #elif defined (__wxpm__) #include "wx/ Os2/app.h "
Similarly in window.h, you can find: #if defined (__wxmsw__) #define WXWINDOWNATIVE WXWINDOWMSW #elif defined (__wxgtk__) #define Wxwindownative wxwindowgtk #elif defined (__wxmgl__) #define WXWINDOWNATIVE WXWINDOWMGL #elif defined (__wxx11__) #define Wxwindownative wxWindowX11 #elif defined (__wxmac__) #define Wxwindownative Wxwindowmac #endif class Wxdllexport Wxwindow : Public Wxwindownative {... }
By specifying a different compilation switch, you can compile a platform-related class library.
Reference documents
"Cross-platform GUI Programming with WxWidgets", Julian Smart and Kevin Hock with Stefan Csomor.
"WxWidgets 2.8.9:a portable C + + and Python GUI toolkit", Julian Smart, Robert roebling, Vadim Zeitlin, Robin Dunn, et al
Http://hi.baidu.com/zshua_404/blog/item/a10155393d4c3623b8998feb.html