Object creation |
Any RxMUI element you create is an object.
An object is an instance of a class.
Every class defines the attributes and the methods of its objects.
Classes are:
An object is referred by a name.
The name of an object is a valid ARexx symbol <64 chars.
The name is NOT unique: the last object created is the owner of its name.
Objects are created with the function NewObj().
A call to NewObj() can create a SINGLE object or MANY objects.
The arguments for NewObj() are:
<class/V>,<name/O>,[stem/V],[freeChild/N]
Some useful functions are provided to create objects faster.
This lines creates a text object named status (a status line):
status.Frame="Text" status.BackGroud="TextBack" status.PreParse="1B63"x status.Contents="I am ready" res=NewObj("Text","status") |
This lines creates a group object named g containing a text object named status:
g.0="status" status.Class="Text" status.Frame="Text" status.BackGroud="TextBack" status.PreParse="1B63"x status.Contents="I am ready" res=NewObj("group","g") |
Because of a text object that acts like a status line can be created using the function text(), you can do the same thing with the lines:
g.0=text("status","I am ready") res=NewObj("group","g") |
A very cute function, that does not create any object, but it is just used for style reason is child(), so it's the same to do:
child("G",text("status","I am ready")) res=NewObj("group","g") |
If you want to center horizontally status , then you can do something like:
g.Horiz=1 g.0=HSpace() g.1="status" status.Class="Text" status.Frame="Text" status.BackGroud="TextBack" status.PreParse="1B63"x status.Contents="I am ready" g.2=HSpace() res=NewObj("group","g") |
You created a horizontal group named G with 3 children:
The same thing may be done with:
oname=MakeObj("g","HCenter",text("status","I am ready")) |
You may use child() XOR dotted enumeration: you CANNOT use both in the same definition.
It means it is not legal to do something like
child("G",text("status","I am ready")) g.1=label("Hello World!") |
There are classes that may have children and classes that cannot have children:
g.Columns=2 g.0=label("_C") g.1=CheckMark("C",0,"c") g.2=label("C") g.3=CheckMark("C++",0) g.0=label("_ARexx") g.1=CheckMark("ARexx",0,"a") g.0=label("_E") g.1=CheckMark("E",0,"e") res=NewObj("group","g") |
Children may be add to a group via the Add() function.
When you create an object, you must:
As you can see, objects definition can be nested.
Read carefully the following examples lines. They create all the same objects:
- a vertical framed group named g that contains - an unnamed Busy bar - a horizontal group named radiog that contains - an unnamed label - a radio named gender - a text object named advert
1. Four NewObj() calls
gender.Horiz=1 gender.ControlChar="g" gender.Entries="Male|Female" res=NewObj("Radio","gender") radiog.Horiz=1 radiog.0=label("_Gender") radiog.1="gender" res=NewObj("group","radiog") advert.Contents=ParseText("%bNote:%n Read carefully the conditions") res=NewObj("text","advert") g.Frame="group" g.0=MakeObj(,"Busy") g.1="radiog" g.2="advert" res=NewObj("group","g") |
2. Three NewObj() calls
radiog.Horiz=1 radiog.0=label("_Gender") radiog.1="gender" gender.Class="radio" gender.Horiz=1 gender.ControlChar="g" gender.Entries="Male|Female" res=NewObj("group","radiog") advert.Contents=ParseText("%bNote:%n Read carefully the conditions") res=NewObj("text","advert") g.Frame="group" g.0=MakeObj(,"Busy") g.1="radiog" g.2="advert" res=NewObj("group","g") |
3. One NewObj() call
g.Frame="group" g.0=MakeObj(,"Busy") g.1="radiog" radiog.Class="group" radiog.Horiz=1 radiog.0=label("_Gender") radiog.1="gender" gender.Class="radio" gender.Horiz=1 gender.ControlChar="g" gender.Entries="Male|Female" g.2="advert" advert.Class="text" advert.Contents=ParseText("%bNote:%n Read carefully the conditions") res=NewObj("group","g") |
4. One NewObj() call with child()
g.Frame="group" call child("g",MakeObj(,"Busy")) call child("g","radiog","group") radiog.Horiz=1 radiog.0=label("_Gender") radiog.1="gender" gender.Class="radio" gender.Horiz=1 gender.ControlChar="g" gender.Entries="Male|Female" call child("g","advert","text") advert.Contents=ParseText("%bNote:%n Read carefully the conditions") res=NewObj("group","g") |
Your final goal is to create, at least, an Application object, that contains a SubWindow object, with its Contents defined.
The following lines create:
- an Application object named app that contains - a Window object named mwin that contains - a vertical group named mgroup than contains - a 2-columned group named g0 that contains - an unnamed label - a String object named name - an unnamed label - a String object named phone - a horizontal group named g1 that contains - a button named ok - a button named cancel
app.Title="Example" app.Version="$VER: Example 1.1 (23.9.2001)" app.Copyright="Copyright 2000, 2001 by Alfonso Ranieri" app.Author="Alfonso Ranieri" app.Description="A little RxMUI example" app.Base="RXMUIEXAMPLE" app.SubWindow="mwin" mwin.ID="MAIN" mwin.Title="A little RxMUI example" mwin.Contents="mgroup" mgroup.0="g0" g0.Class="group" g0.Frame="group" g0.Columns=2 g0.0=label("_Name"); g0.1=string("name","n") g0.2=label("_Phone"); g0.2=string("phone","p") mgroup.1="g1" g1.Class="group" g1.0=button("ok","_OK") g1.1=button("cancel","_Cancel") res=NewObj("Application","app") |
It is the same to do:
app.Title="Example" app.Version="$VER: Example 1.1 (23.9.2001)" app.Copyright="Copyright 2000, 2001 by Alfonso Ranieri" app.Author="Alfonso Ranieri" app.Description="A little RxMUI example" app.Base="RXMUIEXAMPLE" app.SubWindow="mwin" mwin.ID="MAIN" mwin.Title="A little RxMUI example" mwin.Contents="mgroup" call child("mgroup","g0","Group") g0.Frame="group" g0.Columns=2 g0.0=label("_Name"); g0.1=string("Name","n") g0.2=label("_Phone"); g0.2=string("Phone","p") call child("mgroup","g1","Group") g1.0=button("ok","_OK") g1.1=button("cancel","_Cancel") res=NewObj("Application","app") |
And so on...
NewObj() returns 0 on success, an integer>0 on failure.
If an object can't be created for any reason, all the sub-created objects are disposed.
If you are confused...Experiencing is always the best way to learn.