Example #1
0
/**
* @brief Callback when subrxFrequencyDisplay is created
*
* @param widget
* @param event
*
* @return
*/
gboolean subrxFrequencyDisplayConfigure(GtkWidget* widget,GdkEventConfigure* event) {
    GdkGC* gc;
    PangoContext *context;
    PangoLayout *layout;
    char temp[128];

    if(subrxPixmap) g_object_unref(subrxPixmap);

    subrxPixmap=gdk_pixmap_new(widget->window,widget->allocation.width,widget->allocation.height,-1);

    gc=gdk_gc_new(widget->window);
    gdk_gc_set_rgb_fg_color(gc,&background);
    gdk_draw_rectangle(subrxPixmap,
                       gc,
                       TRUE,
                       0,0,
                       widget->allocation.width,
                       widget->allocation.height);

    context = gdk_pango_context_get_for_screen(gdk_screen_get_default ());
    layout = pango_layout_new(context);
    pango_layout_set_width(layout,widget->allocation.width*PANGO_SCALE);
    pango_layout_set_alignment(layout,PANGO_ALIGN_RIGHT);
#ifdef NETBOOK
    sprintf(temp,"<span foreground='%s' background='#2C2C2C' font_desc='Sans Bold 12'>% 7lld.%03lld.%03lld </span>",subrx?"#00FF00":"#C0C0C0",subrxFrequency/1000000LL,(subrxFrequency%1000000LL)/1000LL,subrxFrequency%1000LL);
#else
    sprintf(temp,"<span foreground='%s' background='#2C2C2C' font_desc='Sans Bold 24'>% 7lld.%03lld.%03lld </span>",subrx?"#00FF00":"#C0C0C0",subrxFrequency/1000000LL,(subrxFrequency%1000000LL)/1000LL,subrxFrequency%1000LL);
#endif
    pango_layout_set_markup(layout,temp,-1);
    gdk_draw_layout(GDK_DRAWABLE(subrxPixmap),gc,0,0,layout);

    gdk_gc_set_rgb_fg_color(gc,&grey);
    gdk_draw_rectangle(subrxPixmap,
                       gc,
                       FALSE,
                       0,0,
                       widget->allocation.width-1,
                       widget->allocation.height-1);

    g_object_unref(context);
    g_object_unref(layout);
    g_object_unref(gc);

    return TRUE;
}
Example #2
0
static void drawTest(Ihandle *ih)
{
    GdkWindow* wnd = (GdkWindow*)IupGetAttribute(ih, "DRAWABLE");
    GdkGC* gc = gdk_gc_new(wnd);
    int w = IupGetInt(ih, "PREVIEWWIDTH");
    int h = IupGetInt(ih, "PREVIEWHEIGHT");
    GdkColor color;

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

    gdk_draw_line(wnd, gc, 0, 0, w-1, h-1);
    gdk_draw_line(wnd, gc, 0, h-1, w-1, 0);

    g_object_unref(gc);
}
Example #3
0
extern "C" void svm_toy_initialize()
{
	gboolean success[7];

	gdk_colormap_alloc_colors(
		gdk_colormap_get_system(),
		colors,
		7,
		FALSE,
		TRUE,
		success);

	gc = gdk_gc_new(draw_main->window);
	pixmap = gdk_pixmap_new(draw_main->window,XLEN,YLEN,-1);
	gdk_gc_set_foreground(gc,&colors[0]);
	gdk_draw_rectangle(pixmap,gc,TRUE,0,0,XLEN,YLEN);
	gtk_entry_set_text(GTK_ENTRY(entry_option),DEFAULT_PARAM);
}
Example #4
0
static int setup_fonts(void)
{
  int width, height;
  GdkDrawable *drawable=GDK_DRAWABLE(gtk_widget_get_root_window(GTK_WIDGET(GLOBALS->mainwindow)));
  GdkScreen *fonts_screen = gdk_drawable_get_screen (drawable);
  GLOBALS->fonts_renderer = gdk_pango_renderer_get_default (fonts_screen);
  gdk_pango_renderer_set_drawable (GDK_PANGO_RENDERER (GLOBALS->fonts_renderer), drawable);

  GLOBALS->fonts_gc = gdk_gc_new (drawable);
  gdk_pango_renderer_set_gc (GDK_PANGO_RENDERER (GLOBALS->fonts_renderer), GLOBALS->fonts_gc);

  gdk_drawable_get_size (drawable, &width, &height);

  GLOBALS->fonts_context = gdk_pango_context_get_for_screen (fonts_screen);
  GLOBALS->fonts_layout = pango_layout_new (GLOBALS->fonts_context);

  return 0;
}
Example #5
0
static void
mt_main_draw_line (MTClosure *mt, gint x1, gint y1, gint x2, gint y2)
{
    GdkWindow *root;
    GdkGC *gc;

    root = gdk_screen_get_root_window (mt_main_current_screen (mt));
    gc = gdk_gc_new (root);
    gdk_gc_set_subwindow (gc, GDK_INCLUDE_INFERIORS);
    gdk_gc_set_function (gc, GDK_INVERT);
    gdk_gc_set_line_attributes (gc, 1,
				GDK_LINE_SOLID,
				GDK_CAP_ROUND,
				GDK_JOIN_ROUND);
    gdk_draw_arc (root, gc, TRUE, x1 - 4, y1 - 4, 8, 8, 0, 23040);
    gdk_draw_line (root, gc, x1, y1, x2, y2);
    g_object_unref (gc);
}
Example #6
0
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;
}
Example #7
0
void
GtkAggGlue::render(int minx, int miny, int maxx, int maxy)
{
     if (!_offscreenbuf) {
         return;
     }

     const int& x = minx;
     const int& y = miny;
     size_t width = std::min(_offscreenbuf->width, maxx - minx);
     size_t height = std::min(_offscreenbuf->height, maxy - miny);

     GdkGC* gc = gdk_gc_new(_drawing_area->window);
    
     gdk_draw_image(_drawing_area->window, gc, _offscreenbuf, x, y, x, y, width,
                    height);
     gdk_gc_unref(gc);
}
Example #8
0
gboolean whiteb_expose_event(GtkWidget *white_board, GdkEventExpose *ev, gpointer user_data)
{
	struct question *question_data = user_data;
	if(whiteb_image == NULL)
	{
		/* Load the image */
		whiteb_image = rsvg_pixbuf_from_file_at_size(g_strdup_printf("questions/%s/%s/%s/%s/%s/%s",question_data->group,question_data->level,question_data->type,question_data->topic,question_data->stopic,question_data->filename),768,576, NULL);
		if(whiteb_image!=NULL)
		{
			GdkPixmap *question_map = gdk_pixmap_new(NULL,768,576,24);
			draw_fill_a_buffer(question_map);
			gdk_draw_pixbuf(question_map,gdk_gc_new(question_map),whiteb_image,0,0,0,0,768,576,GDK_RGB_DITHER_NONE,0,0);
			draw_set_original(question_map);
		}
	}
	draw_sync_buffers(white_board);
	return 0;
}
_HYPlatformGraphicPane::_HYPlatformGraphicPane(int h, int w, int d)
{
	fillColor = (GdkColor){0,0,0,0};
	//printf ("Allocating pixmap\n");
	thePane = gdk_pixmap_new (NULL, w, h, 24/*d<24?d:24*/);
	//printf ("Allocating context\n");
	theContext   = gdk_gc_new (thePane);
	//printf ("Allocating context\n");
	textLayout   = pango_layout_new (screenPContext);
	theFont		 = pango_font_description_new ();
	//printf ("Setting colormaps\n");
	gdk_drawable_set_colormap (thePane, gdk_colormap_get_system ()); // ?
	gdk_gc_set_colormap (theContext, gdk_colormap_get_system ()); // ?
	
	charCachePangoItems   = NULL;
	for (long k=0; k<=60; k=k+1)
		cachedCharacterGlyphs[k] = NULL;
}
/* Draw the exon view */
static void drawExonView(GtkWidget *exonView, GdkDrawable *drawable)
{
  DEBUG_ENTER("drawExonView");
  
  ExonViewProperties *properties = exonViewGetProperties(exonView);
  DotterContext *dc = properties->dc;

  GdkGC *gc = gdk_gc_new(drawable);

  /* Set a clip rectangle for drawing the exons and introns (because they are drawn "over the
   * edges" to make sure intron lines have the correct slope etc.) */
  gdk_gc_set_clip_origin(gc, 0, 0);
  gdk_gc_set_clip_rectangle(gc, &properties->exonViewRect);
  
  /* Draw the exons and introns. Since we could have a lot of them in the loop, extract all the
   * info we need now and pass it around so we don't have to look for this stuff each time. */
  
  DrawData drawData = {
    properties->parent,
    drawable,
    gc,
    properties->dc,
    properties->dwc,
    
    &properties->exonViewRect,
    properties->qRange,
    
    properties->yPad,
    properties->horizontal ? properties->exonViewRect.y : properties->exonViewRect.x,
    properties->exonHeight,

    properties->strand,
    properties->horizontal,
    properties->bumped,
    FALSE
  };
  
  /* Loop through all sequences, drawing all msps that are exons/introns */
  GList *seqList = dc->seqList;
  g_list_foreach(seqList, drawExonIntronItem, &drawData);

  g_object_unref(gc);
  DEBUG_EXIT("drawExonView returning ");
}
Example #11
0
void eplay_load_image()
{

	if (im) {
		gdk_imlib_kill_image(im);
		im = NULL;
	}

	if(!p[image_idx]) {
		im = gdk_imlib_load_image(image_names[image_idx]);
	}


	if (first) {
		w = org_w = im->rgb_width;
		h = org_h = im->rgb_height;
		win_x = (screen_x - w) / 2;
		win_y = (screen_y - h) / 2;
		attr.window_type = GDK_WINDOW_TEMP;
		attr.wclass = GDK_INPUT_OUTPUT;
		attr.event_mask = GDK_ALL_EVENTS_MASK;
		attr.x = attr.y = 0;
		attr.width = screen_x;
		attr.height = screen_y;
		parent = NULL;
		win = gdk_window_new(parent, &attr, ATTRIBUTES_MASK);
		gdk_window_show(win);
		gc = gdk_gc_new(win);
		first = 0;
		gdk_window_set_background(win, &color_bg);
		gdk_keyboard_grab(win, FALSE, CurrentTime);
		gdk_pointer_grab(win, FALSE, event_mask, NULL, cursor, CurrentTime);
		gdk_window_set_hints(win, win_x, win_y, w, h, w, h, GDK_HINT_MIN_SIZE |
							 GDK_HINT_MAX_SIZE | GDK_HINT_POS);
	}
/*	gdk_imlib_free_pixmap(p[image_idx]);  */  /* killing old pixmap */
	if(!p[image_idx]) {
		gdk_imlib_render(im, w, h);     /* Imlib render ... */
		p[image_idx] = gdk_imlib_move_image(im);    /* creating new */
	}

	gdk_draw_pixmap(win, gc, p[image_idx], 0, 0, win_x, win_y, w, h);
	gdk_window_show(win);       /* display image */
}
Example #12
0
/**
* @brief update vfo b display
*
* @param widget
* @param event
*
* @return
*/
void updateVfoBDisplay() {
    GdkGC* gc;
    PangoContext *context;
    PangoLayout *layout;
    char temp[128];

    if(vfoBFrequency->window) {
        gc=gdk_gc_new(vfoBFrequency->window);
        gdk_gc_set_rgb_fg_color(gc,&background);
        gdk_draw_rectangle(vfoBPixmap,
                           gc,
                           TRUE,
                           0,0,
                           vfoBFrequency->allocation.width,
                           vfoBFrequency->allocation.height);

        context = gdk_pango_context_get_for_screen (gdk_screen_get_default ());
        layout = pango_layout_new (context);
        pango_layout_set_width(layout,vfoBFrequency->allocation.width*PANGO_SCALE);
        pango_layout_set_alignment(layout,PANGO_ALIGN_RIGHT);
#ifdef NETBOOK
        sprintf(temp,"<span foreground='%s' background='#2C2C2C' font_desc='Sans Bold 12'>% 7lld.%03lld.%03lld </span>",bTransmitting?"#FF0000":"#C0C0C0",frequencyB/1000000LL,(frequencyB%1000000LL)/1000LL,frequencyB%1000LL);
#else
        sprintf(temp,"<span foreground='%s' background='#2C2C2C' font_desc='Sans Bold 20'>% 7lld.%03lld.%03lld </span>",bTransmitting?"#FF0000":"#C0C0C0",frequencyB/1000000LL,(frequencyB%1000000LL)/1000LL,frequencyB%1000LL);
#endif

        pango_layout_set_markup(layout,temp,-1);
        gdk_draw_layout(GDK_DRAWABLE(vfoBPixmap),gc,0,0,layout);

        gdk_gc_set_rgb_fg_color(gc,&grey);
        gdk_draw_rectangle(vfoBPixmap,
                           gc,
                           FALSE,
                           0,0,
                           vfoBFrequency->allocation.width-1,
                           vfoBFrequency->allocation.height-1);

        g_object_unref(context);
        g_object_unref(layout);
        g_object_unref(gc);

        gtk_widget_queue_draw(vfoBFrequency);
    }
}
gboolean expose_event_top_left(GtkWidget *widget,GdkEventExpose *event, gpointer user){

	static GdkGC		*this_gc = NULL;

	TimeLinePrivate		*priv;
	priv = (TimeLinePrivate *)user;
	if(priv->top_left_evb->window == NULL || priv->display_buffer_top_left == NULL){

	}
	if (NULL == this_gc)
	{
		this_gc = gdk_gc_new(GDK_DRAWABLE(priv->top_left_evb->window));
	}

	gdk_draw_drawable(GDK_DRAWABLE(priv->top_left_evb->window), GDK_GC(this_gc),
	GDK_PIXMAP(priv->display_buffer_top_left),0, 0,	0, 0,priv->left_border_width, priv->top_border_height);
	//gtk_widget_modify_bg(GTK_WIDGET(priv->top_left_evb),GTK_STATE_NORMAL,&entireRowColor);
	return TRUE;
}
Example #14
0
int ink_setDrawable(GdkDrawable *pDrawable)
{
    //avoiding duplicated efforts
    if(pCurrDrawable==pDrawable) return 0;

    pCurrDrawable=pDrawable;

    if(pCurrGDKGC)
        g_object_unref(pCurrGDKGC);

    pCurrGDKGC=gdk_gc_new(pDrawable);
    if(NULL==pCurrGDKGC)
    {
        SB_INKERRPRINTF("error when create GDKGC\n");
        return -1;
    }
    SB_INKPRINTF("create gdk gc successfully\n");
    return 0;
}
Example #15
0
/**
 * gwy_vector_layer_setup_gc:
 * @layer: A vector data view layer.
 *
 * Sets up Gdk graphic context of the vector layer for its parent window.
 *
 * This function is intended only for layer implementation.
 **/
