/* Draw a rectangle on the screen, size depending on pressure,
   and color on the type of device */
static void
draw_brush (GtkWidget *widget, GdkInputSource source,
            gdouble x, gdouble y, gdouble pressure)
{
  GdkGC *gc;
  GdkRectangle update_rect;

  switch (source)
    {
    case GDK_SOURCE_MOUSE:
      gc = widget->style->dark_gc[gtk_widget_get_state (widget)];
      break;
    case GDK_SOURCE_PEN:
      gc = widget->style->black_gc;
      break;
    case GDK_SOURCE_ERASER:
      gc = widget->style->white_gc;
      break;
    default:
      gc = widget->style->light_gc[gtk_widget_get_state (widget)];
    }

  update_rect.x = x - 10 * pressure;
  update_rect.y = y - 10 * pressure;
  update_rect.width = 20 * pressure;
  update_rect.height = 20 * pressure;
  gdk_draw_rectangle (pixmap, gc, TRUE,
                      update_rect.x, update_rect.y,
                      update_rect.width, update_rect.height);
  gtk_widget_queue_draw_area (widget, 
                      update_rect.x, update_rect.y,
                      update_rect.width, update_rect.height);
}
Exemplo n.º 2
0
static void
maybe_check_submenu_state (GtkMenuItem    *menu_item,
                           ThemeMatchData *match_data)
{
  /* Distinguish between active and passive focus, depending on whether the
   * focus is in submenu.
   *
   * Active focus:
   *   function = BOX
   *   state    = PRELIGHT
   *
   * Passive focus:
   *   function = BOX
   *   state    = SELECTED
   */
  if (menu_item->submenu)
    {
      GtkWidget *sub_item;

      sub_item = GTK_MENU_SHELL (menu_item->submenu)->active_menu_item;
      if (sub_item && gtk_widget_get_state (sub_item) != GTK_STATE_NORMAL)
	match_data->state = GTK_STATE_SELECTED;
    }

  /* This is a hack to cover the cases where a menu item is being 
   * used outside the usual a GtkMenu. More specificaly, this covers
   * menu items inside the hildon-desktop custom menu widget. */
  if (!GTK_IS_MENU (GTK_WIDGET (menu_item)->parent) &&
      !gtk_widget_is_focus (GTK_WIDGET (menu_item)) &&
      gtk_widget_get_state (GTK_WIDGET (menu_item)) != GTK_STATE_NORMAL)
    match_data->state = GTK_STATE_SELECTED;
}
Exemplo n.º 3
0
static gboolean
mx_gtk_light_switch_expose (GtkWidget      *lightswitch,
                            GdkEventExpose *event)
{
  MxGtkLightSwitchPrivate *priv;
  GtkStyle *style;
  GtkStateType state_type;
  cairo_t *cr;

  cr = gdk_cairo_create (gtk_widget_get_window (lightswitch));

  cairo_rectangle (cr,
                   event->area.x,
                   event->area.y,
                   event->area.width,
                   event->area.height);

  cairo_clip (cr);

  priv = MX_GTK_LIGHT_SWITCH_GET_PRIVATE (lightswitch);
  style = gtk_widget_get_style (lightswitch);
  state_type = gtk_widget_get_state (lightswitch);

  /* draw the trough */
  gtk_paint_box (style,
                 gtk_widget_get_window (lightswitch),
                 (state_type != GTK_STATE_INSENSITIVE && priv->active)
                 ? GTK_STATE_SELECTED : state_type,
                 GTK_SHADOW_IN,
                 NULL,
                 NULL,
                 "light-switch-trough",
                 0,
                 0,
                 (priv->trough_width),
                 priv->switch_height);


  /* draw the switch itself */
  if (state_type != GTK_STATE_INSENSITIVE)
    {
      gtk_paint_box (style,
                     gtk_widget_get_window (lightswitch),
                     gtk_widget_get_state (lightswitch),
                     GTK_SHADOW_OUT,
                     NULL,
                     NULL,
                     "light-switch-handle",
                     priv->x + style->xthickness,
                     style->ythickness,
                     priv->switch_width - style->xthickness * 2,
                     priv->switch_height - style->ythickness * 2);
    }

  cairo_destroy (cr);

  return FALSE;
}
Exemplo n.º 4
0
static bool
childrenUseEvent(GtkWidget *widget, GdkEventButton *event, bool inNoteBook)
{
    // accept, by default
    bool usable = true;

    // get children and check
    GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
    for (GList *child = children;child && usable;child = g_list_next(child)) {
        // cast child to GtkWidget
        if (GTK_IS_WIDGET(child->data)) {
            GtkWidget *childWidget = GTK_WIDGET(child->data);
            GdkWindow *window = nullptr;

            // check widget state and type
            if (gtk_widget_get_state(childWidget) == GTK_STATE_PRELIGHT) {
                // if widget is prelight, we don't need to check where event
                // happen, any prelight widget indicate we can't do a move
                usable = false;
                continue;
            }

            window = gtk_widget_get_window(childWidget);
            if (!(window && gdk_window_is_visible(window)))
                continue;

            if (GTK_IS_NOTEBOOK(childWidget))
                inNoteBook = true;

            if(!(event && withinWidget(childWidget, event)))
                continue;

            // check special cases for which grab should not be enabled
            if((isBlackListed(G_OBJECT(childWidget))) ||
               (GTK_IS_NOTEBOOK(widget) && Tab::isLabel(GTK_NOTEBOOK(widget),
                                                         childWidget)) ||
               (GTK_IS_BUTTON(childWidget) &&
                gtk_widget_get_state(childWidget) != GTK_STATE_INSENSITIVE) ||
               (gtk_widget_get_events(childWidget) &
                (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK)) ||
               (GTK_IS_MENU_ITEM(childWidget)) ||
               (GTK_IS_SCROLLED_WINDOW(childWidget) &&
                (!inNoteBook || gtk_widget_is_focus(childWidget)))) {
                usable = false;
            }

            // if child is a container and event has been accepted so far,
            // also check it, recursively
            if (usable && GTK_IS_CONTAINER(childWidget)) {
                usable = childrenUseEvent(childWidget, event, inNoteBook);
            }
        }
    }
    if (children) {
        g_list_free(children);
    }
    return usable;
}
static void init_gc(void)	{
	
	count_new = 0;
	calculate_standard_signal();
	calculate_difficulty();
	calculate_sensitivity();

	count = 0;
	count_new = 0;
	count_standard_signal = border; /* border so that signal starts with low */
	initial_count=0;


	// drawing

	is_stop=FALSE;
	is_pause=FALSE;
	mute=FALSE;
	image_volume_on = GTK_WIDGET(gtk_image_new_from_file("/home/pi/gtk_drawing/lautsprecher_mit.png"));
	gtk_button_set_image(GTK_BUTTON(cmd_mute), image_volume_on);
	gtk_button_set_label(GTK_BUTTON(cmd_pause), "Pause");


	count = 0;
	count_new = 0;
	count_standard_signal = border; /* border so that signal starts with low */


	gtk_widget_get_allocation(draw_area, &draw_area_size);
	g_print("width: %d \n height: %d \n", draw_area_size.width, draw_area_size.height);
	
	pixmap = gdk_pixmap_new(draw_area->window, 2*draw_area_size.width, draw_area_size.height, -1);

	gdk_colormap_alloc_color(gtk_widget_get_colormap(draw_area), &red, FALSE, TRUE);
	gdk_colormap_alloc_color(gtk_widget_get_colormap(draw_area), &black, FALSE, TRUE);
	gdk_colormap_alloc_color(gtk_widget_get_colormap(draw_area), &green, FALSE, TRUE);
	
	gc = gdk_gc_new(pixmap);
	*gc = *(draw_area->style->fg_gc[gtk_widget_get_state(draw_area)]);
	gdk_gc_set_foreground(gc, &red);
	gdk_gc_set_line_attributes(gc, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);

	gcgr = gdk_gc_new(pixmap);
	*gcgr = *(draw_area->style->fg_gc[gtk_widget_get_state(draw_area)]);
	gdk_gc_set_foreground(gcgr, &green);
	gdk_gc_set_line_attributes(gcgr, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);

	gcbl = gdk_gc_new(pixmap); // black graphic context
	*gcbl = *(draw_area->style->fg_gc[gtk_widget_get_state(draw_area)]);
	gdk_gc_set_foreground(gcbl, &black);
	gdk_gc_set_line_attributes(gcbl, 2, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);

}
Exemplo n.º 6
0
static gboolean panel_icon_grid_expose(GtkWidget *widget, GdkEventExpose *event)
#endif
{
    if (gtk_widget_is_drawable(widget))
    {
        if (gtk_widget_get_has_window(widget) &&
            !gtk_widget_get_app_paintable(widget))
#if GTK_CHECK_VERSION(3, 0, 0)
            gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0,
                                  gtk_widget_get_allocated_width(widget),
                                  gtk_widget_get_allocated_height(widget));
#else
            gtk_paint_flat_box(gtk_widget_get_style(widget),
                               gtk_widget_get_window(widget),
                               gtk_widget_get_state(widget), GTK_SHADOW_NONE,
                               &event->area, widget, "panelicongrid",
                               0, 0, -1, -1);
#endif

#if GTK_CHECK_VERSION(3, 0, 0)
        GTK_WIDGET_CLASS(panel_icon_grid_parent_class)->draw(widget, cr);
#else
        GTK_WIDGET_CLASS(panel_icon_grid_parent_class)->expose_event(widget, event);
#endif
    }
    return FALSE;
}
Exemplo n.º 7
0
/* Redraw the screen from the backing pixmap */
static gboolean expose_event (GtkWidget      *widget,
                              GdkEventExpose *event)
{
	static GdkImage *image = NULL;
	GdkCursor *cursor;
	GdkPixbuf *pixbuf;

	if (framebuffer_allocated == FALSE) {

		rfbClientSetClientData (cl, gtk_init, widget);

		image = gdk_drawable_get_image (widget->window, 0, 0,
		                                widget->allocation.width,
		                                widget->allocation.height);

		cl->frameBuffer= image->mem;

		cl->width  = widget->allocation.width;
		cl->height = widget->allocation.height;

		cl->format.bitsPerPixel = image->bits_per_pixel;
		cl->format.redShift     = image->visual->red_shift;
		cl->format.greenShift   = image->visual->green_shift;
		cl->format.blueShift    = image->visual->blue_shift;

		cl->format.redMax   = (1 << image->visual->red_prec) - 1;
		cl->format.greenMax = (1 << image->visual->green_prec) - 1;
		cl->format.blueMax  = (1 << image->visual->blue_prec) - 1;

#ifdef LIBVNCSERVER_CONFIG_LIBVA
		/* Allow libvncclient to use a more efficient way
		 * of putting the framebuffer on the screen when
		 * using the H.264 format.
		 */
		cl->outputWindow = GDK_WINDOW_XID(widget->window);
#endif

		SetFormatAndEncodings (cl);

		framebuffer_allocated = TRUE;

		/* Also disable local cursor */
                pixbuf = gdk_pixbuf_new_from_xpm_data(dot_cursor_xpm);
	        cursor = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, dot_cursor_x_hot, dot_cursor_y_hot);
		g_object_unref(pixbuf);	
		gdk_window_set_cursor (gtk_widget_get_window(GTK_WIDGET(window)), cursor);
		gdk_cursor_unref(cursor);
	}

