コード例 #1
0
ファイル: GtkDrawOp.cpp プロジェクト: AbdelghaniDr/mirror
void SystemDraw::DrawRectOp(int x, int y, int cx, int cy, Color color)
{
	if(IsNull(color))
		return;
	FlushText();
	cairo_rectangle(cr, x, y, cx, cy);
	if(color == InvertColor()) {
#if GTK_CHECK_VERSION(2,24,0) && (CAIRO_VERSION_MAJOR > 1 || CAIRO_VERSION_MINOR > 9)
		SetColor(White());
		cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE);
		cairo_fill(cr);
		cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
#else
		if(drawable) {
			GdkGC *gc = gdk_gc_new(drawable);
	        gdk_gc_set_function(gc, GDK_INVERT);
	        Point o = GetOffset();
	        gdk_draw_drawable(drawable, gc, drawable, x + o.x, y + o.y, x + o.x, y + o.y, cx, cy);
	        gdk_gc_set_function(gc, GDK_COPY);
	        gdk_gc_destroy(gc);
		}
#endif
	}
	else {
		SetColor(color);
		cairo_fill(cr);
	}
}
コード例 #2
0
ファイル: ctx_dl_tiles.c プロジェクト: dss91/omgps
static void dlarea_redraw_func()
{
	if (draw_dlarea_with_wgs84) {
		map_repo_t *repo = g_view.fglayer.repo;
		int zoom = repo->zoom;

		point_t center_pixel = wgs84_to_tilepixel(g_view.center_wgs84, zoom, repo);
		point_t tl = wgs84_to_tilepixel(dlarea_wgs84_tl, zoom, repo);
		point_t br = wgs84_to_tilepixel(dlarea_wgs84_br, zoom, repo);

		dlarea.x = tl.x - (center_pixel.x - (g_view.width >> 1));
		dlarea.y = tl.y - (center_pixel.y - (g_view.height >> 1));
		dlarea.width = (br.x - tl.x);
		dlarea.height = (br.y - tl.y);
	}

	map_draw_back_layers(g_view.da->window);

	if (dlarea.width > 0 && dlarea.height > 0) {
		if (draw_dlarea_with_wgs84)
			gdk_gc_set_function(g_context.dlarea_gc, GDK_COPY);
		gdk_draw_rectangle (g_view.da->window, g_context.dlarea_gc, FALSE,
			dlarea.x, dlarea.y, dlarea.width, dlarea.height);
		gdk_gc_set_function(g_context.dlarea_gc, GDK_INVERT);
	}
}
コード例 #3
0
ファイル: ctkcurve.c プロジェクト: carbn/nvidia-settings
static void draw(CtkCurve *ctk_curve)
{
    CtrlTarget *ctrl_target = ctk_curve->ctrl_target;
    gushort *lut;
    gint n_lut_entries;

#ifdef CTK_GTK3
    /* Fill Curve surface with black background */
    cairo_set_operator(ctk_curve->c_context, CAIRO_OPERATOR_SOURCE);
    
    cairo_set_source_rgba(ctk_curve->c_context, 0.0, 0.0, 0.0, 1.0);
    cairo_rectangle(ctk_curve->c_context, 0, 0,
                    ctk_curve->width, ctk_curve->height);
    cairo_fill(ctk_curve->c_context);

    /* Add the Color LUT ramp lines */
    cairo_set_operator(ctk_curve->c_context, CAIRO_OPERATOR_ADD);

    cairo_set_source_rgba(ctk_curve->c_context, 1.0, 0.0, 0.0, 1.0);
    NvCtrlGetColorRamp(ctrl_target, RED_CHANNEL, &lut, &n_lut_entries);
    plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries,
                    ctk_curve->width, ctk_curve->height);

    cairo_set_source_rgba(ctk_curve->c_context, 0.0, 1.0, 0.0, 1.0);
    NvCtrlGetColorRamp(ctrl_target, GREEN_CHANNEL, &lut, &n_lut_entries);
    plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries,
                    ctk_curve->width, ctk_curve->height);

    cairo_set_source_rgba(ctk_curve->c_context, 0.0, 0.0, 1.0, 1.0);
    NvCtrlGetColorRamp(ctrl_target, BLUE_CHANNEL, &lut, &n_lut_entries);
    plot_color_ramp(ctk_curve->c_context, lut, n_lut_entries,
                    ctk_curve->width, ctk_curve->height);
