Click Here
home features news forums classifieds faqs links search
6071 members 
Amiga Q&A /  Free for All /  Emulation /  Gaming / (Latest Posts)
Login

Nickname

Password

Lost Password?

Don't have an account yet?
Register now!

Support Amigaworld.net
Your support is needed and is appreciated as Amigaworld.net is primarily dependent upon the support of its users.
Donate

Menu
Main sections
» Home
» Features
» News
» Forums
» Classifieds
» Links
» Downloads
Extras
» OS4 Zone
» IRC Network
» AmigaWorld Radio
» Newsfeed
» Top Members
» Amiga Dealers
Information
» About Us
» FAQs
» Advertise
» Polls
» Terms of Service
» Search

IRC Channel
Server: irc.amigaworld.net
Ports: 1024,5555, 6665-6669
SSL port: 6697
Channel: #Amigaworld
Channel Policy and Guidelines

Who's Online
15 crawler(s) on-line.
 77 guest(s) on-line.
 0 member(s) on-line.



You are an anonymous user.
Register Now!
 gryfon:  13 mins ago
 VooDoo:  40 mins ago
 Dragster:  2 hrs 1 min ago
 bhabbott:  2 hrs 6 mins ago
 Hypex:  3 hrs 23 mins ago
 amigakit:  4 hrs 14 mins ago
 matthey:  4 hrs 15 mins ago
 agami:  5 hrs 7 mins ago
 BigD:  6 hrs 17 mins ago
 Rob:  6 hrs 57 mins ago

/  Forum Index
   /  Free For All
      /  Old universal drag and drop code of mine...
Register To Post

PosterThread
gonegahgah 
Old universal drag and drop code of mine...
Posted on 30-Sep-2024 9:31:01
#1 ]
Regular Member
Joined: 5-Dec-2008
Posts: 166
From: Australia

This is some code a wrote a long time ago.
It's purpose was so I could add a more universal drag and drop to the Classic Amiga system...

It had a few features:

It had zones as well as watchers.
A zone was interested when the mouse pointer was over it.
A watcher was always interested.

A possible example of a watcher would be "eyes" which follow the pointer.
You could also use it for a magnifier, etc. Maybe autopoint as well?
At least I think that was the intent.

It also allowed for delayed rendering so that the input chain would not get bogged down.
I think I stole a bit from the Window flags which of course is dangerous.
Something like that would have needed to be ratified.
I also used the window's UserData as that was the only way I could get a handle into the Window.

I thought I played around with autopoint in relation to this but I can't see it at a quick glance.
I think I figured that it would be better to have one commodity flicking through the screen list than to have multiple doing that consecutively!
Also, I think autopoint had a possible fault scenario but I can't remember what that was?

Anyhow, here's the MouseZone code for starters.
Hope it makes some sense and is of some use?
My documentation wasn't great in those days.
Now-a-days I describe/document first and code second.
It also uses some of my own garbage collection and event handling code.
I'm happy to add that too but it may want to be rewritten around?

 Status: Offline
Profile     Report this post  
gonegahgah 
Re: Old universal drag and drop code of mine...
Posted on 30-Sep-2024 9:31:45
#2 ]
Regular Member
Joined: 5-Dec-2008
Posts: 166
From: Australia

// Commodity: MouseZone

// -----------------------------------------------------------------------------

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "MouseZone.h"

// -----------------------------------------------------------------------------

char __stdiowin[]="CON:10/10/600/100/Debug";
char __stdiov37[]="/CLOSE/AUTO";

// -----------------------------------------------------------------------------

UWORD GetProgramGoing(int argc,char **argv);
UWORD GetToolTypes(struct NewBroker *newbroker,int argc,char **argv);
VOID HandleEvent_CxBroker(BOOL *quit,CxMsg *pMsg);
VOID HandleEvent_CxSignal(VOID);
VOID HandleEvent_CtrlC(BOOL *quit);
VOID ReportError(ULONG errornr);

// -----------------------------------------------------------------------------

struct EasyStruct easystruct = {
sizeof(struct EasyStruct),0,"Mouse Zone",NULL,NULL
};

// -----------------------------------------------------------------------------

struct EventsManager *pEventsMgr; // (Signal,Handler) List
struct MinList pAnchor; // Cleanup List
CxObj *pBroker;
struct ChuteNode *pKillCommodity;
struct ZonesLock *pZonesLock;

