This commit is contained in:
akkana%netscape.com 1998-08-13 21:51:02 +00:00
Родитель 0446a265f4
Коммит b300b57b42
10 изменённых файлов: 287 добавлений и 75 удалений

Просмотреть файл

@ -35,6 +35,12 @@
#include "xpassert.h"
#include "csid.h"
#ifdef ENDER
#include "EditorFrame.h"
#include "EditorView.h"
#include "EditorToolbar.h"
#endif
#include "DtWidgets/ComboBox.h"
#include <Xfe/Xfe.h>
@ -240,6 +246,59 @@ ToolbarSpec XFE_BrowserFrame::toolbar_spec[] = {
{ NULL }
};
#ifdef ENDER
static ToolbarSpec alignment_menu_spec[] = {
{ xfeCmdSetAlignmentStyleLeft, PUSHBUTTON, &ed_left_group },
{ xfeCmdSetAlignmentStyleCenter, PUSHBUTTON, &ed_center_group },
{ xfeCmdSetAlignmentStyleRight, PUSHBUTTON, &ed_right_group },
{ NULL }
};
static ToolbarSpec goodies_menu_spec[] = {
{ xfeCmdInsertLink, PUSHBUTTON, &ed_link_group },
{ xfeCmdInsertTarget, PUSHBUTTON, &ed_target_group },
{ xfeCmdInsertImage, PUSHBUTTON, &ed_image_group },
{ xfeCmdInsertHorizontalLine, PUSHBUTTON, &ed_hrule_group },
{ xfeCmdInsertTable, PUSHBUTTON, &ed_table_group },
{ NULL }
};
static ToolbarSpec editor_style_toolbar_spec[] = {
{ xfeCmdSetParagraphStyle, COMBOBOX },
{ xfeCmdSetFontFace, COMBOBOX },
{ xfeCmdSetFontSize, COMBOBOX },
{ xfeCmdSetFontColor, COMBOBOX },
TOOLBAR_SEPARATOR,
{ xfeCmdToggleCharacterStyleBold, TOGGLEBUTTON, &ed_bold_group },
{ xfeCmdToggleCharacterStyleItalic, TOGGLEBUTTON, &ed_italic_group },
{ xfeCmdToggleCharacterStyleUnderline, TOGGLEBUTTON, &ed_underline_group },
{ xfeCmdClearAllStyles, PUSHBUTTON , &ed_clear_group },
TOOLBAR_SEPARATOR,
{ xfeCmdInsertBulletedList, TOGGLEBUTTON, &ed_bullet_group },
{ xfeCmdInsertNumberedList, TOGGLEBUTTON, &ed_number_group },
TOOLBAR_SEPARATOR,
{ xfeCmdOutdent, PUSHBUTTON, &ed_outdent_group },
{ xfeCmdIndent, PUSHBUTTON, &ed_indent_group },
{ xfeCmdSetAlignmentStyle, CASCADEBUTTON, &ed_left_group, 0, 0, 0,
(MenuSpec*)&alignment_menu_spec },
{ "editorGoodiesMenu", CASCADEBUTTON, &ed_insert_group, 0, 0, 0,
(MenuSpec*)&goodies_menu_spec },
{ NULL }
};
#endif /* ENDER */
static XFE_CommandList* my_commands;
XFE_Command*
XFE_BrowserFrame::getCommand(CommandType cmd)
{
return findCommand(my_commands, cmd);
}
extern "C" void fe_HackTranslations (MWContext *, Widget);
XFE_BrowserFrame::XFE_BrowserFrame(Widget toplevel,
@ -284,6 +343,21 @@ XFE_BrowserFrame::XFE_BrowserFrame(Widget toplevel,
"personalToolbarItem",
this);
#ifdef ENDER
// Create the editor toolbars needed for embedded composer
m_editorStyleToolbar = new XFE_EditorToolbar(this,
m_toolbox,
"editorFormattingToolbar",
(ToolbarSpec*)&editor_style_toolbar_spec,
True);
// don't show the editor toolbars; they will be turned on when
// we load a page which contains an htmlarea.
// Need to register commands which the editor toolbars will need:
registerCommand(my_commands, new SetFontColorCommand(0));
#endif /* ENDER */
// add notification now 'cuz frame->getURL might not get called and
// fe_SetURLString will break.
registerInterest(XFE_HTMLView::newURLLoading,
@ -367,6 +441,26 @@ XFE_BrowserFrame::updateToolbar()
m_toolbar->update();
}
#ifdef ENDER
void
XFE_BrowserFrame::showEditorToolbar(XFE_View* view)
{
if (m_editorStyleToolbar)
{
m_editorStyleToolbar->show();
if (view)
m_editorStyleToolbar->setCommandDispatcher(view);
}
}
void
XFE_BrowserFrame::hideEditorToolbar()
{
if (m_editorStyleToolbar)
m_editorStyleToolbar->hide();
}
#endif /* ENDER */
XP_Bool
XFE_BrowserFrame::isCommandEnabled(CommandType cmd,
void *calldata, XFE_CommandInfo*)
@ -599,6 +693,10 @@ XFE_CALLBACK_DEFN(XFE_BrowserFrame, newPageLoading)
getLogo()->easterEgg(url);
}
#endif /* NETSCAPE_PRIV */
#ifdef ENDER
hideEditorToolbar();
#endif /* ENDER */
}
XFE_CALLBACK_DEFN(XFE_BrowserFrame, updateToolbarAppearance)(XFE_NotificationCenter */*obj*/,

Просмотреть файл

@ -33,6 +33,8 @@
#include "PersonalToolbar.h"
#include <Xm/Xm.h>
class XFE_EditorToolbar;
class XFE_BrowserFrame : public XFE_Frame
{
public:
@ -56,12 +58,22 @@ public:
virtual void respectChrome(Chrome * chrome);
static void bringToFrontOrMakeNew(Widget toplevel);
virtual XFE_Command* getCommand(CommandType);
#ifdef ENDER
void showEditorToolbar(XFE_View*);
void hideEditorToolbar();
#endif /* ENDER */
private:
XFE_PersonalToolbar * m_personalToolbar;
XFE_URLBar * m_urlBar;
XFE_BrowserDrop * m_browserDropSite;
#ifdef ENDER
XFE_EditorToolbar * m_editorStyleToolbar;
#endif /* ENDER */
XP_Bool m_notification_added;

Просмотреть файл

@ -273,7 +273,10 @@ XFE_ViewCommand::isDeterminate(XFE_Frame* frame, XFE_CommandInfo* info)
if (!view)
view = frame_to_view(this, frame, info);
return ((XFE_AbstractCommand*)this)->isDeterminate(view, info);
if (view)
return ((XFE_AbstractCommand*)this)->isDeterminate(view, info);
return FALSE;
}
XFE_CommandParameters*

Просмотреть файл

@ -423,7 +423,7 @@ static ToolbarSpec editor_file_toolbar_spec[] = {
{ NULL }
};
static ToolbarSpec alignment_menu_spec[] = {
ToolbarSpec XFE_EditorFrame::alignment_menu_spec[] = {
{ xfeCmdSetAlignmentStyleLeft, PUSHBUTTON, &ed_left_group },
{ xfeCmdSetAlignmentStyleCenter, PUSHBUTTON, &ed_center_group },
{ xfeCmdSetAlignmentStyleRight, PUSHBUTTON, &ed_right_group },
@ -450,7 +450,7 @@ static ToolbarSpec editor_style_toolbar_spec[] = {
{ xfeCmdOutdent, PUSHBUTTON, &ed_outdent_group },
{ xfeCmdIndent, PUSHBUTTON, &ed_indent_group },
{ xfeCmdSetAlignmentStyle, CASCADEBUTTON, &ed_left_group, 0, 0, 0,
(MenuSpec*)&alignment_menu_spec },
(MenuSpec*)&XFE_EditorFrame::alignment_menu_spec },
{ NULL }
};

Просмотреть файл

@ -81,6 +81,10 @@ public:
static MenuSpec save_submenu_spec[];
static MenuSpec publish_submenu_spec[];
// alignment menu spec needs to be public so BrowserFrame can
// use it for embedded editors:
static ToolbarSpec alignment_menu_spec[];
private:
XFE_EditorToolbar* m_format_toolbar;

Просмотреть файл

@ -22,7 +22,7 @@
* EditorToolbar.cpp --- Toolbar for Editor and HTML Mail Compose.
*
* Created: David Williams <djw@netscape.com>, Feb-7-1997
* RCSID: "$Id: EditorToolbar.cpp,v 3.1 1998/03/28 03:26:24 ltabb Exp $"
* RCSID: "$Id: EditorToolbar.cpp,v 3.2 1998/08/13 21:50:58 akkana%netscape.com Exp $"
*
*----------------------------------------------------------------------------
*/
@ -213,6 +213,75 @@ XFE_EditorToolbarPushButton::XFE_EditorToolbarPushButton(Widget,
{
}
XFE_Command*
XFE_ActionMenuItem::getCommand(CommandType id)
{
XFE_Frame* frame = getParentFrame();
XFE_View* view = 0;
XFE_Command* cmd = 0;
if (id == 0)
id = m_cmd_id;
// get the dispatcher from the XFE_EditorToolbar m_parent
if (m_parent->isClassOf("EditorToolbar"))
{
XFE_EditorToolbar* tb = (XFE_EditorToolbar*)m_parent;
if (tb)
{
XFE_Component* cmdDispatcher = tb->getCommandDispatcher();
/* See comments in Menu.cpp */
if (cmdDispatcher)
{
if (cmdDispatcher->isClassOf("View"))
view = (XFE_View *)cmdDispatcher;
else if (cmdDispatcher->isClassOf("Frame"))
frame = (XFE_Frame *)cmdDispatcher;
}
}
}
if (view)
cmd = view->getCommand(id);
else if (frame)
cmd = frame->getCommand(id);
return cmd;
}
XFE_Component *
XFE_ActionMenuItem::getCommandDispatcher()
{
// get the dispatcher from the XFE_EditorToolbar m_parent
if (m_parent->isClassOf("EditorToolbar"))
{
XFE_EditorToolbar* tb = (XFE_EditorToolbar*)m_parent;
if (tb)
{
XFE_Component* cmdDispatcher = tb->getCommandDispatcher();
if (cmdDispatcher)
return cmdDispatcher;
}
}
return getParentFrame();
}
void XFE_ActionMenuItem::doCommand(XFE_CommandInfo* info)
{
if (m_cmd_handler != NULL)
m_cmd_handler->doCommand(getParentFrame(), info);
else
{
XFE_Component* dispatcher = getCommandDispatcher();
if (dispatcher && dispatcher->isClassOf("View"))
((XFE_View*)dispatcher)->doCommand(m_cmd_id, NULL, info);
else if (dispatcher && dispatcher->isClassOf("Frame"))
((XFE_Frame*)dispatcher)->doCommand(m_cmd_id, NULL, info);
else
getParentFrame()->doCommand(m_cmd_id, NULL, info);
}
}
void
XFE_EditorToolbarPushButton::update()
{
@ -223,7 +292,7 @@ XFE_EditorToolbarPushButton::update()
// Do we have a command handler?
//
if (!m_cmd_handler)
m_cmd_handler = getParentFrame()->getCommand(m_cmd_id);
m_cmd_handler = getCommand(m_cmd_id);
if (m_cmd_handler != NULL)
sensitive = m_cmd_handler->isEnabled(getParentFrame(), &e_info);
@ -327,7 +396,7 @@ XFE_EditorToolbarToggleButton::update()
// Do we have a command handler?
//
if (!m_cmd_handler)
m_cmd_handler = getParentFrame()->getCommand(m_cmd_id);
m_cmd_handler = getCommand(m_cmd_id);
if (m_cmd_handler != NULL) {
sensitive = m_cmd_handler->isEnabled(frame, &e_info);
@ -408,7 +477,7 @@ cl_selection_cb(Widget /*widget*/, XtPointer client_data, XtPointer cb_data)
{
DtComboBoxCallbackStruct* info = (DtComboBoxCallbackStruct*)cb_data;
XFE_ComboList* list = (XFE_ComboList*)client_data;
list->itemSelected(info->item_position);
}
@ -448,7 +517,7 @@ XFE_ComboList::XFE_ComboList(Widget parent, ToolbarSpec* spec,
XtSetArg(args[n], XmNmarginHeight, 0); n++;
XtSetArg(args[n], XmNarrowType, XmMOTIF); n++;
m_combo = DtCreateComboBox(m_widget,
(char*)spec->toolbarButtonName,
(char*)spec->toolbarButtonName,
args, n);
XtManageChild(m_combo);
@ -565,8 +634,8 @@ XFE_SmartComboList::update()
XFE_Frame* frame = getParentFrame();
int index = -1;
if (!m_cmd_handler)
m_cmd_handler = getParentFrame()->getCommand(m_cmd_id);
if (!m_cmd_handler)
m_cmd_handler = getCommand();
if (m_cmd_handler != NULL) {
if (!m_params) {
@ -1227,6 +1296,8 @@ XFE_EditorToolbar::XFE_EditorToolbar(XFE_Component* parent_frame,
m_toplevel = parent_frame;
m_update_list = NULL;
m_cmdDispatcher = 0;
m_rowcol = make_toolbar(parent_toolbox->getBaseWidget(),
name, spec, this, do_frame);
@ -1264,6 +1335,11 @@ XFE_EditorToolbar::~XFE_EditorToolbar()
command_update_cb);
}
const char* XFE_EditorToolbar::getClassName()
{
return "XFE_EditorToolbar::className";
}
Widget
XFE_EditorToolbar::findButton(const char* /*name*/,
EChromeTag /*tag*/)

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@ -22,7 +22,7 @@
* EditorToolbar.h --- Toolbar for Editor and HTML Mail Compose.
*
* Created: David Williams <djw@netscape.com>, Feb-7-1997
* RCSID: "$Id: EditorToolbar.h,v 3.2 1998/06/22 21:19:13 spider Exp $"
* RCSID: "$Id: EditorToolbar.h,v 3.3 1998/08/13 21:50:59 akkana%netscape.com Exp $"
*
*----------------------------------------------------------------------------
*/
@ -48,11 +48,16 @@ public:
virtual ~XFE_EditorToolbar();
virtual const char* getClassName(); // return the class name
// contract:
void update();
Widget findButton(const char*, EChromeTag);
void updateCommand(CommandType);
XFE_Component* getCommandDispatcher() { return m_cmdDispatcher; }
void setCommandDispatcher(XFE_Component* d) { m_cmdDispatcher = d; }
// local:
XFE_Frame* getParentFrame() { return (XFE_Frame*)m_toplevel; }
Widget getChildrenManager() { return m_rowcol; };
@ -61,6 +66,7 @@ public:
private:
XFE_ComponentList* m_update_list;
Widget m_rowcol;
XFE_Component * m_cmdDispatcher;
};
class XFE_AbstractMenuItem : public XFE_Component
@ -70,7 +76,6 @@ public:
virtual void update() { };
virtual CommandType getCmdId() = 0;
virtual XP_Bool showsUpdate() { return TRUE; };
};
class XFE_MenuItem : public XFE_AbstractMenuItem
@ -102,12 +107,9 @@ public:
CommandType getCmdId() {
return m_cmd_id;
}
void doCommand(XFE_CommandInfo* info) {
if (m_cmd_handler != NULL)
m_cmd_handler->doCommand(getParentFrame(), info);
else
getParentFrame()->doCommand(m_cmd_id, NULL, info);
}
XFE_Command* getCommand(CommandType id = 0);
XFE_Component* getCommandDispatcher();
void doCommand(XFE_CommandInfo* info);
XP_Bool showsUpdate();
protected:
// data

Просмотреть файл

@ -40,35 +40,6 @@ extern "C" int XFE_EDITOR_NEWTABLE_COLS;
#define FE_SYNTAX_ERROR() doSyntaxErrorAlert(view, info)
//
// This acts as an encapsulator for the doCommand() method.
// Sub-classes impliment a reallyDoCommand(), and leave the
// boring maintainence work to this class. This approach
// saves every sub-class from calling super::doCommand(),
// which would really be a drag, now wouldn't it.
//
class XFE_EditorViewCommand : public XFE_ViewCommand
{
public:
XFE_EditorViewCommand(char* name, XFE_EditorView *v = NULL) : XFE_ViewCommand(name, v) {};
virtual void reallyDoCommand(XFE_View*, XFE_CommandInfo*) = 0;
virtual XP_Bool requiresChromeUpdate() {
return TRUE;
};
void doCommand(XFE_View* v_view, XFE_CommandInfo* info) {
XFE_EditorView* view = (XFE_EditorView*)v_view;
if (m_view)
view = (XFE_EditorView *)m_view;
reallyDoCommand(view, info);
if (requiresChromeUpdate()) {
view->updateChrome();
}
};
};
class UndoCommand : public XFE_EditorViewCommand
{
public:
@ -213,16 +184,6 @@ public:
};
};
class AlwaysEnabledCommand : public XFE_EditorViewCommand
{
public:
AlwaysEnabledCommand(char* name, XFE_EditorView *v) : XFE_EditorViewCommand(name, v) {};
XP_Bool isEnabled(XFE_View*, XFE_CommandInfo*) {
return True;
};
};
class DeleteCommand : public AlwaysEnabledCommand
{
public:
@ -1121,24 +1082,10 @@ SetFontFaceCommand::reallyDoCommand(XFE_View* view, XFE_CommandInfo* info)
set(view, index);
}
class SetFontColorCommand : public AlwaysEnabledCommand
XP_Bool SetFontColorCommand::isDeterminate(XFE_View* view, XFE_CommandInfo*)
{
public:
SetFontColorCommand(XFE_EditorView *v) : AlwaysEnabledCommand(xfeCmdSetFontColor, v) {
m_params = NULL;
};
virtual XP_Bool isDynamic() { return TRUE; };
XP_Bool isDeterminate(XFE_View* view, XFE_CommandInfo*) {
return style_is_determinate(view->getContext(), TF_FONT_COLOR);
};
XFE_CommandParameters* getParameters(XFE_View* view);
int getParameterIndex(XFE_View* view);
void setParameterIndex(XFE_View* view, unsigned index);
void reallyDoCommand(XFE_View* view, XFE_CommandInfo* info);
private:
XFE_CommandParameters* m_params;
};
return style_is_determinate(view->getContext(), TF_FONT_COLOR);
}
XFE_CommandParameters*
SetFontColorCommand::getParameters(XFE_View*)

Просмотреть файл

@ -79,5 +79,66 @@ private:
static void updateChromeTimeout(XtPointer closure, XtIntervalId* id);
};
// Command classes which need to be public
// (needed by BrowserFrame for embedded editor)
// This acts as an encapsulator for the doCommand() method.
// Sub-classes impliment a reallyDoCommand(), and leave the
// boring maintainence work to this class. This approach
// saves every sub-class from calling super::doCommand(),
// which would really be a drag, now wouldn't it.
//
class XFE_EditorViewCommand : public XFE_ViewCommand
{
public:
XFE_EditorViewCommand(char* name, XFE_EditorView *v = NULL)
: XFE_ViewCommand(name, v) {};
virtual void reallyDoCommand(XFE_View*, XFE_CommandInfo*) = 0;
virtual XP_Bool requiresChromeUpdate() {
return TRUE;
};
void doCommand(XFE_View* v_view, XFE_CommandInfo* info) {
XFE_EditorView* view = (XFE_EditorView*)v_view;
if (m_view)
view = (XFE_EditorView *)m_view;
reallyDoCommand(view, info);
if (requiresChromeUpdate()) {
view->updateChrome();
}
};
};
class AlwaysEnabledCommand : public XFE_EditorViewCommand
{
public:
AlwaysEnabledCommand(char* name, XFE_EditorView *v)
: XFE_EditorViewCommand(name, v) {};
XP_Bool isEnabled(XFE_View*, XFE_CommandInfo*) {
return True;
};
};
class SetFontColorCommand : public AlwaysEnabledCommand
{
public:
SetFontColorCommand(XFE_EditorView *v)
: AlwaysEnabledCommand(xfeCmdSetFontColor, v) {
m_params = NULL;
};
virtual XP_Bool isDynamic() { return TRUE; };
XP_Bool isDeterminate(XFE_View* view, XFE_CommandInfo*);
XFE_CommandParameters* getParameters(XFE_View* view);
int getParameterIndex(XFE_View* view);
void setParameterIndex(XFE_View* view, unsigned index);
void reallyDoCommand(XFE_View* view, XFE_CommandInfo* info);
private:
XFE_CommandParameters* m_params;
};
#endif /* _xfe_editorview_h */

Просмотреть файл

@ -28,6 +28,7 @@
#include "ViewGlue.h"
#include "il_util.h"
#include "layers.h"
#include "BrowserFrame.h"
#ifndef NO_WEB_FONTS
#include "Mnfrf.h"
@ -160,6 +161,14 @@ XFE_CreateEmbeddedEditor(Widget parent, int32 cols, int32 rows,
URL_Struct* url = NET_CreateURLStruct(default_url, NET_NORMAL_RELOAD);
eev->getURL(url);
// Show the editor toolbars in the containing Frame:
// XXX NOTE! This needs to be redone when we support
// an embedded editor inside an EditorFrame.
XFE_BrowserFrame* bf = (XFE_BrowserFrame*)frame;
if (bf)
bf->showEditorToolbar(eev);
return(w);
}