#else
    GtkWidget *widget = GTK_WIDGET(ctk_curve);

    gdk_gc_set_function(ctk_curve->gdk_gc, GDK_COPY);
    
    gdk_draw_rectangle(ctk_curve->gdk_pixmap, widget->style->black_gc,
                       TRUE, 0, 0, ctk_curve->width, ctk_curve->height);

    gdk_gc_set_function(ctk_curve->gdk_gc, GDK_XOR);

    gdk_gc_set_foreground(ctk_curve->gdk_gc, &ctk_curve->gdk_color_red);
    NvCtrlGetColorRamp(ctrl_target, RED_CHANNEL, &lut, &n_lut_entries);
    plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc,
                    lut, n_lut_entries, ctk_curve->width, ctk_curve->height);
    
    gdk_gc_set_foreground(ctk_curve->gdk_gc, &ctk_curve->gdk_color_green);
    NvCtrlGetColorRamp(ctrl_target, GREEN_CHANNEL, &lut, &n_lut_entries);
    plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc,
                    lut, n_lut_entries, ctk_curve->width, ctk_curve->height);

    gdk_gc_set_foreground(ctk_curve->gdk_gc, &ctk_curve->gdk_color_blue);
    NvCtrlGetColorRamp(ctrl_target, BLUE_CHANNEL, &lut, &n_lut_entries);
    plot_color_ramp(ctk_curve->gdk_pixmap, ctk_curve->gdk_gc,
                    lut, n_lut_entries, ctk_curve->width, ctk_curve->height);
