mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 118296: implement NS_THEME_MENUBAR, NS_THEME_TOOLBAR, NS_THEME_MENUPOPUP and NS_THEME_MENUITEM (GTK2)
r=bryner, sr=roc
This commit is contained in:
parent
65eec61ff9
commit
a58d650d2b
@ -128,6 +128,12 @@ typedef enum {
|
||||
MOZ_GTK_TAB,
|
||||
/* Paints the background and border of a GtkNotebook. */
|
||||
MOZ_GTK_TABPANELS,
|
||||
/* Paints the background of the menu bar. */
|
||||
MOZ_GTK_MENUBAR,
|
||||
/* Paints the background of menus, context menus. */
|
||||
MOZ_GTK_MENUPOPUP,
|
||||
/* Paints items of menubar and popups. */
|
||||
MOZ_GTK_MENUITEM,
|
||||
/* Paints the background of a window, dialog or page. */
|
||||
MOZ_GTK_WINDOW
|
||||
} GtkThemeWidgetType;
|
||||
|
@ -84,6 +84,7 @@ nsNativeThemeGTK::nsNativeThemeGTK()
|
||||
mFirstTabAtom = do_GetAtom("first-tab");
|
||||
mCurPosAtom = do_GetAtom("curpos");
|
||||
mMaxPosAtom = do_GetAtom("maxpos");
|
||||
mMenuActiveAtom = do_GetAtom("_moz-menuactive");
|
||||
|
||||
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
|
||||
memset(mSafeWidgetStates, 0, sizeof(mSafeWidgetStates));
|
||||
@ -242,20 +243,25 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
// reset the entire struct to zero
|
||||
memset(aState, 0, sizeof(GtkWidgetState));
|
||||
} else {
|
||||
|
||||
// for dropdown textfields, look at the parent frame (the textbox)
|
||||
if (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD)
|
||||
aFrame = aFrame->GetParent();
|
||||
|
||||
PRInt32 eventState = GetContentState(aFrame);
|
||||
|
||||
aState->active = ((eventState & NS_EVENT_STATE_ACTIVE) == NS_EVENT_STATE_ACTIVE);
|
||||
aState->disabled = IsDisabled(aFrame);
|
||||
aState->active = (eventState & NS_EVENT_STATE_ACTIVE) == NS_EVENT_STATE_ACTIVE;
|
||||
aState->focused = (eventState & NS_EVENT_STATE_FOCUS) == NS_EVENT_STATE_FOCUS;
|
||||
aState->inHover = (eventState & NS_EVENT_STATE_HOVER) == NS_EVENT_STATE_HOVER;
|
||||
aState->isDefault = FALSE; // XXX fix me
|
||||
aState->canDefault = FALSE; // XXX fix me
|
||||
|
||||
if (aWidgetType == NS_THEME_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_RADIO_CONTAINER)
|
||||
aWidgetType == NS_THEME_RADIO_CONTAINER) {
|
||||
aState->focused = CheckBooleanAttr(aFrame, mFocusedAtom);
|
||||
else
|
||||
aState->focused = ((eventState & NS_EVENT_STATE_FOCUS) == NS_EVENT_STATE_FOCUS);
|
||||
}
|
||||
|
||||
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
|
||||
@ -267,10 +273,12 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
aState->maxpos = CheckIntegerAttr(tmpFrame, mMaxPosAtom);
|
||||
}
|
||||
|
||||
aState->inHover = ((eventState & NS_EVENT_STATE_HOVER) == NS_EVENT_STATE_HOVER);
|
||||
aState->disabled = IsDisabled(aFrame);
|
||||
aState->isDefault = FALSE; // XXX fix me
|
||||
aState->canDefault = FALSE; // XXX fix me
|
||||
// menu item state is determined by the attribute "_moz-menuactive",
|
||||
// and not by the mouse hovering (accessibility).
|
||||
if (aWidgetType == NS_THEME_MENUITEM) {
|
||||
aState->inHover = CheckBooleanAttr(aFrame, mMenuActiveAtom);
|
||||
aState->active = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +347,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
aGtkWidgetType = MOZ_GTK_RADIOBUTTON_CONTAINER;
|
||||
break;
|
||||
case NS_THEME_TOOLBOX:
|
||||
case NS_THEME_TOOLBAR:
|
||||
aGtkWidgetType = MOZ_GTK_TOOLBAR;
|
||||
break;
|
||||
case NS_THEME_TOOLTIP:
|
||||
@ -379,6 +387,15 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
aGtkWidgetType = MOZ_GTK_TAB;
|
||||
}
|
||||
break;
|
||||
case NS_THEME_MENUBAR:
|
||||
aGtkWidgetType = MOZ_GTK_MENUBAR;
|
||||
break;
|
||||
case NS_THEME_MENUPOPUP:
|
||||
aGtkWidgetType = MOZ_GTK_MENUPOPUP;
|
||||
break;
|
||||
case NS_THEME_MENUITEM:
|
||||
aGtkWidgetType = MOZ_GTK_MENUITEM;
|
||||
break;
|
||||
case NS_THEME_WINDOW:
|
||||
case NS_THEME_DIALOG:
|
||||
aGtkWidgetType = MOZ_GTK_WINDOW;
|
||||
@ -584,6 +601,8 @@ nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
||||
aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
|
||||
aWidgetType == NS_THEME_PROGRESSBAR ||
|
||||
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
|
||||
aWidgetType == NS_THEME_MENUBAR ||
|
||||
aWidgetType == NS_THEME_MENUPOPUP ||
|
||||
aWidgetType == NS_THEME_TOOLTIP ||
|
||||
aWidgetType == NS_THEME_WINDOW ||
|
||||
aWidgetType == NS_THEME_DIALOG) {
|
||||
@ -636,8 +655,8 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
|
||||
case NS_THEME_BUTTON:
|
||||
case NS_THEME_RADIO:
|
||||
case NS_THEME_CHECKBOX:
|
||||
case NS_THEME_TOOLBOX:
|
||||
// case NS_THEME_TOOLBAR: (not in skin)
|
||||
case NS_THEME_TOOLBOX: // N/A
|
||||
case NS_THEME_TOOLBAR:
|
||||
case NS_THEME_TOOLBAR_BUTTON:
|
||||
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
|
||||
// case NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN:
|
||||
@ -694,11 +713,12 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
|
||||
case NS_THEME_CHECKBOX_CONTAINER:
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
case NS_THEME_MENUBAR:
|
||||
case NS_THEME_MENUPOPUP:
|
||||
case NS_THEME_MENUITEM:
|
||||
case NS_THEME_WINDOW:
|
||||
case NS_THEME_DIALOG:
|
||||
#endif
|
||||
// case NS_THEME_MENU:
|
||||
// case NS_THEME_MENUBAR:
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ private:
|
||||
nsCOMPtr<nsIAtom> mFirstTabAtom;
|
||||
nsCOMPtr<nsIAtom> mCurPosAtom;
|
||||
nsCOMPtr<nsIAtom> mMaxPosAtom;
|
||||
nsCOMPtr<nsIAtom> mMenuActiveAtom;
|
||||
|
||||
PRUint8 mDisabledWidgetTypes[32];
|
||||
PRUint8 mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget
|
||||
|
@ -21,6 +21,7 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com> (Original Author)
|
||||
* Pierre Chanial <p_ch@verizon.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
@ -62,10 +63,18 @@ static GtkWidget* gEntryWidget;
|
||||
static GtkWidget* gArrowWidget;
|
||||
static GtkWidget* gDropdownButtonWidget;
|
||||
static GtkWidget* gHandleBoxWidget;
|
||||
static GtkWidget* gToolbarWidget;
|
||||
static GtkWidget* gFrameWidget;
|
||||
static GtkWidget* gProgressWidget;
|
||||
static GtkWidget* gTabWidget;
|
||||
static GtkWidget* gTooltipWidget;
|
||||
static GtkWidget* gMenuBarWidget;
|
||||
static GtkWidget* gMenuBarItemWidget;
|
||||
static GtkWidget* gMenuPopupWidget;
|
||||
static GtkWidget* gMenuItemWidget;
|
||||
|
||||
static GtkShadowType gMenuBarShadowType;
|
||||
static GtkShadowType gToolbarShadowType;
|
||||
|
||||
static style_prop_t style_prop_func;
|
||||
|
||||
@ -178,6 +187,20 @@ ensure_handlebox_widget()
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_toolbar_widget()
|
||||
{
|
||||
if (!gToolbarWidget) {
|
||||
ensure_handlebox_widget();
|
||||
gToolbarWidget = gtk_toolbar_new();
|
||||
gtk_container_add(GTK_CONTAINER(gHandleBoxWidget), gToolbarWidget);
|
||||
gtk_widget_realize(gToolbarWidget);
|
||||
gtk_widget_style_get(gToolbarWidget, "shadow_type", &gToolbarShadowType,
|
||||
NULL);
|
||||
}
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_tooltip_widget()
|
||||
{
|
||||
@ -218,15 +241,67 @@ ensure_frame_widget()
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_menu_bar_widget()
|
||||
{
|
||||
if (!gMenuBarWidget) {
|
||||
gMenuBarWidget = gtk_menu_bar_new();
|
||||
setup_widget_prototype(gMenuBarWidget);
|
||||
gtk_widget_style_get(gMenuBarWidget, "shadow_type", &gMenuBarShadowType,
|
||||
NULL);
|
||||
}
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_menu_bar_item_widget()
|
||||
{
|
||||
if (!gMenuBarItemWidget) {
|
||||
ensure_menu_bar_widget();
|
||||
gMenuBarItemWidget = gtk_menu_item_new();
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget),
|
||||
gMenuBarItemWidget);
|
||||
gtk_widget_realize(gMenuBarItemWidget);
|
||||
}
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_menu_popup_widget()
|
||||
{
|
||||
if (!gMenuPopupWidget) {
|
||||
ensure_menu_bar_item_widget();
|
||||
gMenuPopupWidget = gtk_menu_new();
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(gMenuBarItemWidget),
|
||||
gMenuPopupWidget);
|
||||
gtk_widget_realize(gMenuPopupWidget);
|
||||
}
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_menu_item_widget()
|
||||
{
|
||||
if (!gMenuItemWidget) {
|
||||
ensure_menu_popup_widget();
|
||||
gMenuItemWidget = gtk_menu_item_new_with_label("M");
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(gMenuPopupWidget),
|
||||
gMenuItemWidget);
|
||||
gtk_widget_realize(gMenuItemWidget);
|
||||
}
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static GtkStateType
|
||||
ConvertGtkState(GtkWidgetState* state)
|
||||
{
|
||||
if (state->disabled)
|
||||
return GTK_STATE_INSENSITIVE;
|
||||
else if (state->active)
|
||||
return GTK_STATE_ACTIVE;
|
||||
else if (state->inHover)
|
||||
return (state->active ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT);
|
||||
else
|
||||
return GTK_STATE_NORMAL;
|
||||
return GTK_STATE_PRELIGHT;
|
||||
return GTK_STATE_NORMAL;
|
||||
}
|
||||
|
||||
static gint
|
||||
@ -296,13 +371,15 @@ moz_gtk_button_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
width -= 2;
|
||||
height -= 2;
|
||||
}
|
||||
|
||||
shadow_type = (state->active && state->inHover) ?
|
||||
GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
||||
|
||||
|
||||
shadow_type = button_state == GTK_STATE_ACTIVE ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
||||
|
||||
if (relief != GTK_RELIEF_NONE || (button_state != GTK_STATE_NORMAL &&
|
||||
button_state != GTK_STATE_INSENSITIVE)) {
|
||||
TSOffsetStyleGCs(style, x, y);
|
||||
/* the following line can trigger an assertion (Crux theme)
|
||||
file ../../gdk/gdkwindow.c: line 1846 (gdk_window_clear_area):
|
||||
assertion `GDK_IS_WINDOW (window)' failed */
|
||||
gtk_paint_box(style, drawable, button_state, shadow_type, cliprect,
|
||||
widget, "button", x, y, width, height);
|
||||
}
|
||||
@ -739,23 +816,21 @@ moz_gtk_toolbar_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect)
|
||||
{
|
||||
GtkStyle* style;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
ensure_handlebox_widget();
|
||||
style = gHandleBoxWidget->style;
|
||||
ensure_toolbar_widget();
|
||||
style = gToolbarWidget->style;
|
||||
|
||||
TSOffsetStyleGCs(style, rect->x, rect->y);
|
||||
|
||||
if (style->bg_pixmap[GTK_STATE_NORMAL]) {
|
||||
gtk_style_apply_default_background(style, drawable, TRUE,
|
||||
GTK_STATE_NORMAL,
|
||||
cliprect, rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
else {
|
||||
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
||||
cliprect, gHandleBoxWidget, "dockitem_bin",
|
||||
rect->x, rect->y, rect->width, rect->height);
|
||||
}
|
||||
gtk_style_apply_default_background(style, drawable, TRUE,
|
||||
GTK_STATE_NORMAL,
|
||||
cliprect, rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
|
||||
gtk_paint_box (style, drawable, GTK_STATE_NORMAL, gToolbarShadowType,
|
||||
cliprect, gToolbarWidget, "toolbar",
|
||||
rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
@ -924,6 +999,66 @@ moz_gtk_tabpanels_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_menu_bar_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect)
|
||||
{
|
||||
GtkStyle* style;
|
||||
GtkShadowType shadow_type;
|
||||
ensure_menu_bar_widget();
|
||||
style = gMenuBarWidget->style;
|
||||
|
||||
TSOffsetStyleGCs(style, rect->x, rect->y);
|
||||
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
|
||||
cliprect, rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, gMenuBarShadowType,
|
||||
cliprect, gMenuBarWidget, "menubar", rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_menu_popup_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect)
|
||||
{
|
||||
GtkStyle* style;
|
||||
ensure_menu_popup_widget();
|
||||
style = gMenuPopupWidget->style;
|
||||
|
||||
TSOffsetStyleGCs(style, rect->x, rect->y);
|
||||
gtk_style_apply_default_background(style, drawable, TRUE, GTK_STATE_NORMAL,
|
||||
cliprect, rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
gtk_paint_box(style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_OUT,
|
||||
cliprect, gMenuPopupWidget, "menu",
|
||||
rect->x, rect->y, rect->width, rect->height);
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_menu_item_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect, GtkWidgetState* state)
|
||||
{
|
||||
GtkStyle* style;
|
||||
GtkShadowType shadow_type;
|
||||
|
||||
if (state->inHover && !state->disabled) {
|
||||
ensure_menu_item_widget();
|
||||
|
||||
style = gMenuItemWidget->style;
|
||||
TSOffsetStyleGCs(style, rect->x, rect->y);
|
||||
gtk_widget_style_get(gMenuItemWidget, "selected_shadow_type",
|
||||
&shadow_type, NULL);
|
||||
gtk_paint_box(style, drawable, GTK_STATE_PRELIGHT, shadow_type,
|
||||
cliprect, gMenuItemWidget, "menuitem", rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_window_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect)
|
||||
@ -946,14 +1081,15 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
|
||||
gint* ythickness)
|
||||
{
|
||||
GtkWidget* w;
|
||||
|
||||
switch (widget) {
|
||||
case MOZ_GTK_BUTTON:
|
||||
ensure_button_widget();
|
||||
w = gButtonWidget;
|
||||
break;
|
||||
case MOZ_GTK_TOOLBAR:
|
||||
ensure_handlebox_widget();
|
||||
w = gHandleBoxWidget;
|
||||
ensure_toolbar_widget();
|
||||
w = gToolbarWidget;
|
||||
break;
|
||||
case MOZ_GTK_ENTRY:
|
||||
ensure_entry_widget();
|
||||
@ -984,6 +1120,18 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
|
||||
*ythickness = 1;
|
||||
return MOZ_GTK_SUCCESS;
|
||||
break;
|
||||
case MOZ_GTK_MENUBAR:
|
||||
ensure_menu_bar_widget();
|
||||
w = gMenuBarWidget;
|
||||
break;
|
||||
case MOZ_GTK_MENUPOPUP:
|
||||
ensure_menu_popup_widget();
|
||||
w = gMenuPopupWidget;
|
||||
break;
|
||||
case MOZ_GTK_MENUITEM:
|
||||
ensure_menu_item_widget();
|
||||
w = gMenuItemWidget;
|
||||
break;
|
||||
/* These widgets have no borders, since they are not containers. */
|
||||
case MOZ_GTK_CHECKBUTTON:
|
||||
case MOZ_GTK_RADIOBUTTON:
|
||||
@ -1139,6 +1287,15 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
|
||||
case MOZ_GTK_TABPANELS:
|
||||
return moz_gtk_tabpanels_paint(drawable, rect, cliprect);
|
||||
break;
|
||||
case MOZ_GTK_MENUBAR:
|
||||
return moz_gtk_menu_bar_paint(drawable, rect, cliprect);
|
||||
break;
|
||||
case MOZ_GTK_MENUPOPUP:
|
||||
return moz_gtk_menu_popup_paint(drawable, rect, cliprect);
|
||||
break;
|
||||
case MOZ_GTK_MENUITEM:
|
||||
return moz_gtk_menu_item_paint(drawable, rect, cliprect, state);
|
||||
break;
|
||||
case MOZ_GTK_WINDOW:
|
||||
return moz_gtk_window_paint(drawable, rect, cliprect);
|
||||
break;
|
||||
|
@ -128,6 +128,12 @@ typedef enum {
|
||||
MOZ_GTK_TAB,
|
||||
/* Paints the background and border of a GtkNotebook. */
|
||||
MOZ_GTK_TABPANELS,
|
||||
/* Paints the background of the menu bar. */
|
||||
MOZ_GTK_MENUBAR,
|
||||
/* Paints the background of menus, context menus. */
|
||||
MOZ_GTK_MENUPOPUP,
|
||||
/* Paints items of menubar and popups. */
|
||||
MOZ_GTK_MENUITEM,
|
||||
/* Paints the background of a window, dialog or page. */
|
||||
MOZ_GTK_WINDOW
|
||||
} GtkThemeWidgetType;
|
||||
|
@ -84,6 +84,7 @@ nsNativeThemeGTK::nsNativeThemeGTK()
|
||||
mFirstTabAtom = do_GetAtom("first-tab");
|
||||
mCurPosAtom = do_GetAtom("curpos");
|
||||
mMaxPosAtom = do_GetAtom("maxpos");
|
||||
mMenuActiveAtom = do_GetAtom("_moz-menuactive");
|
||||
|
||||
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
|
||||
memset(mSafeWidgetStates, 0, sizeof(mSafeWidgetStates));
|
||||
@ -242,20 +243,25 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
// reset the entire struct to zero
|
||||
memset(aState, 0, sizeof(GtkWidgetState));
|
||||
} else {
|
||||
|
||||
// for dropdown textfields, look at the parent frame (the textbox)
|
||||
if (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD)
|
||||
aFrame = aFrame->GetParent();
|
||||
|
||||
PRInt32 eventState = GetContentState(aFrame);
|
||||
|
||||
aState->active = ((eventState & NS_EVENT_STATE_ACTIVE) == NS_EVENT_STATE_ACTIVE);
|
||||
aState->disabled = IsDisabled(aFrame);
|
||||
aState->active = (eventState & NS_EVENT_STATE_ACTIVE) == NS_EVENT_STATE_ACTIVE;
|
||||
aState->focused = (eventState & NS_EVENT_STATE_FOCUS) == NS_EVENT_STATE_FOCUS;
|
||||
aState->inHover = (eventState & NS_EVENT_STATE_HOVER) == NS_EVENT_STATE_HOVER;
|
||||
aState->isDefault = FALSE; // XXX fix me
|
||||
aState->canDefault = FALSE; // XXX fix me
|
||||
|
||||
if (aWidgetType == NS_THEME_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
|
||||
aWidgetType == NS_THEME_RADIO_CONTAINER)
|
||||
aWidgetType == NS_THEME_RADIO_CONTAINER) {
|
||||
aState->focused = CheckBooleanAttr(aFrame, mFocusedAtom);
|
||||
else
|
||||
aState->focused = ((eventState & NS_EVENT_STATE_FOCUS) == NS_EVENT_STATE_FOCUS);
|
||||
}
|
||||
|
||||
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
|
||||
aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
|
||||
@ -267,10 +273,12 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
aState->maxpos = CheckIntegerAttr(tmpFrame, mMaxPosAtom);
|
||||
}
|
||||
|
||||
aState->inHover = ((eventState & NS_EVENT_STATE_HOVER) == NS_EVENT_STATE_HOVER);
|
||||
aState->disabled = IsDisabled(aFrame);
|
||||
aState->isDefault = FALSE; // XXX fix me
|
||||
aState->canDefault = FALSE; // XXX fix me
|
||||
// menu item state is determined by the attribute "_moz-menuactive",
|
||||
// and not by the mouse hovering (accessibility).
|
||||
if (aWidgetType == NS_THEME_MENUITEM) {
|
||||
aState->inHover = CheckBooleanAttr(aFrame, mMenuActiveAtom);
|
||||
aState->active = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,7 +347,7 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
aGtkWidgetType = MOZ_GTK_RADIOBUTTON_CONTAINER;
|
||||
break;
|
||||
case NS_THEME_TOOLBOX:
|
||||
case NS_THEME_TOOLBAR:
|
||||
aGtkWidgetType = MOZ_GTK_TOOLBAR;
|
||||
break;
|
||||
case NS_THEME_TOOLTIP:
|
||||
@ -379,6 +387,15 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
||||
aGtkWidgetType = MOZ_GTK_TAB;
|
||||
}
|
||||
break;
|
||||
case NS_THEME_MENUBAR:
|
||||
aGtkWidgetType = MOZ_GTK_MENUBAR;
|
||||
break;
|
||||
case NS_THEME_MENUPOPUP:
|
||||
aGtkWidgetType = MOZ_GTK_MENUPOPUP;
|
||||
break;
|
||||
case NS_THEME_MENUITEM:
|
||||
aGtkWidgetType = MOZ_GTK_MENUITEM;
|
||||
break;
|
||||
case NS_THEME_WINDOW:
|
||||
case NS_THEME_DIALOG:
|
||||
aGtkWidgetType = MOZ_GTK_WINDOW;
|
||||
@ -584,6 +601,8 @@ nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
||||
aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
|
||||
aWidgetType == NS_THEME_PROGRESSBAR ||
|
||||
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
|
||||
aWidgetType == NS_THEME_MENUBAR ||
|
||||
aWidgetType == NS_THEME_MENUPOPUP ||
|
||||
aWidgetType == NS_THEME_TOOLTIP ||
|
||||
aWidgetType == NS_THEME_WINDOW ||
|
||||
aWidgetType == NS_THEME_DIALOG) {
|
||||
@ -636,8 +655,8 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
|
||||
case NS_THEME_BUTTON:
|
||||
case NS_THEME_RADIO:
|
||||
case NS_THEME_CHECKBOX:
|
||||
case NS_THEME_TOOLBOX:
|
||||
// case NS_THEME_TOOLBAR: (not in skin)
|
||||
case NS_THEME_TOOLBOX: // N/A
|
||||
case NS_THEME_TOOLBAR:
|
||||
case NS_THEME_TOOLBAR_BUTTON:
|
||||
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
|
||||
// case NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN:
|
||||
@ -694,11 +713,12 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
|
||||
case NS_THEME_CHECKBOX_CONTAINER:
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
case NS_THEME_MENUBAR:
|
||||
case NS_THEME_MENUPOPUP:
|
||||
case NS_THEME_MENUITEM:
|
||||
case NS_THEME_WINDOW:
|
||||
case NS_THEME_DIALOG:
|
||||
#endif
|
||||
// case NS_THEME_MENU:
|
||||
// case NS_THEME_MENUBAR:
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
@ -95,6 +95,7 @@ private:
|
||||
nsCOMPtr<nsIAtom> mFirstTabAtom;
|
||||
nsCOMPtr<nsIAtom> mCurPosAtom;
|
||||
nsCOMPtr<nsIAtom> mMaxPosAtom;
|
||||
nsCOMPtr<nsIAtom> mMenuActiveAtom;
|
||||
|
||||
PRUint8 mDisabledWidgetTypes[32];
|
||||
PRUint8 mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget
|
||||
|
@ -334,7 +334,7 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame*
|
||||
::SetThemeBackground(kThemeBrushWhite, 24, true);
|
||||
break;
|
||||
|
||||
case NS_THEME_MENU:
|
||||
case NS_THEME_MENUPOPUP:
|
||||
::SetThemeBackground(kThemeBrushDialogBackgroundActive, 24, true);
|
||||
::EraseRect(&macRect);
|
||||
::SetThemeBackground(kThemeBrushWhite, 24, true);
|
||||
@ -713,7 +713,7 @@ nsNativeThemeMac::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
|
||||
case NS_THEME_TAB_PANEL:
|
||||
case NS_THEME_TEXTFIELD:
|
||||
case NS_THEME_DIALOG:
|
||||
case NS_THEME_MENU:
|
||||
case NS_THEME_MENUPOPUP:
|
||||
*aShouldRepaint = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -764,7 +764,7 @@ nsNativeThemeMac::ThemeSupportsWidget(nsIPresContext* aPresContext, nsIFrame* aF
|
||||
switch ( aWidgetType ) {
|
||||
case NS_THEME_DIALOG:
|
||||
case NS_THEME_WINDOW:
|
||||
// case NS_THEME_MENU: // no support for painting menu backgrounds
|
||||
// case NS_THEME_MENUPOPUP: // no support for painting menu backgrounds
|
||||
case NS_THEME_TOOLTIP:
|
||||
|
||||
case NS_THEME_CHECKBOX:
|
||||
|
Loading…
Reference in New Issue
Block a user