struct IntuitionBase *IntuitionBase = NULL;
struct Library *UAIBase,*CxBase,*LayersBase;

#define CHUTE pAnchor

// -----------------------------------------------------------------------------

VOID main(int iArgC,char **pArgV) {

UWORD wErrorNbr;

if(!(UAIBase = OpenLibrary("uai.library",0L))) {
ReportError(ERR_NOLIB_UAI);
}
else {
NEWCHUTE(); // Ready the chute for adding to.
}

if(wErrorNbr = GetProgramGoing(iArgC,pArgV)) {
ReportError(wErrorNbr);
}
else {
HandleEvents(pEventsMgr); // Does all event waiting & passes to handlers.
}

CLEARCHUTE(); // Handles all the clean up (except UAIBase).
CloseLibrary(UAIBase);

}

// -----------------------------------------------------------------------------

UWORD GetProgramGoing(int iArgC,char **ppArgV) {

struct ClassLibrary *pZoneBase;
LONG lCXSigBit;
UWORD wErrorNbr;

struct NewBroker rNewBroker = {
NB_VERSION,"MouseZone","Mouse Zone V1.0","Track mouse pointer over zones"
,NBU_UNIQUE,0,0,0,0
};

if(!(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library"
,36L))) {
return(ERR_NOLIB_INTUITION);
}
if(!ADDTOCHUTE((ULONG)CloseLibrary,IntuitionBase)) {
return(ERR_NOMEM);
}

if(!(CxBase = OpenLibrary("commodities.library",37L))) {
return(ERR_NOLIB_COMMODITIES);
}
if(!ADDTOCHUTE((ULONG)CloseLibrary,CxBase)) {
return(ERR_NOMEM);
}

if(!(LayersBase = OpenLibrary("layers.library",33L))) {
return(ERR_NOLIB_LAYERS);
}
if(!ADDTOCHUTE((ULONG)CloseLibrary,LayersBase)) {
return(ERR_NOMEM);
}

if(!(pZoneBase = (struct ClassLibrary *)OpenLibrary("uai/zones/zoneclass"
,0L))) {
return(ERR_NOLIB_ZONECLASS);
}
if(!ADDTOCHUTE((ULONG)CloseLibrary,pZoneBase)) {
return(ERR_NOMEM);
}

if(!ADDTOCHUTE((ULONG)DeleteEventsManager
,pEventsMgr = CreateEventsManager())) { // Creates an events manager
return(ERR_NOMEM);
}

if(!(pZonesLock = (struct ZonesLock *)FindSemaphore("Zones"))) { // zoneclass.
return(ERR_SEMAPHOREFAILED);
}

if(wErrorNbr = GetToolTypes(&rNewBroker,iArgC,ppArgV)) {
return(wErrorNbr);
}

if(!ADDTOCHUTE((ULONG)DeleteMsgPort
,rNewBroker.nb_Port = CreateMsgPort())) {
return(ERR_NOMEM);
}

if(!(pBroker = CxBroker(&rNewBroker,NULL))) {
return(ERR_NOMEM);
}
if(!(pKillCommodity = ADDTOCHUTE((ULONG)DeleteCxObjAll,pBroker))) {
return(ERR_NOMEM);
}

if(!ADDTOCHUTE((ULONG)DeleteEventRule
,CreateEventRuleTags(ERA_AddToEventsManager,pEventsMgr
,ERA_MsgPort,rNewBroker.nb_Port
,ERA_Handler,(ULONG)HandleEvent_CxBroker
,TAG_DONE))) {
return(ERR_NOMEM);
}

if(ADDTOCHUTE((ULONG)DeleteEventRule
,CreateEventRuleTags(ERA_AddToEventsManager,pEventsMgr
,ERA_Signal,SIGBREAKF_CTRL_C
,ERA_Handler,(ULONG)HandleEvent_CtrlC
,TAG_DONE))) {
return(ERR_NOMEM);
}

if(-1 == (lCXSigBit = AllocSignal(-1))) {
return(ERR_NOMORESIGNALS);
}
if(!ADDTOCHUTE((ULONG)FreeSignal,(VOID *)lCXSigBit)) {
return(ERR_NOMEM);
}

if(!ADDTOCHUTE((ULONG)DeleteEventRule
,CreateEventRuleTags(ERA_AddToEventsManager,pEventsMgr
,ERA_SigBit,lCXSigBit
,ERA_Handler,(ULONG)HandleEvent_CxSignal
,TAG_DONE))) {
return(ERR_NOMEM);
}