void
gwy_vector_layer_setup_gc(GwyVectorLayer *layer)
{
    GtkWidget *parent;
    GdkColor fg, bg;

    g_return_if_fail(GWY_IS_VECTOR_LAYER(layer));
    parent = GWY_DATA_VIEW_LAYER(layer)->parent;
    if (!GTK_WIDGET_REALIZED(parent))
        return;

    if (!layer->gc)
        layer->gc = gdk_gc_new(parent->window);
    gdk_gc_set_function(layer->gc, GDK_XOR);
    fg.pixel = 0xFFFFFFFF;  /* FIXME */
    bg.pixel = 0x00000000;  /* FIXME */
    gdk_gc_set_foreground(layer->gc, &fg);
    gdk_gc_set_background(layer->gc, &bg);
}
int iniciar(const char **argumentos) {
    PON_ERROR("Iniciando filtro de gestos...\n");
      filtro= new Filtro();

      // Iniciar la ventana de visualizaciĆ³n
      ventana = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    gtk_window_set_title(GTK_WINDOW(ventana),
		       "Imagen filtrada");   
    gtk_window_set_default_size (GTK_WINDOW(ventana), 320, 240);		
    
    
    g_signal_connect((gpointer) ventana, "delete_event",
		     G_CALLBACK(cerrar_ventana), 0);
    gtk_widget_show(ventana);
    gc =gdk_gc_new (ventana->window);

	return 0;
}
Example #17
0
/* Redraw the screen from the backing pixmap */
static gint expose_event( GtkWidget      *widget,
                          GdkEventExpose *event )
{
  static GdkGC *copy_gc = NULL;

  if (copy_gc == NULL) {
    copy_gc = gdk_gc_new(widget->window);
  }

  gdk_draw_rgb_image(widget->window,
		     copy_gc,
		     event->area.x, event->area.y,
		     event->area.width, event->area.height,
		     GDK_RGB_DITHER_NONE,
		     rgbdata + event->area.x*3+event->area.y*3*width,
		     width*3 );

  return FALSE;
}
Example #18
0
static void
drawWindow(InstanceData* instanceData, GdkDrawable* gdkWindow)
{
  NPWindow window = instanceData->window;
  int x = window.x;
  int y = window.y;
  int width = window.width;
  int height = window.height;

  NPP npp = instanceData->npp;
  if (!npp)
    return;

  const char* uaString = sBrowserFuncs->uagent(npp);
  if (!uaString)
    return;

  GdkGC* gdkContext = gdk_gc_new(gdkWindow);

  // draw a grey background for the plugin frame
  GdkColor grey;
  grey.red = grey.blue = grey.green = 32767;
  gdk_gc_set_rgb_fg_color(gdkContext, &grey);
  gdk_draw_rectangle(gdkWindow, gdkContext, TRUE, x, y, width, height);

  // draw a 3-pixel-thick black frame around the plugin
  GdkColor black;
  black.red = black.green = black.blue = 0;
  gdk_gc_set_rgb_fg_color(gdkContext, &black);
  gdk_gc_set_line_attributes(gdkContext, 3, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
  gdk_draw_rectangle(gdkWindow, gdkContext, FALSE, x + 1, y + 1,
                     width - 3, height - 3);

  // paint the UA string
  PangoContext* pangoContext = gdk_pango_context_get();
  PangoLayout* pangoTextLayout = pango_layout_new(pangoContext);
  pango_layout_set_width(pangoTextLayout, (width - 10) * PANGO_SCALE);
  pango_layout_set_text(pangoTextLayout, uaString, -1);
  gdk_draw_layout(gdkWindow, gdkContext, x + 5, y + 5, pangoTextLayout);
  g_object_unref(pangoTextLayout);

  g_object_unref(gdkContext);
}
Example #19
0
void quote_view_theme_changed(QuoteView * qv)
{
	int width, height;
	GdkPixmap *pixmap;
	GdkGC *gc;
	QuoteInfo *quote;

	if (!qv->with_maritime)
		return;

	gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height);

	pixmap =
	    gdk_pixmap_new(qv->quotes->window, width, height,
			   gtk_widget_get_visual(qv->quotes)->depth);

	gc = gdk_gc_new(pixmap);
	gdk_gc_set_foreground(gc, &black);
	gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height);
	gdk_gc_set_fill(gc, GDK_TILED);
	gdk_gc_set_tile(gc, theme_get_terrain_pixmap(SEA_TERRAIN));
	gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height);
	if (maritime_pixbuf)
		g_object_unref(maritime_pixbuf);
	maritime_pixbuf =
	    gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0,
					 -1, -1);
	g_object_unref(gc);
	g_object_unref(pixmap);

	/* Remove all maritime quotes */
	quote = quotelist_first(qv->quote_list);
	while (quote != NULL) {
		QuoteInfo *curr = quote;
		quote = quotelist_next(quote);
		if (curr->is_domestic)
			break;
		remove_quote(qv, curr);
	}

	/* Add all of the maritime trades that can be performed */
	check_maritime_trades(qv);
}
Example #20
0
// redraw part of screen
static gboolean
da_expose_event	(GtkWidget *widget,
                 GdkEventExpose *event)
{
    GdkGC *gc;
    GdkColor color;
    color.red=65535;
    color.blue=65535;
    color.green=65535;
    gc = gdk_gc_new(widget->window);
    gdk_gc_set_rgb_fg_color(gc, &color);
    gdk_draw_drawable(widget->window,
                      widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
                      pixmap,
                      event->area.x, event->area.y,
                      event->area.x, event->area.y,
                      event->area.width, event->area.height);
    return FALSE;
}
Example #21
0
/** \brief concatenate two pixmaps
 *
 * horizontal concatenation
 * @param window
 * @param dest destination pixmap
 * @param s1 first pixmap
 * @param s2 second pixmap
 * @returns dest for convenience
 */
