Move utility functions to their own class.

This commit is contained in:
ramiro%netscape.com 1998-10-12 13:48:15 +00:00
Родитель 2c0e548402
Коммит 84b6718cb1
5 изменённых файлов: 122 добавлений и 34 удалений

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

@ -229,29 +229,6 @@ 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)
{

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

@ -80,13 +80,6 @@ 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);

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

@ -31,6 +31,7 @@
#include "IconGroup.h"
#include "View.h"
#include "ToolbarDrop.h"
#include "RDFUtils.h"
#include "felocale.h"
#include "intl_csi.h"
@ -318,7 +319,7 @@ XFE_RDFMenuToolbarBase::getPixmapsForEntry(HT_Resource entry,
#ifdef NOT_YET
if (hasCustomIcon(entry)) {} /*else {*/
#endif /*NOT_YET*/
if (ht_IsFECommand(entry))
if (XFE_RDFUtils::ht_IsFECommand(entry))
{
const char* url = HT_GetNodeURL(entry);
@ -554,7 +555,7 @@ XFE_RDFMenuToolbarBase::entryActivated(Widget w, HT_Resource entry)
{
if (entry)
{
if (ht_IsFECommand(entry))
if (XFE_RDFUtils::ht_IsFECommand(entry))
{
Cardinal numparams = 1;
CommandType cmd;
@ -563,7 +564,7 @@ XFE_RDFMenuToolbarBase::entryActivated(Widget w, HT_Resource entry)
if (HT_IsURLBar(entry)) {
cmd = xfeCmdOpenPage;
} else {
cmd = ht_GetFECommand(entry);
cmd = XFE_RDFUtils::ht_GetFECommand(entry);
}
XFE_CommandInfo info(XFE_COMMAND_EVENT_ACTION,
@ -1479,7 +1480,7 @@ XFE_RDFMenuToolbarBase::getStyleAndLayout(HT_Resource entry, int32 * toolbar_st
else {
// Value not provided. It is top for command buttons and side
// for personal
if (ht_IsFECommand(entry))
if (XFE_RDFUtils::ht_IsFECommand(entry))
*layout = XmBUTTON_LABEL_ON_BOTTOM;
else
*layout = XmBUTTON_LABEL_ON_RIGHT;

62
cmd/xfe/src/RDFUtils.cpp Normal file
Просмотреть файл

@ -0,0 +1,62 @@
/* -*- 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.
*/
//////////////////////////////////////////////////////////////////////////
// //
// Name: RDFUtils.cpp //
// //
// Description: Misc RDF XFE specific utilities. //
// //
// Author: Ramiro Estrugo <ramiro@netscape.com> //
// //
//////////////////////////////////////////////////////////////////////////
#include "RDFUtils.h"
#include "xp_str.h"
#include "xpassert.h"
//////////////////////////////////////////////////////////////////////////
//
// XFE Command utilities
//
// Is the URL a 'special' command url that translates to an FE command ?
//
//////////////////////////////////////////////////////////////////////////
/*static*/ XP_Bool
XFE_RDFUtils::ht_IsFECommand(HT_Resource item)
{
const char* url = HT_GetNodeURL(item);
return (XP_STRNCMP(url, "command:", 8) == 0);
}
//////////////////////////////////////////////////////////////////////////
/*static*/ CommandType
XFE_RDFUtils::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;
}
}
//////////////////////////////////////////////////////////////////////////

55
cmd/xfe/src/RDFUtils.h Normal file
Просмотреть файл

@ -0,0 +1,55 @@
/* -*- 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.
*/
//////////////////////////////////////////////////////////////////////////
// //
// Name: RDFUtils.h //
// //
// Description: Misc RDF XFE specific utilities. //
// //
// Author: Ramiro Estrugo <ramiro@netscape.com> //
// //
//////////////////////////////////////////////////////////////////////////
#ifndef _xfe_rdf_utils_h_
#define _xfe_rdf_utils_h_
#include "htrdf.h"
#include "xp_core.h"
#include "Command.h"
class XFE_RDFUtils
{
public:
XFE_RDFUtils() {}
~XFE_RDFUtils() {}
//////////////////////////////////////////////////////////////////////
// //
// XFE Command utilities //
// //
// 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);
};
#endif // _xfe_rdf_utils_h_