#endif
}
コード例 #4
0
ファイル: iupgtk_draw.c プロジェクト: LuaDist/iup
void iupDrawRectangleInvert(IdrawCanvas* dc, int x1, int y1, int x2, int y2)
{
  GdkColor color;
  iupgdkColorSet(&color, 255, 255, 255);
  gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &color);
  gdk_gc_set_function(dc->pixmap_gc, GDK_XOR);
  gdk_draw_rectangle(dc->pixmap, dc->pixmap_gc, TRUE, x1, y1, x2-x1+1, y2-y1+1);
  gdk_gc_set_function(dc->pixmap_gc, GDK_COPY);
}
コード例 #5
0
//__________________________________________________________________
void _HYPlatformGraphicPane::_InvertRect (_HYRect& rct)
{
	GdkRectangle clip_rect = HYRect2GDKRect (rct);
	GdkPixbuf* theImage = gdk_pixbuf_get_from_drawable (NULL, thePane, NULL, rct.left, rct.top, 0, 0, clip_rect.width, clip_rect.height);
	gdk_gc_set_function (theContext,GDK_INVERT);
	gdk_draw_pixbuf (thePane, theContext, theImage, 0,0, clip_rect.x, clip_rect.y, clip_rect.width, clip_rect.height, GDK_RGB_DITHER_NORMAL, 0, 0);
	gdk_gc_set_function (theContext,GDK_COPY);
	g_object_unref (theImage);
}
コード例 #6
0
ファイル: map_port.c プロジェクト: Jalakas/gpsdrive
void map_bkg_rectangle(MapGC *mgc, MapSettings *settings,
		       int x, int y, int width, int height)
{
  if (FALSE);
#ifdef HAVE_CAIRO
  else if (mgc->cairo_cr)
    {
      cairo_set_operator(mgc->cairo_cr, CAIRO_OPERATOR_OVER);
      cairo_set_source_rgba(mgc->cairo_cr, .937, .937, .937, .8);
      cairo_rectangle(mgc->cairo_cr, x, y, width, height);
      cairo_fill(mgc->cairo_cr);
      cairo_set_operator(mgc->cairo_cr, CAIRO_OPERATOR_SOURCE);
    }
#endif
#ifdef HAVE_GTK
  else if (mgc->gtk_drawable)
    {
      gdk_gc_set_function(mgc->gtk_gc, GDK_OR);
      gdk_gc_set_foreground(mgc->gtk_gc, &settings->textback);
      gdk_draw_rectangle(mgc->gtk_drawable, mgc->gtk_gc, TRUE,
			 x, y, width, height);
      gdk_gc_set_function(mgc->gtk_gc, GDK_COPY);
    }
#endif
#ifdef HAVE_QT
  else if (mgc->qt_painter)
    {
      qt_bkg_rectangle(mgc->qt_painter, settings,
		       x, y, width, height);
    }
#endif
#ifdef HAVE_QUARTZ
  else if (mgc->quartz_gc)
    {
      CGContextSetRGBFillColor(mgc->quartz_gc, .937, .937, .937, 1.);
      //gdk_gc_set_function(mgc->gtk_gc, GDK_OR);
      //gdk_gc_set_foreground(mgc->gtk_gc, &settings->textback);
      //gdk_draw_rectangle(mgc->gtk_drawable, mgc->gtk_gc, TRUE,
      //		 x, y, width, height);
      //gdk_gc_set_function(mgc->gtk_gc, GDK_COPY);
    }
#endif
#ifdef WIN32
  else if (mgc->win_dc)
    {
      COLORREF color = RGB(0xa5, 0xa6, 0xa5);
      HBRUSH brush = CreateSolidBrush(color);
      HBRUSH oldBrush = SelectObject(mgc->win_dc, brush);
      SetROP2(mgc->win_dc, R2_MERGEPEN);
      win32_setpen(mgc, 4, color);
      Rectangle(mgc->win_dc, x, y, x + width, y + height);
      SetROP2(mgc->win_dc, R2_COPYPEN);
      SelectObject(mgc->win_dc, oldBrush);
      DeleteObject(brush);
    }
#endif
}
コード例 #7
0
void iupdrvDrawSelectRect(IdrawCanvas* dc, int x1, int y1, int x2, int y2)
{
  GdkColor c;
  iupgdkColorSetRGB(&c, 255, 255, 255);
  gdk_gc_set_rgb_fg_color(dc->pixmap_gc, &c);

  iupDrawCheckSwapCoord(x1, x2);
  iupDrawCheckSwapCoord(y1, y2);

  gdk_gc_set_function(dc->pixmap_gc, GDK_XOR);
  gdk_draw_rectangle(dc->pixmap, dc->pixmap_gc, TRUE, x1, y1, x2 - x1 + 1, y2 - y1 + 1);
  gdk_gc_set_function(dc->pixmap_gc, GDK_COPY);
}
コード例 #8
0
ファイル: caret.cpp プロジェクト: lelou6666/pcmanx-gtk2
void CCaret::DrawInverse()
{
	if( !m_pParent )
		return;
	if( !GDK_IS_DRAWABLE(m_pParent->window))
	{
//		g_warning("Warring! Draw on DELETED widget!\n");
		return;
	}
	gdk_gc_set_function(m_GC, GDK_INVERT);
	gdk_draw_drawable(m_pParent->window, m_GC, m_pParent->window,
					m_Pos.x, m_Pos.y, m_Pos.x, m_Pos.y, m_Width, m_Height);
	gdk_gc_set_function(m_GC, GDK_COPY);
}
コード例 #9
0
ファイル: gtans.c プロジェクト: GNOME/gcompris
void taninitcbgr(void){
  int i;
  GdkColor *color;

  initcbgr = TRUE; /* pour ne pas initialiser 2 fois */

  for (i=PXSTART; i<PXSTART+PXNBR; i++){
    tabgc[i] = gdk_gc_new(widgetgrande->window);
    if (tabpxpixmode[i])
      tansetpixmapmode(widgetgrande,tabpxnam[i],i);
    else
      tansetcolormode(&colortab[i],i);
  }

  for (i=0; i<GRISNBR; i++){
    color = &colortab[i];
    color->red = color->green = color->blue = (gushort)(65535.0/(GRISNBR-1)*i);
    tabgc[i] = gdk_gc_new(widgetgrande->window);
    tansetcolormode(color,i);
  }

  invertgc=gdk_gc_new(widgetgrande->window);
  gdk_gc_set_function(invertgc,GDK_INVERT);
  tabgc[GCPIECEHLP]=gdk_gc_new(widgetgrande->window);
  tansetcolormode(&colortab[GCPIECEHLP],GCPIECEHLP);
  /* les line attribute sont dans le callback */

  if (initcbpe)
    taninitcbcommun();

}
コード例 #10
0
ファイル: gtkhid-gdk.c プロジェクト: BenBergman/geda-pcb
static void
draw_crosshair (render_priv *priv)
{
  GdkWindow *window = gtk_widget_get_window (gport->drawing_area);
  GtkStyle *style = gtk_widget_get_style (gport->drawing_area);
  gint x, y;
  static GdkGC *xor_gc;
  static GdkColor cross_color;

  if (gport->crosshair_x < 0 || ghidgui->creating || !gport->has_entered)
    return;

  if (!xor_gc)
    {
      xor_gc = gdk_gc_new (window);
      gdk_gc_copy (xor_gc, style->white_gc);
      gdk_gc_set_function (xor_gc, GDK_XOR);
      gdk_gc_set_clip_origin (xor_gc, 0, 0);
      set_clip (priv, xor_gc);
      /* FIXME: when CrossColor changed from config */
      ghid_map_color_string (Settings.CrossColor, &cross_color);
    }

  gdk_gc_set_foreground (xor_gc, &cross_color);

  x = DRAW_X (gport->crosshair_x);
  y = DRAW_Y (gport->crosshair_y);

  draw_right_cross (xor_gc, x, y);
  if (Crosshair.shape == Union_Jack_Crosshair_Shape)
    draw_slanted_cross (xor_gc, x, y);
  if (Crosshair.shape == Dozen_Crosshair_Shape)
    draw_dozen_cross (xor_gc, x, y);
}
コード例 #11
0
static void
clear_light_marker (void)
{
  /* Restore background if it has been saved */
  /* ======================================= */

  if (backbuf.image != NULL)
    {
      GdkColor  color;

      color.red   = 0x0;
      color.green = 0x0;
      color.blue  = 0x0;
      gdk_gc_set_rgb_bg_color (gc, &color);

      color.red   = 0xFFFF;
      color.green = 0xFFFF;
      color.blue  = 0xFFFF;
      gdk_gc_set_rgb_fg_color (gc, &color);

      gdk_gc_set_function (gc, GDK_COPY);

      gdk_draw_image (previewarea->window, gc,
		      backbuf.image,
		      0, 0,
		      backbuf.x, backbuf.y,
		      backbuf.w, backbuf.h);

      g_object_unref (backbuf.image);
      backbuf.image = NULL;
    }
}
コード例 #12
0
void
draw_preview_wireframe (void)
{
  gint      startx, starty, pw, ph;
  GdkColor  color;

  color.red   = 0x0;
  color.green = 0x0;
  color.blue  = 0x0;
  gdk_gc_set_rgb_bg_color (gc, &color);

  color.red   = 0xFFFF;
  color.green = 0xFFFF;
  color.blue  = 0xFFFF;
  gdk_gc_set_rgb_fg_color (gc, &color);

  gdk_gc_set_function (gc, GDK_INVERT);

  pw     = PREVIEW_WIDTH  * mapvals.zoom;
  ph     = PREVIEW_HEIGHT * mapvals.zoom;
  startx = (PREVIEW_WIDTH  - pw) / 2;
  starty = (PREVIEW_HEIGHT - ph) / 2;

  clear_wireframe ();
  draw_wireframe (startx, starty, pw, ph);
}
コード例 #13
0
ファイル: draw_grid.c プロジェクト: Jalakas/gpsdrive
/* *****************************************************************************
 * Draw Text (lat/lon) into Grid
 */
