home *** CD-ROM | disk | FTP | other *** search
- /*
- ** CXDEMO.E
- **
- ** (C) Copyright 1996 Marco Talamelli.
- ** All Rights Reserved.
- **
- ** On 22 May 96: A dead-loop bug corrected by Dominique Dutoit.
- ** On 25 May 96: A big bad bug fixed in libraries/bgui.m so
- ** this example now works.
- **
- ** Updated on 10-Aug-96
- **/
-
- OPT OSVERSION=37
- OPT PREPROCESS
-
- MODULE 'libraries/bgui',
- 'libraries/bguim',
- 'libraries/gadtools',
- 'libraries/commodities',
- 'bgui',
- 'bgui/bgui_image',
- 'bgui/bgui_cx',
- 'dos/dos',
- 'tools/boopsi',
- 'utility/tagitem',
- 'intuition/screens',
- 'intuition/intuition',
- 'intuition/classes',
- 'intuition/classusr',
- 'intuition/gadgetclass'
-
- /*
- ** Key ID.
- **/
- #define CX_F1_PRESSED 1
-
- /*
- ** Gadget ID's.
- **/
- #define ID_HIDE 1
- #define ID_QUIT 2
-
- PROC main()
-
- DEF cm_broker:PTR TO object, wn_window, ga_hide, ga_quit,
- signal = 0, winsig = 0, sigrec, type, id, rc,
- running = TRUE,infotxt:PTR TO CHAR
-
- /*
- ** Information text.
- **/
- infotxt := '\ec\eb\ed8'+
- 'CxDemo\n\n\ed2\en'+
- 'This is a small "do-nothing" example of how\n'+
- 'to use the BGUI commodity class.\n'+
- 'In this example F1 is the Hotkey used to\n'+
- 'signal the broker to open the window.'
-
- /*
- ** Open the library.
- **/
- IF bguibase := OpenLibrary( 'bgui.library', 37 )
-
- /*
- ** Setup a commodity object.
- **/
- cm_broker := CommodityObject,
- COMM_Name, 'CxDemo',
- COMM_Title, 'Simple BGUI broker.',
- COMM_Description, 'Does not do anything usefull.',
- COMM_ShowHide, TRUE,
- EndObject
-
- /*
- ** Object OK?
- **/
- IF cm_broker
- /*
- ** Create a small window.
- **/
- wn_window := WindowObject,
- WINDOW_Title, 'CxDemo',
- WINDOW_RMBTrap, TRUE,
- WINDOW_SizeGadget, FALSE, /* No use in this window. */
- WINDOW_AutoAspect, TRUE,
- WINDOW_AutoKeyLabel, TRUE,
- WINDOW_MasterGroup,
- VGroupObject, HOffset( 6 ), VOffset( 6 ), Spacing( 6 ), GROUP_BackFill, SHINE_RASTER,
- StartMember,
- InfoObject, ButtonFrame,
- FRM_Flags, FRF_RECESSED,
- INFO_TextFormat, infotxt,
- INFO_FixTextWidth, TRUE,
- INFO_MinLines, 6,
- EndObject,
- EndMember,
- StartMember,
- HGroupObject, Spacing( 4 ),
- StartMember, ga_hide := KeyButton( '_Hide', ID_HIDE ), EndMember,
- VarSpace( DEFAULT_WEIGHT ),
- StartMember, ga_quit := KeyButton( '_Quit', ID_QUIT ), EndMember,
- EndObject, FixMinHeight,
- EndMember,
- EndObject,
- EndObject
-
- /*
- ** Window OK?
- **/
- IF wn_window
- /*
- ** Add F1 as hotkey.
- **/
- IF AddHotkey( cm_broker, 'f1', CX_F1_PRESSED, 0 )
- /*
- ** Obtain broker signal mask.
- **/
- GetAttr( COMM_SigMask, cm_broker, {signal} )
- /*
- ** Activate the broker.
- **/
- EnableBroker( cm_broker )
- /*
- ** Open up the window.
- **/
- IF WindowOpen( wn_window )
- /*
- ** Obtain window sigmask.
- **/
- GetAttr( WINDOW_SigMask, wn_window, {winsig} )
- /*
- ** Wait for messages.
- **/
- WHILE running = TRUE
- sigrec := Wait( signal OR winsig OR SIGBREAKF_CTRL_C )
- /*
- ** Broker signal?
- **/
- IF ( sigrec AND signal )
- /*
- ** Obtain the messages from the
- ** broker.
- **/
- WHILE ( MsgInfo( cm_broker, {type}, {id}, NIL ) <> CMMI_NOMORE )
- /*
- ** Evaluate message.
- **/
- SELECT type
-
- CASE CXM_IEVENT
- SELECT id
-
- CASE CX_F1_PRESSED
- IF WindowOpen( wn_window )
- GetAttr( WINDOW_SigMask, wn_window, {winsig} )
- ENDIF
- ENDSELECT
-
- CASE CXM_COMMAND
- SELECT id
-
- CASE CXCMD_KILL
- WriteF( 'bye bye\n' )
- running := FALSE
-
- CASE CXCMD_DISABLE
- WriteF( 'broker disabled\n' )
- DisableBroker( cm_broker )
-
- CASE CXCMD_ENABLE
- WriteF( 'broker enabled\n' )
- EnableBroker( cm_broker )
-
- CASE CXCMD_UNIQUE
- IF WindowOpen( wn_window )
- GetAttr( WINDOW_SigMask, wn_window, {winsig} )
- ENDIF
- CASE CXCMD_APPEAR
- IF WindowOpen( wn_window )
- GetAttr( WINDOW_SigMask, wn_window, {winsig} )
- ENDIF
-
- CASE CXCMD_DISAPPEAR
- WindowClose( wn_window )
- winsig := 0
- ENDSELECT
- ENDSELECT
- ENDWHILE
- ENDIF
-
- /*
- ** Window signal?
- **/
- IF ( sigrec AND winsig )
- WHILE ( wn_window AND (( rc := HandleEvent( wn_window )) <> WMHI_NOMORE ))
- SELECT rc
-
- CASE ID_HIDE
- WindowClose( wn_window )
- winsig := 0
- CASE WMHI_CLOSEWINDOW
- /*
- ** Hide the window.
- **/
- WindowClose( wn_window )
- winsig := 0
-
- CASE ID_QUIT
- /*
- ** The end.
- **/
- running := FALSE
- ENDSELECT
- ENDWHILE
- ENDIF
-
- /*
- ** CTRL+C?
- **/
- IF ( sigrec AND SIGBREAKF_CTRL_C )
- running := FALSE
- ENDIF
- ENDWHILE
- ELSE
- WriteF( 'unable to open the window\n' )
- ENDIF
- ELSE
- WriteF( 'unable to add the hotkey\n' )
- ENDIF
- DisposeObject( wn_window )
- ELSE
- WriteF( 'unable to create a window object\n' )
- ENDIF
- DisposeObject( cm_broker )
- ELSE
- WriteF( 'unable to create a commodity object\n' )
- ENDIF
- CloseLibrary(bguibase)
- ELSE
- WriteF('Could not open the bgui.library\n')
- ENDIF
- ENDPROC
-