Move configure functions to XFE_RDFUtils.

This commit is contained in:
ramiro%netscape.com 1998-10-13 14:23:57 +00:00
Родитель 9b5cc1c903
Коммит 7173e75a48
6 изменённых файлов: 125 добавлений и 178 удалений

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

@ -589,14 +589,7 @@ XFE_RDFMenuToolbarBase::createCascadeButton(Widget menu,
XFE_RDFUtils::setItemLabelString(_frame->getContext(),cascade,entry);
// Configure the new cascade button
if (_fancyItems)
{
configureXfeBmCascade(cascade,entry);
}
else
{
configureCascade(cascade,entry);
}
XFE_RDFUtils::configureMenuCascadeButton(cascade,entry);
// Create a new bookmark data structure for the callbacks
data = XP_NEW_ZAP(ItemCallbackStruct);
@ -640,14 +633,12 @@ XFE_RDFMenuToolbarBase::createMoreButton(Widget menu)
&cascade,
&pulldown);
if (_fancyItems)
{
configureXfeBmCascade(cascade,NULL);
}
else
{
configureCascade(cascade,NULL);
}
#if 0
// Cant use a NULL entry...hmmm...
// Configure the more button
XFE_RDFUtils::configureMenuCascadeButton(cascade,NULL);
#endif
return cascade;
}
@ -672,16 +663,15 @@ XFE_RDFMenuToolbarBase::createPushButton(Widget menu, HT_Resource entry)
if (_fancyItems)
{
button = XfeCreateBmButton(non_full_menu,xfeCmdOpenTargetUrl,NULL,0);
configureXfeBmButton(button,entry);
}
else
{
button = XmCreatePushButton(non_full_menu,xfeCmdOpenTargetUrl,NULL,0);
configureButton(button,entry);
}
// Configure the new push button
XFE_RDFUtils::configureMenuPushButton(button,entry);
// Set the item's label
XFE_RDFUtils::setItemLabelString(_frame->getContext(),button,entry);
@ -774,110 +764,13 @@ XFE_RDFMenuToolbarBase::createSeparator(Widget menu)
separator = XmCreateSeparator(parent,name,NULL,0);
configureSeparator(separator,NULL);
// configureSeparator(separator,NULL);
XtManageChild(separator);
return separator;
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFMenuToolbarBase::configureXfeBmButton(Widget item,HT_Resource entry)
{
int32 toolbar_style;
PREF_GetIntPref("browser.chrome.toolbar_style", &toolbar_style);
if (toolbar_style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
XmNlabelPixmapMask, XmUNSPECIFIED_PIXMAP,
NULL);
}
else
{
Pixmap pixmap;
Pixmap mask;
XFE_RDFUtils::getPixmapsForEntry(item,
entry,
&pixmap,
&mask,
NULL,
NULL);
XtVaSetValues(item,
XmNlabelPixmap, pixmap,
XmNlabelPixmapMask, mask,
NULL);
}
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFMenuToolbarBase::configureXfeBmCascade(Widget item,HT_Resource entry)
{
int32 toolbar_style;
PREF_GetIntPref("browser.chrome.toolbar_style", &toolbar_style);
if (toolbar_style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
XmNlabelPixmapMask, XmUNSPECIFIED_PIXMAP,
XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
XmNarmPixmapMask, XmUNSPECIFIED_PIXMAP,
NULL);
}
else
{
Pixmap pixmap;
Pixmap mask;
Pixmap armedPixmap;
Pixmap armedMask;
XFE_RDFUtils::getPixmapsForEntry(item,
entry,
&pixmap,
&mask,
&armedPixmap,
&armedMask);
Arg av[4];
Cardinal ac = 0;
XtSetArg(av[ac],XmNlabelPixmap, pixmap); ac++;
XtSetArg(av[ac],XmNlabelPixmapMask, mask); ac++;
// Only show the aremd pixmap/mask if this entry has children
if (XfeIsAlive(XfeCascadeGetSubMenu(item)))
{
XtSetArg(av[ac],XmNarmPixmap, armedPixmap); ac++;
XtSetArg(av[ac],XmNarmPixmapMask, armedMask); ac++;
}
XtSetValues(item,av,ac);
}
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFMenuToolbarBase::configureButton(Widget /*item*/,
HT_Resource /*entry*/)
{
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFMenuToolbarBase::configureCascade(Widget /*item*/,
HT_Resource /*entry*/)
{
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFMenuToolbarBase::configureSeparator(Widget /*item*/,
HT_Resource /*entry*/)
{
}
//////////////////////////////////////////////////////////////////////////
HT_Resource
XFE_RDFMenuToolbarBase::getAddFolder()
{

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

@ -120,13 +120,6 @@ protected:
// Gets called when the personal toolbar folder's name changes
virtual void updateToolbarFolderName ();
// Configure the items
virtual void configureXfeBmButton (Widget, HT_Resource);
virtual void configureXfeBmCascade (Widget, HT_Resource);
virtual void configureButton (Widget, HT_Resource);
virtual void configureCascade (Widget, HT_Resource);
virtual void configureSeparator (Widget, HT_Resource);
// Menu component creation methods
Widget createCascadeButton (Widget menu, HT_Resource entry,
XP_Bool ignore_children);

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

@ -376,50 +376,6 @@ XFE_RDFToolbar::updateRoot()
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFToolbar::configureXfeButton(Widget item,HT_Resource entry)
{
int32 style = XFE_RDFUtils::getStyleForEntry(entry);
unsigned char layout = XFE_RDFUtils::getButtonLayoutForEntry(entry,
style);
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNpixmap, XmUNSPECIFIED_PIXMAP,
XmNpixmapMask, XmUNSPECIFIED_PIXMAP,
NULL);
XtVaSetValues(item, XmNbuttonLayout, layout, NULL);
}
else
{
Pixmap pixmap;
Pixmap pixmapMask;
XFE_RDFUtils::getPixmapsForEntry(item,
entry,
&pixmap,
&pixmapMask,
NULL,
NULL);
XtVaSetValues(item,
XmNpixmap, pixmap,
XmNpixmapMask, pixmapMask,
XmNbuttonLayout, layout,
NULL);
}
#ifdef NOT_YET
// Add popup callback to item
XtAddCallback(item,
XmNbutton3DownCallback,
&XFE_RDFToolbar::popupCB,
(XtPointer) this);
#endif
}
//////////////////////////////////////////////////////////////////////////
/* virtual */ void
XFE_RDFToolbar::configureXfeCascade(Widget item,HT_Resource entry)
{
int32 style = XFE_RDFUtils::getStyleForEntry(entry);
@ -468,14 +424,6 @@ XFE_RDFToolbar::configureXfeCascade(Widget item,HT_Resource entry)
XtVaSetValues(item,XmNbuttonLayout,layout,NULL);
}
#ifdef NOT_YET
// Add popup callback to item
XtAddCallback(item,
XmNbutton3DownCallback,
&XFE_RDFToolbar::popupCB,
(XtPointer) this);
#endif
}
//////////////////////////////////////////////////////////////////////////
void

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

