示例#1
0
static void
gdl_dock_tablabel_paint (GtkWidget      *widget,
                         cairo_t *cr)
{
    GtkBin          *bin;
    GtkAllocation    widget_allocation;
    GdlDockTablabel *tablabel;
    gint             border_width;
    cairo_rectangle_int_t rect;

    bin = GTK_BIN (widget);
    tablabel = GDL_DOCK_TABLABEL (widget);
    border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));

    gtk_widget_get_allocation (widget, &widget_allocation);
    rect.x = widget_allocation.x + border_width;
    rect.y = widget_allocation.y + border_width;
    rect.width = tablabel->drag_handle_size * HANDLE_RATIO;
    rect.height = widget_allocation.height - 2*border_width;

    if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
    {
        GtkStyleContext* context = gtk_widget_get_style_context (widget);
        gtk_style_context_set_state (context,
                                     tablabel->active ? 0 : GTK_STATE_FLAG_ACTIVE);

        gtk_render_handle (gtk_widget_get_style_context (widget),
                           cr, rect.x, rect.y, rect.width, rect.height);
    };
}
示例#2
0
void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
    wxPaintDC dc(this);

#ifdef __WXGTK20__
    // Draw grip first
    if ( ShowsSizeGrip() )
    {
        const wxRect& rc = GetSizeGripRect();
#ifdef __WXGTK3__
        GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget);
        GdkRectangle rect;
        if (toplevel && (!gtk_window_get_resize_grip_area(GTK_WINDOW(toplevel), &rect) ||
            rect.width == 0 || rect.height == 0))
        {
            GtkStyleContext* sc = gtk_widget_get_style_context(toplevel);
            gtk_style_context_save(sc);
            gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP);
            GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
            if (GetLayoutDirection() == wxLayout_RightToLeft)
                sides = GTK_JUNCTION_CORNER_BOTTOMLEFT;
            gtk_style_context_set_junction_sides(sc, sides);
            gtk_render_handle(sc,
                static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext()),
                rc.x, rc.y, rc.width, rc.height);
            gtk_style_context_restore(sc);
        }
#else
        GdkWindowEdge edge =
            GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST :
                                                           GDK_WINDOW_EDGE_SOUTH_EAST;
        gtk_paint_resize_grip(gtk_widget_get_style(m_widget),
                            GTKGetDrawingWindow(),
                            gtk_widget_get_state(m_widget),
                            NULL,
                            m_widget,
                            "statusbar",
                            edge,
                            rc.x, rc.y, rc.width, rc.height );
#endif
    }