AttachCxObj(pBroker,CxSignal(FindTask(NULL),lCXSigBit));
if(CxObjError(pBroker)) {
return(ERR_NOMEM);
}

ActivateCxObj(pBroker,1L);

return(NO_ERROR);

}

// -----------------------------------------------------------------------------

UWORD GetToolTypes(struct NewBroker *rNewBroker,int iArgC,char **pArgV) {

struct Library *IconBase;
UBYTE **pToolTypeArray;
UWORD wErrorNbr;

rNewBroker->nb_Pri = 0;

if(IconBase = OpenLibrary("icon.library",36L)) {

// DEBUG: 2009-10-26 Don't ask me why the following doesn't work.
// It used to work???
// if(pToolTypeArray = ArgArrayInit((LONG)iArgC,(UBYTE **)ppArgV)) {
// rNewBroker->nb_Pri = (BYTE)ArgInt(pToolTypeArray,"CX_PRIORITY",0);
// ArgArrayDone();
// wErrorNbr = NO_ERROR; // wErrorNbr = 0
// }
// else {
// wErrorNbr = ERR_NOMEM;
// }
CloseLibrary(IconBase); // Only needed long enough to get tool types.
// return(wErrorNbr);
return(NO_ERROR);

}

return(ERR_NOLIB_ICON);

}

// -----------------------------------------------------------------------------

VOID __saveds HandleEvent_CxBroker(BOOL *quit,CxMsg *pMsg) {

ULONG lMsgId,lMsgType;

lMsgType = CxMsgType(pMsg);
lMsgId = CxMsgID(pMsg);
ReplyMsg((struct Message *)pMsg);
if(!*quit) {

switch(lMsgType) {
case CXM_COMMAND:
switch(lMsgId) {
case CXCMD_DISABLE:
ActivateCxObj(pBroker,0L);
break;
case CXCMD_ENABLE:
ActivateCxObj(pBroker,1L);
break;
case CXCMD_KILL:
ClearChuteNode(pKillCommodity);
*quit = TRUE;
break;
}
break;
}

}

}

// -----------------------------------------------------------------------------

struct zpInput rHandleMsg; // Global okay as zones locked.
struct zpGoInactive rGoInactiveMsg = { ZM_GOINACTIVE };

// -----------------------------------------------------------------------------

