home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD2.bin
/
bbs
/
dev
/
cmanual-3.0.lha
/
CManual
/
Intuition
/
Requesters
/
Example10.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-12
|
17KB
|
470 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) V3.0 Amiga C Club (ACC) */
/* ------------------------------- ------------------ */
/* */
/* Book: ACM Intuition Amiga C Club */
/* Chapter: Requesters Tulevagen 22 */
/* File: Example10.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 example demonstrates how you use a requester with a */
/* predrawn bitmap. This is very useful when you want */
/* colourful and eye catching requesters. The advantage */
/* with a special bitmap is that if the window which the */
/* requester is tied to is resized, the drawing will not be */
/* destroied. */
/* */
/* The graphics data is stored in a separate file called */
/* "Example10Graphics.c". Both this and the graphical file */
/* should be compiled separately, then linked together. If */
/* you have a SAS (Lattice) C Compiler you would do like */
/* this: */
/* lc Example10.c */
/* lc Example10Graphics.c */
/* blink with Example10.lnk */
/* */
/* This program will NOT try to erase the disk! It is ony a */
/* demonstration how to use a requester. */
#include <intuition/intuition.h>
/* The size of the requester: */
#define WIDTH 310
#define HEIGHT 180
#define DEPTH 4
#define COLOURS 16
struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
/* The graphics for the requester: */
extern UWORD chip YesNoData[];
/* The sixteen colours: (RGB) */
UWORD colour[COLOURS]=
{
0x000, 0xFFF, 0x500, 0x900, 0xE00, 0xE60, 0xFE0, 0x06F,
0x0AF, 0x04C, 0x666, 0x888, 0xBBB, 0x555, 0x028, 0x0CF
};
/* The YesNo image structure: */
struct Image YesNoImage=
{
0, 0, /* LeftEdge, TopEdge */
285, 154, DEPTH, /* Width, Height, Depth */
YesNoData, /* ImageData */
0x0F, 0x00, /* PlanePick, PlaneOnOff */
NULL /* NextImage */
};
/* The BitMap structure: */
struct BitMap my_bitmap;
/* The RastPort: */
struct RastPort my_rast_port;
/* The YES gadget (the left one): */
struct Gadget yes_gadget=
{
NULL, /* NextGadget, no more gadgets in the list. */
44, /* LeftEdge, 44 pixels out. */
108, /* TopEdge, 108 lines down. */
80, /* Width, 80 pixels wide. */
30, /* Height, 30 pixels lines heigh. */
GADGHCOMP, /* Flags, when this gadget is highlighted, the gadget */
/* will be rendered in the complement colours. */
GADGIMMEDIATE| /* Activation, our program will recieve a message when */
RELVERIFY| /* the user has selected this gadget, and when the user */
/* has released it. */
ENDGADGET, /* When the user has selected this gadget, the */
/* requester is satisfied, and is deactivated. */
/* IMPORTANT! At least one gadget per requester */
/* must have the flag ENDGADGET set. If not, the */
/* requester would never be deactivated! */
BOOLGADGET| /* GadgetType, a Boolean 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. */
NULL, /* GadgetRender, no rendering. */
NULL, /* SelectRender, no alternative rendering. */
NULL, /* GadgetText, no text. */
NULL, /* MutualExclude, no mutual exclude. */
NULL, /* SpecialInfo, NULL since this is a Boolean gadget. */
/* (It is not a Proportional/String or Integer gdget) */
0, /* GadgetID, no id. */
NULL /* UserData, no user data connected to the gadget. */
};
/* The NO gadget (the right one): */
struct Gadget no_gadget=
{
&yes_gadget, /* NextGadget, pointer to the yes gadget. */
200, /* LeftEdge, 200 pixels out. */
108, /* TopEdge, 108 lines down. */
75, /* Width, 75 pixels wide. */
30, /* Height, 30 pixels lines heigh. */
GADGHCOMP, /* Flags, when this gadget is highlighted, the gadget */
/* will be rendered in the complement colours. */
GADGIMMEDIATE| /* Activation, our program will recieve a message when */
RELVERIFY, /* the user has selected this gadget, and when the user */
/* has released it. */
BOOLGADGET| /* GadgetType, a Boolean 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. */
NULL, /* GadgetRender, no rendering. */
NULL, /* SelectRender, no alternative rendering. */
NULL, /* GadgetText, no text. */
NULL, /* MutualExclude, no mutual exclude. */
NULL, /* SpecialInfo, NULL since this is a Boolean gadget. */
/* (It is not a Proportional/String or Integer gdget) */
0, /* GadgetID, no id. */
NULL /* UserData, no user data connected to the gadget. */
};
/***********************************************************************/
/* Important notice: */
/* Remember that every gadget which is connected to a requester must */
/* have the flag REQGADGET set in the GadgetType field. Remember also */
/* that at least one gadget per requester must have the ENDGADGET flag */
/* set in the Activation field. */
/***********************************************************************/
/* The request structure: */
struct Requester my_requester=
{
NULL, /* OlderRequester, used by Intuition. */
5, 15, /* LeftEdge, TopEdge, 0 pixels out, 0 lines down. */
WIDTH, HEIGHT, /* Width, Height, 285 pixels wide, 154 lines high. */
0, 0, /* RelLeft, RelTop, Since POINTREL flag is not set, */
/* Intuition ignores these values. */
&no_gadget, /* ReqGadget, pointer to the first gadget. */
NULL, /* ReqBorder, no rendering. */
NULL, /* ReqText, no text. */
PREDRAWN, /* Flags, we use our own predrawn BitMap. */
0, /* BackFill, no backfill. */
NULL, /* ReqLayer, used by Intuition. Set to NULL. */
NULL, /* ReqPad1, used by Intuition. Set to NULL. */
NULL, /* ImageBMap, will later be changed. */
NULL, /* RWindow, used by Intuition. Set to NULL. */
NULL /* ReqPad2, used by Intuition. Set to NULL. */
};
/* A pinter to a Screen structure: */
struct Screen *my_screen;
/* The NewScreen structure: */
struct NewScreen my_new_screen=
{
0, /* LeftEdge Should always be 0. */
0, /* TopEdge Top of the display.*/
320, /* Width We are using a high-resolution screen. */
200, /* Height Non-Interlaced NTSC (American) display. */
DEPTH,