home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Mecomp Multimedia 1
/
Mecomp-CD.iso
/
amiga
/
tools
/
boot
/
powerwindows
/
developper
/
examples
/
windowchecker.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-04-23
|
5KB
|
184 lines
/*======== Example Source-Code for an external Window-Checker =========
(C) Copyright 1997 by Steger Georg.
Created with MaxonCPP 4.0 Pro
Description:
¯¯¯¯¯¯¯¯¯¯¯¯
This Windowchecker uses a Routine very similiar to the
standard one of PowerWindows. It also replaces the Look
of the Iconify-Gadget. You will get a little nice Smiley!
It looks a little bit strange on Lowres-Screens, but hey,
this is only an Example!!
====================================================================*/
/* OS-Includes */
#include <intuition/intuition.h>
#include <intuition/imageclass.h>
#include <graphics/gfx.h>
// #pragma header
/* Compiler-Includes */
#include <pragma/intuition_lib.h>
#include <pragma/graphics_lib.h>
#include <pragma/exec_lib.h>
#include <string.h>
/* Program-Includes */
#include "/PWDevelopper.h"
/* Macros */
#define CWDRAWIMAGE_Msg (((struct cwRenderIG *)msg)->DrawImageMsg)
#define IG_IMAGE (((struct cwRenderIG *)msg)->GadImage)
#define IG_RP (((struct cwRenderIG *)msg)->DrawImageMsg->imp_RPort)
#define DRI_PENS di->dri_Pens
/* Vars */
struct GfxBase *GfxBase;
struct IntuitionBase *IntuitionBase;
/* Program */
LONG CheckWindow(Msg msg)
{
struct DrawInfo *di;
struct Gadget *gad;
WORD x1,y1,x2,y2,width,leftmost,state;
BYTE IsInactive,IsSelected;
switch (msg->MethodID)
{
/*========== CW_INIT ===========================================*/
case CW_INIT:
GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",36);
if (!GfxBase) return RIR_FAIL;
return CWR_OK;
/*========== CW_EXIT ===========================================*/
case CW_EXIT:
if (GfxBase) CloseLibrary((struct Library *)GfxBase);
return CWR_OK;
/*========== CW_CHECK ==========================================*/
case CW_CHECK:
gad=CWCHECK_Msg->Win->FirstGadget;
x1=0;y1=0;width=0;leftmost=1;
while (gad)
{
x1++;
if (gad->GadgetType>YP_SYSTYPEMASK)
{
if (!y1) y1=x1;
}
if ((gad->TopEdge==0) && (gad->Flags&GFLG_RELRIGHT) && (!(gad->Flags&(GFLG_RELWIDTH|GFLG_RELHEIGHT|GFLG_RELBOTTOM))))
{
if (((gad->GadgetType>YP_SYSTYPEMASK)==GTYP_WDEPTH) ||
((gad->GadgetType>YP_SYSTYPEMASK)==GTYP_WZOOM))
{
width=gad->Width;
}
if (gad->LeftEdge<leftmost)
{
leftmost=gad->LeftEdge;
}
}
gad=gad->NextGadget;
}
if (!width)
width=24;
CWCHECK_Msg->Gad_LeftEdge=leftmost-width+1;
CWCHECK_Msg->Gad_TopEdge=0;
CWCHECK_Msg->Gad_Width=width;
CWCHECK_Msg->Gad_Height=CWCHECK_Msg->Win->BorderTop;
CWCHECK_Msg->Gad_Flags=GFLG_RELRIGHT;
CWCHECK_Msg->Gad_Position=y1;
return CWR_OK|CWR_ICONIFYGAD|CWR_ICONIFYPOS;
/*========== CW_RENDERIG =======================================*/
case CW_RENDERIG:
if ((di=CWRENDERIG_Msg->DrawImageMsg->imp_DrInfo))
{
x1=CWDRAWIMAGE_Msg->imp_Offset.X+IG_IMAGE->LeftEdge;
y1=CWDRAWIMAGE_Msg->imp_Offset.Y+IG_IMAGE->TopEdge;
x2=x1-1+(CWDRAWIMAGE_Msg->MethodID==IM_DRAW ? IG_IMAGE->Width : CWDRAWIMAGE_Msg->imp_Dimensions.Width);
y2=y1-1+(CWDRAWIMAGE_Msg->MethodID==IM_DRAW ? IG_IMAGE->Height : CWDRAWIMAGE_Msg->imp_Dimensions.Height);
state=CWDRAWIMAGE_Msg->imp_State;
IsInactive=((state==IDS_INACTIVENORMAL) || (state==IDS_INACTIVESELECTED) || (state==IDS_INACTIVEDISABLED));
IsSelected=((state==IDS_SELECTED) || (state==IDS_INACTIVESELECTED) || (state==IDS_SELECTEDDISABLED));
/* Standard Frame */
SetAPen(IG_RP,DRI_PENS[IsInactive ? BACKGROUNDPEN : FILLPEN]);
RectFill(IG_RP,x1+2,y1+1,x2-1,y2-1);
SetAPen(IG_RP,DRI_PENS[SHADOWPEN]);
RectFill(IG_RP,x1,y1+1,x1,y2-1);
SetAPen(IG_RP,DRI_PENS[IsSelected ? SHADOWPEN : SHINEPEN]);
RectFill(IG_RP,x1+1,y1,x1+1,y2-1);
RectFill(IG_RP,x1,y1,x2,y1);
SetAPen(IG_RP,DRI_PENS[IsSelected ? SHINEPEN : SHADOWPEN]);
RectFill(IG_RP,x2,y1+1,x2,y2);
RectFill(IG_RP,x1+1,y2,x2-1,y2);
/* let's draw a Smiley!! */
SetAPen(IG_RP,DRI_PENS[SHADOWPEN]);
RectFill(IG_RP,x1+5,y1+3,x1+9,y1+7);
RectFill(IG_RP,x2-8,y1+3,x2-4,y1+7);
SetAPen(IG_RP,DRI_PENS[IsInactive ? BACKGROUNDPEN : SHINEPEN]);
RectFill(IG_RP,x1+6,y1+5-(IsSelected ? 0 : 1),x1+8,y1+6);
RectFill(IG_RP,x2-7,y1+5-(IsSelected ? 0 : 1),x2-5,y1+6);
SetAPen(IG_RP,DRI_PENS[SHADOWPEN]);
WritePixel(IG_RP,x1+7,y1+5);
WritePixel(IG_RP,x2-6,y1+5);
if (IsSelected)
{
RectFill(IG_RP,x1+8,y2-5,x2-7,y2-3);
SetAPen(IG_RP,DRI_PENS[IsInactive ? BACKGROUNDPEN : SHINEPEN]);
RectFill(IG_RP,x1+9,y2-4,x2-8,y2-4);
} else {
RectFill(IG_RP,x1+8,y2-5,x2-7,y2-3);
RectFill(IG_RP,x1+6,y2-6,x1+9,y2-4);
RectFill(IG_RP,x2-8,y2-6,x2-5,y2-4);
SetAPen(IG_RP,DRI_PENS[IsInactive ? BACKGROUNDPEN : SHINEPEN]);
RectFill(IG_RP,x1+9,y2-4,x2-8,y2-4);
RectFill(IG_RP,x1+7,y2-5,x1+8,y2-5);
RectFill(IG_RP,x2-7,y2-5,x2-6,y2-5);
}
}
return CWR_OK;
/*========== default ===========================================*/
default:
return CWR_FAIL;
}
}