home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv6.zip / vac22os2 / ibmcobol / samples / toolkit / wps / wsfile / wsfolder.c < prev    next >
C/C++ Source or Header  |  1996-11-20  |  32KB  |  1,084 lines

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