@ -78,7 +78,6 @@ protected:
void addItem (HT_Resource);
// Override RDFMenuToolbarBase methods
virtual void configureXfeButton (Widget, HT_Resource);
virtual void configureXfeCascade (Widget, HT_Resource);
// Toolbar component creation methods

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

@ -45,6 +45,9 @@
#include <Xfe/Button.h> // For XmBUTTON_ defines
#include <Xfe/BmButton.h> // For XfeIsBmButton()
#include <Xfe/BmCascade.h> // For XfeIsBmCascade()
//////////////////////////////////////////////////////////////////////////
//
// XFE Command utilities
@ -657,3 +660,102 @@ XFE_RDFUtils::getButtonLayoutForEntry(HT_Resource entry,int32 style)
return layout;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Menu items
//
//////////////////////////////////////////////////////////////////////////
/* static */ void
XFE_RDFUtils::configureMenuPushButton(Widget item,HT_Resource entry)
{
XP_ASSERT( XfeIsAlive(item) );
XP_ASSERT( entry != NULL );
// Pixmaps can only be set for XfeBmButton widgets
if (XfeIsBmButton(item))
{
int32 style;
PREF_GetIntPref("browser.chrome.style", &style);
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
XmNlabelPixmapMask, XmUNSPECIFIED_PIXMAP,
NULL);
}
else
{
Pixmap pixmap;
Pixmap mask;
XFE_RDFUtils::getPixmapsForEntry(item,
entry,
&pixmap,
&mask,
NULL,
NULL);
XtVaSetValues(item,
XmNlabelPixmap, pixmap,
XmNlabelPixmapMask, mask,
NULL);
}
}
}
//////////////////////////////////////////////////////////////////////////
/* static */ void
XFE_RDFUtils::configureMenuCascadeButton(Widget item,HT_Resource entry)
{
XP_ASSERT( XfeIsAlive(item) );
XP_ASSERT( entry != NULL );
// Pixmaps can only be set for XfeBmCascade widgets
if (XfeIsBmCascade(item))
{
int32 style;
PREF_GetIntPref("browser.chrome.style", &style);
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
XmNlabelPixmapMask, XmUNSPECIFIED_PIXMAP,
XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
XmNarmPixmapMask, XmUNSPECIFIED_PIXMAP,
NULL);
}
else
{
Pixmap pixmap;
Pixmap mask;
Pixmap armedPixmap;
Pixmap armedMask;
XFE_RDFUtils::getPixmapsForEntry(item,
entry,
&pixmap,
&mask,
&armedPixmap,
&armedMask);
Arg av[4];
Cardinal ac = 0;
XtSetArg(av[ac],XmNlabelPixmap, pixmap); ac++;
XtSetArg(av[ac],XmNlabelPixmapMask, mask); ac++;
// Only show the armed pixmap/mask if this entry has children
if (XfeIsAlive(XfeCascadeGetSubMenu(item)))
{
XtSetArg(av[ac],XmNarmPixmap, armedPixmap); ac++;
XtSetArg(av[ac],XmNarmPixmapMask, armedMask); ac++;
}
XtSetValues(item,av,ac);
}
}
}
//////////////////////////////////////////////////////////////////////////

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

@ -130,6 +130,18 @@ public:
static unsigned char getButtonLayoutForEntry (HT_Resource entry,
int32 style);
//////////////////////////////////////////////////////////////////////
// //
// Menu items //
// //
//////////////////////////////////////////////////////////////////////
static void configureMenuPushButton (Widget item,
HT_Resource entry);
static void configureMenuCascadeButton (Widget item,
HT_Resource entry);
};
#endif // _xfe_rdf_utils_h_