#ifndef CODE_GFXLOCKED_CXX
#define CODE_GFXLOCKED_CXX

/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: gfx_locked.cxx,v 1.1.1.1 1998/07/16 19:29:31 cvs Exp $)
 * 
 * Copyright (C) 1998 Jürgen Schmitz
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA  02111-1307, USA.
 *-----------------------------------------------------------------------
 */

#include "types.h"
#include <Xclasses/Xcolors.h>
#include <Xclasses/gadget.h>
#include <Xclasses/gfx_object.h>
#include <Xclasses/gfx_locked.h>
// #include "include/gfx_locked_p.h"

static int lock_pixmap_counter=0;
static Pixmap lock_pixmap;

gfx_locked::gfx_locked(void) : gfx_object()
{
	p=NULL;
//	while (!(p=new pgfx_locked))
//	{
//		outOfMemory("gfx_locked");
//	}
//	p->o=this;
	Name("gfx_locked");
	if (lock_pixmap_counter++==0)
	{
		lock_pixmap=0;
	}
}
//pgfx_locked::pgfx_locked(void)
//{
//}
//pgfx_locked::~pgfx_locked()
//{
//}
gfx_locked::~gfx_locked()
{
	if (--lock_pixmap_counter==0 && lock_pixmap)
	{
		XFreePixmap(display(),lock_pixmap);
		lock_pixmap=0;
	}
//	if (p) delete p;
}

void gfx_locked::draw_normal(class gadget *g,int x,int y,int w,int h)
{
}
void gfx_locked::draw_selected(class gadget *g,int x,int y,int w,int h)
{
}
void gfx_locked::draw_locked(class gadget *g,int x,int y,int w,int h)
{
	if (lock_pixmap==0)
	{
		char data[]={8+128,0,2+32,0,8+128,0,2+32,0};
		lock_pixmap=XCreateBitmapFromData(display(),g->gg_win(),
		               data,
		               8,8);
	}
	XSetForeground(display(),g->gg_gc(),col_black());
	XSetStipple(display(),g->gg_gc(),lock_pixmap);
	XSetFillStyle(display(),g->gg_gc(),FillStippled);
	XFillRectangle(display(),g->gg_win(),g->gg_gc(),x,y,w,h);
	XSetFillStyle(display(),g->gg_gc(),FillSolid);
}
void gfx_locked::draw_selectedlocked(class gadget *g,int x,int y,int w,int h)
{
	draw_locked(g,x,y,w,h);
}

#endif
