Move getStyleAndLayout() functions to XFE_RDFUtils.

This commit is contained in:
ramiro%netscape.com 1998-10-13 14:06:26 +00:00
Родитель 7d95caab5e
Коммит 4c90243605
7 изменённых файлов: 154 добавлений и 227 удалений

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

@ -1006,78 +1006,6 @@ XFE_RDFMenuToolbarBase::getDropLastAccess()
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFMenuToolbarBase::getStyleAndLayout(HT_Resource entry, int32 * toolbar_style, unsigned char * layout)
{
void * data = NULL;
/* Get the Toolbar displaymode from HT */
HT_GetTemplateData(HT_TopNode(HT_GetView(entry)), gNavCenter->toolbarDisplayMode, HT_COLUMN_STRING, &data);
if (!data)
{
/* No value provided initially. So get it from prefs and set in HT */
/* int result = */ PREF_GetIntPref("browser.chrome.toolbar_style",
toolbar_style);
if (*toolbar_style == BROWSER_TOOLBAR_TEXT_ONLY)
HT_SetNodeData(HT_TopNode(HT_GetView(entry)), gNavCenter->toolbarDisplayMode, HT_COLUMN_STRING, "text");
else if (*toolbar_style == BROWSER_TOOLBAR_ICONS_ONLY)
HT_SetNodeData(HT_TopNode(HT_GetView(entry)), gNavCenter->toolbarDisplayMode, HT_COLUMN_STRING, "pictures");
else
HT_SetNodeData(HT_TopNode(HT_GetView(entry)), gNavCenter->toolbarDisplayMode, HT_COLUMN_STRING, "PicturesAndText");
}
else {
/* Value is found in HT */
char * answer = (char *) data;
if ((!XP_STRCASECMP(answer, "text")))
{
*toolbar_style = BROWSER_TOOLBAR_TEXT_ONLY;
}
else if ((!XP_STRCASECMP(answer, "icons")))
{
*toolbar_style = BROWSER_TOOLBAR_ICONS_ONLY;
}
else
*toolbar_style = BROWSER_TOOLBAR_ICONS_AND_TEXT;
}
if (*toolbar_style == BROWSER_TOOLBAR_ICONS_AND_TEXT) {
/* Get the Toolbar bitmap position from HT */
HT_GetTemplateData(HT_TopNode(HT_GetView(entry)), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data);
if (data)
{
char * answer = (char *) data;
if ((!XP_STRCASECMP(answer, "top")))
{
*layout = XmBUTTON_LABEL_ON_BOTTOM;
}
else if ((!XP_STRCASECMP(answer, "side")))
{
*layout = XmBUTTON_LABEL_ON_RIGHT;
}
}
else {
// Value not provided. It is top for command buttons and side
// for personal
if (XFE_RDFUtils::ht_IsFECommand(entry))
*layout = XmBUTTON_LABEL_ON_BOTTOM;
else
*layout = XmBUTTON_LABEL_ON_RIGHT;
}
}
else if (*toolbar_style == BROWSER_TOOLBAR_ICONS_ONLY)
{
*layout = XmBUTTON_PIXMAP_ONLY;
}
else if (*toolbar_style == BROWSER_TOOLBAR_TEXT_ONLY)
{
*layout = XmBUTTON_LABEL_ONLY;
}
}
//////////////////////////////////////////////////////////////////////////
void
XFE_RDFMenuToolbarBase::notify(HT_Resource n, HT_Event whatHappened)
{
D(debugEvent(n, whatHappened,"MTB"););

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

@ -138,8 +138,6 @@ protected:
HT_Resource getMenuFolder ();
XP_Bool getOnlyHeaders ();
void getStyleAndLayout(HT_Resource , int32 *, unsigned char * );
// Item callbacks
static void item_armed_cb (Widget,XtPointer,XtPointer);
static void item_disarmed_cb (Widget,XtPointer,XtPointer);

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

@ -378,13 +378,11 @@ XFE_RDFToolbar::updateRoot()
/* virtual */ void
XFE_RDFToolbar::configureXfeButton(Widget item,HT_Resource entry)
{
int32 toolbar_style;
unsigned char layout;
int32 style = XFE_RDFUtils::getStyleForEntry(entry);
unsigned char layout = XFE_RDFUtils::getButtonLayoutForEntry(entry,
style);
getStyleAndLayout(entry, &toolbar_style, &layout);
if (toolbar_style == BROWSER_TOOLBAR_TEXT_ONLY)
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNpixmap, XmUNSPECIFIED_PIXMAP,
@ -424,13 +422,12 @@ XFE_RDFToolbar::configureXfeButton(Widget item,HT_Resource entry)
/* virtual */ void
XFE_RDFToolbar::configureXfeCascade(Widget item,HT_Resource entry)
{
int32 toolbar_style;
unsigned char layout;
getStyleAndLayout(entry, &toolbar_style, &layout);
int32 style = XFE_RDFUtils::getStyleForEntry(entry);
unsigned char layout = XFE_RDFUtils::getButtonLayoutForEntry(entry,
style);
D(printf("XFE_RDFToolbar::configureXfeCascade: toolbar_style = %d layout = %d\n", toolbar_style, layout););
if (toolbar_style == BROWSER_TOOLBAR_TEXT_ONLY)
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(item,
XmNpixmap, XmUNSPECIFIED_PIXMAP,

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

@ -33,8 +33,9 @@
#include "xp_str.h"
#include "xpassert.h"
#include "felocale.h" // fe_ConvertToXmString()
#include "felocale.h" // For fe_ConvertToXmString()
#include "intl_csi.h" // For INTL_ functions
#include "prefapi.h" // For PREF_GetIntPref
#include "xfe.h" // For fe_FormatDocTitle()
@ -42,6 +43,8 @@
#include <Xfe/Label.h> // For XfeIsLabel()
#include <Xm/Label.h> // For XmIsLabel()
#include <Xfe/Button.h> // For XmBUTTON_ defines
//////////////////////////////////////////////////////////////////////////
//
// XFE Command utilities
@ -529,3 +532,128 @@ XFE_RDFUtils::getPixmapsForEntry(Widget item,
}
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Style and layout
//
//////////////////////////////////////////////////////////////////////////
/* static */ int32
XFE_RDFUtils::getStyleForEntry(HT_Resource entry)
{
XP_ASSERT( entry != NULL );
int32 style = BROWSER_TOOLBAR_TEXT_ONLY;
void * data = NULL;
// Get the Toolbar displaymode from HT
HT_GetTemplateData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
&data);
// No value provided initially. So get it from prefs and set in HT
if (!data)
{
/* int result = */ PREF_GetIntPref("browser.chrome.toolbar_style",
&style);
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
HT_SetNodeData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
"text");
}
else if (style == BROWSER_TOOLBAR_ICONS_ONLY)
{
HT_SetNodeData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
"pictures");
}
else
{
HT_SetNodeData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
"PicturesAndText");
}
}
// Value is found in HT
else
{
char * answer = (char *) data;
if ((!XP_STRCASECMP(answer, "text")))
{
style = BROWSER_TOOLBAR_TEXT_ONLY;
}
else if ((!XP_STRCASECMP(answer, "icons")))
{
style = BROWSER_TOOLBAR_ICONS_ONLY;
}
else
{
style = BROWSER_TOOLBAR_ICONS_AND_TEXT;
}
}
return style;
}
//////////////////////////////////////////////////////////////////////////
/* static */ unsigned char
XFE_RDFUtils::getButtonLayoutForEntry(HT_Resource entry,int32 style)
{
XP_ASSERT( entry != NULL ) ;
unsigned char layout = XmBUTTON_LABEL_ONLY;
void * data = NULL;
if (style == BROWSER_TOOLBAR_ICONS_AND_TEXT)
{
// Get the Toolbar bitmap position from HT */
HT_GetTemplateData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarBitmapPosition,
HT_COLUMN_STRING,
&data);
if (data)
{
char * answer = (char *) data;
if ((!XP_STRCASECMP(answer, "top")))
{
layout = XmBUTTON_LABEL_ON_BOTTOM;
}
else if ((!XP_STRCASECMP(answer, "side")))
{
layout = XmBUTTON_LABEL_ON_RIGHT;
}
}
// Value not provided. It is top for command buttons and side
// for personal
else
{
if (XFE_RDFUtils::ht_IsFECommand(entry))
{
layout = XmBUTTON_LABEL_ON_BOTTOM;
}
else
{
layout = XmBUTTON_LABEL_ON_RIGHT;
}
}
}
else if (style == BROWSER_TOOLBAR_ICONS_ONLY)
{
layout = XmBUTTON_PIXMAP_ONLY;
}
else if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
layout = XmBUTTON_LABEL_ONLY;
}
return layout;
}
//////////////////////////////////////////////////////////////////////////

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

@ -120,6 +120,16 @@ public:
Pixmap * maskOut,
Pixmap * armedPixmapOut,
Pixmap * armedMaskOut);
//////////////////////////////////////////////////////////////////////
// //
// Style and layout interface //
// //
//////////////////////////////////////////////////////////////////////
static int32 getStyleForEntry (HT_Resource entry);
static unsigned char getButtonLayoutForEntry (HT_Resource entry,
int32 style);
};
#endif // _xfe_rdf_utils_h_

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

@ -127,17 +127,19 @@ XFE_ToolbarButton::configure()
getHtResource());
// Set the item's style and layout
int32 button_style = getButtonStyle();
unsigned char button_layout = styleToLayout(button_style);
HT_Resource entry = getHtResource();
int32 style = XFE_RDFUtils::getStyleForEntry(entry);
unsigned char layout = XFE_RDFUtils::getButtonLayoutForEntry(entry,
style);
if (button_style == BROWSER_TOOLBAR_TEXT_ONLY)
if (style == BROWSER_TOOLBAR_TEXT_ONLY)
{
XtVaSetValues(m_widget,
XmNpixmap, XmUNSPECIFIED_PIXMAP,
XmNpixmapMask, XmUNSPECIFIED_PIXMAP,
NULL);
XtVaSetValues(m_widget, XmNbuttonLayout, button_layout, NULL);
XtVaSetValues(m_widget, XmNbuttonLayout, layout, NULL);
}
else
{
@ -154,7 +156,7 @@ XFE_ToolbarButton::configure()
XtVaSetValues(m_widget,
XmNpixmap, pixmap,
XmNpixmapMask, pixmapMask,
XmNbuttonLayout, button_layout,
XmNbuttonLayout, layout,
NULL);
}
@ -185,134 +187,6 @@ XFE_ToolbarButton::addCallbacks()
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Style and layout interface
//
//////////////////////////////////////////////////////////////////////////
int32
XFE_ToolbarButton::getButtonStyle()
{
int32 button_style = BROWSER_TOOLBAR_TEXT_ONLY;
void * data = NULL;
HT_Resource entry = getHtResource();
XP_ASSERT( entry != NULL ) ;
// Get the Toolbar displaymode from HT
HT_GetTemplateData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
&data);
// No value provided initially. So get it from prefs and set in HT
if (!data)
{
/* int result = */ PREF_GetIntPref("browser.chrome.toolbar_style",
&button_style);
if (button_style == BROWSER_TOOLBAR_TEXT_ONLY)
{
HT_SetNodeData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
"text");
}
else if (button_style == BROWSER_TOOLBAR_ICONS_ONLY)
{
HT_SetNodeData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
"pictures");
}
else
{
HT_SetNodeData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarDisplayMode,
HT_COLUMN_STRING,
"PicturesAndText");
}
}
// Value is found in HT
else
{
char * answer = (char *) data;
if ((!XP_STRCASECMP(answer, "text")))
{
button_style = BROWSER_TOOLBAR_TEXT_ONLY;
}
else if ((!XP_STRCASECMP(answer, "icons")))
{
button_style = BROWSER_TOOLBAR_ICONS_ONLY;
}
else
{
button_style = BROWSER_TOOLBAR_ICONS_AND_TEXT;
}
}
return button_style;
}
//////////////////////////////////////////////////////////////////////////
unsigned char
XFE_ToolbarButton::styleToLayout(int32 button_style)
{
unsigned char button_layout = XmBUTTON_LABEL_ONLY;
void * data = NULL;
HT_Resource entry = getHtResource();
XP_ASSERT( entry != NULL ) ;
if (button_style == BROWSER_TOOLBAR_ICONS_AND_TEXT)
{
// Get the Toolbar bitmap position from HT */
HT_GetTemplateData(HT_TopNode(HT_GetView(entry)),
gNavCenter->toolbarBitmapPosition,
HT_COLUMN_STRING,
&data);
if (data)
{
char * answer = (char *) data;
if ((!XP_STRCASECMP(answer, "top")))
{
button_layout = XmBUTTON_LABEL_ON_BOTTOM;
}
else if ((!XP_STRCASECMP(answer, "side")))
{
button_layout = XmBUTTON_LABEL_ON_RIGHT;
}
}
// Value not provided. It is top for command buttons and side
// for personal
else
{
if (XFE_RDFUtils::ht_IsFECommand(entry))
{
button_layout = XmBUTTON_LABEL_ON_BOTTOM;
}
else
{
button_layout = XmBUTTON_LABEL_ON_RIGHT;
}
}
}
else if (button_style == BROWSER_TOOLBAR_ICONS_ONLY)
{
button_layout = XmBUTTON_PIXMAP_ONLY;
}
else if (button_style == BROWSER_TOOLBAR_TEXT_ONLY)
{
button_layout = XmBUTTON_LABEL_ONLY;
}
return button_layout;
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
// Button callback interface

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

@ -82,14 +82,6 @@ protected:
//////////////////////////////////////////////////////////////////////
virtual void addCallbacks ();
//////////////////////////////////////////////////////////////////////
// //
// Style and layout interface //
// //
//////////////////////////////////////////////////////////////////////
int32 getButtonStyle ();
unsigned char styleToLayout (int32 button_style);
//////////////////////////////////////////////////////////////////////
// //
// Button callback interface //