home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / macfe / central / PopupBox.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.0 KB  |  126 lines

  1. /*-----------------------------------------------------------------------------
  2.     StdPopup
  3.     Written 1994 Netscape Communications Corporation
  4.     
  5.     Portions derived from MacApp, 
  6.     Copyright ⌐ 1984-1994 Apple Computer, Inc. All rights reserved.
  7. -----------------------------------------------------------------------------*/
  8.  
  9. #pragma once
  10. #ifndef _DISCRETE_LIST_BOX_
  11. #define _DISCRETE_LIST_BOX_
  12.  
  13. /*-----------------------------------------------------------------------------
  14.     StdPopup
  15.     We need non-text menu items, so we will use a custom menu definition
  16.     procedure.
  17.     We need to have a dynamic number of menus, so we will use PopupMenuSelect.
  18.     
  19.     static Handle sMenuProc
  20.     In order to use a custom procedure, we need to dispatch from a handle.
  21.     This handle is constant and therefore can be global.
  22.     
  23.     static StdPopup * sMenuObject
  24.     We can't figure out which object called PopupMenuSelect, so we will set
  25.     this global right before calling it. We will never get a menu callback
  26.     except from within PopupMenuSelect.
  27.  
  28.     Handle fDefaultMenuProc
  29.     This is the normal definition procedure for the menu. We'll use it to
  30.     handle most operations; only overriding drawing.
  31.     
  32.     MenuHandle fMenu
  33.     We only need a menu widget when we're calling PopupMenuSelect; we could 
  34.     actually just have 1 of them and reuse it amongst any number of objects, or
  35.     give each item its own widget.
  36.  
  37. //    short item = 0;
  38. //    DoMenuProc (mSizeMsg, m, gZeroRect, gZeroPt, item);
  39. -----------------------------------------------------------------------------*/
  40. #include <Menus.h>
  41. #include <LAttachment.h>
  42. #include <LGAPopup.h>
  43. #include "PascalString.h"
  44.  
  45. class LP_Glypher;
  46.  
  47. #define dlbPopupMenuID 'cz'
  48.  
  49. class CGAPopupMenu;
  50.  
  51. // StdPopup
  52.  
  53. class StdPopup: public LAttachment {
  54. public:
  55.                     StdPopup (CGAPopupMenu* target);
  56.                     ~StdPopup ();
  57.     // definition
  58.     virtual short    GetCount ()=0;
  59.     virtual CStr255    GetText (short item)=0;
  60.     // interface
  61.     Point            CalcTargetFrame (short & baseline);
  62.     void            DirtyMenu ();
  63.     
  64.     ResIDT            GetTextTraits() const;
  65.     ResIDT            SetTextTraits(ResIDT inTextTraits);
  66. protected:
  67.     MenuHandle        GetMacMenuH();
  68.     
  69.     virtual Boolean    NeedCustomPopup() const;
  70.     
  71.      virtual void    SyncMenu (MenuHandle aquiredMenu);
  72.     virtual short    CalcMaxWidth (MenuHandle aquiredMenu);
  73.     void            DrawWidget (MenuHandle aquiredMenu, const Rect & widgetFrame);
  74.     virtual void    ExecuteSelf (MessageT message, void *param);
  75.     
  76.     // do ScriptCode Menu Trick on IM:MacTbxEss Page3-46
  77.     // Give subclass a chance to do it.
  78.     virtual void    SetMenuItemText(MenuHandle aquiredMenu, int item, CStr255& itemText) 
  79.                         { ::SetMenuItemText(aquiredMenu, item, itemText); } ;
  80.     // Let us have a chance to override PopUpMenuSelect
  81.     virtual    long    PopUpMenuSelect(MenuHandle aquiredMenu, short top, short left, short popUpItem)
  82.                         { return ::PopUpMenuSelect( aquiredMenu,  top,  left,  popUpItem); };
  83.     virtual    void     DrawTruncTextBox (CStr255 text, const Rect& box);
  84.  
  85.     friend class TempUseMenu;
  86.     CGAPopupMenu*    fTarget;
  87.     MenuHandle    fMenu; // this is used if we're doing the  UTF8 stuff
  88. private:
  89.     Boolean            fDirty;
  90. };
  91.  
  92.  
  93. class    CGAPopupMenu : public LGAPopup {
  94. friend class StdPopup;
  95. public:
  96.     enum { class_ID = 'Gatt' };
  97.     typedef LGAPopup super;
  98.     
  99.                 CGAPopupMenu(LStream* inStream);
  100.     virtual        ~CGAPopupMenu();
  101.     
  102.     void SetTextTraits(ResIDT inTextTraitsID) { mTextTraitsID = inTextTraitsID; }
  103.     ResIDT GetTextTraits() const { return mTextTraitsID; }
  104.  
  105.     void SetNeedCustomDrawFlag(Boolean needCustomDraw) { mNeedCustomDraw = needCustomDraw; }
  106. // For UTF8
  107.     //----<< Ñ DRAWING Ñ >>------------------------------------------------------------
  108.  
  109.     virtual    void            DrawPopupTitle            ();
  110.     virtual    void            CalcTitleRect                ( Rect    &outRect );        // Ñ OVERRIDE
  111. protected:
  112.     //----<< Ñ POPUP MENU HANDLING Ñ >>------------------------------------------------
  113.  
  114.     virtual    void            HandlePopupMenuSelect    (    Point        inPopupLoc,
  115.                                                                     Int16        inCurrentItem,
  116.                                                                     Int16        &outMenuID,
  117.                                                                     Int16        &outMenuItem );
  118.  
  119.  
  120. private:
  121.     Boolean mNeedCustomDraw;
  122. };
  123.  
  124. #endif /* _DISCRETE_LIST_BOX_ */
  125.  
  126.