Example #1
0
/** Load/construct the images */
static void load_pixmaps(QuoteView * qv)
{
	static gboolean init = FALSE;
	int width, height;
	GdkPixmap *pixmap;
	GdkGC *gc;

	if (init)
		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_fill(gc, GDK_TILED);
	gdk_gc_set_tile(gc, theme_get_terrain_pixmap(SEA_TERRAIN));
	gdk_gc_set_foreground(gc, &black);
	gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, width, height);
	maritime_pixbuf =
	    gdk_pixbuf_get_from_drawable(NULL, pixmap, NULL, 0, 0, 0, 0,
					 -1, -1);
	g_object_unref(pixmap);
	g_object_unref(gc);

	cross_pixbuf =
	    gtk_widget_render_icon(qv->quotes, GTK_STOCK_CANCEL,
				   GTK_ICON_SIZE_MENU, NULL);

	init = TRUE;
}
Example #2
0
void make_background()
{
  if( background )
    g_object_unref( background );
  if( ! (*bg_filename &&
	 (background = gdk_pixmap_create_from_xpm( window->window, NULL, NULL, bg_filename ))) )
  {
    int i, j;
    background = gdk_pixmap_new( window->window, ws_width, ws_height, -1 );
    gdk_draw_rectangle( background, gc[bg], TRUE, 1, 1, ws_width, ws_height );

    /* draw the boundaries of the different viewports */
    if( vp_width < ws_width-1 || vp_height < ws_height-1 )
      for( i=1; i<ws_width; i+=vp_width )
	for( j=1; j<ws_height; j+=vp_height )
	  gdk_draw_rectangle( background, gc[vp_divider], FALSE,
			      i+1, j+1, vp_width-3, vp_height-3 );

    /* draw the workspace-boundary (repeated by tiling) */
    gdk_draw_line( background, gc[ws_divider], 0, 0, 0, ws_height );
    gdk_draw_line( background, gc[ws_divider], 1, 0, ws_width, 0 );
  }
  gdk_gc_set_fill( gc[bg], GDK_TILED );
  gdk_gc_set_tile( gc[bg], background );
}
Example #3
0
void SetUpStatusBarStuff (GtkWidget* aWindow)
{
	_String			   fName = baseDirectory & "GTKResources/striped.xpm";
	statusBarLayout			 = pango_layout_new (screenPContext);
	statusBarFontDesc		 = pango_font_description_new ();
	stripedFill				 = gdk_pixmap_create_from_xpm (GDK_DRAWABLE(aWindow->window), NULL, NULL, fName.sData);
	stripedFillGC			 = gdk_gc_new (GDK_DRAWABLE(aWindow->window));
	if (stripedFill)
	{
		gdk_gc_set_fill (stripedFillGC,GDK_TILED);
		gdk_gc_set_tile	(stripedFillGC,stripedFill);
	}
	else
	{
		printf ("Failed to load a status bar .xpm from %s\n", fName.sData);
	}
	
	gdk_gc_set_line_attributes		  (stripedFillGC, 1, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_MITER);
	GdkColor saveFG = {0,0,0,0};
	gdk_gc_set_foreground			  (stripedFillGC, &saveFG);

	pango_font_description_set_family (statusBarFontDesc, statusBarFont.face.sData);
	pango_font_description_set_style  (statusBarFontDesc, (statusBarFont.style & HY_FONT_ITALIC) ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL);
	pango_font_description_set_weight (statusBarFontDesc, (statusBarFont.style & HY_FONT_BOLD) ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL);
	pango_font_description_set_size   (statusBarFontDesc, statusBarFont.size*PANGO_SCALE);
	pango_layout_set_font_description (statusBarLayout, statusBarFontDesc ); // ref ?
	pango_layout_set_width			  (statusBarLayout, -1);
	
	redButtonIcon = (GdkPixbuf*)ProcureIconResource(4000);
	yellowButtonIcon = (GdkPixbuf*)ProcureIconResource(4001);
	greenButtonIcon = (GdkPixbuf*)ProcureIconResource(4002);
	orangeButtonIcon = (GdkPixbuf*)ProcureIconResource(4003);
	
}
Example #4
0
/* Set a tile pixmap for a graphics context.
 * This will only be used if the fill mode is GDK_TILED. */
