Initial check-in of HTMLArea (embedded composer widget) form

element feature. All Ender related code is ifdef'd ENDER.
This commit is contained in:
kin%netscape.com 1998-08-05 19:08:58 +00:00
Родитель 38bdb3eb97
Коммит afd3088bfe
13 изменённых файлов: 767 добавлений и 14 удалений

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

@ -849,6 +849,8 @@ xfe2_EditorInit(MWContext* context)
#endif
if (context->type == MWContextEditor) {
Widget w;
/*
* NOTE: the MWContextMessageComposition has it's own ev handler...
*
@ -856,7 +858,14 @@ xfe2_EditorInit(MWContext* context)
#ifdef DEBUG_rhess
fprintf(stderr, "tag1::[ %p ]\n", CONTEXT_WIDGET(context));
#endif
XtAddEventHandler(CONTEXT_WIDGET(context), FocusChangeMask,
#ifdef ENDER
if (EDITOR_CONTEXT_DATA(context)->embedded)
w = CONTEXT_DATA(context)->drawing_area;
else
#endif /* ENDER */
w = CONTEXT_WIDGET(context);
XtAddEventHandler(w, FocusChangeMask,
FALSE, (XtEventHandler)fe_change_focus_eh,
context);
}
@ -944,7 +953,10 @@ fe_EditorCleanup(MWContext* context)
* for a new doc, as that'll mean dialogs, and .....
*/
if (context->type != MWContextMessageComposition &&
!EDT_IS_NEW_DOCUMENT(context) &&
!EDT_IS_NEW_DOCUMENT(context) &&
#ifdef ENDER
!EDITOR_CONTEXT_DATA(context)->embedded &&
#endif /* ENDER */
(!EDT_IsBlocked(context) && EDT_DirtyFlag(context))) {
fe_EditorPreferencesGetAutoSave(context, &as_enabled, &as_time);
if (as_enabled)
@ -2602,8 +2614,11 @@ fe_EditorGetUrlExitRoutine(MWContext* context, URL_Struct* url, int status)
/*
* Then request a dissapearing act.
*/
XtAppAddTimeOut(fe_XtAppContext, 0, fe_editor_exit_timeout,
(XtPointer)context);
#ifdef ENDER
if (! EDITOR_CONTEXT_DATA(context)->embedded)
#endif /* ENDER */
XtAppAddTimeOut(fe_XtAppContext, 0, fe_editor_exit_timeout,
(XtPointer)context);
}
}
}
@ -2664,8 +2679,13 @@ FE_EditorDocumentLoaded(MWContext* context)
/*
* Set autosave period.
*/
fe_EditorPreferencesGetAutoSave(context, &as_enable, &as_time);
EDT_SetAutoSavePeriod(context, as_time);
#ifdef ENDER
if (! EDITOR_CONTEXT_DATA(context)->embedded)
#endif /* ENDER */
{
fe_EditorPreferencesGetAutoSave(context, &as_enable, &as_time);
EDT_SetAutoSavePeriod(context, as_time);
}
fe_HackEditorNotifyToolbarUpdated(context);
}

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

