#ifndef CODE_TEXTBOXP_H
#define CODE_TEXTBOXP_H

/*-----------------------------------------------------------------------
 * Xclasses header file
 * ($Id: textbox_p.h,v 1.1.1.1 1998/07/16 19:29:30 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 <Xclasses/Xcolors.h>
#include <Xclasses/textbox.h>
#include <Xclasses/gadget.h>
#include <Xclasses/Ddraw.h>
#include <Xclasses/popup.h>
#include <Xclasses/scroller.h>
#include <Xclasses/dlist.h>
#include <Xclasses/gfx_locked.h>


#define TA_SCROLL       0
#define TA_EXPOSE       1
#define TA_CURSOR       2
#define TA_EVENT        3
#define TA_EXPOSEFROM	4

#define MEMBLOCKSIZE	1000

class pttextbox: public gadget
{
	friend class ptextbox;
	friend class textbox;
public:
    pttextbox() : gadget()
    {};
	~pttextbox() {};

	int gg_active(void) { return active; };
};

class ptextbox
{
	friend class textbox;
public:
	textbox *o;

	int	readonly:1,
		bottom:1,
		m_up:1,
		m_down:1,
		m_left:1,
		m_right:1,
		justactive:1,
		free:1;
	int				bgcol;

	int				vscrollersize;		// V-Scrollerbreite
	int				hscrollersize;		// H-Scrollerbreite
	char			*text;
	int				size;
	int				used;

	scroller		hscroll,vscroll;
	pttextbox		innen;
	gfx_locked		glock;
	popup			edit_menu;

	int				top;
	int				left;
	int				lines;
	int				cols;
	int				total;
	int				largest;
	int				minrows;
	int				mincols;
	int				maxlen;
	int				curx,cury,curm;
	int				mcurx,mcury,mcurm;
	int				mstart,mend;
	int				charw;
	int				charh;

	int				cache_line;
	char			*cache_char;
	int				cache_curm;

    ptextbox();
	~ptextbox();

	void checkMem(void);
	void setvars(void);
	void checkwidth(void);
	void RemoveAll(void);
	void textaus(int r,int v);
	void textaus(int r,XEvent *e=NULL);
	void zeileclear(int l,int x=0);
	void zeileaus(int l);
	char *findline(int l);
	int  linelength(char *t);
	int  linelength2(char *t); // <=cols
	int  lineoffset(int l);
    void inschar(char *,int size=0);
    void delchar(int);
    void cursor(int rq=0);
    void uncursor(void);
	void checkVisible(void);
	void setXY2M(int,int);
	void setM2XY(int);
	void cutpaste(XEvent *);
	void remmark(XEvent *);
	void write(int x,int y,char *t,int l,int tcol,int hcol);
};

#endif