int
clip_GDK_GCSETTILE(ClipMachine * cm)
{
	C_object  *cgc = _fetch_co_arg(cm);
	C_widget *cxpm = _fetch_cwidget(cm,_clip_spar(cm,2));
	CHECKCOBJ(cgc,GDK_IS_GC(cgc));
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cxpm,GTK_IS_PIXMAP);
	gdk_gc_set_tile(GDK_GC(cgc->object), GTK_PIXMAP(cxpm->widget)->pixmap);
	return 0;
err:
	return 1;
}
Example #5
0
/* do not use clip mask; only one tile under mask was drawn */
void
_zune_fill_tiled_rectangle(struct MUI_ImageSpec *img,
			   struct MUI_RenderInfo *mri,
			   LONG left, LONG top, LONG width, LONG height,
			   LONG xoffset, LONG yoffset)
{
    GdkPixmap *pixmap;

    g_return_if_fail((pixmap = __zune_imspec_get_pixmap(img)) != NULL);

    gdk_gc_set_fill(mri->mri_RastPort, GDK_TILED);
    gdk_gc_set_tile(mri->mri_RastPort, pixmap);
    gdk_gc_set_ts_origin(mri->mri_RastPort, xoffset, yoffset);

    gdk_draw_rectangle (mri->mri_Window, mri->mri_RastPort, TRUE,
			left, top, width, height);
    gdk_gc_set_fill(mri->mri_RastPort, GDK_SOLID);
    gdk_gc_set_ts_origin(mri->mri_RastPort, 0, 0);
}
Example #6
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 #7
0
/* charge un pixmap, si necessaire desalloue et/ou (re)alloue la couleur */
gboolean tansetpixmapmode(GtkWidget *widget, char *aname, int gcnbr){

  GdkPixmap *pixmap;
  GdkGC *gc;
  char *pname;
  gboolean ret;


  pixmap=tabpxpx[gcnbr];
  pname=tabpxnam[gcnbr];
  gc=tabgc[gcnbr];

  if (tabcolalloc[gcnbr]){
    gdk_colormap_free_colors (gdk_colormap_get_system(), &colortab[gcnbr], 1);
    tabcolalloc[gcnbr] = FALSE;
  }

  if (pixmap!=NULL)
    gdk_pixmap_unref(pixmap);

  ret=FALSE;
  if ( (pixmap=gdk_pixmap_create_from_xpm (widget->window, NULL, NULL, aname))!=NULL ){
    tanallocname(&pname,aname);
    gdk_gc_set_fill (gc, GDK_TILED);
    gdk_gc_set_tile (gc, pixmap);
    ret=TRUE;
  }

  if (pname==NULL)
    tanallocname(&pname,"LoadPixmapFailed");

  tabpxpx[gcnbr] = pixmap;
  tabpxnam[gcnbr] = pname;
  tabpxpixmode[gcnbr] = ret;

  if (!ret)
    tansetcolormode(&colortab[gcnbr],gcnbr);

  return (ret);

}
Example #8
0
File: cdgdk.c Project: LuaDist/cd
static int cdinteriorstyle(cdCtxCanvas *ctxcanvas, int style)
{
  GdkFill sty = GDK_SOLID;

  switch (style)
  {
    case CD_SOLID:
      sty = GDK_SOLID;
      break;

    case CD_HATCH :
      if (!ctxcanvas->last_hatch) 
        return ctxcanvas->canvas->interior_style;

      gdk_gc_set_stipple(ctxcanvas->gc, ctxcanvas->last_hatch);

      if (ctxcanvas->canvas->back_opacity == CD_OPAQUE)
        sty = GDK_OPAQUE_STIPPLED;
      else
        sty = GDK_STIPPLED;
      break;

    case CD_STIPPLE:
      gdk_gc_set_stipple(ctxcanvas->gc, ctxcanvas->last_stipple);

      if (ctxcanvas->canvas->back_opacity == CD_OPAQUE)
        sty = GDK_OPAQUE_STIPPLED;
      else
        sty = GDK_STIPPLED;
      break;

    case CD_PATTERN:
      gdk_gc_set_tile(ctxcanvas->gc, ctxcanvas->last_pattern);
      sty = GDK_TILED;
      break;
  }

  gdk_gc_set_fill(ctxcanvas->gc, sty);

  return style;
}
Example #9
0
void ZLGtkPaintContext::setFillColor(ZLColor color, FillStyle style) {
	if (style == SOLID_FILL) {
		::setColor(myFillGC, color);
		gdk_gc_set_fill(myFillGC, GDK_SOLID);
	} else {
		gdk_gc_set_fill(myFillGC, GDK_TILED);
		if (myPixmap != 0) {
			if (myTilePixmap != 0) {
				gdk_pixmap_unref(myTilePixmap);
			}
			static GdkColor fgColor;
			::setColor(fgColor, color);
			static GdkColor bgColor;
			::setColor(bgColor, myBackColor);
			static char data[] = { 0x0C, 0x0C, 0x03, 0x03 };
			myTilePixmap = gdk_pixmap_create_from_data(
				myPixmap, data, 4, 4, gdk_drawable_get_depth(myPixmap), &fgColor, &bgColor
			);
			gdk_gc_set_tile(myFillGC, myTilePixmap);
		}
	}
}
void _HYConsoleWindow::_PaintStatusBar(Ptr,bool force)
{
    if (GTK_WIDGET_MAPPED (theWindow)) {
        _Parameter      vL;
        checkParameter (VerbosityLevelString, vL, 0.0);

        if (vL<-0.5 && !force) {
            clock_t curMeasure = clock();
            _Parameter diff = 1.0/CLOCKS_PER_SEC*(curMeasure-lastMeasure);
            if (diff < -vL) {
                return;
            }
            lastMeasure = curMeasure;
        }

        if (!stripedFillGC) {
            SetUpStatusBarStuff (theWindow);
        }

        GdkRectangle wRC  = {0,0,theWindow->allocation.width,HY_SCROLLER_WIDTH},
                     w2RC;

        if (!_hyConsoleWindowGC) {
            _hyConsoleWindowGC   = gdk_gc_new     (theWindow->window);
            gdk_gc_set_tile (_hyConsoleWindowGC, stripedFill);
            gdk_gc_set_line_attributes(_hyConsoleWindowGC,1,GDK_LINE_SOLID,GDK_CAP_NOT_LAST,GDK_JOIN_MITER);
            _hyConsoleLayout = pango_layout_new (screenPContext);
            pango_layout_set_width (_hyConsoleLayout, -1);
            statusBarBold = pango_font_description_new ();
            statusBarNormal = pango_font_description_new ();
            _HYFont         consoleFont = {_HY_MONO_FONT,9,HY_FONT_PLAIN};
            HYFont2PangoFontDesc (consoleFont,statusBarNormal);
            consoleFont.style = HY_FONT_BOLD;
            HYFont2PangoFontDesc (consoleFont,statusBarBold);
        }

        GdkPixmap * offBitmap        = gdk_pixmap_new (theWindow->window, wRC.width, wRC.height,-1);

        if (offBitmap) {
            gdk_gc_set_fill         (_hyConsoleWindowGC,GDK_TILED);
            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,-1,-1,wRC.width+2,wRC.height+2);
            gdk_gc_set_fill         (_hyConsoleWindowGC,GDK_SOLID);
            gdk_gc_set_foreground   (_hyConsoleWindowGC,&_BLACKBRUSH_);
            gdk_draw_line(offBitmap,_hyConsoleWindowGC,0,0,wRC.width,0);

            pango_layout_set_font_description(_hyConsoleLayout,statusBarNormal);
            pango_layout_set_text(_hyConsoleLayout,fileName.getStr(),fileName.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,33,wRC.height-13,_hyConsoleLayout);

            if (inputStatus == 1) {
                pango_layout_set_text(_hyConsoleLayout,cInput.getStr(),cInput.sLength);
            } else {
                pango_layout_set_text(_hyConsoleLayout,action.getStr(),action.sLength);
            }

            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,193,wRC.height-13,_hyConsoleLayout);

            gdk_gc_set_foreground   (_hyConsoleWindowGC,&_DARKGREYBRUSH_);

            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,0,1,30,wRC.height-1);
            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,150,1,40,wRC.height-1);
            gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,wRC.width-55,1,55,wRC.height-1);

            gdk_gc_set_foreground   (_hyConsoleWindowGC,&_WHITEBRUSH_);
            pango_layout_set_font_description(_hyConsoleLayout,statusBarBold);

            pango_layout_set_text(_hyConsoleLayout,cState.getStr(),cState.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,3,wRC.height-13,_hyConsoleLayout);
            pango_layout_set_text(_hyConsoleLayout,cTask.getStr(),cTask.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,151,wRC.height-13,_hyConsoleLayout);

            pango_layout_set_font_description(_hyConsoleLayout,statusBarNormal);

            pango_layout_set_text(_hyConsoleLayout,timer.getStr(),timer.sLength);
            gdk_draw_layout(offBitmap,_hyConsoleWindowGC,wRC.width-53,wRC.height-13,_hyConsoleLayout);

            if (percentDone>0 || percentDone == -HY_SL_DONE) {
                GdkColor blackBrush = HYColorToGDKColor((_HYColor) {
                    80,80,80
                }),
                orangeBrush = HYColorToGDKColor((_HYColor) {
                    255,153,102
                });

                gdk_gc_set_foreground   (_hyConsoleWindowGC,&orangeBrush);
                gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,true,wRC.width-135,wRC.height-14,(percentDone>=0?percentDone:100.)*0.75,12);

                gdk_gc_set_foreground   (_hyConsoleWindowGC,&blackBrush);
                gdk_draw_rectangle      (offBitmap,_hyConsoleWindowGC,false,wRC.width-135,wRC.height-14,75,12);

                //gdk_gc_set_foreground (_hyConsoleWindowGC,&_WHITEBRUSH_);
                _String pLine;
                if (percentDone>=0) {
                    pLine = _String(percentDone)&"%";
                } else {
                    pLine = "DONE";
                }

                pango_layout_set_text(_hyConsoleLayout,pLine.getStr(),pLine.sLength);
                gdk_draw_layout(offBitmap,_hyConsoleWindowGC,wRC.width-107,wRC.height-13,_hyConsoleLayout);
            }
        }

        gdk_draw_drawable (theWindow->window, _hyConsoleWindowGC, offBitmap, 0, 0, theWindow->allocation.x, theWindow->allocation.y+theWindow->allocation.height-wRC.height, -1, -1);
        g_object_unref (offBitmap);
    }
}
Example #11
0
File: tedDraw.c Project: dimkr/ted
void tedDrawShadedRectangle(
			AppDrawingData *	add,
			APP_BITMAP_IMAGE	shadingPixmaps[DOCsp_COUNT],
			int			pattern,
			int			x0,
			int			y0,
			int			x1,
			int			y1 )
    {
    if  ( ! shadingPixmaps[pattern] )
	{
	const int	wide= 8;
	const int	high= 8;
	const int	d= 4;
	int		t;
	int		s= 0;

	int		x;
	int		y;

	AppDrawingData	addPat;

	appInitDrawingData( &addPat );

	shadingPixmaps[pattern]= appMakePixmap( add, wide, high );;
	if  ( ! shadingPixmaps[pattern] )
	    { XDEB(shadingPixmaps[pattern]); return;	}

	appCloneDrawingEnvironment( &addPat,
			add, 1.0, 0.05, shadingPixmaps[pattern] );

	appDrawSetForegroundWhite( &addPat );
	appDrawFillRectangle( &addPat, 0, 0, wide, high );

	appDrawSetForegroundBlack( &addPat );

	switch( pattern )
	    {
	    case DOCspSOLID:
		LDEB(pattern);
		t= 0; s= 0;
		break;

	    case DOCspBGHORIZ:
	    case DOCspBGVERT:
	    case DOCspBGFDIAG:
	    case DOCspBGBDIAG:
	    case DOCspBGCROSS:
	    case DOCspBGDCROSS:
		t= 1; s= 0;
		break;

	    case DOCspBGDKHORIZ:
	    case DOCspBGDKVERT:
	    case DOCspBGDKFDIAG:
	    case DOCspBGDKBDIAG:
	    case DOCspBGDKCROSS:
	    case DOCspBGDKDCROSS:
		t= 2; s= 1;
		break;

	    default:
		LDEB(pattern);
		return;
	    }

	if  ( t > 0 )
	    {
	    appDrawSetLineAttributes( &addPat,
			t, LINEstyleSOLID, LINEcapPROJECTING, LINEjoinMITER,
			(unsigned char *)0, 0 );
	    }

	switch( pattern )
	    {
	    case DOCspSOLID:
		LDEB(pattern);
		break;

	    case DOCspBGHORIZ:
	    case DOCspBGDKHORIZ:
		y= 0;
		while( y < high )
		    {
		    appDrawDrawLine( &addPat, 0, y+ s, wide- 1, y+ s );
		    y += d;
		    }
		break;

	    case DOCspBGVERT:
	    case DOCspBGDKVERT:
		x= 0;
		while( x < wide )
		    {
		    appDrawDrawLine( &addPat, x+ s, 0, x+ s, high- 1 );
		    x += d;
		    }
		break;

	    case DOCspBGFDIAG:
	    case DOCspBGDKFDIAG:
		x= -high;
		while( x < wide )
		    {
		    appDrawDrawLine( &addPat, x+ s, 0, x+ high+ s, high );
		    x += d;
		    }
		break;

	    case DOCspBGBDIAG:
	    case DOCspBGDKBDIAG:
		x= 0;
		while( x < wide+ high )
		    {
		    appDrawDrawLine( &addPat, x, 0, x- high, high );
		    x += d;
		    }
		break;

	    case DOCspBGCROSS:
	    case DOCspBGDKCROSS:
		y= 0;
		while( y < high )
		    {
		    appDrawDrawLine( &addPat, 0, y+ s, wide- 1, y+ s );
		    y += d;
		    }
		x= 0;
		while( x < wide )
		    {
		    appDrawDrawLine( &addPat, x+ s, 0, x+ s, high- 1 );
		    x += d;
		    }
		break;

	    case DOCspBGDCROSS:
	    case DOCspBGDKDCROSS:
		x= -high;
		while( x < wide )
		    {
		    /*
		    appDrawDrawLine( &addPat, x+ s, 0, x+ high+ s, high );
		    */
		    appDrawDrawLine( &addPat, x, 0, x+ high, high );
		    x += d;
		    }
		x= 0;
		while( x < wide+ high )
		    {
		    appDrawDrawLine( &addPat, x, 0, x- high, high );
		    x += d;
		    }
		break;

	    default:
		LDEB(pattern);
		return;
	    }

	appCleanDrawingData( &addPat );
	}

#   ifdef USE_MOTIF
    XSetFillStyle( add->addDisplay, add->addGc, FillTiled );
    XSetTile( add->addDisplay, add->addGc, shadingPixmaps[pattern] );
#   endif
#   ifdef USE_GTK
    gdk_gc_set_fill( add->addGc, GDK_TILED );
    gdk_gc_set_tile( add->addGc, shadingPixmaps[pattern] );
#   endif

    appDrawFillRectangle( add, x0, y0, x1- x0+ 1, y1- y0+ 1 );

#   ifdef USE_MOTIF
    XSetFillStyle( add->addDisplay, add->addGc, FillSolid );
#   endif
#   ifdef USE_GTK
    gdk_gc_set_fill( add->addGc, GDK_SOLID );
#   endif

    return;
    }
Example #12
0
static VALUE
rg_set_tile(VALUE self, VALUE tile)
{
    gdk_gc_set_tile(_SELF(self), GDK_PIXMAP(RVAL2GOBJ(tile)));
    return self;
}