home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / rdfui / CHyperTreeFlexTable.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.3 KB  |  176 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. //
  20. // Mike Pinkerton, Netscape Communications
  21. //
  22. // Contains:
  23. //
  24. // Ñ╩CHyperTreeFlexTable
  25. //         A subclass of CStandardFlexTable to handle working with XP RDF Hyper Trees
  26. //
  27. // Ñ CHyperTreeSelector
  28. //        Modifies the selection model used by PP to also consult HT to see if a row is
  29. //        selected
  30. //
  31.  
  32. #pragma once
  33.  
  34. #include "CStandardFlexTable.h"
  35. #include "LTableRowSelector.h"
  36. #include "CDynamicTooltips.h"
  37.  
  38. // STL Headers
  39. #include <vector.h>
  40.  
  41. // RDF Headers
  42. #include "rdf.h"
  43. #include "htrdf.h"
  44.  
  45.  
  46. #pragma mark -- class CHyperTreeFlexTable --
  47.  
  48.  
  49. class CHyperTreeFlexTable :
  50.     public CStandardFlexTable, public CDynamicTooltipMixin
  51. {
  52. public:
  53.         enum {
  54.             class_ID = 'htFT',
  55.             nameColumn = 'NCnC'
  56.         };
  57.         
  58.     CHyperTreeFlexTable(LStream *inStream);
  59.     ~CHyperTreeFlexTable();
  60.  
  61.     virtual void     ChangeSort ( const LTableHeader::SortChange* inSortChange ) ;
  62.  
  63.     virtual void    OpenView(HT_View inHTView);
  64.     virtual void    ExpandNode(HT_Resource inHTNode);
  65.     virtual void    CollapseNode(HT_Resource inHTNode);
  66.     virtual void    SyncSelectionWithHT ( ) ;
  67.  
  68.     HT_View            GetHTView()    const { return mHTView; }
  69.     
  70.     bool            IsViewSameAsBeforeDrag() const { return mViewBeforeDrag == mHTView; }
  71.  
  72. protected:
  73.  
  74.     
  75.         // CStandardFlexTable Overrides
  76.     virtual void OpenRow ( TableIndexT inRow ) ;
  77.     virtual Boolean    CellInitiatesDrag(const STableCell&) const;
  78.     virtual Boolean CellSelects ( const STableCell& inCell ) const;
  79.     virtual Boolean RowCanAcceptDrop ( DragReference inDragRef, TableIndexT inDropRow ) ;
  80.     virtual Boolean RowCanAcceptDropBetweenAbove( DragReference inDragRef, TableIndexT inDropRow ) ;
  81.     virtual FlavorType FindAcceptableFlavor ( DragReference inDragRef, ItemReference inItemRef ) ;
  82.     virtual Boolean NodeCanAcceptDrop ( DragReference inDragRef, HT_Resource inTargetNode ) ;
  83.     virtual void HiliteDropRow ( TableIndexT inRow, Boolean inDrawBarAbove ) ;
  84.     virtual Boolean    RowIsContainer ( const TableIndexT & /* inRow */ ) const ;
  85.     virtual void DrawCellContents( const STableCell &inCell, const Rect &inLocalRect);
  86.     virtual ResIDT GetIconID(TableIndexT inRow) const;        
  87.     virtual UInt16 GetNestedLevel(TableIndexT inRow) const;
  88.     virtual void SetCellExpansion( const STableCell& inCell, Boolean inExpand);
  89.     virtual Boolean    CellHasDropFlag(const STableCell& inCell, Boolean& outIsExpanded) const;
  90.         
  91.         // Stuff related to hiliting
  92.     virtual TableIndexT    GetHiliteColumn() const { return 1; } ;
  93.     virtual Boolean GetHiliteTextRect ( TableIndexT inRow, Rect& outRect) const ;
  94.     virtual void GetMainRowText( TableIndexT inRow, char* outText, UInt16 inMaxBufferLength) const ;
  95.     virtual void DoHiliteRgn ( RgnHandle inHiliteRgn ) const;
  96.     virtual void DoHiliteRect ( const Rect & inHiliteRect ) const;
  97.     virtual void HiliteSelection( Boolean inActively, Boolean inHilite) ;
  98.     
  99.     virtual void SetUpTableHelpers() ;    
  100.     
  101.     virtual Uint32 FindTitleColumnID ( ) const ;
  102.  
  103.         // Handle drag and drop
  104.     virtual void DragSelection(const STableCell& inCell, const SMouseDownEvent &inMouseDown);
  105.     virtual void DoDragSendData ( FlavorType inFlavor, ItemReference inItemRef, DragReference inDragRef) ;
  106.     virtual void ReceiveDragItem ( DragReference inDragRef, DragAttributes inDragAttrs,
  107.                                         ItemReference inItemRef, Rect &inItemBounds ) ;
  108.     virtual Boolean ItemIsAcceptable ( DragReference inDragRef, ItemReference inItemRef ) ;
  109.     virtual void HandleDropOfHTResource ( HT_Resource node ) ;
  110.     virtual void HandleDropOfPageProxy ( vector<char> & inURLAndTitle ) ;
  111.     virtual void HandleDropOfLocalFile ( const char* inFileURL, const char* fileName ) ;
  112.     virtual void DeleteSelectionByDragToTrash ( LArray & inItems ) ;
  113.  
  114.         // for dynamic tooltip tracking and mouse cursor tracking
  115.     virtual void MouseWithin ( Point inPortPt, const EventRecord& ) ;    
  116.     virtual void MouseLeave ( ) ;
  117.     virtual void AdjustCursorSelf ( Point /*inPoint*/, const EventRecord& inEvent ) ;
  118.     virtual void FindTooltipForMouseLocation ( const EventRecord& inMacEvent,
  119.                                                     StringPtr outTip ) ;
  120.  
  121.         // for inline editing
  122.     virtual void InlineEditorDone ( ) ;
  123.     virtual bool CanDoInlineEditing ( ) ;
  124.  
  125.         // command stuff
  126.     virtual void    DeleteSelection ( );
  127.     virtual void    FindCommandStatus ( CommandT inCommand, Boolean &outEnabled,
  128.                                         Boolean &outUsesMark, Char16 &outMark, Str255 outName) ;
  129.  
  130. //-----------------------------------
  131. // Data
  132. //-----------------------------------
  133.     HT_View                    mHTView;
  134.     HT_Notification            mHTNotificationData;
  135.     DragSendDataUPP            mSendDataUPP;
  136.     HT_View                    mViewBeforeDrag;
  137.     HT_Resource                mDropNode;            // the HT node that corresponds to mDropRow
  138.  
  139.     STableCell                mTooltipCell;        // tracks where mouse is for tooltips    
  140.  
  141. }; // class CHyperTreeFlexTable
  142.  
  143.  
  144. #pragma mark -- class CHyperTreeSelector --
  145.  
  146.  
  147. //
  148. // class CHyperTreeSelector
  149. //
  150. // A replacement for the standard selector class used by LTableView to sync the 
  151. // selection with the backend HT_API 
  152. //
  153.  
  154. class CHyperTreeSelector : public LTableRowSelector
  155. {
  156. public:
  157.  
  158.     CHyperTreeSelector ( LTableView *inTableView, Boolean inAllowMultiple=true )
  159.         : LTableRowSelector ( inTableView, inAllowMultiple ), mTreeView(NULL) { } ;
  160.  
  161.         // overridden to ask HT if row is selected
  162.     virtual Boolean CellIsSelected ( const STableCell &inCell ) const;
  163.  
  164.         // keep us in sync with HT when a new view is opened
  165.     virtual void SyncSelectorWithHT ( ) ;
  166.     
  167.     void TreeView ( HT_View inNewView ) { mTreeView = inNewView; } ;
  168.  
  169. protected:
  170.  
  171.     virtual void DoSelect (    const TableIndexT inRow, Boolean inSelect, Boolean inHilite,
  172.                                 Boolean    inNotify ) ;
  173.  
  174.     HT_View mTreeView;
  175.  
  176. }; // class CHyperTreeSelector