delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/21/05:34:30

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro GUI question
Date: Tue, 15 Jul 1997 21:27:55 +0100
Organization: None
Distribution: world
Message-ID: <kYdKyEAL19yzEwRb@talula.demon.co.uk>
References: <33cab096 DOT 48306491 AT babyblue DOT cs DOT yale DOT edu>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 49
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

mapson writes:
>For a start, here's a little problem I have: I can make a nice little
>d_check_proc box, but I have no idea how to read back the value of the
>box (i.e., checked or not checked). I'm sure it is easy, but I just
>don't know how.

Just examine the flags field in the dialog object. Eg:

    if (dialog[object_number].flags & D_SELECTED)
        printf("Yo!\n");

>Post here, please. And any other tips on the basic philosophy of the
>Allegro GUI approach would be appreciated... it seems very powerful,
>but I must say that I think it is perhaps the least well documented
>portion of Allegro. 

True enough! It's not documented in great detail, but it's really quite
simple once you get your head around it. The trick is to realise that
it's a very lightweight system, and doesn't contain a great deal of
code. The core dialog management routines do very little at all, and
leave all the details up to the individual callback routines. A dialog
is simply a list of objects, each of which has a position on the screen,
a few bits of data that can mean whatever you want them to mean, and a
pointer to a function tha controls the object. The dialog manager keeps
track of whatever operations need to be performed (drawing the object,
telling it when the mouse moves on top of it or away from it, or when it
is clicked, or when a key is pressed while it is selected, etc), and
simply calls the object procedure whenever any of these things happen.
Thats all there is to it! By writing a suitable handler function for
these events, you can make objects that look and behave in absolutely
any way you like, but all that sort of real work is down to you to
implement in your object procedure :-) 

>Making menus work properly has been very
>difficult, for instance- I find myself skipping the do_dialog manager
>altogether and just use do_menu to avoid tangles.

If you have a menu that works with do_menu(), it would be very easy to
use a d_menu_proc object instead. Just place the object wherever you
want the menu to be (0,0 works well for the usual top left positioning),
and set the dp field to point to your MENU structure (the same thing you
would normally pass to do_menu(). The d_menu_proc() routine is very
simple, it just sits there in your dialog and calls do_menu() whenever
the mouse moves over the top of it...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019