Appendix D Other Features in wxWidgets

wxWidgets is a large system, and we couldn’t cover all its features in depth. Here we present a sampler of other aspects that may be useful to you; details on most of them can be found in the wxWidgets reference manual. See also Appendix E, “Third-Party Tools for wxWidgets,” for third-party classes.

Further Window Classes

wxGenericDirCtrl shows a hierarchy of directories, and optionally files; it can be used to build browsers.

wxCalendarCtrl (see Figure D-1) is an attractive way for the user to enter date information. This control can be customized in various ways, including highlighting special dates and starting the week with either Monday or Sunday. wxCalendarCtrl is in the core wxWidgets library, and the sample is in samples/calendar.

Figure D-1 wxCalendarCtrl

wxCalendarCtrl

wxDatePickerCtrl is a more compact control than wxCalendarCtrl that allows the user to select a date. On Windows, it uses a native Win32 control, and on other platforms, a generic wxWidgets version is used.

wxTipWindow is a kind of wxPopupWindow that can be used for showing tooltips, and it is used by wxSimpleHelpProvider to show popup help. The tooltip text is provided in the constructor itself.

wxStyledTextCtrl is a wrapper around Scintilla, a highly capable code editor with highlighting, wrapping, and many other features. With minimal code, your application can support editing text files for a large number of different file formats and programming languages. The Scintilla project can be found at www.scintilla.org, and wxStyledTextCtrl can be found in the contrib hierarchy of your wxWidgets distribution. Check out the demo in contrib/samples/stc (see Figure D-2); documentation is available at http://www.yellowbrain.com/stc.

Figure D-2 wxStyledTextCtrl example

wxStyledTextCtrl example

wxStaticPicture shows an arbitrary, possibly scaled image, working around a restriction in wxStaticBitmap image size on Windows. See contrib/src/gizmos.

wxLEDNumberCtrl (see Figure D-3) is a simulation of an LED display for showing a numeric string. See contrib/src/gizmos.

Figure D-3 LED control

LED control

wxEditableListBox shows a list of strings with controls to add, delete, and move items.

wxFoldPanelBar (see Figure D-4) is an alternative to tabs as a way of showing multiple panels of controls economically. The titles of “folded” panels stack up along the bottom when not in use, and unlike with a tabbed interface, you can choose any combination of panels to be shown simultaneously. See contrib/src/foldbar.

Figure D-4 Folding panel

Folding panel

wxGIFAnimationCtrl can be used for simple, small animations (see Figure D-5). It uses a generic set of classes for flipbook-style animation, and these classes can be extended to use sources of animation data other than GIF. Note that wxHtmlWindow can also display animated GIFs, using its own method. See contrib/src/animate.

Figure D-5 GIF animation control

GIF animation control

wxSplashScreen shows a window with a thin border, displaying a bitmap describing your application. Show it in application initialization and then either explicitly destroy it or let it time-out.

OGL (Object Graphics Library) provides a way to display diagrams consisting of shapes connected by lines, with optional arrows and labels. Figure D-6 shows the wxPython OGL demo displaying a variety of shape types. See contrib/src/ogl.

Figure D-6 wxPython running the OGL demo

wxPython running the OGL demo

FL (Frame Layout) manages the layout for windows that can be moved around a frame and “undocked.” This will soon be superceded by an improved solution. See contrib/src/fl.

ODBC Classes

ODBC is a cross-platform standard for accessing databases, so it’s natural for wxWidgets to provide support for it. Using wxODBC, you can access a wide variety of databases including DB2, DBase, Firebird, INFORMIX, Interbase, MS SQL Server, MS Access, MySQL, Oracle, Pervasive SQL, PostgreSQL, Sybase, XBase, Sequiter, and VIRTUOSO. The main wxODBC classes are wxDb and wxDbTable. For more information, see “Database Classes Overview” in the wxWidgets reference manual. See also samples/db and demos/dbbrowse (see Figure D-7). You may also be interested in reusing the generic tab and page controls that are part of this demo.

Figure D-7 wxWidgets dbbrowse ODBC demo

