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

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

// --------------------------------------------------------------------------
// ----- ZafMDIWindow -------------------------------------------------------
// --------------------------------------------------------------------------

enum ZafMDIType
{
	ZAF_MDI_PARENT		= 0,
	ZAF_MDI_CHILD		= 1
};

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

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

	// --- Attributes & data access ---
	// get
	ZafMDIType MDIType(void) const;
	virtual ZafWindowObject *RootObject(void) const;
	// set
	virtual ZafMDIType SetMDIType(ZafMDIType mdiType);

	// --- Window members ---
	virtual bool SetMaximized(bool maximized);
	virtual bool SetMinimized(bool maximized);
	virtual ZafWindow *SetOwner(ZafWindow *owner);
	virtual ZafSelectionType SetSelectionType(ZafSelectionType selectionType);
	virtual bool SetTemporary(bool temporary);

	// --- Window object members ---
#	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
	virtual ZafEventType Draw(const ZafEventStruct &event, ZafEventType ccode);
	virtual ZafEventType Event(const ZafEventStruct &event);
	virtual void GetClip(ZafWindowObject *object, ZafRegionStruct &clip, ZafRegionStruct &viewPort);
	ZafLogicalEvent LogicalEvent(const ZafEventStruct &event);
	virtual ZafEventType MoveEvent(const ZafEventStruct &event);
	virtual ZafEventType ScrollEvent(const ZafEventStruct &event);
	virtual bool SetAcceptDrop(bool acceptDrop);
	virtual bool SetBordered(bool bordered);
	virtual bool SetDisabled(bool disabled);
	virtual bool SetNoncurrent(bool noncurrent);
	virtual bool SetParentPalette(bool parentPalette);
	virtual ZafRegionType SetRegionType(ZafRegionType regionType);
	virtual bool SetVisible(bool visible);

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

	ZafMDIWindow &operator+(ZafWindowObject *object) { Add(object); return(*this); }
	ZafMDIWindow &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;

	// --- Advanced class members ---
	virtual ZafWindowObject *NotifyFocus(ZafWindowObject *object, bool focus);

	// --- Special OS members ---
	virtual void OSSize(void);
#	if defined(ZAF_INDEPENDENT) || defined(ZAF_CURSES)
	virtual void OSInvalidateRegion(ZafRegionStruct *region, bool immediateRedraw = false, bool client = false);
//	virtual void OSUpdateRegions(ZafRegionList *region);
	virtual void ModifyOSShift(ZafPositionStruct &osPosition);
	virtual void OSDrawChildren(ZafRegionList *regionList);
#	endif

protected:
	virtual const ZafPaletteStruct *MapClassPalette(ZafPaletteType type, ZafPaletteState state);

	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;

	// --- 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 (ZafMDIWindow::Read); }
	void WriteData(ZafObjectPersistence &persist);
#endif

private:
	ZafMDIType mdiType;

	static ZafEventMap ZAF_FARDATA defaultEventMap[];
	static ZafPaletteMap ZAF_FARDATA defaultPaletteMap[];
};

// --- inline functions ---
inline ZafMDIType ZafMDIWindow::MDIType(void) const { return (mdiType); }

#endif // Z_MDIWIN_HPP

