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

/**********************************************************************

  YAAF is Copyright 1997-1999 by William Woody.

  Redistribution and use in source and binary forms, with or without 
  modification, are permitted provided that the following conditions 
  are met:

  Redistributions of source code must retain the above copyright notice, 
  this list of conditions and the following disclaimer.

  Neither the name of the copyright holder or other contributors may
  be used to promote products derived from this software without
  specific written prior permission.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 
  SOFTWARE.
  
  Contact:   woody@alumni.caltech.edu
  Web page:  http://www.pandawave.com/yaaf/

**********************************************************************/

#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													*/
/*																		*/
/************************************************************************/

/*$	XGListView
 *
 *		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(XRect);
		void					DoSizeView(void);
		bool					DoMouseDown(XPoint,short);
		void					DoMouseMove(XPoint,short);
		void					DoMouseUp(XPoint,short);

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

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

/*$	XGListControl
 *
 *		The list control
 */

class XGListControl : public XGScrollView {
	public:
								XGListControl(XGView *o, XGArgStream &s);
		virtual					~XGListControl();
		
		enum {
			kClassID = 'list'
		};
		
		/*
		 *	Lists
		 */
		
		void					GetItem(long, char *) const;
		void					SetItem(long, const char *);
		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					fSwitchSelect;
		
		bool					fUpdate;
		bool					fNeedUpdate;
	
	friend class XGListView;
};

#endif // PandaWave_XLIST

