Logo18.191.140.222 
  News  Recent  Stats  Forums  Discord  Contact
  Menu
 Username

 Password


   Register here

 Main menu
   BBCode test
 
 Content
   About OpenAmiga
   Guidelines
   Definitions
   SVN Access
   Licenses
   IRC channel
   Links
   ToDo List
   List Content
 
 Projects
   Suggested (1)
   Open (11)
   Assigned (27)
   Pending (0)
   Finished (7)
   Closed (5)
 
 Categories
   Cli (2)
   Datatype (9)
   Drivers (3)
   System (15)
   Workbench (16)
  Global pointers
[Print][View Files]
Guideline - Mouse pointers
<- Back to guidelines

Content
    
- Intro
- Example of use
- Load and Discard functions
- Example fallback bitmap


Intro
Openamiga encourages its developers to use the mouse pointers defined in the Extended default mouse pointer types project where ever possible to heighten the user experience.

You can download the pointers here.

Below is some example code that can be used for this purpose.

Points to remember:
- Always reset the mouse pointer before closing your window.
    This includes iconification of your window
- Always reset the mouse pointer before discarding your loaded pointers.

This will reset your pointer to the normal system pointer:
IIntuition->SetWindowPointer(window, TAG_DONE);


Example of use

 ...

 struct DiskObject *diskObject;
 struct Object *pointrObj;
 STRPTR name = "cellpointer";  // do not specify pointer filename or path
                               // simply state the name

 ...

 LoadPointer(name,
             &diskObject,
             &pointerObj,
             &fallbackPointer,
             screen);

 ...
 
 IIntuition->SetWindowPointer(window, WA_Pointer, pointerObj, TAG_DONE);

 ...

 IIntuition->SetWindowPointer(window, TAG_DONE); // reset pointer

 ...

 DiscardPointer(&diskObject,&pointerObj); // Must discard the loaded data

 ...



Load and Discard functions
void LoadPointer(STRPTR name, struct DiskObject **diskObject,
                 struct Object **pointerObj, struct BitMap *fallback,
                 struct Screen *screen)
{
 *pointerObj=NULL;

 *diskObject = IIcon->GetIconTags(NULL, ICONGETA_GetDefaultName, name, ICONGETA_FailIfUnavailable, TRUE, TAG_DONE);

 if(*diskObject)
 {
  UBYTE *image = NULL;
  int32 w,h;
  char *xoffset_tool,*yoffset_tool;
  int32 xoffset=0, yoffset=0;
  IIcon->LayoutIcon(*diskObject,screen,TAG_DONE);
  IIcon->IconControl(*diskObject,ICONCTRLA_GetImageData1,&image,
                                 ICONCTRLA_GetWidth,&w,
                                 ICONCTRLA_GetHeight,&h,
                     TAG_DONE);
                          
  if((xoffset_tool = (char *)IIcon->FindToolType((*diskObject)->do_ToolTypes, (STRPTR)"XOFFSET")))
  {
   char *tmp;
   xoffset = strtol(xoffset_tool,&tmp,0);
  }
  
  if((yoffset_tool = (char *)IIcon->FindToolType((*diskObject)->do_ToolTypes, (STRPTR)"YOFFSET")))
  {
   char *tmp;
   yoffset = strtol(yoffset_tool,&tmp,0);
  }
  
  if(image)
  {
   *pointerObj = (struct Object *)IIntuition->NewObject(NULL,(STRPTR)"pointerclass",
    POINTERA_BitMap,fallback,
    POINTERA_ImageData,image,
    POINTERA_Width,w,
    POINTERA_Height,h,
    POINTERA_XOffset,-xoffset,
    POINTERA_YOffset,-yoffset,TAG_DONE);
  }
  else
  {
   *pointerObj = NULL;
  }
 }
}

void DiscardPointer(struct DiskObject **diskObject, struct Object **pointerObj)
{
 if(*pointerObj)
 {
  IIntuition->DisposeObject(*pointerObj);
 }
 
 if(*diskObject)
 {
  IIcon->FreeDiskObject(*diskObject);
 }
}


Example fallback bitmap
static UWORD fallbackPointerData[]=
{
 0x0400,0x0e00,0x0e00,0x0e00,0x0e00,0x0f80,0x0fe0,0x4ff8,
 0xeff8,0x7ff8,0x3ff8,0x1ff8,0x1ff8,0x1ff8,0x0ff0,0x00f0,
 
 0x0400,0x0a00,0x0a00,0x0a00,0x0a00,0x0b80,0x0ae0,0x4ab8,
 0xa828,0x5808,0x2808,0x1008,0x1008,0x1008,0x0810,0x0ff0
};

static struct BitMap fallbackPointer=
{
 2,16,0,2,0,{(PLANEPTR)fallbackPointerData,(PLANEPTR)(fallbackPointerData+16)}
};
Open Amiga project website, Created in 2008 by Björn Hagström