Update an embarrassingly outdated application writing guide

At least mention wxGraphicsContext and Bind() instead of only speaking
of wxDC and event tables.

Also mention sizers.

Do _not_ mention obsolete and deprecated wxList and friends.
This commit is contained in:
Vadim Zeitlin
2019-09-29 19:11:23 +02:00
parent 1d3dd168ac
commit fe3f1ee6ab

View File

@@ -11,28 +11,39 @@
@tableofcontents @tableofcontents
To set a wxWidgets application going, you will need to derive a wxApp class and @section overview_roughguide_structure Application Structure
override wxApp::OnInit.
An application must have a top-level wxFrame or wxDialog window. Each frame may To set a wxWidgets application going, you will need to derive a wxApp class and
contain one or more instances of classes such as wxPanel, wxSplitterWindow or override wxApp::OnInit() in which you will typically create your application
other windows and controls. main top-level window.
This window can be a wxFrame or a wxDialog and may contain one or more
instances of classes such as wxPanel, wxSplitterWindow or other windows and
controls.
A frame can have a wxMenuBar, a wxToolBar, a wxStatusBar, and a wxIcon for when A frame can have a wxMenuBar, a wxToolBar, a wxStatusBar, and a wxIcon for when
the frame is iconized. the frame is iconized.
A wxPanel is used to place controls (classes derived from wxControl) which are A wxPanel is used to place controls (classes derived from wxControl) which are
used for user interaction. Examples of controls are wxButton, wxCheckBox, used for user interaction. Examples of controls are wxButton, wxCheckBox,
wxChoice, wxListBox, wxRadioBox, and wxSlider. wxChoice, wxListBox, wxRadioBox, and wxSlider. Such controls need to be
positioned correctly -- and also repositioned when the top-level window is
resized by the user -- and to do this you use wxSizer-derived classes, such as
wxBoxSizer and wxFlexGridSizer, to layout everything correctly.
Instances of wxDialog can also be used for controls and they have the advantage Instances of wxDialog can also be used for controls and they have the advantage
of not requiring a separate frame. of not requiring a separate panel inside the,.
Instead of creating a dialog box and populating it with items, it is possible Instead of creating a dialog box and populating it with items, it is possible
to choose one of the convenient common dialog classes, such as wxMessageDialog to choose one of the convenient common dialog classes, such as wxMessageDialog
and wxFileDialog. and wxFileDialog.
You never draw directly onto a window - you use a <em>device context</em> (DC).
@section overview_roughguide_draw Drawing on the Screen
You never draw directly onto a window -- you use either one of the older
<em>device context</em> (DC) classes or the newer <em>graphics context</em>
(GC) one, that support features such as alpha transparency or anti-aliasing.
wxDC is the base for wxClientDC, wxPaintDC, wxMemoryDC, wxPostScriptDC, wxDC is the base for wxClientDC, wxPaintDC, wxMemoryDC, wxPostScriptDC,
wxMemoryDC, wxMetafileDC and wxPrinterDC. If your drawing functions have wxDC wxMemoryDC, wxMetafileDC and wxPrinterDC. If your drawing functions have wxDC
as a parameter, you can pass any of these DCs to the function, and thus use the as a parameter, you can pass any of these DCs to the function, and thus use the
@@ -40,20 +51,19 @@ same code to draw to several different devices. You can draw using the member
functions of wxDC, such as wxDC::DrawLine and wxDC::DrawText. Control colour on functions of wxDC, such as wxDC::DrawLine and wxDC::DrawText. Control colour on
a window (wxColour) with brushes (wxBrush) and pens (wxPen). a window (wxColour) with brushes (wxBrush) and pens (wxPen).
To intercept events, you add a wxDECLARE_EVENT_TABLE macro to the window class With wxGraphicsContext, you create it using one of the methods of
declaration, and put a wxBEGIN_EVENT_TABLE ... wxEND_EVENT_TABLE block in the wxGraphicsRenderer and then construct your drawing from wxGraphicsPath objects,
implementation file. Between these macros, you add event macros which map the finally using wxGraphicsContext::StrokePath() or wxGraphicsContext::FillPath().
event (such as a mouse click) to a member function. These might override
predefined event handlers such as for wxKeyEvent and wxMouseEvent.
Most modern applications will have an on-line, hypertext help system; for this,
you need wxHelp and the wxHelpController class to control wxHelp.
GUI applications aren't all graphical wizardry. List and hash table needs are @section overview_roughguide_events Event Handling
catered for by wxList and wxHashMap. You will undoubtedly need some
platform-independent @ref group_funcmacro_file, and you may find it handy to GUI programs spend most of their time waiting for the user-initiated events --
maintain and search a list of paths using wxPathList. There's many and then processing them. To do it, you use wxEvtHandler::Bind() to specify the
@ref group_funcmacro_misc of operating system methods and other functions. handler for an event of the given time. Event handlers receive the object
describing the event, such as wxKeyEvent or wxMouseEvent, and perform whichever
action corresponds to it. See @ref overview_events "events handling" overview
for much more information about this subject.
@see @ref group_class @see @ref group_class