home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
cmanual-3.0.lha
/
CManual
/
Intuition
/
Requesters
/
Example8.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-12
|
24KB
|
593 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) V3.0 Amiga C Club (ACC) */
/* ------------------------------- ------------------ */
/* */
/* Book: ACM Intuition Amiga C Club */
/* Chapter: Requesters Tulevagen 22 */
/* File: Example8.c 181 41 LIDINGO */
/* Author: Anders Bjerin SWEDEN */
/* Date: 92-05-01 */
/* Version: 1.10 */
/* */
/* Copyright 1992, Anders Bjerin - Amiga C Club (ACC) */
/* */
/* Registered members may use this program freely in their */
/* own commercial/noncommercial programs/articles. */
/* */
/***********************************************************/
/* This program will open a normal window which is connected to the */
/* Workbench Screen. The window will use all System Gadgets, and will */
/* close first when the user has selected the System gadget Close */
/* window. Inside the window we have activated an Application requester */
/* with three connecting gadgets. Two are Boolean gadgets ("OK and */
/* "CANCEL"), and one is an Integer gadget. */
#include <intuition/intuition.h>
struct IntuitionBase *IntuitionBase;
/************************************/
/* THE INTEGER GADGET's STRUCTURES: */
/************************************/
/* The coordinates for the box around the integer gadget: */
SHORT integer_border_points[]=
{
-7, -4, /* Start at position (-7, -4) */
200, -4, /* Draw a line to the right to position (200,-4) */
200, 11, /* Draw a line down to position (200,11) */
-7, 11, /* Draw a line to the left to position (-7,11) */
-7, -4 /* Finish of by drawing a line up to position (-7,-4) */
};
/* The Border structure for the integer gadget: */
struct Border integer_border=
{
0, 0, /* LeftEdge, TopEdge. */
1, /* FrontPen, colour register 1. */
0, /* BackPen, for the moment unused. */
JAM1, /* DrawMode, draw the lines with colour 1. */
5, /* Count, 5 pair of coordinates in the array. */
integer_border_points,/* XY, pointer to the array with the coordinates. */
NULL, /* NextBorder, no other Border structures. */
};
/* The IntuiText structure for the integer gadget: */
struct IntuiText integer_text=
{
1, /* FrontPen, colour register 1. (white) */
0, /* BackPen, not used since JAM1. */
JAM1, /* DrawMode, draw the characters with colour 1, and do not */
/* bother about the background. */
-53, 0, /* LeftEdge, TopEdge. */
NULL, /* ITextFont, use default font. */
"Age: ", /* IText, the text that will be printed. */
NULL, /* NextText, no other IntuiText structures. */
};
UBYTE my_buffer[25]; /* 25 characters including the NULL-sign. */
UBYTE my_undo_buffer[25]; /* Must be at least as big as my_buffer. */
struct StringInfo integer_info=
{
my_buffer, /* Buffer, pointer to a null-terminated string. */
my_undo_buffer, /* UndoBuffer, pointer to a null-terminated string. */
/* (Remember my_buffer is equal to &my_buffer[0]) */
0, /* BufferPos, initial position of the cursor. */
25, /* MaxChars, 25 characters inc. null-sign ('\0'). */
0, /* DispPos, first character in the string should be */
/* first character in the display. */
/* Intuition initializes and maintaines these variables: */
0, /* UndoPos */
0, /* NumChars */
0, /* DispCount */
0, 0, /* CLeft, CTop */
NULL, /* LayerPtr */
NULL, /* LongInt */
NULL, /* AltKeyMap */
};
struct Gadget integer_gadget=
{
NULL, /* NextGadget, no more gadgets in the list. */
68, /* LeftEdge, 68 pixels out. */
26, /* TopEdge, 26 lines down. */
198, /* Width, 198 pixels wide. */
8, /* Height, 8 pixels lines heigh. */
GADGHCOMP, /* Flags, draw the select box in the complement */
/* colours. Note: it actually only the cursor which */
/* will be drawn in the complement colours (yellow). */
/* If you set the flag GADGHNONE the cursor will not be */
/* highlighted, and the user will therefore not be able */
/* to see it. */
GADGIMMEDIATE| /* Activation, our program will recieve a message when */
RELVERIFY| /* the user has selected this gadget, and when the user */
/* has released it. */
LONGINT, /* An Integer gadget. */
STRGADGET| /* GadgetType, a String gadget which is connected to */
REQGADGET, /* a requester. IMPORTANT! Every gadget which is */
/* connectd to a requester must have the REQGADGET flsg */
/* set in the GadgetType field. */
(APTR) &integer_border, /* GadgetRender, a pointer to our Border struc. */
NULL, /* SelectRender, NULL since we do not supply the gadget */
/* with an alternative image. */
&integer_text, /* GadgetText, a pointer to our IntuiText structure. */
NULL, /* MutualExclude, no mutual exclude. */
(APTR) &integer_info, /* SpecialInfo, a pointer to a StringInfo str. */
0, /* GadgetID, no id. */
NULL /* UserData, no user data connected to the gadget. */
};
/*******************************/
/* THE OK GADGET's STRUCTURES: */
/*******************************/
/* The coordinates for the OK box: */
SHORT ok_border_points[]=
{
0, 0, /* Start at position (0,0) */
22, 0, /* Draw a line to the right to position (22,0) */
22, 10, /* Draw a line down to position (22,10) */
0, 10, /* Draw a line to the left to position (0,10) */
0, 0 /* Finish of by drawing a line up to position (0,0) */
};
/* The Border structure: */
struct Border ok_border=
{
0, 0, /* LeftEdge, TopEdge. */
1, /* FrontPen, colour register 1. */
0, /* BackPen, for the moment unused. */
JAM1, /* DrawMode, draw the lines with colour 1. */
5, /* Count, 5 pair of coordinates in the array. */
ok_border_points, /* XY, pointer to the array with the coord. */
NULL, /* NextBorder, no other Border structures are connected. */
};
/* The IntuiText structure: */
struct IntuiText ok_text=
{
1, /* FrontPen, colour register 1. */
0, /* BackPen, not used since JAM1. */
JAM1, /* DrawMode, draw the characters with colour 1, do not */
/* change the background. */
4, 2, /* LeftEdge, TopEdge. */
NULL, /* ITextFont, use default font. */
"OK", /* IText, the text that will be printed. */
NULL, /* NextText, no other IntuiText structures are connected. */
};
struct Gadget ok_gadget=
{
&integer_gadget, /* NextGadget, linked to the Integer gadget. */
14, /* LeftEdge, 14 pixels out. */
47, /* TopEdge, 47 lines down. */
23, /* Width, 23 pixels wide. */
11, /* Height, 11 pixels lines heigh. */
GADGHCOMP, /* Flags, when this gadget is highlighted, the gadget */
/* will be rendered in the complement colours. */
/* (Colour 0 (00) will be changed to colour 3 (11) */
/* (Colour 1 (01) - " - 2 (10) */
/* (Colour 2 (10) - " - 1 (01) */
/* (Colour 3 (11) - " - 0 (00) */
GADGIMMEDIATE| /* Activation, our program will recieve a message when */
RELVERIFY| /* the user has selected this gadget, and when the user */
/* h