The needed info is very dispersed in the RKRM plus the SDK docs.
I understand (now) that the arguments of hookfunctions you write, are filled in by the OS libraries. In the source i am working on it seemed that for a Windows backfill hook the structure of the third argument was defined as struct BackFill by the author, whereas the OS library uses BackFillMessage with exactly the same structure;
I was not able to find anywhere in the docs that the second
argument was of type struct Rastport.
The program below is a synthesis of the Gui4Cli source's approach.
It works but the reverse is not true, even after correcting the source in conformity with his smaller model, I get unhelpfull freezes immediately after loading with the Gui4Cli a (Gui4Cli)script that opens a window.
So i am still stuck in commenting out the WA_BackFill lines in OpenWindowTagList() call.
I am out of ideas how to tackle this. The last idea i had was to have the do_Backfill() function return immediately, but the behaviour is the same.
Code: Select all
/* compiles and works, use -lauto */
#define __USE_INLINE__
#define __USE_BASETYPE__
#define ZERO ((BPTR)NULL)
#include <proto/intuition.h> //OpenWindowTags CloseWindow
#include <proto/graphics.h> //SetAPen SetDrMd SetMaxPen RectFill
#include <proto/dos.h> //Delay Printf
#include <proto/exec.h> //AllocSysObjectTags
#include <exec/types.h>
#include <exec/exec.h>
#include <exec/execbase.h>
#include <exec/ports.h>
#include <exec/io.h>
#include <intuition/intuition.h>
struct BackFillData //Michaël van Elst
{
struct Layer *l;
struct Rectangle bounds;
LONG offx, offy;
};
/*graphics/layers.h
* The message a backfill hook receives
struct BackFillMessage
{
struct Layer *Layer;
struct Rectangle Bounds;
LONG OffsetX;
LONG OffsetY;
};
*/
struct BackFill // michaël van Elst
{
char mode; /* s=solid, p=pattern, i=icon, I=image */
SHORT apen, bpen;
LONG top, left, width, height;
struct DiskObject *dobj;
struct BitMap BM;
struct imginfo *img;
};
struct guifile
{
struct BackFill bf;
struct Remember *rkey;
struct Hook *hk; //OS4 was
///struct Hook hk;
} *gf;
/*
struct Hook //proto/hooks.h
{
struct MinNode h_MinNode;
ULONG (*h_Entry)(); /* assembler entry point */
ULONG (*h_SubEntry)(); /* often HLL entry point */
APTR h_Data; /* owner specific */
}*/
/*struct Rectangle graphics/gfx.h
{ //redefinition of struct Rectangle
WORD MinX;
WORD MinY;
WORD MaxX;
WORD MaxY;
}; */
ULONG INTERRUPT SAVEDS do_backfill(struct Hook * , struct RastPort * , struct BackFillData * );
// where do we find that the 2de arg is struct Tastport *
ULONG INTERRUPT SAVEDS do_backfill(struct Hook *h, struct RastPort *rp, struct BackFillData *bfd)
{
struct RastPort clonerp;
struct BackFill *bf;
bf = (struct BackFill *)h->h_Data;
// *---------- Clone rastport -----------* /
clonerp = *rp; // * clone Rastport so as not to change user settings * /
clonerp.Layer = NULL; // * Backfill RastPorts must not have a layer * /
// *---------- do backfill --------------* /
switch (bf->mode)
{
case 's' : // SOLID
SetAPen (&clonerp, bf->apen);
SetDrMd (&clonerp, JAM1);
SetMaxPen (&clonerp, ~0); // * V39 only * /
RectFill (&clonerp, bfd->bounds.MinX, bfd->bounds.MinY,
bfd->bounds.MaxX, bfd->bounds.MaxY); //OS4E
break;
}
return (0);
}
int main() {
struct Window *myWindow;
struct Remember *tempkey=NULL;
struct guifile * gf;
if (!(gf = (struct guifile *)AllocRemember(&tempkey, sizeof(struct guifile),
MEMF_CLEAR)))
{ goto endFUN; }
gf->rkey = tempkey;
tempkey = NULL;
//APTR bfhook;
gf->bf.apen = 4; //change backgroudn color here
gf->bf.mode = 's';
gf->bf.bpen = 2;
//gf->bf.dobj = NULL;
if (!(gf->hk=AllocSysObjectTags( ASOT_HOOK, ASOHOOK_Entry, do_backfill, ASOHOOK_Data, NULL, TAG_DONE)))
{ goto endFUN; }
gf->hk->h_Data = (APTR)&gf->bf;
struct TagItem win_tags[] =
{
{WA_Left , 20L },
{WA_Top , 20L },
{WA_Width , 200L },
{WA_Height , 150L },
{WA_MinWidth , 200L },
{WA_MinHeight , 100L },
{WA_MaxWidth , ~0 },
{WA_MaxHeight , ~0 },
{WA_AutoAdjust , TRUE },
{WA_Activate , TRUE },
{WA_Title , (LONG)"My Window" },
{WA_Flags , WFLG_SIZEGADGET | WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_ACTIVATE },
{WA_BackFill , (LONG)gf->hk },
{WA_IDCMP , ZERO },
{TAG_DONE , ZERO },
};
myWindow = OpenWindowTagList (NULL, win_tags);
Delay(200);
if (myWindow) CloseWindow(myWindow);
FreeRemember(&gf->rkey, TRUE);
return(0);
endFUN:
return(1);
}