Exemple #1
0
static void
run_functions (Test *test)
{
    GtkStyle *style = styles[test->style];
    
    if (test->function & FUNCTION_ARROW)
        gtk_paint_arrow (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, test->arrow_type, test->fill, 0, 0, 10, 10);

    if (test->function & FUNCTION_BOX)
        gtk_paint_box (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);

    if (test->function & FUNCTION_SHADOW)
        gtk_paint_shadow (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);

    if (test->function & FUNCTION_BOX_GAP)
        gtk_paint_box_gap (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10, test->gap_side, 0, 100);

    if (test->function & FUNCTION_SHADOW_GAP)
        gtk_paint_shadow_gap (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10, test->gap_side, 0, 100);


    if (test->function & FUNCTION_CHECK)
        gtk_paint_check (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);
        
    if (test->function & FUNCTION_EXPANDER)
        gtk_paint_expander (style, window->window, test->state, NULL, widgets[test->widget], test->detail, 10, 10, test->expander_style);

    if (test->function & FUNCTION_EXTENSION)
        gtk_paint_extension (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10, test->gap_side);

    if (test->function & FUNCTION_FLAT_BOX)
        gtk_paint_flat_box (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);

    if (test->function & FUNCTION_FOCUS)
        gtk_paint_focus (style, window->window, test->state, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);

    if (test->function & FUNCTION_HANDLE)
        gtk_paint_handle (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10, test->orientation);

    if (test->function & FUNCTION_OPTION)
        gtk_paint_option (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);

    if (test->function & FUNCTION_RESIZE_GRIP)
        gtk_paint_resize_grip (style, window->window, test->state, NULL, widgets[test->widget], test->detail, test->edge, 0, 0, 10, 10);

    if (test->function & FUNCTION_SLIDER)
        gtk_paint_slider (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10, test->orientation);

    if (test->function & FUNCTION_TAB)
        gtk_paint_tab (style, window->window, test->state, test->shadow, NULL, widgets[test->widget], test->detail, 0, 0, 10, 10);


    if (test->function & FUNCTION_HLINE)
        gtk_paint_hline (style, window->window, test->state, NULL, widgets[test->widget], test->detail, 1, 10, 4);

    if (test->function & FUNCTION_VLINE)
        gtk_paint_vline (style, window->window, test->state, NULL, widgets[test->widget], test->detail, 1, 10, 4);
}
Exemple #2
0
static VALUE
style_paint_check(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE shadow_type, VALUE area, VALUE widget, VALUE detail, VALUE x, VALUE y, VALUE width, VALUE height)
{
    gtk_paint_check(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)),
                    RVAL2STATE(state_type), RVAL2SHADOW(shadow_type), RVAL2REC(area),
                    GTK_WIDGET(RVAL2GOBJ(widget)), RVAL2CSTR(detail),
                    NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height));
    return self;
}
void WidgetRenderingContext::gtkPaintCheck(const IntRect& rect, GtkWidget* widget, GtkStateType stateType, GtkShadowType shadowType, const gchar* detail)
{
    GdkRectangle paintRect = { m_paintRect.x + rect.x(), m_paintRect.y + rect.y(), rect.width(), rect.height() };
    gtk_paint_check(gtk_widget_get_style(widget), m_target, stateType, shadowType, &paintRect, widget,
                    detail, paintRect.x, paintRect.y, paintRect.width, paintRect.height);
}
Exemple #4
0
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;
}
Exemple #5
0
gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* event )
{
/*     g_message("Exposed!!!   %s", GTK_WIDGET_HAS_FOCUS(widget) ? "XXX" : "---" ); */
    gint insetX = 0;
    gint insetY = 0;

    (void)event;
/*
    gint lower = widget->allocation.width;
    lower = (widget->allocation.height < lower) ? widget->allocation.height : lower;
    if ( lower > 16 ) {
        insetX++;
        if ( lower > 18 ) {
            insetX++;
            if ( lower > 22 ) {
                insetX++;
                if ( lower > 24 ) {
                    insetX++;
                    if ( lower > 32 ) {
                        insetX++;
                    }
                }
            }
        }
        insetY = insetX;
    }
*/

    if ( GTK_WIDGET_DRAWABLE( widget ) ) {
        GtkStyle* style = gtk_widget_get_style( widget );

        if ( insetX > 0 || insetY > 0 ) {
            gtk_paint_flat_box( style,
                                widget->window,
                                (GtkStateType)GTK_WIDGET_STATE(widget),
                                GTK_SHADOW_NONE,
                                NULL,
                                widget,
                                NULL,
                                0, 0,
                                widget->allocation.width, widget->allocation.height);
        }

        GdkGC *gc = gdk_gc_new( widget->window );
        EekPreview* preview = EEK_PREVIEW(widget);
        GdkColor fg = {0, static_cast<guint16>(preview->_r), static_cast<guint16>(preview->_g), static_cast<guint16>(preview->_b)};

        gdk_colormap_alloc_color( gdk_colormap_get_system(), &fg, FALSE, TRUE );

        gdk_gc_set_foreground( gc, &fg );

        gdk_draw_rectangle( widget->window,
                            gc,
                            TRUE,
                            insetX, insetY,
                            widget->allocation.width - (insetX * 2), widget->allocation.height - (insetY * 2) );

        if ( preview->_previewPixbuf ) {
            GtkDrawingArea* da = &(preview->drawing);
            GdkDrawable* drawable = (GdkDrawable*) (((GtkWidget*)da)->window);
            gint w = 0;
            gint h = 0;
            gdk_drawable_get_size(drawable, &w, &h);
            if ((w != preview->_scaledW) || (h != preview->_scaledH)) {
                if (preview->_scaled) {
                    g_object_unref(preview->_scaled);
                }
                preview->_scaled = gdk_pixbuf_scale_simple(preview->_previewPixbuf, w, h, GDK_INTERP_BILINEAR);
                preview->_scaledW = w;
                preview->_scaledH = h;
            }

            GdkPixbuf* pix = (preview->_scaled) ? preview->_scaled : preview->_previewPixbuf;
            gdk_draw_pixbuf( drawable, 0, pix, 0, 0, 0, 0, w, h, GDK_RGB_DITHER_NONE, 0, 0 );
        }


        if ( preview->_linked ) {
            /* Draw arrow */
            GdkRectangle possible = {insetX, insetY, (widget->allocation.width - (insetX * 2)), (widget->allocation.height - (insetY * 2)) };
            GdkRectangle area = {possible.x, possible.y, possible.width / 2, possible.height / 2 };

            /* Make it square */
            if ( area.width > area.height )
                area.width = area.height;
            if ( area.height > area.width )
                area.height = area.width;

            /* Center it horizontally */
            if ( area.width < possible.width ) {
                int diff = (possible.width - area.width) / 2;
                area.x += diff;
            }


            if ( preview->_linked & PREVIEW_LINK_IN ) {
                gtk_paint_arrow( style,
                                 widget->window,
                                 (GtkStateType)widget->state,
                                 GTK_SHADOW_ETCHED_IN,
                                 NULL, /* clip area.  &area, */
                                 widget, /* may be NULL */
                                 NULL, /* detail */
                                 GTK_ARROW_DOWN,
                                 FALSE,
                                 area.x, area.y,
                                 area.width, area.height
                                 );
            }

            if ( preview->_linked & PREVIEW_LINK_OUT ) {
                GdkRectangle otherArea = {area.x, area.y, area.width, area.height};
                if ( otherArea.height < possible.height ) {
                    otherArea.y = possible.y + (possible.height - otherArea.height);
                }

                gtk_paint_arrow( style,
                                 widget->window,
                                 (GtkStateType)widget->state,
                                 GTK_SHADOW_ETCHED_OUT,
                                 NULL, /* clip area.  &area, */
                                 widget, /* may be NULL */
                                 NULL, /* detail */
                                 GTK_ARROW_DOWN,
                                 FALSE,
                                 otherArea.x, otherArea.y,
                                 otherArea.width, otherArea.height
                                 );
            }

            if ( preview->_linked & PREVIEW_LINK_OTHER ) {
                GdkRectangle otherArea = {insetX, area.y, area.width, area.height};
                if ( otherArea.height < possible.height ) {
                    otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
                }

                gtk_paint_arrow( style,
                                 widget->window,
                                 (GtkStateType)widget->state,
                                 GTK_SHADOW_ETCHED_OUT,
                                 NULL, /* clip area.  &area, */
                                 widget, /* may be NULL */
                                 NULL, /* detail */
                                 GTK_ARROW_LEFT,
                                 FALSE,
                                 otherArea.x, otherArea.y,
                                 otherArea.width, otherArea.height
                                 );
            }


            if ( preview->_linked & PREVIEW_FILL ) {
                GdkRectangle otherArea = {possible.x + ((possible.width / 4) - (area.width / 2)),
                                          area.y,
                                          area.width, area.height};
                if ( otherArea.height < possible.height ) {
                    otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
                }
                gtk_paint_check( style,
                                 widget->window,
                                 (GtkStateType)widget->state,
                                 GTK_SHADOW_ETCHED_OUT,
                                 NULL,
                                 widget,
                                 NULL,
                                 otherArea.x, otherArea.y,
                                 otherArea.width, otherArea.height );
            }

            if ( preview->_linked & PREVIEW_STROKE ) {
                GdkRectangle otherArea = {possible.x + (((possible.width * 3) / 4) - (area.width / 2)),
                                          area.y,
                                          area.width, area.height};
                if ( otherArea.height < possible.height ) {
                    otherArea.y = possible.y + (possible.height - otherArea.height) / 2;
                }
                gtk_paint_diamond( style,
                                   widget->window,
                                   (GtkStateType)widget->state,
                                   GTK_SHADOW_ETCHED_OUT,
                                   NULL,
                                   widget,
                                   NULL,
                                   otherArea.x, otherArea.y,
                                   otherArea.width, otherArea.height );
            }
        }


        if ( GTK_WIDGET_HAS_FOCUS(widget) ) {
            gtk_paint_focus( style,
                             widget->window,
                             GTK_STATE_NORMAL,
                             NULL, /* GdkRectangle *area, */
                             widget,
                             NULL,
                             0 + 1, 0 + 1,
                             widget->allocation.width - 2, widget->allocation.height - 2 );
        }
    }


    return FALSE;
}