@ -29,6 +29,10 @@
#include "xpform.h"
#include "layers.h"
#ifdef ENDER
#include "edt.h"
#endif /* ENDER */
#include <plevent.h> /* for mocha */
#include <prtypes.h>
#include <libevent.h>
@ -130,6 +134,15 @@ typedef struct {
Widget text_widget; /* form_data.widget is the scrolled window. */
} FETextAreaFormData;
#ifdef ENDER
typedef struct {
FEFormData form_data;
MWContext *editor_context;
} FEHTMLAreaFormData;
#endif /* ENDER */
typedef struct {
FEFormData form_data;
@ -173,6 +186,19 @@ static void textarea_get_value(FEFormData *, LO_FormElementStruct *, XP_Bool);
static void textarea_reset(FEFormData *, LO_FormElementStruct *);
static void textarea_lost_focus(FEFormData *);
#ifdef ENDER
static void htmlarea_create_widget(FEFormData *, LO_FormElementStruct *);
static void htmlarea_get_size(FEFormData *, LO_FormElementStruct *);
static void htmlarea_display(FEFormData *, LO_FormElementStruct *);
static void htmlarea_get_value(FEFormData *, LO_FormElementStruct *, XP_Bool);
static void htmlarea_reset(FEFormData *, LO_FormElementStruct *);
static void htmlarea_text_focus(FEFormData *, LO_FormElementStruct *);
static void htmlarea_lost_focus(FEFormData *);
static void htmlarea_element_free(FEFormData *, LO_FormElementStruct *);
#endif /* ENDER */
static void form_element_display(FEFormData *, LO_FormElementStruct *);
static void form_element_get_size(FEFormData *, LO_FormElementStruct *);
static void form_element_is_submit(FEFormData *, LO_FormElementStruct *);
@ -280,6 +306,24 @@ static FEFormVtable textarea_form_vtable = {
textarea_lost_focus
};
#ifdef ENDER
static FEFormVtable htmlarea_form_vtable = {
htmlarea_create_widget,
htmlarea_get_size,
NULL,
htmlarea_display,
htmlarea_get_value,
htmlarea_element_free,
htmlarea_reset,
NULL /* text_select */,
NULL /* text_change */,
htmlarea_text_focus,
htmlarea_lost_focus
};
#endif /* ENDER */
/*
** Why are these next two functions in this file?
*/
@ -2376,6 +2420,173 @@ textarea_lost_focus(FEFormData *fed)
}
}
#ifdef ENDER
static void
htmlarea_focus_cb(Widget w, XtPointer closure, XEvent *event, Boolean *cont)
{
*cont = TRUE;
if (event->type == FocusIn)
fe_got_focus_cb(w, closure, (XtPointer)0);
else
fe_lost_focus_cb(w, closure, (XtPointer)0);
}
static void
htmlarea_create_widget(FEFormData *fed, LO_FormElementStruct *form)
{
extern Widget XFE_CreateEmbeddedEditor(Widget, int32, int32, const char *, MWContext *);
extern MWContext *XFE_GetEmbeddedEditorContext(Widget, MWContext *);
FEHTMLAreaFormData *ha_fed = (FEHTMLAreaFormData *)fed;
LO_FormElementData *form_data = XP_GetFormElementData(form);
MWContext *context = ha_fed->form_data.context;
Widget parent = CONTEXT_DATA(context)->drawing_area;
char *default_text = (char*)XP_FormGetDefaultText(form_data);
LO_TextAttr *text_attr = XP_GetFormTextAttr(form);
int32 wid, ht;
/* XXX: For now, we are using the textarea's rows/cols attribute to specify
* the composer widget's dimensions.
*/
XP_FormTextAreaGetDimensions(form_data, &ht, &wid);
ha_fed->form_data.widget =
XFE_CreateEmbeddedEditor(parent, wid, ht, NULL, context);
ha_fed->editor_context =
XFE_GetEmbeddedEditorContext(ha_fed->form_data.widget,
context);
/* Can't register a XmNfocusCallback or XmNlosingFocusCallback on
* a DrawingArea so we register an event handler.
*/
XtAddEventHandler(CONTEXT_DATA(ha_fed->editor_context)->drawing_area,
FocusChangeMask, FALSE, htmlarea_focus_cb, fed);
if (default_text)
{
fe_forms_clean_text(fed->context, text_attr->charset, default_text, False);
EDT_SetDefaultText(ha_fed->editor_context, default_text);
}
}
static void
htmlarea_get_size(FEFormData *fed, LO_FormElementStruct *form)
{
#if 1
LO_FormElementData *form_data;
int32 wid, ht;
form_data = XP_GetFormElementData(form);
/* XXX: For now, we are using the textarea's rows/cols attribute to specify
* the composer widget's dimensions.
*/
XP_FormTextAreaGetDimensions(form_data, &ht, &wid);
form->width = wid;
form->height = ht;
#else
form_element_get_size(fed, form);
#endif
}
static void
htmlarea_display(FEFormData *fed, LO_FormElementStruct *form)
{
form_element_display(fed, form);
}
static void
htmlarea_get_value(FEFormData *fed, LO_FormElementStruct *form, XP_Bool delete_p)
{
MWContext *context = fed->context;
LO_FormElementData *form_data = XP_GetFormElementData(form);
FEHTMLAreaFormData *ha_fed = (FEHTMLAreaFormData*)fed;
int32 cols;
PA_Block current_text;
PA_Block default_text;
XP_HUGE_CHAR_PTR text = 0;
XP_FormTextAreaGetDimensions(form_data, NULL, &cols);
EDT_SaveToBuffer(ha_fed->editor_context, &text);
if (! text) return;
current_text = XP_FormGetCurrentText(form_data);
default_text = XP_FormGetDefaultText(form_data);
if (current_text && current_text != default_text)
free (current_text);
XP_FormSetCurrentText(form_data, (char *)text);
if (delete_p)
{
extern Widget XFE_DestroyEmbeddedEditor(Widget, MWContext *);
XFE_DestroyEmbeddedEditor(ha_fed->form_data.widget, context);
ha_fed->form_data.widget = 0;
}
}
static void
htmlarea_reset(FEFormData *fed, LO_FormElementStruct *form)
{
#ifdef NOT_YET_KIN
LO_FormElementData *form_data = XP_GetFormElementData(form);
FEHTMLAreaFormData *ha_fed = (FEHTMLAreaFormData*)fed;
char *default_text = (char*)XP_FormGetDefaultText(form_data);
LO_TextAttr *text_attr = XP_GetFormTextAttr(form);
int16 charset = text_attr->charset;
if (default_text)
{
fe_forms_clean_text(fed->context, charset, default_text, False);
EDT_SetDefaultText(ha_fed->editor_context, default_text);
}
#endif /* NOT_YET_KIN */
}
static void
htmlarea_text_focus(FEFormData *fed, LO_FormElementStruct *form)
{
text_focus(fed, form);
}
static void
htmlarea_lost_focus(FEFormData *fed)
{
//
// TODO: Do stuff like in ...
//
// text_lost_focus(fed);
//
}
static void
htmlarea_element_free(FEFormData *fed, LO_FormElementStruct *form)
{
extern Widget XFE_DestroyEmbeddedEditor(Widget, MWContext *);
if (fed->widget)
{
FEHTMLAreaFormData *ha_fed = (FEHTMLAreaFormData *)fed;
MWContext *context = ha_fed->form_data.context;
XFE_DestroyEmbeddedEditor(ha_fed->form_data.widget, context);
ha_fed->form_data.widget = 0;
}
XP_FREE(fed);
}
#endif /* ENDER */
static FEFormData *
alloc_form_data(int32 form_type)
{
@ -2418,6 +2629,15 @@ alloc_form_data(int32 form_type)
data->vtbl = textarea_form_vtable;
return data;
#ifdef ENDER
case FORM_TYPE_HTMLAREA:
data = (FEFormData*)XP_NEW_ZAP(FEHTMLAreaFormData);
data->vtbl = htmlarea_form_vtable;
return data;
#endif /* ENDER */
case FORM_TYPE_SELECT_MULT:
data = (FEFormData*)XP_NEW_ZAP(FESelectMultFormData);
data->vtbl = selectmult_form_vtable;

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

@ -579,9 +579,8 @@ static MenuSpec fe_editor_show_options_popups[] =
};
XFE_PopupMenu*
fe_EditorNewPopupMenu(XFE_Frame* frame, Widget parent)
fe_EditorNewPopupMenu(XFE_Frame* frame, Widget parent, MWContext *context)
{
MWContext* context = frame->getContext();
XFE_PopupMenu* popup;
ED_ElementType e_type;
MenuSpec* list;

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

@ -118,6 +118,6 @@ protected:
};
MenuSpec* fe_EditorInstanciateMenu(XFE_Frame* frame, MenuSpec* spec);
XFE_PopupMenu* fe_EditorNewPopupMenu(XFE_Frame*, Widget);
XFE_PopupMenu* fe_EditorNewPopupMenu(XFE_Frame*, Widget, MWContext*);
#endif /* _xfe_editorframe_h */

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

