toolbox-programming with oslib

Jonathan Coxhead jonathan at doves.demon.co.uk
Tue Oct 17 19:32:28 BST 2000


On 17 Oct 00, Tony van der Hoff wrote,

 | I can't recall why we decided it was
 | preferable to use the MEMBERS macro instead of defining a standard object
 | header, and using that as part of a structure; something to do with 
offsets
 | or packing maybe? Can you refresh my memory, please?

   Basically, it's just to save having to write ".header" all over the 
place: you can write

      msg.size

instead of

      msg.header.size

   The latter is much clearer (it's the size of the message, not the size 
of the header), and it matches the way you'd do it in an object-oriented 
language like C++ (i e, a Message_DataSend "is a" Wimp_Message [with extra 
members], rather than a "message header" followed by some extra members).

   Since the cases are analogous, it would be good if their implementation 
was also analogous in the way.

 | That's certainly what I had intended to do, and what I think I used in
 | the example for Uwe:
 | 
 |   struct
 |   {
 |     toolbox_RESOURCE_FILE_OBJECT_MEMBERS
 |     colourdbox_object obj;
 |   } colourdbox_template;
 | 
 | The DefMod source would be:
 | 
 |   ColourDbox_Template = .Struct
 |   (
 |     Toolbox_ResourceFileObject,
 |     ColourDbox_Object: obj
 |   );
 | 
 | Both the component structs already exist in OSLib. Is that not what you
 | meant?

   Yes, I think so.

 | There is also a need to declare object action structures, which are
 | specialised wimp events. I intend to do that at the same time; e.g.
 | 
 |    Toolbox_ActionHeader = .Struct
 |    (
 |       .Int: size,
 |       .Int: ref_no,
 |       .Bits: action_no,
 |       .Bits: flags
 |    ); 
 | 
 |   Menu_ActionAboutToBeShownBlock = .Struct
 |   (
 |     Toolbox_ActionHeader: hdr,
 |     Toolbox_PositionTag: tag,
 |     .Union
 |     (
 |       OS_Coord: top_left,
 |       Menu_Full: full
 |     ): position
 |   );
 | 
 | Any comments?

   I don't see why this is different: a menu action "is a" toolbox action, 
so shouldn't that be done the same way too?

        /|
 o o o (_|/
        /|
       (_/



More information about the oslib-user mailing list