Add support for id ranges to XRC.

Allow to declare ranges of consecutive IDs in XRC by using the "id[n]" syntax.
Show this functionality in the xrc sample and test it in the new unit test.

Also show and test the "object reference" XRC functionality.

Closes #11431.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2010-11-07 14:00:59 +00:00
parent 1f6ea93556
commit 0526c8cc07
37 changed files with 1671 additions and 23 deletions

View File

@@ -43,7 +43,7 @@ wx_top_builddir = @wx_top_builddir@
DESTDIR =
WX_RELEASE = 2.9
WX_VERSION = $(WX_RELEASE).1
WX_VERSION = $(WX_RELEASE).2
LIBDIRNAME = $(wx_top_builddir)/lib
XRCDEMO_CXXFLAGS = -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) \
$(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) \
@@ -55,7 +55,8 @@ XRCDEMO_OBJECTS = \
xrcdemo_xrcdemo.o \
xrcdemo_myframe.o \
xrcdemo_derivdlg.o \
xrcdemo_custclas.o
xrcdemo_custclas.o \
xrcdemo_objrefdlg.o
### Conditionally set variables: ###
@@ -195,7 +196,7 @@ xrcdemo$(EXEEXT): $(XRCDEMO_OBJECTS) $(__xrcdemo___win32rc)
data:
@mkdir -p ./rc
@for f in artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm; do \
@for f in artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm objref.xrc objrefdlg.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm; do \
if test ! -f ./rc/$$f -a ! -d ./rc/$$f ; \
then x=yep ; \
else x=`find $(srcdir)/rc/$$f -newer ./rc/$$f -print` ; \
@@ -220,6 +221,9 @@ xrcdemo_derivdlg.o: $(srcdir)/derivdlg.cpp
xrcdemo_custclas.o: $(srcdir)/custclas.cpp
$(CXXC) -c -o $@ $(XRCDEMO_CXXFLAGS) $(srcdir)/custclas.cpp
xrcdemo_objrefdlg.o: $(srcdir)/objrefdlg.cpp
$(CXXC) -c -o $@ $(XRCDEMO_CXXFLAGS) $(srcdir)/objrefdlg.cpp
# Include dependency info, if present:
@IF_GNU_MAKE@-include ./.deps/*.d

View File

@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// Name: xmldemo.cpp
// Name: derivdlg.h
// Purpose: XML resources sample: A derived dialog
// Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik
// RCS-ID: $Id$

View File

@@ -39,7 +39,8 @@ XRCDEMO_OBJECTS = \
$(OBJS)\xrcdemo_xrcdemo.obj \
$(OBJS)\xrcdemo_myframe.obj \
$(OBJS)\xrcdemo_derivdlg.obj \
$(OBJS)\xrcdemo_custclas.obj
$(OBJS)\xrcdemo_custclas.obj \
$(OBJS)\xrcdemo_objrefdlg.obj
### Conditionally set variables: ###
@@ -255,7 +256,7 @@ $(OBJS)\xrcdemo.exe: $(XRCDEMO_OBJECTS) $(OBJS)\xrcdemo_sample.res
data:
if not exist $(OBJS)\rc mkdir $(OBJS)\rc
for %f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%f copy .\rc\%f $(OBJS)\rc
for %f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm objref.xrc objrefdlg.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%f copy .\rc\%f $(OBJS)\rc
$(OBJS)\xrcdemo_sample.res: .\..\..\samples\sample.rc
brcc32 -32 -r -fo$@ -i$(BCCDIR)\include -d__WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) $(__MSLU_DEFINE_p_1) -i$(SETUPHDIR) -i.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_1_p) -i. $(__DLLFLAG_p_1) -i.\..\..\samples -dNOPCH .\..\..\samples\sample.rc
@@ -272,3 +273,5 @@ $(OBJS)\xrcdemo_derivdlg.obj: .\derivdlg.cpp
$(OBJS)\xrcdemo_custclas.obj: .\custclas.cpp
$(CXX) -q -c -P -o$@ $(XRCDEMO_CXXFLAGS) .\custclas.cpp
$(OBJS)\xrcdemo_objrefdlg.obj: .\objrefdlg.cpp
$(CXX) -q -c -P -o$@ $(XRCDEMO_CXXFLAGS) .\objrefdlg.cpp

View File

@@ -33,7 +33,8 @@ XRCDEMO_OBJECTS = \
$(OBJS)\xrcdemo_xrcdemo.o \
$(OBJS)\xrcdemo_myframe.o \
$(OBJS)\xrcdemo_derivdlg.o \
$(OBJS)\xrcdemo_custclas.o
$(OBJS)\xrcdemo_custclas.o \
$(OBJS)\xrcdemo_objrefdlg.o
### Conditionally set variables: ###
@@ -242,7 +243,7 @@ $(OBJS)\xrcdemo.exe: $(XRCDEMO_OBJECTS) $(OBJS)\xrcdemo_sample_rc.o
data:
if not exist $(OBJS)\rc mkdir $(OBJS)\rc
for %%f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%%f copy .\rc\%%f $(OBJS)\rc
for %%f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm objref.xrc objrefdlg.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%%f copy .\rc\%%f $(OBJS)\rc
$(OBJS)\xrcdemo_sample_rc.o: ./../../samples/sample.rc
windres --use-temp-file -i$< -o$@ --define __WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) $(__MSLU_DEFINE_p_1) --include-dir $(SETUPHDIR) --include-dir ./../../include $(__CAIRO_INCLUDEDIR_p) --include-dir . $(__DLLFLAG_p_1) --include-dir ./../../samples --define NOPCH
@@ -259,6 +260,9 @@ $(OBJS)\xrcdemo_derivdlg.o: ./derivdlg.cpp
$(OBJS)\xrcdemo_custclas.o: ./custclas.cpp
$(CXX) -c -o $@ $(XRCDEMO_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\xrcdemo_objrefdlg.o: ./objrefdlg.cpp
$(CXX) -c -o $@ $(XRCDEMO_CXXFLAGS) $(CPPDEPS) $<
.PHONY: all clean data

View File

@@ -56,7 +56,8 @@ XRCDEMO_OBJECTS = \
xrcdemo_xrcdemo.o \
xrcdemo_myframe.o \
xrcdemo_derivdlg.o \
xrcdemo_custclas.o
xrcdemo_custclas.o \
xrcdemo_objrefdlg.o
### Conditionally set variables: ###
@@ -105,6 +106,9 @@ xrcdemo_derivdlg.o: ./derivdlg.cpp
xrcdemo_custclas.o: ./custclas.cpp
$(CXX) -c -o $@ $(XRCDEMO_CXXFLAGS) $(CPPDEPS) $<
xrcdemo_objrefdlg.o: ./objrefdlg.cpp
$(CXX) -c -o $@ $(XRCDEMO_CXXFLAGS) $(CPPDEPS) $<
.PHONY: all install uninstall clean

View File

@@ -33,7 +33,8 @@ XRCDEMO_OBJECTS = \
$(OBJS)\xrcdemo_xrcdemo.obj \
$(OBJS)\xrcdemo_myframe.obj \
$(OBJS)\xrcdemo_derivdlg.obj \
$(OBJS)\xrcdemo_custclas.obj
$(OBJS)\xrcdemo_custclas.obj \
$(OBJS)\xrcdemo_objrefdlg.obj
XRCDEMO_RESOURCES = \
$(OBJS)\xrcdemo_sample.res
@@ -365,7 +366,7 @@ $(OBJS)\xrcdemo.exe: $(XRCDEMO_OBJECTS) $(OBJS)\xrcdemo_sample.res
data:
if not exist $(OBJS)\rc mkdir $(OBJS)\rc
for %f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%f copy .\rc\%f $(OBJS)\rc
for %f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm objref.xrc objrefdlg.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%f copy .\rc\%f $(OBJS)\rc
$(OBJS)\xrcdemo_sample.res: .\..\..\samples\sample.rc
rc /fo$@ /d WIN32 $(____DEBUGRUNTIME_3_p_1) $(__NO_VC_CRTDBG_p_1) /d __WXMSW__ $(__WXUNIV_DEFINE_p_1) $(__DEBUG_DEFINE_p_1) $(__NDEBUG_DEFINE_p_1) $(__EXCEPTIONS_DEFINE_p_1) $(__RTTI_DEFINE_p_1) $(__THREAD_DEFINE_p_1) $(__UNICODE_DEFINE_p_1) $(__MSLU_DEFINE_p_1) /i $(SETUPHDIR) /i .\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES_1_p) /i . $(__DLLFLAG_p_1) /d _WINDOWS /i .\..\..\samples /d NOPCH .\..\..\samples\sample.rc
@@ -382,3 +383,5 @@ $(OBJS)\xrcdemo_derivdlg.obj: .\derivdlg.cpp
$(OBJS)\xrcdemo_custclas.obj: .\custclas.cpp
$(CXX) /c /nologo /TP /Fo$@ $(XRCDEMO_CXXFLAGS) .\custclas.cpp
$(OBJS)\xrcdemo_objrefdlg.obj: .\objrefdlg.cpp
$(CXX) /c /nologo /TP /Fo$@ $(XRCDEMO_CXXFLAGS) .\objrefdlg.cpp

View File

@@ -252,7 +252,8 @@ XRCDEMO_OBJECTS = &
$(OBJS)\xrcdemo_xrcdemo.obj &
$(OBJS)\xrcdemo_myframe.obj &
$(OBJS)\xrcdemo_derivdlg.obj &
$(OBJS)\xrcdemo_custclas.obj
$(OBJS)\xrcdemo_custclas.obj &
$(OBJS)\xrcdemo_objrefdlg.obj
all : $(OBJS)
@@ -285,7 +286,7 @@ $(OBJS)\xrcdemo.exe : $(XRCDEMO_OBJECTS) $(OBJS)\xrcdemo_sample.res
data : .SYMBOLIC
if not exist $(OBJS)\rc mkdir $(OBJS)\rc
for %f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%f copy .\rc\%f $(OBJS)\rc
for %f in (artprov.xpm artprov.xrc basicdlg.xpm basicdlg.xrc controls.xpm controls.xrc custclas.xpm custclas.xrc derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif resource.xrc toolbar.xrc uncenter.xpm objref.xrc objrefdlg.xpm uncenter.xrc update.gif variable.xpm variable.xrc throbber.gif stop.xpm) do if not exist $(OBJS)\rc\%f copy .\rc\%f $(OBJS)\rc
$(OBJS)\xrcdemo_sample.res : .AUTODEPEND .\..\..\samples\sample.rc
wrc -q -ad -bt=nt -r -fo=$^@ -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__NDEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) $(__UNICODE_DEFINE_p) -i=$(SETUPHDIR) -i=.\..\..\include $(____CAIRO_INCLUDEDIR_FILENAMES) -i=. $(__DLLFLAG_p) -i=.\..\..\samples -dNOPCH $<
@@ -302,3 +303,5 @@ $(OBJS)\xrcdemo_derivdlg.obj : .AUTODEPEND .\derivdlg.cpp
$(OBJS)\xrcdemo_custclas.obj : .AUTODEPEND .\custclas.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(XRCDEMO_CXXFLAGS) $<
$(OBJS)\xrcdemo_objrefdlg.obj : .AUTODEPEND .\objrefdlg.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(XRCDEMO_CXXFLAGS) $<

View File

@@ -49,6 +49,8 @@
#include "derivdlg.h"
// Our custom class, for the custom class example.
#include "custclas.h"
// And our objref dialog, for the object reference and ID range example.
#include "objrefdlg.h"
// For functions to manipulate our wxTreeCtrl and wxListCtrl
#include "wx/treectrl.h"
#include "wx/listctrl.h"
@@ -83,6 +85,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(XRCID("derived_tool_or_menuitem"), MyFrame::OnDerivedDialogToolOrMenuCommand)
EVT_MENU(XRCID("controls_tool_or_menuitem"), MyFrame::OnControlsToolOrMenuCommand)
EVT_MENU(XRCID("uncentered_tool_or_menuitem"), MyFrame::OnUncenteredToolOrMenuCommand)
EVT_MENU(XRCID("obj_ref_tool_or_menuitem"), MyFrame::OnObjRefToolOrMenuCommand)
EVT_MENU(XRCID("custom_class_tool_or_menuitem"), MyFrame::OnCustomClassToolOrMenuCommand)
EVT_MENU(XRCID("platform_property_tool_or_menuitem"), MyFrame::OnPlatformPropertyToolOrMenuCommand)
EVT_MENU(XRCID("art_provider_tool_or_menuitem"), MyFrame::OnArtProviderToolOrMenuCommand)
@@ -268,6 +271,22 @@ void MyFrame::OnUncenteredToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
}
void MyFrame::OnObjRefToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
// The dialog redirects log messages, so save the old log target first
wxLog* oldlogtarget = wxLog::SetActiveTarget(NULL);
// Make an instance of the dialog
ObjrefDialog* objrefDialog = new ObjrefDialog(this);
// Show the instance of the dialog, modally.
objrefDialog->ShowModal();
objrefDialog->Destroy();
// Restore the old log target
delete wxLog::SetActiveTarget(oldlogtarget);
}
void MyFrame::OnCustomClassToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
{
wxDialog dlg;

View File

@@ -44,6 +44,7 @@ private:
void OnDerivedDialogToolOrMenuCommand(wxCommandEvent& event);
void OnControlsToolOrMenuCommand(wxCommandEvent& event);
void OnUncenteredToolOrMenuCommand(wxCommandEvent& event);
void OnObjRefToolOrMenuCommand(wxCommandEvent& event);
void OnCustomClassToolOrMenuCommand(wxCommandEvent& event);
void OnPlatformPropertyToolOrMenuCommand(wxCommandEvent& event);
void OnArtProviderToolOrMenuCommand(wxCommandEvent& event);

290
samples/xrc/objrefdlg.cpp Normal file
View File

@@ -0,0 +1,290 @@
//-----------------------------------------------------------------------------
// Name: objref.cpp
// Purpose: XML resources sample: Object references and ID ranges dialog
// Author: David Hart, Vaclav Slavik
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Standard wxWidgets headers
//-----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
// For all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers)
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
//-----------------------------------------------------------------------------
// Header of this .cpp file
//-----------------------------------------------------------------------------
#include "objrefdlg.h"
//-----------------------------------------------------------------------------
// Remaining headers: Needed wx headers, then wx/contrib headers, then application headers
//-----------------------------------------------------------------------------
#include "wx/xrc/xmlres.h" // XRC XML resouces
//-----------------------------------------------------------------------------
// Public members
//-----------------------------------------------------------------------------
ObjrefDialog::ObjrefDialog(wxWindow* parent)
{
wxXmlResource::Get()->LoadDialog(this, parent, wxT("objref_dialog"));
nb = XRCCTRL(*this, "objref_notebook", wxNotebook);
wxCHECK_RET(nb, "failed to find objref_notebook");
nb->Bind(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, &ObjrefDialog::OnNotebookPageChanged, this);
iconspage_bound = false;
calcpage_bound = false;
}
ObjrefDialog::~ObjrefDialog()
{
// Select page 0. Otherwise if the Calc page were selected, when it's removed the Icons page is selected
// and sets the log target again in idle time, *after* myframe restores the old one!
nb->ChangeSelection(0);
}
//-----------------------------------------------------------------------------
// Private members (including the event handlers)
//-----------------------------------------------------------------------------
void ObjrefDialog::OnNotebookPageChanged( wxNotebookEvent &event )
{
switch(event.GetSelection())
{
case copy_page:
{
// This is a straight object reference to the first page
// so change the text programmatically
nb->SetPageText(copy_page, "Page 1 copy");
wxNotebookPage *page = nb->GetPage(copy_page);
wxTextCtrl *text = XRCCTRL(*page, "description_text", wxTextCtrl);
text->ChangeValue(
wxString("This is a duplicate of page 1, using an object reference. ")
+ wxString("It was created by this very simple xml:\n\n")
+ wxString("<object class=\"notebookpage\">\n\t<object_ref ref=\"page1\"/>\n")
+ wxString("\t<label>Page 1 copy</label>\n</object>")
+ wxString("\n\n(Then I'm cheating by inserting this text programmatically.)")
);
break;
}
case icons_page:
{
wxNotebookPage *page = nb->GetPage(icons_page);
if (!iconspage_bound)
{
iconspage_bound = true;
// We want to direct UpdateUI events for the ID range 'first_row' to OnUpdateUIFirst().
// We could achieve this using first_row[0] and first_row[2], but what if a fourth
// column were added? It's safer to use the 'typedefs' for the two ends of the range:
page->Bind(wxEVT_UPDATE_UI, &ObjrefDialog::OnUpdateUIFirst,
this, XRCID("first_row[start]"), XRCID("first_row[end]"));
// Similarly for the other two rows
page->Bind(wxEVT_UPDATE_UI, &ObjrefDialog::OnUpdateUISecond,
this, XRCID("second_row[start]"), XRCID("second_row[end]"));
page->Bind(wxEVT_UPDATE_UI, &ObjrefDialog::OnUpdateUIThird,
this, XRCID("third_row[start]"), XRCID("third_row[end]"));
}
text = XRCCTRL(*page, "log_text", wxTextCtrl);
if (text)
delete wxLog::SetActiveTarget(new wxLogTextCtrl(text));
break;
}
case calc_page:
{
wxNotebookPage *page = nb->GetPage(calc_page);
if (!calcpage_bound)
{
calcpage_bound = true;
// Bind the id ranges, using the [start] and [end] 'typedefs'
page->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ObjrefDialog::OnNumeralClick,
this, XRCID("digits[start]"), XRCID("digits[end]"));
page->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &ObjrefDialog::OnOperatorClick,
this, XRCID("operators[start]"), XRCID("operators[end]"));
}
result_txt = XRCCTRL(*page, "result", wxTextCtrl);
text = XRCCTRL(*page, "log_text", wxTextCtrl);
if (text)
delete wxLog::SetActiveTarget(new wxLogTextCtrl(text));
ClearCalculator();
break;
}
default: return;
}
}
// There are undoubtedly simpler ways of doing all this, but we're demonstrating the use of ID ranges
void ObjrefDialog::OnUpdateUIFirst(wxUpdateUIEvent& event)
{
// The checkbox with the XRCID 'check[0]' controls this row of icons
wxCheckBox *chk = XRCCTRL(*(nb->GetPage(icons_page)), "check[0]", wxCheckBox);
if (chk)
event.Enable(chk->IsChecked());
// Let's create a log-window entry
static bool checked = true;
if (chk->IsChecked() != checked)
{
checked = chk->IsChecked();
wxLogMessage("Row one has been %s by check[0], XRCID = %i", checked ? "enabled" : "disabled", XRCID("check[0]"));
wxLogMessage("XRCIDs: first_row[start] = %i, first_row[0] = %i, first_row[1] = %i, first_row[2] = %i, first_row[end] = %i",
XRCID("first_row[start]"), XRCID("first_row[0]"), XRCID("first_row[1]"), XRCID("first_row[2]"), XRCID("first_row[end]"));
}
}
void ObjrefDialog::OnUpdateUISecond(wxUpdateUIEvent& event)
{
// The checkbox with the XRCID 'check[1]' controls this row of icons
wxCheckBox *chk = XRCCTRL(*(nb->GetPage(icons_page)), "check[1]", wxCheckBox);
if (chk)
event.Enable(chk->IsChecked());
// Let's create a log-window entry
static bool checked = true;
if (chk->IsChecked() != checked)
{
checked = chk->IsChecked();
wxLogMessage("Row two has been %s by check[1], XRCID = %i", checked ? "enabled" : "disabled", XRCID("check[1]"));
wxLogMessage("XRCIDs: second_row[start] = %i, second_row[0] = %i, second_row[1] = %i, second_row[2] = %i, second_row[end] = %i",
XRCID("second_row[start]"), XRCID("second_row[0]"), XRCID("second_row[1]"), XRCID("second_row[2]"), XRCID("second_row[end]"));
}
}
void ObjrefDialog::OnUpdateUIThird(wxUpdateUIEvent& event)
{
// The checkbox with the XRCID 'check[2]' controls this row of icons
wxCheckBox *chk = XRCCTRL(*(nb->GetPage(icons_page)), "check[2]", wxCheckBox);
if (chk)
event.Enable(chk->IsChecked());
// Let's create a log-window entry
static bool checked = true;
if (chk->IsChecked() != checked)
{
checked = chk->IsChecked();
wxLogMessage("Row three has been %s by check[2], XRCID = %i", checked ? "enabled" : "disabled", XRCID("check[2]"));
wxLogMessage("XRCIDs: third_row[start] = %i, third_row[0] = %i, third_row[1] = %i, third_row[2] = %i, third_row[end] = %i",
XRCID("third_row[start]"), XRCID("third_row[0]"), XRCID("third_row[1]"), XRCID("third_row[2]"), XRCID("third_row[end]"));
}
}
void ObjrefDialog::OnNumeralClick(wxCommandEvent& event)
{
// See how the id range simplifies determining which numeral was clicked
int digit = event.GetId() - XRCID("digits[start]");
char c = '0' + digit;
if (current==0 && previous==0)
{
// We're just starting a calculation, so get rid of the placeholder '0'
result_txt->Clear();
}
else if (operator_expected == true)
{
// If we've just finished one calculation, and now a digit is entered, clear
ClearCalculator();
result_txt->Clear();
}
(*result_txt) << c;
current = current*10 + digit;
wxLogMessage("You clicked digits[%c], XRCID %i", c, event.GetId());
}
void ObjrefDialog::OnOperatorClick(wxCommandEvent& event)
{
static const char symbols[] = "+-*/=";
operator_expected = false;
int ID = event.GetId() - XRCID("operators[start]");
// We carefully used "operators[end]" as the name of the Clear button
if (event.GetId() == XRCID("operators[end]"))
{
wxLogMessage("You clicked operators[%i], XRCID %i, 'Clear'", ID, event.GetId());
return ClearCalculator();
}
switch(ID)
{
case operator_plus:
case operator_minus:
case operator_multiply:
case operator_divide:
if (current!=0 || previous!=0)
{
// We're in the middle of a complex calculation, so do the first bit
Calculate();
}
curr_operator = (CalcOperator)ID;
break;
case operator_equals:
Calculate();
wxLogMessage("You clicked operators[%i], XRCID %i, giving a '%c'", ID, event.GetId(), symbols[ID]);
curr_operator = operator_equals;
// Flag that the next entry should be an operator, not a digit
operator_expected = true;
return;
}
(*result_txt) << ' ' << symbols[ID] << ' ';
wxLogMessage("You clicked operators[%i], XRCID %i, giving a '%c'", ID, event.GetId(), symbols[ID]);
}
void ObjrefDialog::Calculate()
{
switch(curr_operator)
{
case operator_plus:
previous += current; break;
case operator_minus:
previous -= current; break;
case operator_multiply:
previous *= current; break;
case operator_divide:
if (current!=0)
previous /= current;
break;
default: return;
}
curr_operator = operator_plus;
current = 0;
result_txt->Clear();
(*result_txt) << previous;
}
void ObjrefDialog::ClearCalculator()
{
current = previous = 0;
curr_operator = operator_plus;
operator_expected = false;
result_txt->ChangeValue("0");
}

