2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of...

13
2nd Rotor Workshop 2003 1 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria, Canada http://www.cs.up.ac.za/rotor

Transcript of 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of...

Page 1: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 1

Views – an XML-based independent GUI system

Judith BishopUniversity of Pretoria, South Africa

Nigel HorspoolUniversity of Victoria, Canada

http://www.cs.up.ac.za/rotor

Page 2: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 2

Motivation

Forward looking– Move to platform independent GUI systems– Integration of XML into languages (cf XEN)

Technical– Rotor does not have a GUI capability– Interesting challenges in Reflection, RegEx etc

Educational– Dissatisfaction with method-oriented or drag and drop GUIs– Separation of concerns

Page 3: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 3

The reality of a single cross-language, cross-platform GUI interface programming model is in sight, based on an XML description language supported by fast native

runtimes. [Russel Jones, DevX, Nov 2002]

Supporting many GUIs isn't just a simple process of including one set of libraries or another; it's often a frustrating and error-prone exercise in writing GUI-

specific code. [Russel Jones, DevX, Aug 2003]

Where GUIs are going

Page 4: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 4

VS.NET

Common Language Runtime

System

System.Data(ADO.NET)

System.Xml

System.Drawing

System.Web(ASP.NET)

System.WinForms

SDK Tools

Rotor CLI Implementation

C#

JScript

Platform Abstraction

System.WinForms

Jim Miller
Make the next three slides fade transition so it's easy to see how they differ?
Page 5: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 5

GUI building today

GUI BuilderGUI Builder

Add ListenersAdd Listeners

Handlers

widget rendering in the OS

widget rendering in the OS

Visual Studio

C#

Windowswidget calls in a language

Application

Page 6: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 6

A GUI using XML

Application

Handlers

widget rendering in the OS

widget rendering in the OS

Control Engine

Add ListenersAdd Listeners

GUI

XML

Spec

GUI

XML

Spec

Page 7: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 7

Example in ViewsViews.Form f = new Views.Form(@"<Form> <vertical> <horizontal> <Button Name=Show/> <Button Name=Hide/> </horizontal> <PictureBox Name=pic Image='Jacarandas.jpg' Height=175/> </vertical></Form>" );

string c;for (;;) { c = f.GetControl(); if (c==null) break; PictureBox pb = f["pic"]; switch (c) { case ”Show" : pb.Show(); break; } case ”Hide" : pb.Hide(); break; } }}

No pixel positioning

No generated code

Separation of concerns

XML C#

Page 8: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 8

The Views Notationform: <form> controlGroup </form>controlGroup: <vertical> controlList </vertical>

| <horizontal> controlList </horizontal>controlList: { control }

textItemList: { <item> text </item> }control: controlGroup

| <Button/> | <CheckBox/>| <CheckedListBox> textItemList </CheckedListBox>| <DomainUpDown> textItemList </DomainUpDown>| <GroupBox> radioButtonList </GroupBox>| <Label/> | <ListBox/>| <OpenFileDialog/> | <SaveFileDialog/>| <PictureBox/> | <TextBox/>| <ProgressBar/> | <TrackBar/>

radioButtonList: { <RadioButton/> }

Page 9: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 9

The Eight Handler methodsForm(string spec,params)

The constructor.

void CloseGUI( )

Terminates the execution thread

string GetControl( )

Waits for the user to perform an action

string GetText(string name)

Returns the value of the Text attribute

int GetValue(string name)

Returns the Value attribute from TrackBar, ProgressBar and CheckBox

int GetValue(string name, int index) Returns the status of CheckBox at position index

void PutText(string name, string s)Displays the string in a TextBox or ListBox control.

void PutValue(string name, int v)Sets an integer value associated with a ProgressBar or CheckBox

Essentially five kinds of methods:

construct

close

getControl

get

put

PLUS … direct access

Page 10: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 10

Views1 implementation

RegEx API would be nice for normalising XML– If REs fail to match, hard to create a use friendly error message– did not use the RE package.

XML API produces poor error messages when reading XML– implemented our own lexical analyzer for the XML specifications– preprocess the user’s XML then use the XML package,

Views inverts the interaction logic of controls

– normally events cause invocation of handling routines asynchronously

– our simple interface has the user invoke Views to wait for an event to happen ...

s = form.GetControl();

switch(s) { ...

case "Push Me":

Page 11: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 11

Views2 implementation

Views2 is a general-purpose tool for creating sophisticated graph structures whose nodes are arbitrary class instances and where the structure layout is defined by a simple XML notation

Correspondence can be made to work with reflection:Views2.Create( "<TagName A1=V1 A2=V2 A3=V2 .. />" )

so we can introduce new tags without preprogramming Views for all controls

Views2 can handle asynchronous events<Button Name="Show" Click="ButtonClick"/>

c.f. show.Click += new EventHandler(ActionPerformed);

Page 12: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 12

Future Work

Completing Views2 and writing it up

Completing the TCL/Tk version and looking at alternative GUI tools

Completing a drag and drop stand-alone tool to emit Views XML

Further investigating the pedagogy

Thinking of asking MS to make Regex available in all operating systems – e.g. “PDA .NET environment we've seen doesn'tinclude the regexp

library, threading, reflection or a full version of collections.”

Long term – XML checking in the language

Page 13: 2nd Rotor Workshop 20031 Views – an XML-based independent GUI system Judith Bishop University of Pretoria, South Africa Nigel Horspool University of Victoria,

2nd Rotor Workshop 2003 13

References on www.cs.up.ac.za/rotor

Horspool R N and Bishop J M, Views - and independent GUI development tool for Rotor, 1st Rotor Workshop, Cambridge July 2002.

Bishop J M and Horspool R N, Views - a Vendor Independent Extensible Windowing System, presented at IFIP WG2.4 meeting, Dagstuhl, Germany, November 2002

Bishop J M, Horspool R N and Worrall B G, Experience with integrating Java with C# and .NET, JavaGrande, Seattle, November 2002, and Concurrency and Computation - Practice and Experience, to be published, January 2004

Bishop J M, Tutorial at RISE, University of Linkoping, Sweden, December 2002

Bishop J M and Horspool R N, Views report to Microsoft, January 2003

Bishop J M and Horspool R N, C# - the modular language for the 2000s. Tutorial at JMLC, Klagenfurt, August 2003

Bishop J M and Horspool R N, C# Concisely, Addison Wesley, appear October 2003.

Bishop J M and Horspool, Towards principles of GUI programming using Views, paper submitted to SIGCSE 2004.