home *** CD-ROM | disk | FTP | other *** search
-
- /*******************************************************************
- $CRT 22 Oct 1996 : hb
-
- $AUT Holger Burkarth
- $DAT >>SuperWin.c<< 02 Mar 1997 11:04:51 - (C) ProDAD
- *******************************************************************/
-
- //##ex mcpp:cppc -gs -o pos:pos/Ex/SuperWin p:pLib/StartCode.o p:/pOS_RKRM/pIntui/SuperWin.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:pGadget/PropGad.h"
- #include "p:pLayer/Clip.h"
- #include "p:pScreen/ScrTags.h"
- #include "p:pScreen/Window.h"
- #include "p:pScreen/Screen.h"
- #include "p:pGFX/GfxTags.h"
- #include "p:pGFX/GfxMap.h"
- #include "p:pGFX/RastPort.h"
- #include "p:pIntui/IntuMsg.h"
- #include "p:pIntui/Tags.h"
- #include "p:pDtType/DtTags.h"
- #include "p:pDtType/Picture.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"
- #include "p:proto/pDtType2.h"
- #include "p:proto/pLayer2.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;
- struct pOS_DataTypeBase *gb_DtTypeBase;
- struct pOS_LayerBase *gb_LayerBase;
-
- VOID CalcSliders(pOS_Window*,pOS_Gadget*,pOS_Gadget*,UWORD width,UWORD height);
- VOID MoveSliders(pOS_Window*,pOS_Gadget*,pOS_Gadget*,UWORD width,UWORD height);
-
-
- /*----------------------------------
- -----------------------------------*/
- #ifdef __cplusplus
- extern "C"
- #endif
-
- VOID main()
- {
- pOS_DosArgs* Args;
- UWORD Err=0;
- ULONG Ops[1]={0};
-
- gb_IntuiBase=(pOS_IntuiDevice*)pOS_OpenLibrary("pintui.library",0);
- gb_GfxBase=(pOS_GfxBase*)pOS_OpenLibrary("pgraphics.library",0);
- gb_DtTypeBase=(pOS_DataTypeBase*)pOS_OpenLibrary("pDtType.library",0);
- gb_LayerBase=(pOS_LayerBase*)pOS_OpenLibrary("pLayer.library",0);
-
-
- Args=pOS_ReadDosArgs(
- // 0
- "",
- 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) {
- pOS_Window *Win;
- pOS_Screen *Scr;
- pOS_GfxMap *SuperMap;
- pOS_Gadget *HPropGad,*VPropGad;
- UWORD GWidth =256;
- UWORD GHeight=256;
-
- if(Scr=pOS_LockPubScreen("Workbench")) {
- pOS_WBox Box;
- const pOS_DrawInfo *Dri=Scr->scr_DrawInfo;
-
- SuperMap=pOS_AllocGfxMap(Dri->dri_Base,
- GFXTAG_Width, GWidth,
- GFXTAG_Height, GHeight,
- GFXTAG_FriendGfxMap, (ULONG)Scr->scr_RastPort->rp_GfxMap,
- GFXTAG_GfxFlags, GFXMAPF_Draw | GFXMAPF_Clear,
- TAG_END);
-
-
-
- pOS_GetWindowBorder(Scr,&Box,WINFLGF_SizeBBottom | WINFLGF_SizeBRight,
- GFLG_RelWidth | GFLG_RelBottom,
- GACT_BottomBorder);
-
- HPropGad=(pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GPropClass],0,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- ICLTAG_Immediate, TRUE,
- ICLTAG_UpdateGadget, TRUE,
- ICLTAG_Left, Box.Left+3,
- ICLTAG_RelBottom, Box.Top+3,
- ICLTAG_RelWidth, Box.Width-6,
- ICLTAG_Height, Box.Height-6,
- ICLTAG_AutoDelete, TRUE,
- ICLTAG_TopBorder, TRUE,
- ICLTAG_GadBorderType, GADBORTYP_None,
- PRGADTAG_CreateUDGads,TRUE,
- PRGADTAG_Flags, PRGADF_FreeHoriz,
- PRGADTAG_Visible, GWidth,
- PRGADTAG_Total, GWidth,
- TAG_END);
-
- pOS_GetWindowBorder(Scr,&Box,WINFLGF_SizeBBottom | WINFLGF_SizeBRight,
- GFLG_RelRight | GFLG_RelHeight,
- GACT_RightBorder);
-
- VPropGad=(pOS_Gadget*)pOS_NewIObject(NULL,Dri->dri_Names[SCRNAM_GPropClass],0,
- ICLTAG_DrawInfo, (ULONG)Scr->scr_DrawInfo,
- ICLTAG_Immediate, TRUE,
- ICLTAG_UpdateGadget, TRUE,
- ICLTAG_RelRight, Box.Left+3,
- ICLTAG_Top, Box.Top+3,
- ICLTAG_Width, Box.Width-6,
- ICLTAG_RelHeight, Box.Height-6,
- ICLTAG_AutoDelete, TRUE,
- ICLTAG_RightBorder, TRUE,
- ICLTAG_GadBorderType, GADBORTYP_None,
- PRGADTAG_CreateUDGads,TRUE,
- PRGADTAG_Flags, PRGADF_FreeVert,
- PRGADTAG_Visible, GHeight,
- PRGADTAG_Total, GHeight,
- TAG_END);
-
-
- if(SuperMap) {
- Win=pOS_OpenWindow(
- SCRTAG_Title, (ULONG)"SuperGfx-Window",
- SCRTAG_PubName, (ULONG)"Workbench",
- SCRTAG_Flags, WINFLGF_DepthGadget | WINFLGF_GimmeZeroZero
- | WINFLGF_Activate | WINFLGF_CloseGadget
- | WINFLGF_Dragbar | WINFLGF_SizeGadget
- | WINFLGF_SizeBBottom | WINFLGF_SizeBRight,
- SCRTAG_IDCMP, IDCMP_CloseWindow | IDCMP_VanillaKey
- | IDCMP_GadgetDown | IDCMP_GadgetUp | IDCMP_UpdateGadget
- | IDCMP_NewSize,
- SCRTAG_Width, GWidth/2,
- SCRTAG_Height, GHeight/2,
- SCRTAG_InnerMinWidth, 20,
- SCRTAG_InnerMinHeight,20,
- SCRTAG_InnerMaxWidth, GWidth,
- SCRTAG_InnerMaxHeight,GHeight,
- SCRTAG_ZipGadget, TRUE,
- SCRTAG_SuperGfxMap, (ULONG)SuperMap,
- SCRTAG_Gadget, (ULONG)HPropGad,
- SCRTAG_Gadget, (ULONG)VPropGad,
- TAG_DONE);
-
- if(Win) {
- pOS_IntuiMessage *Msg;
- BOOL Ende=FALSE;
-
- pOS_DrawRectFill(Win->win_RastPort,120,120,160,160);
-
- CalcSliders(Win,HPropGad,VPropGad,GWidth,GHeight);
-
- while(!Ende) {
- pOS_WaitPort(Win->win_UserPort);
- while(Msg=(pOS_IntuiMessage*)pOS_GetMsg(Win->win_UserPort)) {
- switch(Msg->im_Class) {
-
-
- case IDCMP_GadgetUp:
- case IDCMP_GadgetDown:
- case IDCMP_UpdateGadget:
- if( (pOS_Gadget*)Msg->im_IAddress==HPropGad
- || (pOS_Gadget*)Msg->im_IAddress==VPropGad) {
- MoveSliders(Win,HPropGad,VPropGad,GWidth,GHeight);
- }
- break;
-
-
- case IDCMP_NewSize:
- CalcSliders(Win,HPropGad,VPropGad,GWidth,GHeight);
- break;
-
- case IDCMP_CloseWindow: Ende=TRUE; break;
- }
- if(pOS_SysIMessage(Msg)==FALSE)
- pOS_ReplyMsg(&Msg->im_Message);
- }
- }
- pOS_CloseWindow(Win);
- }
- else printf("Cannot open window\n");
- pOS_FreeGfxMap(SuperMap);
- }
- else printf("Cannot create SuperGfxMap\n");
- 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((pOS_Library*)gb_GfxBase);
- pOS_CloseLibrary((pOS_Library*)gb_IntuiBase);
- pOS_CloseLibrary((pOS_Library*)gb_DtTypeBase);
- pOS_CloseLibrary((pOS_Library*)gb_LayerBase);
- }
-
-
-
- /*----------------------------------
- -----------------------------------*/
- VOID CalcSliders(pOS_Window* win,pOS_Gadget* hgad,pOS_Gadget* vgad,
- UWORD width,UWORD height)
- {
- pOS_IBox Box;
-
- pOS_GetWindowIBox(win,&Box,NULL);
- if(hgad)
- pOS_SetGadgetAttrs(win,hgad,
- PRGADTAG_Visible, Box.Width,
- TAG_END);
-
- if(vgad)
- pOS_SetGadgetAttrs(win,vgad,
- PRGADTAG_Visible, Box.Height,
- TAG_END);
- }
-
-
- /*----------------------------------
- -----------------------------------*/
- VOID MoveSliders(pOS_Window* win,pOS_Gadget* hgad,pOS_Gadget* vgad,
- UWORD width,UWORD height)
- {
- ULONG Value;
- SLONG Diff;
- pOS_Layer *const Ly=win->win_Layer;
-
- if(hgad) {
- pOS_GetGadgetAttr(NULL,hgad,PRGADTAG_Top, &Value);
-
- Diff=-Ly->ly_ScrollX-Value;
- if(Diff!=0) pOS_ScrollLayer(Ly,Diff,0);
- }
- if(vgad) {
- pOS_GetGadgetAttr(NULL,vgad,PRGADTAG_Top,&Value);
-
- Diff=-Ly->ly_ScrollY-Value;
- if(Diff!=0) pOS_ScrollLayer(Ly,0,Diff);
- }
- }
-