64
samples/xrc/objrefdlg.h Normal file
View File

@@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// Name: objref.h
// Purpose: XML resources sample: Object references and ID ranges dialog
// Author: David Hart, Vaclav Slavik
// RCS-ID: $Id$
// Copyright: (c) Vaclav Slavik
// Licence: wxWindows licence
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Begin single inclusion of this .h file condition
//-----------------------------------------------------------------------------
#ifndef _OBJREFDLG_H_
#define _OBJREFDLG_H_
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include "wx/dialog.h"
#include "wx/notebook.h"
//-----------------------------------------------------------------------------
// Class definition: ObjrefDialog
//-----------------------------------------------------------------------------
class ObjrefDialog : public wxDialog
{
public:
// Constructor.
ObjrefDialog( wxWindow* parent );
// Destructor.
~ObjrefDialog();
private:
enum PageNumbers { first_page, copy_page, icons_page, calc_page };
enum CalcOperator { operator_plus, operator_minus, operator_multiply, operator_divide, operator_equals };
void OnNotebookPageChanged( wxNotebookEvent &event );
void OnUpdateUIFirst(wxUpdateUIEvent& event);
void OnUpdateUISecond(wxUpdateUIEvent& event);
void OnUpdateUIThird(wxUpdateUIEvent& event);
void OnNumeralClick(wxCommandEvent& event);
void OnOperatorClick(wxCommandEvent& event);
void Calculate();
void ClearCalculator();
wxNotebook *nb;
wxTextCtrl *text;
wxTextCtrl *result_txt;
bool iconspage_bound;
bool calcpage_bound;
int current;
int previous;
bool operator_expected;
CalcOperator curr_operator;
};
#endif //_OBJREFDLG_H_

