Category : C Source Code
Archive   : HIM100.ZIP
Filename : MENUDEMO.C

 
Output of file : MENUDEMO.C contained in archive : HIM100.ZIP
/***************** Program Source Module ***********************/
#ifdef AUTOPDOC

MODULE: mmtest.c

DESCRIPTION:

This program exercises the following menu manager modules:

pum1.c pop up menu #1 - no mark/unmark capability
pum2.c pop up menu #2 - mark/unmark capability
pul1.c pop up list #1 - no selection capability
mmcolorm.c pop up color selection menu - background or forground

TABLE OF CONTENTS:

#endif
/*
*
* Copyright 1988 Allsoft (tm)
* 100 Calle Playa Del Sol NE
* Albuquerque, NM 87109
*
* ALL RIGHTS RESERVED.
*
* Unauthorized distribution, adaptation or use may be
* subject to civil and criminal penalties.
*
*/
/********** Filled by Polytron Version Control System **********

$Author: jmborde $

$Date: 05 Apr 1988 13:53:12 $

$Revision: 1.0 $

$Log: K:/CROOT/C/FMLIB/MM/VCS/MENUDEMO.C $
*
* Rev 1.0 05 Apr 1988 13:53:12 jmborde
* Initial revision.

****************************************************************/

/*** Include Files ***/

#include "stdio.h"
#include "malloc.h"
#include "km.h"
#include "wn.h"
#include "lm.h"
#include "mm.h"

/*** Typedefs ***/

/*** Constants ***/

#define INULL (int (*)())NULL

/*** Global Vars ***/

/*** Macros ***/


