Loading Mouse Pointers - (Fixed)

AmigaOne X1000 platform specific issues.

Loading Mouse Pointers - (Fixed)

Postby gonegahgah » Thu Aug 15, 2013 2:52 am

I found some code at http://openamiga.org/?function=viewpage&pageid=23.
This helped me to write the code at the bottom.

There seems to be something missing. I say that because when I use this I get a corrupt image.
Now the funny thing is if I run OWB the corruption goes away.
I can do this with my app open and the corruption just automatically disappears in my app?

So OWB is obviously doing something to correct something in the background that fixes things live?

Can someone help me?

Code:
Code: Select all
   pSelf->ad_TextPointerIcon = pSelf->ad_IIcon->GetIconTags(NULL,
      ICONGETA_GetDefaultName,    "textpointer",
      ICONGETA_FailIfUnavailable, TRUE,
      TAG_DONE);
   pSelf->ad_TextPointer = MakePointerFromIcon(pSelf,
      pSelf->ad_TextPointerIcon, pSelf->ad_Window->WScreen);

Object *MakePointerFromIcon(struct AppData *pSelf,
   struct DiskObject *pIcon, struct Screen *pScreen)
{
   UBYTE *pIconImage;
   int32 iWidth, iHeight;

   // Remap icon image; actually I don't understand why remapping is even required for a sprite?
   pSelf->ad_IIcon->LayoutIcon(pIcon, (struct Screen *) ~0UL,
      TAG_DONE);

   // Get the image data and its width and height.
   pSelf->ad_IIcon->IconControl(pIcon,
      ICONCTRLA_GetImageData1, &pIconImage,
      ICONCTRLA_GetWidth,      &iWidth,
      ICONCTRLA_GetHeight,     &iHeight,
      TAG_DONE);
   if(pIconImage)
   {
      uint32 iXOffset, iYOffset;

      // Get the XOffset specified in the tooltypes.
      char *pFind = (char *) pSelf->ad_IIcon->FindToolType(
         pIcon->do_ToolTypes, "XOFFSET");
      IDOS->StrToLong(pFind, &iXOffset); // Defaults to 0.
      // Get the YOffset specified in the tooltypes.
      pFind = (char *) pSelf->ad_IIcon->FindToolType(
         pIcon->do_ToolTypes, "YOFFSET");
      IDOS->StrToLong(pFind, &iYOffset); // Defaults to 0.

      // Create the pointer object that you can set for window.
      Object *pPointer =
         pSelf->ad_IIntuition->NewObject(NULL, "pointerclass",
         POINTERA_ImageData, pIconImage,
         POINTERA_Width,     iWidth,
         POINTERA_Height,    iHeight,
         POINTERA_XOffset,   -iXOffset,
         POINTERA_YOffset,   -iYOffset,
         TAG_DONE);

      return pPointer;
   }
   return NULL;
}
Last edited by gonegahgah on Thu Aug 15, 2013 12:11 pm, edited 1 time in total.
User avatar
gonegahgah
 
Posts: 43
Joined: Fri May 31, 2013 5:22 pm

Re: Loading Mouse Pointers

Postby gonegahgah » Thu Aug 15, 2013 12:10 pm

Case of spot the difference I guess...
Seems I do have to specify POINTERA_BitMap which I thought I could get by without doing so...
All works fine now.

I am curious why I would get the pointer imagery from OWB coming through?
It wasn't just the text pointer but whatever pointer over change had occurred last.
I could only find a text pointer and a hand pointer in OWB.
If either were the last over area pointer image they would then also appear in my app when I moved the mouse over a pointer.zone.

Wonder why that would be?
I also wonder why the default fall back icon was an indistinct nothing and then become whatever OWB last changed its pointer to?
How does my app pull across something brought into being by another app?

Anyhow, hopefully no-one will benefit from seeing my cheesy looking fall-back mouse pointer. :/
I guess that was what someone else on some other forum was talking about now...
I think the user would prefer the standard default pointer than my cheesy attempt at one :O

Ah, well, all very amusing 8().
They are unlikely to see the poor fallback substitute anyway so I won't fret. LOL.
User avatar
gonegahgah
 
Posts: 43
Joined: Fri May 31, 2013 5:22 pm


Return to Platform: AmigaOne X1000

Who is online

Users browsing this forum: No registered users and 4 guests