VOID __saveds HandleEvent_CxSignal(VOID) {

LONG lBaseLock;
struct Screen *pScreen;
struct Layer *pLayer;
struct ZoneNode *pWatcher; // Such as AutoPoint commodity, moveclass, etc.
struct Screen *pPubScreen,*pFirstPubScreen,*pPrevPubScreen;
UBYTE *pPubScreenName;

ULONG lIsZone = FALSE;
struct {
WORD X,Y;
} rMouseInWindow,rMouseInScreen = {
-1,-1
};
rHandleMsg.zpi_Window = NULL;

ObtainSemaphore(&pZonesLock->zl_Semaphore); // So window.zones remains.
lBaseLock = LockIBase(0L);
pScreen = IntuitionBase->FirstScreen;
while(pScreen) {

if(pScreen->MouseY > 0) { // Is rMouseInWindow pointer over this pScreen?
pLayer = WhichLayer(&pScreen->LayerInfo,(LONG)pScreen->MouseX
,(LONG)pScreen->MouseY);

if(pLayer && pLayer != pScreen->BarLayer) {
rHandleMsg.zpi_Window = (struct Window *)pLayer->Window;
rMouseInWindow.X = rHandleMsg.zpi_Window->MouseX;
rMouseInWindow.Y = rHandleMsg.zpi_Window->MouseY;
lIsZone = rHandleMsg.zpi_Window->MoreFlags & WFLAG_WINDOWZONE;
}

rHandleMsg.zpi_Screen = pScreen;
rMouseInScreen.X = pScreen->MouseX;
rMouseInScreen.Y = pScreen->MouseY;
rHandleMsg.zpi_PubScreenName = NULL;
if(pPubScreenName = NextPubScreen(NULL,pZonesLock->zl_PubScreenName)) {

if(pFirstPubScreen = LockPubScreen(pPubScreenName)) {

pPubScreen = LockPubScreen(pPubScreenName);
do {

if(pPubScreen != rHandleMsg.zpi_Screen) { // Okay as IBase is locked.

pPrevPubScreen = pPubScreen;
pPubScreenName = NextPubScreen(pPubScreen
,pZonesLock->zl_PubScreenName);
UnlockPubScreen(NULL,pPrevPubScreen);
if(pPubScreenName) {
pPubScreen = LockPubScreen(pPubScreenName);
}
else {
// With Workbench about this will probably never occur.
pPubScreen = NULL;
}
}

else {

rHandleMsg.zpi_PubScreenName = pZonesLock->zl_PubScreenName;
UnlockPubScreen(NULL,pPubScreen);
pPubScreen = NULL; // ie. Stop looking.

}

}
while(pPubScreen && pPubScreen != pFirstPubScreen);

if(pPubScreen) { // ie. equals pFirstPubScreen...
UnlockPubScreen(NULL,pFirstPubScreen); // Managed to go full circle.
}

UnlockPubScreen(NULL,pFirstPubScreen); // Undo original lock.
}
}
pScreen = NULL;
}
else {
pScreen = pScreen->NextScreen;
}
}

rHandleMsg.zpi_Mouse = rMouseInScreen;
rHandleMsg.MethodID = ZM_HANDLEINPUT;
for(pWatcher = (struct ZoneNode *)pZonesLock->zl_WhileIBaseLocked.mlh_Head
;pWatcher->zn_Node.mln_Succ;pWatcher = (struct ZoneNode *
)pWatcher->zn_Node.mln_Succ) {
pWatcher->zn_Type = (UWORD)DoMethodA(pWatcher->zn_Zone,(Msg)&rHandleMsg);
}

rHandleMsg.MethodID = ZM_DELAYEDRENDER;
for(pWatcher = (struct ZoneNode *)pZonesLock->zl_WhileIBaseLocked.mlh_Head
;pWatcher->zn_Node.mln_Succ;pWatcher = (struct ZoneNode *
)pWatcher->zn_Node.mln_Succ) {

if(pWatcher->zn_Type == ZMR_DELAYEDRENDER) {
DoMethodA(pWatcher->zn_Zone,(Msg)&rHandleMsg);
}
}

UnlockIBase(lBaseLock);
if(lIsZone) {

rHandleMsg.zpi_Mouse = rMouseInWindow;
rHandleMsg.MethodID = ZM_HANDLEINPUT;
rHandleMsg.zpi_Mouse.X = rMouseInWindow.X;
rHandleMsg.zpi_Mouse.Y = rMouseInWindow.Y;
DoMethodA((Object *)rHandleMsg.zpi_Window->UserData,(Msg)&rHandleMsg);
rGoInactiveMsg.zpgi_Window = rHandleMsg.zpi_Window;
rHandleMsg.zpi_Mouse = rMouseInScreen;

}
elseif(pZonesLock->zl_ActiveZone) {

DoMethodA(pZonesLock->zl_ActiveZone,(Msg)&rGoInactiveMsg);
pZonesLock->zl_ActiveZone = NULL;

}

rHandleMsg.MethodID = ZM_HANDLEINPUT;
for(pWatcher = (struct ZoneNode *)pZonesLock->zl_AfterIBaseUnlock.mlh_Head
;pWatcher->zn_Node.mln_Succ;pWatcher = (struct ZoneNode *
)pWatcher->zn_Node.mln_Succ) {

pWatcher->zn_Type = (UWORD)DoMethodA(pWatcher->zn_Zone,(Msg)&rHandleMsg);

}

rHandleMsg.MethodID = ZM_DELAYEDRENDER;
for(pWatcher = (struct ZoneNode *)pZonesLock->zl_AfterIBaseUnlock.mlh_Head
;pWatcher->zn_Node.mln_Succ;pWatcher = (struct ZoneNode *
)pWatcher->zn_Node.mln_Succ) {

if(pWatcher->zn_Type == ZMR_DELAYEDRENDER) {
DoMethodA(pWatcher->zn_Zone,(Msg)&rHandleMsg);
}

}
ReleaseSemaphore(&pZonesLock->zl_Semaphore);

}

// -----------------------------------------------------------------------------

VOID __saveds HandleEvent_CtrlC(BOOL *quit) {

ClearChuteNode(pKillCommodity);
*quit = TRUE;

}

// -----------------------------------------------------------------------------