#endif // __WXGTK20__

    if (GetFont().IsOk())
        dc.SetFont(GetFont());

    // compute char height only once for all panes:
    int textHeight = dc.GetCharHeight();

    dc.SetBackgroundMode(wxBRUSHSTYLE_TRANSPARENT);
    for (size_t i = 0; i < m_panes.GetCount(); i ++)
        DrawField(dc, i, textHeight);
}
示例#3
0
文件: styleexamples.c 项目: BYC/gtk
static gboolean
draw_cb_handles (GtkWidget *widget, cairo_t *cr)
{
  GtkStyleContext *context;

  context = gtk_widget_get_style_context (widget);
  gtk_style_context_save (context);

  gtk_style_context_add_class (context, "paned");
  gtk_render_handle (context, cr, 12, 22, 20, 10);
  gtk_render_handle (context, cr, 44, 12, 10, 20);
  gtk_style_context_remove_class (context, "paned");

  gtk_style_context_add_class (context, "grip");
  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_CORNER_BOTTOMLEFT);
  gtk_render_handle (context, cr, 12, 48, 12, 12);

  gtk_style_context_set_junction_sides (context, GTK_JUNCTION_CORNER_BOTTOMRIGHT);
  gtk_render_handle (context, cr, 40, 48, 12, 12);

  gtk_style_context_restore (context);

  return TRUE;
}
示例#4
0
static gboolean handle_real_draw (GtkWidget* base, cairo_t* cr) {
	Handle * self;
	gboolean result = FALSE;
	cairo_t* _tmp0_;
	GdkWindow* _tmp1_ = NULL;
	gboolean _tmp2_ = FALSE;
	self = (Handle*) base;
	g_return_val_if_fail (cr != NULL, FALSE);
	_tmp0_ = cr;
	_tmp1_ = gtk_widget_get_window ((GtkWidget*) self);
	_tmp2_ = gtk_cairo_should_draw_window (_tmp0_, _tmp1_);
	if (_tmp2_) {
		GtkStyleContext* _tmp3_ = NULL;
		GtkStyleContext* _tmp4_;
		GtkStyleContext* context;
		GtkAllocation allocation = {0};
		GtkAllocation _tmp5_ = {0};
		GtkStyleContext* _tmp6_;
		cairo_t* _tmp7_;
		GtkAllocation _tmp8_;
		gint _tmp9_;
		GtkAllocation _tmp10_;
		gint _tmp11_;
		GtkAllocation _tmp12_;
		gint _tmp13_;
		GtkAllocation _tmp14_;
		gint _tmp15_;
		_tmp3_ = gtk_widget_get_style_context ((GtkWidget*) self);
		_tmp4_ = _g_object_ref0 (_tmp3_);
		context = _tmp4_;
		gtk_widget_get_allocation ((GtkWidget*) self, &_tmp5_);
		allocation = _tmp5_;
		_tmp6_ = context;
		_tmp7_ = cr;
		_tmp8_ = allocation;
		_tmp9_ = _tmp8_.x;
		_tmp10_ = allocation;
		_tmp11_ = _tmp10_.y;
		_tmp12_ = allocation;
		_tmp13_ = _tmp12_.height;
		_tmp14_ = allocation;
		_tmp15_ = _tmp14_.width;
		gtk_render_handle (_tmp6_, _tmp7_, (gdouble) _tmp9_, (gdouble) (_tmp11_ + ((_tmp13_ - 40) / 2)), (gdouble) _tmp15_, 40.0);
		_g_object_unref0 (context);
	}
	result = FALSE;
	return result;
}
示例#5
0
void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
    wxPaintDC dc(this);

#ifdef __WXGTK20__
    // Draw grip first
    if ( ShowsSizeGrip() )
    {
        const wxRect& rc = GetSizeGripRect();
#ifdef __WXGTK3__
        GtkWidget* toplevel = gtk_widget_get_toplevel(m_widget);
        GdkRectangle rect;
        wxGCC_WARNING_SUPPRESS(deprecated-declarations)
        if (toplevel && (!gtk_window_get_resize_grip_area(GTK_WINDOW(toplevel), &rect) ||
            rect.width == 0 || rect.height == 0))
        wxGCC_WARNING_RESTORE()
        {
            GtkStyleContext* sc = gtk_widget_get_style_context(toplevel);
            gtk_style_context_save(sc);
            gtk_style_context_add_class(sc, GTK_STYLE_CLASS_GRIP);
            GtkJunctionSides sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
            if (GetLayoutDirection() == wxLayout_RightToLeft)
                sides = GTK_JUNCTION_CORNER_BOTTOMLEFT;
            gtk_style_context_set_junction_sides(sc, sides);
            gtk_render_handle(sc,
                static_cast<cairo_t*>(dc.GetImpl()->GetCairoContext()),
                rc.x, rc.y, rc.width, rc.height);
            gtk_style_context_restore(sc);
        }
#else
        GdkWindowEdge edge =
            GetLayoutDirection() == wxLayout_RightToLeft ? GDK_WINDOW_EDGE_SOUTH_WEST :
                                                           GDK_WINDOW_EDGE_SOUTH_EAST;
        gtk_paint_resize_grip(gtk_widget_get_style(m_widget),
                            GTKGetDrawingWindow(),
                            gtk_widget_get_state(m_widget),
                            NULL,
                            m_widget,
                            "statusbar",
                            edge,
                            rc.x, rc.y, rc.width, rc.height );
#endif
    }
