home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!portal!cup.portal.com!Lee_Robert_Willis
- From: Lee_Robert_Willis@cup.portal.com
- Newsgroups: comp.sys.amiga.programmer
- Subject: BOOPSI and GA_RelBottom, (Help!)
- Message-ID: <69066@cup.portal.com>
- Date: Sat, 7 Nov 92 16:09:05 PDT
- Organization: The Portal System (TM)
- Distribution: world
- Lines: 217
-
- /*
-
- This program attempts (and fails :-( ) to create a BOOPSI "frbuttonclass"
- gadget positioned relative to the bottom of the window (using GA_RelBottom)
-
- It also creates an 'old-style' gadget which is relative to the bottom.
-
- PROBLEMS:
-
- The 'old-style' gadget works fine, but the BOOPSI gadget
- seems to ignore the GA_RelBottom flag and position relative to the
- top. (I create a 16-pixel high gadget, positioned GA_RelBottom -16L,
- and instead of showing up at the base of the window, it shows up
- right at the top (only the bottom-most line shows))
-
- I'm using SAS C 6.0.
-
- (I checked the INCLUDES, and GA_RelBottom is defines as 0x0004, just like
- in the RKMs.)
-
- Lee Willis Lee_Robert_Willis@cup.portal.com
-
- */
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #include <exec/types.h>
- #include <exec/libraries.h>
- #include <intuition/intuition.h>
- #include <intuition/gadgetclass.h>
- #include <intuition/imageclass.h>
- #include <proto/exec.h>
- #include <proto/intuition.h>
-
- #define WINDOW_WIDTH 200L
- #define WINDOW_HEIGHT 100L
-
-
- struct WindowData
- {
- struct Window *window;
- struct DrawInfo *drawinfo;
- struct Image *frame;
- struct Gadget *gadget;
- struct Gadget OldStyle_gadget;
- };
-
-
- void CleanUp_Window( struct WindowData *wd );
-
- struct IntuiText gadgtext = { 1, 0, JAM1, 0,0, NULL, "Old-style", NULL };
-
- BOOL SetUp_Window( struct WindowData *wd )
- {
-
- wd->window = wd->drawinfo = wd->frame = wd->gadget = NULL;
-
-
- wd->window = OpenWindowTags( NULL,
- WA_Left, 0L,
- WA_Top, 0L,
- WA_InnerWidth, WINDOW_WIDTH,
- WA_InnerHeight, WINDOW_HEIGHT,
- WA_AutoAdjust, TRUE,
- WA_Title, "BOOPSI gadget experiment",
- WA_ScreenTitle, "BOOPSI gadget experiment",
-
- /*--- Window border options -----*/
- WA_DragBar, TRUE,
- WA_DepthGadget, TRUE,
- WA_CloseGadget, TRUE,
- WA_Activate, TRUE,
- WA_WBenchWindow, TRUE,
- WA_SimpleRefresh, TRUE,
-
- /*--- What kind of events do we want ----*/
- WA_IDCMP, IDCMP_CLOSEWINDOW
- | IDCMP_REFRESHWINDOW
- | IDCMP_GADGETDOWN
- | IDCMP_GADGETUP
- | IDCMP_IDCMPUPDATE,
-
- TAG_END );
-
- if (wd->window == NULL)
- return FALSE;
-
- wd->drawinfo = GetScreenDrawInfo( wd->window->WScreen );
-
- if ((wd->frame = (struct Image *) NewObject( NULL, "frameiclass", TAG_END ))
- == NULL)
- {
- CleanUp_Window( wd);
- return FALSE;
- }
-
- if ((wd->gadget = NewObject( NULL, "frbuttonclass",
- GA_Left, 16L,
- GA_RelBottom, -16L, /* <-- This *should* put the gadget */
- GA_Width, 64L, /* at window_bottom-16, but it */
- GA_Height, 16L, /* doesn't. Why? */
- GA_Text, "Boopsi",
- GA_DrawInfo, wd->drawinfo,
- GA_Image, wd->frame,
- GA_Immediate, TRUE,
- GA_RelVerify, TRUE,
- GA_Next, &wd->OldStyle_gadget,
- TAG_END )) == NULL)
-
- {
- CleanUp_Window( wd );
- return FALSE;
- }
-
- wd->OldStyle_gadget.NextGadget = NULL;
- wd->OldStyle_gadget.LeftEdge = 72;
- wd->OldStyle_gadget.TopEdge = -16;
- wd->OldStyle_gadget.Width = 64;
- wd->OldStyle_gadget.Height = 16;
- wd->OldStyle_gadget.Flags = GFLG_GADGHCOMP | GFLG_RELBOTTOM;
- wd->OldStyle_gadget.Activation = GACT_RELVERIFY;
- wd->OldStyle_gadget.GadgetType = GTYP_BOOLGADGET;
- wd->OldStyle_gadget.GadgetRender = NULL;
- wd->OldStyle_gadget.SelectRender = NULL;
- wd->OldStyle_gadget.GadgetText = &gadgtext;
- wd->OldStyle_gadget.MutualExclude = 0;
- wd->OldStyle_gadget.SpecialInfo = NULL;
- wd->OldStyle_gadget.GadgetID = 0;
- wd->OldStyle_gadget.UserData = NULL;
-
-
- AddGList( wd->window, wd->gadget, -1, 2, NULL );
- RefreshGList( wd->gadget, wd->window, NULL, 2 );
-
- return TRUE;
- }
-
-
- void CleanUp_Window( struct WindowData *wd )
- {
- int i;
-
- if (wd->window)
- {
- CloseWindow(wd->window);
- wd->window = NULL;
- }
-
- if (wd->gadget != NULL)
- {
- DisposeObject( (APTR) wd->gadget );
- wd->gadget = NULL;
- }
-
- if (wd->frame != NULL)
- {
- DisposeObject( (APTR) wd->frame );
- wd->frame = NULL;
- }
- }
-
-
- void do_window( void )
- {
- struct IntuiMessage *event;
- BOOL done = FALSE;
- struct WindowData wd;
-
-
- if (SetUp_Window( &wd ))
- {
- while (! done)
- {
- event = (struct IntuiMessage*) GetMsg( wd.window->UserPort );
- if (event == NULL)
- {
- WaitPort(wd.window->UserPort);
- continue;
- }
-
- switch( event->Class )
- {
- case IDCMP_CLOSEWINDOW:
- done = TRUE;
- break;
-
- case IDCMP_REFRESHWINDOW:
- BeginRefresh( wd.window );
- EndRefresh( wd.window, TRUE );
- break;
- }
- ReplyMsg( (struct Message*) event );
- }
-
- CleanUp_Window(&wd);
- }
- }
-
-
- struct IntuitionBase *IntuitionBase;
-
- void main( int argc, char **argv )
- {
- if ((IntuitionBase =
- (struct IntuitionBase*) OpenLibrary( "intuition.library", 37 )))
- {
- do_window();
- }
- else
- {
- if (argc)
- printf("Error: You need intuition.library (version 37 or later).\n");
- }
-
- CloseLibrary( (struct Library*) IntuitionBase );
- }
-