home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CNavCenterSelectorPane.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.0 KB  |  200 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. // Ñ SelectorImage
  25. //        an abstract class for drawing the workspace icon
  26. //
  27. // Ñ TitleImage
  28. //        implements above
  29. //
  30. // Ñ CNavCenterSelectorPane
  31. //        handles drawing/clicking/tooltips/etc of workspaces and all powerplant interactions
  32. //
  33.  
  34. #pragma once
  35.  
  36. #include <LPane.h>
  37. #include <LBroadcaster.h>
  38.  
  39. #include "LString.h"
  40. #include "htrdf.h"
  41. #include "CDynamicTooltips.h"
  42.  
  43.  
  44. #pragma mark -- class SelectorImage and SelectorData --
  45.  
  46.  
  47. //
  48. // SelectorImage
  49. //
  50. // An abstract base class that knows how to draw itself in the appropriate mode (text/icon/text&icon)
  51. // as well as selected or not-selected.
  52. //
  53. class SelectorImage
  54. {
  55.     public:
  56.         virtual ~SelectorImage ( ) { } ;
  57.         virtual void DrawInCurrentView( const Rect& bounds, unsigned long mode ) const = 0;
  58. };
  59.  
  60.  
  61. //
  62. // SelectorData
  63. //
  64. // an element within the Nav Center workspace list.
  65. //
  66. struct SelectorData
  67. {
  68.     SelectorData ( HT_View inView ) ;
  69.     ~SelectorData();
  70.     
  71.     SelectorImage*        workspaceImage;        // ptr to object that knows how to draw workspace icon
  72. };
  73.  
  74.  
  75. #pragma mark -- class CNavCenterSelectorPane --
  76.  
  77. //
  78. // CNavCenterSelectorPane
  79. //
  80. // Draws the workspace icons in a vertical table. Handles setting the currently selected
  81. // workspace when an icon is clicked on and telling the RDFCoordinator to change the open/close
  82. // state of the shelf if need be.
  83. //
  84.  
  85. class CNavCenterSelectorPane
  86.         : public LView, public LDragAndDrop, public LBroadcaster, public LCommander,
  87.             public CDynamicTooltipMixin
  88. {
  89. public:
  90.     friend class CNavCenterSelectorContextMenuAttachment;
  91.     
  92.         // modes for drawing icons
  93.     enum {
  94.         kSelected = 1, kIcon = 2, kText = 4
  95.     };
  96.  
  97.         // powerplant stuff (panes and messages)
  98.     enum {
  99.         class_ID                    = 'NvSl',
  100.         msg_ShelfStateShouldChange    = 'shlf',        // broadcast when shelf should open/close
  101.         msg_ActiveSelectorChanged    = 'selc'        // broadcast when selector changes
  102.     };
  103.  
  104.     CNavCenterSelectorPane( LStream* );
  105.     virtual ~CNavCenterSelectorPane();
  106.  
  107.         // Tell view to select the next workspace, wrapping around if we hit the ends    
  108.     virtual void CycleCurrentWorkspace ( ) ;
  109.  
  110.         // Tell view if it is in a browser window 
  111.     void SetEmbedded ( bool isEmbedded ) { mIsEmbedded = isEmbedded; }
  112.     
  113.         // Get/Set info about the HT_Pane that contains all the workspaces to display 
  114.     void SetHTPane ( HT_Pane inPane ) { mHTPane = inPane; }
  115.     HT_Pane GetHTPane ( ) const { return mHTPane; }
  116.  
  117.         // access and change the current workspace.
  118.     void SetActiveWorkspace ( HT_View inNewWorkspace ) ;
  119.     HT_View GetActiveWorkspace ( ) const { return mCachedWorkspace; }
  120.     
  121.     static const RGBColor mBGColor;
  122.     
  123. protected:
  124.  
  125.         // PowerPlant overrides
  126.     virtual void DrawSelf();
  127.     virtual void ClickSelf( const SMouseDownEvent& );
  128.     virtual void AdjustCursorSelf( Point, const EventRecord& );
  129.     virtual void FindCommandStatus ( CommandT inCommand, Boolean &outEnabled,
  130.                                         Boolean &outUsesMark, Char16 &outMark, Str255 outName) ;
  131.  
  132.         // redraw when things change and broadcast that they have.
  133.     virtual void NoticeActiveWorkspaceChanged ( HT_View iter ) ;
  134.     
  135.         // click handling
  136.     size_t FindIndexForPoint ( const Point & inMouseLoc ) const;
  137.     HT_View FindSelectorForPoint ( const Point & inMouseLoc ) const;
  138.  
  139.         // stuff for dynamic tooltips
  140.     virtual void FindTooltipForMouseLocation ( const EventRecord& inMacEvent, StringPtr outTip ) ;
  141.     virtual void MouseWithin ( Point inPortPt, const EventRecord& ) ;
  142.     virtual void MouseLeave ( ) ;
  143.  
  144.         // stuff for drag and drop
  145.     virtual Boolean    ItemIsAcceptable ( DragReference inDragRef, ItemReference inItemRef ) ;
  146.     virtual void    InsideDropArea ( DragReference inDragRef ) ;
  147.     virtual void    EnterDropArea ( DragReference inDragRef, Boolean inDragHasLeftSender ) ;
  148.     virtual void    LeaveDropArea ( DragReference inDragRef ) ;
  149.     
  150.     bool                mIsEmbedded;            // is this embedded in chrome or standalone window?
  151.     HT_Pane                mHTPane;
  152.     HT_View                mCachedWorkspace;        // which view is currently active?
  153.     short                mTooltipIndex;            // which item is mouse hovering over
  154.     bool                mMouseIsInsidePane;        // is the mouse in the pane?
  155.     Uint32                mDragAndDropTickCount;    // used only during d&d as a timer
  156.  
  157.     unsigned long        mImageMode;
  158.     size_t                mCellHeight;
  159.  
  160. }; // class CNavCenterSelectorPane
  161.  
  162.  
  163. #pragma mark -- class TitleImage --
  164.  
  165. //
  166. // TitleImage
  167. //
  168. // A simple little hack to display the title of the workspace
  169. //
  170.  
  171. class TitleImage : public SelectorImage
  172. {
  173. public:
  174.     TitleImage ( const LStr255 & inTitle, ResIDT inIconID ) ;
  175.  
  176.     virtual void DrawInCurrentView( const Rect& bounds, unsigned long mode ) const ;
  177.     
  178.     const LStr255 & Title ( ) const { return mTitle; } ;
  179.     ResIDT IconID ( ) const { return mIconID; } ;
  180.     Uint16 TextWidth ( ) const { return mTextWidth; } ;
  181.         
  182. private:
  183.  
  184. #if DRAW_SELECTED_AS_TAB
  185.     virtual    void            DrawOneTab(RgnHandle inBounds) const;
  186.     virtual    void            DrawTopBevel(RgnHandle inTab) const;
  187.     virtual    void            DrawBottomBevel(RgnHandle inTab, Boolean inCurrentTab) const;
  188.     virtual void            DrawOneTabBackground(
  189.                                 RgnHandle inRegion,
  190.                                 Boolean inCurrentTab) const;
  191.     virtual void            DrawOneTabFrame(RgnHandle inRegion, Boolean inCurrentTab) const;
  192.     virtual void            DrawCurrentTabSideClip(RgnHandle inRegion) const;
  193. #endif
  194.  
  195.     LStr255 mTitle;
  196.     ResIDT mIconID;
  197.     Uint16 mTextWidth;
  198.     
  199. }; // classTitleImage
  200.