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 is NOT unique: the last object created is the owner of its name.
Objects are created with the function NewObj().
Some useful functions are provided to create objects faster.
A single call to NewObj() can create a SINGLE object or MANY objects.
The arguments for NewObj() are:
<classname>,<objectname/V>,[stem/V],[freeChild/N]
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:
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 may not 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 busybar
- a horizontal group named RADIOG that contains
- an unnamed label
- a radio named GENDER
- a text object named ADVERT
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")
|
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")
|
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")
|
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, that contains a Contents.
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.0 (20.7.2000)"
app.copyright="Copyright 2000 by Alfie"
app.author="alfie"
app.description="A little RxMUI example"
app.base="EXAMPLE"
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.0 (20.7.2000)"
app.copyright="Copyright 2000 by Alfie"
app.author="alfie"
app.description="A little RxMUI example"
app.base="EXAMPLE"
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.class="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.