VOID ReportError(ULONG wErrorNbr) {

if(IntuitionBase) {

easystruct.es_TextFormat = "Error:\n%s.";
easystruct.es_GadgetFormat = "Okay";
EasyRequest(NULL,&easystruct,NULL,aError[wErrorNbr - 1]);

}
else {

printf("Error: %s.\n",aError[wErrorNbr]);
Delay(TICKS_PER_SECOND * 3);

}

}

// -----------------------------------------------------------------------------


Last edited by gonegahgah on 30-Sep-2024 at 09:32 AM.

 Status: Offline
Profile     Report this post  
gonegahgah 
Re: Old universal drag and drop code of mine...
Posted on 30-Sep-2024 9:36:11
#3 ]
Regular Member
Joined: 5-Dec-2008
Posts: 166
From: Australia

The includes were:
exec/types.h
exec/lists.h
dos/dos.h
intuition/intuitionbase.h
intuition/classes.h
libraries/commodities.h
uai/chute.h
uai/event.h
uai/classes/zoneclass.h
clib/exec_protos.h
clib/dos_protos.h
clib/intuition_protos.h
clib/commodities_protos.h
clib/layers_protos.h
clib/uai_protos.h
clib/alib_protos.h
clib/alib_stdio_protos.h
string.h

 Status: Offline
Profile     Report this post  
gonegahgah 
Re: Old universal drag and drop code of mine...
Posted on 4-Oct-2024 6:49:56
#4 ]
Regular Member
Joined: 5-Dec-2008
Posts: 166
From: Australia

// Class: "icon.move"
// Superclass: "moveclass"

// Note on adaption: This class can be adapted. Refer manual for more information
// about this. The class below is called: "icon.move".
// If you wish to adapt it elsewhere using the MakeAdaptedClass() function you will
// need to specify:
// likeclassid = "icon.move"
// toclass = "moveclass"

#include exec/types.h
#include exec/memory.h
#include graphics/gfxmacros.h
#include intuition/classes.h
#include intuition/imageclass.h
#include uai/classes/zoneclass.h
#include clib/exec_protos.h
#include clib/intuition_protos.h
#include clib/graphics_protos.h
#include clib/layers_protos.h
#include clib/utility_protos.h
#include clib/alib_protos.h
#include proto/exec.h
#include proto/intuition.h
#include proto/graphics.h
#include proto/layers.h
#include proto/utility.h

struct IconMove_InstData {
• • struct Screen *imid_Screen; // Current screen icons are over.
• • struct Layer *imid_FakeLayer; // Moving layer used for maintaining behind layers.
• • struct RastPort imid_RastPort; // Copy of screen rastport.
• • struct { WORD X,Y; } imid_Last; // Last mouse position over screen.
• • struct Image imid_Image;
• • // The Image structure should be replaced by using the actual fields plus...
• • // UWORD *imid_Mask; // for icons that have irregular edges (eg. prefs)...
• • // ... minus the field NextImage which is unneccessary.
/* end struct */ };

ULONG __asm IconMove_Dispatch(register __a0 Class *,register __a2 Object *
,register __a1 Msg);
ULONG IconMove_New(Class *,Object *pTrueClass,struct opSet* pMsg);
ULONG IconMove_RemoveMover(Class *,Object *,struct zpRemoveMover *pMsg);
ULONG IconMove_HandleInput(Class *,Object *,struct zpInput *pMsg);
ULONG IconMove_DelayedRender(Class *,Object *,struct zpInput *pMsg);

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Library *LayersBase,*UtilityBase;
struct ClassLibrary *pMoveBase;

// Don't change the names of Class_Init() or Class_Expunge() as classbase.a requires
// these to be named as they are.

