more support for pane creation/deletion.

This commit is contained in:
slamm%netscape.com 1998-09-08 20:14:06 +00:00
Родитель 096fb59315
Коммит dbd6d99329
2 изменённых файлов: 130 добавлений и 97 удалений

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

@ -46,37 +46,18 @@ XFE_RDFBase::XFE_RDFBase()
/*virtual*/
XFE_RDFBase::~XFE_RDFBase()
{
XFE_RDFBase * xfe_view = (XFE_RDFBase *)HT_GetViewFEData(_ht_view);
if (xfe_view == this)
{
// HT is holding onto a pointer to this class.
// Since this is going away, clear the pointer from HT.
HT_SetViewFEData(_ht_view, NULL);
}
if (isPaneCreator())
{
deletePane();
}
else
{
HT_SetViewFEData(_ht_view, NULL);
}
}
//////////////////////////////////////////////////////////////////////////
/*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
@ -121,6 +102,22 @@ XFE_RDFBase::newPaneFromResource(RDF_Resource node)
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::newBookmarksPane()
{
newPane();
HT_View view = HT_GetViewType(_ht_pane, HT_VIEW_BOOKMARK);
HT_SetSelectedView(_ht_pane, view);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::newHistoryPane()
{
newPane();
HT_View view = HT_GetViewType(_ht_pane, HT_VIEW_HISTORY);
HT_SetSelectedView(_ht_pane, view);
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::newToolbarPane()
{
startPaneCreate();
@ -130,6 +127,75 @@ XFE_RDFBase::newToolbarPane()
finishPaneCreate();
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::startPaneCreate()
{
deletePane();
// Setup the notification struct
_ht_ns = new HT_NotificationStruct;
XP_BZERO(_ht_ns, sizeof(HT_NotificationStruct));
_ht_ns->notifyProc = notify_cb;
_ht_ns->data = this;
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::finishPaneCreate()
{
HT_SetPaneFEData(_ht_pane, this);
_ht_view = HT_GetSelectedView(_ht_pane);
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::deletePane()
{
if (_ht_ns)
{
delete _ht_ns;
_ht_ns = NULL;
XP_ASSERT(_ht_pane);
if (_ht_pane)
{
HT_DeletePane(_ht_pane);
}
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::setHTView(HT_View view)
{
XP_ASSERT(view);
// Nothing to do
if (view == _ht_view) return;
_ht_view = view;
HT_Pane pane = HT_GetPane(_ht_view);
// It is an error to switch to a new pane in setHTView()
// if this object is the HT_Pane creator.
// Use the new pane methods instead.
XP_ASSERT(!isPaneCreator() || _ht_pane == pane);
_ht_pane = pane;
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;
}
//////////////////////////////////////////////////////////////////////////
HT_Resource
XFE_RDFBase::getRootFolder()
{
@ -154,6 +220,29 @@ XFE_RDFBase::updateRoot()
{
}
//////////////////////////////////////////////////////////////////////////
/*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;
}
}
//////////////////////////////////////////////////////////////////////////
/*virtual*/ void
XFE_RDFBase::notify(HT_Resource n, HT_Event whatHappened)
{
@ -170,7 +259,7 @@ XFE_RDFBase::notify(HT_Resource n, HT_Event whatHappened)
HT_View ht_view = HT_GetView(n);
XFE_RDFBase * xfe_view = (XFE_RDFBase *)HT_GetViewFEData(ht_view);
if (xfe_view)
if (xfe_view && xfe_view != this)
xfe_view->notify(n, whatHappened);
}
break;
@ -191,66 +280,6 @@ XFE_RDFBase::notify_cb(HT_Notification ns, HT_Resource n,
xfe_rdfpane_obj->notify(n, whatHappened);
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::startPaneCreate()
{
deletePane();
// Setup the notification struct
_ht_ns = new HT_NotificationStruct;
XP_BZERO(_ht_ns, sizeof(HT_NotificationStruct));
_ht_ns->notifyProc = notify_cb;
_ht_ns->data = this;
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::finishPaneCreate()
{
HT_SetPaneFEData(_ht_pane, this);
//HT_SetNotificationMask(_ht_pane, NULL);
}
//////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::deletePane()
{
if (_ht_ns)
{
delete _ht_ns;
XP_ASSERT(_ht_pane);
if (_ht_pane)
{
HT_DeletePane(_ht_pane);
}
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFBase::setHTView(HT_View view)
{
XP_ASSERT(view);
// Nothing to do
if (view == _ht_view) return;
_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
@ -299,7 +328,7 @@ XFE_RDFBase::debugEvent(HT_Resource n, HT_Event whatHappened,
printf(" ");
#ifdef DEBUG_slamm
#define EVENTDEBUG(x) printf("%s: %-21s (0x%x) %s, %s\n",\
#define EVENTDEBUG(x) printf("%s: %s (0x%x) %s, %s\n",\
label,(x),pane,viewName,nodeName);
#else
#define EVENTDEBUG(x)

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

@ -41,13 +41,10 @@ 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 newBookmarksPane ();
void newHistoryPane ();
void newToolbarPane ();
void newPaneFromURL (char * url,
int param_count = 0,
@ -74,6 +71,13 @@ public:
// Update the current view from the root.
virtual void updateRoot ();
// 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);
// Handle HT events
virtual void notify (HT_Resource n, HT_Event whatHappened);
@ -84,10 +88,10 @@ protected:
void *token, uint32 tokenType);
// Called by the pane creation methods
void startPaneCreate ();
void finishPaneCreate ();
virtual void startPaneCreate ();
virtual void finishPaneCreate ();
void deletePane ();
virtual void deletePane ();
#ifdef DEBUG
void debugEvent (HT_Resource n, HT_Event e,