#ifndef LIBVNCSERVER_CONFIG_LIBVA
	gdk_draw_image (GDK_DRAWABLE (widget->window),
	                widget->style->fg_gc[gtk_widget_get_state(widget)],
	                image,
	                event->area.x, event->area.y,
	                event->area.x, event->area.y,
	                event->area.width, event->area.height);
#endif

	return FALSE;
}
Exemplo n.º 8
0
static gboolean window_menu_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
#endif
{
	WindowMenu* window_menu = data;

	if (gtk_widget_has_focus(window_menu->applet))
		gtk_paint_focus(gtk_widget_get_style(widget),
#if GTK_CHECK_VERSION (3, 0, 0)
						cr,
#else
						gtk_widget_get_window(widget),
#endif
						gtk_widget_get_state(widget),
#if !GTK_CHECK_VERSION (3, 0, 0)
						NULL,
#endif
						widget,
						"menu-applet",
						0, 0,
#if GTK_CHECK_VERSION (3, 0, 0)
						gtk_widget_get_allocated_width (widget),
						gtk_widget_get_allocated_height (widget));
#else
						-1, -1);
#endif

	return FALSE;
}
static gboolean
gb_progress_bar_draw (GtkWidget *widget,
                      cairo_t   *cr)
{
   GbProgressBarPrivate *priv;
   GtkStyleContext *context;
   GbProgressBar *bar = (GbProgressBar *)widget;
   GtkAllocation allocation;
   GtkStateType state;
   GdkRGBA color = { 0 };

   g_return_val_if_fail(GB_IS_PROGRESS_BAR(bar), FALSE);

   priv = bar->priv;

   if (gtk_widget_is_drawable(widget)) {
      gtk_widget_get_allocation(widget, &allocation);

      state = gtk_widget_get_state(widget);
      context = gtk_widget_get_style_context(widget);
      gtk_style_context_get_color(context, state, &color);

      cairo_save(cr);
      cairo_rectangle(cr,
                      0,
                      0,
                      priv->fraction * allocation.width,
                      allocation.height);
      gdk_cairo_set_source_rgba(cr, &color);
      cairo_fill(cr);
      cairo_restore(cr);
   }

   return FALSE;
}
Exemplo n.º 10
0
/***********************************************
 * hc_gtk2_engine_hack_menu_shell_leave -
 *
 *   Leave signal to ensure menushell items
 *   normal state on mouse leave.
 ***********************************************/
