ダブルバッファリング
 表示する内容をPixmapに保持しておき、ウインドウにPixmapを表示する。
import dui.All;

public:

class HelloWorld : MainWindow , ExposeListener 
{
	public :
	
	Pixmap buffer;

	this()
	{
		super("mosskite");
		DrawingArea area = new DrawingArea();
		area.setSizeRequest(100,100);
		add(area);

		setSizeRequest(200,200);
		show();
		
		Dispatcher dis = new Dispatcher();
		dis.addExposeListener(this,area);
	}
	

	bit noExposeCallback(Widget widget)
		{
			return false;
		}

	bit exposeCallback(Widget widget)
		{
		static int flag = 0;
		if( widget.getWindow() != null && flag == 0)
		{
		flag =1;
		buffer = new Pixmap(new Pixmap(widget.getWindow()),100,100,-1);
		GC gc = widget.getFGgc();
		gc.setForeground(new Color(255,255,255));
		buffer.drawRectangle(gc,true,0,0,100,100);
		}
		else
		{	
		widget.getDrawable().drawDrawable(widget.getFGgc(),buffer,0,0,0,0,100,100);
		}
		return true;
		}
}
 
void main(char [][]args)
{	
	DUI dui = DUI.dui(args);
	new HelloWorld();
	dui.go();						
}
しかし以下のようなエラーがでます。
(HelloWorld.exe:3852): Gdk-CRITICAL **: file gdkdraw.c: line 643 (gdk_draw_drawa
ble): assertion `GDK_IS_DRAWABLE (drawable)' failed

dui_00.15_98での問題点

PixmapからのDrawableにて drawableとすると nullが返されます。 ということで gDraw()を使います。 
Drawableを書き直す・
void drawRectangle
(GC gc, bit filled, gint x, gint y, gint width, gint height)
{
gdk_draw_rectangle
(this.gDraw(), gc.getGDKgc(), filled, x, y, width, height);
}

void drawDrawable
(GC gc, Drawable drawable, gint xsrc, gint ysrc, gint xdest,
 gint ydest, gint width, gint height)
{
gdk_draw_drawable
(this.drawable, gc.getGDKgc(), drawable.gDraw(),
 xsrc, ysrc, xdest, ydest, width, height);
}
戻る

楽天モバイル[UNLIMITが今なら1円] ECナビでポインと Yahoo 楽天 LINEがデータ消費ゼロで月額500円〜!


無料ホームページ 無料のクレジットカード 海外格安航空券 解約手数料0円【あしたでんき】 海外旅行保険が無料! 海外ホテル