[ Lit Window Library at SourceForge ] [ Lit Window Productions Homepage ] [ wxWidgets Tips&Tricks ] [ wxVisualSetup ]
Mediator Design Pattern. See the web for more information about this particular design pattern if you are unfamiliar with it. In short: A Mediator object is an object that encapsulates the interdependencies of several objects. Each individual object knows only about the Mediator. It passes any change requests to it along to the Mediator. The Mediator is the only participant that "knows the whole picture". It is the "conductor" of a symphonic "orchester" of individual objects.
Add the rapidui.h include file to rssmainframe.h
////@end includes #include <litwindow/wx/rapidui.h>
class RssMainFrame: public wxFrame { public: RapidUI m_rapidUI;
Add the following lines to rssmainframe.cpp to start a rules section
BEGIN_RULES(g_rules) END_RULES()
The rules section is empty for now. We will fill in some rules in the next step, RSS Reader Tutorial Step 4: Filling in the rules
The windows is a collection of one or more wxWindow* pointers. The children of the window you pass to RapidUI are automatically assumed to be under RapidUIs control as well. The tutorial simply uses the top level frame window as the window root for RapidUI.
The data is a collection of data adapters that point to your actual data object. The members of a struct - direct or inherited - are automatically assumed to be part of the RapidUI data collection. The tutorial needs only one data adapter: the adapter to the global variable g_data.
The best place to pass these objects to the RapidUI object is in the RssMainFrame::Create() function in the file rssmainframe.cpp:
bool RssMainFrame::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style ) { SetParent(parent); CreateControls(); Centre(); ////@end RssMainFrame creation
m_rapidUI.AddWindow(this); // Add the main frame to RapidUI m_rapidUI.AddData(make_accessor(g_data)); // Add the list of channels m_rapidUI.AddRules(g_rules); // Add rules m_rapidUI.Start(); // Start the RapidUI mediator mechanism
make_accessor creates a data adapter for the global variable g_channels. Here is an alternative version:
m_rapidUI << this << make_accessor(g_data) << g_rules << RapidUI::Go;
rssmainframe.obj : warning LNK4217: locally defined symbol ?get@?$prop_type_object@URssReaderData@@@ data_adapter@@SAPAVconverter_base@2@PBURssReaderData@@@Z (public: static class data_adapter::converter_base * __cdecl data_adapter::prop_type_object<struct RssReaderData>::get(struct RssReaderData const *)) imported in function "class data_adapter::converter_base * __cdecl data_adapter::get_prop_type<struct RssReaderData> (struct RssReaderData const *)" (??$get_prop_type@URssReaderData@@@data_adapter@@YAPAVconverter_base@0@PBURs sReaderData@@@Z)
m_rapidUI.AddWindow(this); // Add the main frame to RapidUI m_rapidUI.AddData(make_accessor(g_data)); // Add the list of channels m_rapidUI.AddRules(g_rules); // Add rules m_rapidUI.Start(); // Start the RapidUI mediator mechanism
Continue with step 4 RSS Reader Tutorial Step 4: Filling in the rules
Copyright 2004, Hajo Kirchhoff, Lit Window Productions