home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 02 Nov 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>WinMenu2.c<< 29 Jan 1997 13:25:38 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/Ex/WinMenu2 p:pLib/StartCode.o p:/pOS_RKRM/pIntui/WinMenu2.c p:pLib/StdIO.o -l pOSStub -l pOS
-
- /***********************************************************
- pOS programing example - Copyright (C) 1995-97 proDAD
-
- This code was written as an easy to understand example,
- how to program pOS features. It is provided 'as-is',
- without any express or implied warranty.
-
- Permission is hereby granted to use, copy and modify
- this source code for any purpose, without fee, subject
- to the following conditions:
-
- (1) This notice may not be removed or altered from any
- source distribution.
-
- (2) Altered source versions must be plainly marked as
- such, and must not be misrepresented as being
- the original source code.
-
- (3) If only executable code is distributed, then the
- accompanying documentation have to state that
- "this software is based in part on examples of
- the pOS developer packet".
-
- (4) Permission for use of this code is granted only
- if the user accepts full responsibility for any
- undesirable consequences. proDAD accept NO LIABILITY
- for damages of any kind.
-
- ©proDAD
- ***********************************************************/
-
- /*\
- *** Example:
- ***
- \*/
-
-
- #define __COMPUTER_AMIGA 1
- #define NOMYDEBUG
-
- #include "p:pExec/Types.h"
- #include "p:pDOS/ArgTags.h"
- #include "p:pDOS/DosSig.h"
- #include "p:pDOS/DosErrors.h"
- #include "p:pGadget/Gadget.h"
- #include "p:pScreen/ScrTags.h"
- #include "p:pScreen/Window.h"
- #include "p:pScreen/Screen.h"
- #include "p:pIntui/IntuMsg.h"
- #include "p:pIntui/Tags.h"
- #include "p:pIntui/FraClass.h"
- #include "p:pIntui/Menu.h"
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
- #include "p:proto/pIntui2.h"
-
- #ifdef _____ME_____
- #include "grund/inc_string.h"
- #include "grund/inc_stdio.h"
- #else
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <string.h>
- #include <stdio.h>
- #ifdef __cplusplus
- }
- #endif
- #endif
-
-
- const CHAR *HelpText=
- ""
- ;
-
- const CHAR *PrgHeader=
- "";
-
- const CHAR *PrgVerText=
- "$VER: 1.0 ("__DATE2__") (Copyright 1996-97 by proDAD) (Created by Holger Burkarth)";
-
-
- struct pOS_IntuiDevice *gb_IntuiBase;
-
-
- static CHAR *gb_Names[]=
- {
- "env:sysgfx/prodad.anim"
- };
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- UWORD Err=0;
- ULONG Ops[1]={0};
-
- gb_IntuiBase=(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
-
-
- Args=pOS_ReadDosArgs(
- // 0 1
- "NAME/M",
- Ops,sizeof(Ops)/sizeof(ULONG),
-
- ARGTAG_PrgHeaderText, (ULONG)PrgHeader, /* kurze Programm-Beschreibung */
- ARGTAG_HelpText, (ULONG)HelpText, /* Help-Texte */
- ARGTAG_PrgVerText, (ULONG)PrgVerText, /* VER-String */
- TAG_END);
-
- if(Args) {
- struct pOS_Window *Win;
- struct pOS_Gadget *Gad,*TextGad;
- struct pOS_Screen *Scr;
- CHAR** Names=(CHAR**)Ops[0];
- UWORD NumNames=0;
-
- if(Names) for(; Names[NumNames]!=NULL; ++NumNames);
- if(NumNames==0) {
- Names=gb_Names;
- NumNames=1;
- }
-
- if(Scr=pOS_LockPubScreen("Workbench")) {
- struct pOS_MenuList *MenuList;
- static struct pOS_MenuTag gb_Menu[20];
- const struct pOS_DrawInfo *const Dri=Scr->scr_DrawInfo;
- struct pOS_TagItem *TagArray;
- /******
- pOS_TagItem Tags2[]={
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo, // 0
- IOGFXTAG_FileName, (ULONG)Names[], // 1
- TAG_DONE // 2
- };
- pOS_TagItem BTags2[]={
- ICLTAG_RenderClassName, (ULONG)"igfx.class", // 3
- ICLTAG_RenderTags, (ULONG)Tags2, // 4
- TAG_DONE // 5
- };
- ******/
-
- memset(gb_Menu,0,sizeof(gb_Menu));
-
- TagArray=(struct pOS_TagItem*)pOS_AllocVec(sizeof(struct pOS_TagItem)*6*NumNames,MEMF_CLEAR);
- if(TagArray) {
- UWORD i;
- struct pOS_TagItem* Tag;
-
- for(i=0,Tag=TagArray; i<NumNames; ++i, Tag+=6) {
- Tag[0].ti_Tag=ICLTAG_DrawInfo; Tag[0].ti_Data=(ULONG)Scr->scr_DrawInfo;
- Tag[1].ti_Tag=IOGFXTAG_FileName; Tag[1].ti_Data=(ULONG)Names[i];
- Tag[2].ti_Tag=TAG_END;
- Tag[3].ti_Tag=ICLTAG_RenderClassName; Tag[3].ti_Data=(ULONG)"igfx.class";
- Tag[4].ti_Tag=ICLTAG_RenderTags; Tag[4].ti_Data=(ULONG)&Tag[0];
- Tag[5].ti_Tag=TAG_END;
-
- gb_Menu[5+i].mt_Type=MENUTAGTYP_Item;
- gb_Menu[5+i].mt_Tags=&Tag[3];
- }
- }
- else printf("Cannot alloc TagArray\n");
-
- TextGad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GTxtBoxClass],0,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- IOBJTAG_StaticString, (ULONG)"*** Window-Menu-Demo-2 *** \nPress right mouse",
- ICLTAG_AddWidth, 20,
- ICLTAG_AddHeight, 10,
- TAG_DONE);
-
- Gad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
- ICLTAG_AutoDelete, TRUE,
- GRPGADTAG_BorLeft, 10,
- GRPGADTAG_BorTop, 10,
- GRPGADTAG_BorRight, 10,
- GRPGADTAG_BorBottom, 10,
- GRPGADTAG_AddGadget,(ULONG)TextGad,
- TAG_DONE);
-
-
- gb_Menu[0].mt_Type=MENUTAGTYP_Title;
- gb_Menu[0].mt_U.mt_Lable="gTitle";
- gb_Menu[1].mt_Type=MENUTAGTYP_Item;
- gb_Menu[1].mt_U.mt_Lable="Item - 1";
-
- struct pOS_TagItem Tags1[]={
- ICLTAG_Width, 40,
- ICLTAG_Height, 40,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- ICLTAG_FrameType, IFRACLTYP_SysWDepth,
- TAG_DONE
- };
- struct pOS_TagItem BTags1[]={
- ICLTAG_RenderClassName, (ULONG)"iimage.class",
- ICLTAG_RenderTags, (ULONG)Tags1,
- TAG_DONE
- };
- gb_Menu[2].mt_Type=MENUTAGTYP_Item;
- gb_Menu[2].mt_Tags=BTags1;
-
- gb_Menu[3].mt_Type=MENUTAGTYP_Item;
- gb_Menu[3].mt_U.mt_Lable="Item - 2";
-
- gb_Menu[4].mt_Type=MENUTAGTYP_Title;
- gb_Menu[4].mt_U.mt_Lable="GFX";
-
-
- printf("Create Menus ...\n");
- if(MenuList=pOS_CreateMenuTagA(Scr->scr_DrawInfo,gb_Menu,0)) {
- pOS_PreLayoutMenu(MenuList,Scr->scr_DrawInfo);
-
- Win=pOS_OpenWindow(
- SCRTAG_Title, (ULONG)"<-- Close",
- SCRTAG_PubName, (ULONG)"Workbench",
- SCRTAG_Flags, WINFLGF_DepthGadget | WINFLGF_SimpleRefresh |
- WINFLGF_Activate | WINFLGF_CloseGadget | WINFLGF_Dragbar,
- SCRTAG_IDCMP, IDCMP_CloseWindow | IDCMP_MenuPick,
- SCRTAG_AutoSizeGadget, (ULONG)Gad,
- TAG_DONE);
-
- if(Win) {
- struct pOS_IntuiMessage *Msg;
- BOOL Ende=FALSE;
- const UWORD MWidth =Win->win_Width;
- const UWORD MHeight=Win->win_Height;
-
- pOS_SetMenuStrip(Win,MenuList);
-
- while(!Ende) {
- ULONG Sig;
- Sig=pOS_WaitSignal( (1<<Win->win_UserPort->mp_SigBit) | DOSSIGF_CTRL_C);
- if(Sig & DOSSIGF_CTRL_C) Ende=TRUE;
-
- while(Msg=(struct pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
- switch(Msg->im_Class) {
-
- case IDCMP_MenuPick:
- break;
-
- case IDCMP_CloseWindow: Ende=TRUE; break;
- default: if(pOS_SysIMessage(Msg)) Msg=NULL;
- }
- if(Msg) pOS_ReplyMsg(&Msg->im_Message);
- }
- }
- pOS_SetMenuStrip(Win,NULL);
- pOS_CloseWindow(Win);
- }
- else printf("Cannot open window\n");
- pOS_DeleteMenu(MenuList);
- }
- else printf("Error in pOS_CreateMenuTagA\n");
- if(TagArray) pOS_FreeVec(TagArray);
- pOS_UnlockPubScreen(Scr);
- }
- else printf("Cannot lock PubScreen\n");
- pOS_DeleteDosArgs(Args); /* Args freigeben */
- }
- else Err=DOSFAIL_FAIL; /* vollkommen fehlgeschlagen */
-
- pOS_SetShellFail(Err);
-
- pOS_CloseLibrary((struct pOS_Library*)gb_IntuiBase);
- }
-