home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / Menu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.3 KB  |  171 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.    Menu -- class definition for menu bars.
  20.    Created: Chris Toshok <toshok@netscape.com>, 7-Aug-96.
  21.  */
  22.  
  23.  
  24.  
  25. #ifndef _xfe_menu_h
  26. #define _xfe_menu_h
  27.  
  28. #include "Component.h"
  29. #include "Command.h"
  30. #include "Chrome.h"
  31.  
  32. class XFE_View;
  33. class XFE_Frame;
  34.  
  35. typedef void (*dynamenuCreateProc)(Widget, void *, XFE_Frame *);
  36.  
  37. typedef struct MenuSpec {
  38.   /* these are generally initialized in a menu spec. */
  39.   char *menuItemName;
  40.   EChromeTag tag;
  41.   struct MenuSpec *submenu;
  42.   char *radioGroupName;
  43.   Boolean toggleSet;
  44.   void *callData; /* sent in the callData portion of the *Command functions. */
  45.  
  46.   dynamenuCreateProc generateProc;
  47.   
  48.   /* Paramaterization stuff */
  49.   char*  cmd_name;
  50.   char*  cmd_args[8];
  51.  
  52.   Boolean do_not_manage; /* set to true if we don't manage this item */
  53.  
  54.   //  methods
  55.   char* getCmdName() {
  56.     return (cmd_name != NULL)? cmd_name: menuItemName;
  57.   }
  58.   
  59. } MenuSpec;
  60.  
  61. /* nice shortcuts */
  62. #define MENU_SEPARATOR { "--", SEPARATOR }
  63. #define MENU_END { NULL }
  64. #define MENU_TOGGLE(w) \
  65. { (w), TOGGLEBUTTON }
  66. #define MENU_TOGGLE_1ARG(w,c,a) \
  67. { (w), TOGGLEBUTTON, 0, 0, 0, 0, 0, (c), { (a) } }
  68. #define MENU_PUSHBUTTON(w) \
  69. { (w), PUSHBUTTON }
  70. #define MENU_PUSHBUTTON_NAMED(w, c) \
  71. { (w), PUSHBUTTON, 0, 0, 0, 0, 0, (c) }
  72. #define MENU_PUSHBUTTON_1ARG(w,c,a) \
  73. { (w), PUSHBUTTON, 0, 0, 0, 0, 0, (c), { (a) } }
  74. #define MENU_MENU(w, s) \
  75. { (w), CASCADEBUTTON, (MenuSpec*)(s) }
  76.  
  77. #define xfeMenuFile "fileMenu"
  78. #define xfeMenuEdit "editMenu"
  79. #define xfeMenuView "viewMenu"
  80. #define xfeMenuInsert "insertMenu"
  81. #define xfeMenuFormat "formatMenu"
  82. #define xfeMenuTools "toolsMenu"
  83. #define xfeMenuGo "goMenu"
  84. #define xfeMenuItem "itemMenu"
  85. #define xfeMenuMessage "messageMenu"
  86. #define xfeMenuBookmark "bookmarkMenu"
  87.  
  88. #if defined(MOZ_MAIL_NEWS) && defined(EDITOR) && defined(MOZ_TASKBAR)
  89. #define xfeMenuWindow "windowMenu"
  90. #else
  91. #define xfeMenuWindow "windowMenuLite"
  92. #endif
  93.  
  94. #define xfeMenuHelp "helpMenu"
  95.  
  96. // this next one is going away soon... don't use it.  Use windowMenu
  97. #define xfeMenuNavigate "navigateMenu"
  98.  
  99. class XFE_Menu : public XFE_Component
  100. {
  101. public:
  102.   XFE_Menu(XFE_Frame *parent_frame, MenuSpec *menu_spec, Widget baseMenuWidget);
  103.   virtual ~XFE_Menu();
  104.  
  105.   XFE_Frame *getFrame();
  106.  
  107.   void setMenuSpec(MenuSpec *menu_spec);
  108.  
  109.   // interface for view's adding and subtracting menu items
  110.   Widget addMenuItem(char *itemName, EChromeTag tag, 
  111.              MenuSpec *submenuSpec = NULL, char *radioGroupName = NULL,
  112.              Boolean toggleSet = False, void *callData = NULL, dynamenuCreateProc generateProc = NULL,
  113.              int position = XmLAST_POSITION);
  114.   void removeMenuItem(char *itemName, EChromeTag tag);
  115.  
  116.   void hideMenuItem(char *itemName, EChromeTag tag);
  117.   void showMenuItem(char *itemName, EChromeTag tag);
  118.   Widget findMenuItem(char *itemName, EChromeTag tag);
  119.  
  120.   void addMenuSpec(MenuSpec *menu_spec);
  121.  
  122.   void update();
  123.   void updateSubMenu(Widget submenu);
  124.   void updateMenuItem(Widget menuItem);
  125.  
  126.   void updateCommand(CommandType command);
  127.   void updateCommandInSubMenu(CommandType command, Widget submenu);
  128.   void updateCommandInMenuItem(CommandType command, Widget menuItem);
  129.  
  130.   // update all the commands in the menu.
  131.   XFE_CALLBACK_DECL(update)
  132.   // update a specific command in the menu.
  133.   XFE_CALLBACK_DECL(updateCommand)
  134.  
  135. protected:
  136.   void createWidgets();
  137.   void createWidgets(MenuSpec *spec);
  138.  
  139.   Widget findMenuItemInMenu(char *itemName, EChromeTag tag, Widget menu);
  140.  
  141. private:
  142.   XFE_Frame *m_parentFrame;
  143.   MenuSpec *m_spec;
  144.  
  145.   Widget createPulldown(char *cascadeName, MenuSpec *spec, Widget parent_menu, XP_Bool is_fancy);
  146.   Widget createMenuItem(MenuSpec *spec, Widget parent_cascade, Widget parent);
  147.  
  148. #ifdef DELAYED_MENU_CREATION
  149.   void delayedCreatePulldown(Widget cascade, Widget pulldown, MenuSpec *spec);
  150.   static void delayed_create_pulldown(Widget, XtPointer, XtPointer);
  151. #endif
  152.  
  153.   void updateToggleGroup(Widget w);
  154.  
  155.   static void pushb_arm_cb(Widget, XtPointer, XtPointer);
  156.   static void pushb_activate_cb(Widget, XtPointer, XtPointer);
  157.   static void pushb_disarm_cb(Widget, XtPointer, XtPointer);
  158.  
  159.   static void toggleb_arm_cb(Widget, XtPointer, XtPointer);
  160.   static void toggleb_activate_cb(Widget, XtPointer, XtPointer);
  161.   static void toggleb_disarm_cb(Widget, XtPointer, XtPointer);
  162.  
  163.   static void radiob_arm_cb(Widget, XtPointer, XtPointer);
  164.   static void radiob_activate_cb(Widget, XtPointer, XtPointer);
  165.   static void radiob_disarm_cb(Widget, XtPointer, XtPointer);
  166.  
  167.   static void cascade_update_cb(Widget, XtPointer, XtPointer);
  168. };
  169.  
  170. #endif /* _xfe_menu_h */
  171.