int __saveds __asm Class_Init(register __a6 struct ClassLibrary *pClassBase) {
• • Class *pClass;
• • extern ULONG EnterClassLibrary();

• • if(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",36L)) {
• • • • return(FALSE);
• • }
• •
• • • • if(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",36L)) {
• • • • • • if(LayersBase = OpenLibrary("layers.library",36L)) {
• • • • • • • • if(UtilityBase = OpenLibrary("utility.library",36L)) {
• • • • • • • • • • if(pMoveBase = (struct ClassLibrary *)OpenLibrary("movers/moveclass",0L)) {
• • • • • • • • • • • • if(pClass = MakeClass("icon.move",NULL,pMoveBase->cl_Class
• • • • • • • • • • • • ,sizeof(struct IconMove_InstData),0)) {
• • • • • • • • • • • • • • pClass->cl_Dispatcher.h_Entry = EnterClassLibrary;
• • • • • • • • • • • • • • pClass->cl_Dispatcher.h_SubEntry = (ULONG (*)())IconMove_Dispatch;
• • • • • • • • • • • • • • pClass->cl_Dispatcher.h_Data = pClassBase; // So that EnterClassLibrary() works.
• • • • • • • • • • • • • • pClassBase->cl_Class = pClass; // So that ClassLibrary openers can find pClass.
• • • • • • • • • • • • • • AddClass(pClass);
• • • • • • • • • • • • • • return(TRUE); // Opened successfully.
• • • • • • • • • • • • /* end if */ }
• • • • • • • • • • • • CloseLibrary((struct Library *)pMoveBase);
• • • • • • • • • • /* end if */ }
• • • • • • • • • • CloseLibrary(UtilityBase);
• • • • • • • • /* end if */ }
• • • • • • • • CloseLibrary(LayersBase);
• • • • • • /* end if */ }
• • • • • • CloseLibrary((struct Library *)GfxBase);
• • • • /* end if */ }
• • • • CloseLibrary((struct Library *)IntuitionBase);
• • /* end if */ }
• • return(FALSE); // Failed to open.
/* end Class_Init() */ }

void __saveds __asm Class_Expunge(register __a6 struct ClassLibrary *pClassBase) {
• • FreeClass(pClassBase->cl_Class);
• • CloseLibrary((struct Library *)pMoveBase);
• • CloseLibrary(UtilityBase);
• • CloseLibrary(LayersBase);
• • CloseLibrary((struct Library *)GfxBase); // This will be needed for improved version.
• • CloseLibrary((struct Library *)IntuitionBase);
/* end Class_Expunge() */ }

ULONG __saveds __asm IconMove_Dispatch(register __a0 Class *pClass,register
__a2 Object *pObject,register __a1 Msg pMsg) {
• • switch(pMsg->MethodID) {
• • case OM_NEW:
• • • • return(IconMove_New(pClass,pObject,(struct opSet *)pMsg));
• • case ZM_REMOVEMOVER: // This is sent by application.
• • • • return(IconMove_RemoveMover(pClass,pObject,(struct zpRemoveMover *)pMsg));
• • case ZM_HANDLEINPUT: // This is sent by MouseZone commodity.
• • • • return(IconMove_HandleInput(pClass,pObject,(struct zpInput *)pMsg));
• • case ZM_DELAYEDRENDER: // This is sent by MouseZone commodity at our request.
• • • • return(IconMove_DelayedRender(pClass,pObject,(struct zpInput *)pMsg));
• • default:
• • • • return(DoSuperMethodA(pClass,pObject,pMsg));
• • /* end switch */ }
/* end IconMove_Dispatch() */ }

