int4 MCNativeTheme::getmetric(Widget_Metric wmetric) { //get metric for widget type without state info int4 ret = 0; switch(wmetric) { case WTHEME_METRIC_TABSTARTOFFSET: return 0; //offset from x to tab pane to x of first tab break; case WTHEME_METRIC_TABNONSELECTEDOFFSET: ret = 1; break; case WTHEME_METRIC_TABOVERLAP: ret = -1; // hardcoded break; case WTHEME_METRIC_TABRIGHTMARGIN: case WTHEME_METRIC_TABLEFTMARGIN: ret = 12; break; case WTHEME_METRIC_MINIMUMSIZE: case WTHEME_METRIC_OPTIMUMSIZE: case WTHEME_METRIC_DRAWSIZE: case WTHEME_METRIC_PARTSIZE: ret = 0; break; case WTHEME_METRIC_TRACKSIZE: if ( gtktracksize == 0 ) { if (gtktracksize == 0) gtktracksize = getscrollbarmintracksize(); } return gtktracksize; break; case WTHEME_METRIC_CHECKBUTTON_INDICATORSIZE: moz_gtk_checkbox_get_metrics(&ret, 0); break; case WTHEME_METRIC_CHECKBUTTON_INDICATORSPACING: moz_gtk_checkbox_get_metrics(0, &ret); break; case WTHEME_METRIC_RADIOBUTTON_INDICATORSIZE: moz_gtk_radiobutton_get_metrics(&ret, 0); break; case WTHEME_METRIC_RADIOBUTTON_INDICATORSPACING: moz_gtk_radiobutton_get_metrics(0, &ret); break; default: break; } return ret; }
static void setToggleSize(RenderStyle* style, EAppearance appearance) { // The width and height are both specified, so we shouldn't change them. if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) return; // FIXME: This is probably not correct use of indicator_size and indicator_spacing. gint indicator_size, indicator_spacing; switch (appearance) { case CheckboxAppearance: if (moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS) return; break; case RadioAppearance: if (moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS) return; break; default: return; } // Other ports hard-code this to 13, but GTK+ users tend to demand the native look. // It could be made a configuration option values other than 13 actually break site compatibility. int length = indicator_size + indicator_spacing; if (style->width().isIntrinsicOrAuto()) style->setWidth(Length(length, Fixed)); if (style->height().isAuto()) style->setHeight(Length(length, Fixed)); }
static gint moz_gtk_toggle_paint(GdkDrawable* drawable, GdkRectangle* rect, GdkRectangle* cliprect, GtkWidgetState* state, gboolean selected, gboolean inconsistent, gboolean isradio, GtkTextDirection direction) { GtkStateType state_type = ConvertGtkState(state); GtkShadowType shadow_type = (selected)?GTK_SHADOW_IN:GTK_SHADOW_OUT; gint indicator_size, indicator_spacing; gint x, y, width, height; gint focus_x, focus_y, focus_width, focus_height; GtkWidget *w; GtkStyle *style; if (isradio) { moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing); w = gParts->radiobuttonWidget; } else { moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing); w = gParts->checkboxWidget; } // "GetMinimumWidgetSize was ignored" // FIXME: This assert causes a build failure in WebKitGTK+ debug // builds, because it uses 'false' in its definition. We may want // to force this file to be built with g++, by renaming it. // ASSERT(rect->width == indicator_size); /* * vertically center in the box, since XUL sometimes ignores our * GetMinimumWidgetSize in the vertical dimension */ x = rect->x; y = rect->y + (rect->height - indicator_size) / 2; width = indicator_size; height = indicator_size; focus_x = x - indicator_spacing; focus_y = y - indicator_spacing; focus_width = width + 2 * indicator_spacing; focus_height = height + 2 * indicator_spacing; style = gtk_widget_get_style(w); TSOffsetStyleGCs(style, x, y); gtk_widget_set_sensitive(w, !state->disabled); gtk_widget_set_direction(w, direction); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), selected); if (isradio) { gtk_paint_option(style, drawable, state_type, shadow_type, cliprect, gParts->radiobuttonWidget, "radiobutton", x, y, width, height); if (state->focused) { gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect, gParts->radiobuttonWidget, "radiobutton", focus_x, focus_y, focus_width, focus_height); } } else { /* * 'indeterminate' type on checkboxes. In GTK, the shadow type * must also be changed for the state to be drawn. */ if (inconsistent) { gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gParts->checkboxWidget), TRUE); shadow_type = GTK_SHADOW_ETCHED_IN; } else { gtk_toggle_button_set_inconsistent(GTK_TOGGLE_BUTTON(gParts->checkboxWidget), FALSE); } gtk_paint_check(style, drawable, state_type, shadow_type, cliprect, gParts->checkboxWidget, "checkbutton", x, y, width, height); if (state->focused) { gtk_paint_focus(style, drawable, GTK_STATE_ACTIVE, cliprect, gParts->checkboxWidget, "checkbutton", focus_x, focus_y, focus_width, focus_height); } } return MOZ_GTK_SUCCESS; }