home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: InfoMgt / InfoMgt.zip / shr93.zip / NOTIFY.C < prev    next >
Text File  |  1993-04-12  |  4KB  |  143 lines

  1. /*
  2.  * OS/2 Work Place Shell Sample Program - ShrNotifier model code
  3.  *
  4.  * Copyright (C) 1993 IBM Corporation
  5.  *
  6.  *   DISCLAIMER OF WARRANTIES.  The following [enclosed] code is
  7.  *   sample code created by IBM Corporation.  This sample code is
  8.  *   not part of any standard or IBM product and is provided to you
  9.  *   solely for the purpose of assisting you in the development of
  10.  *   your applications.  The code is provided "AS IS".  ALL
  11.  *   WARRANTIES ARE EXPRESSLY DISCLAIMED, INCLUDING THE IMPLIED
  12.  *   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  13.  *   PURPOSE.  IBM shall not be liable for any damages arising out
  14.  *   of your use of the sample code, even if IBM has been advised of
  15.  *   the possibility of such damages.
  16.  */
  17.  
  18. #define ShrNotifier_Class_Source
  19. #define SOM_NoTest
  20.  
  21. #include "share.h"
  22. #include "somlist.h"
  23. #include "shrfoldr.h"
  24.  
  25. /*
  26.  * SOM generates method stubs that
  27.  * cause compiler warnings.  Suspend warnings
  28.  * (but be wary, this can mask errors in the
  29.  * emitted "passthru" sections of the CSC file).
  30.  */
  31.  
  32. #pragma checkout(suspend)
  33. #include "notify.ih"
  34. #pragma checkout(resume)
  35.  
  36. /*
  37.  * 
  38.  *  METHOD: shrQueryWindowNotifyList                        (X) PRIVATE
  39.  *                                                          ( ) PUBLIC
  40.  *  DESCRIPTION:
  41.  * 
  42.  *    Lazy query of the window notify list which holds the
  43.  *    window handles of view interested in significant
  44.  *    changes in an observable model.
  45.  *
  46.  */
  47.  
  48. SOM_Scope SOMObject * SOMLINK ntf_shrQueryWindowNotifyList
  49.     (ShrNotifier *somSelf)
  50. {
  51.   ShrNotifierData *somThis = ShrNotifierGetData(somSelf);
  52.  
  53.   if (!_somWindowNotifyList)
  54.     _somWindowNotifyList = _shrclsValueListNew(ShrListNewClass(0,0));
  55.  
  56.   return _somWindowNotifyList;
  57. }
  58.  
  59. /*
  60.  * 
  61.  *  METHOD: shrAddInterestedWindow                         ( ) PRIVATE
  62.  *          shrRemoveInterestedWindow                      (X) PUBLIC
  63.  *                                         
  64.  *  DESCRIPTION:
  65.  * 
  66.  *    Ask the notifier to add or remove interest in 
  67.  *    significant changes in the model.
  68.  */
  69.  
  70. SOM_Scope BOOL SOMLINK ntf_shrAddInterestedWindow
  71.     (ShrNotifier *somSelf, HWND hwndInterested)
  72. {
  73.   return _shrAddLast(_shrQueryWindowNotifyList(somSelf), 
  74.       (PVOID) hwndInterested);
  75. }
  76.  
  77. SOM_Scope BOOL SOMLINK ntf_shrRemoveInterestedWindow
  78.     (ShrNotifier *somSelf, HWND hwndInterested)
  79. {
  80.   return _shrRemove(_shrQueryWindowNotifyList(somSelf),
  81.       (PVOID) hwndInterested);
  82. }
  83.  
  84. /*
  85.  * 
  86.  *  METHOD: shrNotifyInterestedWindow                       ( ) PRIVATE
  87.  *                                                          (X) PUBLIC
  88.  *  DESCRIPTION:
  89.  * 
  90.  *    Tells windows (views) that have registered with the
  91.  *    shrNotifyInterestedWindows that a significant change
  92.  *    has occurred to the model they are monitoring.
  93.  *
  94.  */
  95.  
  96. SOM_Scope ULONG SOMLINK ntf_shrNotifyInterestedWindows
  97.     (ShrNotifier *somSelf, SOMAny *somChangedObject, 
  98.     ULONG ulChangeMsg, MPARAM mp1, MPARAM mp2)
  99. {
  100.   ShrNotifierData *somThis = ShrNotifierGetData(somSelf);
  101.   HWND hwndInterested = NULLHANDLE;
  102.   ULONG cInterested = 0;
  103.   PVOID pEnum;
  104.  
  105.   if (_somWindowNotifyList)
  106.   {
  107.     pEnum = _shrBeginEnum(_somWindowNotifyList);
  108.  
  109.     while (_shrNext(_somWindowNotifyList, pEnum, 
  110.         (PVOID *) &hwndInterested))
  111.     {
  112.       cInterested++;
  113.       WinSendMsg(hwndInterested, ulChangeMsg, mp1, mp2);
  114.     }
  115.  
  116.     _shrEndEnum(_somWindowNotifyList, pEnum);
  117.   }
  118.  
  119.   ShrCnrRefreshDetails(somChangedObject);
  120.  
  121.   return cInterested;
  122. }
  123.  
  124. /*
  125.  * 
  126.  *  OVERRIDE: somUninit                                     ( ) PRIVATE
  127.  *                                                          (X) PUBLIC
  128.  *  DESCRIPTION:
  129.  * 
  130.  *    Free resources before going away.
  131.  *
  132.  */
  133.  
  134. SOM_Scope VOID SOMLINK ntf_somUninit(ShrNotifier *somSelf)
  135. {
  136.   ShrNotifierData *somThis = ShrNotifierGetData(somSelf);
  137.  
  138.   if (_somWindowNotifyList)
  139.     _somFree(_somWindowNotifyList);
  140.  
  141.   parent_somUninit(somSelf);
  142. }
  143.