ULONG IconMove_New(Class *pClass,Object *pTrueClass,struct opSet *pMsg) {
• • Object *pObject;
• • struct IconMove_InstData *pData;
• • if(pObject = (Object *)DoSuperMethodA(pClass,pTrueClass,(Msg)pMsg)) {
• • • • pData = INST_DATA(pClass,pObject);
• • • • pData->imid_Screen = NULL; // So that IconMove_HandleInput will create new layer.
• • • • pData->imid_Image.NextImage = NULL; // Don't want other images attached.
• • • • pData->imid_Image.LeftEdge = (WORD)GetTagData(IA_Left,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.TopEdge = (WORD)GetTagData(IA_Top,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.Width = (WORD)GetTagData(IA_Width,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.Height = (WORD)GetTagData(IA_Height,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.Depth = (WORD)GetTagData(I2A_Depth,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.ImageData = (UWORD *)GetTagData(IA_Data,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.PlanePick = (UBYTE)GetTagData(I2A_PlanePick,0,pMsg->ops_AttrList);
• • • • pData->imid_Image.PlaneOnOff = (UBYTE)GetTagData(I2A_PlaneOnOff,0,pMsg->ops_AttrList);
• • /* end if */ }
• • return((ULONG)pObject);
/* end IconMove_New() */ }

ULONG IconMove_RemoveMover(Class *pClass,Object *pObject,struct zpRemoveMover *pMsg) {
• • struct IconMove_InstData *pData = INST_DATA(pClass,pObject);
• • ULONG result;
• • result = DoSuperMethodA(pClass,pObject,(Msg)pMsg); // Removes mover from pZonesLock.
• • if(pData->imid_Screen) {
• • • • LockLayerInfo(&pData->imid_Screen->LayerInfo);
• • • • DeleteLayer(NULL,pData->imid_FakeLayer); // Only valid if imid_Screen is.
• • • • UnlockLayerInfo(&pData->imid_Screen->LayerInfo);
• • • • UnlockPubScreen(NULL,pData->imid_Screen);
• • • • pData->imid_Screen = NULL;
• • /* end if */ }
• • return(result);
/* end IconMove_RemoveMover() */ }

ULONG IconMove_HandleInput(Class *pClass,Object *pObject,struct zpInput *pMsg) {
• • struct { WORD X,Y; } icon,delta;
• • struct Screen *screen;
• • struct IconMove_InstData *pData = INST_DATA(pClass,pObject);
• • if(pMsg->zpi_Screen != pData->imid_Screen) {
• • • • if(pData->imid_Screen) {
• • • • • • LockLayerInfo(&pData->imid_Screen->LayerInfo);
• • • • • • DeleteLayer(NULL,pData->imid_FakeLayer); // Only valid if imid_Screen is.
• • • • • • UnlockLayerInfo(&pData->imid_Screen->LayerInfo);
• • • • • • UnlockPubScreen(NULL,pData->imid_Screen);
• • • • • • pData->imid_Screen = NULL;
• • • • /* end if */ }
• • • • if(pMsg->zpi_PubScreenName) {
• • • • • • if(screen = LockPubScreen(pMsg->zpi_PubScreenName)) {
• • • • • • • • icon.X = pMsg->zpi_Mouse.X + pData->imid_Image.LeftEdge;
• • • • • • • • icon.Y = pMsg->zpi_Mouse.Y + pData->imid_Image.TopEdge;
• • • • • • • • LockLayerInfo(&screen->LayerInfo);
• • • • • • • • pData->imid_FakeLayer = CreateUpfrontLayer(&screen->LayerInfo,&screen->BitMap
• • • • • • • • ,icon.X,icon.Y,icon.X + pData->imid_Image.Width - 1
• • • • • • • • ,icon.Y + pData->imid_Image.Height - 1,LAYERSIMPLE,NULL);
• • • • • • • • UnlockLayerInfo(&screen->LayerInfo);
• • • • • • • • if(pData->imid_FakeLayer) {
• • • • • • • • • • pData->imid_Screen = screen;
• • • • • • • • • • pData->imid_RastPort = screen->RastPort; // Copy rastport.
• • • • • • • • • • return(ZMR_DELAYEDRENDER);
• • • • • • • • /* end if */ }
• • • • • • /* end if */ }
• • • • /* end if */ }
• • }else if(pData->imid_Screen) {
• • • • icon.X = pMsg->zpi_Mouse.X + pData->imid_Image.LeftEdge;
• • • • icon.Y = pMsg->zpi_Mouse.Y + pData->imid_Image.TopEdge;
• • • • delta.X = icon.X - pData->imid_FakeLayer->bounds.MinX;
• • • • delta.Y = icon.Y - pData->imid_FakeLayer->bounds.MinY;
• • • • if(delta.X || delta.Y) {
• • • • • • MoveLayer(NULL,pData->imid_FakeLayer,delta.X,delta.Y);
• • • • • • UpfrontLayer(NULL,pData->imid_FakeLayer);
• • • • • • return(ZMR_DELAYEDRENDER);
• • • • /* end if */ }
• • /* end if */ }
• • return(ZMR_KEEPHANDLING);
/* end IconMove_Dispatch() */ }

ULONG IconMove_DelayedRender(Class *pClass,Object *pObject,struct zpInput *pMsg) {
• • struct IconMove_InstData *pData = INST_DATA(pClass,pObject);
• • DrawImage(&pData->imid_RastPort,&pData->imid_Image,pMsg->zpi_Mouse.X,pMsg->zpi_Mouse.Y);
• • return(ZMR_KEEPHANDLING);
/* end IconMover_DelayedRender() */ }

Last edited by gonegahgah on 04-Oct-2024 at 06:52 AM.

 Status: Offline
Profile     Report this post  

[ home ][ about us ][ privacy ] [ forums ][ classifieds ] [ links ][ news archive ] [ link to us ][ user account ]
Copyright (C) 2000 - 2019 Amigaworld.net.
Amigaworld.net was originally founded by David Doyle