home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / mac / UserInterface / CNotificationAttachment.cp < prev    next >
Encoding:
Text File  |  1998-04-08  |  2.3 KB  |  94 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #include "CNotificationAttachment.h"
  20.  
  21. #include "PascalString.h"
  22.  
  23. CNotificationAttachment* CNotificationAttachment::sCurrentNotifier = NULL;
  24.  
  25. CNotificationAttachment::CNotificationAttachment()
  26. :    LAttachment(msg_Event)
  27. ,    mIconSuite(NULL)
  28. {
  29.     mNotification.qLink = 0;
  30.     mNotification.qType = nmType;
  31.     mNotification.nmMark = true;
  32.     Post();
  33.     SetExecuteHost(true);
  34.     sCurrentNotifier = this;
  35. }
  36.  
  37. CNotificationAttachment::~CNotificationAttachment()
  38. {
  39.     Remove();
  40.     sCurrentNotifier = NULL;
  41. }
  42.  
  43. void CNotificationAttachment::ExecuteSelf(
  44.     MessageT        inMessage,
  45.     void            *ioParam)
  46. {
  47.     Assert_(inMessage == msg_Event);
  48.     EventRecord* theEvent = (EventRecord*)ioParam;
  49.  
  50.     if (theEvent->what == osEvt)
  51.         {
  52.         Uint8    osEvtFlag = ((Uint32)theEvent->message) >> 24;
  53.         if ((osEvtFlag == suspendResumeMessage) && (theEvent->message & resumeFlag))
  54.             {
  55.             delete this;
  56.             }
  57.         }
  58. }
  59.  
  60. void CNotificationAttachment::Post(void)
  61. {
  62.     OSErr theErr = ::GetIconSuite(&mIconSuite, 170, svAllSmallData);
  63.     ThrowIfOSErr_(theErr);
  64.  
  65.     ::HNoPurge(mIconSuite);
  66.  
  67.     mNotification.nmIcon = mIconSuite;
  68.  
  69.     ::GetIndString(mNoteString, 7099, 3);
  70.     Assert_(mNoteString.Length());
  71.     if (mNoteString.Length() > 0)
  72.         mNotification.nmStr = mNoteString;
  73.     else
  74.         mNotification.nmStr = NULL;
  75.  
  76.     mNotification.nmSound = (Handle)-1;
  77.     mNotification.nmResp = NULL;
  78.  
  79.     theErr = ::NMInstall(&mNotification);
  80.     ThrowIfOSErr_(theErr);
  81. }
  82.  
  83. void CNotificationAttachment::Remove(void)
  84. {
  85.     ::NMRemove(&mNotification);
  86.  
  87.     if (mIconSuite != NULL)
  88.         {
  89.         ::DisposeIconSuite(mIconSuite, true);
  90.         mIconSuite = NULL;
  91.         }
  92. }
  93.  
  94.