static gboolean
hc_gtk2_engine_hack_menu_shell_leave(GtkWidget *widget,
                                     GdkEventCrossing *event,
                                     gpointer user_data)
{
    if (GE_IS_MENU_SHELL(widget))
    {
        GList *children = NULL, *child = NULL;

        if (GE_IS_CONTAINER(widget))
        {
            children = gtk_container_get_children(GTK_CONTAINER(widget));

            for (child = g_list_first(children); child; child = g_list_next(child))
            {
                if ((child->data) && GE_IS_MENU_ITEM(child->data) &&
                        (gtk_widget_get_state (GTK_WIDGET(child->data)) != GTK_STATE_INSENSITIVE))
                {
                    GtkWidget* submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(child->data));
                    if ((!GE_IS_MENU(submenu)) ||
                            (!(gtk_widget_get_realized(submenu) &&
                               gtk_widget_get_visible (submenu))))
                    {
                        gtk_widget_set_state (GTK_WIDGET(child->data), GTK_STATE_NORMAL);
                    }
                }
            }

            if (children)
                g_list_free(children);
        }
    }

    return FALSE;
}
static gboolean
render_contribution_topdown(GtkExperimentTranscript *trans,
			    ExperimentReaderContrib *contrib,
			    gint64 current_time, gint64 current_time_px,
			    gint *last_contrib_y)
{
	GtkWidget *widget = GTK_WIDGET(trans);

	gint old_last_contrib_y = *last_contrib_y;
	int logical_height;

	*last_contrib_y = current_time_px - TIME_TO_PX(contrib->start_time);

	if (!configure_text_layout(trans, contrib, current_time,
				   *last_contrib_y, old_last_contrib_y,
				   &logical_height))
		return TRUE;

	if (*last_contrib_y - logical_height > widget->allocation.height)
		return FALSE;

	gdk_draw_layout(GDK_DRAWABLE(trans->priv->layer_text),
			widget->style->text_gc[gtk_widget_get_state(widget)],
			0, *last_contrib_y - logical_height,
			trans->priv->layer_text_layout);

	return *last_contrib_y < widget->allocation.height;
}
Exemplo n.º 12
0
void wxStatusBarGeneric::OnPaint(wxPaintEvent& WXUNUSED(event) )
{
    wxPaintDC dc(this);

#ifdef __WXGTK20__
    // Draw grip first
    if ( ShowsSizeGrip() )
    {
        const wxRect& rc = GetSizeGripRect();
        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 // __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);
}
Exemplo n.º 13
0
static gboolean
qtcMenuShellLeave(GtkWidget *widget, GdkEventCrossing *event, void *data)
{
    QTC_UNUSED(data);
    QTC_UNUSED(event);
    if (GTK_IS_MENU_SHELL(widget) && GTK_IS_CONTAINER(widget)) {
        GList *children = gtk_container_get_children(GTK_CONTAINER(widget));
        for (GList *child = children;child;child = g_list_next(child)) {
            if ((child->data) && GTK_IS_MENU_ITEM(child->data) &&
                (gtk_widget_get_state(GTK_WIDGET(child->data)) !=
                 GTK_STATE_INSENSITIVE)) {
                GtkWidget *submenu =
                    gtk_menu_item_get_submenu(GTK_MENU_ITEM(child->data));
                GtkWidget *topLevel =
                    submenu ? gtk_widget_get_toplevel(submenu) : NULL;

                if (submenu &&
                    ((!GTK_IS_MENU(submenu)) ||
                     (!(gtk_widget_get_realized(submenu) &&
                        gtk_widget_get_visible(submenu) &&
                        gtk_widget_get_realized(topLevel) &&
                        gtk_widget_get_visible(topLevel))))) {
                    gtk_widget_set_state(GTK_WIDGET(child->data),
                                         GTK_STATE_NORMAL);
                }
            }
        }
        if (children) {
            g_list_free(children);
        }
    }
    return false;
}
Exemplo n.º 14
0
static gboolean panel_menu_bar_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
#endif
{
	PanelMenuBar* menubar = data;

	if (gtk_widget_has_focus(GTK_WIDGET(menubar)))
	{
		gtk_paint_focus(gtk_widget_get_style(widget),
#if GTK_CHECK_VERSION (3, 0, 0)
						cr,
#else
						gtk_widget_get_window(widget),
#endif
						gtk_widget_get_state(GTK_WIDGET(menubar)),
#if !GTK_CHECK_VERSION (3, 0, 0)
						NULL,
#endif
						widget,
						"menubar-applet",
						0,
						0,
#if GTK_CHECK_VERSION (3, 0, 0)
						gtk_widget_get_allocated_width (widget),
						gtk_widget_get_allocated_height (widget));
#else
						-1,
						-1);
#endif
	}

	return FALSE;
}
static inline void
render_backdrop_area(GtkExperimentTranscript *trans, gint64 current_time_px)
{
	GtkWidget *widget = GTK_WIDGET(trans);

	gint y_start, y_end;
	GdkColor color;
	GdkColor *bg = &widget->style->bg[gtk_widget_get_state(widget)];

	if (!gtk_experiment_transcript_get_use_backdrop_area(trans))
		return;

	if (gtk_experiment_transcript_get_reverse_mode(trans)) {
		y_end = current_time_px - TIME_TO_PX(trans->priv->backdrop.start);
		y_start = current_time_px - TIME_TO_PX(trans->priv->backdrop.end);
	} else {
		y_start = widget->allocation.height -
			  (current_time_px - TIME_TO_PX(trans->priv->backdrop.start));
		y_end = widget->allocation.height -
			(current_time_px - TIME_TO_PX(trans->priv->backdrop.end));
	}

	if ((y_start < 0 && y_end < 0) ||
	    (y_start > widget->allocation.height &&
	     y_end > widget->allocation.height))
		return;

	y_start = CLAMP(y_start, 0, widget->allocation.height);
	y_end = CLAMP(y_end, 0, widget->allocation.height);

	color.pixel = 0;
	color.red = MAX((gint)bg->red - BACKDROP_VALUE, 0);
	color.blue = MAX((gint)bg->blue - BACKDROP_VALUE, 0);
	color.green = MAX((gint)bg->green - BACKDROP_VALUE, 0);
	if (!color.red && !color.blue && !color.green) {
		color.red = MIN((gint)bg->red + BACKDROP_VALUE, G_MAXUINT16);
		color.blue = MIN((gint)bg->blue + BACKDROP_VALUE, G_MAXUINT16);
		color.green = MIN((gint)bg->green + BACKDROP_VALUE, G_MAXUINT16);
	}
	gtk_widget_modify_fg(widget, gtk_widget_get_state(widget), &color);

	gdk_draw_rectangle(GDK_DRAWABLE(trans->priv->layer_text),
			   widget->style->fg_gc[gtk_widget_get_state(widget)],
			   TRUE,
			   0, y_start,
			   widget->allocation.width, y_end - y_start);
}
Exemplo n.º 16
0
static void
on_preview_expose_event (GtkWidget      *drawing_area,
			 GdkEventExpose *event,
			 gpointer        data)
{
  ScreenshotDialog *dialog = data;
  GdkPixbuf *pixbuf = NULL;
  gboolean free_pixbuf = FALSE;
  cairo_t *cr;

  /* Stolen from GtkImage.  I really should just make the drawing area an
   * image some day */
  if (gtk_widget_get_state (drawing_area) != GTK_STATE_NORMAL)
    {
      GtkIconSource *source;

      source = gtk_icon_source_new ();
      gtk_icon_source_set_pixbuf (source, dialog->preview_image);
      gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
      gtk_icon_source_set_size_wildcarded (source, FALSE);
                  
      pixbuf = gtk_style_render_icon (drawing_area->style,
				      source,
				      gtk_widget_get_direction (drawing_area),
				      gtk_widget_get_state (drawing_area),
				      (GtkIconSize) -1,
				      drawing_area,
				      "gtk-image");
      free_pixbuf = TRUE;
      gtk_icon_source_free (source);
    }
  else
    {
      pixbuf = g_object_ref (dialog->preview_image);
    }
  
  cr = gdk_cairo_create (drawing_area->window);
  gdk_cairo_region (cr, event->region);
  cairo_clip (cr);

  gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
  cairo_paint (cr);

  cairo_destroy (cr);

  g_object_unref (pixbuf);
}
Exemplo n.º 17
0
static gboolean
panel_toggle_button_draw (GtkWidget *widget, cairo_t *cr)
{
  GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
  GtkStateType state_type;
  GtkShadowType shadow_type;
  GtkAllocation allocation;
  GtkStyleContext *context = gtk_widget_get_style_context (widget);
  GtkStateFlags flags = 0;

  state_type = gtk_widget_get_state (widget);
    
  /* FIXME: someone make this layout work nicely for all themes
   * Currently I'm trying to imitate the volume applet's widget */
  if (gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (widget))) {
    if (state_type == GTK_STATE_ACTIVE)
      state_type = GTK_STATE_NORMAL;
    shadow_type = GTK_SHADOW_ETCHED_IN;
  } else {
    shadow_type = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
  }
  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
    state_type = GTK_STATE_SELECTED;
  /* FIXME: better detail? */
  gtk_widget_get_allocation (widget, &allocation);
  gtk_style_context_add_class (context, "togglebutton");
  switch (state_type)
    {
    case GTK_STATE_PRELIGHT:
      flags |= GTK_STATE_FLAG_PRELIGHT;
      break;
    case GTK_STATE_SELECTED:
      flags |= GTK_STATE_FLAG_SELECTED;
      break;
    case GTK_STATE_INSENSITIVE:
      flags |= GTK_STATE_FLAG_INSENSITIVE;
      break;
    case GTK_STATE_ACTIVE:
      flags |= GTK_STATE_FLAG_ACTIVE;
      break;
    case GTK_STATE_FOCUSED:
      flags |= GTK_STATE_FLAG_FOCUSED;
      break;
    case GTK_STATE_NORMAL:
    case GTK_STATE_INCONSISTENT:
    default:
      break;
  }

  gtk_style_context_set_state (context, flags);
  gtk_render_background (context, cr, (gdouble) allocation.x, (gdouble) allocation.y,
                                 (gdouble) allocation.width, (gdouble) allocation.height);
  (void) shadow_type;

  if (child)
    gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
  
  return FALSE;
}
Exemplo n.º 18
0
static void
cb_state_change (GtkWidget *widget, G_GNUC_UNUSED GtkStateType old_state, GOComboBox *combo_box)
{
	GtkStateType const new_state = gtk_widget_get_state (widget);
	if (combo_box->priv->display_widget)
		gtk_widget_set_state (combo_box->priv->display_widget,
				      new_state);
}
Exemplo n.º 19
0
GtkStateType nsgtk_widget_get_state(GtkWidget *widget)
{
  #if GTK_CHECK_VERSION(2,18,0)
	return gtk_widget_get_state(widget);
  #else
	return GTK_WIDGET_STATE(widget);
  #endif
}
Exemplo n.º 20
0
static void draw(Scope *scope)
{
	guint segcnt, i;
	GdkPoint pt[SCOPE_WIDTH+1];
	GdkSegment seg[100], *segp;
	GtkWidget *widget;
	GtkAllocation allocation;
	GtkStyle *style;

	widget = GTK_WIDGET(scope);
	g_return_if_fail(gtk_widget_is_drawable(widget));
	g_return_if_fail(scope->pixmap);
	gtk_widget_get_allocation(widget, &allocation);
	style = gtk_widget_get_style(widget);
	/* calculate grid segments */
	for (segp = seg, segcnt = i = 0; i < SCOPE_WIDTH; i += SCOPE_WIDTH/8) {
		segp->x1 = segp->x2 = i;
		segp->y1 = SCOPE_HEIGHT/2-5;
		segp->y2 = SCOPE_HEIGHT/2+5;
		segp++;
		segcnt++;
	}
        segp->y1 = segp->y2 = SCOPE_HEIGHT/2;
        segp->x1 = 0;
        segp->x2 = SCOPE_WIDTH-1;
        segp++;
        segcnt++;
	/* copy data points */
	for (i = 0; i < SCOPE_WIDTH; i++) {
		pt[i].x = i;
		pt[i].y = ((32767-(int)scope->y[i])*SCOPE_HEIGHT) >> 16;
	}
	/* clear window */
	gdk_draw_rectangle(scope->pixmap, style->base_gc[gtk_widget_get_state(widget)],
			   TRUE, 0, 0, 
			   allocation.width, 
			   allocation.height);
	/* draw grid */
	gdk_draw_segments(scope->pixmap, scope->grid_gc, seg, segcnt);
	/* draw trace */
	gdk_draw_lines(scope->pixmap, scope->trace_gc, pt, SCOPE_WIDTH);
	/* draw to screen */
	gdk_draw_drawable(gtk_widget_get_window(widget), style->base_gc[gtk_widget_get_state(widget)], scope->pixmap, 
			  0, 0, 0, 0, allocation.width, allocation.height);
}
Exemplo n.º 21
0
/* Draws a rounded rectangle with text inside. */
static gboolean
numbers_draw_cb (GtkWidget *widget, cairo_t *ctx, gpointer data)
{
	double x, y, w, h;
	PangoLayout * layout;
	gint font_size = gtk_widget_get_font_size (widget);

	#if (INDICATOR_MESSAGES_HAS_LOZENGE == 1)
	gboolean is_lozenge = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "is-lozenge"));
	/* let the label handle the drawing if it's not a lozenge */
	if (!is_lozenge)
		return FALSE;
	#endif

	if (!GTK_IS_WIDGET (widget)) return FALSE;

	/* get style + arrow position / dimensions */
	double red, green, blue;
	GtkStyleContext *style = gtk_widget_get_style_context (widget);
	GdkRGBA color;
	gtk_style_context_get_color (style, gtk_widget_get_state(widget), &color);
	red = color.red;
	green = color.green;
	blue = color.blue;
	GtkAllocation allocation;
	gtk_widget_get_allocation (widget, &allocation);
	w = allocation.width;
	h = allocation.height;
	x = y = 0;

	layout = gtk_label_get_layout (GTK_LABEL(widget));
	PangoRectangle layout_extents;
	pango_layout_get_extents (layout, NULL, &layout_extents);
	pango_extents_to_pixels (&layout_extents, NULL);

	if (layout_extents.width == 0)
		return TRUE;

	cairo_set_line_width (ctx, 1.0);

	cairo_set_fill_rule (ctx, CAIRO_FILL_RULE_EVEN_ODD);

	/* cairo drawing code */
	custom_cairo_rounded_rectangle (ctx, x - font_size/2.0, y, w + font_size, h);

	cairo_set_source_rgba (ctx, red,
	                           green,
	                           blue, 0.5);

	x += (allocation.width - layout_extents.width) / 2.0;
	y += (allocation.height - layout_extents.height) / 2.0;
	cairo_move_to (ctx, floor (x), floor (y));
	pango_cairo_layout_path (ctx, layout);
	cairo_fill (ctx);

	return TRUE;
}
Exemplo n.º 22
0
gint expose_event( GtkWidget *widget, GdkEventExpose *event, gpointer data )
{
  gdk_draw_drawable( widget->window,
		  widget->style->fg_gc[gtk_widget_get_state( widget )],
		  pixmap,
		  0, 0, 0, 0,
		  width, height );
  return TRUE;
}
Exemplo n.º 23
0
static void
type_toggled_cb(GtkWidget *widget, gpointer data)
{
   if (gtk_widget_get_state (widget) & GTK_STATE_SELECTED)
     {
       grid_type = GPOINTER_TO_INT (data);
       preview_redraw();
     }
}
Exemplo n.º 24
0
static gboolean window_menu_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
{
	WindowMenu* window_menu = data;

	if (gtk_widget_has_focus(window_menu->applet))
		gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(widget), NULL, widget, "menu-applet", 0, 0, -1, -1);

	return FALSE;
}
Exemplo n.º 25
0
gboolean draw_mypb(GtkWidget *widget, GdkEventExpose *event, gpointer data)
{
	int off;
	GtkAllocation alloc;
	pqi const inst = (pqi)data;
	gtk_widget_get_allocation(inst->box, &alloc); /* Get the dimensions of our widget */
	off = inst->clicked ? (int)(alloc.width / 16.0) : 0; /* Use it as our draw offset */
	gdk_draw_pixbuf(widget->window,widget->style->fg_gc[gtk_widget_get_state(widget)],inst->glowing?inst->pmainicon_glow:inst->pmainicon,0,0,off-1,off-1,-1,-1,GDK_RGB_DITHER_NONE,0,0);
	return TRUE;
}
Exemplo n.º 26
0
static void gdkDrawFocusRect(Ihandle* ih, int x, int y, int w, int h)
{
  GdkWindow* window = iupgtkGetWindow(ih->handle);
  GtkStyle *style = gtk_widget_get_style(ih->handle);
#if GTK_CHECK_VERSION(2, 18, 0)
  GtkStateType state = gtk_widget_get_state(ih->handle);
#else
  GtkStateType state = GTK_WIDGET_STATE(ih->handle);
#endif
  gtk_paint_focus(style, window, state, NULL, ih->handle, NULL, x, y, w, h);
}
Exemplo n.º 27
0
Arquivo: gailbutton.c Projeto: BYC/gtk
/*
 * This is the signal handler for the "pressed" or "enter" signal handler
 * on the GtkButton.
 *
 * If the state is now GTK_STATE_ACTIVE we notify a property change
 */
