Esempio n. 1
0
static void
ig_reload_style (GnmItemGrid *ig)
{
	GocItem *item = GOC_ITEM (ig);
	GtkStyleContext *context = goc_item_get_style_context (item);
	GtkBorder border;
	GtkStateFlags state = GTK_STATE_FLAG_NORMAL;
	GnmPane *pane = GNM_PANE (item->canvas);

	gtk_style_context_save (context);
	gtk_style_context_add_region (context, "function-marker", 0);
	gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
				     &ig->function_marker_color);
	gtk_style_context_get_border_color (context, state,
					    &ig->function_marker_border_color);
	gtk_style_context_restore (context);

	gtk_style_context_save (context);
	gtk_style_context_add_region (context, "pane-divider", 0);
	gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
				     &ig->pane_divider_color);
	gtk_style_context_get_border (context, GTK_STATE_FLAG_NORMAL, &border);
	ig->pane_divider_width = border.top;  /* Hack? */
	gtk_style_context_restore (context);

	/* ---------------------------------------- */

	context = gtk_widget_get_style_context (GTK_WIDGET (pane));
	gtk_widget_style_get (GTK_WIDGET (pane),
			      "function-indicator-size",
			      &ig->function_marker_size,
			      NULL);
}
Esempio n. 2
0
static gboolean
cb_treeview_draw (GtkWidget *widget,
		  cairo_t *cr,
		  StfDialogData *pagedata)
{
	int ruler_x = pagedata->fixed.ruler_x;
	int height;
	GtkAllocation a;
	GdkWindow *bin_window;
	GdkRGBA ruler_color;
	GtkStyleContext *context;

	if (ruler_x < 0)
		return FALSE;

	bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
	if (!gtk_cairo_should_draw_window (cr, bin_window))
		return FALSE;

	gtk_widget_get_allocation (widget, &a);
	height = a.height;

	context = gtk_widget_get_style_context (GTK_WIDGET (pagedata->dialog));
	gtk_style_context_save (context);
	gtk_style_context_add_region (context, "fixed-format-ruler", 0);
	gnm_style_context_get_color (context, GTK_STATE_FLAG_NORMAL,
				     &ruler_color);
	gtk_style_context_restore (context);

	cairo_save (cr);
	cairo_rectangle (cr, ruler_x, 0, ruler_x + 1, height);
	cairo_clip (cr);
	gdk_cairo_set_source_rgba (cr, &ruler_color);
	cairo_move_to (cr, ruler_x, 0);
	cairo_line_to (cr, ruler_x, height);
	cairo_stroke (cr);
	cairo_restore (cr);

	return FALSE;
}
Esempio n. 3
0
static gboolean
draw_cb_extension (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, "notebook");
  gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, 0);

  gtk_style_context_set_state (context, 0);
  gtk_render_extension (context, cr, 26, 12, 24, 12, GTK_POS_BOTTOM);
  gtk_render_extension (context, cr, 12, 26, 12, 24, GTK_POS_RIGHT);
  gtk_render_extension (context, cr, 26, 52, 24, 12, GTK_POS_TOP);
  gtk_render_extension (context, cr, 52, 26, 12, 24, GTK_POS_LEFT);

  gtk_style_context_restore (context);

  return TRUE;
}
static void
anjuta_tabber_setup_style_context (AnjutaTabber* tabber, GtkStyleContext* context,
                                   GList* child, GtkStateFlags* state_flags,
                                   GtkRegionFlags* region_flags)
{
	gint page_num;
	gboolean current;
	GtkRegionFlags region;
	GtkStateFlags state;

	page_num = g_list_position (tabber->priv->children, child);
	current = page_num == tabber->priv->active_page;

	region = anjuta_tabber_get_region_flags (tabber, page_num);

	gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, region);

	if (gtk_widget_get_direction (GTK_WIDGET (tabber)) == GTK_TEXT_DIR_LTR)
		gtk_style_context_set_junction_sides (context,
		                                      GTK_JUNCTION_CORNER_TOPLEFT);
	else
		gtk_style_context_set_junction_sides (context,
		                                      GTK_JUNCTION_CORNER_TOPRIGHT);

	state = gtk_style_context_get_state (context);
	if (current)
		state |= GTK_STATE_FLAG_ACTIVE;
	else
		state &= ~GTK_STATE_FLAG_ACTIVE;
	gtk_style_context_set_state (context, state);

	if (state_flags)
		*state_flags = state;
	if (region_flags)
		*region_flags = region;
}
Esempio n. 5
0
JNIEXPORT void JNICALL
Java_org_gnome_gtk_GtkStyleContext_gtk_1style_1context_1add_1region
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jstring _regionName,
	jint _flags
)
{
	GtkStyleContext* self;
	const gchar* regionName;
	GtkRegionFlags flags;

	// convert parameter self
	self = (GtkStyleContext*) _self;

	// convert parameter regionName
	regionName = (const gchar*) bindings_java_getString(env, _regionName);
	if (regionName == NULL) {
		return; // Java Exception already thrown
	}

	// convert parameter flags
	flags = (GtkRegionFlags) _flags;

	// call function
	gtk_style_context_add_region(self, regionName, flags);

	// cleanup parameter self

	// cleanup parameter regionName
	bindings_java_releaseString(regionName);

	// cleanup parameter flags
}
Esempio n. 6
0
static void
anjuta_tabber_render_tab (GtkWidget* widget,
                          GtkWidget* tab,
                          cairo_t* cr,
                          gboolean current,
                          GtkRegionFlags region_flags)
{
	AnjutaTabber* tabber = ANJUTA_TABBER (widget);
	GtkAllocation alloc;
	GtkAllocation widget_alloc;

	gint focus_width;
	gint tab_curvature;
	gint tab_overlap;
	gint tab_begin;
	gint tab_end;

	gint xpadding;
	gint ypadding;
	GtkStyleContext* context = gtk_widget_get_style_context (widget);

	if (current)
		gtk_widget_set_state_flags (tab, GTK_STATE_FLAG_ACTIVE, TRUE);
	else
		gtk_widget_unset_state_flags (tab, GTK_STATE_FLAG_ACTIVE);		
	
	gtk_widget_style_get (widget,
	                      "focus-line-width", &focus_width,
	                      "tab-curvature", &tab_curvature,
	                      "tab-overlap", &tab_overlap,
	                      NULL);

	 /* Get border/padding for tab */
	gtk_style_context_save (context);
	gtk_style_context_add_class (context, GTK_STYLE_CLASS_NOTEBOOK);
	gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB,
	                              region_flags);
	if (current)
		gtk_style_context_set_state (context, GTK_STATE_FLAG_ACTIVE);
	if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
		gtk_style_context_set_junction_sides (context,
			                                  GTK_JUNCTION_CORNER_TOPLEFT);
	else
		gtk_style_context_set_junction_sides (context,
			                                  GTK_JUNCTION_CORNER_TOPRIGHT);		
	
	gtk_widget_get_allocation (widget, &widget_alloc);
	gtk_widget_get_allocation (tab, &alloc);

	xpadding = focus_width + tabber->priv->tab_hborder;
	ypadding = focus_width + tabber->priv->tab_vborder;

	tab_begin = tab_curvature - tab_overlap;
	tab_end = tab_curvature - tab_overlap;

	if (region_flags | GTK_REGION_FIRST)
		tab_begin += tab_overlap;
	if (region_flags | GTK_REGION_LAST)
		tab_end += tab_overlap;
	
	alloc.x -= widget_alloc.x;
	alloc.x -= tab_begin;
	alloc.x -= xpadding;
	alloc.y -= widget_alloc.y;
	alloc.y -= ypadding;
	alloc.width += 2 * (xpadding) + tab_begin + tab_end;
	alloc.height += 2 * ypadding;
	
	gtk_render_extension (context,
	                      cr,
	                      alloc.x, 
	                      alloc.y,
	                      alloc.width, 
	                      alloc.height,
	                      GTK_POS_BOTTOM);

	if (gtk_widget_has_focus (widget) &&
	    current)
	{
		GtkAllocation allocation;
		
		gtk_widget_get_allocation (tab, &allocation);

		gtk_render_focus (context, cr,
		                  allocation.x - focus_width,
		                  allocation.y - focus_width,
		                  allocation.width + 2 * focus_width,
		                  allocation.height + 2 * focus_width);
	}
	
	gtk_style_context_restore (context);
}