home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Amiga Shareware Floppies / ma21.dms / ma21.adf / MUIBuilder / examplessource / e / Click.e next >
Text File  |  1994-01-09  |  3KB  |  115 lines

  1. OPT OSVERSION=37
  2.  
  3. MODULE 'muimaster', 'libraries/mui'
  4. MODULE 'utility/tagitem', 'utility/hooks'
  5. MODULE 'intuition/classes', 'intuition/classusr'
  6.  
  7. CONST MUI_TRUE = 1
  8.  
  9. ENUM ID_BUTTON1 = 1, ID_BUTTON2, ID_BUTTON3
  10.  
  11.  
  12. PROC main()
  13.  
  14.     DEF signal, result_DoMethod, running = TRUE
  15.  
  16.     DEF app, wi_try, tx_label_0, bt_1stbutton, bt_2ndbutton, bt_3rdbutton
  17.  
  18.     DEF stR_TX_label_0 : PTR TO CHAR
  19.  
  20.     stR_TX_label_0 := '\e8\ecClick on buttons'
  21.  
  22.     IF (muimasterbase := OpenLibrary('muimaster.library',0)) = NIL
  23.         CleanUp(100)
  24.     ENDIF
  25.  
  26.     app := ApplicationObject,
  27.         MUIA_Application_Author, 'Eric Totel',
  28.         MUIA_Application_Base, 'CLICK',
  29.         MUIA_Application_Title, 'Click',
  30.         MUIA_Application_Version, '1.0',
  31.         MUIA_Application_Copyright, 'Eric Totel 1994',
  32.         MUIA_Application_Description, 'just a demo !!!',
  33.         SubWindow, wi_try := WindowObject,
  34.             MUIA_Window_Title, 'Click !!!',
  35.             MUIA_HelpNode, 'WI_try',
  36.             WindowContents, GroupObject,
  37.                 Child, tx_label_0 := TextObject,
  38.                     MUIA_Background, 131,
  39.                     MUIA_Text_Contents, stR_TX_label_0,
  40.                     MUIA_Text_SetMax, 0,
  41.                     MUIA_Text_SetMin, 1,
  42.                     MUIA_Frame, 9,
  43.                 End,
  44.                 Child, GroupObject,
  45.                     MUIA_Group_Horiz, MUI_TRUE,
  46.                     MUIA_Group_SameWidth, MUI_TRUE,
  47.                     Child, bt_1stbutton := KeyButton( 'Button 1', "1" ),
  48.                     Child, bt_2ndbutton := KeyButton( 'Button 2', "2" ),
  49.                     Child, bt_3rdbutton := KeyButton( 'Button 3', "3" ),
  50.                 End,
  51.             End,
  52.         End,
  53.     End
  54.  
  55.     /************************/
  56.     /* Buttons Notification */
  57.     /************************/
  58.  
  59.     doMethod( bt_1stbutton, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_BUTTON1 ] )
  60.     doMethod( bt_2ndbutton, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_BUTTON2 ] )
  61.     doMethod( bt_3rdbutton, [ MUIM_Notify, MUIA_Pressed, FALSE, app, 2, MUIM_Application_ReturnID, ID_BUTTON3 ] )
  62.     
  63.     /***********************/
  64.     /* Window closing      */
  65.     /***********************/
  66.  
  67.      doMethod( wi_try, [ MUIM_Notify, MUIA_Window_CloseRequest, MUI_TRUE, app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit ] )
  68.  
  69.     /***********************/
  70.     /* Window Opening      */
  71.     /***********************/
  72.  
  73.     set( wi_try, MUIA_Window_Open , MUI_TRUE )
  74.  
  75.     /* main loop */
  76.  
  77.     WHILE running
  78.         result_DoMethod := doMethod( app, [ MUIM_Application_Input, {signal} ] )
  79.         SELECT result_DoMethod
  80.             CASE ID_BUTTON1
  81.                 set( tx_label_0, MUIA_Text_Contents, '\ec\e8You pressed first button' )
  82.             CASE ID_BUTTON2
  83.                 set( tx_label_0, MUIA_Text_Contents, '\ec\e8You pressed second button' )
  84.             CASE ID_BUTTON3
  85.                 set( tx_label_0, MUIA_Text_Contents, '\ec\e8You pressed third button' )
  86.             CASE MUIV_Application_ReturnID_Quit
  87.                 running := FALSE
  88.         ENDSELECT
  89.         IF signal THEN Wait( signal )
  90.     ENDWHILE
  91.  
  92.     MuI_DisposeObject( app )
  93.  
  94. ENDPROC
  95.  
  96.  
  97. PROC doMethod( obj:PTR TO object, msg:PTR TO msg )
  98.  
  99.     DEF h:PTR TO hook, o:PTR TO object, dispatcher
  100.  
  101.     IF obj
  102.         o := obj-SIZEOF object     /* instance data is to negative offset */
  103.         h := o.class
  104.         dispatcher := h.entry      /* get dispatcher from hook in iclass */
  105.         MOVEA.L h,A0
  106.         MOVEA.L msg,A1
  107.         MOVEA.L obj,A2           /* probably should use CallHookPkt, but the */
  108.         MOVEA.L dispatcher,A3    /*   original code (DoMethodA()) doesn't. */
  109.         JSR (A3)                 /* call classDispatcher() */
  110.         MOVE.L D0,o
  111.         RETURN o
  112.     ENDIF
  113.  
  114. ENDPROC NIL
  115.