home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
useful
/
dev
/
c
/
cmanual
/
intuition
/
menus
/
example4.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-12
|
13KB
|
338 lines
/***********************************************************/
/* */
/* Amiga C Encyclopedia (ACE) V3.0 Amiga C Club (ACC) */
/* ------------------------------- ------------------ */
/* */
/* Book: ACM Intuition Amiga C Club */
/* Chapter: Menus Tulevagen 22 */
/* File: Example4.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 opens a normal window to which we connect a menu strip. */
/* The menu will look like this: */
/* */
/* Status */
/* -------------- */
/* | v Readmode | (ghosted) */
/* | Editmode | */
/* -------------- */
/* */
/* The Readmode item is selected and ghosted, and when the user selects */
/* the Editmode item, it will become disabled (ghosted) while the read- */
/* mode item will be enabled (not ghosted). This means that if the */
/* program is in "readmode", the user should only be able to chose the */
/* "editmode", and v.v. */
/* */
/* The purpose with this program is to show how you can use the OnMenu */
/* and OffMenu functions inorder to make an "user-friendly interface". */
#include <intuition/intuition.h>
struct IntuitionBase *IntuitionBase;
/*************************************************************************/
/* E D I T M O D E I T E M */
/*************************************************************************/
/* The text for the editmode item: */
struct IntuiText my_editmode_text=
{
2, /* FrontPen, black. */
0, /* BackPen, not used since JAM1. */
JAM1, /* DrawMode, do not change the background. */
CHECKWIDTH, /* LeftEdge, CHECKWIDTH amount of pixels out. */
/* This will leave enough space for the check mark. */
1, /* TopEdge, 1 line down. */
NULL, /* TextAttr, default font. */
"Editmode", /* IText, the string. */
NULL /* NextItem, no link to other IntuiText structures. */
};
/* The MenuItem structure for the editmode item: */
struct MenuItem my_editmode_item=
{
NULL, /* NextItem, last item in the list. */
0, /* LeftEdge, 0 pixels out. */
10, /* TopEdge, 10 lines down. */
150, /* Width, 150 pixels wide. */
10, /* Height, 10 lines high. */
ITEMTEXT| /* Flags, render this item with text. */
ITEMENABLED| /* this item will be enabled. */
CHECKIT| /* it is an attribute item. */
HIGHCOMP, /* complement the colours when highlihted. */
0xFFFFFFFD, /* MutualExclude, mutualexclude all items except the */
/* second (this) one. */
(APTR) &my_editmode_text, /* ItemFill, pointer to the text. */
NULL, /* SelectFill, nothing since we complement the col. */
0, /* Command, not accessable from the keyboard. */
NULL, /* SubItem, ignored by Intuition. */
MENUNULL, /* NextSelect, no items selected. */
};
/*************************************************************************/
/* R E A D M O D E I T E M */
/*************************************************************************/
/* The text for the readmode item: */
struct IntuiText my_readmode_text=
{
2, /* FrontPen, black. */
0, /* BackPen, not used since JAM1. */
JAM1, /* DrawMode, do not change the background. */
CHECKWIDTH, /* LeftEdge, CHECKWIDTH amount of pixels out. */
/* This will leave enough space for the check mark. */
1, /* TopEdge, 1 line down. */
NULL, /* TextAttr, default font. */
"Readmode", /* IText, the string. */
NULL /* NextItem, no link to other IntuiText structures. */
};
/* The MenuItem structure for the readmode item: */
struct MenuItem my_readmode_item=
{
&my_editmode_item, /* NextItem, pointer to the second (edit) item. */
0, /* LeftEdge, 0 pixels out. */
0, /* TopEdge, 0 lines down. */
150, /* Width, 150 pixels wide. */
10, /* Height, 10 lines high. */
ITEMTEXT| /* Flags, render this item with text. */
/* this item will be disabled. */
CHECKIT| /* it is an attribute item. */
CHECKED| /* this item is initially selected. */
HIGHCOMP, /* complement the colours when highlihted. */
0xFFFFFFFE, /* MutualExclude, mutualexclude all items except the */
/* first (this) one. */
(APTR) &my_readmode_text, /* ItemFill, pointer to the text. */
NULL, /* SelectFill, nothing since we complement the col. */
0, /* Command, not accessable from the keyboard. */
NULL, /* SubItem, ignored by Intuition. */
MENUNULL, /* NextSelect, no items selected. */
};
/*************************************************************************/
/* M E N U */
/*************************************************************************/
/* The Menu structure for the first (and only) menu: */
struct Menu my_menu=
{
NULL, /* NextMenu, no more menu structures. */
0, /* LeftEdge, left corner. */
0, /* TopEdge, for the moment ignored by Intuition. */
50, /* Width, 50 pixels wide. */
0, /* Height, for the moment ignored by Intuition. */
MENUENABLED, /* Flags, this menu will be enabled. */
"Status", /* MenuName, the string. */
&my_readmode_item /* FirstItem, pointer to the first item in the list. */
};
/* Declare a pointer to a Window structure: */
struct Window *my_window;
/* Declare and initialize your NewWindow structure: */
struct NewWindow my_new_window=
{
50, /* LeftEdge x position of the window. */
25, /* TopEdge y positio of the window. */
250, /* Width 250 pixels wide. */
100, /* Height 100 lines high. */
0, /* DetailPen Text should be drawn with colour reg. 0 */
1, /* BlockPen Blocks should be drawn with colour reg. 1 */
CLOSEWINDOW| /* IDCMPFlags The window will give us a message if the */
/* user has selected the Close window gad. */
MENUPICK,
SMART_REFRESH| /* Flags Intuition should refresh the window. */
WINDOWCLOSE| /* Close Gadget. */
WINDOWDRAG| /* Drag gadget. */
WINDOWDEPTH| /* Depth arrange Gadgets. */
WINDOWSIZING| /* Sizing Gadget. */
ACTIVATE, /* The window should be Active when opened. */
NULL, /* FirstGadget No Custom gadgets. */
NULL, /* CheckMark Use Intuitio