#ifndef CODE_POPUPP_H
#define CODE_POPUPP_H

/*-----------------------------------------------------------------------
 * Xclasses header file
 * ($Id: popup_p.h,v 1.4 2002/03/21 09:41:01 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 <Xclasses/popup.h>
#include <Xclasses/Xwindows.h>
#include <Xclasses/gadget.h>
#include <Xclasses/gfx_text.h>
#include <Xclasses/gfx_object.h>
#include <Xclasses/gfx_knob.h>
#include <Xclasses/callable.h>

#include <Xclasses/keyclass.h>
#include <Xclasses/dlist.h>

#define TOP			2	// oben, unten im Popup
#define EXTRA		3	// oben, unten um Eintrag
#define RULEREXTRA	0	// oben, unten um Ruler
#define SEITE		0	// rechts, links um Eintrag
#define IMGMINUS	2	// von gfx_object'en abziehen
#define SCUTSPACE	30	// zwischen Text und Short-Cut (20)

struct zeilen
{
	struct node base;

	int			select:1,
				check:1,
				mx:1,
				sub:1,
				locked:1,
				hascut:1,
				ruler:1,
				pressed:1,
				head:1,
				issub:1,
				free:1;
	gfx_text	text;
	gfx_text	scut;
	gfx_object	*gfx;
	char		scutC[30];
	int			nr;
	int 		y,h,w,h2;

	dlist		subzeilen;
	struct zeilen *subboss;
};

class ppopup : public callable
{
	friend class popup;

public:
	class popup *o;
	
	class Xwindows win,subwin;
	class gadget subgg;
	// MPOP: Array subgg und subwin mit Max-Tiefe

	int oldx,oldy;

	dlist txt;
	int	x,y,w,h;
	int sx,sy,sw,sh;
	keyclass	*kc;

	int			userdata;
	callback	fcb;

	int sel,oldsel;
	int subsel,oldsubsel;// MPOP: array
	int tohighstart,subtohighstart;// MPOP: array
	zeilen *addto;
	zeilen *head;

	int open:1,
		sopen:1,// MPOP: array
		grabed:1,
		tohigh:1,
		subtohigh:1,// MPOP: array
		go_down:1,
		go_up:1,
		free:1;

    ppopup();
    ~ppopup();

	int calcpop(dlist *);
	int calcmax(dlist *);
	int select(int,int);
	void select2(void);
	void paint(void);
	void zeileaus(zeilen*,int,gadget*,int lockall=0);
	void zeile(zeilen *z);
	void subzeile(zeilen *z);
	void subopen(zeilen *);
	zeilen *findID(int);

	zeilen *Add(char*,char*);
	int Hook(XEvent *,KeySym,char *,int);
	void setkeys(int mode,dlist *z);
};

#endif
