home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warptlk3.zip / TOOLKIT / SAMPLES / WPS / WSFILE / WSFOLDER.C < prev    next >
Text File  |  1995-08-24  |  26KB  |  877 lines

  1.  
  2. /*
  3.  * This file was generated by the SOM Compiler.
  4.  * FileName: wsfolder.c.
  5.  * Generated using:
  6.  *     SOM Precompiler spc: 1.22
  7.  *     SOM Emitter emitc: 1.24
  8.  */
  9.  
  10. /******************************************************************************
  11. *
  12. *  Module Name: WSFOLDER.C
  13. *
  14. *  OS/2 Work Place Shell Sample Program
  15. *
  16. *  Copyright (C) 1994, 1995 IBM Corporation
  17. *
  18. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  19. *      sample code created by IBM Corporation. This sample code is not
  20. *      part of any standard or IBM product and is provided to you solely
  21. *      for  the purpose of assisting you in the development of your
  22. *      applications.  The code is provided "AS IS", without
  23. *      warranty of any kind.  IBM shall not be liable for any damages
  24. *      arising out of your use of the sample code, even if they have been
  25. *      advised of the possibility of such damages.
  26. *
  27. *  Entry Points:
  28. *
  29. *     Class Methods:
  30. *
  31. *        wsfoldM_clsQueryModuleHandle
  32. *
  33. *     Overridden Class Methods:
  34. *
  35. *        wsfoldM_wpclsInitData
  36. *        wsfoldM_wpclsQueryTitle
  37. *        wsfoldM_wpclsQueryIconData
  38. *        wsfoldM_wpclsQueryIconDataN
  39. *        wsfoldM_wpclsQueryDefaultView
  40. *        wsfoldM_wpclsQueryDefaultHelp
  41. *        wsfoldM_wpclsQueryStyle
  42. *
  43. *     Instance Methods:
  44. *
  45. *        wsfold_closeViews
  46. *        wsfold_queryFirstViewHandle
  47. *        wsfold_setFirstViewHandle
  48. *
  49. *     Overridden Instance Methods:
  50. *
  51. *        wsfold_wpOpen
  52. *        wsfold_wpClose
  53. *        wsfold_wpMenuItemHelpSelected
  54. *        wsfold_wpMenuItemSelected
  55. *        wsfold_wpModifyPopupMenu
  56. *        wsfold_wpDragOver
  57. *        wsfold_wpDrop
  58. *        wsfold_wpDeleteFromObjUseList
  59. *        wsfold_wpQueryConcurrentView
  60. *        wsfold_wpInitData
  61. *        wsfold_wpPrintObject
  62. *        wsfold_wpAddToContent
  63. *        wsfold_wpDeleteFromContent
  64. *
  65. *     Non-Method Functions:
  66. *
  67. *
  68. ******************************************************************************/
  69.  
  70. #define INCL_DOS
  71. #define INCL_PM
  72. #include <os2.h>
  73. #include <string.h>
  74.  
  75. #define WSFOLDER_Class_Source
  76. #define M_WSFOLDER_Class_Source
  77. #include "wsfolder.ih"
  78. /* CSC2IDL:  REMOVED after .csc -> .idl conversion:   #include "wsfolder.ph" */
  79.  
  80. /***************** GLOBAL/STATIC (NON-INSTANCE) DATA SECTION ******************
  81. *****                                                                     *****
  82. *****    This data shouldn't be changed by instance methods or it will    *****
  83. *****    effect all instances!  Any variables that are specific (unique   *****
  84. *****    values) for each instance of this object should be declared as   *****
  85. *****  instance data or dynamically allocated and stored as window data.  *****
  86. *****                                                                     *****
  87. *****      This global data should be declared as class instance data     *****
  88. *****    if it will change after initialization.  In this case, it will   *****
  89. *****                  be accessed through class methods.                 *****
  90. *****                                                                     *****
  91. ******************************************************************************/
  92.  
  93.    UCHAR      szWSFOLDERClassTitle[CCHMAXPATH] = "";
  94.    CHAR       szHelpLibrary[] =          "wsfolder.hlp";
  95.    HMODULE    hmod = NULLHANDLE;
  96.  
  97. /*
  98.  *  METHOD: closeViews                                     ( ) PRIVATE
  99.  *                                                         (X) PUBLIC
  100.  *  DESCRIPTION:
  101.  *
  102.  *    Close all but the first of the currently open views of a wsfolder object.
  103.  *
  104.  *  NOTE: There is a "Close Views" option on the context menu, that will
  105.  *         call this method
  106.  */
  107. SOM_Scope void   SOMLINK wsfold_closeViews(WSFOLDER *somSelf)
  108. {
  109.     PUSEITEM  pUseItem, pUseItemNext;
  110.     PVIEWITEM pViewItem;
  111.     HWND      hwndView;
  112.     typedef struct _HANDLENODE
  113.     {
  114.        LHANDLE handle;
  115.        struct _HANDLENODE * pNextHandle;
  116.     } HANDLENODE;
  117.     HANDLENODE *pHandles = NULL;
  118.     HANDLENODE *pTemp = NULL;
  119.  
  120.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  121.     WSFOLDERMethodDebug("WSFOLDER","wsfold_closeViews");
  122.  
  123.  
  124.     /* go through use list looking for OPENVIEW use items, as you
  125.      * find one, add view item's handle to a list
  126.      */
  127.     for ( pUseItem = _wpFindUseItem(somSelf , USAGE_OPENVIEW, NULL);
  128.           pUseItem;
  129.           pUseItem = _wpFindUseItem(somSelf , USAGE_OPENVIEW, pUseItem) )
  130.     {
  131.        if (pTemp = (HANDLENODE*)_wpAllocMem(somSelf,sizeof(HANDLENODE),NULL))
  132.        {
  133.           pViewItem = (PVIEWITEM)(pUseItem + 1);
  134.           pTemp->handle = pViewItem->handle;       /* hwnd of view */
  135.           pTemp->pNextHandle = pHandles;
  136.           pHandles = pTemp;
  137.        }
  138.     }
  139.  
  140.     /* go through list of handles we just found and close any
  141.      * views other than the first one
  142.      */
  143.     pTemp = pHandles;
  144.     while (pTemp)
  145.     {
  146.        if (_queryFirstViewHandle(somSelf) != (HWND)pTemp->handle )
  147.        {
  148.           WinSendMsg( (HWND)pTemp->handle, WM_CLOSE, 0, 0);
  149.        }
  150.        pTemp = pTemp->pNextHandle;
  151.     }
  152.  
  153.     /* free our list */
  154.     while (pHandles)
  155.     {
  156.        pTemp = pHandles;
  157.        pHandles = pTemp->pNextHandle;
  158.        _wpFreeMem(somSelf,(PBYTE)pTemp);
  159.     }
  160.  
  161. }
  162.  
  163. /*
  164.  *
  165.  *   METHOD: queryFirstViewHandle                           ( ) PRIVATE
  166.  *                                                          (X) PUBLIC
  167.  *   DESCRIPTION:
  168.  *
  169.  *     return the handle of the view that was opened first of the
  170.  *     currently open views of this wsfolder object.
  171.  *
  172.  */
  173. SOM_Scope HWND   SOMLINK wsfold_queryFirstViewHandle(WSFOLDER *somSelf)
  174. {
  175.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  176.     WSFOLDERMethodDebug("WSFOLDER","wsfold_queryFirstViewHandle");
  177.  
  178.     return _hwndFirstView;
  179. }
  180.  
  181. /*
  182.  *
  183.  *   METHOD: setFirstViewHandle                             ( ) PRIVATE
  184.  *                                                          (X) PUBLIC
  185.  *   DESCRIPTION:
  186.  *
  187.  *     Do special processing on first open of folder
  188.  *
  189.  *   PARAMETERS:
  190.  *
  191.  *      HWND - hwnd of the first of multiple currently opened
  192.  *             views of this object
  193.  *
  194.  *   RETURNS:
  195.  *
  196.  *      TRUE - hwnd set successfully
  197.  *      FALSE - first hwnd wasn't set successfully
  198.  *
  199.  */
  200. SOM_Scope BOOL   SOMLINK wsfold_setFirstViewHandle(WSFOLDER *somSelf,
  201.                 HWND hwndView)
  202. {
  203.     BOOL rc = TRUE;
  204.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  205.     WSFOLDERMethodDebug("WSFOLDER","wsfold_setFirstViewHandle");
  206.  
  207.     if (hwndView != NULLHANDLE)
  208.     {
  209.       if (_hwndFirstView == NULLHANDLE)  /* no current first view */
  210.       {
  211.          _hwndFirstView = hwndView;     /* setting to a first view handle */
  212.       }
  213.       else
  214.       {
  215.          /* a non-null _hwndFirstView can only be wiped out by resetting it
  216.           * to NULLHANDLE, not to another handle.  This prevents a
  217.           * misuse of this method
  218.           */
  219.          rc = FALSE;
  220.       }
  221.  
  222.     }
  223.     else      /* wiping out first view handle */
  224.     {
  225.        _hwndFirstView = NULLHANDLE;
  226.     }
  227.  
  228.     return rc;
  229. }
  230.  
  231. /*
  232.  *  METHOD: wpOpen                                         ( ) PRIVATE
  233.  *                                                         (X) PUBLIC
  234.  *  DESCRIPTION:
  235.  *
  236.  *    Do special processing on first open of folder
  237.  */
  238. SOM_Scope HWND   SOMLINK wsfold_wpOpen(WSFOLDER *somSelf,
  239.                 HWND hwndCnr,
  240.                 ULONG ulView,
  241.                 ULONG param)
  242. {
  243.     HWND        hwndFromParentOpen = NULLHANDLE;
  244.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  245.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpOpen");
  246.  
  247.     if (_queryFirstViewHandle(somSelf) == NULLHANDLE)
  248.     {
  249.  
  250.        /* we ONLY want to do this on the FIRST open of the folder.
  251.         */
  252.        if (_wpPopulate(somSelf, NULLHANDLE, NULL, FALSE))
  253.         {
  254.            WPObject *Obj;
  255.            WPObject *LastFoundObj = NULL;
  256.  
  257.            /* loop through the contents of the folder, checking each to
  258.             * see if it is an instance of a WPFolder, we'll delete any
  259.             * WPFolders as a cleanup step
  260.             */
  261.            for ( Obj = _wpQueryContent(somSelf,NULL,(ULONG)QC_First);
  262.                  Obj;
  263.                  Obj = _wpQueryContent(somSelf, Obj, (ULONG) QC_Next ))
  264.            {
  265.               /* delete the last object found on the previous iteration
  266.                * of the loop (we couldn't delete it then, because we
  267.                * needed it at the top of the loop for this iteration)
  268.                */
  269.               if (LastFoundObj)
  270.               {
  271.                  _wpDelete(LastFoundObj,0);
  272.                  LastFoundObj = NULL;
  273.               }
  274.  
  275.               /* we want to make sure that all previously
  276.                * existing folders are deleted
  277.                */
  278.               if (_somIsA(Obj, _WPFolder))
  279.               {
  280.                  LastFoundObj = Obj;
  281.               }
  282.  
  283.            }  /* end for */
  284.  
  285.  
  286.            /* if there is still one object left to delete, do it now
  287.             */
  288.            if (LastFoundObj)
  289.            {
  290.               _wpDelete(LastFoundObj,0);
  291.               LastFoundObj = NULL;
  292.            }
  293.        } /* end if populate */
  294.     } /* end if first open */
  295.  
  296.     /* now, show the opened folder */
  297.     hwndFromParentOpen = parent_wpOpen(somSelf, hwndCnr, ulView, param);
  298.  
  299.     /* if this is the first open, set our global flag
  300.      */
  301.     if (_queryFirstViewHandle(somSelf) == NULLHANDLE)
  302.     {
  303.         _setFirstViewHandle(somSelf, hwndFromParentOpen);
  304.     }
  305.  
  306.     return hwndFromParentOpen;
  307. }
  308.  
  309. /*
  310.  *
  311.  *   METHOD: wpInitData                                     ( ) PRIVATE
  312.  *                                                          (X) PUBLIC
  313.  *   DESCRIPTION:
  314.  *
  315.  *     Set object's detail class to be WSFILE
  316.  *
  317.  */
  318.  
  319. SOM_Scope VOID   SOMLINK wsfold_wpInitData(WSFOLDER *somSelf)
  320. {
  321.     SOMClass * pClass;
  322.     somId      ClassId;
  323.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  324.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpInitData");
  325.  
  326.     parent_wpInitData(somSelf);
  327.     ClassId = SOM_IdFromString( "WSFILE" );
  328.     pClass = _somFindClass( SOMClassMgrObject, ClassId, 1, 1);
  329.     SOMFree(ClassId);         /* always free somIds */
  330.     _wpSetFldrDetailsClass(somSelf, pClass);
  331.     _wpSetFldrSortClass(somSelf, pClass);
  332. }
  333. /*
  334.  * METHOD: wpModifyPopupMenu                              ( ) PRIVATE
  335.  *                                                        (X) PUBLIC
  336.  * DESCRIPTION:
  337.  *
  338.  *   Add our extra option to the context menu to close all but first view
  339.  */
  340. SOM_Scope BOOL   SOMLINK wsfold_wpModifyPopupMenu(WSFOLDER *somSelf,
  341.                 HWND hwndMenu,
  342.                 HWND hwndCnr,
  343.                 ULONG iPosition)
  344. {
  345.     HMODULE    hmod = NULLHANDLE;
  346.     zString    zsPathName;
  347.  
  348.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  349.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpModifyPopupMenu");
  350.  
  351.     hmod = _clsQueryModuleHandle(_WSFOLDER);
  352.     if (hmod)
  353.     {
  354.        _wpInsertPopupMenuItems( somSelf, hwndMenu, 0, hmod, ID_CLOSEVIEWSMENU, 0);
  355.     }
  356.  
  357.     return (parent_wpModifyPopupMenu(somSelf,hwndMenu,hwndCnr,iPosition));
  358.  
  359. }
  360.  
  361. /*
  362.  * METHOD: wpMenuItemSelected                             ( ) PRIVATE
  363.  *                                                        (X) PUBLIC
  364.  * DESCRIPTION:
  365.  *
  366.  *   Process extra menu option that we added.
  367.  */
  368. SOM_Scope BOOL   SOMLINK wsfold_wpMenuItemSelected(WSFOLDER *somSelf,
  369.                 HWND hwndFrame,
  370.                 ULONG ulMenuId)
  371. {
  372.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  373.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpMenuItemSelected");
  374.  
  375.     if (ulMenuId == IDM_CLOSEVIEWS)
  376.     {
  377.        _closeViews(somSelf);
  378.        return(TRUE);
  379.     }
  380.     else
  381.     {
  382.        return (parent_wpMenuItemSelected(somSelf,hwndFrame,ulMenuId));
  383.     }
  384. }
  385.  
  386.  
  387. /*
  388.  *
  389.  *  METHOD: wpMenuItemHelpSelected                         ( ) PRIVATE
  390.  *                                                         (X) PUBLIC
  391.  *  DESCRIPTION:
  392.  *
  393.  *    Process help for the extra menu option that we added.
  394.  *
  395.  */
  396. SOM_Scope BOOL   SOMLINK wsfold_wpMenuItemHelpSelected(WSFOLDER *somSelf,
  397.                 ULONG MenuId)
  398. {
  399.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  400.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpMenuItemHelpSelected");
  401.  
  402.     switch( MenuId )
  403.     {
  404.        case IDM_CLOSEVIEWS:
  405.  
  406.           return(_wpDisplayHelp(somSelf,ID_HELP_CLOSEVIEWS,szHelpLibrary));
  407.           break;
  408.  
  409.        default:
  410.           break;
  411.     }
  412.  
  413.      return (parent_wpMenuItemHelpSelected(somSelf,MenuId));
  414. }
  415.  
  416. /*
  417.  *
  418.  *  METHOD: wpClose                                        ( ) PRIVATE
  419.  *                                                         (X) PUBLIC
  420.  *  DESCRIPTION:
  421.  *
  422.  *    When a folder object is closed, we will zero out its first view
  423.  *    instance variable, so that the next time it has a first view opened,
  424.  *    we can keep track of that.
  425.  *
  426.  */
  427. SOM_Scope BOOL   SOMLINK wsfold_wpClose(WSFOLDER *somSelf)
  428. {
  429.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  430.     BOOL          rcParentClose;
  431.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpClose");
  432.  
  433.     rcParentClose = parent_wpClose(somSelf);
  434.     _setFirstViewHandle(somSelf, NULLHANDLE);
  435.     return(rcParentClose);
  436. }
  437.  
  438. /*
  439.  * METHOD: wpDragOver                                     ( ) PRIVATE
  440.  *                                                        (X) PUBLIC
  441.  * DESCRIPTION:
  442.  *
  443.  *   Instances of class WSFOLDER are the only folders that accept a drop
  444.  *   of a WSFILE object.  This override returns DOR_DROP when a WSFILE
  445.  *   object is dragged over a WSFOLDER object.  The default meaning of
  446.  *   a drag will be changed to perform a COPY (instead of the default
  447.  *   being to MOVE the object)
  448.  */
  449. SOM_Scope MRESULT   SOMLINK wsfold_wpDragOver(WSFOLDER *somSelf,
  450.                 HWND hwndCnr,
  451.                 PDRAGINFO pdrgInfo)
  452. {
  453.     MRESULT   mr;
  454.     PDRAGITEM pDragItem;
  455.     ULONG     i;
  456.     ULONG     ulOurs = 0;
  457.  
  458.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  459.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDragOver");
  460.  
  461.     for (i = 0; i < pdrgInfo->cditem ; i++)
  462.     {
  463.        pDragItem = DrgQueryDragitemPtr(pdrgInfo,i);
  464.  
  465.        if (DrgVerifyRMF(pDragItem,"DRM_OUROWNSPECIAL","DRF_OBJECT"))
  466.        {
  467.           ulOurs++;
  468.        }
  469.     }
  470.  
  471.     if (ulOurs == 0)
  472.     {
  473.        mr = (parent_wpDragOver(somSelf,hwndCnr,pdrgInfo));
  474.     }
  475.     else
  476.     {
  477.        if (ulOurs == pdrgInfo->cditem)
  478.        {
  479.           mr = MRFROM2SHORT(DOR_DROP,
  480.                            (SHORT)((pdrgInfo->usOperation == DO_DEFAULT)
  481.                                    ? DO_COPY : pdrgInfo->usOperation));
  482.        }
  483.        else
  484.        {
  485.           mr = MRFROM2SHORT(DOR_NEVERDROP,DO_DEFAULT);
  486.        }
  487.     }
  488.     return mr;
  489. }
  490.  
  491. /*
  492.  * METHOD: wpDrop                                         ( ) PRIVATE
  493.  *                                                        (X) PUBLIC
  494.  * DESCRIPTION:
  495.  *
  496.  *   This override will be called after a drop of a WSFILE object, so that
  497.  *   the drop can actually be processed.
  498.  */
  499. SOM_Scope MRESULT   SOMLINK wsfold_wpDrop(WSFOLDER *somSelf,
  500.                 HWND hwndCnr,
  501.                 PDRAGINFO pdrgInfo,
  502.                 PDRAGITEM pdrgItem)
  503. {
  504.     ULONG     i;
  505.     PDRAGITEM pDragItem;
  506.  
  507.     /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  508.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDrop");
  509.  
  510.     for (i = 0; i < pdrgInfo->cditem ; i++)
  511.     {
  512.        pDragItem = DrgQueryDragitemPtr(pdrgInfo,i);
  513.  
  514.        if (DrgVerifyRMF(pDragItem,"DRM_OUROWNSPECIAL","DRF_OBJECT"))
  515.        {
  516.           DrgDeleteStrHandle(pDragItem->hstrRMF);
  517.           pDragItem->hstrRMF = DrgAddStrHandle("<DRM_OBJECT,DRF_OBJECT>");
  518.        }
  519.     }
  520.  
  521.     return (parent_wpDrop(somSelf,hwndCnr,pdrgInfo,pdrgItem));
  522. }
  523.  
  524. /*
  525.  * METHOD: wpDeleteFromObjUseList                         ( ) PRIVATE
  526.  *                                                        (X) PUBLIC
  527.  * DESCRIPTION:
  528.  *
  529.  *   When a the last view of a WSFOLDER object is closed, we will zero out
  530.  *   its "first view" instance variable, so that the next time it has a first
  531.  *   view opened, we can keep track of that.
  532.  */
  533. SOM_Scope BOOL  SOMLINK wsfold_wpDeleteFromObjUseList(WSFOLDER *somSelf,
  534.                        PUSEITEM  pUseItem )
  535. {
  536.    WSFOLDERData *somThis   = WSFOLDERGetData(somSelf);
  537.    PUSEITEM      pItem;
  538.    BOOL          rcParentCall;
  539.    WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDeleteFromObjUseList");
  540.  
  541.    rcParentCall = parent_wpDeleteFromObjUseList(somSelf, pUseItem);
  542.  
  543.    pItem = _wpFindUseItem(somSelf, USAGE_OPENVIEW, NULL);
  544.    if (!pItem)
  545.    {
  546.       _setFirstViewHandle(somSelf, NULLHANDLE);
  547.    }
  548.    return(rcParentCall);
  549. }
  550.  
  551. /*
  552.  * METHOD: wpQueryConcurrentView                          ( ) PRIVATE
  553.  *                                                        (X) PUBLIC
  554.  * DESCRIPTION:
  555.  *
  556.  *   Objects of WSFOLDER class have concurrent views set to ON
  557.  *   by default
  558.  */
  559. SOM_Scope ULONG  SOMLINK wsfold_wpQueryConcurrentView(WSFOLDER *somSelf )
  560. {
  561. /* WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  562.    WSFOLDERMethodDebug("WSFOLDER","wsfold_wpQueryConcurrentView");
  563.  
  564.    return CCVIEW_ON;
  565. }
  566.  
  567. /*
  568.  *  METHOD: wpPrintObject                                  ( ) PRIVATE
  569.  *                                                         (X) PUBLIC
  570.  *  DESCRIPTION:
  571.  *
  572.  *    We will simply beep when a WSFOLDER object is "printed"
  573.  */
  574. SOM_Scope BOOL   SOMLINK wsfold_wpPrintObject(WSFOLDER *somSelf,
  575.                 PPRINTDEST pPrintDest,
  576.                 ULONG ulReserved)
  577. {
  578.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  579.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpPrintObject");
  580.  
  581.     WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  582.                    (PSZ) "(just pretend!)",
  583.                    (PSZ) "Folder Contents Printing",
  584.                     20,
  585.                     MB_OK | MB_INFORMATION | MB_MOVEABLE);
  586.  
  587.     return TRUE;
  588. }
  589.  
  590. /*
  591.  * METHOD: wpAddToContent                                 ( ) PRIVATE
  592.  *                                                        (X) PUBLIC
  593.  * DESCRIPTION:
  594.  *
  595.  *   We will put up a dialog containing the title of
  596.  *   the newly added object whenever one is added to a WSFOLDER
  597.  *   object
  598.  */
  599. SOM_Scope BOOL   SOMLINK wsfold_wpAddToContent(WSFOLDER *somSelf,
  600.                                                WPObject *pObject)
  601. {
  602.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  603.     BOOL  rc = FALSE;
  604.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpAddToContent");
  605.  
  606.     rc = parent_wpAddToContent(somSelf, pObject);
  607.     if (rc)
  608.     {
  609.        WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  610.                       (PSZ) _wpQueryTitle(pObject),
  611.                       (PSZ) "Notification of added object",
  612.                        20,
  613.                        MB_OK | MB_INFORMATION | MB_MOVEABLE);
  614.     }
  615.     return(rc);
  616.  
  617. }
  618.  
  619. /*
  620.  * METHOD: wpDeleteFromContent                            ( ) PRIVATE
  621.  *                                                        (X) PUBLIC
  622.  * DESCRIPTION:
  623.  *
  624.  *   We will put up a dialog containing the title of
  625.  *   the newly removed object whenever one is removed from a WSFOLDER
  626.  *   object
  627.  */
  628. SOM_Scope BOOL   SOMLINK wsfold_wpDeleteFromContent(WSFOLDER *somSelf,
  629.                                                     WPObject *pObject)
  630. {
  631.     WSFOLDERData *somThis = WSFOLDERGetData(somSelf);
  632.     BOOL rc = FALSE;
  633.     WSFOLDERMethodDebug("WSFOLDER","wsfold_wpDeleteFromContent");
  634.  
  635.     rc = parent_wpDeleteFromContent(somSelf, pObject);
  636.     if (rc)
  637.     {
  638.        WinMessageBox( HWND_DESKTOP, HWND_DESKTOP,
  639.                       (PSZ) _wpQueryTitle(pObject),
  640.                       (PSZ) "Notification of removed object",
  641.                        20,
  642.                        MB_OK | MB_INFORMATION | MB_MOVEABLE);
  643.     }
  644.     return(rc);
  645.  
  646. }
  647.  
  648. #undef SOM_CurrentClass
  649. #define SOM_CurrentClass SOMMeta
  650.  
  651. /*
  652.  *
  653.  *  METHOD: clsQueryModuleHandle                           ( ) PRIVATE
  654.  *                                                         (X) PUBLIC
  655.  *  DESCRIPTION:
  656.  *
  657.  *    This method returns the module handle of this class.  If this is the
  658.  *    first invocation, DosQueryModuleHandle is called to save the handle
  659.  *    for future invocations.
  660.  *
  661.  *  RETURN:
  662.  *
  663.  *    0              Unsuccessful
  664.  *    non-zero       module handle
  665.  *
  666.  */
  667. SOM_Scope HMODULE   SOMLINK wsfoldM_clsQueryModuleHandle(M_WSFOLDER *somSelf)
  668. {
  669.  
  670.     /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  671.     APIRET rc;
  672.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_clsQueryModuleHandle");
  673.  
  674.    /*
  675.     *   Make sure we already have module handle
  676.     */
  677.  
  678.     if (hmod == NULLHANDLE)
  679.     {
  680.      zString zsPathName;
  681.        /*
  682.         *   Retrieve registered pathname of our module (DLL) and query the
  683.         *   module handle.
  684.         */
  685.        zsPathName =
  686.        _somLocateClassFile( SOMClassMgrObject, SOM_IdFromString("WSFOLDER"),
  687.                             WSFOLDER_MajorVersion, WSFOLDER_MinorVersion);
  688.        rc = DosQueryModuleHandle( zsPathName, &hmod);
  689.        if (rc)
  690.        {
  691.           DebugBox("wsfoldM_wpclsInitData", "Failed to load module");
  692.           return;
  693.        }
  694.  
  695.     }   /* end if (hmod == NULLHANDLE) */
  696.  
  697.     return (hmod);
  698.  
  699. }
  700.  
  701. /*
  702.  *
  703.  *  METHOD: wpclsInitData
  704.  *
  705.  *  DESCRIPTION:
  706.  *
  707.  *    Initalize the class data
  708.  *
  709.  */
  710. SOM_Scope void   SOMLINK wsfoldM_wpclsInitData(WSFOLDER *somSelf)
  711. {
  712. /*    WSFOLDERData *somThis = WSFOLDERGetData(somSelf); */
  713.     WSFOLDERMethodDebug("WSFOLDER","wsfoldM_wpclsInitData");
  714.  
  715.     parent_wpclsInitData(somSelf);
  716.  
  717.     /*
  718.      *   Get class title
  719.      */
  720.     if (!WinLoadString(WinQueryAnchorBlock(HWND_DESKTOP), _clsQueryModuleHandle(somSelf), ID_TITLE,
  721.                          sizeof(szWSFOLDERClassTitle), szWSFOLDERClassTitle))
  722.                               /* Load string failed: use the parent's string */
  723.        strcpy(szWSFOLDERClassTitle, parent_wpclsQueryTitle(somSelf));
  724.  
  725. }
  726.  
  727. /*
  728.  *
  729.  *  METHOD: wpclsQueryDefaultHelp                          ( ) PRIVATE
  730.  *                                                         (X) PUBLIC
  731.  *  DESCRIPTION:
  732.  *
  733.  *    Define help for objects of our class.
  734.  *
  735.  */
  736. SOM_Scope BOOL SOMLINK wsfoldM_wpclsQueryDefaultHelp(M_WSFOLDER *somSelf,
  737.                 PULONG pHelpPanelId,
  738.                 PSZ pszHelpLibrary)
  739. {
  740.  /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  741.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryDefaultHelp");
  742.  
  743.     if (pHelpPanelId)                           /* set default help panel id */
  744.        *pHelpPanelId   = ID_HELP_DEFAULT;
  745.  
  746.     if (pszHelpLibrary)                                /* copy help filename */
  747.        strcpy(pszHelpLibrary, szHelpLibrary);
  748.  
  749.     return (TRUE);
  750.  
  751. }
  752.  
  753. /*
  754.  *
  755.  *  METHOD: wpclsQueryDefaultView                          ( ) PRIVATE
  756.  *                                                         (X) PUBLIC
  757.  *  DESCRIPTION:
  758.  *
  759.  *    WSFOLDER objects open in OPEN_DETAILS by default
  760.  *
  761.  */
  762. SOM_Scope ULONG SOMLINK wsfoldM_wpclsQueryDefaultView(M_WSFOLDER *somSelf)
  763. {
  764.  /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  765.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryDefaultView");
  766.  
  767.     return OPEN_DETAILS;
  768.  
  769. }
  770.  
  771. /*
  772.  *
  773.  *  METHOD: wpclsQueryTitle
  774.  *
  775.  *  DESCRIPTION:
  776.  *
  777.  *    Return class title for WSFOLDER class
  778.  *
  779.  */
  780. SOM_Scope PSZ   SOMLINK wsfoldM_wpclsQueryTitle(M_WSFOLDER *somSelf)
  781. {
  782.     /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  783.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryTitle");
  784.  
  785.     if (*szWSFOLDERClassTitle )
  786.        return( szWSFOLDERClassTitle );
  787.     else
  788.        return( parent_wpclsQueryTitle(somSelf));
  789. }
  790.  
  791. /*
  792.  *
  793.  *  METHOD: wpclsQueryIconData                            ( ) PRIVATE
  794.  *                                                         (X) PUBLIC
  795.  *  DESCRIPTION:
  796.  *
  797.  *    Return the class icon
  798.  *
  799.  */
  800. SOM_Scope ULONG SOMLINK wsfoldM_wpclsQueryIconData(M_WSFOLDER *somSelf,
  801.                   PICONINFO pIconInfo)
  802. {
  803.    APIRET rc;
  804.    M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryIconData");
  805.  
  806.    if (pIconInfo)
  807.    {
  808.       /*
  809.        *   fill in icon information
  810.        */
  811.       pIconInfo->fFormat = ICON_RESOURCE;
  812.       pIconInfo->hmod= _clsQueryModuleHandle(somSelf);
  813.       pIconInfo->resid= ID_ICON;
  814.    }
  815.  
  816.    return (sizeof(ICONINFO));
  817.  
  818. }
  819.  
  820. /*
  821.  *
  822.  *  METHOD: wpclsQueryIconDataN                            ( ) PRIVATE
  823.  *                                                         (X) PUBLIC
  824.  *  DESCRIPTION:
  825.  *
  826.  *    Return the class open icon
  827.  *
  828.  */
  829. SOM_Scope ULONG SOMLINK wsfoldM_wpclsQueryIconDataN(M_WSFOLDER *somSelf,
  830.                   PICONINFO pIconInfo, ULONG ulIconIndex)
  831. {
  832.    APIRET rc;
  833.  
  834.    M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryIconDataN");
  835.  
  836.    if (pIconInfo)
  837.    {
  838.       if (ulIconIndex == 1)
  839.       {
  840.          /*
  841.           *   fill in open icon information
  842.           */
  843.          pIconInfo->fFormat = ICON_RESOURCE;
  844.          pIconInfo->hmod= _clsQueryModuleHandle(somSelf);
  845.          pIconInfo->resid= ID_OPENICON;
  846.  
  847.       }
  848.       else
  849.          return parent_wpclsQueryIconDataN(somSelf, pIconInfo, ulIconIndex);
  850.    }
  851.  
  852.    return (sizeof(ICONINFO));
  853.  
  854. }
  855.  
  856. /*
  857.  *  METHOD: wpclsQueryStyle                                ( ) PRIVATE
  858.  *                                                         (X) PUBLIC
  859.  *  DESCRIPTION:
  860.  *
  861.  *    Change default class style so that WSFOLDER objects have can
  862.  *    be "printed" (we'll just beep), and so that this class is not
  863.  *    templated.
  864.  */
  865.  
  866. SOM_Scope ULONG   SOMLINK wsfoldM_wpclsQueryStyle(M_WSFOLDER *somSelf)
  867. {
  868.     /* M_WSFOLDERData *somThis = M_WSFOLDERGetData(somSelf); */
  869.     M_WSFOLDERMethodDebug("M_WSFOLDER","wsfoldM_wpclsQueryStyle");
  870.  
  871.     return ((parent_wpclsQueryStyle(somSelf) & ~CLSSTYLE_NEVERPRINT)
  872.             | CLSSTYLE_PRIVATE);
  873. }
  874.  
  875.  
  876.  
  877.