コード例 #1
0
ファイル: minifram.cpp プロジェクト: czxxjtu/wxPython-1
static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h )
{
    int org_x = 0;
    int org_y = 0;
    gdk_window_get_origin( widget->window, &org_x, &org_y );
    x += org_x;
    y += org_y;

    GdkGC *gc = gdk_gc_new( GDK_ROOT_PARENT() );
    gdk_gc_set_subwindow( gc, GDK_INCLUDE_INFERIORS );
    gdk_gc_set_function( gc, GDK_INVERT );

    gdk_draw_rectangle( GDK_ROOT_PARENT(), gc, FALSE, x, y, w, h );
    gdk_gc_unref( gc );
}
コード例 #2
0
ファイル: lnxgtktheme.cpp プロジェクト: elphinkuo/livecode
static void fill_gdk_drawable(GdkDrawable *p_drawable, GdkColormap *p_colormap, int p_red, int p_green, int p_blue, int p_width, int p_height)
{
	GdkGC *t_gc;
	t_gc = gdk_gc_new(p_drawable);
	gdk_gc_set_colormap(t_gc, p_colormap);
	
	GdkColor t_color;
	t_color . red = p_red;
	t_color . green = p_green;
	t_color . blue = p_blue;
	
	gdk_gc_set_rgb_fg_color(t_gc, &t_color);
	gdk_draw_rectangle(p_drawable, t_gc, TRUE, 0, 0, p_width, p_height);
	g_object_unref(t_gc);
}
コード例 #3
0
ファイル: dialog.c プロジェクト: bbidulock/wmblob
static gboolean callback_expose(GtkWidget *widget, GdkEventExpose *event,
				gpointer data)
{
	GtkStyle *style;

	style = gtk_widget_get_style (widget);

	gdk_draw_rectangle(widget->window,
			style->bg_gc[GTK_STATE_NORMAL],
			TRUE,
			event->area.x, event->area.y,
			event->area.width, event->area.height);

	return(TRUE);
}
コード例 #4
0
// draw one black rectangle
	static void 
draw_brush (GtkWidget *widget, gint x, gint y)
{
	GdkRectangle update_rect;
	update_rect.x = x - SIZE_OF_CELL / 2;
	update_rect.y = y - SIZE_OF_CELL / 2;
	update_rect.width = SIZE_OF_CELL;
	update_rect.height = SIZE_OF_CELL;
	gdk_draw_rectangle 	(pixmap,
			widget->style->black_gc,
			TRUE,
			update_rect.x, update_rect.y,
			update_rect.width, update_rect.height);
	gdk_window_invalidate_rect(widget->window, &update_rect, FALSE);
}
コード例 #5
0
void GtkPaintContext::fillRectangle(int x0, int y0, int x1, int y1) {
	if (x1 < x0) {
		int tmp = x1;
		x1 = x0;
		x0 = tmp;
	}
	if (y1 < y0) {
		int tmp = y1;
		y1 = y0;
		y0 = tmp;
	}
	gdk_draw_rectangle(myPixmap, myFillGC, true,
										 x0 + leftMargin(), y0 + topMargin(),
										 x1 - x0 + 1, y1 - y0 + 1);
}
コード例 #6
0
ファイル: gimpcanvas.c プロジェクト: Amerekanets/gimp
/**
 * gimp_canvas_draw_rectangle:
 * @canvas: a #GimpCanvas widget
 * @style:  one of the enumerated #GimpCanvasStyle's.
 * @filled: %TRUE if the rectangle is to be filled.
 * @x:      X coordinate of the upper left corner.
 * @y:      Y coordinate of the upper left corner.
 * @width:  width of the rectangle.
 * @height: height of the rectangle.
 *
 * Draws a rectangle in the specified style.
 **/