@ -2696,14 +2696,21 @@ EditorPopupCommand::reallyDoCommand(XFE_View* v_view, XFE_CommandInfo* info)
unsigned long x;
unsigned long y;
XFE_PopupMenu* popup;
XFE_Frame *frame;
fe_EventLOCoords(context, info->event, &x, &y);
if (!fe_editor_selection_contains_point(context, x, y))
EDT_SelectObject(context, x, y);
popup = fe_EditorNewPopupMenu((XFE_Frame*)view->getToplevel(),
info->widget);
frame = (XFE_Frame*)view->getToplevel();
#ifdef ENDER
if (! EDITOR_CONTEXT_DATA(context)->embedded)
#endif /* ENDER */
context = frame->getContext();
popup = fe_EditorNewPopupMenu(frame, info->widget, context);
view->setPopupMenu(popup);
popup = view->getPopupMenu();

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

@ -0,0 +1,389 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
EmbeddedEditorView.cpp -- class definition for the embedded editor class
Created: Kin Blas <kin@netscape.com>, 01-Jul-98
*/
#ifdef ENDER
#include "Frame.h"
#include "EmbeddedEditorView.h"
#include "DisplayFactory.h"
#include "ViewGlue.h"
#include "il_util.h"
#include "layers.h"
extern "C"
{
MWContext *fe_CreateNewContext(MWContextType type, Widget w,
fe_colormap *cmap, XP_Bool displays_html);
void fe_set_scrolled_default_size(MWContext *context);
CL_Compositor *fe_create_compositor (MWContext *context);
void fe_EditorCleanup(MWContext *context);
void fe_DestroyLayoutData(MWContext *context);
void fe_load_default_font(MWContext *context);
void xfe2_EditorInit(MWContext *context);
int fe_add_to_all_MWContext_list(MWContext *context);
int fe_remove_from_all_MWContext_list(MWContext *context);
void DisplayPixmap(MWContext *context, IL_Pixmap* image,
IL_Pixmap *mask, long int x, long int y,
jint x_offset, jint y_offset, jint width,
jint height);
void fe_find_scrollbar_sizes(MWContext *context);
void fe_get_final_context_resources(MWContext *context);
}
XFE_EmbeddedEditorView::XFE_EmbeddedEditorView(XFE_Component *toplevel_component,
Widget parent,
XFE_View *parent_view,
MWContext *context)
: XFE_EditorView(toplevel_component, parent, parent_view, context)
{
XtOverrideTranslations(CONTEXT_DATA(context)->drawing_area,
fe_globalData.editor_global_translations);
if (parent_view)
parent_view->addView(this);
}
XFE_EmbeddedEditorView::~XFE_EmbeddedEditorView()
{
XFE_View *parent_view = getParent();
if (parent_view)
parent_view->removeView(this);
}
extern "C" Widget
XFE_CreateEmbeddedEditor(Widget parent, int32 wid, int32 ht,
const char *default_url, MWContext *context)
{
Widget w;
MWContext *new_context;
XFE_Frame *frame = (XFE_Frame *)CONTEXT_DATA(context)->view;
XFE_View *view = frame->widgetToView(parent);
new_context = fe_CreateNewContext(MWContextEditor, CONTEXT_WIDGET(context),
XFE_DisplayFactory::theFactory()->getPrivateColormap(),
TRUE);
EDITOR_CONTEXT_DATA(new_context)->embedded = TRUE;
ViewGlue_addMapping(frame, new_context);
fe_init_image_callbacks(new_context);
fe_InitColormap(new_context);
XFE_EmbeddedEditorView *eev = new XFE_EmbeddedEditorView(
frame,
CONTEXT_DATA(context)->drawing_area,
view,
new_context);
fe_set_scrolled_default_size(new_context);
eev->show();
// New Stuff
fe_get_final_context_resources(new_context);
fe_find_scrollbar_sizes(new_context);
fe_InitScrolling(new_context);
// New Stuff
new_context->compositor = fe_create_compositor(new_context);
w = eev->getBaseWidget();
XtVaSetValues(w,
XmNwidth, wid,
XmNheight, ht,
XmNborderWidth, 1,
0);
XtVaSetValues(CONTEXT_DATA(new_context)->scrolled,
XmNshadowThickness, 1,
0);
xfe2_EditorInit(eev->getContext());
if (!default_url || !*default_url)
default_url = "about:editfilenew";
URL_Struct* url = NET_CreateURLStruct(default_url, NET_NORMAL_RELOAD);
eev->getURL(url);
return(w);
}
extern "C" MWContext *
XFE_GetEmbeddedEditorContext(Widget w, MWContext *context)
{
XFE_Frame *frame = (XFE_Frame *)CONTEXT_DATA(context)->view;
XFE_View *view = frame->widgetToView(w);
return((view) ? view->getContext() : 0);
}
extern "C" void
XFE_DestroyEmbeddedEditor(Widget w, MWContext *context)
{
XFE_Frame *frame = (XFE_Frame *)CONTEXT_DATA(context)->view;
XFE_View *view = frame->widgetToView(w);
MWContext *vcontext;
if (!view)
return;
vcontext = view->getContext();
XP_RemoveContextFromList(vcontext);
fe_remove_from_all_MWContext_list(vcontext);
delete view;
if (!vcontext)
return;
fe_EditorCleanup(vcontext);
fe_DestroyLayoutData (vcontext);
if (vcontext->color_space)
{
IL_ReleaseColorSpace(vcontext->color_space);
vcontext->color_space = NULL;
}
SHIST_EndSession(vcontext);
if (vcontext->compositor)
{
CL_DestroyCompositor(vcontext->compositor);
vcontext->compositor = NULL;
}
free(CONTEXT_DATA(vcontext));
free(vcontext);
}
extern "C" MWContext *
fe_CreateNewContext(MWContextType type, Widget w, fe_colormap *cmap,
XP_Bool displays_html)
{
fe_ContextData *fec;
struct fe_MWContext_cons *cons;
MWContext *context;
context = XP_NewContext();
if (context == NULL)
return 0;
cons = XP_NEW_ZAP(struct fe_MWContext_cons);
if (cons == NULL)
{
XP_FREE(context);
return 0;
}
fec = XP_NEW_ZAP (fe_ContextData);
if (fec == NULL)
{
XP_FREE(cons);
XP_FREE(context);
return 0;
}
context->type = type;
switch (type)
{
case MWContextEditor:
case MWContextMessageComposition:
context->is_editor = True;
break;
default:
context->is_editor = False;
break;
}
CONTEXT_DATA (context) = fec;
CONTEXT_DATA (context)->colormap = cmap;
// set image library Callback functions
CONTEXT_DATA (context)->DisplayPixmap = (DisplayPixmapPtr)DisplayPixmap;
CONTEXT_DATA (context)->NewPixmap = (NewPixmapPtr)NULL;
CONTEXT_DATA (context)->ImageComplete = (ImageCompletePtr)NULL;
CONTEXT_WIDGET (context) = w;
fe_InitRemoteServer (XtDisplay (w));
/* add the layout function pointers */
context->funcs = fe_BuildDisplayFunctionTable();
context->convertPixX = context->convertPixY = 1;
context->is_grid_cell = FALSE;
context->grid_parent = NULL;
/* set the XFE default Document Character set */
CONTEXT_DATA(context)->xfe_doc_csid = fe_globalPrefs.doc_csid;
cons->context = context;
cons->next = fe_all_MWContexts;
fe_all_MWContexts = cons;
XP_AddContextToList (context);
fe_InitIconColors(context);
XtGetApplicationResources (w,
(XtPointer) CONTEXT_DATA (context),
fe_Resources, fe_ResourcesSize,
0, 0);
// Use colors from prefs
LO_Color *color;
color = &fe_globalPrefs.links_color;
CONTEXT_DATA(context)->link_pixel =
fe_GetPixel(context, color->red, color->green, color->blue);
color = &fe_globalPrefs.vlinks_color;
CONTEXT_DATA(context)->vlink_pixel =
fe_GetPixel(context, color->red, color->green, color->blue);
color = &fe_globalPrefs.text_color;
CONTEXT_DATA(context)->default_fg_pixel =
fe_GetPixel(context, color->red, color->green, color->blue);
color = &fe_globalPrefs.background_color;
CONTEXT_DATA(context)->default_bg_pixel =
fe_GetPixel(context, color->red, color->green, color->blue);
if (displays_html) {
Display * dpy;
int screen;
double pixels;
double millimeters;
/* Determine pixels per point for back end font size calculations. */
dpy = XtDisplay(w);
screen = XScreenNumberOfScreen(XtScreen(w));
#define MM_PER_INCH (25.4)
#define POINTS_PER_INCH (72.0)
/* N pixels 25.4 mm 1 inch
* -------- * ------- * ------
* M mm 1 inch 72 pts
*/
pixels = DisplayWidth(dpy, screen);
millimeters = DisplayWidthMM(dpy, screen);
context->XpixelsPerPoint =
((pixels * MM_PER_INCH) / millimeters) / POINTS_PER_INCH;
pixels = DisplayHeight(dpy,screen);
millimeters = DisplayHeightMM(dpy, screen);
context->YpixelsPerPoint =
((pixels * MM_PER_INCH) / millimeters) / POINTS_PER_INCH;
SHIST_InitSession (context);
fe_load_default_font(context);
}
/*
* set the default coloring correctly into the new context.
*/
{
Pixel unused_select_pixel;
XmGetColors (XtScreen (w),
fe_cmap(context),
CONTEXT_DATA (context)->default_bg_pixel,
&(CONTEXT_DATA (context)->fg_pixel),
&(CONTEXT_DATA (context)->top_shadow_pixel),
&(CONTEXT_DATA (context)->bottom_shadow_pixel),
&unused_select_pixel);
}
// New field added by putterman for increase/decrease font
context->fontScalingPercentage = 1.0;
return context;
}
extern "C" int
fe_add_to_all_MWContext_list(MWContext *context)
{
struct fe_MWContext_cons *cons;
XP_ASSERT(context);
if (!context)
return 0;
cons = XP_NEW_ZAP(struct fe_MWContext_cons);
if (!cons)
return -1;
cons->context = context;
cons->next = fe_all_MWContexts;
fe_all_MWContexts = cons;
return 0;
}
extern "C" int
fe_remove_from_all_MWContext_list(MWContext *context)
{
struct fe_MWContext_cons *rest, *prev;
XP_ASSERT(context);
if (!context)
return 0;
for (prev = 0, rest = fe_all_MWContexts ; rest ;
prev = rest, rest = rest->next)
{
if (rest->context == context)
break;
}
XP_ASSERT(rest);
if (!rest)
return -1;
if (prev)
prev->next = rest->next;
else
fe_all_MWContexts = rest->next;
free(rest);
return 0;
}
#endif /* ENDER */

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

