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

#if !defined(Z_NOTEBK_HPP)
#define Z_NOTEBK_HPP
#include <z_win.hpp>

// --------------------------------------------------------------------------
// ----- ZafNotebook --------------------------------------------------------
// --------------------------------------------------------------------------
#if defined(ZAF_INDEPENDENT) || defined(ZAF_CURSES) || defined(ZAF_MACINTOSH)
class ZAF_EXPORT ZafNotebookTabControl;
#endif

class ZAF_EXPORT ZafNotebook : public ZafWindow
{
public:
	// --- General members ---
	ZafNotebook(int left, int top, int width, int height);
	ZafNotebook(const ZafNotebook &copy);
	virtual ~ZafNotebook(void);

	// --- Persistent members ---
	virtual ZafWindowObject *Duplicate(void);
#if defined(USE_ZAF_PERSISTENCE)
	ZafNotebook(const ZafIChar *name, ZafObjectPersistence &persist);
	static ZafElement *Read(const ZafIChar *name, ZafObjectPersistence &persist);
	virtual void Write(ZafObjectPersistence &persist);
#endif

	// --- Attributes & data access ---
	// get
	int CurrentPage(void) const;
	int FirstPage(void) const;
	int LastPage(void) const;
	int TabHeight(void);
	ZafIChar TabHotKeyChar(int page) const;
	int TabHotKeyIndex(int page) const;
	virtual const ZafIChar *TabText(int page);
	int TabWidth(void);
	bool PageDisabled(int page);
	bool PageDisabled(const ZafIChar *matchID);
	// set
	virtual int SetCurrentPage(int currentPage);
	virtual int SetCurrentPage(ZafWindowObject *currentPage);
	virtual int SetTabHeight(int tabHeight);
	virtual ZafIChar SetTabHotKey(int page, ZafIChar hotKeyChar, int index = -1);
	virtual ZafError SetTabText(const ZafIChar *text, int page);
	virtual int SetTabWidth(int tabWidth);
	virtual bool SetPageDisabled(int page, bool disabled);
	virtual bool SetPageDisabled(const ZafIChar *matchID, bool disabled);

	// --- Window members ---
	virtual bool SetDestroyable(bool destroyable);
	virtual bool SetLocked(bool locked);
	virtual bool SetMaximized(bool maximized);
	virtual bool SetMinimized(bool minimized);
	virtual bool SetModal(bool modal);
	virtual bool SetMoveable(bool moveable);
	virtual ZafWindow *SetOwner(ZafWindow *owner);
	virtual ZafSelectionType SetSelectionType(ZafSelectionType selectionType);
	virtual bool SetSizeable(bool sizeable);
	virtual bool SetTemporary(bool temporary);

	// --- Window object members ---
	virtual ZafEventType Event(const ZafEventStruct &event);
	ZafLogicalEvent LogicalEvent(const ZafEventStruct &event);
	virtual ZafEventType ScrollEvent(const ZafEventStruct &event);
	virtual bool SetAcceptDrop(bool acceptDrop);
	virtual bool SetAutomaticUpdate(bool automaticUpdate);
	virtual bool SetBordered(bool bordered);
	virtual ZafWindowObject* NotifyFocus(ZafWindowObject *focusObject, 
	  bool setFocus);
//	virtual bool SetFocus(bool setFocus);

	// --- Advanced event handling ---
#	if defined(ZAF_MACINTOSH)
	virtual ZafEventType DispatchMouseEvent(const ZafEventStruct &event);
#	elif defined(ZAF_INDEPENDENT) || defined(ZAF_CURSES)
	virtual ZafEventType DispatchMouseEvent(const ZafEventStruct &event);
	virtual ZafWindowObject *FindMouseObject(const ZafEventStruct &event);
#	endif

	// --- List members ---
	virtual ZafWindowObject *Add(ZafWindowObject *object, ZafWindowObject *position = ZAF_NULLP(ZafWindowObject));
	virtual ZafWindowObject *Subtract(ZafWindowObject *object);

	ZafNotebook &operator+(ZafWindowObject *object) { Add(object); return(*this); }
	ZafNotebook &operator-(ZafWindowObject *object) { Subtract(object); return(*this); }

	// --- Class identification ---
	static ZafClassID classID;
	static ZafClassNameChar ZAF_FARDATA className[];
	virtual ZafClassID ClassID(void) const { return (classID); }
	virtual ZafClassName ClassName(void) const { return (className); }
	virtual bool IsA(ZafClassID compareID) const;
	virtual bool IsA(ZafClassName compareName) const;

	// --- Special OS members ---
	virtual void OSDestroy(void);
	virtual OSWindowID OSScreenID(ZafScreenIDType type = ZAF_SCREENID) const;
	virtual ZafError OSUpdatePalettes(ZafPaletteType zafTypes, ZafPaletteType osTypes);

protected:
	friend class ZAF_EXPORT OSNotebook;

	// --- General members ---
	int tabHeight, tabWidth;
	int currentPage;

	virtual ZafEventType Draw(const ZafEventStruct &event, ZafEventType ccode);
	virtual ZafEventType DrawShadow(ZafRegionStruct &region, int depth, ZafEventType ccode);
	virtual const ZafPaletteStruct *MapClassPalette(ZafPaletteType type, ZafPaletteState state);
	virtual ZafRegionStruct MaxRegion(ZafWindowObject *object,
		ZafVtJustify vWeight = ZAF_VT_TOP, ZafHzJustify hWeight = ZAF_HZ_LEFT);

	// --- Special OS members ---
	virtual ZafEventType OSEvent(const ZafEventStruct &event);
	virtual void OSMapPalette(ZafPaletteStruct &palette, ZafPaletteType type, ZafPaletteState state);
	virtual void OSRegisterObject(void);

#if defined(USE_ZAF_PERSISTENCE)
	// --- Persistent members ---
	void ReadData(ZafObjectPersistence &persist);
	virtual ZafObjectConstructor ReadFunction(void) { return (ZafNotebook::Read); }
	virtual void WriteChildren(ZafObjectPersistence &persist);
	void WriteData(ZafObjectPersistence &persist);
	virtual void WriteSupportChildren(ZafObjectPersistence &persist);
#endif

#if defined(ZAF_INDEPENDENT)
	virtual ZafEventType DrawFrame(const ZafEventStruct &event, ZafEventType ccode);
#endif

private:
	static ZafPaletteMap ZAF_FARDATA defaultPaletteMap[];
	static ZafEventMap ZAF_FARDATA defaultEventMap[];
	bool focusTransition;

#if defined(ZAF_MSWINDOWS)
	int scrollIndex;
	ZafWindowObject *leftScrollButton;
	ZafWindowObject *rightScrollButton;
#elif defined(ZAF_MOTIF)
	ZafRegionStruct leftArrow, rightArrow;
	void DrawArrows(bool leftDepressed, bool rightDepressed);
#elif defined(ZAF_MACINTOSH)
	ZafNotebookTabControl *tabControl;
#elif defined(ZAF_INDEPENDENT) || defined(ZAF_CURSES)
	ZafNotebookTabControl *tabControl;
	ZafWindowObject *mouseObject;
#endif
};

// --- inline functions ---
inline int ZafNotebook::CurrentPage(void) const { return (Index(current)); }
inline int ZafNotebook::FirstPage(void) const { return (Count() ? 0 : -1); }
inline int ZafNotebook::LastPage(void) const { return (Count() - 1); }
inline int ZafNotebook::TabHeight(void) { return (tabHeight); }
inline int ZafNotebook::TabWidth(void) { return (tabWidth); }

#endif // Z_NOTEBK_HPP

