In my grand mental quest to find the best way to have a ProgrammingLanguageNeutralGui, I've been kicking around the idea of a "GUI machine language" (or perhaps CLR for GUI's). It would not be "machine language" like we know it from x86 etc., but rather a tabular list with just 4 columns:
formID, widgetID, attribute, value
Actually an ordering is assumed such that if you were representing it in a table, a sequence-number column of some kind would also be included. Also, perhaps every row should have a sequential number per login session, such that the first command would have a sequence of 1, the 2nd "2", etc. This can serve as a kind of internal verification mechanism, similar to parity-checking. The lists sent to a server would also have a tracking number. The number is somewhat comparable to the byte offset address shown in many assembler-language listings. However, our examples will only have it implied based on the order presented.
Here's an example based on HTML-like pseudo-code.
The translation into "GUI machine code" may resemble:
formID wdgtID attrib value
-----------------------------
f1 form width 600
f1 form title foo
f2 form parent f1 // represents form nesting
f2 form x 400
f2 form y 200
f2 form title inner
f2 tx1 type text
f2 tx1 x 30
f2 tx1 y 200
f2 tx1 content ssn:
f2 tb1 type textbox
f2 tb1 x 80
f2 tb1 width 30
f2 b1 type button
f2 b1 title Go!
f2 b1 onclick @sendThisForm // standard pre-defined event
Although this example shows positional coordinates, the "browser" wouldn't necessary have to use absolution positioning. (Ideally it would offer both nested positioning capabilities and coordinate positioning, but that's another topic). Also, the "list" is the main focus, not the HTML-like pseudo-code. It is merely to serve as a reference example using a more-familiar notation. (Some positions and widths are not shown for brevity. Some default would normally be assumed for such values.)
"System" is a reserved "form" (not shown) for environmental, communication, and house-cleaning chores. "form" under widget-ID simply indicated that we are referencing the form and not a widget. Widgets don't have to be explicitly declared. Mention of their ID alone declares them. However, they are usually not of much use until a "type" is assigned. There is no need to "erase" widgets, just make them hidden if not used. (Although for garbage collection, perhaps some kind of erasure can be added, but that's later-fancy-land stuff.)
Because our "language" is limited to just 4 columns, sometimes "cursors" are used to indicate the point of focus for a given attribute. This is illustrated in the following grid widget example:
formID wdgtID attrib value
-----------------------------
f1 grid1 type grid
f1 grid1 rowPntr 3
f1 grid1 colPntr 7
f1 grid1 content foo
f1 grid1 rowPntr 4
f1 grid1 colPntr 2
f1 grid1 content bar
f1 grid1 focus true
Setting the "pointers" is not the same as setting focus, at least not on the user-side. A focus command is a separate, explicit activity. Think of the row and column pointers as being for an internal pointer, which do not by themselves affect the mouse or keyboard cursor.
A GUI browser could potentially store command lists internally such that clicking a button can perform multiple actions, such as changing text-box values and changing focus. Maybe an internal "label" can be defined for any action, almost like a "jump" or go-to lable:
formID wdgtID attrib value
-----------------------------
system loadmode internal true // turn on "save only" mode to not execute
system flow label myLabel // instruction "marker" label
form1 form focus true
form1 box1 content Hi Mom!
system flow stop // end of "script"
system loadmode internal false // turn off "save only" mode
...
form2 button1 onClick myLabel // run script "myLabel" upon click
In mark-up pseudo-code, this would resemble:
...
...