зеркало из https://github.com/mozilla/pjs.git
Bug 118294: NS_THEME_DROPDOWN implementation (GTK2)
(+ add forgotten style for menulist-description binding in the new toolkit) r=bryner, sr=roc.
This commit is contained in:
Родитель
0df859e78c
Коммит
beefbf2e53
|
@ -61,6 +61,7 @@ static GtkWidget* gHorizScrollbarWidget;
|
|||
static GtkWidget* gVertScrollbarWidget;
|
||||
static GtkWidget* gEntryWidget;
|
||||
static GtkWidget* gArrowWidget;
|
||||
static GtkWidget* gOptionMenuWidget;
|
||||
static GtkWidget* gDropdownButtonWidget;
|
||||
static GtkWidget* gHandleBoxWidget;
|
||||
static GtkWidget* gToolbarWidget;
|
||||
|
@ -164,6 +165,16 @@ ensure_entry_widget()
|
|||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_option_menu_widget()
|
||||
{
|
||||
if (!gOptionMenuWidget) {
|
||||
gOptionMenuWidget = gtk_option_menu_new();
|
||||
setup_widget_prototype(gOptionMenuWidget);
|
||||
}
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
ensure_arrow_widget()
|
||||
{
|
||||
|
@ -459,6 +470,45 @@ moz_gtk_radio_get_focus(gboolean* interior_focus,
|
|||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_option_menu_get_metrics(gboolean* interior_focus,
|
||||
GtkRequisition* indicator_size,
|
||||
GtkBorder* indicator_spacing,
|
||||
gint* focus_width,
|
||||
gint* focus_pad)
|
||||
{
|
||||
static const GtkRequisition default_indicator_size = { 7, 13 };
|
||||
static const GtkBorder default_indicator_spacing = { 7, 5, 2, 2 };
|
||||
/* these default values are not used in gtkoptionmenu.c
|
||||
static const gboolean default_interior_focus = TRUE;
|
||||
static const gint default_focus_width = 1;
|
||||
static const gint default_focus_pad = 0; */
|
||||
GtkRequisition *tmp_indicator_size;
|
||||
GtkBorder *tmp_indicator_spacing;
|
||||
|
||||
gtk_widget_style_get(gOptionMenuWidget,
|
||||
"interior_focus", interior_focus,
|
||||
"indicator_size", &tmp_indicator_size,
|
||||
"indicator_spacing", &tmp_indicator_spacing,
|
||||
"focus_line_width", focus_width,
|
||||
"focus_padding", focus_pad,
|
||||
NULL);
|
||||
|
||||
if (tmp_indicator_size)
|
||||
*indicator_size = *tmp_indicator_size;
|
||||
else
|
||||
*indicator_size = default_indicator_size;
|
||||
if (tmp_indicator_spacing)
|
||||
*indicator_spacing = *tmp_indicator_spacing;
|
||||
else
|
||||
*indicator_spacing = default_indicator_spacing;
|
||||
|
||||
g_free(tmp_indicator_size);
|
||||
g_free(tmp_indicator_spacing);
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect, GtkWidgetState* state,
|
||||
|
@ -754,6 +804,78 @@ moz_gtk_entry_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
|||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_option_menu_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect, GtkWidgetState* state)
|
||||
{
|
||||
GtkStyle* style;
|
||||
GtkStateType state_type = ConvertGtkState(state);
|
||||
gint x = rect->x, y=rect->y, width=rect->width, height=rect->height;
|
||||
gint tab_x, tab_y;
|
||||
gboolean interior_focus;
|
||||
GtkRequisition indicator_size;
|
||||
GtkBorder indicator_spacing;
|
||||
gint focus_width;
|
||||
gint focus_pad;
|
||||
|
||||
ensure_option_menu_widget();
|
||||
moz_gtk_option_menu_get_metrics(&interior_focus, &indicator_size,
|
||||
&indicator_spacing, &focus_width,
|
||||
&focus_pad);
|
||||
|
||||
style = gOptionMenuWidget->style;
|
||||
|
||||
if (!interior_focus && state->focused) {
|
||||
x += focus_width + focus_pad;
|
||||
y += focus_width + focus_pad;
|
||||
width -= 2 * (focus_width + focus_pad);
|
||||
height -= 2 * (focus_width + focus_pad);
|
||||
}
|
||||
|
||||
TSOffsetStyleGCs(style, x, y);
|
||||
gtk_paint_box(style, drawable, state_type, GTK_SHADOW_OUT,
|
||||
cliprect, gOptionMenuWidget, "optionmenu",
|
||||
x, y, width, height);
|
||||
|
||||
if (gtk_widget_get_direction(gOptionMenuWidget) == GTK_TEXT_DIR_RTL) {
|
||||
tab_x = x + indicator_spacing.right + XTHICKNESS(style);
|
||||
} else {
|
||||
tab_x = x + width - indicator_size.width - indicator_spacing.right -
|
||||
XTHICKNESS(style);
|
||||
}
|
||||
tab_y = y + (height - indicator_size.height) / 2;
|
||||
|
||||
TSOffsetStyleGCs(style, tab_x, tab_y);
|
||||
gtk_paint_tab(style, drawable, state_type, GTK_SHADOW_OUT, cliprect,
|
||||
gOptionMenuWidget, "optionmenutab", tab_x, tab_y,
|
||||
indicator_size.width, indicator_size.height);
|
||||
|
||||
if (state->focused) {
|
||||
if (interior_focus) {
|
||||
x += XTHICKNESS(style) + focus_pad;
|
||||
y += YTHICKNESS(style) + focus_pad;
|
||||
width -= 2 * (XTHICKNESS(style) + focus_pad) +
|
||||
indicator_spacing.left + indicator_spacing.right +
|
||||
indicator_size.width;
|
||||
height -= 2 * (YTHICKNESS(style) + focus_pad);
|
||||
if (gtk_widget_get_direction(gOptionMenuWidget) == GTK_TEXT_DIR_RTL)
|
||||
x += indicator_spacing.left + indicator_spacing.right +
|
||||
indicator_size.width;
|
||||
} else {
|
||||
x -= focus_width + focus_pad;
|
||||
y -= focus_width + focus_pad;
|
||||
width += 2 * (focus_width + focus_pad);
|
||||
height += 2 * (focus_width + focus_pad);
|
||||
}
|
||||
|
||||
TSOffsetStyleGCs(style, x, y);
|
||||
gtk_paint_focus (style, drawable, state_type, cliprect, gOptionMenuWidget,
|
||||
"button", x, y, width, height);
|
||||
}
|
||||
|
||||
return MOZ_GTK_SUCCESS;
|
||||
}
|
||||
|
||||
static gint
|
||||
moz_gtk_dropdown_arrow_paint(GdkDrawable* drawable, GdkRectangle* rect,
|
||||
GdkRectangle* cliprect, GtkWidgetState* state)
|
||||
|
@ -1163,6 +1285,10 @@ moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
|
|||
ensure_arrow_widget();
|
||||
w = gDropdownButtonWidget;
|
||||
break;
|
||||
case MOZ_GTK_DROPDOWN:
|
||||
ensure_option_menu_widget();
|
||||
w = gOptionMenuWidget;
|
||||
break;
|
||||
case MOZ_GTK_TABPANELS:
|
||||
ensure_tab_widget();
|
||||
w = gTabWidget;
|
||||
|
@ -1340,6 +1466,9 @@ moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
|
|||
case MOZ_GTK_ENTRY:
|
||||
return moz_gtk_entry_paint(drawable, rect, cliprect, state);
|
||||
break;
|
||||
case MOZ_GTK_DROPDOWN:
|
||||
return moz_gtk_option_menu_paint(drawable, rect, cliprect, state);
|
||||
break;
|
||||
case MOZ_GTK_DROPDOWN_ARROW:
|
||||
return moz_gtk_dropdown_arrow_paint(drawable, rect, cliprect, state);
|
||||
break;
|
||||
|
|
|
@ -116,6 +116,8 @@ typedef enum {
|
|||
MOZ_GTK_GRIPPER,
|
||||
/* Paints a GtkEntry. */
|
||||
MOZ_GTK_ENTRY,
|
||||
/* Paints a GtkOptionMenu. */
|
||||
MOZ_GTK_DROPDOWN,
|
||||
/* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
|
||||
MOZ_GTK_DROPDOWN_ARROW,
|
||||
/* Paints the container part of a GtkCheckButton. */
|
||||
|
|
|
@ -246,9 +246,10 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
|||
memset(aState, 0, sizeof(GtkWidgetState));
|
||||
} else {
|
||||
|
||||
// for dropdown textfields, look at the parent frame (the textbox)
|
||||
// for dropdown textfields, look at the parent frame (textbox or menulist)
|
||||
if (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD)
|
||||
aFrame = aFrame->GetParent();
|
||||
|
||||
// For XUL checkboxes and radio buttons, the state of the parent
|
||||
// determines our state.
|
||||
if (aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_RADIO ||
|
||||
|
@ -369,10 +370,15 @@ nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
|
|||
case NS_THEME_TOOLBAR_GRIPPER:
|
||||
aGtkWidgetType = MOZ_GTK_GRIPPER;
|
||||
break;
|
||||
case NS_THEME_DROPDOWN_TEXTFIELD:
|
||||
case NS_THEME_TEXTFIELD:
|
||||
case NS_THEME_DROPDOWN_TEXTFIELD:
|
||||
aGtkWidgetType = MOZ_GTK_ENTRY;
|
||||
break;
|
||||
case NS_THEME_DROPDOWN:
|
||||
aGtkWidgetType = MOZ_GTK_DROPDOWN;
|
||||
break;
|
||||
case NS_THEME_DROPDOWN_TEXT:
|
||||
return PR_FALSE; // nothing to do, but prevents the bg from being drawn
|
||||
case NS_THEME_DROPDOWN_BUTTON:
|
||||
aGtkWidgetType = MOZ_GTK_DROPDOWN_ARROW;
|
||||
break;
|
||||
|
@ -754,9 +760,7 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
|
|||
// case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL: (n/a for gtk)
|
||||
case NS_THEME_TEXTFIELD:
|
||||
// case NS_THEME_TEXTFIELD_CARET:
|
||||
// case NS_THEME_DROPDOWN:
|
||||
case NS_THEME_DROPDOWN_BUTTON:
|
||||
// case NS_THEME_DROPDOWN_TEXT:
|
||||
case NS_THEME_DROPDOWN_TEXTFIELD:
|
||||
// case NS_THEME_SLIDER:
|
||||
// case NS_THEME_SLIDER_THUMB:
|
||||
|
@ -773,6 +777,8 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
|
|||
case NS_THEME_MENUITEM:
|
||||
case NS_THEME_WINDOW:
|
||||
case NS_THEME_DIALOG:
|
||||
case NS_THEME_DROPDOWN:
|
||||
case NS_THEME_DROPDOWN_TEXT:
|
||||
#endif
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ classic.jar:
|
|||
+ skin/classic/global/autocomplete.css
|
||||
+ skin/classic/global/popup.css
|
||||
+ skin/classic/global/menu.css
|
||||
+ skin/classic/global/menulist.css
|
||||
+ skin/classic/global/toolbar.css
|
||||
+ skin/classic/global/toolbarbutton.css
|
||||
+ skin/classic/global/button.css
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla Communicator client code, released
|
||||
* March 31, 1998.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Joe Hewitt (hewitt@netscape.com)
|
||||
* Pierre Chanial (p_ch@verizon.net)
|
||||
*/
|
||||
|
||||
/* ===== menulist.css ===================================================
|
||||
== Styles used by the XUL menulist element.
|
||||
====================================================================== */
|
||||
|
||||
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
|
||||
@namespace html url("http://www.w3.org/1999/xhtml");
|
||||
|
||||
/* :::::::::: menulist :::::::::: */
|
||||
|
||||
menulist {
|
||||
-moz-appearance: menulist;
|
||||
margin: 2px 2px;
|
||||
color: -moz-DialogText;
|
||||
}
|
||||
|
||||
.menulist-label-box {
|
||||
-moz-appearance: menulist-text;
|
||||
-moz-box-align: center;
|
||||
-moz-box-pack: center;
|
||||
margin: 1px;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.menulist-label {
|
||||
margin: 1px 3px !important;
|
||||
}
|
||||
|
||||
.menulist-dropmarker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
menulist[disabled="true"] {
|
||||
color: GrayText;
|
||||
}
|
||||
|
||||
.menulist-description {
|
||||
font-style: italic;
|
||||
color: GrayText;
|
||||
margin-left: 1ex !important;
|
||||
}
|
||||
|
||||
/* ::::: editable menulists ::::: */
|
||||
|
||||
menulist[editable="true"] {
|
||||
-moz-appearance: none;
|
||||
color: -moz-FieldText;
|
||||
}
|
||||
|
||||
.menulist-editable-box {
|
||||
-moz-appearance: menulist-textfield;
|
||||
}
|
||||
|
||||
menulist[editable="true"] > .menulist-dropmarker {
|
||||
display: -moz-box;
|
||||
-moz-appearance: menulist-button;
|
||||
}
|
||||
|
||||
html|*.menulist-editable-input {
|
||||
margin: 0px !important;
|
||||
border: none !important;
|
||||
padding: 0px !important;
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
|
||||
/* ::::: compact menulists ::::: */
|
||||
|
||||
.menulist-compact {
|
||||
-moz-box-align: center;
|
||||
-moz-box-pack: center;
|
||||
margin: 0;
|
||||
color: -moz-DialogText;
|
||||
}
|
||||
|
||||
.menulist-compact > .menulist-dropmarker {
|
||||
-moz-appearance: menulist-button;
|
||||
display: -moz-box;
|
||||
margin-left: 2px;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.menulist-compact > .menulist-label {
|
||||
margin: 0 3px !important;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.menulist-compact[open="true"] {
|
||||
color: ThreeDHighlight;
|
||||
}
|
|
@ -1,10 +1,36 @@
|
|||
/*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998-1999 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Joe Hewitt (hewitt@netscape.com)
|
||||
* Kevin Gerich (webmail@kmgerich.com)
*/
/* ===== menulist.css ===================================================
== Styles used by the XUL menulist element.
======================================================================= */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");
/* :::::::::: menulist :::::::::: */
menulist {
-moz-appearance: menulist;
-moz-user-focus: ignore;
margin: 2px 4px;
|
||||
height: 20px !important;
|
||||
}
.menulist-label-box {
-moz-appearance: menulist-text;
-moz-box-align: center;
-moz-box-pack: center;
background-color: #CCCCCC;
|
||||
border: 1px solid blue;
}
.menulist-label {
margin: 1px 3px !important;
|
||||
}
|
||||
/* ..... dropmarker ..... */
.menulist-dropmarker {
-moz-appearance: menulist-button;
}
/* ..... disabled state ..... */
menulist[disabled="true"] {
color: #777777 !important;
}
menulist[disabled="true"] > .menulist-dropmarker {
padding-left: 7px !important;
}
/* ::::: editable menulists ::::: */
menulist[editable="true"] {
-moz-user-focus: normal;
}
menulist[editable="true"] > .menulist-dropmarker {
-moz-border-left-colors: #000000 #CCCCCC #FFFFFF;
-moz-border-radius: 2px;
}
menulist[editable="true"][open="true"] > .menulist-dropmarker {
-moz-border-left-colors: #000000 #454545 #555555;
}
.menulist-editable-box {
margin-right: 4px;
border-top: 1px solid #A1A1A1;
|
||||
|
||||
.menulist-label-box {
|
||||
-moz-appearance: menulist-text;
|
||||
-moz-box-align: center;
|
||||
-moz-box-pack: center;
|
||||
background-color: #CCCCCC;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
.menulist-label {
|
||||
margin: 1px 3px !important;
|
||||
}
|
||||
|
||||
.menulist-description {
|
||||
font-style: italic;
|
||||
color: GrayText;
|
||||
margin-left: 1ex !important;
|
||||
}
|
||||
|
||||
* ..... dropmarker ..... */
|
||||
.menulist-dropmarker {
|
||||
-moz-appearance: menulist-button;
|
||||
}
|
||||
|
||||
/* ..... disabled state ..... */
|
||||
menulist[disabled="true"] {
|
||||
color: #777777 !important;
|
||||
}
|
||||
menulist[disabled="true"] > .menulist-dropmarker {
padding-left: 7px !important;
}
/* ::::: editable menulists ::::: */
menulist[editable="true"] {
-moz-user-focus: normal;
}
menulist[editable="true"] > .menulist-dropmarker {
-moz-border-left-colors: #000000 #CCCCCC #FFFFFF;
-moz-border-radius: 2px;
}
menulist[editable="true"][open="true"] > .menulist-dropmarker {
-moz-border-left-colors: #000000 #454545 #555555;
}
.menulist-editable-box {
margin-right: 4px;
border-top: 1px solid #A1A1A1;
|
||||
border-right: 1px solid #C3C3C3;
|
||||
border-bottom: 1px solid #DDDDDD;
|
||||
border-left: 1px solid #C3C3C3;
padding: 1px 0px 1px 2px;
background-color: -moz-Field;
color: -moz-FieldText;
}
menulist[editable="true"][focused="true"] > .menulist-editable-box {
-moz-border-top-colors: -moz-mac-focusring -moz-mac-focusring #000000;
-moz-border-right-colors: -moz-mac-focusring -moz-mac-focusring #000000;
-moz-border-bottom-colors: -moz-mac-focusring -moz-mac-focusring #000000;
-moz-border-left-colors: -moz-mac-focusring -moz-mac-focusring #000000;
}
html|*.menulist-editable-input {
margin: 0px !important;
border: none !important;
padding: 0px !important;
background: inherit;
font: inherit;
}
/* ::::: compact menulists ::::: */
.menulist-compact {
-moz-box-align: center;
-moz-box-pack: center;
margin: 0;
border: 2px solid;
-moz-border-top-colors: ThreeDLightShadow ThreeDHighlight;
-moz-border-right-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-bottom-colors: ThreeDDarkShadow ThreeDShadow;
-moz-border-left-colors: ThreeDLightShadow ThreeDHighlight;
background-color: -moz-Dialog;
}
.menulist-compact > .menulist-label {
margin: 0 3px !important;
text-align: right;
|
||||
|
|
|
@ -59,6 +59,12 @@ menulist[open="true"]:focus > .menulist-label-box {
|
|||
margin: 1px 3px !important;
|
||||
}
|
||||
|
||||
.menulist-description {
|
||||
font-style: italic;
|
||||
color: GrayText;
|
||||
margin-left: 1ex !important;
|
||||
}
|
||||
|
||||
/* ..... dropmarker ..... */
|
||||
|
||||
.menulist-dropmarker {
|
||||
|
|
Загрузка…
Ссылка в новой задаче