@ -0,0 +1,41 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
/*
EmbeddedEditorView.h -- class definition for the embedded editor class
Created: Kin Blas <kin@netscape.com>, 01-Jul-98
*/
#ifndef _xfe_embeddededitorview_h
#define _xfe_embeddededitorview_h
#ifdef ENDER
#include "EditorView.h"
class XFE_EmbeddedEditorView : public XFE_EditorView
{
public:
XFE_EmbeddedEditorView(XFE_Component *toplevel_component, Widget parent, XFE_View *parent_view, MWContext *context);
~XFE_EmbeddedEditorView();
};
#endif /* ENDER */
#endif /* _xfe_embeddededitorview_h */

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

@ -1118,7 +1118,7 @@ XFE_HTMLView::doCommand(CommandType cmd, void *callData, XFE_CommandInfo* info)
}
else
{
XFE_View::doCommand(cmd);
XFE_View::doCommand(cmd, callData, info);
}
#undef IS_CMD
}

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

@ -190,6 +190,7 @@ CPPSRCS += \
EditorView.cpp \
EditRecentMenu.cpp \
EditTableDialog.cpp \
EmbeddedEditorView.cpp \
$(NULL)
endif

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

@ -23,6 +23,11 @@
#include "rosetta.h"
#include "Frame.h"
#ifdef ENDER
#include "View.h"
#endif /* ENDER */
#include "MozillaApp.h"
#include "ViewGlue.h"
#include "Dashboard.h"
@ -899,6 +904,34 @@ xfeDoCommandAction(Widget w, XEvent *event,
XFE_CommandInfo info(cmd_type, w, event,
p_params, num_cmd_params);
#ifdef ENDER
XFE_View *v = f->widgetToView(w);
if (v && v->handlesCommand(cmd, NULL, &info))
{
if (v->isCommandEnabled(cmd, NULL, &info))
{
XFE_Command *handler = v->getCommand(cmd);
if (handler)
{
printf("handler->doCommand(0x%.8x): %s\n", handler, cmd);
fflush(stdout);
handler->doCommand(v, &info);
}
else
{
printf("v->doCommand(0x%.8x): %s\n", v, cmd);
fflush(stdout);
v->doCommand(cmd, NULL, &info);
}
return;
}
}
#endif /* ENDER */
/* if the frame doesn't handle the command, bomb out early */
if (!f->handlesCommand(cmd, NULL, &info))
{
@ -998,7 +1031,7 @@ xfeDoClickAction(Widget widget, XEvent *event, String *av, Cardinal *ac)
time = fe_GetTimeFromEvent(event);
int delta = (time - fe_click_action_last);
unsigned int delta = (time - fe_click_action_last);
if (delta < XtGetMultiClickTime(XtDisplay(widget)))
n_clicks = 2;

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

@ -125,6 +125,25 @@ XFE_View::addView(XFE_View *new_view)
m_subviews[ m_numsubviews ++ ] = new_view;
}
void
XFE_View::removeView(XFE_View *view)
{
XP_Bool found = FALSE;
int i, vindex;
for (vindex = 0; vindex < m_numsubviews; vindex++)
{
if (m_subviews[vindex] == view)
break;
}
for (i = vindex + 1; i < m_numsubviews; i++)
m_subviews[i - 1] = m_subviews[i];
if (vindex < m_numsubviews)
--m_numsubviews;
}
Boolean
XFE_View::hasSubViews()
{
@ -150,6 +169,11 @@ Boolean
XFE_View::isCommandEnabled(CommandType cmd,
void *calldata, XFE_CommandInfo* info)
{
XFE_Command* handler = getCommand(cmd);
if (handler != NULL)
return handler->isEnabled(this, info);
if ( cmd == xfeCmdStopLoading
&& m_contextData )
{
@ -177,7 +201,12 @@ XFE_View::isCommandEnabled(CommandType cmd,
void
XFE_View::doCommand(CommandType cmd, void *calldata, XFE_CommandInfo* info)
{
if ( cmd == xfeCmdStopLoading
XFE_Command* handler = getCommand(cmd);
if (handler != NULL)
{
handler->doCommand(this, info);
}
else if ( cmd == xfeCmdStopLoading
&& m_contextData )
{
XP_InterruptContext(m_contextData);
@ -217,6 +246,11 @@ Boolean
XFE_View::handlesCommand(CommandType cmd,
void *calldata, XFE_CommandInfo* info)
{
XFE_Command* handler = getCommand(cmd);
if (handler != NULL)
return True;
if (cmd == xfeCmdStopLoading)
{
return True;

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

@ -118,7 +118,12 @@ public:
protected:
MWContext *m_contextData; // the MWContext *
public:
virtual void addView(XFE_View *new_view);
virtual void removeView(XFE_View *view);
protected:
virtual Boolean hasSubViews();
// list of children

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

@ -876,6 +876,10 @@ typedef struct fe_EditorContextData {
Widget toolbar_center;
Widget toolbar_right;
#ifdef ENDER
XP_Bool embedded;
#endif /* ENDER */
} fe_EditorContextData;
/*