void
draw_grid_text (GtkWidget * widget, gdouble posx, gdouble posy, gchar * txt)
{
	/* prints in pango */
	PangoFontDescription *pfd;
	PangoLayout *grid_label_layout;
	gint width, height;

	grid_label_layout = gtk_widget_create_pango_layout (map_drawingarea, txt);

	pfd = pango_font_description_from_string ("Sans 8");

	pango_layout_set_font_description (grid_label_layout, pfd);
	pango_layout_get_pixel_size (grid_label_layout, &width, &height);
	gdk_gc_set_function (kontext_map, GDK_XOR);
	gdk_gc_set_background (kontext_map, &colors.white);
	gdk_gc_set_foreground (kontext_map, &colors.mygray);
	
	gdk_draw_layout_with_colors (drawable, kontext_map, posx - width / 2,
				     posy - height / 2, grid_label_layout, &colors.black,
				     NULL);

	if (grid_label_layout != NULL)
		g_object_unref (G_OBJECT (grid_label_layout));
	/* freeing PangoFontDescription, cause it has been copied by prev. call */
	pango_font_description_free (pfd);

}
コード例 #14
0
ファイル: immerse.c プロジェクト: cbuehler/gwyddion
static gboolean
immerse_view_expose(GtkWidget *view,
                    GdkEventExpose *event,
                    ImmerseControls *controls)
{
    if (event->count > 0)
        return FALSE;

    if (controls->detail) {
        GdkColor white = { 0, 0xffff, 0xffff, 0xffff };
        GdkGC *gc;
        gint w, h, xoff, yoff;

        gwy_data_view_coords_real_to_xy(GWY_DATA_VIEW(view),
                                        controls->args->xpos,
                                        controls->args->ypos,
                                        &xoff, &yoff);
        w = gdk_pixbuf_get_width(controls->detail);
        h = gdk_pixbuf_get_height(controls->detail);
        /* gwy_debug("(%d,%d) %dx%d", xoff, yoff, w, h); */
        gc = gdk_gc_new(view->window);
        gdk_draw_pixbuf(view->window, gc, controls->detail,
                        0, 0, xoff, yoff, w, h,
                        GDK_RGB_DITHER_NORMAL, 0, 0);
        if (controls->args->draw_frame) {
            gdk_gc_set_function(gc, GDK_XOR);
            gdk_gc_set_rgb_fg_color(gc, &white);
            gdk_draw_rectangle(view->window, gc, FALSE, xoff, yoff, w-1, h-1);
        }
        g_object_unref(gc);
    }

    return FALSE;
}
コード例 #15
0
ファイル: cdgdk.c プロジェクト: LuaDist/cd
static int cdwritemode(cdCtxCanvas *ctxcanvas, int write_mode)
{
  switch (write_mode)
  {
  case CD_REPLACE:
    gdk_gc_set_function(ctxcanvas->gc, GDK_COPY);
    break;
  case CD_XOR:
    gdk_gc_set_function(ctxcanvas->gc, GDK_XOR);
    break;
  case CD_NOT_XOR:
    gdk_gc_set_function(ctxcanvas->gc, GDK_EQUIV);
    break;
  }

  return write_mode;
}
コード例 #16
0
ファイル: modify_tool.c プロジェクト: brunetton/dia
static void
modify_button_press(ModifyTool *tool, GdkEventButton *event,
		     DDisplay *ddisp)
{
  Point clickedpoint;
  DiaObject *clicked_obj;
  gboolean some_selected;

  ddisplay_untransform_coords(ddisp,
			      (int)event->x, (int)event->y,
			      &clickedpoint.x, &clickedpoint.y);

  /* don't got to single handle movement if there is more than one object selected */
  some_selected = g_list_length (ddisp->diagram->data->selected) > 1;
  if (!some_selected && do_if_clicked_handle(ddisp, tool, &clickedpoint, event))
    return;
  
  clicked_obj = click_select_object(ddisp, &clickedpoint, event);
  if (!some_selected && do_if_clicked_handle(ddisp, tool, &clickedpoint, event))
    return;

  if ( clicked_obj != NULL ) {
    tool->state = STATE_MOVE_OBJECT;
    tool->object = clicked_obj;
    tool->move_compensate = clicked_obj->position;
    point_sub(&tool->move_compensate, &clickedpoint);
    tool->break_connections = TRUE; /* unconnect when not grabbing handles, just setting to
				      * FALSE is not enough. Need to refine the move op, too. */
    gdk_pointer_grab (gtk_widget_get_window(ddisp->canvas), FALSE,
                      GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
                      NULL, NULL, event->time);
    tool->start_at = clickedpoint;
    tool->start_time = time_micro();
    ddisplay_set_all_cursor(get_cursor(CURSOR_SCROLL));
  } else {
    tool->state = STATE_BOX_SELECT;
    tool->start_box = clickedpoint;
    tool->end_box = clickedpoint;
    tool->x1 = tool->x2 = (int) event->x;
    tool->y1 = tool->y2 = (int) event->y;

    if (tool->gc == NULL) {
      tool->gc = gdk_gc_new(gtk_widget_get_window(ddisp->canvas));
      gdk_gc_set_line_attributes(tool->gc, 1, GDK_LINE_ON_OFF_DASH, 
				 GDK_CAP_BUTT, GDK_JOIN_MITER);
      gdk_gc_set_foreground(tool->gc, &color_gdk_white);
      gdk_gc_set_function(tool->gc, GDK_XOR);
    }

    gdk_draw_rectangle (gtk_widget_get_window (ddisp->canvas), tool->gc, FALSE,
			tool->x1, tool->y1,
			tool->x2 - tool->x1, tool->y2 - tool->y1);

    gdk_pointer_grab (gtk_widget_get_window (ddisp->canvas), FALSE,
                      GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
                      NULL, NULL, event->time);
  }
}
コード例 #17
0
ファイル: gtkhid-gdk.c プロジェクト: thequux/pcb
void
ghid_set_draw_xor (hidGC gc, int xor_mask)
{
    gc->xor_mask = xor_mask;
    if (!gc->gc)
        return;
    gdk_gc_set_function (gc->gc, xor_mask ? GDK_XOR : GDK_COPY);
    ghid_set_color (gc, gc->colorname);
}
コード例 #18
0
ファイル: lighting_preview.c プロジェクト: Amerekanets/gimp
void
draw_preview_image (gboolean recompute)
{
  gint      startx, starty, pw, ph;
  GdkColor  color;

  color.red   = 0x0;
  color.green = 0x0;
  color.blue  = 0x0;
  gdk_gc_set_rgb_bg_color (gc, &color);

  color.red   = 0xFFFF;
  color.green = 0xFFFF;
  color.blue  = 0xFFFF;
  gdk_gc_set_rgb_fg_color (gc, &color);

  gdk_gc_set_function (gc, GDK_COPY);

  compute_preview_rectangle (&startx, &starty, &pw, &ph);

  if (recompute)
    {
      GdkDisplay *display = gtk_widget_get_display (previewarea);
      GdkCursor  *cursor;

      cursor = gdk_cursor_new_for_display (display, GDK_WATCH);

      gdk_window_set_cursor (previewarea->window, cursor);
      gdk_cursor_unref (cursor);

      compute_preview (startx, starty, pw, ph);
      cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
      gdk_window_set_cursor (previewarea->window, cursor);
      gdk_cursor_unref (cursor);
      gdk_flush ();

      /* if we recompute, clear backbuf, so we don't
       * restore the wrong bitmap */
      if (backbuf.image != NULL)
        {
          g_object_unref (backbuf.image);
          backbuf.image = NULL;
        }
    }

  gdk_draw_rgb_image (previewarea->window, gc,
                      0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT,
                      GDK_RGB_DITHER_MAX, preview_rgb_data,
                      3 * PREVIEW_WIDTH);

  /* draw symbols if enabled in UI */
  if (mapvals.interactive_preview)
    {
      draw_handles ();
    }
}
コード例 #19
0
ファイル: routes.c プロジェクト: Jalakas/gpsdrive
/* *****************************************************************************
 */
