home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / gui / CDynamicTooltips.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.8 KB  |  108 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. // Interface for a pair of classes that provided a tooltip that takes its text dynamically
  21. // based on the content of a pane and the mouse location. The CDynamicTooltipPane asks its 
  22. // parent view what string it should display  depending on the current mouse location.
  23. // The CDynamicTootipMixin class is mixed into the parent view to give the the correct 
  24. // interface.
  25. //
  26.  
  27. #pragma once
  28.  
  29. #include "CTooltipAttachment.h"
  30.  
  31. //
  32. // class CDynamicTooltipPane
  33. //
  34. // Handles querying the parent view to get the appropriate text based on the mouse location.
  35. // Works with the CDynamicTooltipMixin class, which the parent view MUST mixin for this
  36. // to work.
  37. //
  38. // To use this class instead of the normal tooltip pane, include the PPob id of an
  39. // instantiation of this class (located in Tooltips.cnst) in the appropriate 
  40. // CTooltipAttachment's properties where it asks for the mTipPaneResID.
  41. //
  42. // NOTE: This will not _crash_ when the parent is not a CDynamicTooltipMixin, but will
  43. // assert so you know you're using it incorrectly.
  44. //
  45.  
  46. class CDynamicTooltipPane : public CToolTipPane
  47. {
  48. public:
  49.     enum { class_ID = 'DyTT' } ;
  50.     
  51.     CDynamicTooltipPane ( LStream* inStream ) : CToolTipPane(inStream) { };
  52.     virtual ~CDynamicTooltipPane ( ) { } ;
  53.  
  54.     virtual void        CalcFrameWithRespectTo(
  55.                             LWindow*                inOwningWindow,
  56.                             LPane*                    inOwningPane,
  57.                             const EventRecord&        inMacEvent,
  58.                             Rect&                     outTipFrame);
  59.  
  60.     virtual    void         CalcTipText(
  61.                             LWindow*                inOwningWindow,
  62.                             LPane*                    inOwningPane,
  63.                             const EventRecord&        inMacEvent,
  64.                             StringPtr                outTipText);
  65.  
  66. }; // CDynamicTooltipPane
  67.  
  68.  
  69. //
  70. // class CDynamicTooltipMixin
  71. //
  72. // Mix into your view/pane and override the appropriate methods to return the correct 
  73. // information to the query for dynamic tooltip text from the CDynamicTooltipPane.
  74. // All methods are pure virtual so you must override them if you intend to use this class.
  75. //
  76. // There is no data in this class, as it only presents an interface.
  77. //
  78. // As a side note, in addition to implementing the FindTooltipforMouseLocation()
  79. // method, you will probably want to override MouseWithin() and track when the
  80. // mouse enters/leaves a "hot" area that gets a tooltip. This is quite important
  81. // if you want to hide the tooltip when the mouse moves away from that spot. The
  82. // code to do this in MouseWithin() would look something like:
  83. //
  84. //        if ( newArea != oldArea ) {
  85. //            ... update your own roll-over feedback as necessary ...
  86. //            ExecuteAttachments ( msg_HideTooltip, nil );
  87. //        }
  88. //
  89. // The CTooltipAttachment responds to this message by hiding the tooltip, thereby
  90. // resetting it for the next "hot spot" the user may move the cursor to within
  91. // the pane.
  92. //
  93.  
  94. class CDynamicTooltipMixin
  95. {
  96.  
  97. public:
  98.     virtual void FindTooltipForMouseLocation ( const EventRecord& inMacEvent,
  99.                                                 StringPtr outTip ) = 0;
  100.  
  101. private:
  102.  
  103.     // make these private so you can't instantiate one of these standalone
  104.     CDynamicTooltipMixin ( ) { } ;
  105.     ~CDynamicTooltipMixin ( ) { } ;
  106.     
  107. }; // CDynamicTooltipMixin
  108.