RE: New win32lib and XML

new topic     » goto parent     » topic index » view thread      » older message » newer message

> -----Original Message-----
> From: Pete Lomax [mailto:petelomax at blueyonder.co.uk]
> Subject: Re: New win32lib and XML
>
>
>
> On Tue, 6 Jan 2004 09:02:14 +1100, Derek Parnell
> <ddparnell at bigpond.com> wrote:
>
> >I'm already ahead of you. In the next win32lib, it would be
> possible to define a window and its controls in a text file.
> This can then be used at run time to instantiate the actual
> Windows controls. Its syntax is a bit but more compact than
> XML. Your example above would look something like ...
> >
> >  window, caption={Dialog Example} at={0,0} size={320,200}
> >
> flags={new,ws_popup,ws_clipsiblings,ws_caption,ws_sysmenu,ws_e
> x_dlgmodalframe}
> >    font={Comic Sans MS,10}
> >
> >  label,caption={Static Text Example}, at{32,29}, size={70,11}
> >
> >  editbox, name=1000, at={32,76}, size={78,14}
> >
> >  icon, at={32,96}, size={32,32}, picture=xyzzy.ico
> >
> >  button, caption={&OK}, at={86,179}, size={50,14}
> >
> >  button, caption={&Cancel}, at={183,179}, size={50,14}
> >

The example above doesn't show it all. There are lots more features.

> Nice. How about applying a font or other attribute to more than one
> control?

 default, font={Comic Sans MS,10)

Now the default font is this. This can be used to supply different defaults
for most attributes. Exceptions include the 'name' and 'caption' attributes.

> Where's the design? blink

What's one of those? blink

> >Let's say you create these lines in a file called
> 'MyDialog.form', then your app would read ...
> >
> >--------
> >  createForm( "file=MyDialog.form" )
> >
> >  global procedure Activate_Dialog_Example(integer self,
> integer event, sequence parms)
> >   . . .
> >  end procedure
> >
> >  global procedure Click_OK(integer self, integer event,
> sequence parms)
> hmm.
> What if I have several xxxDialog.form files, and several button,
> caption={&OK} ...? Or do you mean that in the absence of a name
> attribute, and/or provided the caption is unique, and/or Click_OK is
> expected to use getParent or similar to figure stuff out?

Each form file specifies a single window and its controls. Your app can call
createForm(...) as many times as it likes to create different windows/dialog
forms. Each control, including the form itself, must have a name and the
name is unique within the application. You can either explictly give a
control a name, or if not provided, win32lib will use the caption text to
form a name. If you don't provide a name= or caption= attribute, win32lib
makes up a name (but this is not very useful). There is a new function,
getNameId(<control name>) that returns the control ID value.

The name is used to format standard routine names for event handlers. A new
routine called StartApp() can be used in your app to supply a call-back
routine_id, that is called when win32lib needs to get a routine_id from your
program. This is a very brief overview as there are lots of options here.

The goal is to allow the coder to get maximum usability with minimum effort
from win32lib. For example, one of the attributes is the 'events=' one. This
allows you to specify which events your control will respond to. However,
most controls have default events already defined so this attribute is only
rarely needed. The minimum a coder needs to do is define global routines
with standard names, and include the "w32start.ew" file at the end of the
source code file.

I must state that all this is in ADDITION to existing ways of defining
controls. And you can mix and match methods as needed. For example, you can
call createForm and still add extra controls to it using create().

> >Am I getting close?
> Very.

I have converted many demos to the new form and found it quite liberating.
The code looks cleaner and changing form layouts are much less troublesome.
Especially when using the relative positioning options.

--
Derek

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu