diff --git a/cmd/xfe/src/RDFMenuToolbarBase.cpp b/cmd/xfe/src/RDFMenuToolbarBase.cpp index 289299be4815..1fa1af519fef 100644 --- a/cmd/xfe/src/RDFMenuToolbarBase.cpp +++ b/cmd/xfe/src/RDFMenuToolbarBase.cpp @@ -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");); diff --git a/cmd/xfe/src/RDFMenuToolbarBase.h b/cmd/xfe/src/RDFMenuToolbarBase.h index 57cc41ce1530..d3eccd34bb9a 100644 --- a/cmd/xfe/src/RDFMenuToolbarBase.h +++ b/cmd/xfe/src/RDFMenuToolbarBase.h @@ -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); diff --git a/cmd/xfe/src/RDFToolbar.cpp b/cmd/xfe/src/RDFToolbar.cpp index 7edcb8b36fce..243b0363ac9a 100644 --- a/cmd/xfe/src/RDFToolbar.cpp +++ b/cmd/xfe/src/RDFToolbar.cpp @@ -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, diff --git a/cmd/xfe/src/RDFUtils.cpp b/cmd/xfe/src/RDFUtils.cpp index eee44b28b0ff..e1a760d0030c 100644 --- a/cmd/xfe/src/RDFUtils.cpp +++ b/cmd/xfe/src/RDFUtils.cpp @@ -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 // For XfeIsLabel() #include // For XmIsLabel() +#include // 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; +} +////////////////////////////////////////////////////////////////////////// diff --git a/cmd/xfe/src/RDFUtils.h b/cmd/xfe/src/RDFUtils.h index 1c1e6c3fbf16..e4613e0a8516 100644 --- a/cmd/xfe/src/RDFUtils.h +++ b/cmd/xfe/src/RDFUtils.h @@ -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_ diff --git a/cmd/xfe/src/ToolbarButton.cpp b/cmd/xfe/src/ToolbarButton.cpp index 5d0639a98343..0df0c54a0068 100644 --- a/cmd/xfe/src/ToolbarButton.cpp +++ b/cmd/xfe/src/ToolbarButton.cpp @@ -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 diff --git a/cmd/xfe/src/ToolbarButton.h b/cmd/xfe/src/ToolbarButton.h index 81a2d0b83bce..843b2ba26ca3 100644 --- a/cmd/xfe/src/ToolbarButton.h +++ b/cmd/xfe/src/ToolbarButton.h @@ -82,14 +82,6 @@ protected: ////////////////////////////////////////////////////////////////////// virtual void addCallbacks (); - ////////////////////////////////////////////////////////////////////// - // // - // Style and layout interface // - // // - ////////////////////////////////////////////////////////////////////// - int32 getButtonStyle (); - unsigned char styleToLayout (int32 button_style); - ////////////////////////////////////////////////////////////////////// // // // Button callback interface //