home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / src / EditorToolbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.5 KB  |  188 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.  *----------------------------------------------------------------------------
  21.  *
  22.  *  EditorToolbar.h --- Toolbar for Editor and HTML Mail Compose.
  23.  *
  24.  *  Created: David Williams <djw@netscape.com>, Feb-7-1997
  25.  *  RCSID: "$Id: EditorToolbar.h,v 3.1 1998/03/28 03:26:25 ltabb Exp $"
  26.  *
  27.  *----------------------------------------------------------------------------
  28.  */
  29.  
  30.  
  31. #ifndef _xfe_editor_toolbar_h_
  32. #define _xfe_editor_toolbar_h_
  33.  
  34. #include "ToolboxItem.h"
  35. #include "Command.h"
  36. #include "Frame.h"
  37.  
  38. class XFE_ComponentList;
  39.  
  40. class XFE_EditorToolbar : public XFE_ToolboxItem
  41. {
  42. public:
  43.     XFE_EditorToolbar(XFE_Component* parent_frame,
  44.                       XFE_Toolbox *    parent_toolbox,
  45.                       char*        name,
  46.                       ToolbarSpec* spec,
  47.                       Boolean      show_frame);
  48.  
  49.     ~XFE_EditorToolbar();
  50.  
  51.     // contract:
  52.     void   update();
  53.     Widget findButton(const char*, EChromeTag);
  54.     void   updateCommand(CommandType);
  55.  
  56.     // local:
  57.     XFE_Frame* getParentFrame() { return (XFE_Frame*)m_toplevel; }
  58.     Widget     getChildrenManager() { return m_rowcol; };
  59.     void       show();
  60.  
  61. private:
  62.     XFE_ComponentList* m_update_list;
  63.     Widget             m_rowcol;
  64. };
  65.  
  66. class XFE_AbstractMenuItem : public XFE_Component
  67. {
  68. public:
  69.     // methods
  70.     virtual void update() { };
  71.     virtual CommandType getCmdId() = 0;
  72.     virtual XP_Bool showsUpdate() { return TRUE; };
  73.     
  74. };
  75.  
  76. class XFE_MenuItem : public XFE_AbstractMenuItem
  77. {
  78. public:
  79.     XFE_MenuItem(XFE_Component* parent) {
  80.         m_toplevel = parent->getToplevel();
  81.         m_parent = parent;
  82.     }
  83.     XFE_Frame* getParentFrame() {
  84.         return (XFE_Frame*)getToplevel();
  85.     }
  86.     XFE_Component* getParent() {
  87.         return m_parent;
  88.     }
  89. protected:
  90.     // data
  91.     XFE_Component* m_parent;
  92. };
  93.  
  94. class XFE_ActionMenuItem : public XFE_MenuItem
  95. {
  96. public:
  97.     XFE_ActionMenuItem(XFE_Component* parent, CommandType id)
  98.         : XFE_MenuItem(parent) {
  99.         m_cmd_id = id;
  100.         m_cmd_handler = NULL;
  101.     }
  102.     CommandType getCmdId() {
  103.         return m_cmd_id;
  104.     }
  105.     void doCommand(XFE_CommandInfo* info) {
  106.         if (m_cmd_handler != NULL)
  107.             m_cmd_handler->doCommand(getParentFrame(), info);
  108.         else
  109.             getParentFrame()->doCommand(m_cmd_id, NULL, info);
  110.     }
  111.     XP_Bool showsUpdate();
  112. protected:
  113.     // data
  114.     CommandType    m_cmd_id;
  115.     XFE_Command*   m_cmd_handler;
  116. };
  117.  
  118. class XFE_EditorToolbarItem : public XFE_ActionMenuItem
  119. {
  120. public:
  121.     XFE_EditorToolbarItem(XFE_Component* tb, ToolbarSpec* spec) 
  122.     : XFE_ActionMenuItem(tb, 0) {
  123.         m_spec = spec;
  124.         if (spec != NULL)
  125.             m_cmd_id = (CommandType)m_spec->toolbarButtonName;
  126.         else
  127.             m_cmd_id = 0; // FIXME
  128.     }
  129. protected:
  130.     // data
  131.     ToolbarSpec*   m_spec;
  132. };
  133.  
  134. class XFE_MenuSpecItem : public XFE_ActionMenuItem
  135. {
  136. public:
  137.     XFE_MenuSpecItem(XFE_Component* tb, MenuSpec* spec) 
  138.     : XFE_ActionMenuItem(tb, 0) {
  139.         m_spec = spec;
  140.         if (spec != NULL)
  141.             m_cmd_id = m_spec->menuItemName;
  142.         else
  143.             m_cmd_id = 0; // FIXME
  144.     }
  145. protected:
  146.     // data
  147.     MenuSpec* m_spec;
  148. };
  149.  
  150. class XFE_EditorToolbarPushButton : public XFE_EditorToolbarItem
  151. {
  152. public:
  153.     XFE_EditorToolbarPushButton(Widget         parent,
  154.                                 ToolbarSpec*   spec,
  155.                                 XFE_Component* tb);
  156.     void update();
  157. };
  158.  
  159. class XFE_EditorToolbarToggleButton : public XFE_EditorToolbarItem
  160. {
  161. public:
  162.     XFE_EditorToolbarToggleButton(Widget parent,
  163.                                   ToolbarSpec* spec,
  164.                                   XFE_Component* tb);
  165.                                   
  166.     void update();
  167. };
  168.  
  169. class XFE_EditorToolbarRadioButton : public XFE_EditorToolbarToggleButton
  170. {
  171. public:
  172.     XFE_EditorToolbarRadioButton(Widget parent,
  173.                                  ToolbarSpec* spec,
  174.                                  XFE_Component* tb);
  175. };
  176.  
  177. class XFE_EditorToolbarSpacer : public XFE_EditorToolbarItem
  178. {
  179. public:
  180.     XFE_EditorToolbarSpacer(Widget parent, XFE_Component* tb);
  181.     XP_Bool showsUpdate() { return FALSE; };
  182. };
  183.  
  184. #endif /*_xfe_editor_toolbar_h_*/
  185.  
  186.  
  187.  
  188.