struct pixmap* cat_pixmaps (GtkWidget *window, struct pixmap *dest, struct pixmap* s1, struct pixmap* s2)
{
  GdkGC *white_gc;
  int h1, w1, h2, w2;

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

  gdk_window_get_size (s1->pix, &w1, &h1);
  gdk_window_get_size (s2->pix, &w2, &h2);

  dest->pix  = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), -1);
  dest->mask = gdk_pixmap_new (window->window, w1 + w2, MAX (h1, h2), 1);

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

  if (!masks_gc) {
    masks_gc = gdk_gc_new (dest->mask);
    gdk_gc_set_exposures (masks_gc, FALSE);
  }

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

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

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, s1->mask);
  gdk_draw_pixmap (dest->pix, white_gc, s1->pix, 0, 0, 0, 0, w1, h1);
  gdk_draw_pixmap (dest->mask, masks_gc, s1->mask, 0, 0, 0, 0, w1, h1);

  gdk_gc_set_clip_origin (white_gc, w1, 0);
  gdk_gc_set_clip_mask (white_gc, s2->mask);
  gdk_draw_pixmap (dest->pix, white_gc, s2->pix, 0, 0, w1, 0, w2, h2);
  gdk_draw_pixmap (dest->mask, masks_gc, s2->mask, 0, 0, w1, 0, w2, h2);

  gdk_gc_set_clip_origin (white_gc, 0, 0);
  gdk_gc_set_clip_mask (white_gc, NULL);

  return dest;
}
Example #22
0
//__________________________________________________________________
void        _HYPlatformPullDown::_Paint (Ptr p)
{
    _HYPullDown * theParent = (_HYPullDown*)this;

    GdkRectangle        cRect = HYRect2GDKRect(*(_HYRect*)p);
    _RefreshComboBox();
    if (!(theParent->settings.width&HY_COMPONENT_TRANSP_BG)) {
        if (theParent->parentWindow->window) {
            GdkGC *buttonGC              = gdk_gc_new (theParent->parentWindow->window);
            gdk_gc_set_foreground(buttonGC,&backFill);
            gdk_draw_rectangle(theParent->parentWindow->window,buttonGC,true,cRect.x+theParent->parentWindow->allocation.x,
                               cRect.y+theParent->parentWindow->allocation.y, cRect.width, cRect.height);
            g_object_unref (buttonGC);
        }
    }


    (*theParent)._HYPlatformComponent::_Paint(p);
}
static gboolean touchscreen_callback(GtkWidget *widget, GdkEventMotion *event)
{
	GdkGC *gc;
	PangoLayout *layout;
	char buf[64];

	sprintf(buf, "<span size=\"30000\">[%d, %d]</span>",
		(int)event->x, (int)event->y);
	gdk_window_clear(widget->window);
	gc = gdk_gc_new(widget->window);

	layout = gtk_widget_create_pango_layout(widget, "");
	pango_layout_set_markup(layout, buf, -1);
	gdk_draw_layout(widget->window, gc, 80, 80, layout);
	g_object_unref(layout);
	gdk_gc_destroy(gc);

	return TRUE;
}
Example #24
0
void 
undo_create_mask ( gint width, gint height, GdkBitmap **mask, GdkGC **gc_mask )
{
    GdkColor    color;
	gp_canvas   *cv	=	cv_get_canvas();
     
    *mask 		=	gdk_pixmap_new (NULL, width, height, 1 );
    *gc_mask	=	gdk_gc_new ( *mask );
    gdk_gc_set_line_attributes ( *gc_mask, cv->line_width, GDK_LINE_SOLID, 
                             	 GDK_CAP_ROUND, GDK_JOIN_ROUND );

    color.pixel = 0;
    gdk_gc_set_foreground (*gc_mask, &color);
    gdk_draw_rectangle (*mask, *gc_mask, TRUE, 0, 0, width, height);

    color.pixel = 1;
    gdk_gc_set_foreground (*gc_mask, &color);
    return;
}
Example #25
0
static GdkPixmap *
scale_pixmap (GdkWindow *window, GdkPixmap *pixmap, gdouble scale_x, gdouble scale_y)
{
  GdkGC *gc = NULL;
  GdkPixmap *new_pixmap;
  gint width, height, new_width, new_height;
  GdkPixbuf *pixbuf = NULL;
  GdkPixbuf *aux_pixbuf = NULL;

  if(!pixmap) return NULL;
  if(!window) return NULL;

  gdk_window_get_size(pixmap, &width, &height);

  gc = gdk_gc_new(window);

  if(scale_x == 1.0 && scale_y == 1.0){
    new_pixmap = gdk_pixmap_new(window, width, height, -1);
    gdk_draw_pixmap(new_pixmap,
                    gc,
                    pixmap,
                    0, 0,
                    0, 0,
                    width, height);
    gdk_gc_unref(gc);
    return new_pixmap;
  }

  new_width = roundint(width * scale_x);
  new_height = roundint(height * scale_y);

  pixbuf = gdk_pixbuf_get_from_drawable(NULL, pixmap, gdk_drawable_get_colormap(window), 0, 0, 0, 0, width, height);
  aux_pixbuf = gdk_pixbuf_scale_simple(pixbuf, new_width, new_height, GDK_INTERP_BILINEAR);
  new_pixmap = gdk_pixmap_new(pixmap, new_width, new_height, -1);
  gdk_draw_pixbuf(new_pixmap, gc, aux_pixbuf, 0, 0, 0, 0, new_width, new_height, GDK_RGB_DITHER_MAX, 0, 0);

  gdk_pixbuf_unref(pixbuf);
  gdk_pixbuf_unref(aux_pixbuf);

  gdk_gc_unref(gc);

  return new_pixmap;
}
Example #26
0
File: panel.c Project: g7/fbpanel
static void
make_round_corners(panel *p)
{
    GdkBitmap *b;
    GdkGC* gc;
    GdkColor black = { 0, 0, 0, 0};
    GdkColor white = { 1, 0xffff, 0xffff, 0xffff};
    int w, h, r, br;

    ENTER;
    w = p->aw;
    h = p->ah;
    r = p->round_corners_radius;
    if (2*r > MIN(w, h)) {
        r = MIN(w, h) / 2;
        DBG("chaning radius to %d\n", r);
    }
    if (r < 4) {
        DBG("radius too small\n");
        RET();
    }
    b = gdk_pixmap_new(NULL, w, h, 1);
    gc = gdk_gc_new(GDK_DRAWABLE(b));
    gdk_gc_set_foreground(gc, &black);
    gdk_draw_rectangle(GDK_DRAWABLE(b), gc, TRUE, 0, 0, w, h);
    gdk_gc_set_foreground(gc, &white);
    gdk_draw_rectangle(GDK_DRAWABLE(b), gc, TRUE, r, 0, w-2*r, h);
    gdk_draw_rectangle(GDK_DRAWABLE(b), gc, TRUE, 0, r, r, h-2*r);
    gdk_draw_rectangle(GDK_DRAWABLE(b), gc, TRUE, w-r, r, r, h-2*r);

    br = 2 * r;
    gdk_draw_arc(GDK_DRAWABLE(b), gc, TRUE, 0, 0, br, br, 0*64, 360*64);
    gdk_draw_arc(GDK_DRAWABLE(b), gc, TRUE, 0, h-br-1, br, br, 0*64, 360*64);
    gdk_draw_arc(GDK_DRAWABLE(b), gc, TRUE, w-br, 0, br, br, 0*64, 360*64);
    gdk_draw_arc(GDK_DRAWABLE(b), gc, TRUE, w-br, h-br-1, br, br, 0*64, 360*64);

    gtk_widget_shape_combine_mask(p->topgwin, b, 0, 0);
    g_object_unref(gc);
    g_object_unref(b);

    RET();
}
Example #27
0
GdkPixbuf *text_to_gtk_pixbuf (gchar *text) 
{	
	GtkWidget *scratch = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_realize (scratch); 
	//GtkStyle *style = gtk_widget_get_style(scratch);
	//gchar *bgcolor = gdk_color_to_string(&style->bg[GTK_STATE_NORMAL]);
	//gchar *textcolor = gdk_color_to_string(&style->text[GTK_STATE_NORMAL]);
	PangoLayout *layout = gtk_widget_create_pango_layout (scratch, NULL); 
	//g_object_unref(style);
	gtk_widget_destroy (scratch);

	//gchar *markup = g_strdup_printf ("<span bgcolor='%s' color='%s'>%s</span>", bgcolor, textcolor, text); 
	//gchar *markup = g_strdup_printf ("<span color='%s'>%s</span>", textcolor, text); 
	gchar *markup = g_strdup_printf ("%s", text);
	pango_layout_set_markup (layout, markup, -1); 
	g_free (markup);
	//g_free (bgcolor);
	//g_free (textcolor);

	int width = 0;
	int heigth = 0;
	pango_layout_get_size (layout, &width, &heigth);
	width = width/PANGO_SCALE;
	heigth = heigth/PANGO_SCALE;

	GdkPixbuf *pb = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, heigth);
	gdk_pixbuf_fill(pb, 0xffffffff);
	
	GdkPixmap *pm = gdk_pixmap_new (NULL, width, heigth, 24);
	GdkGC *gc = gdk_gc_new (pm); 
	gdk_draw_pixbuf (pm, gc, pb, 0, 0, 0, 0, width, heigth, GDK_RGB_DITHER_NONE, 0, 0);
	
	gdk_draw_layout (pm, gc, 0, 0, layout);


	g_object_unref(layout);
	g_object_unref(gc);

	GdkPixbuf *ret = gdk_pixbuf_get_from_drawable (NULL, pm, NULL, 0, 0, 0, 0, width, heigth);
	g_object_unref(pb);
	return ret;
}
Example #28
0
/*
 * Aperture macro primitive 1 (Circle)
 */
