Re: New win32lib and XML

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

----- Original Message ----- 
From: "Pete Lomax" <petelomax at blueyonder.co.uk>
To: "EUforum" <EUforum at topica.com>
Subject: New win32lib and XML


> 
> 
> The new win32lib iirc is going to have some major changes to the way
> controls can be specified (so I guess this is mainly aimed at Derek).
> During my trawls on the web, one thing that seems increasingly to be a
> jolly good idea is to store gui layouts in a separate file, and xml is
> probably not the worst choice.
> 
> An example is:
> <?xml version="1.0"?>
> <dialog caption="Dialog Example" top="0" left="0"
>                                  width="320" height="200"
>         style="popup,clipsiblings,caption,sysmenu,modalframe,
>                3dlook,setfont"
>         fontname="Comic Sans MS" fontsize="10">
> <control class="Static" top="29" left="32" width="70"
>          height="11">Static Text Example</control>
> <control class="Edit" top="76" left="32" width="78" height="14"
>          style="not border" id="1000"></control>
> <control class="Picture" top="96" left="32" width="32"
>                          height="32" style="icon"
>          resource-id="128"/>
> <control class="Button" top="179" left="86" width="50"
>                         height="14" id="1">&amp;OK</control>
> <control class="Button" top="179" left="183" width="50"
>                         height="14" id="2">&amp;Cancel</control>
> <control class="ActiveX" top="26" left="130" width="128"
>                          height="118"
>          id="1009" clsid="{6262D3A0-531B-11CF-91F6-C2863C385E30}"/>
> </dialog>
> 
> (from http://www.codeguru.com/advancedui/XMLGUI.html though I really
> hate the idea of use "1", "2", "1000", and "1009" as control id's).
> 
> The major downside is that you can't link handlers directly to
> controls. On the plus side, it divorces the gui alot more from the
> application code, making it much easier to translate to another
> language, remove (make invisible) a field not used by a particular
> client, etc.
> 
> I haven't yet managed to find a common format for such a file (is
> there one for wxWindows?) or a layout editor which stands out, maybe
> Judith's IDE could be hacked?
> 
> Comments, anyone?
> 
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_ex_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}

(but doesn't support activex yet)

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)
   . . . 
  end procedure

  global procedure Click_Cancel(integer self, integer event, sequence parms)
   . . . 
  end procedure

  global procedure Change_1000(integer self, integer event, sequence parms)
   . . . 
  end procedure
  
  . . .

  include w32start.ew
---------------

Am I getting close?
-- 
Derek

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

Search



Quick Links

User menu

Not signed in.

Misc Menu