main()
{
int lnum, lnum1, mwin;
int code;
int pumaction();
int i,j;
char buf[80];
int kbhit(), getch();

lminit(malloc,free,0); /* init list manager package */
wninit(0,0,NULL,0,malloc,free); /* init window manager */
kminit(kbhit,getch); /* init keyboard manager */

/***
create main window
***/

mwin = wncreate(0,0,80,20,WNBLACK,WNCYAN,WNBLUE,WNBLACK);
wnttitle(mwin,"[ Menudemo V1.00 04/04/88 ]");
wnprintf(mwin,"\nThis program demonstrates Window and Menu Manager routines");
wnprintf(mwin,"\nthat are part of the Human Interface Manager (HIM) library.");
wnprintf(mwin,"\n");
wnprintf(mwin,"\nThe first menu is one that allows the user to scroll thru items");
wnprintf(mwin,"\nusing PgUp, PgDn, or arrows. Additionally, the first letter of");
wnprintf(mwin,"\na menu item can be pressed to jump directly to that item.");
wnprintf(mwin,"\nWhen the user presses ESC or makes a selection (via ENTER) the");
wnprintf(mwin,"\ncode can be passed to an \"action\" routine or returned to the");
wnprintf(mwin,"\nfunction which called the menu.");
wnprintf(mwin,"\n\nPress any key to test pmmenu() function...");

/***
pmmenu wo/action test
***/

kmgetch();
lnum = lmcreate(NULL,0,0);
for (i=1; i<=26; i++){
sprintf(buf,"%cPick number %d",i+64,i);
lmael(lnum,buf,0,1);
}
for (i=27; i<=50; i++){
sprintf(buf,"Pick number %d",i);
lmael(lnum,buf,0,1);
}
code = pmmenu(lnum,"[ Pmmenu Demo ]","[ Optional Bottom Title ]",2,2,WNBLACK,WNCYAN,WNBLUE,WNRED,3,INULL);
wnprintf(mwin,"\n\nCode returned from pmmenu() is %d",code);
wnprintf(mwin,"\nPress any key...");
kmgetch();
wncls(mwin);

wnprintf(mwin,"\nBy using an Action routine it's possible to nest your menus.");
wnprintf(mwin,"\n\nPress any key to test pmmenu() with action routine...");

/***
pmmenu w/action test
***/

kmgetch();
code = pmmenu(lnum,"[ Pmmenu Demo ]","[ Optional Bottom Title ]",2,2,WNBLACK,WNCYAN,WNBLUE,WNRED,3,pumaction);
wnprintf(mwin,"\n\nCode returned from nested pmmenu() is %d",code);
wnprintf(mwin,"\nPress any key...");
kmgetch();
wncls(mwin);

/***
pmmenumu module test
***/

wnprintf(mwin,"\nThe next menu type, pmmenumu(), allows the list of items to be");
wnprintf(mwin,"\n\"marked\" and \"unmarked\" by the user via a key of your choice.");
wnprintf(mwin,"\nThe \"mark/unmark\" status of the menu items can be set and read");
wnprintf(mwin,"\nthru the List Manager routines.");
wnprintf(mwin,"\n\nPress any key to test pmmenumu() function...");
kmgetch();

lmmarkel(lnum,5); /* mark an item */
code = pmmenumu(lnum,"[ Pmmenumu Demo ]","[ F10 marks/unmarks ]",2,2,
WNBLACK,WNCYAN,WNBLUE,WNRED,WNBLACK,WNYELLOW,KF10,2,INULL);
for (j = 0, i = lmgfirstel(lnum); i > 0; i = lmgnextel(lnum))
if (lmelstat(lnum,i)) /* see how many elements marked */
j++;
wnprintf(mwin,"\nCode returned is %d",code);
wnprintf(mwin,"\nTotal marked items is %d out of %d",j,lmgnumels(lnum));
wnprintf(mwin,"\nPress any key...");
kmgetch();
wncls(mwin);

/***
pmlist module test
***/

wnprintf(mwin,"\nThe pmlist() menu function is used for displaying a list of items");
wnprintf(mwin,"\nthat are not to be changed by the user.");
wnprintf(mwin,"\n\nPress any key to test pmlist() function...");
kmgetch();

lnum1 = lmcreate(NULL,0,0);
for (i=1; i<=25; i++){
sprintf(buf,"%cPick number %d",i+64,i);
lmael(lnum1,buf,0,1);
}
lmael(lnum," ",0,1);
i = pmlist(lnum1,"[ Pmlist Demo ]","",0,0,WNBLUE,WNRED,-1);
lmdestroy(lnum1);
wnprintf(mwin,"\nPress any key...");
kmgetch();
wndestroy(i);
wncls(mwin);

/***
mmcolorm module test
***/

wnprintf(mwin,"\nThe mmcolorm() menu function gives a developer a easy way of obtaining");
wnprintf(mwin,"\ncolor selections from a user.");
wnprintf(mwin,"\n\nThis test will show how to ask for a valid background color with all");
wnprintf(mwin,"\nforeground colors equal to black. The start pick will be cyan.");
wnprintf(mwin,"\nPress a key...");
kmgetch();
code = mmcolorm("[Background Test]","",
0,0,WNCYAN,WNBLACK,0,0,0,INULL);
wnprintf(mwin,"\nValue returned == %d",code);
wnprintf(mwin,"\n\nPress a key...");
kmgetch();
wncls(mwin);

wnprintf(mwin,"\nYou can of course ask for a valid foreground color. This test");
wnprintf(mwin,"\nwill ask for a foreground color while using red as a background.");
wnprintf(mwin,"\nPress a key...");
kmgetch();
code = mmcolorm("[foreground Test]","[ESC to Abort]",
0,0,WNRED,WNLCYAN,0,1,0,INULL);
wnprintf(mwin,"\nValue returned == %d",code);

wnprintf(mwin,"\nPress a key to exit menudemo..");
kmgetch();
wndestroy(-1);
}

pumaction(option,lnum)
/*****************/
int option,lnum;
{
int loclnum,i,j,code;

if (option == -1)
return(0);


loclnum = lmcreate(NULL,0,0);
lmael(loclnum,"Pick number 1",0,1);
lmael(loclnum,"Pick number 2",0,1);
lmael(loclnum,"Pick number 3",0,1);
lmael(loclnum,"Pick number 4",0,1);
lmael(loclnum,"Pick number 5",0,1);
lmael(loclnum,"Pick number 6",0,1);
lmael(loclnum,"Pick number 7",0,1);

code = pmmenu(loclnum,"[ Nested Menu ]","",5,5,WNBLUE,WNCYAN,WNBLUE,WNRED,5,INULL);
lmdestroy(loclnum);
return(code);

}





  3 Responses to “Category : C Source Code
Archive   : HIM100.ZIP
Filename : MENUDEMO.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/