home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / Toolbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.3 KB  |  150 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.    Toolbar.h -- class definition for the toolbar object.
  20.    Created: Chris Toshok <toshok@netscape.com>, 13-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_toolbar_h
  26. #define _xfe_toolbar_h
  27.  
  28. #include "ToolboxItem.h"
  29.  
  30. //#include "xp_core.h"
  31.  
  32. #include "Command.h"
  33. #include "icons.h"
  34.  
  35. class XFE_View;
  36. class XFE_Frame;
  37. class XFE_Button;
  38. class XFE_Logo;
  39. class XFE_Toolbox;
  40.  
  41. //
  42. // The toolbar is used by many (almost all) of the Frame classes.
  43. //
  44. class XFE_Toolbar : public XFE_ToolboxItem
  45. {
  46.     XFE_Frame *getFrame();
  47.  
  48.     void addButton(const char *name, EChromeTag tag, CommandType command, fe_icon *icon);
  49.  
  50.     virtual Widget findButton(const char *name, EChromeTag tag);
  51.  
  52.     void updateButton(Widget button);
  53.  
  54.     void updateCommand(CommandType command);
  55.  
  56.     void updateAppearance();
  57.  
  58.     XFE_CALLBACK_DECL(doCommand)
  59.  
  60.     // update all the commands in the toolbar.
  61.     XFE_CALLBACK_DECL(update)
  62.     // update a specific command in the toolbar.
  63.     XFE_CALLBACK_DECL(updateCommand)
  64.     // update the toolbar appearance
  65.     XFE_CALLBACK_DECL(updateToolbarAppearance)
  66.  
  67. public:  
  68.  
  69.     XFE_Toolbar(XFE_Frame *            parent_frame,
  70.                 XFE_Toolbox *        parent_toolbox,
  71.                 ToolbarSpec *        spec);
  72.  
  73.     virtual ~XFE_Toolbar();
  74.     void hideButton(const char *name, EChromeTag tag);
  75.     void showButton(const char *name, EChromeTag tag);
  76.     // method version of the callback below.  Used by the frame to force the toolbar
  77.     // to update itself
  78.     void update();
  79.     Widget getToolBar();
  80.     Widget getToolBarForm();
  81.  
  82.     virtual void setToolbarSpec(ToolbarSpec *menu_spec);
  83.  
  84.     // Convert from icon style (from prefs) to button layout enum
  85.     static unsigned char styleToLayout(int32 style);
  86.  
  87. protected:
  88.  
  89.     XFE_Frame *        m_parentFrame;
  90.     ToolbarSpec *    m_spec;
  91.     Widget            m_toolBar;
  92.  
  93.  
  94.     XFE_Button *m_security;
  95.  
  96.     void    createMain                (Widget parent);
  97.     void    createItems                ();
  98.  
  99.     Widget    createItem                (ToolbarSpec *    spec);
  100.     Widget    createPush                (ToolbarSpec *    spec);
  101.     Widget    createSeparator            (ToolbarSpec *    spec);
  102.     Widget    createDynamicCascade    (ToolbarSpec *    spec);
  103.     Widget    createCascade            (ToolbarSpec *    spec);
  104.  
  105.     int        verifyPopupDelay        (int delay);
  106.  
  107.     //////////////////////////////////////////////////////////////////
  108.     //                                                                //
  109.     // User commands support                                        //
  110.     //                                                                //
  111.     //////////////////////////////////////////////////////////////////
  112.     static XtResource    m_user_commandResources[];
  113.     String                m_user_commandName;
  114.     String                m_user_commandData;
  115.     String                m_user_commandIcon;
  116.     String                m_user_commandSubMenu;
  117.  
  118.     void        user_createItems            ();
  119.     
  120.     CommandType    user_verifyCommand    (String                    commandName,
  121.                                      dynamenuCreateProc &    generateProcOut,
  122.                                      void * &                generateArgOut);
  123.  
  124.     void *        user_verifyCommandData    (CommandType        cmd,
  125.                                          String                commandData,
  126.                                          XP_Bool &            needToFreeOut);
  127.     
  128.     IconGroup *    user_verifyCommandIcon    (CommandType        cmd,
  129.                                          String                commandIcon);
  130.     
  131.     MenuSpec *    user_verifySubMenu        (String                commandSubMenu);
  132.     
  133.     void        user_addItem            (String                widgetName,
  134.                                          CommandType        cmd,
  135.                                          EChromeTag            tag,
  136.                                          void *                data,
  137.                                          XP_Bool            needToFreeData,
  138.                                          IconGroup *        ig,
  139.                                          MenuSpec *            subMenuSpec,
  140.                                          XP_Bool            needToFreeSpec,
  141.                                          dynamenuCreateProc    generateProc,
  142.                                          void *                generateArg,
  143.                                          EToolbarPopupDelay    popupDelay);
  144.     
  145.     static void user_commandDestroyCB(Widget,XtPointer,XtPointer);
  146.     static void user_freeCallDataCB(Widget,XtPointer,XtPointer);
  147. };
  148.  
  149. #endif /* _xfe_toolbar_h */
  150.