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 "xp_str.h"
#include "xpassert.h" #include "xpassert.h"
#if DEBUG_slamm #if DEBUG_xxx
#define D(x) x #define D(x) x
#else #else
#define D(x) #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 void
XFE_RDFBase::newPane() XFE_RDFBase::newPane()
{ {
initPane(); startPaneCreate();
_ht_pane = HT_NewPane(_ht_ns); _ht_pane = HT_NewPane(_ht_ns);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void void
@ -64,11 +88,12 @@ XFE_RDFBase::newPaneFromURL(char *url)
char ** param_names = NULL; char ** param_names = NULL;
char ** param_values = NULL; char ** param_values = NULL;
initPane(); startPaneCreate();
_ht_pane = HT_PaneFromURL(NULL, url, _ht_ns, 0, _ht_pane = HT_PaneFromURL(NULL, url, _ht_ns, 0,
param_count, param_names, param_values); param_count, param_names, param_values);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void void
@ -80,21 +105,22 @@ XFE_RDFBase::newPaneFromResource(HT_Resource node)
void void
XFE_RDFBase::newPaneFromResource(RDF_Resource node) XFE_RDFBase::newPaneFromResource(RDF_Resource node)
{ {
initPane(); startPaneCreate();
_ht_pane = HT_PaneFromResource(node, _ht_ns, _ht_pane = HT_PaneFromResource(node, _ht_ns,
PR_FALSE, PR_TRUE, PR_TRUE); PR_FALSE, PR_TRUE, PR_TRUE);
HT_SetPaneFEData(_ht_pane, this); finishPaneCreate();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void void
XFE_RDFBase::newToolbarPane() XFE_RDFBase::newToolbarPane()
{ {
initPane(); startPaneCreate();
_ht_pane = HT_NewToolbarPane(_ht_ns); _ht_pane = HT_NewToolbarPane(_ht_ns);
HT_SetPaneFEData(_ht_pane, this);
finishPaneCreate();
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
HT_Resource HT_Resource
@ -124,9 +150,25 @@ XFE_RDFBase::updateRoot()
/*virtual*/ void /*virtual*/ void
XFE_RDFBase::notify(HT_Resource n, HT_Event whatHappened) XFE_RDFBase::notify(HT_Resource n, HT_Event whatHappened)
{ {
#ifdef DEBUG D(debugEvent(n, whatHappened););
debugEvent(n, whatHappened);
#endif 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 void
XFE_RDFBase::initPane() XFE_RDFBase::startPaneCreate()
{ {
deletePane(); deletePane();
@ -156,11 +198,17 @@ XFE_RDFBase::initPane()
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
void void
XFE_RDFBase::finishPaneCreate()
{
HT_SetPaneFEData(_ht_pane, this);
//HT_SetNotificationMask(_ht_pane, NULL);
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::deletePane() XFE_RDFBase::deletePane()
{ {
// Only delete the pane if we have a notification struct. if (isPaneCreator())
// No nofication struct means the pane was created by another object.
if (_ht_ns)
{ {
delete _ht_ns; delete _ht_ns;
@ -184,9 +232,19 @@ XFE_RDFBase::setHTView(HT_View view)
_ht_view = view; _ht_view = view;
_ht_pane = HT_GetPane(_ht_view); _ht_pane = HT_GetPane(_ht_view);
HT_SetViewFEData(view, this);
updateRoot(); 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 #ifdef DEBUG
void void
XFE_RDFBase::debugEvent(HT_Resource n, HT_Event whatHappened) XFE_RDFBase::debugEvent(HT_Resource n, HT_Event whatHappened)

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

@ -29,6 +29,8 @@
#define _xfe_rdfbase_h_ #define _xfe_rdfbase_h_
#include "htrdf.h" #include "htrdf.h"
#include "xp_core.h"
#include "Command.h"
class XFE_RDFBase class XFE_RDFBase
{ {
@ -39,12 +41,17 @@ public:
virtual ~XFE_RDFBase (); 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. // Pane creation methods.
void newPane(); void newPane ();
void newToolbarPane(); void newToolbarPane ();
void newPaneFromURL(char * url); void newPaneFromURL (char * url);
void newPaneFromResource(HT_Resource node); void newPaneFromResource (HT_Resource node);
void newPaneFromResource(RDF_Resource node); void newPaneFromResource (RDF_Resource node);
// Select a view of a pane. // Select a view of a pane.
// Use this to set the view without creating a new pane. // Use this to set the view without creating a new pane.
@ -52,30 +59,35 @@ public:
// This does not set up the notify callback. The original creator // This does not set up the notify callback. The original creator
// of the pane is responsible for distributing notify events // of the pane is responsible for distributing notify events
// to dependant views. // 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. // Get the root folder of the current view.
HT_Resource getRootFolder(); HT_Resource getRootFolder ();
// Update the current view from the root. // Update the current view from the root.
virtual void updateRoot(); virtual void updateRoot ();
// Handle HT events // Handle HT events
virtual void notify(HT_Resource n, HT_Event whatHappened); virtual void notify (HT_Resource n, HT_Event whatHappened);
protected: protected:
// HT event callback. Setup when a new pane is created. // HT event callback. Setup when a new pane is created.
static void notify_cb(HT_Notification ns, HT_Resource n, static void notify_cb (HT_Notification ns, HT_Resource n,
HT_Event whatHappened, HT_Event whatHappened,
void *token, uint32 tokenType); void *token, uint32 tokenType);
// Called by the pane creation methods to setup a pane // Called by the pane creation methods
void initPane(); void startPaneCreate ();
void finishPaneCreate ();
void deletePane(); void deletePane ();
#ifdef DEBUG #ifdef DEBUG
void debugEvent(HT_Resource n, HT_Event e); void debugEvent (HT_Resource n, HT_Event e);
#endif #endif
HT_Pane _ht_pane; HT_Pane _ht_pane;