home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15520 < prev    next >
Encoding:
Text File  |  1992-11-08  |  6.2 KB  |  228 lines

  1. Path: sparky!uunet!portal!cup.portal.com!Lee_Robert_Willis
  2. From: Lee_Robert_Willis@cup.portal.com
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: BOOPSI and GA_RelBottom, (Help!)
  5. Message-ID: <69066@cup.portal.com>
  6. Date: Sat,  7 Nov 92 16:09:05 PDT
  7. Organization: The Portal System (TM)
  8. Distribution: world
  9. Lines: 217
  10.  
  11. /*
  12.  
  13. This program attempts (and fails :-( ) to create a BOOPSI "frbuttonclass"
  14. gadget positioned relative to the bottom of the window (using GA_RelBottom)
  15.  
  16. It also creates an 'old-style' gadget which is relative to the bottom.
  17.  
  18. PROBLEMS: 
  19.  
  20.    The 'old-style' gadget works fine, but the BOOPSI gadget
  21.    seems to ignore the GA_RelBottom flag and position relative to the
  22.    top.  (I create a 16-pixel high gadget, positioned GA_RelBottom -16L,
  23.    and instead of showing up at the base of the window, it shows up
  24.    right at the top (only the bottom-most line shows))
  25.  
  26. I'm using SAS C 6.0.
  27.  
  28. (I checked the INCLUDES, and GA_RelBottom is defines as 0x0004, just like
  29. in the RKMs.)
  30.  
  31. Lee Willis     Lee_Robert_Willis@cup.portal.com
  32.    
  33. */
  34.  
  35. #include <stdio.h>
  36. #include <stdlib.h>
  37.  
  38. #include <exec/types.h>
  39. #include <exec/libraries.h>
  40. #include <intuition/intuition.h>
  41. #include <intuition/gadgetclass.h>
  42. #include <intuition/imageclass.h>
  43. #include <proto/exec.h>
  44. #include <proto/intuition.h>
  45.  
  46. #define WINDOW_WIDTH      200L
  47. #define WINDOW_HEIGHT     100L
  48.  
  49.  
  50. struct WindowData
  51. {
  52.    struct Window          *window;
  53.    struct DrawInfo        *drawinfo;
  54.    struct Image           *frame;
  55.    struct Gadget          *gadget;
  56.    struct Gadget           OldStyle_gadget;
  57. };
  58.  
  59.  
  60. void CleanUp_Window( struct WindowData *wd );
  61.  
  62. struct IntuiText gadgtext = { 1, 0, JAM1, 0,0, NULL, "Old-style", NULL };
  63.  
  64. BOOL SetUp_Window( struct WindowData *wd )
  65. {   
  66.  
  67.    wd->window = wd->drawinfo = wd->frame = wd->gadget = NULL;   
  68.  
  69.    
  70.    wd->window = OpenWindowTags( NULL,
  71.                WA_Left,          0L,
  72.                WA_Top,           0L,
  73.                WA_InnerWidth,    WINDOW_WIDTH,
  74.                WA_InnerHeight,   WINDOW_HEIGHT,
  75.                WA_AutoAdjust,    TRUE,
  76.                WA_Title,         "BOOPSI gadget experiment",
  77.                WA_ScreenTitle,   "BOOPSI gadget experiment",              
  78.                
  79.                /*--- Window border options -----*/
  80.                WA_DragBar,       TRUE,
  81.                WA_DepthGadget,   TRUE,
  82.                WA_CloseGadget,   TRUE,
  83.                WA_Activate,      TRUE,
  84.                WA_WBenchWindow,  TRUE,
  85.                WA_SimpleRefresh, TRUE,
  86.                
  87.                /*--- What kind of events do we want ----*/
  88.                WA_IDCMP,         IDCMP_CLOSEWINDOW 
  89.                                | IDCMP_REFRESHWINDOW
  90.                                | IDCMP_GADGETDOWN
  91.                                | IDCMP_GADGETUP
  92.                                | IDCMP_IDCMPUPDATE,
  93.                          
  94.                TAG_END );
  95.                   
  96.    if (wd->window == NULL)
  97.       return FALSE;
  98.  
  99.    wd->drawinfo = GetScreenDrawInfo( wd->window->WScreen );
  100.       
  101.    if ((wd->frame = (struct Image *) NewObject( NULL, "frameiclass", TAG_END ))
  102.         == NULL)
  103.    {
  104.       CleanUp_Window( wd);
  105.       return FALSE;
  106.    }
  107.  
  108.    if ((wd->gadget = NewObject( NULL, "frbuttonclass",    
  109.                GA_Left,         16L, 
  110.                GA_RelBottom,   -16L,  /* <-- This *should* put the gadget */
  111.                GA_Width,        64L,  /*     at window_bottom-16, but it  */
  112.                GA_Height,       16L,  /*     doesn't.  Why?               */
  113.                GA_Text,         "Boopsi",                     
  114.                GA_DrawInfo,     wd->drawinfo,    
  115.                GA_Image,        wd->frame,
  116.                GA_Immediate,    TRUE,             
  117.                GA_RelVerify,    TRUE,
  118.                GA_Next,         &wd->OldStyle_gadget,
  119.                TAG_END )) == NULL)      
  120.  
  121.    {
  122.       CleanUp_Window( wd ); 
  123.       return FALSE;
  124.    }
  125.  
  126.    wd->OldStyle_gadget.NextGadget     = NULL;
  127.    wd->OldStyle_gadget.LeftEdge       = 72;
  128.    wd->OldStyle_gadget.TopEdge        = -16;
  129.    wd->OldStyle_gadget.Width          = 64;
  130.    wd->OldStyle_gadget.Height         = 16;
  131.    wd->OldStyle_gadget.Flags          = GFLG_GADGHCOMP | GFLG_RELBOTTOM; 
  132.    wd->OldStyle_gadget.Activation     = GACT_RELVERIFY;
  133.    wd->OldStyle_gadget.GadgetType     = GTYP_BOOLGADGET;
  134.    wd->OldStyle_gadget.GadgetRender   = NULL;
  135.    wd->OldStyle_gadget.SelectRender   = NULL;
  136.    wd->OldStyle_gadget.GadgetText     = &gadgtext;
  137.    wd->OldStyle_gadget.MutualExclude  = 0;
  138.    wd->OldStyle_gadget.SpecialInfo    = NULL;
  139.    wd->OldStyle_gadget.GadgetID       = 0;
  140.    wd->OldStyle_gadget.UserData       = NULL;
  141.  
  142.  
  143.    AddGList( wd->window, wd->gadget, -1, 2, NULL );
  144.    RefreshGList( wd->gadget, wd->window, NULL, 2 );
  145.  
  146.    return TRUE;
  147. }
  148.  
  149.  
  150. void CleanUp_Window( struct WindowData *wd )
  151. {
  152.    int i;
  153.    
  154.    if (wd->window)
  155.    {
  156.       CloseWindow(wd->window);
  157.       wd->window = NULL;
  158.    }
  159.    
  160.    if (wd->gadget != NULL)
  161.    {
  162.       DisposeObject( (APTR) wd->gadget );
  163.       wd->gadget = NULL;
  164.    }
  165.  
  166.    if (wd->frame != NULL)
  167.    {
  168.       DisposeObject( (APTR) wd->frame );
  169.       wd->frame = NULL;
  170.    }
  171. }
  172.  
  173.  
  174. void do_window( void )
  175. {
  176.    struct IntuiMessage    *event;                           
  177.    BOOL                    done = FALSE;     
  178.    struct WindowData       wd;
  179.    
  180.    
  181.    if (SetUp_Window( &wd ))
  182.    {
  183.       while (! done) 
  184.       {
  185.          event = (struct IntuiMessage*) GetMsg( wd.window->UserPort );
  186.          if (event == NULL)
  187.          {
  188.             WaitPort(wd.window->UserPort);
  189.             continue;
  190.          }
  191.  
  192.          switch( event->Class )
  193.          {            
  194.             case IDCMP_CLOSEWINDOW:
  195.                done = TRUE;
  196.                break;
  197.                            
  198.             case IDCMP_REFRESHWINDOW:
  199.                BeginRefresh( wd.window );
  200.                EndRefresh( wd.window, TRUE );
  201.                break;
  202.          }         
  203.          ReplyMsg( (struct Message*) event );                                               
  204.       }
  205.    
  206.       CleanUp_Window(&wd);
  207.    }   
  208. }
  209.  
  210.  
  211. struct IntuitionBase *IntuitionBase;
  212.  
  213. void main( int argc, char **argv )
  214. {
  215.    if ((IntuitionBase = 
  216.          (struct IntuitionBase*) OpenLibrary( "intuition.library", 37 )))
  217.    {
  218.       do_window(); 
  219.    }
  220.    else 
  221.    {
  222.       if (argc) 
  223.          printf("Error:  You need intuition.library (version 37 or later).\n");
  224.    }
  225.    
  226.    CloseLibrary( (struct Library*) IntuitionBase );   
  227. }
  228.