//	Zinc Application Framework - I_NOTEBK.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#include <z_button.hpp>
#include <z_notebk.hpp>

class ZAF_EXPORT ZafNotebookTabControl : public ZafWindow
{
	// ZafNotebook is declared a friend class so that only it can
	// call the private constructor for ZafNotebookTabControl.
	friend class ZAF_EXPORT ZafNotebook;

public:
	ZafWindowObject *currentTab;
	ZafWindowObject *firstVisible;

	ZafNotebookTabControl(const ZafNotebookTabControl &copy);
	~ZafNotebookTabControl(void);
	virtual ZafWindowObject *Add(ZafWindowObject *object, ZafWindowObject *position = ZAF_NULLP(ZafWindowObject));
	virtual ZafWindowObject *Duplicate(void) { return (new ZafNotebookTabControl(*this)); }
	virtual ZafEventType Draw(const ZafEventStruct &event, ZafEventType ccode);
	virtual ZafEventType Event(const ZafEventStruct &event);
	virtual void GetClip(ZafWindowObject *object, ZafRegionStruct &clip, ZafRegionStruct &viewPort);
	int SetCurrentTab(int currentTab);
	int SetCurrentTab(ZafWindowObject *currentTab);
	virtual bool SetSupportObject(bool supportObject);
	virtual ZafWindowObject *Subtract(ZafWindowObject *object);

	virtual ZafEventType DispatchMouseEvent(const ZafEventStruct &event);

	virtual void OSUpdateRegions(ZafRegionList *regionList);

protected:
	virtual ZafPositionStruct ConvertToOSPosition(const ZafWindowObject *object,
		const ZafPositionStruct *zafPosition = ZAF_NULLP(ZafPositionStruct)) const;
	virtual ZafPositionStruct ConvertToZafPosition(const ZafWindowObject *object,
		const ZafPositionStruct *osPosition = ZAF_NULLP(ZafPositionStruct)) const;
	virtual ZafRegionStruct MaxRegion(ZafWindowObject *object,
		ZafVtJustify vWeight = ZAF_VT_TOP, ZafHzJustify hWeight = ZAF_HZ_LEFT);

private:
	ZafNotebookTabControl(void);
};

// --- inline functions ---
inline int ZafNotebookTabControl::SetCurrentTab(ZafWindowObject *currentTab) { return (SetCurrentTab(Index(currentTab))); }

class ZAF_EXPORT ZafNotebookTab : public ZafButton
{
public:
	static int chisel;

	ZafNotebookTab(const ZafIChar *text);
	ZafNotebookTab(const ZafNotebookTab &copy);
	virtual ZafWindowObject *Duplicate(void) { return (new ZafNotebookTab(*this)); }
	virtual ZafEventType Draw(const ZafEventStruct &event, ZafEventType ccode);
	virtual ZafEventType DrawShadow(ZafRegionStruct &region, int depth, ZafEventType ccode);
	virtual ZafEventType Event(const ZafEventStruct &event);
	virtual void OSInvalidateRegion(ZafRegionStruct *region, bool immediateRedraw = false, bool client = false);
};

enum ZafScrollState
{
	ZAF_SCROLL_NONE,
	ZAF_SCROLL_LEFT,
	ZAF_SCROLL_RIGHT
};

class ZAF_EXPORT ZafNotebookScrollArrows : public ZafButton
{
	// ZafNotebookTabControl is declared a friend class so that only it can
	// call the private constructor for ZafNotebookScrollArrows.
	friend class ZAF_EXPORT ZafNotebookTabControl;

public:
	ZafNotebookScrollArrows(const ZafNotebookScrollArrows &copy);
	~ZafNotebookScrollArrows();
	virtual ZafWindowObject *Duplicate(void) { return (new ZafNotebookScrollArrows(*this)); }
	virtual ZafEventType Draw(const ZafEventStruct &event, ZafEventType ccode);
	virtual ZafEventType DrawShadow(ZafRegionStruct &region, int depth, ZafEventType ccode);
	virtual ZafEventType Event(const ZafEventStruct &event);
	virtual bool SetSupportObject(bool supportObject);
	
protected:
	// --- Image support ---
	static char ZAF_FARDATA scrollLeftArrowName[];
	static char ZAF_FARDATA scrollRightArrowName[];
	static ZafBitmapData *scrollLeftArrowBitmap;
	static ZafBitmapData *scrollRightArrowBitmap;
	static void ImageAllocate(void);
	static void ImageFree(bool globalRequest = false);

private:
	ZafNotebookScrollArrows(void);

	int middle;
	ZafScrollState scrollState;
};

