RwxWidgets Annotated Examples
We provide some lengthier, annotated examples of doing
some things using RwxWidgets. We try to describe
the thought process about some of the tasks and
the approaches we used.
-
- Drag and Drop XML, HTML,PDF
- The basics of drag and drop and an more involved, dynamic
example in which we determine the suitablility of a drop target
based on the content and not the type of the data being dragged.
This also shows how we can implement a derived C++ class with R
functions as methods.
-
- Menu XML, HTML,PDF
- An example of creating a wxMenuBar with different menus and
and cascading menus within those. This also illustrates how to
handle events on menus and for collections of menu items using a
range of widget ids.
-
- Extended C++ classes with R methods XML, HTML,PDF
- This illustrates how we can create instances of derived C++
classes and implement its methods with R functions. The example uses
the wxDir class and the wxDirTraverser interface in C++ for
working with files and directories.
-
- A basic wxTreeCtrl example XML, HTML,PDF
- This illustrates how to do basic things with the wxTreeCtrl
class and the associated wxTreeItemId objects. We change the
background and foreground colors and and set images on some of
the items.
-
- Displaying an XML document with a wxTreeCtrl widget XML, HTML,PDF
- This displays the nodes of an XML tree in a wxTreeCtrl.
-
- Working with wxImageList XML, HTML,PDF
- This shows how to create images/bitmaps in R using wxWidgets
and managing these in a wxImageList which can be used in widgets
such as wxNotebook, wxTreeCtrl, wxListCtrl, etc.
-
- Adding widgets to a wxDialog XML, HTML,PDF
-
-
- Building a wxDialog from scratch. XML, HTML,PDF
-
-
- Hiding/Showing widgets within a wxSizer XML, HTML,PDF
-
We write these documents using an XML format that allows us to combine
the annotation with the code and read them in various formats. We use
the Docbook format for marking up the text and inserting the code and
use XML and XSL to process the document in R and externally to work
with the code and create documents.
We have added our own XML elements and use the namespaces
http://www.r-project.org and http://www.omegahat.org to identify
these elements.
One can browse these documents directly in a good Web browser
as they have the associated XSL stylesheet referenced within them.
One can also use XSL to convert them to HTML or PDF (via FO)
and indeed one can convert them to LaTeX and then process them
via that tool chain.
And one can read and execute the code in R directly from the
document using the XML
package and the function xmlSource()
available from
xmlInternalSource.R.
You can load this into R using
source(url("http://www.omegahat.org/xmlInternalSource.R"))
and then use it with, e.g.
xmlSource("http://www.omegahat.org/RwxWidgets/ExampleDocuments/menu.xml")
or
xmlSource(""http://www.omegahat.org/RwxWidgets/ExampleDocuments/DragNDrop.xml", xpath = "//r:example[@id='DynamicDnD']")
Duncan Temple Lang
<duncan@wald.ucdavis.edu>
Last modified: Sat Jun 9 16:14:52 PDT 2007