void
display_dsc (void)
{
	GdkGC *kontext;
	gint len;
	gchar *text;
	PangoFontDescription *pfd;
	PangoLayout *wplabellayout;

	if (!do_display_dsc)
		return;
	if ((textcount >= (int) strlen (displaytext)))
	{
		do_display_dsc = FALSE;
		free (displaytext);
		displaytext = NULL;
		return;
	}
	if (textcount > 20)
		text = displaytext + textcount;
	else
		text = displaytext;
	kontext = gdk_gc_new (drawable);
	len = strlen (text);
	/*   if (len>10) */
	/*       len=10; */

	/*   gdk_gc_set_function (kontext, GDK_OR); */

	gdk_gc_set_foreground (kontext, &colors.mygray);
	gdk_draw_rectangle (drawable, kontext, 1, 0, gui_status.mapview_y - 40, gui_status.mapview_x,
			    40);
	gdk_gc_set_function (kontext, GDK_COPY);
	/*   gdk_gc_set_foreground (kontext, &blue); */

	/* prints in pango */

	wplabellayout = gtk_widget_create_pango_layout (map_drawingarea, text);
	//KCFX  
	if (local_config.guimode == GUI_PDA)
		pfd = pango_font_description_from_string ("Sans 8");
	else
		pfd = pango_font_description_from_string ("Sans bold 14");
	pango_layout_set_font_description (wplabellayout, pfd);
	/*          pango_layout_get_pixel_size (wplabellayout, &width, &height); */
	gdk_draw_layout_with_colors (drawable, kontext, 11, gui_status.mapview_y - 30,
				     wplabellayout, &colors.blue, NULL);

	if (wplabellayout != NULL)
		g_object_unref (G_OBJECT (wplabellayout));
	/* freeing PangoFontDescription, cause it has been copied by prev. call */
	pango_font_description_free (pfd);

	textcount += 2;

}
コード例 #20
0
ファイル: rbgdkgc.c プロジェクト: tec/ruby-gnome2
static VALUE
rg_set_function(VALUE self, VALUE func)
{
    GdkFunction f;
    f = (GdkFunction)(RVAL2GENUM(func, GDK_TYPE_FUNCTION));
    if (f > GDK_SET)
        rb_raise(rb_eArgError, "function out of range");

    gdk_gc_set_function(_SELF(self), f);
    return self;
}
コード例 #21
0
ファイル: uni-nav.c プロジェクト: sjoblomj/Viewnior
static void
uni_nav_realize (GtkWidget * widget)
{
    GTK_WIDGET_CLASS (uni_nav_parent_class)->realize (widget);
    UniNav *nav = UNI_NAV (widget);
    nav->gc = gdk_gc_new (gtk_widget_get_window (widget));
    gdk_gc_set_function (nav->gc, GDK_INVERT);
    gdk_gc_set_line_attributes (nav->gc,
                                3,
                                GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_MITER);
}
コード例 #22
0
ファイル: gdkgc.c プロジェクト: amery/clip-itk
/* Determines how the current pixel values and the pixel values being
 * drawn are combined to produce the final pixel values. */
