home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / mattach.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.9 KB  |  171 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. #pragma once
  20.  
  21. #include "mfinder.h"
  22. #include "LArray.h"
  23.  
  24. class CMailWindow;
  25. class LWindow;
  26. struct MSG_AttachmentData;
  27.  
  28. /* CMailAttachment
  29.  * holds all the information about a single attachment
  30.  * list of these is kept inside a mail window
  31.  * Has to mirror MSG_AttachmentData struct in mime.h
  32.  */
  33. struct CMailAttachment    {
  34.     char * fURL;
  35.     char * fDesiredType;
  36.     char * fRealType;     /* The type of the URL if known, otherwise NULL */
  37.     char * fRealName;    /* Real name of the file */
  38.     char * fDescription;
  39.     Boolean fSelected;
  40.     OSType    fFileType;
  41.     OSType    fFileCreator;
  42.  
  43.     CMailAttachment(char * url, char * mimeType = NULL, char * realType = NULL, char * realName = NULL)    
  44.     {
  45.         memset(this, 0, sizeof(CMailAttachment));
  46.         fURL = url; 
  47.         fDesiredType = mimeType;
  48.         fRealType = realType;
  49.         fRealName = realName;
  50.         fSelected = FALSE;
  51.  
  52.         // ÑÑÑ FIX ME: LAME
  53.         fFileType = 'TEXT';
  54.         fFileCreator = '????';
  55.     }
  56.     CMailAttachment(const FSSpec & spec);
  57.     CMailAttachment(const MSG_AttachmentData * data);
  58.     CMailAttachment()    
  59.     {
  60.         memset(this, 0, sizeof(CMailAttachment));
  61.     }
  62.     void FreeMembers();
  63.     CStr255& UrlText();
  64.     void ComposeDescription();
  65. };
  66.  
  67. /**************************************************************************
  68.  * class CAttachmentList
  69.  * holds a list of CMailAttachments
  70.  * When you delete a CMailAttachments item, it disposes of things that it
  71.  * points to.
  72.  * knows how to clone itself
  73.  **************************************************************************/
  74. class CAttachmentList : public LArray    {
  75. public:
  76.  
  77. // constructors
  78.                     CAttachmentList();
  79.     virtual            ~CAttachmentList();
  80.     static CAttachmentList * Clone(CAttachmentList * clone);
  81.  
  82. // LArray overrides
  83.     virtual void    RemoveItemsAt(Uint32    inCount, Int32    inAtIndex);
  84.  
  85. // ÑÑ╩access
  86.     MSG_AttachmentData* NewXPAttachmentList();        // Creates an attachment list
  87.     void            DeleteXPAttachmentList(MSG_AttachmentData* list);    // Deletes the XP list
  88.     void            InitializeFromXPAttachmentList(const MSG_AttachmentData* list);
  89. };
  90.  
  91. /* ************************************************************************
  92.  * CAttachmentView
  93.  * displays a list of attachments
  94.  * By default, our list is fully destroyed on termination
  95.  **************************************************************************/
  96. #define attachWindID        8002
  97. #define SELECTED_CELL        -1
  98.  
  99. #define kSFAttachFile 146
  100. const MessageT msg_AttachFile            = 'Atch';
  101. const MessageT msg_AttachWeb            = 'AtWb';
  102. const MessageT msg_RemoveAttach            = 'RmAt';
  103.  
  104. class CAttachmentView : public LFinderView, public LBroadcaster, public LListener    {
  105. public:
  106.     enum { class_ID = 'AtVw', msg_AttachmentsAdded = 'AttA', msg_AttachmentsRemoved = 'AttR' };
  107.  
  108. // ÑÑ constructors
  109.     CAttachmentView( LStream * inStream);
  110.  
  111.     virtual void FinishCreateSelf();
  112.  
  113. // ÑÑ access
  114.     void            SetAttachList(CAttachmentList * list);
  115.     CAttachmentList * GetAttachList() {return mAttachList;}
  116.     Boolean            GetSelectedAttachment(CMailAttachment &attach);
  117.     void            AddMailAttachment(CMailAttachment * attach, Boolean refresh = true);
  118.     void            ModifyMailAttachment(Int32 cell,     // SELECTED_CELL for current selection
  119.                                             CMailAttachment * attach, 
  120.                                             Boolean refresh);
  121.     void            SetMimeType(char * type);
  122.     void             AddWebPageWithUI(unsigned char *defaultText);
  123.     void            AddFile(const FSSpec& spec);
  124.     void            DeleteSelection(Boolean refresh = TRUE);
  125.  
  126. // ÑÑ Finder view overrides
  127.     virtual void        DrawCellColumn( UInt32 cell, UInt16 column );
  128.     virtual Boolean        SyncDisplay( UInt32 visCells );
  129.     virtual Boolean        IsCellSelected( Int32 cell );
  130.     virtual ResIDT        CellIcon( Int32 /* cell */ ) { return 133; }
  131.     virtual void        CellText( Int32 cell, CStr255& text );
  132.     virtual void        GetTextRect( UInt32 cell, Rect& where );
  133.     virtual void         GetIconRect( UInt32 cell, Rect& where );
  134.     virtual void        GetWiglyRect( UInt32 cell, Rect& rect );
  135.     virtual void        SelectItem( const EventRecord& event, UInt32 cell, Boolean refresh );
  136.     virtual void        ClearSelection();
  137.     virtual UInt32        GetVisibleCount();
  138.     virtual UInt32        FirstSelectedCell();
  139.  
  140. // ÑÑ PP overrides
  141.     virtual Boolean     HandleKeyPress( const EventRecord& inEvent );
  142.     virtual Boolean        ProcessCommand(CommandT inCommand, void *ioParam);
  143.     virtual void        BeTarget();
  144.     virtual void        TakeOffDuty();
  145.     virtual void        ListenToMessage(MessageT inMessage, void* ioParam);
  146. // ÑÑ drag'n'drop
  147.     virtual    void         InsideDropArea( DragReference inDragRef );
  148.     virtual void        HiliteDropArea(DragReference inDragRef);
  149.  
  150.     virtual Boolean     ItemIsAcceptable(DragReference    inDragRef, ItemReference    inItemRef);
  151.     virtual void         DoDragReceive(DragReference inDragRef);
  152.     virtual void        ReceiveDragItem(    DragReference     inDragRef, 
  153.                                     DragAttributes    flags, 
  154.                                     ItemReference     inItemRef, 
  155.                                     Rect&             itemBounds);
  156.     // utility functions for new compose window because attach view
  157.     // is inside a tab switcher
  158.     void                AddDropAreaToWindow(LWindow* inWindow);
  159.     void                RemoveDropAreaFromWindow(LWindow* inWindow);
  160.  
  161.     inline UInt32        CountSelectedItems()    { return mSelectedItemCount; }                                    
  162.  
  163. protected:
  164.     void            SelectItem( UInt32 cell, Boolean refresh );
  165.  
  166.     CAttachmentList *    mAttachList;
  167.     UInt32                mSelectedItemCount;
  168.     Boolean                mNotifyAttachmentChanges;
  169.     Boolean                mCurrentlyAddedToDropList;
  170. };
  171.