/*	XList.h
 *
 *		Defines the list control and other variants
 */

/*  YAAF - Yet another application framework
 *  Copyright (C) 1997, 1998 William Edward Woody
 *  
 *  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 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 MERCHANTABIILITY 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.
 *  
 *  To contact the author, either e-mail me at woody@pandawave.com, 
 *	or write to
 *  
 *          William Edward Woody
 *          In Phase Consulting
 *          1545 Ard Eevin Avenue
 *          Glendale, CA 91202
 *
 *	Or visit us on the web at http://www.pandawave.com
 */

#ifndef PandaWave_XLIST
#define PandaWave_XLIST

#include <XConfig.h>
#include <XHandle.h>
#include <XControls.h>
#include <XScroll.h>
#include <XView.h>

/************************************************************************/
/*																		*/
/*	Forwards															*/
/*																		*/
/************************************************************************/

class XGListView;
class XGListControl;
class XGDraw;
class XGFont;

/************************************************************************/
/*																		*/
/*	Class Declarations													*/
/*																		*/
/************************************************************************/

/*	@C"XGListView"
 *	@D"XGView"
 *	@H"XList.h"
 *	@I
 *
 *		The list view itself. This is the code for drawing the contents
 *	of the list
 */

class XGListView : public XGView {
	public:
								XGListView(XGListControl *);
		virtual					~XGListView();
				
		/*
		 *	Events
		 */
		
		void					DoDrawView(Rect);
		void					DoSizeView(void);
		bool					DoMouseDown(Point,short);
		void					DoMouseMove(Point,short);
		void					DoMouseUp(Point,short);

		void					RedrawLine(long);
		void					CalcResize(void);

		void					ScrollInRange(long);
	private:
		XGListControl			*fControl;
		
		void					DrawLine(XGDraw &,long,short,bool);
};

/*	@C"XGListControl"
 *	@D"XGScrollView"
 *	@H"XList.h"
 *	@I
 *
 *		The list control
 */

class XGListControl : public XGScrollView {
	public:
								XGListControl(XGOwner *o, XGArgStream &s);
		virtual					~XGListControl();
		
		enum {
			kClassID = 'list'
		};
		
		/*
		 *	Lists
		 */
		
		void					GetItem(long, char *) const;
		long					Length() const;
		void					Insert(long,const char *);
		void					Delete(long);
		void					DeleteAll();
		
		void					SetUpdate(bool update);
		
		bool					GetSelect(long);
		void					SetSelect(long,bool);
		void					ClearSelect(void);
		
		long					GetValue();
		void					SetValue(long);

	private:
		XGListView				*fView;
		XGFont					*fFont;
		XGStringList			fList;
		
		bool					fMultiSelect;
		
		bool					fUpdate;
		bool					fNeedUpdate;
	
	friend class XGListView;
};

#endif // PandaWave_XLIST

