Fixes for switching focus on Ender toolbars

This commit is contained in:
akkana%netscape.com 1998-08-21 23:02:19 +00:00
Родитель 3bf3d8097f
Коммит a2ea33ac12
5 изменённых файлов: 87 добавлений и 10 удалений

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

@ -121,6 +121,9 @@ extern int XP_EDT_DRAG_TABLE;
extern void fe_MailComposeDocumentLoaded(MWContext*);
extern void fe_HackEditorNotifyToolbarUpdated(MWContext* context);
#ifdef ENDER
extern void XFE_EmbeddedEditorViewFocus(MWContext*);
#endif /* ENDER */
static void
fe_Bell(MWContext* context)
@ -6161,9 +6164,9 @@ void xfe_GetShiftAndCtrl(XEvent* event, Boolean* shiftP, Boolean* ctrlP)
* selected cell (if any), which means this code would have to live in
* EditorView.cpp. But that means a lot of code change which I won't
* be able to check in for quite some time due to the stability freeze.
* So as a TEMPORARY measure, they're implemented as statics and we
* So as a temporary measure, they're implemented as statics and we
* count on the unliklihood of selection-extending in multiple windows
* at once. (Safe for drag-select, unsafe for shift-ctrl-click.) Yuck.
* at once. (Safe for drag-select, less so for shift-ctrl-click.) Yuck.
*/
static LO_Element* edElement = 0;
static XP_Bool crossedCellBoundary = FALSE;
@ -6369,7 +6372,16 @@ fe_EditorGrabFocus(MWContext* context, XEvent *event)
}
}
else
{
#ifdef ENDER
/* See if we're in an HTML textarea -- if so, we need to fiddle
* with toolbars to indicate which area has focus.
*/
if (EDITOR_CONTEXT_DATA(context)->embedded)
XFE_EmbeddedEditorViewFocus(context);
#endif /* ENDER */
edElement = 0;
}
crossedCellBoundary = FALSE;
}

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

@ -448,9 +448,13 @@ XFE_BrowserFrame::showEditorToolbar(XFE_View* view)
{
if (m_editorStyleToolbar)
{
m_editorStyleToolbar->show();
if (view)
m_editorStyleToolbar->setCommandDispatcher(view);
m_editorStyleToolbar->update();
// XXX Need to find a way to reset the toolbar to reflect
// what's selected in the current view. This doesn't do it:
//m_editorStyleToolbar->updateCommand(0);
m_editorStyleToolbar->show();
}
}

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

@ -101,6 +101,12 @@ XFE_Command::isSlow()
return TRUE; // of course
}
XP_Bool
XFE_Command::isViewCommand()
{
return FALSE;
}
XP_Bool
XFE_Command::isEnabled(XFE_View*, XFE_CommandInfo*)
{
@ -243,6 +249,12 @@ frame_to_view(XFE_Command* command, XFE_Frame* frame, XFE_CommandInfo*)
return NULL;
}
XP_Bool
XFE_ViewCommand::isViewCommand()
{
return TRUE;
}
XP_Bool
XFE_ViewCommand::isEnabled(XFE_Frame* frame, XFE_CommandInfo* info)
{

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

@ -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.2 1998/08/13 21:50:58 akkana%netscape.com Exp $"
* RCSID: "$Id: EditorToolbar.cpp,v 3.3 1998/08/21 23:02:19 akkana%netscape.com Exp $"
*
*----------------------------------------------------------------------------
*/
@ -269,7 +269,15 @@ XFE_ActionMenuItem::getCommandDispatcher()
void XFE_ActionMenuItem::doCommand(XFE_CommandInfo* info)
{
if (m_cmd_handler != NULL)
{
if (m_cmd_handler->isViewCommand())
{
XFE_Component* dispatcher = getCommandDispatcher();
if (dispatcher && dispatcher->isClassOf("View"))
((XFE_ViewCommand*)m_cmd_handler)->setView((XFE_View*)dispatcher);
}
m_cmd_handler->doCommand(getParentFrame(), info);
}
else
{
XFE_Component* dispatcher = getCommandDispatcher();

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

@ -74,6 +74,23 @@ XFE_EmbeddedEditorView::~XFE_EmbeddedEditorView()
parent_view->removeView(this);
}
extern "C" XFE_Frame*
fe_getFrameFromContext(MWContext* context)
{
XFE_Frame *frame = 0;
while (context)
{
frame = ViewGlue_getFrame(context);
if (frame)
return frame;
if (context->grid_parent)
context = context->grid_parent;
else
return 0;
}
return 0; /* warning control -- shouldn't actually get here */
}
extern "C" Widget
XFE_CreateEmbeddedEditor(Widget parent, int32 cols, int32 rows,
const char *default_url, MWContext *context)
@ -81,7 +98,10 @@ XFE_CreateEmbeddedEditor(Widget parent, int32 cols, int32 rows,
Widget w;
MWContext *new_context;
XFE_Frame *frame = (XFE_Frame *)CONTEXT_DATA(context)->view;
XFE_Frame *frame = fe_getFrameFromContext(context);
XP_ASSERT(frame);
if (!frame)
return 0;
XFE_View *view = frame->widgetToView(parent);
new_context = fe_CreateNewContext(MWContextEditor, CONTEXT_WIDGET(context),
@ -131,9 +151,6 @@ XFE_CreateEmbeddedEditor(Widget parent, int32 cols, int32 rows,
cols2pixels = overall.width;
rows2pixels = ascent + descent;
/* could also use CONTEXT_DATA(context)->line_height */
#ifdef DEBUG_akkana
printf("Read the font: %d x %d\n", rows2pixels, cols2pixels);
#endif
}
else
{
@ -172,10 +189,31 @@ XFE_CreateEmbeddedEditor(Widget parent, int32 cols, int32 rows,
return(w);
}
extern "C" void
XFE_EmbeddedEditorViewFocus(MWContext* context)
{
XFE_Frame *frame = fe_getFrameFromContext(context);
XFE_EmbeddedEditorView* eev = 0;
XP_ASSERT(frame);
if (frame)
eev = (XFE_EmbeddedEditorView*)frame->widgetToView(CONTEXT_DATA(context)->drawing_area);
XP_ASSERT(eev);
if (!eev)
return;
XFE_BrowserFrame* bf = (XFE_BrowserFrame*)frame;
if (bf)
{
bf->showEditorToolbar(eev);
}
}
extern "C" MWContext *
XFE_GetEmbeddedEditorContext(Widget w, MWContext *context)
{
XFE_Frame *frame = (XFE_Frame *)CONTEXT_DATA(context)->view;
XFE_Frame *frame = fe_getFrameFromContext(context);
XP_ASSERT(frame);
if (!frame)
return 0;
XFE_View *view = frame->widgetToView(w);
return((view) ? view->getContext() : 0);
@ -184,7 +222,10 @@ XFE_GetEmbeddedEditorContext(Widget w, MWContext *context)
extern "C" void
XFE_DestroyEmbeddedEditor(Widget w, MWContext *context)
{
XFE_Frame *frame = (XFE_Frame *)CONTEXT_DATA(context)->view;
XFE_Frame *frame = fe_getFrameFromContext(context);
XP_ASSERT(frame);
if (!frame)
return;
XFE_View *view = frame->widgetToView(w);
MWContext *vcontext;