static void
gerbv_gdk_draw_prim1(GdkPixmap *pixmap, GdkGC *gc, double *p, 
		     double scale, gint x, gint y)
{
    const int exposure_idx = 0;
    const int diameter_idx = 1;
    const int x_offset_idx = 2;
    const int y_offset_idx = 3;
    const gint full_circle = 23360;
    GdkGC *local_gc = gdk_gc_new(pixmap);
    gint dia    = round(fabs(p[diameter_idx] * scale));
    gint real_x = x - dia / 2;
    gint real_y = y - dia / 2;
    GdkColor color;

    gdk_gc_copy(local_gc, gc);

    real_x += (int)(p[x_offset_idx] * (double)scale);
    real_y -= (int)(p[y_offset_idx] * (double)scale);

    /* Exposure */
    if (p[exposure_idx] == 0.0) {
	color.pixel = 0;
	gdk_gc_set_foreground(local_gc, &color);
    }

    gdk_gc_set_line_attributes(local_gc, 
			       1, /* outline always 1 pixels */
			       GDK_LINE_SOLID, 
			       GDK_CAP_BUTT, 
			       GDK_JOIN_MITER);

    /* 
     * A filled circle 
     */
    gdk_draw_arc(pixmap, local_gc, 1, real_x, real_y, dia, dia, 
		 0, full_circle);

    gdk_gc_unref(local_gc);

    return;
} /* gerbv_gdk_draw_prim1 */
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_initState__II
  (JNIEnv *env, jobject obj, jint width, jint height)
{
  struct graphics *g;

  g = (struct graphics *) malloc (sizeof (struct graphics));
  g->x_offset = g->y_offset = 0;

  gdk_threads_enter ();
  g->drawable = (GdkDrawable *) gdk_pixmap_new (NULL, width, height, 
						gdk_rgb_get_visual ()->depth);
  g->cm = gdk_rgb_get_cmap ();
  gdk_colormap_ref (g->cm);
  g->gc = gdk_gc_new (g->drawable);

  gdk_threads_leave ();

  NSA_SET_PTR (env, obj, g);
}
Example #30
0
static void
show_crosshair (gboolean paint_new_location)
{
  render_priv *priv = gport->render_priv;
  GdkWindow *window = gtk_widget_get_window (gport->drawing_area);
  GtkStyle *style = gtk_widget_get_style (gport->drawing_area);
  gint x, y;
  static gint x_prev = -1, y_prev = -1;
  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);
    }
  x = DRAW_X (gport->crosshair_x);
  y = DRAW_Y (gport->crosshair_y);

  gdk_gc_set_foreground (xor_gc, &cross_color);

  if (x_prev >= 0 && !paint_new_location)
    draw_crosshair (xor_gc, x_prev, y_prev);

  if (x >= 0 && paint_new_location)
    {
      draw_crosshair (xor_gc, x, y);
      x_prev = x;
      y_prev = y;
    }
  else
    x_prev = y_prev = -1;
}