зеркало из https://github.com/mozilla/gecko-dev.git
Cleaning up checkbox/radio button code, now that I understand how it's supposed to work. Hooked up checkbox/radio containers. Fixed active/hover state problems with buttons. Not part of the build.
This commit is contained in:
Родитель
f6f6979c15
Коммит
c0810e34f3
|
@ -57,12 +57,10 @@ extern GtkWidget* gDropdownButtonWidget;
|
|||
GtkStateType
|
||||
ConvertGtkState(GtkWidgetState* aState)
|
||||
{
|
||||
if (aState->active)
|
||||
return GTK_STATE_ACTIVE;
|
||||
else if (aState->disabled)
|
||||
if (aState->disabled)
|
||||
return GTK_STATE_INSENSITIVE;
|
||||
else if (aState->inHover)
|
||||
return GTK_STATE_PRELIGHT;
|
||||
return (aState->active ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT);
|
||||
else
|
||||
return GTK_STATE_NORMAL;
|
||||
}
|
||||
|
@ -103,7 +101,7 @@ moz_gtk_button_paint(GdkWindow* window, GtkStyle* style,
|
|||
height -= 2;
|
||||
}
|
||||
|
||||
shadow_type = (buttonState->active) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
||||
shadow_type = (buttonState->active && buttonState->inHover) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
||||
|
||||
if (relief != GTK_RELIEF_NONE || (button_state != GTK_STATE_NORMAL &&
|
||||
button_state != GTK_STATE_INSENSITIVE))
|
||||
|
@ -122,36 +120,21 @@ moz_gtk_button_paint(GdkWindow* window, GtkStyle* style,
|
|||
}
|
||||
|
||||
void
|
||||
moz_gtk_check_button_draw_indicator(GdkWindow* window, GtkStyle* style,
|
||||
moz_gtk_checkbox_paint(GdkWindow* window, GtkStyle* style,
|
||||
GdkRectangle* boxRect, GdkRectangle* clipRect,
|
||||
GtkToggleButtonState* aState, const char* detail)
|
||||
{
|
||||
GtkStateType state_type;
|
||||
GtkShadowType shadow_type;
|
||||
gint indicator_size = 10;
|
||||
gint indicator_spacing = 2;
|
||||
gint indicator_size, indicator_spacing;
|
||||
GtkWidgetState* wState = (GtkWidgetState*) aState;
|
||||
gint x, y, width, height;
|
||||
|
||||
/* XXX get indicator size/spacing properties
|
||||
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
|
||||
*/
|
||||
_gtk_check_button_get_props(GTK_CHECK_BUTTON(gCheckboxWidget), &indicator_size,
|
||||
&indicator_spacing);
|
||||
|
||||
state_type = ConvertGtkState(wState);
|
||||
|
||||
if (state_type != GTK_STATE_NORMAL &&
|
||||
state_type != GTK_STATE_PRELIGHT)
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
if (state_type != GTK_STATE_NORMAL) /* this is for drawing e.g. a prelight box */
|
||||
gtk_paint_flat_box (style, window, state_type,
|
||||
GTK_SHADOW_ETCHED_OUT,
|
||||
clipRect, gCheckboxWidget, detail,
|
||||
boxRect->x, boxRect->y,
|
||||
boxRect->width, boxRect->height);
|
||||
|
||||
x = boxRect->x + indicator_spacing;
|
||||
y = boxRect->y + (boxRect->height - indicator_size) / 2;
|
||||
x = boxRect->x; /* left justified within the rect */
|
||||
y = boxRect->y + (boxRect->height - indicator_size) / 2; /* vertically centered */
|
||||
width = indicator_size;
|
||||
height = indicator_size;
|
||||
|
||||
|
@ -164,32 +147,12 @@ moz_gtk_check_button_draw_indicator(GdkWindow* window, GtkStyle* style,
|
|||
state_type = ConvertGtkState(wState);
|
||||
}
|
||||
|
||||
if (!strcmp(detail, "radiobutton"))
|
||||
if (detail[0] == 'r') /* radiobutton */
|
||||
gtk_paint_option(style, window, state_type, shadow_type, clipRect,
|
||||
gCheckboxWidget, detail, x+1, y+1, width, height);
|
||||
gCheckboxWidget, (char*) detail, x, y, width, height);
|
||||
else
|
||||
gtk_paint_check(style, window, state_type, shadow_type, clipRect,
|
||||
gCheckboxWidget, detail, x+1, y+1, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
moz_gtk_checkbox_paint(GdkWindow* window, GtkStyle* style,
|
||||
GdkRectangle* boxRect, GdkRectangle* clipRect,
|
||||
GtkToggleButtonState* aState, const char* detail)
|
||||
{
|
||||
moz_gtk_check_button_draw_indicator(window, style, boxRect,
|
||||
clipRect, aState, detail);
|
||||
|
||||
#if 0
|
||||
if (((GtkWidgetState*)aState)->focused) {
|
||||
gint border_width = GTK_CONTAINER(gCheckboxWidget)->border_width;
|
||||
gtk_paint_focus (style, window,
|
||||
NULL, gCheckboxWidget, detail,
|
||||
boxRect->x + border_width, boxRect->y + border_width,
|
||||
boxRect->width - 2*border_width - 1,
|
||||
boxRect->height - 2*border_width - 1);
|
||||
}
|
||||
#endif
|
||||
gCheckboxWidget, (char*) detail, x, y, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -289,3 +252,21 @@ moz_gtk_dropdown_arrow_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* r
|
|||
clipRect, gArrowWidget, "arrow", GTK_ARROW_DOWN, TRUE, rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
|
||||
void
|
||||
moz_gtk_container_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
|
||||
GdkRectangle* clipRect, GtkWidgetState* state, const char* detail)
|
||||
{
|
||||
GtkStateType state_type = ConvertGtkState(state);
|
||||
|
||||
if (state_type != GTK_STATE_NORMAL &&
|
||||
state_type != GTK_STATE_PRELIGHT)
|
||||
state_type = GTK_STATE_NORMAL;
|
||||
|
||||
if (state_type != GTK_STATE_NORMAL) /* this is for drawing e.g. a prelight box */
|
||||
gtk_paint_flat_box (style, window, state_type,
|
||||
GTK_SHADOW_ETCHED_OUT,
|
||||
clipRect, gCheckboxWidget, (char*) detail,
|
||||
rect->x, rect->y,
|
||||
rect->width, rect->height);
|
||||
}
|
||||
|
|
|
@ -99,6 +99,10 @@ void
|
|||
moz_gtk_dropdown_arrow_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
|
||||
GdkRectangle* clipRect, GtkWidgetState* state);
|
||||
|
||||
void
|
||||
moz_gtk_container_paint(GdkWindow* window, GtkStyle* style, GdkRectangle* rect,
|
||||
GdkRectangle* clipRect, GtkWidgetState* aState, const char* detail);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -269,16 +269,6 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
|
|||
nsIAtom* atom = (aWidgetType == NS_THEME_CHECKBOX) ? mCheckedAtom : mSelectedAtom;
|
||||
checkBoxState.selected = CheckBooleanAttr(aFrame, atom);
|
||||
|
||||
#ifdef DEBUG_NATIVE_THEME
|
||||
printf("paint checkbox: aRect=(%d,%d,%d,%d), aClipRect=(%d,%d,%d,%d)\n",
|
||||
aRect.x, aRect.y, aRect.width, aRect.height, aClipRect.x,
|
||||
aClipRect.y, aClipRect.width, aClipRect.height);
|
||||
|
||||
printf(" gdk_rect=(%d,%d,%d,%d), gdk_clip=(%d,%d,%d,%d)\n",
|
||||
gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height,
|
||||
gdk_clip.x, gdk_clip.y, gdk_clip.width, gdk_clip.height);
|
||||
#endif
|
||||
|
||||
moz_gtk_checkbox_paint(window, gCheckboxWidget->style, &gdk_rect,
|
||||
&gdk_clip, &checkBoxState,
|
||||
(aWidgetType==NS_THEME_RADIO) ? "radiobutton" : "checkbutton");
|
||||
|
@ -294,14 +284,8 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
|
|||
|
||||
GtkWidgetState buttonState;
|
||||
GetGtkWidgetState(aFrame, &buttonState);
|
||||
|
||||
GtkArrowType arrowType = GtkArrowType(aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP);
|
||||
|
||||
#ifdef DEBUG_NATIVE_THEME
|
||||
printf("paint scrollbar button, rect=(%d,%d,%d,%d), clip=(%d,%d,%d,%d)\n",
|
||||
gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height,
|
||||
gdk_clip.x, gdk_clip.y, gdk_clip.width, gdk_clip.height);
|
||||
#endif
|
||||
moz_gtk_scrollbar_button_paint(window, gScrollbarWidget->style, &gdk_rect, &gdk_clip,
|
||||
&buttonState, arrowType);
|
||||
}
|
||||
|
@ -328,11 +312,6 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
|
|||
GtkWidgetState thumbState;
|
||||
GetGtkWidgetState(aFrame, &thumbState);
|
||||
|
||||
#ifdef DEBUG_NATIVE_THEME
|
||||
printf("paint thumb, rect=(%d,%d,%d,%d), clip=(%d,%d,%d,%d)\n",
|
||||
gdk_rect.x, gdk_rect.y, gdk_rect.width, gdk_rect.height,
|
||||
gdk_clip.x, gdk_clip.y, gdk_clip.width, gdk_clip.height);
|
||||
#endif
|
||||
moz_gtk_scrollbar_thumb_paint(window, gScrollbarWidget->style,
|
||||
&gdk_rect, &gdk_clip, &thumbState);
|
||||
}
|
||||
|
@ -374,6 +353,19 @@ nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
|
|||
}
|
||||
break;
|
||||
|
||||
case NS_THEME_CHECKBOX_CONTAINER:
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
{
|
||||
EnsureCheckBoxWidget();
|
||||
|
||||
GtkWidgetState state;
|
||||
GetGtkWidgetState(aFrame, &state);
|
||||
|
||||
moz_gtk_container_paint(window, gCheckboxWidget->style, &gdk_rect,
|
||||
&gdk_clip, &state,
|
||||
(aWidgetType == NS_THEME_RADIO_CONTAINER) ? "radiobutton" : "checkbutton");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -501,6 +493,7 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext, nsIFrame*
|
|||
aResult->width += child_requisition.width;
|
||||
aResult->height += child_requisition.height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -557,6 +550,8 @@ nsNativeThemeGTK::ThemeSupportsWidget(nsIPresContext* aPresContext,
|
|||
switch (aWidgetType) {
|
||||
case NS_THEME_BUTTON:
|
||||
case NS_THEME_CHECKBOX:
|
||||
case NS_THEME_CHECKBOX_CONTAINER:
|
||||
case NS_THEME_RADIO_CONTAINER:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_UP:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
|
||||
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
|
||||
|
|
Загрузка…
Ссылка в новой задаче