void
gimp_canvas_draw_rectangle (GimpCanvas      *canvas,
                            GimpCanvasStyle  style,
                            gboolean         filled,
                            gint             x,
                            gint             y,
                            gint             width,
                            gint             height)
{
  if (! gimp_canvas_ensure_style (canvas, style))
    return;

  gdk_draw_rectangle (GTK_WIDGET (canvas)->window, canvas->gc[style],
                      filled, x, y, width, height);
}
コード例 #7
0
ファイル: gnucash-grid.c プロジェクト: gijut/gnucash
void
gnucash_draw_hatching (GdkDrawable *drawable, GdkGC *gc,
                       int x, int y, int width, int height)
{
    gdk_gc_set_foreground (gc, &gn_light_gray);

    gdk_draw_rectangle (drawable, gc, FALSE,
                        x + 2, y + 2, height / 3, height / 3);

    gdk_draw_line (drawable, gc,
                   x + 2, y + 2 + height / 3, x + 2 + height / 3, y + 2);

    gdk_draw_line (drawable, gc,
                   x + 2, y + 2, x + 2 + height / 3, y + 2 + height / 3);
}
コード例 #8
0
ファイル: gpkplotting.c プロジェクト: AquaSoftGmbH/lame
/* Create a new backing pixmap of the appropriate size */
static  gint
configure_event(GtkWidget * widget, GdkEventConfigure * event, gpointer data)
{
    GdkPixmap **ppixmap;
    if ((ppixmap = findpixmap(widget))) {
        if (*ppixmap)
            gdk_pixmap_unref(*ppixmap);
        *ppixmap = gdk_pixmap_new(widget->window,
                                  widget->allocation.width, widget->allocation.height, -1);
        gdk_draw_rectangle(*ppixmap,
                           widget->style->white_gc,
                           TRUE, 0, 0, widget->allocation.width, widget->allocation.height);
    }
    return TRUE;
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_fillRect
  (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
{
  struct graphics *g;

  g = (struct graphics *) NSA_GET_PTR (env, obj);

  gdk_threads_enter ();

  gdk_draw_rectangle (g->drawable, g->gc, TRUE, 
		      x + g->x_offset, y + g->y_offset, width, height);
  gdk_flush ();
  gdk_threads_leave ();
}
コード例 #10
0
static void
gtk_plot_gdk_draw_rectangle                          (GtkPlotPC *pc,
                                                     gint filled,
                                                     gdouble x, gdouble y,
                                                     gdouble width, gdouble height)
{
  if(!GTK_PLOT_GDK(pc)->gc) return;
  if(!GTK_PLOT_GDK(pc)->drawable) return;

  gdk_draw_rectangle (GTK_PLOT_GDK(pc)->drawable, GTK_PLOT_GDK(pc)->gc,
                      filled,
                      roundint(x), roundint(y),
                      roundint(width), roundint(height));

}
コード例 #11
0
ファイル: pager.c プロジェクト: g7/fbpanel
/*****************************************************************
 * Desk Functions                                                *
 *****************************************************************/
static void
desk_clear_pixmap(desk *d)
{
    GtkWidget *widget;

    ENTER;
    DBG("d->no=%d\n", d->no);
    if (!d->pix)
        RET();
    widget = GTK_WIDGET(d->da);
    if (d->pg->wallpaper && d->xpix != None) {
        gdk_draw_drawable (d->pix,
              widget->style->dark_gc[GTK_STATE_NORMAL],
              d->gpix,
              0, 0, 0, 0,
              widget->allocation.width,
              widget->allocation.height);
    } else {
        gdk_draw_rectangle (d->pix,
              ((d->no == d->pg->curdesk) ?
                    widget->style->dark_gc[GTK_STATE_SELECTED] :
                    widget->style->dark_gc[GTK_STATE_NORMAL]),
              TRUE,
              0, 0,
              widget->allocation.width,
              widget->allocation.height);
    }
    if (d->pg->wallpaper && d->no == d->pg->curdesk)
        gdk_draw_rectangle (d->pix,
              widget->style->light_gc[GTK_STATE_SELECTED],
              FALSE,
              0, 0,
              widget->allocation.width -1,
              widget->allocation.height -1);
    RET();
}
コード例 #12
0
ファイル: gthumb-slide.c プロジェクト: ChingezKhan/gthumb
void
gthumb_draw_frame (int          image_x,
		   int          image_y,
		   int          image_w,
		   int          image_h,
		   GdkDrawable *drawable,
		   GdkColor    *frame_color)
{
	GdkGC    *gc;
	GdkColor  white;
	int       frame_width;

	gc = gdk_gc_new (drawable);

	gdk_color_parse ("#FFFFFF", &white);
	gdk_gc_set_rgb_fg_color (gc, &white);
	gdk_draw_rectangle (drawable,
			    gc,
			    TRUE,
			    image_x, image_y,
			    image_w, image_h);
	
	gdk_gc_set_rgb_fg_color (gc, frame_color); 
	gdk_gc_set_line_attributes (gc, FRAME_WIDTH, 0, 0, 0);

	frame_width = FRAME_WIDTH - 2;
	gdk_draw_rectangle (drawable,
			    gc,
			    FALSE,
			    image_x - frame_width, 
			    image_y - frame_width,
			    image_w + (frame_width * 2) - 1,
			    image_h + (frame_width * 2) - 1);

	g_object_unref (gc);
}
コード例 #13
0
ファイル: Fenetre.cpp プロジェクト: valoufr33380/DUT-Info
gboolean Fenetre::configure_event(GtkWidget *widget, GdkEventConfigure *event)
{ // init => on crée une image mémoire pour le rafraîchissement
  if (dessin!=NULL) // enlever l'ancien bitmap
      g_object_unref (dessin);
  // en créer un nouveau
  dessin = gdk_pixmap_new (widget->window,
			   widget->allocation.width,
			   widget->allocation.height, -1);
  // l'image est effacée = remplie par la couleur de fond
  gdk_gc_set_rgb_fg_color(widget->style->bg_gc[GTK_STATE_NORMAL],&fond);
  gdk_draw_rectangle (dessin, widget->style->bg_gc[GTK_STATE_NORMAL],
              TRUE, 0, 0, 
              widget->allocation.width, widget->allocation.height);
  return TRUE;
}
コード例 #14
0
ファイル: explorer.c プロジェクト: ain101/Fyre
static void
update_image_preview (GtkFileChooser *chooser, GtkImage *image) {
    GdkPixbuf *image_pixbuf, *temp;
    static GdkPixbuf *emblem_pixbuf = NULL;
    gchar *filename;
    GdkPixmap *pixmap;
    gint width, height;

    if (emblem_pixbuf == NULL) {
	emblem_pixbuf = gdk_pixbuf_new_from_file (FYRE_DATADIR "/metadata-emblem.png", NULL);
	if (!emblem_pixbuf)
	    emblem_pixbuf = gdk_pixbuf_new_from_file (BR_DATADIR ("/fyre/metadata-emblem.png"), NULL);
    }

    filename = gtk_file_chooser_get_filename (chooser);
    if (filename == NULL) {
	gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
	return;
    }

    image_pixbuf = gdk_pixbuf_new_from_file_at_size (filename, 112, 112, NULL);
    if (image_pixbuf == NULL) {
	gtk_file_chooser_set_preview_widget_active (chooser, FALSE);
	return;
    }
    width = gdk_pixbuf_get_width (image_pixbuf);
    height = gdk_pixbuf_get_height (image_pixbuf);

    pixmap = gdk_pixmap_new (GTK_WIDGET (image)->window, width + 16, height + 16, -1);
    gdk_draw_rectangle (pixmap, GTK_WIDGET (image)->style->bg_gc[GTK_STATE_NORMAL], TRUE, 0, 0, width + 16, height + 16);
    gdk_draw_pixbuf (pixmap, NULL, image_pixbuf, 0, 0, 0, 0, width - 1, height - 1, GDK_RGB_DITHER_NONE, 0, 0);

    temp = gdk_pixbuf_new_from_file (filename, NULL);
    if (temp) {
        if (gdk_pixbuf_get_option (temp, "tEXt::fyre_params"))
            gdk_draw_pixbuf (pixmap, NULL, emblem_pixbuf, 0, 0, width - 16, height - 16, 31, 31, GDK_RGB_DITHER_NONE, 0, 0);
        else if (gdk_pixbuf_get_option (temp, "tEXt::de_jong_params"))
            gdk_draw_pixbuf (pixmap, NULL, emblem_pixbuf, 0, 0, width - 16, height - 16, 31, 31, GDK_RGB_DITHER_NONE, 0, 0);
        gdk_pixbuf_unref (temp);
    }

    if (image_pixbuf)
	gdk_pixbuf_unref (image_pixbuf);

    gtk_image_set_from_pixmap (GTK_IMAGE (image), pixmap, NULL);
    gdk_pixmap_unref (pixmap);
    gtk_file_chooser_set_preview_widget_active (chooser, TRUE);
}
コード例 #15
0
ファイル: vtepangox.c プロジェクト: Cordia/vte
static void
_vte_pango_x_fill_rectangle(struct _vte_draw *draw,
			  gint x, gint y, gint width, gint height,
			  GdkColor *color, guchar alpha)
{
	struct _vte_pango_x_data *data;
	GdkColor wcolor;

	data = (struct _vte_pango_x_data*) draw->impl_data;
	wcolor = *color;
	gdk_rgb_find_color(gdk_drawable_get_colormap(draw->widget->window),
			   &wcolor);
	gdk_gc_set_foreground(data->gc, &wcolor);
	gdk_draw_rectangle(draw->widget->window, data->gc, TRUE,
			   x, y, width, height);
}
コード例 #16
0
ファイル: histogram.c プロジェクト: medmatix/ggobi
static void
histogram_pixmap_clear (ggvisd *ggv, ggobid *gg)
{
  colorschemed *scheme = gg->activeColorScheme;
  dissimd *D = ggv->dissim;
  GtkWidget *da = D->da;

  if (gg->plot_GC == NULL)
    init_plot_GC (D->pix, gg);

  gdk_gc_set_foreground (gg->plot_GC, &scheme->rgb_bg);
  gdk_draw_rectangle (D->pix, gg->plot_GC,
                      TRUE, 0, 0,
                      da->allocation.width,
                      da->allocation.height);
}
コード例 #17
0
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);
}
コード例 #18
0
ファイル: pixmaps.c プロジェクト: svn2github/xqf
void create_server_pixmap (GtkWidget *window, struct pixmap *stype, 
                                   int n, GdkPixmap **pix, GdkBitmap **mask) {
  GdkGC *white_gc;
  int hb, wb, hs, ws;

  if (!GTK_WIDGET_REALIZED (window))
    gtk_widget_realize (window);

  gdk_window_get_size (buddy_pix[1].pix, &wb, &hb);
  gdk_window_get_size (stype->pix, &ws, &hs);

  *pix  = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), -1);
  *mask = gdk_pixmap_new (window->window, wb + ws, MAX (hs, hb), 1);

  white_gc = window->style->base_gc[GTK_STATE_NORMAL];

  if (!masks_gc) {
    masks_gc = gdk_gc_new (*mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

  mask_pattern.pixel = 0;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);
  gdk_draw_rectangle (*mask, masks_gc, TRUE, 0, 0, -1, -1);

  mask_pattern.pixel = 1;
  gdk_gc_set_foreground (masks_gc, &mask_pattern);

  if (n) {
    ensure_buddy_pix (window, n);

    gdk_gc_set_clip_origin (white_gc, 0, 0);
    gdk_gc_set_clip_mask (white_gc, buddy_pix[n].mask);
    gdk_draw_pixmap (*pix, white_gc, buddy_pix[n].pix, 0, 0, 0, 0, wb, hb);

    gdk_draw_pixmap (*mask, masks_gc, buddy_pix[n].mask, 0, 0, 0, 0, wb, hb);
  }

  gdk_gc_set_clip_origin (white_gc, wb, 0);
  gdk_gc_set_clip_mask (white_gc, stype->mask);
  gdk_draw_pixmap (*pix, white_gc, stype->pix, 0, 0, wb, 0, ws, hs);

  gdk_draw_pixmap (*mask, masks_gc, stype->mask, 0, 0, wb, 0, ws, hs);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, NULL);
}
コード例 #19
0
ファイル: test.c プロジェクト: mabm/raytracer
//Dessine un rectangle sur la zone de dessin pour representer le tracer, 
//equivalent du pinceau dans un logiciel de dessin
static void
draw_brush (GtkWidget *widget, gdouble x, gdouble y)
{
  GdkRectangle update_rect; //Creer un rectangle

  update_rect.x = x - 5; //position x du rectangle
  update_rect.y = y - 5; //position y du rectangle
  update_rect.width = 10; //Largeur du rectangle
  update_rect.height = 10; //hauteur du rectangle
  //Dessine le rectangle 
  gdk_draw_rectangle (pixmap,
		      widget->style->black_gc,  //Rectangle de couleur nour
                      TRUE,
                      update_rect.x, update_rect.y,  
                      update_rect.width, update_rect.height);
  gtk_widget_draw (widget, &update_rect);
}
コード例 #20
0
/* Draw the marker that indicates where the threshold is */
static void drawThresholdMarker(GdkDrawable *drawable, GtkWidget *greyramp)
{
  GreyrampProperties *properties = greyrampGetProperties(greyramp);
  DotterContext *dc = properties->dwc->dotterCtx;
  
  GdkRectangle markerRect;
  getThresholdMarkerRect(properties, &markerRect);
  
  /* Draw the threshold marker outline (there's no fill because we want the background greyramp to show through) */
  GdkGC *gc = gdk_gc_new(drawable);
  
  GdkColor *lineColor = getGdkColor(DOTCOLOR_THRESHOLD_MARKER, dc->defaultColors, properties->draggingThreshold, properties->dwc->usePrintColors);
  gdk_gc_set_foreground(gc, lineColor);
  gdk_draw_rectangle(drawable, gc, FALSE, markerRect.x, markerRect.y, markerRect.width, markerRect.height);
  
  g_object_unref(gc);
}
コード例 #21
0
ファイル: gui_canvas.c プロジェクト: bert/fped
void redraw(void)
{
	float aw, ah;

	aw = draw_ctx.widget->allocation.width;
	ah = draw_ctx.widget->allocation.height;
	gdk_draw_rectangle(draw_ctx.widget->window,
	    instantiation_error ? gc_bg_error : gc_bg, TRUE, 0, 0, aw, ah);

	DPRINTF("--- redraw: inst_draw ---");
	inst_draw();
	if (highlight)
		highlight();
	DPRINTF("--- redraw: tool_redraw ---");
	tool_redraw();
	DPRINTF("--- redraw: done ---");
}
コード例 #22
0
ファイル: diagdkrenderer.c プロジェクト: AmiGanguli/dia
/* Draw a highlighted version of a string.
 */
