#ifndef CODE_GFXDIR_CXX
#define CODE_GFXDIR_CXX

/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: gfx_dir.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/gfx_dir.h>
#include <Xclasses/gadget.h>
#include <Xclasses/Xcolors.h>
//#include "include/gfx_dir_p.h"

static int dir_col=-1;

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

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

static void draw(class gfx_dir *o,class gadget *g,int x,int y,int w,int h,int c)
{
#define PTS1C	7
#define PTS2C	7
	XPoint pts1[PTS1C]={{x+1,y+5},{0,h-6},
					  {w-2,0},{0,-(h-6)},
					  {-2,-2},{-(w-2-4),0},
					  {-2,2}};
	XPoint pts11[PTS1C]={{x+1,y+5},{0,h-6},
					  {w-2,0},{0,-(h-6)},
					  {-2,-1},{-(w-2-4),0},
					  {-2,1}};
  	XPoint pts2[PTS2C]={{x+3,y+1},{2,0},
					  {2,2},{0,3},
					  {-(2+4),0},{0,-3},
					  {2,-2}};

	if (dir_col==-1)
	{
		dir_col=o->AllocColor(0xdddd,0xdddd,0xbbbb);
	}

	XSetLineAttributes(o->display(),g->gg_gc(),0,LineSolid,CapNotLast,JoinMiter);

	XSetForeground(o->display(),g->gg_gc(),o->col_white());
	XFillPolygon(o->display(),g->gg_win(),g->gg_gc(),pts2,PTS2C,Convex,CoordModePrevious);
	XSetForeground(o->display(),g->gg_gc(),c);
	XDrawLines(o->display(),g->gg_win(),g->gg_gc(),pts2,PTS2C,CoordModePrevious);


	XSetForeground(o->display(),g->gg_gc(),dir_col);
//  shape: Complex, Convex, or Nonconvex
	XFillPolygon(o->display(),g->gg_win(),g->gg_gc(),pts11,PTS1C,Convex,CoordModePrevious);
	XSetForeground(o->display(),g->gg_gc(),c);
	XDrawLines(o->display(),g->gg_win(),g->gg_gc(),pts1,PTS1C,CoordModePrevious);

//	XSetForeground(o->display(),g->gg_gc(),o->col_white());
//	XFillPolygon(o->display(),g->gg_win(),g->gg_gc(),pts2,PTS2C,Convex,CoordModePrevious);
//	XSetForeground(o->display(),g->gg_gc(),c);
//	XDrawLines(o->display(),g->gg_win(),g->gg_gc(),pts2,PTS2C,CoordModePrevious);

	XSetLineAttributes(o->display(),g->gg_gc(),0,LineSolid,CapButt,JoinRound);
}

void gfx_dir::Adjust(int a)
{
//	p->adjust=a;
}
void gfx_dir::draw_normal(class gadget *g,int x,int y,int w,int h)
{
	draw(this,g,x,y,w,h,col_text());
}
void gfx_dir::draw_selected(class gadget *g,int x,int y,int w,int h)
{
	draw(this,g,x+1,y+1,w,h,col_selectedtext());
}
void gfx_dir::draw_locked(class gadget *g,int x,int y,int w,int h)
{
	draw(this,g,x,y,w,h,col_text());
}
void gfx_dir::draw_selectedlocked(class gadget *g,int x,int y,int w,int h)
{
	draw(this,g,x+1,y+1,w,h,col_selectedtext());
}

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

#endif