wxWidgets dbbrowse ODBC demo

For other wxWidgets database access wrappers, see wxOTL and wxSQLite in Appendix E.

MIME Types Manager

The wxMimeTypesManager class enables an application to retrieve information about all known MIME types from a system-specific location, including the file extension for each MIME type. An application uses a global instance of it, called wxTheMimeTypesManager.

Network Functionality

wxWidgets provides more than just the wxSocket class for working with networks. These are some of the network-related wxSocket classes that you can find more about from the manual.

wxURI can be used to extract information from a URI (Uniform Resource Identifier). A URL is a subset of a URI, so the wxURL class (for parsing and streaming from URLs) is derived from wxURI.

wxIPV4address is used to represent a standard Internet address.

wxFTP and wxHTTP can be used for performing FTP and HTTP operations. However, for a fuller implementation, consider using the CURL library instead (see Appendix E for wxCURL and wxCurlDAV).

wxDialUpManager encapsulates functions dealing with verifying the connection status of the computer (connected to the Internet via a direct connection, connected through a modem, or not connected at all) and to establish this connection if required. The application can also request notification about changes in the connection status. This class is currently only supported on Windows.

The wxEmail class in contrib/src/net can be used to send mail via SMAPI on Windows or the sendmail program on Linux.

Multimedia Classes

You can use the wxSound class on all platforms to load and play short sound files. On Windows, wxSound uses wave files (.wav). On Linux, the Open Sound System is used where available, and so it supports the formats handled by OSS. On Mac OS X, wxSound uses Apple’s QuickTime to play wave and other formats.

From wxWidgets 2.5.4, the wxMediaCtrl class is available on Windows, Mac OS X, and Linux. wxMediaCtrl can play sound and video files, and it uses DirectShow on Windows, QuickTime on Mac OS X, and GStreamer on Linux.

Embedded Web Browsers

Although wxHtmlWindow is a fantastic lightweight HTML viewer, sometimes you need full web facilities in your application. Eventually wxWidgets will provide a single class to embed an appropriate browser on each platform, but for now there are different classes to achieve this.

On Mac OS X, wxWidgets comes with wxWebKitCtrl, which you need to enable by passing --enable-webkit to configure when building wxWidgets.

On Linux, you can download wxMozilla (see Appendix E). Be warned that your application distribution will swell by many megabytes if embedding Mozilla.

On Windows, you can download wxIE (see Appendix E) to embed Internet Explorer in your application. You can also consider using wxMozilla on Windows.

Accessibility

Because wxWidgets uses native widgets wherever possible, applications built with it are already quite accessible and tend to be friendly towards screen-reading applications. However, there is a wxAccessible class that can be used to make an application more accessible on Windows by deriving from the class, providing implementations of virtual classes, and associating an instance of it with the appropriate window instance. The class should be enabled with wxUSE_ACCESSIBILITY to 1 in setup.h. Currently, only Microsoft Active Accessibility is supported.

OLE Automation

The wxAutomationObject class represents an OLE automation object containing a single data member, an IDispatch pointer. It contains a number of functions that make it easy to perform automation operations and set and get properties. The class makes heavy use of the wxVariant class and is only available under Windows.

The usage of these classes is quite close to OLE automation usage in Visual Basic. The API is high-level, and the application can specify multiple properties in a single string. The following example gets the current Excel instance, and if it exists, makes the active cell bold:


wxAutomationObject excelObject;
if (excelObject.GetInstance("Excel.Application"))
      excelObject.PutProperty("ActiveCell.Font.Bold", true);

Renderer Classes

The wxRendererNative class and derivatives abstract high-level drawing operations for widgets or parts of widgets, such as buttons, splitter bars, and so on. This allows windows that are drawn “generically” using wxWidgets to use native or at least consistent components. For more information, please see the documentation for wxRendererNative.

Event Loops

The event loop is modeled with the wxEventLoop class. Start the loop by calling Run, test whether the loop is running with IsRunning, and exit the loop with Exit. This class is used for the main loop of the application, and you can also use it for subordinate event loops, as used when showing a modal dialog.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.47.166