home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 3 / AACD03.BIN / AACD / Programming / Triton / Source / classes / image.c < prev    next >
C/C++ Source or Header  |  1998-05-23  |  5KB  |  143 lines

  1. /*
  2.  *  OpenTriton -- A free release of the triton.library source code
  3.  *  Copyright (C) 1993-1998  Stefan Zeiger
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20.  
  21.  
  22. /****** triton.library/class_Image ******
  23. *
  24. *   NAME    
  25. *    class_Image -- An image (V2)
  26. *
  27. *   SUPERCLASS
  28. *    class_DisplayObject
  29. *
  30. *   SYNOPSIS
  31. *    TROB_Image
  32. *
  33. *   ATTRIBUTES
  34. *    <Default>        : <Image>
  35. *                       [create]
  36. *    TRAT_Flags       : ULONG flags
  37. *                       - TRIM_BOOPSI : <Default> is a pointer to a
  38. *                                       struct IClass BOOPSI image class.
  39. *                       [create]
  40. *    TRAT_MinWidth    : Minimum image width in pixels. Defaults to
  41. *                       the image button height.
  42. *                       [create, set]
  43. *    TRAT_MinHeight   : Minimum image height in pixels. Defaults to
  44. *                       the image button height.
  45. *                       [create, set]
  46. *
  47. ******/
  48.  
  49.  
  50. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  51. //////////////////////////////////////////////////////////////////////////////////////// Include our stuff //
  52. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  53.  
  54. #define TR_THIS_IS_TRITON
  55.  
  56. #include <ctype.h>
  57. #include <dos.h>
  58. #include <utility/hooks.h>
  59. #include <clib/alib_protos.h>
  60. #include <libraries/triton.h>
  61. #include <clib/triton_protos.h>
  62. #include "/internal.h"
  63. #include "image.def"
  64.  
  65.  
  66. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  67. ////////////////////////////////////////////////////////////////////////////////////////////// Object data //
  68. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  69.  
  70. #define OBJECT (&(object->DO.O))
  71. #define DISPLAYOBJECT (&(object->DO))
  72. #define IMAGE object
  73.  
  74.  
  75. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  76. ////////////////////////////////////////////////////////////////////////////////////////////////// Methods //
  77. /////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78.  
  79. TR_METHOD(Image,NEW,NewData)
  80. {
  81.   if(!TRDP_DisplayObject_NEW(object,messageid,data,metaclass->trc_SuperClass)) return NULL;
  82.   if(!(DISPLAYOBJECT->MinHeight)) DISPLAYOBJECT->MinHeight=(data->project->trp_PropFont->tf_YSize)+6;
  83.   if(!(DISPLAYOBJECT->MinWidth)) DISPLAYOBJECT->MinWidth=(data->project->trp_PropFont->tf_YSize)+6;
  84.   DISPLAYOBJECT->XResize=TRUE;
  85.   DISPLAYOBJECT->YResize=TRUE;
  86.  
  87.   return (ULONG)object;
  88. }
  89.  
  90.  
  91. TR_SIMPLEMETHOD(Image,REFRESH)
  92. {
  93.   DrawImageState(OBJECT->Project->trp_Window->RPort,
  94.          IMAGE->Image,
  95.          DISPLAYOBJECT->Left,
  96.          DISPLAYOBJECT->Top,
  97.          IDS_NORMAL,
  98.          OBJECT->Project->trp_DrawInfo);
  99.   return 1L;
  100. }
  101.  
  102.  
  103. TR_METHOD(Image,INSTALL,InstallData)
  104. {
  105.   struct Image *image;
  106.  
  107.   TRDP_DisplayObject_INSTALL(object,messageid,data,metaclass->trc_SuperClass);
  108.   if(!(image=(struct Image *)NewObject(IMAGE->IClass,NULL,
  109.                        IA_Height,      DISPLAYOBJECT->Height,
  110.                        IA_Width,       DISPLAYOBJECT->Width,
  111.                        SYSIA_DrawInfo, OBJECT->Project->trp_DrawInfo,
  112.                        TAG_END))) return NULL;
  113.   IMAGE->Image=image;
  114.  
  115.   return TR_DIRECTMETHODCALL(Image,REFRESH);
  116. }
  117.  
  118.  
  119. TR_METHOD(Image,SETATTRIBUTE,SetAttributeData)
  120. {
  121.   switch(data->attribute)
  122.     {
  123.     case TRAT_MinWidth:
  124.       DISPLAYOBJECT->MinWidth=data->value;
  125.       return 1;
  126.     case TRAT_MinHeight:
  127.       DISPLAYOBJECT->MinHeight=data->value;
  128.       return 1;
  129.     case 0:
  130.       IMAGE->IClass=(struct IClass *)(data->value);
  131.       return 1;
  132.     default:
  133.       return TRDP_DisplayObject_SETATTRIBUTE(object,messageid,data,metaclass->trc_SuperClass);
  134.     }
  135. }
  136.  
  137.  
  138. TR_SIMPLEMETHOD(Image,REMOVE)
  139. {
  140.   if(IMAGE->Image) DisposeObject((Object *)(IMAGE->Image));
  141.   return 1L;
  142. }
  143.