示例#6
0
文件: gtktexthandle.c 项目: GYGit/gtk
static void
_gtk_text_handle_draw (GtkTextHandle         *handle,
                       cairo_t               *cr,
                       GtkTextHandlePosition  pos)
{
  GtkTextHandlePrivate *priv;
  HandleWindow *handle_window;
  GtkStyleContext *context;
  gint width, height;

  priv = handle->priv;
  handle_window = &priv->windows[pos];

  context = gtk_widget_get_style_context (handle_window->widget);
  _gtk_text_handle_get_size (handle, &width, &height);

  cairo_save (cr);
  cairo_translate (cr, handle_window->border.left, handle_window->border.top);

  gtk_render_handle (context, cr, 0, 0, width, height);

  cairo_restore (cr);
}
示例#7
0
void wxAuiDefaultDockArt::DrawSash(wxDC& dc, wxWindow *window, int orientation, const wxRect& rect)
{
#if defined( __WXMAC__ ) && wxOSX_USE_COCOA_OR_CARBON
    wxUnusedVar(window);
    wxUnusedVar(orientation);

    HIRect splitterRect = CGRectMake( rect.x , rect.y , rect.width , rect.height );
    CGContextRef cgContext ;
    wxGCDCImpl *impl = (wxGCDCImpl*) dc.GetImpl();
    cgContext = (CGContextRef) impl->GetGraphicsContext()->GetNativeContext() ;

    HIThemeSplitterDrawInfo drawInfo ;
    drawInfo.version = 0 ;
    drawInfo.state = kThemeStateActive ;
    drawInfo.adornment = kHIThemeSplitterAdornmentNone ;
    HIThemeDrawPaneSplitter( &splitterRect , &drawInfo , cgContext , kHIThemeOrientationNormal ) ;

#elif defined(__WXGTK__)
    // clear out the rectangle first
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sashBrush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);

#if 0
    GdkRectangle gdk_rect;
    if (orientation == wxVERTICAL )
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = m_sashSize;
        gdk_rect.height = rect.height;
    }
    else
    {
        gdk_rect.x = rect.x;
        gdk_rect.y = rect.y;
        gdk_rect.width = rect.width;
        gdk_rect.height = m_sashSize;
    }
#endif

    if (!window) return;
    if (!window->m_wxwindow) return;
    if (!gtk_widget_is_drawable(window->m_wxwindow)) return;

#ifdef __WXGTK3__
    cairo_t* cr = static_cast<cairo_t*>(dc.GetGraphicsContext()->GetNativeContext());
    // invert orientation for widget (horizontal GtkPaned has a vertical splitter)
    wxOrientation orient = orientation == wxVERTICAL ? wxHORIZONTAL : wxVERTICAL;
    GtkWidget* widget = wxGTKPrivate::GetSplitterWidget(orient);
    GtkStyleContext* sc = gtk_widget_get_style_context(widget);
    gtk_style_context_save(sc);

    gtk_style_context_add_class(sc, GTK_STYLE_CLASS_PANE_SEPARATOR);
    gtk_render_handle(sc, cr, rect.x, rect.y, rect.width, rect.height);

    gtk_style_context_restore(sc);
#else
    gtk_paint_handle
    (
        gtk_widget_get_style(window->m_wxwindow),
        window->GTKGetDrawingWindow(),
        // flags & wxCONTROL_CURRENT ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL,
        GTK_STATE_NORMAL,
        GTK_SHADOW_NONE,
        NULL /* no clipping */,
        window->m_wxwindow,
        "paned",
        rect.x,
        rect.y,
        rect.width,
        rect.height,
        (orientation == wxVERTICAL) ? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL
    );
#endif // !__WXGTK3__

#else
    wxUnusedVar(window);
    wxUnusedVar(orientation);
    dc.SetPen(*wxTRANSPARENT_PEN);
    dc.SetBrush(m_sashBrush);
    dc.DrawRectangle(rect.x, rect.y, rect.width, rect.height);
#endif
}