home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 02 Jun 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>Win.c<< 29 Jan 1997 13:24:15 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/Ex/Win p:pLib/StartCode.o p:/pOS_RKRM/pIntui/Win.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:pGFX/Text.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/IType.h"
- #include "p:proto/pLibExt.h"
- #include "p:proto/pExec2.h"
- #include "p:proto/pDOS2.h"
- #include "p:proto/pIntui2.h"
- #include "p:proto/pGFX2.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;
- struct pOS_GfxBase *gb_GfxBase;
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- struct pOS_DosArgs* Args;
- UWORD Err=0; // 0 1 2 3 4 5
- ULONG Ops[6]={(ULONG)"findgad.library/findgad.class",0,0,1,(ULONG)"courier.font",15};
-
- gb_IntuiBase=(struct pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
- gb_GfxBase=(struct pOS_GfxBase*)pOS_OpenLibrary("pgraphics.library",0);
-
- Args=pOS_ReadDosArgs(
- // 0 1 2 3 4 5
- "CLASSNAME, HELPFILE/K, HELPID/K, DISTEST/S FONT, FONTSIZE=FS/N",
- 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_TextAttr TA;
- struct pOS_TextFont *TF;
- struct pOS_Window *Win;
- struct pOS_Gadget *Gad,*FindGad;
- struct pOS_Screen *Scr;
- struct pOS_Gadget *DisTestGad=NULL;
-
- TA.ta_Name =(CHAR*)Ops[4];
- TA.ta_YSize=*((ULONG*)Ops[5]);
- TA.ta_Style=0;
- TA.ta_Flags=FNTFLGF_Proportional; TA.ta_Tags=NULL;
-
- TF=pOS_OpenFont(&TA);
- if(!TF) {
- printf("Cannot open font %s size %ld\n",TA.ta_Name,TA.ta_YSize);
- }
-
- if(Scr=pOS_LockPubScreen("Workbench")) {
- const struct pOS_DrawInfo *const Dri=Scr->scr_DrawInfo;
-
- FindGad=(struct pOS_Gadget*)pOS_NewIObject(NULL,(CHAR*)Ops[0],0,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- ICLTAG_Gwk, 1,
- TAG_DONE);
-
- if(FindGad) {
- Gad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GGroupClass],0,
- ICLTAG_AutoDelete, TRUE,
- GRPGADTAG_BorLeft, 4,
- GRPGADTAG_BorTop, 4,
- GRPGADTAG_BorRight, 4,
- GRPGADTAG_BorBottom, 4,
- GRPGADTAG_AddGadget,(ULONG)FindGad,
- TAG_DONE);
-
- if(Ops[3]) {
- pOS_SetGadgetAttrs(NULL,Gad,
- GRPGADTAG_Horiz, TRUE,
- GRPGADTAG_SpaceHoriz, 10,
- GRPGADTAG_AddGadget, (ULONG)
- pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GBarClass],0,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- TAG_DONE),
- TAG_DONE);
- }
-
-
- if(Ops[3]) {
- static const CHAR *TxtArray[]={
- "_Enable",
- "_Disable",
- NULL
- };
-
- DisTestGad=(struct pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GMXClass],0,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- MXGADTAG_StrLabels, (ULONG)TxtArray,
- ICLTAG_FixSize, TRUE,
- TAG_DONE);
-
- pOS_SetGadgetAttrs(NULL,Gad,
- GRPGADTAG_AddGadget, (ULONG)DisTestGad,
- TAG_DONE);
- }
-
- Win=pOS_OpenWindow(
- SCRTAG_HelpFile, Ops[1],
- SCRTAG_HelpID, Ops[2],
- SCRTAG_Title, (ULONG)Ops[0],
- SCRTAG_PubName, (ULONG)"Workbench",
- SCRTAG_TextFont, (ULONG)TF,
- SCRTAG_Flags, WINFLGF_DepthGadget | WINFLGF_SimpleRefresh |
- WINFLGF_SizeGadget | WINFLGF_Activate |
- WINFLGF_CloseGadget | WINFLGF_Dragbar |
- WINFLGF_SizeBBottom,
- SCRTAG_IDCMP, IDCMP_CloseWindow | IDCMP_StdSysMsg,
- SCRTAG_AutoSizeGadget, (ULONG)Gad,
- SCRTAG_ZipGadget,TRUE,
- SCRTAG_IGfxType, IGFXTYP_StdWin,
- TAG_DONE);
-
- if(Win) {
- struct pOS_IntuiMessage *Msg;
- BOOL Ende=FALSE;
- const UWORD MWidth =Win->win_Width;
- const UWORD MHeight=Win->win_Height;
-
- while(!Ende) {
- if(DOSSIGF_CTRL_C & pOS_WaitSignal((1<<Win->win_UserPort->mp_SigBit) | DOSSIGF_CTRL_C)) break;
-
- while(Msg=(struct pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
-
- if(pOS_SysIMessage(Msg)) Msg=NULL;
- else {
- switch(Msg->im_Class) {
-
- case IDCMP_GadgetDown:
- if(DisTestGad == ((struct pOS_Gadget*)Msg->im_IAddress)->gad_Parent)
- {
- pOS_SetGadgetAttrs(Win,FindGad,
- ICLTAG_Disabled, Msg->im_Code==1,
- TAG_DONE);
- }
- break;
-
- case IDCMP_CloseWindow: Ende=TRUE; break;
- }
- }
- if(Msg) pOS_ReplyMsg(&Msg->im_Message);
- }
- }
- pOS_CloseWindow(Win);
- }
- else printf("Cannot open window\n");
- }
- else printf("Cannot create gadget <%s>\n",Ops[0]);
- pOS_UnlockPubScreen(Scr);
- }
- else printf("Cannot lock PubScreen\n");
-
- if(TF) pOS_CloseFont(TF);
- pOS_DeleteDosArgs(Args); /* Args freigeben */
- }
- else Err=DOSFAIL_FAIL; /* vollkommen fehlgeschlagen */
-
- pOS_SetShellFail(Err);
-
- pOS_CloseLibrary((pOS_Library*)gb_IntuiBase);
- pOS_CloseLibrary((pOS_Library*)gb_GfxBase);
- }
-