|
wxWidgets can be used on mobile and other embedded devices, using GTK+, X11, and Windows CE ports (and others in the future). The most obvious limitation associated with many of these devices is the size of the display, which for a smartphone may be as little as 176x220 pixels. Many dialogs will need an alternative dialog layout for small displays; some controls may be omitted altogether, especially as the functionality of the application may be reduced compared with a desktop application. You can detect the size of the device with wxSystemSettings::GetScreenType, for example: #include "wx/settings.h" bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); GetScreenType returns one of the values listed in Table 9-1. Because the types increase in value as the screen size increases, you can use integer comparison operators to deal with classes of devices with screens below a certain size, as in the example we've just seen.
If you need more detail about the display size, there are three ways to get it:
When you know you may have a stunted display to run on, what can you do with this information? Here are some strategies you can use:
Occasionally you will need to use API enhancements for particular platforms. Microsoft Smartphone has two special buttons that you can assign labels, such as "OK" and "Cancel". On this platform, instead of creating two wxButton objects, you should call wxDialog::SetLeftMenu and wxDialog::SetRightMenu with an identifier, label, and optional submenu to show. Because these functions only exist on the Smartphone port, you need to conditionally compile your code. For example: #ifdef __SMARTPHONE__ SetLeftMenu(wxID_OK, wxT("OK")); SetRightMenu(wxID_OK, wxT("Cancel")); #else wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL); GetTopSizer()->Add(buttonSizer, 0, wxALL|wxGROW, 0); buttonSizer->Add(new wxButton(this, wxID_OK), 0, wxALL, 5); buttonSizer->Add(new wxButton(this, wxID_CANCEL), 0, wxALL, 5); #endif |
|