static void
draw_highlighted_string(DiaGdkRenderer *renderer,
			PangoLayout *layout,
			int x, int y,
			GdkColor *color)
{
  gint width, height;

  pango_layout_get_pixel_size(layout, &width, &height);

  gdk_gc_set_foreground(renderer->gc, color);

  gdk_draw_rectangle (renderer->pixmap,
		      renderer->gc, TRUE,
		      x-3, y-3,
		      width+6, height+6);
}
コード例 #23
0
static gboolean expose_event_cb(GtkWidget *widget, GdkEventExpose *event)
{
    if (widget->window)
    {
        GtkStyle *style;

        style = gtk_widget_get_style(widget);

        gdk_draw_rectangle(widget->window,
                           style->bg_gc[GTK_STATE_NORMAL],
                           TRUE,
                           event->area.x, event->area.y,
                           event->area.width, event->area.height);
    }

    return TRUE;
}
コード例 #24
0
ファイル: graphics.c プロジェクト: alexulter/comp-math-teapot
// clears pixmap
static gboolean
da_clear (GtkWidget *da)
{
    gint w=0;
    gint h=0;
    if (pixmap)
        g_object_unref(pixmap);
    gdk_drawable_get_size(da->window,&w,&h);
    pixmap = gdk_pixmap_new(da->window,w,h,-1);
    gdk_draw_rectangle (pixmap,
                        da->style->white_gc,
                        TRUE,
                        0, 0,
                        da->allocation.width,
                        da->allocation.height);
    return TRUE;
}
コード例 #25
0
ファイル: vtepangox.c プロジェクト: Cordia/vte
static void
_vte_pango_x_clear(struct _vte_draw *draw,
		   gint x, gint y, gint width, gint height)
{
	struct _vte_pango_x_data *data;
	gint i, j, h, w, xstop, ystop;

	data = (struct _vte_pango_x_data*) draw->impl_data;

	if ((data->pixmap == NULL) ||
	    (data->pixmapw == 0) ||
	    (data->pixmaph == 0)) {
		gdk_gc_set_foreground(data->gc, &data->color);
		gdk_draw_rectangle(draw->widget->window,
				   data->gc,
				   TRUE,
				   x, y, width, height);
		return;
	}

	/* Flood fill. */
	xstop = x + width;
	ystop = y + height;

	y = ystop - height;
	j = (data->scrolly + y) % data->pixmaph;
	while (y < ystop) {
		x = xstop - width;
		i = (data->scrollx + x) % data->pixmapw;
		h = MIN(data->pixmaph - (j % data->pixmaph), ystop - y);
		while (x < xstop) {
			w = MIN(data->pixmapw - (i % data->pixmapw), xstop - x);
			gdk_draw_drawable(draw->widget->window,
					  data->gc,
					  data->pixmap,
					  i, j,
					  x, y,
					  w, h);
			x += w;
			i = 0;
		}
		y += h;
		j = 0;
	}
}
コード例 #26
0
// Completely redraw the graph widget
void graph_redraw(PluginData *pd)
{
	GtkStyle *graph_style = gtk_widget_get_style (pd->graph);
	// clear the pixmap
	gdk_draw_rectangle (pd->graph_pixmap, graph_style->light_gc[GTK_STATE_NORMAL],
											TRUE, 0, 0, GRAPH_WIDTH, GRAPH_HEIGHT);
	
	// histogram
	for (int i=0; i<GRAPH_WIDTH; i++)
	{
		gdk_draw_line (pd->graph_pixmap, graph_style->mid_gc[GTK_STATE_NORMAL], i, GRAPH_HEIGHT * (1.0-pd->histogram[i]), i, GRAPH_HEIGHT);
	}
	// horizontal lines
	gdk_draw_line (pd->graph_pixmap, graph_style->dark_gc[GTK_STATE_NORMAL], 0, GRAPH_HEIGHT-1, GRAPH_WIDTH, GRAPH_HEIGHT-1);
	for (int i = 1; i < 10; i++)
	{
		int y = value_to_graph(i/2.0);
		gdk_draw_line (pd->graph_pixmap, graph_style->dark_gc[GTK_STATE_NORMAL], 0, y, GRAPH_WIDTH, y);
	}
	gdk_draw_line (pd->graph_pixmap, graph_style->dark_gc[GTK_STATE_NORMAL], 0, 0, GRAPH_WIDTH, 0);
	// vertical lines
	for (int i = 0; i < 10; i++)
	{
		int x = dist_to_graph(i)*GRAPH_WIDTH;
		gdk_draw_line (pd->graph_pixmap, graph_style->dark_gc[GTK_STATE_NORMAL], x, 0, x, GRAPH_HEIGHT);
		x = dist_to_graph(10*i)*GRAPH_WIDTH;
		gdk_draw_line (pd->graph_pixmap, graph_style->dark_gc[GTK_STATE_NORMAL], x, 0, x, GRAPH_HEIGHT);
	}
	gdk_draw_line (pd->graph_pixmap, graph_style->dark_gc[GTK_STATE_NORMAL], GRAPH_WIDTH-1, 0, GRAPH_WIDTH-1, GRAPH_HEIGHT);
	// wavelet marks
	float diagonal = sqrt(pd->image_width*pd->image_width + pd->image_height*pd->image_height)/2;
	for (int i = 0; i < WAVELET_DEPTH; i++)
	{
		int x = CLAMPED(dist_to_graph(scale_to_dist(i, diagonal))*GRAPH_WIDTH, 0, GRAPH_WIDTH-1);
		gdk_draw_line (pd->graph_pixmap, graph_style->text_gc[GTK_STATE_NORMAL], x, GRAPH_HEIGHT/2 - 2, x, GRAPH_HEIGHT/2 + 2);
	}
	// user curve
	gdk_draw_lines (pd->graph_pixmap, graph_style->text_gc[GTK_STATE_NORMAL], pd->curve_user.points, GRAPH_WIDTH);
	// user points
	for (int i = 0; i < pd->curve_user.count; i++)
	{
		gdk_draw_arc(pd->graph_pixmap, graph_style->text_gc[GTK_STATE_NORMAL], FALSE, pd->curve_user.user_points[i].x-GRAPH_HOTSPOT-1, pd->curve_user.user_points[i].y-GRAPH_HOTSPOT-1, GRAPH_HOTSPOT*2+1, GRAPH_HOTSPOT*2+1, 0, 64*360);
	}
	gdk_draw_drawable (pd->graph->window, graph_style->text_gc[GTK_STATE_NORMAL], pd->graph_pixmap, 0, 0, 0, 0, GRAPH_WIDTH, GRAPH_HEIGHT);
}
コード例 #27
0
ファイル: scope.c プロジェクト: coreyreichle/soundmodem
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);
}
コード例 #28
0
ファイル: table.c プロジェクト: ralight/ggz
static void table_clear_table(int write_to_screen)
{
	assert(table_buf && table_style);

	/* There's no real reason why write_to_screen shouldn't be used, but
	   it's probably not a good idea. */
	assert(!write_to_screen);

	/* Clear the buffer to the style's background color */
	gdk_draw_rectangle(table_buf,
			   table_style->bg_gc[GTK_WIDGET_STATE(table)],
			   TRUE, 0, 0, get_table_width(),
			   get_table_height());

	if (write_to_screen)
		table_show_table(0, 0, get_table_width(),
				 get_table_height());
}
コード例 #29
0
ファイル: interface.c プロジェクト: wader/gtktetris
gint game_area_expose_event(GtkWidget       *widget,
			    GdkEventExpose  *event,
			    gpointer         user_data)
{	
  if(!game_over)
    {
      from_virtual();
      move_block(0,0,0); 
    }
  else
    gdk_draw_rectangle(widget->window,
		       widget->style->black_gc,
		       TRUE,
		       0,0,
		       widget->allocation.width,
		       widget->allocation.height);
  return FALSE;
}
コード例 #30
0
ファイル: gui_dialogs.c プロジェクト: krzyzanowskim/GNUGadu
static gboolean about_configure_event(GtkWidget * image, GdkEventConfigure * event, gpointer data)
{
    if (pixmap)
        return TRUE;

    if (!gc)
    {
        GdkColor color;
        gdk_color_parse("#ffffff", &color);
        gc = gdk_gc_new(image->window);
        gdk_gc_set_rgb_fg_color(gc, &color);
    }

    pixmap = gdk_pixmap_new(image->window, image->allocation.width, image->allocation.height, -1);

    gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, image->allocation.width, image->allocation.height);
    return TRUE;
}