home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mnicon2.zip / MNIcon.c < prev    next >
Text File  |  1996-02-07  |  5KB  |  169 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: MNIcon.c.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitc: 1.24
  8.  */
  9.  
  10. /*
  11.  * MNIcon class release 2.0 (02/06/96) by Makoto Nagata
  12.  */
  13.  
  14. #define MNIcon_Class_Source
  15. #include "MNIcon.ih"
  16.  
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  20.  
  21. #include <wpshadow.h>
  22.  
  23. /*******************************************************************************
  24.  
  25.     Class Data
  26.  
  27. *******************************************************************************/
  28.  
  29. char szClassName[] = "MNIcon";
  30.  
  31. /*******************************************************************************
  32.  
  33.     Get Original Object
  34.  
  35.     - if pObject is a shadow, returns the original
  36.  
  37. *******************************************************************************/
  38.  
  39. WPObject* GetOriginalObject(WPObject* pObject)
  40. {
  41.     if (pObject)
  42.     {
  43.         if (_somIsA(pObject, _WPShadow))
  44.         {
  45.             return _wpQueryShadowedObject(pObject, FALSE);
  46.         }
  47.     }
  48.  
  49.     return pObject;
  50. }
  51.  
  52. /*******************************************************************************
  53.  
  54.     _wpDragOver
  55.  
  56.     - objects are droppable only if it is an object other than MNIcon
  57.  
  58. *******************************************************************************/
  59.  
  60. #undef SOM_CurrentClass
  61. #define SOM_CurrentClass SOMInstance
  62.  
  63. SOM_Scope MRESULT   SOMLINK mnicon_wpDragOver(MNIcon *somSelf,
  64.         HWND hwndCnr,
  65.         PDRAGINFO pdrgInfo)
  66. {
  67.     PDRAGITEM pdrgItem;
  68.     ULONG ulIndex;
  69.     WPObject* object;
  70.  
  71.     /* MNIconData *somThis = MNIconGetData(somSelf); */
  72.     MNIconMethodDebug("MNIcon","mnicon_wpDragOver");
  73.  
  74.     for (ulIndex = 0; ulIndex < DrgQueryDragitemCount(pdrgInfo); ulIndex ++)
  75.     {
  76.         pdrgItem = DrgQueryDragitemPtr(pdrgInfo, ulIndex);
  77.  
  78.         if (!DrgVerifyRMF(pdrgItem, "DRM_OBJECT", "DRF_OBJECT"))
  79.         {
  80.             return MRFROM2SHORT(DOR_NEVERDROP, DO_UNKNOWN);
  81.         }
  82.         else
  83.         {
  84.             object = GetOriginalObject((WPObject *)OBJECT_FROM_PREC(pdrgItem->ulItemID));
  85.  
  86.             if ((!object) || (_somIsA(object, _MNIcon)))
  87.             {
  88.                 return MRFROM2SHORT(DOR_NEVERDROP, DO_UNKNOWN);
  89.             }
  90.         }
  91.     }
  92.  
  93.     return MRFROM2SHORT(DOR_DROP, DO_UNKNOWN);
  94. }
  95.  
  96. /*******************************************************************************
  97.  
  98.     _wpDrop
  99.  
  100.     - sets the icon of the dropped objects using _wpSetIconData
  101.     - uses fixed size buffer because _wpQueryIconData doesn't give me the size!
  102.     - works only if the IconData type is ICON_DATA (which is the case for *.ICO)
  103.  
  104. *******************************************************************************/
  105.  
  106. #define MAXICONINFO 8192
  107.  
  108. #undef SOM_CurrentClass
  109. #define SOM_CurrentClass SOMInstance
  110.  
  111. SOM_Scope MRESULT   SOMLINK mnicon_wpDrop(MNIcon *somSelf,
  112.         HWND hwndCnr,
  113.         PDRAGINFO pdrgInfo,
  114.         PDRAGITEM pdrgItem)
  115. {
  116.     WPObject* object;
  117.     PICONINFO pIconInfo;
  118.     ULONG ulSize;
  119.  
  120.     /* MNIconData *somThis = MNIconGetData(somSelf); */
  121.     MNIconMethodDebug("MNIcon","mnicon_wpDrop");
  122.  
  123.     if (DrgVerifyRMF(pdrgItem, "DRM_OBJECT", "DRF_OBJECT"))
  124.     {
  125.         object = GetOriginalObject((WPObject *)OBJECT_FROM_PREC(pdrgItem->ulItemID));
  126.  
  127.         if ((object) && (!_somIsA(object, _MNIcon)))
  128.         {
  129.             ulSize = MAXICONINFO;
  130.  
  131.             if (pIconInfo = (PICONINFO)_wpAllocMem(somSelf, ulSize, NULL))
  132.             {
  133.                 if (_wpQueryIconData(somSelf, pIconInfo))
  134.                 {
  135.                     if (pIconInfo->fFormat == ICON_DATA)
  136.                     {
  137.                         pIconInfo->cb = sizeof(ICONINFO) + pIconInfo->cbIconData;
  138.                         pIconInfo->pIconData = ((PBYTE)pIconInfo) + sizeof(ICONINFO);
  139.  
  140.                         _wpSetIconData(object, pIconInfo);
  141.                     }
  142.                 }
  143.                 _wpFreeMem(somSelf, (PBYTE)pIconInfo);
  144.             }
  145.         }
  146.     }
  147.  
  148.     return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
  149. }
  150.  
  151. /*******************************************************************************
  152.  
  153.     _wpclsQueryTitle
  154.  
  155. *******************************************************************************/
  156.  
  157. #undef SOM_CurrentClass
  158. #define SOM_CurrentClass SOMMeta
  159.  
  160. SOM_Scope PSZ   SOMLINK mniconM_wpclsQueryTitle(M_MNIcon *somSelf)
  161. {
  162.     /* M_MNIconData *somThis = M_MNIconGetData(somSelf); */
  163.     
  164.     M_MNIconMethodDebug("M_MNIcon","mniconM_wpclsQueryTitle");
  165.  
  166.     return szClassName;
  167. }
  168.  
  169.