static void
gail_button_pressed_enter_handler (GtkWidget       *widget)
{
  AtkObject *accessible;

  if (gtk_widget_get_state (widget) == GTK_STATE_ACTIVE)
    {
      accessible = gtk_widget_get_accessible (widget);
      atk_object_notify_state_change (accessible, ATK_STATE_ARMED, TRUE);
      GAIL_BUTTON (accessible)->state = GTK_STATE_ACTIVE;
    }
}
/* Redraw the screen from the backing pixmap */
static gboolean
expose_event (GtkWidget *widget, GdkEventExpose *event)
{
  gdk_draw_drawable (widget->window,
                     widget->style->fg_gc[gtk_widget_get_state (widget)],
                     pixmap,
                     event->area.x, event->area.y,
                     event->area.x, event->area.y,
                     event->area.width, event->area.height);

  return FALSE;
}
Exemplo n.º 29
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);
}
Exemplo n.º 30
0
GtkStateFlags nsgtk_widget_get_state_flags(GtkWidget *widget)
{
#if GTK_CHECK_VERSION(3,0,0)
	return gtk_widget_get_state_flags(widget);
#else
#if GTK_CHECK_VERSION(2,18,0)
	return gtk_widget_get_state(widget);
#else
	return 0; /* FIXME */
#endif
#endif
}