Add support for FE commands from RDF.

This commit is contained in:
slamm%netscape.com 1998-09-02 00:26:24 +00:00
Родитель 44c25d0923
Коммит 30a8512a63
2 изменённых файлов: 105 добавлений и 35 удалений

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

@ -25,7 +25,7 @@
#include "xp_str.h"
#include "xpassert.h"
#if DEBUG_slamm
#if DEBUG_xxx
#define D(x) x
#else
#define D(x)
@ -48,13 +48,37 @@ XFE_RDFBase::~XFE_RDFBase()
{
}
//////////////////////////////////////////////////////////////////////////
/*static*/ XP_Bool
XFE_RDFBase::ht_IsFECommand(HT_Resource item)
{
const char* url = HT_GetNodeURL(item);
return (XP_STRNCMP(url, "command:", 8) == 0);
}
//////////////////////////////////////////////////////////////////////////
/*static*/ CommandType
XFE_RDFBase::ht_GetFECommand(HT_Resource item)
{
const char* url = HT_GetNodeURL(item);
if (url && XP_STRNCMP(url, "command:", 8) == 0)
{
return Command::convertOldRemote(url + 8);
}
else
{
return NULL;
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::newPane()
{
initPane();
startPaneCreate();
_ht_pane = HT_NewPane(_ht_ns);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
}
//////////////////////////////////////////////////////////////////////////
void
@ -64,11 +88,12 @@ XFE_RDFBase::newPaneFromURL(char *url)
char ** param_names = NULL;
char ** param_values = NULL;
initPane();
startPaneCreate();
_ht_pane = HT_PaneFromURL(NULL, url, _ht_ns, 0,
param_count, param_names, param_values);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
}
//////////////////////////////////////////////////////////////////////////
void
@ -80,21 +105,22 @@ XFE_RDFBase::newPaneFromResource(HT_Resource node)
void
XFE_RDFBase::newPaneFromResource(RDF_Resource node)
{
initPane();
startPaneCreate();
_ht_pane = HT_PaneFromResource(node, _ht_ns,
PR_FALSE, PR_TRUE, PR_TRUE);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::newToolbarPane()
{
initPane();
startPaneCreate();
_ht_pane = HT_NewToolbarPane(_ht_ns);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
}
//////////////////////////////////////////////////////////////////////////
HT_Resource
@ -124,9 +150,25 @@ XFE_RDFBase::updateRoot()
/*virtual*/ void
XFE_RDFBase::notify(HT_Resource n, HT_Event whatHappened)
{
#ifdef DEBUG
debugEvent(n, whatHappened);
#endif
D(debugEvent(n, whatHappened););
switch (whatHappened) {
case HT_EVENT_VIEW_ADDED:
; // Do nothing
break;
default:
// Pass this event to the view
if (isPaneCreator())
{
HT_View ht_view = HT_GetView(n);
XFE_RDFBase * xfe_view = (XFE_RDFBase *)HT_GetViewFEData(ht_view);
if (xfe_view)
xfe_view->notify(n, whatHappened);
}
break;
}
}
//////////////////////////////////////////////////////////////////////////
//
@ -144,7 +186,7 @@ XFE_RDFBase::notify_cb(HT_Notification ns, HT_Resource n,
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::initPane()
XFE_RDFBase::startPaneCreate()
{
deletePane();
@ -156,11 +198,17 @@ XFE_RDFBase::initPane()
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::finishPaneCreate()
{
HT_SetPaneFEData(_ht_pane, this);
//HT_SetNotificationMask(_ht_pane, NULL);
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::deletePane()
{
// Only delete the pane if we have a notification struct.
// No nofication struct means the pane was created by another object.
if (_ht_ns)
if (isPaneCreator())
{
delete _ht_ns;
@ -184,9 +232,19 @@ XFE_RDFBase::setHTView(HT_View view)
_ht_view = view;
_ht_pane = HT_GetPane(_ht_view);
HT_SetViewFEData(view, this);
updateRoot();
}
//////////////////////////////////////////////////////////////////////////
XP_Bool
XFE_RDFBase::isPaneCreator()
{
// Pane was created by this object if the notification struct is set.
// No nofication struct means the pane was created by another object.
return _ht_ns != NULL;
}
//////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
void
XFE_RDFBase::debugEvent(HT_Resource n, HT_Event whatHappened)

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

@ -29,6 +29,8 @@
#define _xfe_rdfbase_h_
#include "htrdf.h"
#include "xp_core.h"
#include "Command.h"
class XFE_RDFBase
{
@ -39,12 +41,17 @@ public:
virtual ~XFE_RDFBase ();
// Is the URL a 'special' command url that
// translates to an FE command?
static XP_Bool ht_IsFECommand (HT_Resource item);
static CommandType ht_GetFECommand (HT_Resource item);
// Pane creation methods.
void newPane();
void newToolbarPane();
void newPaneFromURL(char * url);
void newPaneFromResource(HT_Resource node);
void newPaneFromResource(RDF_Resource node);
void newPane ();
void newToolbarPane ();
void newPaneFromURL (char * url);
void newPaneFromResource (HT_Resource node);
void newPaneFromResource (RDF_Resource node);
// Select a view of a pane.
// Use this to set the view without creating a new pane.
@ -52,35 +59,40 @@ public:
// This does not set up the notify callback. The original creator
// of the pane is responsible for distributing notify events
// to dependant views.
void setHTView(HT_View v);
void setHTView (HT_View v);
// Return true when the pane was created here.
// Return false if the pane is only shared.
XP_Bool isPaneCreator ();
// Get the root folder of the current view.
HT_Resource getRootFolder();
HT_Resource getRootFolder ();
// Update the current view from the root.
virtual void updateRoot();
virtual void updateRoot ();
// Handle HT events
virtual void notify(HT_Resource n, HT_Event whatHappened);
virtual void notify (HT_Resource n, HT_Event whatHappened);
protected:
// HT event callback. Setup when a new pane is created.
static void notify_cb(HT_Notification ns, HT_Resource n,
HT_Event whatHappened,
void *token, uint32 tokenType);
static void notify_cb (HT_Notification ns, HT_Resource n,
HT_Event whatHappened,
void *token, uint32 tokenType);
// Called by the pane creation methods to setup a pane
void initPane();
// Called by the pane creation methods
void startPaneCreate ();
void finishPaneCreate ();
void deletePane();
void deletePane ();
#ifdef DEBUG
void debugEvent(HT_Resource n, HT_Event e);
void debugEvent (HT_Resource n, HT_Event e);
#endif
HT_Pane _ht_pane;
HT_View _ht_view;
HT_Notification _ht_ns;
HT_Pane _ht_pane;
HT_View _ht_view;
HT_Notification _ht_ns;
};
#endif /* _xfe_rdfbase_h_ */