View File

@@ -49,6 +49,11 @@
<object class="wxMenu" name="advanced_demos_menu">
<label>_Advanced</label>
<help>Advanced techniques with XRC</help>
<object class="wxMenuItem" name="obj_ref_tool_or_menuitem">
<label>_Object References Example</label>
<bitmap>objrefdlg.xpm</bitmap>
<help>Use of object references and event ranges</help>
</object>
<object class="wxMenuItem" name="custom_class_tool_or_menuitem">
<label>_Custom Class Example</label>
<bitmap>custclas.xpm</bitmap>

418
samples/xrc/rc/objref.xrc Normal file
View File

@@ -0,0 +1,418 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<resource version="2.3.0.1" xmlns="http://www.wxwidgets.org/wxxrc">
<object class="wxDialog" name="objref_dialog">
<object class="wxFlexGridSizer">
<object class="sizeritem">
<object class="wxNotebook" name="objref_notebook">
<object class="notebookpage">
<object class="wxPanel" name="page1">
<object class="wxFlexGridSizer">
<object class="sizeritem">
<object class="wxTextCtrl" name="description_text">
<value>This dialog demonstrates the use of object references and ID arrays.\n\nAs you turn the pages of the notebook, you will notice that each has an identical section at the bottom. Instead of writing that section's xml several times, this is done just once, as a wxPanel named 'bottom__panel'. The panel is then added to each page's sizer by the single line: &lt;object__ref ref=&quot;bottom__panel&quot;/&gt;</value>
<style>wxTE_MULTILINE|wxTE_READONLY</style>
</object>
<option>1</option>
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object_ref ref="bottom_panel"/>
<flag>wxEXPAND</flag>
</object>
<cols>1</cols>
<rows>0</rows>
<vgap>0</vgap>
<hgap>10</hgap>
<growablecols>0</growablecols>
<growablerows>0</growablerows>
<growablerows>1</growablerows>
</object>
</object>
<label>Page 1</label>
</object>
<object class="notebookpage">
<object_ref ref="page1"/>
<label>Page 1 copy</label>
</object>
<object class="notebookpage">
<object class="wxPanel" name="page2">
<object class="wxFlexGridSizer">
<object class="sizeritem">
<object class="wxTextCtrl" name="description_text">
<value>ID ranges are a way to simplify the management of several similar controls, especially their event-handling.\nAn ID range is declared by putting something like this into the XRC file:\n &lt;ids-range name=&quot;check&quot; size=&quot;3&quot; start=&quot;10000&quot; /&gt;\n'size' and 'start' being optional.\n\nIf you then give an item the name 'check[2]', it will be allocated that ID in the range.\n\nBy default the IDs in a range are negative, being assigned by wxWindow::NewControlId. If you wish, you can specify the start of the range; if so, the IDs *must* be positive (and it's your responsibility to avoid clashes, so start above wxID__HIGHEST).</value>
<style>wxTE_MULTILINE|wxTE_READONLY</style>
</object>
<option>1</option>
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<object class="spacer">
<option>1</option>
<flag>wxLEFT</flag>
<border>100</border>
</object>
<object class="sizeritem">
<object class="wxBoxSizer">
<object class="sizeritem">
<object class="wxStaticText">
<label>Uncheck to disable a row</label>
</object>
</object>
<object class="sizeritem">
<object_ref ref="checkboxes"/>
<flag>wxALIGN_CENTRE</flag>
</object>
<orient>wxVERTICAL</orient>
</object>
<flag>wxALIGN_CENTRE_VERTICAL</flag>
</object>
<orient>wxHORIZONTAL</orient>
<object class="spacer">
<size>50,-1</size>
</object>
<object class="sizeritem">
<object class="wxStaticBoxSizer">
<object class="sizeritem">
<object class="wxGridSizer">
<object class="sizeritem">
<object class="wxStaticBitmap" name="first_row[0]">
<bitmap>update.gif</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="first_row[1]">
<bitmap>basicdlg.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="first_row[2]">
<bitmap>controls.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="second_row[0]">
<bitmap>custclas.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="second_row[1]">
<bitmap>derivdlg.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="second_row[2]">
<bitmap>platform.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="third_row[0]">
<bitmap>objrefdlg.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="third_row[1]">
<bitmap>uncenter.xpm</bitmap>
</object>
</object>
<object class="sizeritem">
<object class="wxStaticBitmap" name="third_row[2]">
<bitmap>variable.xpm</bitmap>
</object>
</object>
<rows>3</rows>
<vgap>7</vgap>
<hgap>7</hgap>
</object>
<flag>wxALL</flag>
<border>3</border>
</object>
<label>Icons</label>
<orient>wxVERTICAL</orient>
</object>
<flag>wxALIGN_CENTRE_VERTICAL</flag>
</object>
<object class="spacer">
<option>1</option>
<flag>wxLEFT</flag>
<border>100</border>
</object>
</object>
<flag>wxTOP|wxBOTTOM|wxEXPAND</flag>
<border>15</border>
</object>
<object class="sizeritem">
<object_ref ref="bottom_panel"/>
<option>1</option>
<flag>wxEXPAND</flag>
</object>
<cols>1</cols>
<rows>0</rows>
<vgap>0</vgap>
<hgap>10</hgap>
<growablecols>0</growablecols>
<growablerows>0</growablerows>
<growablerows>2</growablerows>
</object>
</object>
<label>Icons</label>
</object>
<object class="notebookpage">
<object class="wxPanel" name="page3">
<object class="wxFlexGridSizer">
<object class="sizeritem">
<object class="wxTextCtrl" name="description_text">
<value>This not very useful calculator demonstrates some features of ID ranges. One range is defined for the number keys, and another for the operators.\n\nIf you look at the .xrc file, you'll see that I wrote:\n &lt;ids-range name=&quot;digits&quot; size=&quot;8&quot;/&gt;\ncreating that range with a size of 8 (I must have forgotten to count my thumbs). The code will still work, though: the actual number of range items is counted when the file is loaded, and the range extended if necessary to accommodate them. However if the size is too big, it isn't truncated.\n\nAn ID range always has the special items defined: &lt;rangename&gt;[start] and &lt;rangename&gt;[end]. So, for the range 'digits', digits[start] == digits[0], and digits[end] == digits[9]. [end] will always refer to the end of the range, even if there's no object with that ID.\n\nThe digits of the calculator are named 'digits[0]' to 'digits[9]'. Adjacent range items are guaranteed to be assigned consecutive IDs, so code such as this will work as expected:\n for (int n=XRCID(&quot;digits[start]&quot;); n &lt; XRCID(&quot;digits[end]&quot;); ++n) { DoFoo(n); }\nor\n int index = event.GetId() - XRCID(&quot;digits[0]&quot;);</value>
<style>wxTE_MULTILINE|wxTE_READONLY</style>
</object>
<option>1</option>
<flag>wxALL|wxEXPAND</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxStaticBoxSizer">
<object class="sizeritem">
<object class="wxGridBagSizer">
<object class="sizeritem">
<object class="wxButton" name="digits[7]">
<label>7</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>0,0</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[8]">
<label>8</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>0,1</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[9]">
<label>9</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>0,2</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="operators[3]">
<label>/</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>0,3</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[4]">
<label>4</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>1,0</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[5]">
<label>5</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>1,1</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[6]">
<label>6</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>1,2</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="operators[2]">
<label>X</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>1,3</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[1]">
<label>1</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>2,0</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[2]">
<label>2</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>2,1</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[3]">
<label>3</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>2,2</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="operators[1]">
<label>-</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>2,3</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="digits[0]">
<label>0</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>3,0</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="operators[4]">
<label>=</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>3,1</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="operators[end]">
<label>Cl</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>3,2</cellpos>
</object>
<object class="sizeritem">
<object class="wxButton" name="operators[0]">
<label>+</label>
<style>wxBU_EXACTFIT</style>
</object>
<flag>wxEXPAND</flag>
<cellpos>3,3</cellpos>
</object>
<object class="sizeritem">
<object class="wxTextCtrl" name="result"/>
<flag>wxEXPAND</flag>
<cellpos>4,0</cellpos>
<cellspan>1,4</cellspan>
</object>
<vgap>5</vgap>
<hgap>5</hgap>
</object>
<flag>wxALL</flag>
<border>5</border>
</object>
<label>Calculator</label>
<orient>wxVERTICAL</orient>
</object>
<flag>wxTOP|wxALIGN_CENTRE_HORIZONTAL</flag>
<border>10</border>
</object>
<object class="sizeritem">
<object_ref ref="bottom_panel"/>
<option>1</option>
<flag>wxEXPAND</flag>
</object>
<cols>1</cols>
<rows>0</rows>
<vgap>0</vgap>
<hgap>10</hgap>
<growablecols>0</growablecols>
<growablerows>0</growablerows>
<growablerows>2</growablerows>
</object>
</object>
<label>Calc</label>
</object>
</object>
<option>1</option>
<flag>wxGROW|wxALIGN_CENTER_VERTICAL|wxALL</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxButton" name="wxID_OK">
<label>OK</label>
<default>1</default>
</object>
<flag>wxTOP|wxBOTTOM|wxALIGN_CENTRE</flag>
<border>20</border>
</object>
<cols>1</cols>
<rows>0</rows>
<vgap>0</vgap>
<hgap>0</hgap>
<growablecols>0</growablecols>
<growablerows>0</growablerows>
</object>
<title>Object References and ID Ranges Example</title>
<centered>1</centered>
<style>wxCAPTION|wxSYSTEM_MENU|wxRESIZE_BORDER</style>
<exstyle>wxDIALOG_EX_CONTEXTHELP</exstyle>
</object>
<object class="wxPanel" name="bottom_panel">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxStaticLine">
<style>wxLI_HORIZONTAL</style>
</object>
<flag>wxTOP|wxEXPAND</flag>
<border>20</border>
</object>
<object class="sizeritem">
<object class="wxStaticText">
<label>Log window:</label>
</object>
<flag>wxTOP</flag>
<border>5</border>
</object>
<object class="sizeritem">
<object class="wxTextCtrl" name="log_text">
<size>-1,100</size>
<style>wxTE_MULTILINE</style>
</object>
<option>1</option>
<flag>wxEXPAND</flag>
</object>
</object>
</object>
<object class="wxPanel" name="checkboxes">
<object class="wxBoxSizer">
<orient>wxVERTICAL</orient>
<object class="sizeritem">
<object class="wxCheckBox" name="check[0]">
<checked>1</checked>
</object>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="check[1]">
<checked>1</checked>
</object>
</object>
<object class="sizeritem">
<object class="wxCheckBox" name="check[2]">
<checked>1</checked>
</object>
</object>
</object>
</object>
<ids-range name="check" size="3" start="10000"/>
<ids-range name="first_row"/>
<ids-range name="second_row"/>
<ids-range name="third_row"/>
<ids-range name="digits" size="8"/>
<ids-range name="operators"/>
</resource>

View File

@@ -0,0 +1,26 @@
/* XPM */
static const char *const objrefdlg_xpm[] = {
"16 16 7 1",
" c None",
". c #EBF70E",
"+ c #000000",
"@ c #808080",
"# c #0000FF",
"$ c #FFFFFF",
"% c #F8A836",
" . ",
"+++.++++++++++++",
"+.@.@.@@@@@@.@@+",
"+@...#######.#@+",
"...@....@@.@.@.+",
"+@...$$$$$$...@+",
"+.$.@.@@@%%%$%..",
"+@$.@@@@@@@%%%@+",
"+@$.$$$$$$%$%$%+",
"+@$$$$$$$$$$%$@+",
"+@$$$$@@@@$$$$@+",
"+@$$$$@@@@$$$$@+",
"+@$$$$$$$$$$$$@+",
"+@@@@@@@@@@@@@@+",
"++++++++++++++++",
" "};

View File

@@ -26,6 +26,11 @@
<longhelp>Disable autocentering of a dialog on its parent</longhelp>
</object>
<object class="separator"/>
<object class="tool" name="obj_ref_tool_or_menuitem">
<bitmap>objrefdlg.xpm</bitmap>
<tooltip>Object references and event ranges example</tooltip>
<longhelp>Use of object references and event ranges</longhelp>
</object>
<object class="tool" name="custom_class_tool_or_menuitem">
<tooltip>Custom Class Example</tooltip>
<bitmap>custclas.xpm</bitmap>

View File

@@ -9,12 +9,14 @@
myframe.cpp
derivdlg.cpp
custclas.cpp
objrefdlg.cpp
</sources>
<headers>
derivdlg.h
xrcdemo.h
myframe.h
custclas.h
objrefdlg.h
</headers>
<wx-lib>xrc</wx-lib>
<wx-lib>html</wx-lib>
@@ -33,6 +35,7 @@
derivdlg.xpm derivdlg.xrc fileopen.gif filesave.gif frame.xrc
fuzzy.gif menu.xrc platform.xpm platform.xrc quotes.gif
resource.xrc toolbar.xrc uncenter.xpm
objref.xrc objrefdlg.xpm
uncenter.xrc update.gif variable.xpm variable.xrc
throbber.gif stop.xpm
</files>

View File

@@ -64,10 +64,11 @@ bool MyApp::OnInit()
return false;
// If there is any of a certain format of image in the xrcs, then first
// load a handler for that image type. This example uses XPMs, but if
// you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
// load a handler for that image type. This example uses XPMs & a gif, but
// if you want PNGs, then add a PNG handler, etc. See wxImage::AddHandler()
// documentation for the types of image handlers available.
wxImage::AddHandler(new wxXPMHandler);
wxImage::AddHandler(new wxGIFHandler);
// Initialize all the XRC handlers. Always required (unless you feel like
// going through and initializing a handler of each control type you will

View File

@@ -264,10 +264,14 @@ SOURCE=.\myframe.cpp
# End Source File
# Begin Source File
SOURCE=.\..\..\samples\sample.rc
SOURCE=.\objrefdlg.cpp
# End Source File
# Begin Source File
SOURCE=.\..\..\samples\sample.rc
# End Source File
# Begin Source File
SOURCE=.\xrcdemo.cpp
# End Source File
# End Group
@@ -288,6 +292,10 @@ SOURCE=.\myframe.h
# End Source File
# Begin Source File
SOURCE=.\objrefdlg.h
# End Source File
# Begin Source File
SOURCE=.\xrcdemo.h
# End Source File
# End Group

View File

@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// Name: xmldemo.cpp
// Name: xmldemo.h
// Purpose: XML resources sample: Main application file
// Author: Robert O'Connor (rob@medicalmnemonics.com), Vaclav Slavik
// RCS-ID: $Id$

View File

@@ -551,6 +551,9 @@
RelativePath=".\myframe.cpp">
</File>
<File
RelativePath=".\objrefdlg.cpp">
</File>
<File
RelativePath=".\xrcdemo.cpp">
</File>
</Filter>
@@ -568,6 +571,9 @@
RelativePath=".\myframe.h">
</File>
<File
RelativePath=".\objrefdlg.h">
</File>
<File
RelativePath=".\xrcdemo.h">
</File>
</Filter>

View File

@@ -816,6 +816,10 @@
>
</File>
<File
RelativePath=".\objrefdlg.cpp"
>
</File>
<File
RelativePath=".\xrcdemo.cpp"
>
</File>
@@ -838,6 +842,10 @@
>
</File>
<File
RelativePath=".\objrefdlg.h"
>
</File>
<File
RelativePath=".\xrcdemo.h"
>
</File>

View File

@@ -788,6 +788,10 @@
>
</File>
<File
RelativePath=".\objrefdlg.cpp"
>
</File>
<File
RelativePath=".\xrcdemo.cpp"
>
</File>
@@ -810,6 +814,10 @@
>
</File>
<File
RelativePath=".\objrefdlg.h"
>
</File>
<File
RelativePath=".\xrcdemo.h"
>
</File>