int
clip_GDK_GCSETFUNCTION(ClipMachine * cm)
{
	C_object        *cgc = _fetch_co_arg(cm);
	GdkFunction function = _clip_parni(cm,2);
	CHECKCOBJ(cgc,GDK_IS_GC(cgc)); CHECKOPT(2,NUMERIC_t);
	gdk_gc_set_function(GDK_GC(cgc->object), function);
	return 0;
err:
	return 1;
}
コード例 #23
0
static void
draw_light_marker (gint xpos,
		   gint ypos)
{
  GdkColor  color;

  color.red   = 0x0;
  color.green = 0x0;
  color.blue  = 0x0;
  gdk_gc_set_rgb_bg_color (gc, &color);

  color.red   = 0x0;
  color.green = 0x4000;
  color.blue  = 0xFFFF;
  gdk_gc_set_rgb_fg_color (gc, &color);

  gdk_gc_set_function (gc, GDK_COPY);

  if (mapvals.lightsource.type == POINT_LIGHT)
    {
      lightx = xpos;
      lighty = ypos;

      /* Save background */
      /* =============== */

      backbuf.x = lightx - 7;
      backbuf.y = lighty - 7;
      backbuf.w = 14;
      backbuf.h = 14;

      /* X doesn't like images that's outside a window, make sure */
      /* we get the backbuffer image from within the boundaries   */
      /* ======================================================== */

      if (backbuf.x < 0)
        backbuf.x = 0;
      else if ((backbuf.x + backbuf.w) > PREVIEW_WIDTH)
        backbuf.w = (PREVIEW_WIDTH - backbuf.x);
      if (backbuf.y < 0)
        backbuf.y = 0;
      else if ((backbuf.y + backbuf.h) > PREVIEW_HEIGHT)
        backbuf.h = (PREVIEW_WIDTH - backbuf.y);

      backbuf.image = gdk_drawable_get_image (previewarea->window,
                                              backbuf.x, backbuf.y,
                                              backbuf.w, backbuf.h);

      gdk_draw_arc (previewarea->window, gc,
		    TRUE,
		    lightx - 7, lighty - 7, 14, 14,
		    0, 360 * 64);
    }
}
コード例 #24
0
ファイル: exp_pixmap.c プロジェクト: kwalus/QCADesigner
/**
 * exp_pixmap_clean:
 * @exp_pixmap: An "expanding pixmap"
 *
 * Paints the entire surface area of an #EXP_PIXMAP black.
 */
