home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
bgui-1.1a.lha
/
BGUI
/
demos
/
popwindow.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-09-23
|
9KB
|
181 lines
;/* Execute me to compile with DICE V3.0
dcc popwindow.c -proto -mi -ms -mRR -lbgui
quit
*/
/*
** $RCSfile: popwindow.c,v $
** Description: Simple demonstration of jumping to another screen.
** Copyright: (C) Copyright 1994 Jaba Development.
** (C) Copyright 1994 Jan van den Baard.
** All Rights Reserved.
**
** $Author: jaba $
** $Revision: 1.2 $
** $Date: 1994/09/23 11:29:18 $
**/
#include <libraries/bgui.h>
#include <libraries/bgui_macros.h>
#include <libraries/gadtools.h>
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <proto/bgui.h>
#include <proto/intuition.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
** Library base pointer.
** NOTE: The intuition.library is opened by DICE
** it's auto-init code.
**/
struct Library *BGUIBase;
/*
** Object ID's.
**/
#define ID_QUIT 1
#define ID_SCREENNAME 2
int main( int argc, char *argv[] )
{
struct Window *window;
Object *WO_Window, *GO_Quit, *GO_Name;
UBYTE name[ 64 ];
ULONG signal = 0, rc, tmp;
BOOL running = TRUE;
/*
** Open the library.
**/
if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
/*
** Create the window object.
**/
WO_Window = WindowObject,
WINDOW_Title, "PopWindow Demo",
WINDOW_ScaleWidth, 20,
WINDOW_SizeGadget, FALSE,
WINDOW_PubScreenName, "Workbench",
WINDOW_MasterGroup,
VGroupObject, HOffset( 4 ), VOffset( 4 ), Spacing( 4 ),
StartMember, GO_Name = String( "Screen Name:", "Workbench", 64, ID_SCREENNAME ), EndMember,
StartMember,
HGroupObject,
VarSpace( 50 ),
StartMember, GO_Quit = KeyButton( "_Quit", ID_QUIT ), EndMember,
VarSpace( 50 ),
EndObject,
EndMember,
EndObject,
EndObject;
/*
** Object created OK?
**/
if ( WO_Window ) {
/*
** Assign a key to the button.
**/
tmp = GadgetKey( WO_Window, GO_Quit, "q" );
/*
** OK?
**/
if ( tmp ) {
/*
** try to open the window.
**/
if ( window = WindowOpen( WO_Window )) {
/*
** Obtain it's wait mask.
**/
GetAttr( WINDOW_SigMask, WO_Window, &signal );
/*
** Event loop...
**/
do {
Wait( signal );
/*
** Handle events.
**/
while (( rc = HandleEvent( WO_Window )) != WMHI_NOMORE ) {
/*
** Evaluate return code.
**/
switch ( rc ) {
case WMHI_CLOSEWINDOW:
case ID_QUIT:
running = FALSE;
break;
case ID_SCREENNAME:
/*
** Obtain screen name.
**/
GetAttr( STRINGA_TextVal, GO_Name, &tmp );
/*
** Save it.
**/
strcpy( name, ( UBYTE * )tmp );
/*
** Close the window.
**/
WindowClose( WO_Window );
/*
** Setup name.
**/
SetAttrs( WO_Window, WINDOW_PubScreenName, name, TAG_END );
/*
** Re-open window.
**/
if ( window = WindowOpen( WO_Window )) {
/*
** Re-set signal mask.
**/
signal = 0L;
GetAttr( WINDOW_SigMask, WO_Window, &signal );
/*
** Show it in the gadget.
**/
SetGadgetAttrs(( struct Gadget * )GO_Name, window, NULL, STRINGA_TextVal, name, TAG_END );
} else {
puts( "Can't re-open the window!" );
goto bye;
}
break;
}
}
} while ( running );
} else
puts ( "Could not open the window" );