#ifndef CODE_MXBUTTON_CXX
#define CODE_MXBUTTON_CXX

/*-----------------------------------------------------------------------
 * Xclasses code file
 * ($Id: mxbutton.cxx,v 1.1.1.1 1998/07/16 19:29:28 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/gadget.h>
#include <Xclasses/button.h>
#include <Xclasses/mxbutton.h>
#include "include/mxbutton_p.h"

mxbutton::mxbutton(): mxgadget()
{
	while (!(p=new pmxbutton))
	{
		outOfMemory("mxbutton");
	}
	p->o=this;
	Name("mxbutton");
}
pmxbutton::pmxbutton()
{
	anzahl=0;
}
pmxbutton::~pmxbutton()
{
}
mxbutton::~mxbutton()
{
	if (win) Free();
	if (p) delete p;
}
void mxbutton::Items(char *gbuttxts[])
{
	p->buttxts=gbuttxts;
	p->anzahl=0;
	while (p->buttxts[p->anzahl])    
	{
		p->anzahl++;
	}
	
	if (p->buts=new class selbutton[p->anzahl])
	{
		if (p->butp=new selgadget*[p->anzahl+1])
		{
			for(int i=0;i<p->anzahl;i++)
			{
				p->buts[i].Text(p->buttxts[i]);
				p->buts[i].CopyFont(this);
				p->butp[i]=&p->buts[i];
			}
			p->butp[p->anzahl]=NULL;
			mxgadget::Items(p->butp);
		}
	}	
}
void mxbutton::Free(void)
{
	mxgadget::Free();
	if (p->anzahl>0)
	{
		delete p->butp;
		delete [] p->buts;
		p->anzahl=0;
	}
}

#endif