void exp_pixmap_clean (EXP_PIXMAP *exp_pixmap)
  {
  GdkGC *gc = NULL ;

  gc = gdk_gc_new (exp_pixmap->pixmap) ;
  gdk_gc_set_function (gc, GDK_COPY) ;
  gdk_gc_set_foreground (gc, &clrBlack) ;
  gdk_gc_set_background (gc, &clrBlack) ;
  gdk_draw_rectangle (exp_pixmap->pixmap, gc, TRUE, 0, 0, exp_pixmap->cxUsed, exp_pixmap->cyUsed) ;
  g_object_unref (gc) ;
  }
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_setFunction
  (JNIEnv *env, jobject obj, jint func)
{
  struct graphics *g;
  g = (struct graphics *) NSA_GET_PTR (env, obj);
  
  gdk_threads_enter ();
  gdk_gc_set_function (g->gc, func);
  gdk_threads_leave ();
}
コード例 #26
0
ファイル: nova.c プロジェクト: Amerekanets/gimp
static void
nova_center_cursor_draw (NovaCenter *center)
{
  GtkWidget *prvw = center->preview->area;
  gint       width, height;

  gimp_preview_get_size (center->preview, &width, &height);

  gdk_gc_set_function (prvw->style->black_gc, GDK_INVERT);

  if (show_cursor)
    {
      if (center->cursor_drawn)
        {
          gdk_draw_line (prvw->window,
                         prvw->style->black_gc,
                         center->oldx, 1, center->oldx,
                         height - 1);
          gdk_draw_line (prvw->window,
                         prvw->style->black_gc,
                         1, center->oldy,
                         width - 1, center->oldy);
        }

      gdk_draw_line (prvw->window,
                     prvw->style->black_gc,
                     center->curx, 1, center->curx,
                     height - 1);
      gdk_draw_line (prvw->window,
                     prvw->style->black_gc,
                     1, center->cury,
                     width - 1, center->cury);
    }

  /* current position of cursor is updated */
  center->oldx         = center->curx;
  center->oldy         = center->cury;
  center->cursor_drawn = TRUE;

  gdk_gc_set_function (prvw->style->black_gc, GDK_COPY);
}
コード例 #27
0
void
draw_preview_image (gint docompute)
{
  gint startx, starty, pw, ph;
  GdkColor  color;

  color.red   = 0x0;
  color.green = 0x0;
  color.blue  = 0x0;
  gdk_gc_set_rgb_bg_color (gc, &color);

  color.red   = 0xFFFF;
  color.green = 0xFFFF;
  color.blue  = 0xFFFF;
  gdk_gc_set_rgb_fg_color (gc, &color);

  gdk_gc_set_function (gc, GDK_COPY);
  linetab[0].x1 = -1;

  pw = PREVIEW_WIDTH * mapvals.zoom;
  ph = PREVIEW_HEIGHT * mapvals.zoom;
  startx = (PREVIEW_WIDTH - pw) / 2;
  starty = (PREVIEW_HEIGHT - ph) / 2;

  if (docompute == TRUE)
    {
      GdkDisplay *display = gtk_widget_get_display (previewarea);
      GdkCursor  *cursor;

      cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
      gdk_window_set_cursor (previewarea->window, cursor);
      gdk_cursor_unref (cursor);

      compute_preview (0, 0, width - 1, height - 1, pw, ph);

      cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
      gdk_window_set_cursor(previewarea->window, cursor);
      gdk_cursor_unref (cursor);

      clear_light_marker ();
    }

  if (pw != PREVIEW_WIDTH || ph != PREVIEW_HEIGHT)
    gdk_window_clear (previewarea->window);

  gdk_draw_rgb_image (previewarea->window, gc,
                      startx, starty, pw, ph,
                      GDK_RGB_DITHER_MAX,
                      preview_rgb_data, 3 * pw);

  draw_lights (startx, starty, pw, ph);
}
コード例 #28
0
ファイル: gimppaletteview.c プロジェクト: Amerekanets/gimp
static void
gimp_palette_view_realize (GtkWidget *widget)
{
  GimpPaletteView *view = GIMP_PALETTE_VIEW (widget);

  GTK_WIDGET_CLASS (parent_class)->realize (widget);

  view->gc = gdk_gc_new (widget->window);

  gdk_gc_set_function (view->gc, GDK_INVERT);
  gdk_gc_set_line_attributes (view->gc, 1,
                              GDK_LINE_SOLID, GDK_CAP_BUTT, GDK_JOIN_ROUND);
}
コード例 #29
0
static void draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop, GdkRectangle *rcClip)
  {
  int Nix, Nix1 ;
  GdkGC *gc = NULL ;
  GdkRectangle rcReal ;
  GdkPoint ptSrc, ptDst ;
  QCADRectangleElectrode *rc_electrode = QCAD_RECTANGLE_ELECTRODE (obj) ;
  GdkColor *clr = NULL ;

  world_to_real_rect (&(obj->bounding_box), &rcReal) ;

  if (!RECT_INTERSECT_RECT (rcReal.x, rcReal.y, rcReal.width, rcReal.height, rcClip->x, rcClip->y, rcClip->width, rcClip->height))
    return ;

  clr = obj->bSelected ? clr_idx_to_clr_struct (RED) : &(obj->clr) ;
  gc = gdk_gc_new (dst) ;
  gdk_gc_set_foreground (gc, clr) ;
  gdk_gc_set_background (gc, clr) ;
  gdk_gc_set_function (gc, rop) ;
  gdk_gc_set_clip_rectangle (gc, rcClip) ;

  ptSrc.x = world_to_real_x (rc_electrode->precompute_params.pt[0].xWorld) ;
  ptSrc.y = world_to_real_y (rc_electrode->precompute_params.pt[0].yWorld) ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[1].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[1].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;
  ptSrc = ptDst ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[2].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[2].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;
  ptSrc = ptDst ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[3].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[3].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;
  ptSrc = ptDst ;
  ptDst.x = world_to_real_x (rc_electrode->precompute_params.pt[0].xWorld) ;
  ptDst.y = world_to_real_y (rc_electrode->precompute_params.pt[0].yWorld) ;
  gdk_draw_line (dst, gc, ptSrc.x, ptSrc.y, ptDst.x, ptDst.y) ;

  for (Nix = 0 ; Nix < rc_electrode->n_x_divisions ; Nix++)
    for (Nix1 = 0 ; Nix1 < rc_electrode->n_y_divisions ; Nix1++)
      {
      ptSrc.x = world_to_real_x (exp_array_index_2d (rc_electrode->precompute_params.pts, WorldPoint, Nix1, Nix).xWorld) ;
      ptSrc.y = world_to_real_y (exp_array_index_2d (rc_electrode->precompute_params.pts, WorldPoint, Nix1, Nix).yWorld) ;
      if (PT_IN_RECT (ptSrc.x, ptSrc.y, rcClip->x, rcClip->y, rcClip->width, rcClip->height))
        gdk_draw_point (dst, gc, ptSrc.x, ptSrc.y) ;
      }

  g_object_unref (gc) ;
  }
