home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
bgui-1.1a.lha
/
BGUI
/
demos
/
cxdemo.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-03
|
15KB
|
259 lines
;/* Execute me to compile with DICE V3.0.
dcc cxdemo.c -proto -mi -ms -mRR -lbgui
quit
*/
/*
** $RCSfile: cxdemo.c,v $
** Description: Small BGUI commodity class demonstration.
** Copyright: (C) Copyright 1994 Jaba Development.
** (C) Copyright 1994 Jan van den Baard.
** All Rights Reserved.
**
** $Author: jaba $
** $Revision: 1.2 $
** $Date: 1994/08/03 11:19:36 $
**/
#include <exec/types.h>
#include <libraries/gadtools.h>
#include <dos/dos.h>
#include <libraries/bgui.h>
#include <libraries/bgui_macros.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/bgui.h>
#include <stdio.h>
/*
** Library base pointer.
**/
struct Library *BGUIBase = NULL;
/*
** Key ID.
**/
#define CX_F1_PRESSED 1L
/*
** Gadget ID's.
**/
#define ID_HIDE 1L
#define ID_QUIT 2L
/*
** Information text.
**/
UBYTE *InfoTxt = ISEQ_C ISEQ_B ISEQ_HIGHLIGHT
"CxDemo\n\n" ISEQ_TEXT ISEQ_N
"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.";
int main( int argc, char *argv[] )
{
Object *CM_Broker, *WN_Window, *GA_Hide, *GA_Quit;
ULONG signal = 0L, winsig = 0L, sigrec, type, id, rc;
BOOL running = TRUE;
/*
** Open the library.
**/
if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
/*
** 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;
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_MasterGroup,
VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
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;
if ( WN_Window ) {
/*
** Add F1 as hotkey.
**/
if ( AddHotkey( CM_Broker, "f1", CX_F1_PRESSED, 0L )) {
/*
** Add gadget keys.
**/
GadgetKey( WN_Window, GA_Hide, "h" );
GadgetKey( WN_Window, GA_Quit, "q" );
/*
** 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.
**/
do {
sigrec = Wait( signal | winsig | SIGBREAKF_CTRL_C );
/*
** Broker signal?
**/
if ( sigrec & signal ) {
/*
** Obtain the messages from the
** broker.
**/
while ( MsgInfo( CM_Broker, &type, &id, NULL ) != CMMI_NOMORE ) {
/*
** Evaluate message.
**/
switch ( type ) {
case CXM_IEVENT:
switch ( id ) {
case CX_F1_PRESSED:
goto openUp;
}
break;
case CXM_COMMAND:
switch ( id ) {
case CXCMD_KILL:
puts( "bye bye" );
running = FALSE;