#ifndef CODE_GFXCHECKBOX_CXX
#define CODE_GFXCHECKBOX_CXX

/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: gfx_checkbox.cxx,v 1.2 1998/10/06 00:01:19 schmitzj 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/gfx_checkbox.h>
#include <Xclasses/gadget.h>
#include <Xclasses/Xcolors.h>
//#include "include/gfx_checkbox_p.h"
#include "../include/defaults.h"


gfx_checkbox::gfx_checkbox() : gfx_object()
{
//	while (!(p=new pgfx_checkbox))
//	{
//		outOfMemory("gfx_checkbox");
//	}
//	p->o=this;
	Name("gfx_checkbox");
}
gfx_checkbox::~gfx_checkbox()
{
//	if (p) delete p;
}

//pgfx_checkbox::pgfx_checkbox(void)
//{
//	adjust=ADJUST_LEFT|ADJUST_TOP;
//}
//pgfx_checkbox::~pgfx_checkbox()
//{
//}

void gfx_checkbox::draw_normal(class gadget *g,int x,int y,int w,int h)
{
	x+=2; w-=4;
	y+=2; h-=4;
	if (w<h) h=w; else w=h;
	XSetForeground(display(),g->gg_gc(),col_background());
	XFillRectangle(display(),g->gg_win(),g->gg_gc(),x,y,w,h);

	XSetForeground(display(),g->gg_gc(),col_shine());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x+w,y);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x,y+h);
	XSetForeground(display(),g->gg_gc(),col_shine2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+w-1,y+1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+1,y+h-1);

	XSetForeground(display(),g->gg_gc(),col_shadow());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x,y+h);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x+w,y);
	XSetForeground(display(),g->gg_gc(),col_shadow2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+1,y+h-1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+w-1,y+1);
}
void gfx_checkbox::draw_selected(class gadget *g,int x,int y,int w,int h)
{
	x+=2; w-=4;
	y+=2; h-=4;
	if (w<h) h=w; else w=h;
	char *res=GetResource("check");
	int ck=0;
	if (res && !strcasecmp(res,"True")) ck=1;
	if (ck)
		XSetForeground(display(),g->gg_gc(),col_background());
	else
		XSetForeground(display(),g->gg_gc(),col_selected());

	XFillRectangle(display(),g->gg_win(),g->gg_gc(),x,y,w,h);

	if (defaults.new3D)
		XSetForeground(display(),g->gg_gc(),col_shadow2());
	else
		XSetForeground(display(),g->gg_gc(),col_shadow());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x+w,y);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x,y+h);
	if (defaults.new3D)
		XSetForeground(display(),g->gg_gc(),col_shadow());
	else
		XSetForeground(display(),g->gg_gc(),col_shadow2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+w-1,y+1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+1,y+h-1);

	if (defaults.new3D)
		XSetForeground(display(),g->gg_gc(),col_shine2());
	else
		XSetForeground(display(),g->gg_gc(),col_shine());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x,y+h);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x+w,y);
	if (defaults.new3D)
		XSetForeground(display(),g->gg_gc(),col_shine());
	else
		XSetForeground(display(),g->gg_gc(),col_shine2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+1,y+h-1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+w-1,y+1);

	if (ck)
	{
		XSetForeground(display(),g->gg_gc(),col_text());
		XDrawLine(display(),g->gg_win(),g->gg_gc(),x+3,y+h/2-1,x+4,y+h-1);
		XDrawLine(display(),g->gg_win(),g->gg_gc(),x+3,y+h/2,x+3,y+h-1);
		XDrawLine(display(),g->gg_win(),g->gg_gc(),x+4,y+h-1,x+w,y+3);
		XDrawLine(display(),g->gg_win(),g->gg_gc(),x+3,y+h-1,x+w,y+2);
	}
}
void gfx_checkbox::draw_locked(class gadget *g,int x,int y,int w,int h)
{
	x+=2; w-=4;
	y+=2; h-=4;
	if (w<h) h=w; else w=h;
	XSetForeground(display(),g->gg_gc(),col_background());
	XFillRectangle(display(),g->gg_win(),g->gg_gc(),x,y,w,h);

	XSetForeground(display(),g->gg_gc(),col_shine());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x+w,y);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x,y+h);
	XSetForeground(display(),g->gg_gc(),col_shadow2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+w-1,y+1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+1,y+h-1);

	XSetForeground(display(),g->gg_gc(),col_shadow());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x,y+h);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x+w,y);
	XSetForeground(display(),g->gg_gc(),col_shine2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+1,y+h-1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+w-1,y+1);
}
void gfx_checkbox::draw_selectedlocked(class gadget *g,int x,int y,int w,int h)
{
	x+=2; w-=4;
	y+=2; h-=4;
	if (w<h) h=w; else w=h;
	XSetForeground(display(),g->gg_gc(),col_selected());
	XFillRectangle(display(),g->gg_win(),g->gg_gc(),x,y,w,h);

	XSetForeground(display(),g->gg_gc(),col_shadow());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x+w,y);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x,y,x,y+h);
	XSetForeground(display(),g->gg_gc(),col_shine2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+w-1,y+1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+1,y+1,x+1,y+h-1);

	XSetForeground(display(),g->gg_gc(),col_shine());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x,y+h);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w,y+h,x+w,y);
	XSetForeground(display(),g->gg_gc(),col_shadow2());
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+1,y+h-1);
	XDrawLine(display(),g->gg_win(),g->gg_gc(),x+w-1,y+h-1,x+w-1,y+1);
}

int gfx_checkbox::height(class gadget *g)
{
	return NOLIMIT;
}
int gfx_checkbox::width(class gadget *g)
{
	return NOLIMIT;
}

#endif