コード例 #30
0
static void draw (QCADDesignObject *obj, GdkDrawable *dst, GdkFunction rop)
  {
  GdkGC *gc = NULL ;
  char *pszFont = NULL ;
  GdkRectangle rc = {0} ;
  GdkRectangle rcDst = {0} ;
  GdkRectangle rcDraw = {0} ;
  QCADLabel *label = NULL ;

  if ((label = QCAD_LABEL (obj))->bShrinkWrap)
    qcad_label_shrinkwrap (label) ;

  world_to_real_rect (&(obj->bounding_box), &rc) ;
  gdk_drawable_get_size (dst, &(rcDst.width), &(rcDst.height)) ;
  if (!gdk_rectangle_intersect (&rc, &rcDst, &rcDraw)) return ;

  gc = gdk_gc_new (dst) ;
  gdk_gc_set_function (gc, rop) ;
  gdk_gc_set_clip_rectangle (gc, &rc) ;
  if (GDK_COPY == rop)
    {
    gdk_gc_set_foreground (gc, obj->bSelected ? &(QCAD_DESIGN_OBJECT_GET_CLASS (obj)->clrSelected) : &(obj->clr)) ;
    draw_string (dst, gc, pszFont = g_strdup_printf ("Courier %d", world_to_real_cy (CYFONT)),
      rc.x + XTOP_LABEL_OFFSET, rc.y + YTOP_LABEL_OFFSET, label->psz) ;
    g_free (pszFont) ;
    }
  else
    {
    if (label->bNeedsEPMDraw)
      {
      GdkGC *gcEPM = NULL ;

      label->bNeedsEPMDraw = FALSE ;
      label->epm = exp_pixmap_cond_new (label->epm, dst, rcDraw.width, rcDraw.height, -1) ;
      exp_pixmap_clean (label->epm) ;
      gcEPM = gdk_gc_new (label->epm->pixmap) ;
      gdk_gc_set_foreground (gcEPM, obj->bSelected ? &(QCAD_DESIGN_OBJECT_GET_CLASS (obj)->clrSelected) : &(obj->clr)) ;
      draw_string (label->epm->pixmap, gcEPM, pszFont = g_strdup_printf ("Courier %d", world_to_real_cy (CYFONT)),
        XTOP_LABEL_OFFSET, YTOP_LABEL_OFFSET, label->psz) ;
      g_free (pszFont) ;
      g_object_unref (gcEPM) ;
      }
    gdk_draw_drawable (dst, gc, label->epm->pixmap, 0, 0, rc.x, rc.y, rcDraw.width, rcDraw.height) ;
    }

  if (obj->bSelected)
    gdk_draw_rectangle (dst, gc, FALSE, rc.x, rc.y, rc.width - 1, rc.height - 1) ;
  gdk_gc_unref (gc) ;
  }