COMMENT @----------------------------------------------------------------------

	Copyright (c) GeoWorks 1989 -- All Rights Reserved

PROJECT:	PC GEOS
FILE:		Objects/gDocGrpC.def

DECLARER:	UI

DESCRIPTION:
	This file defines GenDocumentGroupClass.

	$Id: gDocGrpC.def,v 1.1 97/04/04 14:19:53 newdeal Exp $

------------------------------------------------------------------------------@

SetDef	__GDOCGRPC

StartLibrary	ui

GenDocumentGroupClass	class	GenClass

;-----------------------------------------------------------------------------
;		Application notification
;-----------------------------------------------------------------------------

; An application can add behavior on new/open/close/save/save as/revert in two
; ways.
; First, it can subclass GenDocument and subclass the methods MSG_GEN_DOCUMENT_?
; In this case, the notification OD should be 0.
; Second, it can set the notification OD to another object or to the process.
; In this case, the notification OD will get called with MSG_META_DOC_OUTPUT_FILE_??
; which can be handled to add the desired behavior.

;-----------------------------------------------------------------------------
;		Methods sent from outside
;-----------------------------------------------------------------------------

MSG_GEN_DOCUMENT_GROUP_NEW_DOC	message
;
; 	Create a new document.
;
; Pass:	 	dx - size DocumentCommonParams
;		ss:bp - DocumentCommonParams
; Return:	cx:dx - new Document object created (0 if error)
;		ax, bp - destroyed

MSG_GEN_DOCUMENT_GROUP_IMPORT_NEW_DOC	message
;
; 	Create a new document and import into it
;
; Pass:	 	ss:bp - ImpexTranslationParams
; Return:	cx:dx - new Document object created (0 if error)
;		ax, bp - destroyed

MSG_GEN_DOCUMENT_GROUP_OPEN_DOC	message
;
; Open a document.
;
; Pass:	 	dx - size DocumentCommonParams
;		ss:bp - DocumentCommonParams
; Return:	carry - set if error
; Return:	cx:dx - new Document object created (0 if error)
;		ax - destroyed

;---

MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY	message
;
; Mark document as dirty.
;
; Pass:	 	cx:dx - document to mark dirty.  If 0 then the target
;		document is marked as dirty
; Return:	nothing
;		ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_GROUP_MARK_DIRTY_BY_FILE	message
;
; Mark document with given file as dirty.
;
; Pass:	 	cx - file handle open to the document.
; Return:	nothing
;		ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_GROUP_OPEN_DEFAULT_DOC	message
;
; Try to open the default document (name passed).  If this file cannot be
; opened, take appropriate action.
;
; Pass:		dx - size DocumentCommonParams
;		ss:bp - DocumentCommonParams (DNOP_flags not set)
; Return:	ax, cx, dx - destroyed

;--------

MSG_GEN_DOCUMENT_GROUP_GET_ATTRS	message
;
; Get the GenDocumentGroupAttrs
;
; Pass:		nothing
; Return:	ax - GenDocumentGroupAttrs
;		cx, dx, bp - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_UI_ATTRS	message
;
; Get the GenDocumentControlAttrs from the GenDocumentControl
;
; Pass:		nothing
; Return:	ax - GenDocumentControlAttrs
;		cx, dx, bp - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_TEMPLATE_DIR	message
;
; Get the template directory
;
; Pass: 	cx:dx - buffer to put template directory in
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_GROUP_GET_UI_FEATURES	message
;
; Get the GenDocumentControlFeatures from the GenDocumentControl
;
; Pass:		nothing
; Return:	ax - GenDocumentControlFeatures
;		cx, dx, bp - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_DEFAULT_NAME	message
;
; Get the default name
;
; Pass:		cx:dx - DocumentCommonParams buffer
; Return:	ax - GenDocumentGroupAttrs
;		cx:dx.DCP_name - default name
;		cx:dx.DCP_path, cx:dx.DCP_diskHandle - directory holding the
;			file whose name is in DCP_name
;		cx, dx - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_OUTPUT	message
;
; Get the output
;
; Pass:		nothing
; Return:	cx:dx - output
;		bp - unchanged
;		ax - destroyed

MSG_GEN_DOCUMENT_GROUP_SET_OUTPUT	message
;
; Set the output
;
; Pass:		cx:dx - output
; Return:	nothing
;		cx, dx, bp - unchanged
;		ax - destroyed

;---

MSG_GEN_DOCUMENT_GROUP_GET_TOKEN	message
;
; Get the token from the UI doc control
;
; Pass:		cx:dx - address to store token at
; Return:	nothing
;		cx, dx, bp - unchanged
;		ax - destroyed

MSG_GEN_DOCUMENT_GROUP_GET_CREATOR	message
;
; Get the creator token from the UI doc control
;
; Pass:		cx:dx - address to store creator token
; Return:	nothing
;		cx, dx, bp - unchanged
;		ax - destroyed

MSG_GEN_DOCUMENT_GROUP_GET_PROTOCOL	message
;
; Get the protocol stored with the app document control
;
; Pass:		nothing
; Return:	cx - major protocol
;		dx - minor protocol
;		bp - unchanged
;		ax - destroyed

MSG_GEN_DOCUMENT_GROUP_GET_VIEW		message
;
; Get the GenView to connect documents to
;
; Pass:		nothing
; Return:	cx:dx - view
;		ax, bp - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_DISPLAY	message
;
; Get the GenDisplay to duplicate for each document
;
; Pass:		nothing
; Return:	cx:dx - display
;		ax, bp - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_DISPLAY_GROUP	message
;
; Get the GenDisplayGroup to attach GenDisplay's to
;
; Pass:		nothing
; Return:	cx:dx - display group
;		ax, bp - unchanged

MSG_GEN_DOCUMENT_GROUP_GET_DOC_BY_FILE	message
;
; Find the document with the given file
;
; Pass:		cx - file handle open to the document.
; Return:	cx:dx - OD (0 if none)
;		cx - unchanged
;		ax - destroyed

MSG_GEN_DOCUMENT_GROUP_SAVE_AS_CANCELLED	message
;
; Cancel save as
;
; Pass:		nothing
; Return:	nothing
;		ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_GROUP_SEARCH_FOR_DOC	message	
;
; See if the passed document is open and bring it to the front if it is.
;
; Context:	Used by GenApplicationClass to locate the application with
;		a particular document open, if any.
; Source:	GenApplicationClass
; Destination:  GenDocumentGroupClass
; Interception: Don't.
;
; Pass:
;		ss:bp	= DocumentCommonParams
; Return:
;		carry set if document found
;		ax, cx, dx, bp - destroyed
;

MSG_GEN_DOCUMENT_GROUP_AUTO_SAVE_BY_FILE	message
;
; AutoSave the document for a given file
;
; Context:	Used by the VMFile Temp Async mechanism
;
; Pass:		cx - file handle of the document
;			
; Return:	nothing
;
;		ax, cx, dx, bp - destroyed
;
MSG_GEN_DOCUMENT_GROUP_SET_DIRTY_LIMIT_BY_FILE	message
;
;
; Context:	Used by the VMFile Temp Async mechanism
; Source:	UI_VMFileSetInitialDirtyLimit
;
; Pass:		cx - file handle of the document
;			
; Return:	nothing
;
;		ax, cx, dx,- destroyed
;

;-----------------------------------------------------------------------------
;		Hints
;-----------------------------------------------------------------------------

;HINT_DISPLAYS_ON_FIELD 	vardata

	; Put displays on the field group (and thus reserve no space for the
	; GenDocumentGroup).  Not possible in some specific UI's

protominor UINewForZoomer

ATTR_GEN_DOCUMENT_GROUP_ALLOW_MULTIPLE_WRITE_ACCESS		vardata
;
; This hint will allow the document to be VMOpen'ed to permit multiple
; threads to attempt to write the VM file at once, meaning that the
; VMA_SINGLE_THREAD_ACCESS flag will not be passed. Use with caution!
;

protoreset

ATTR_GEN_DOCUMENT_GROUP_DOCUMENT_HANDLES		vardata	word
;
; Specifies minimum number of handles necessary to allow creation or
; opening of document.  If less than that is available, will report
; error to user.  Set to 0 for no check.
;

;-----------------------------------------------------------------------------
;		Constants & Structures
;-----------------------------------------------------------------------------

GenDocumentGroupAttrs	record
    GDGA_VM_FILE:1				;Documents stored in VM files
    GDGA_NATIVE:1				;If document not in VM file,
						; then should be in format
						; native to filesystem.
    GDGA_SUPPORTS_AUTO_SAVE:1			;Use auto-save
    GDGA_AUTOMATIC_CHANGE_NOTIFICATION:1	;Automatically provide change
						;notification
    GDGA_AUTOMATIC_DIRTY_NOTIFICATION:1		;Use automatic mechanism for
						;VM dirty notification
    GDGA_APPLICATION_THREAD:1			;Set if AppDocumentControl runs
						;in the application thread
    GDGA_VM_FILE_CONTAINS_OBJECTS:1		;Set if appropriate VM
						;attributes for storing objects
						;should be set in the VM file
    GDGA_CONTENT_DOES_NOT_MANAGE_CHILDREN:1	;VisContent does not manage its
						;children
    GDGA_LARGE_CONTENT:1			;VisContent uses large model
    GDGA_AUTOMATIC_UNDO_INTERACTION:1		;Sends out undo set-context
    						; messages automatically
    :6
GenDocumentGroupAttrs	end

DocQuitStatus	etype	word
DQS_OK		enum	DocQuitStatus
DQS_CANCEL	enum	DocQuitStatus
DQS_DELAYED	enum	DocQuitStatus
DQS_SAVE_ERROR	enum	DocQuitStatus

;-----------------------------------------------------------------------------
;		Instance Data
;-----------------------------------------------------------------------------

    GDGI_attrs		GenDocumentGroupAttrs \
			    mask GDGA_VM_FILE or \
			    mask GDGA_SUPPORTS_AUTO_SAVE or \
			    mask GDGA_AUTOMATIC_CHANGE_NOTIFICATION or \
			    mask GDGA_AUTOMATIC_DIRTY_NOTIFICATION or \
			    mask GDGA_APPLICATION_THREAD or \
			    mask GDGA_CONTENT_DOES_NOT_MANAGE_CHILDREN or \
			    mask GDGA_AUTOMATIC_UNDO_INTERACTION
    GDGI_untitledName	lptr.char	;default name

    GDGI_documentClass	fptr.ClassStruct GenDocumentClass
					;type of object to instantiate
    GDGI_genDocument	optr		;document to automatically duplicate,
					;takes priority over class field

    GDGI_output		optr		;output
    GDGI_documentControl optr		;GenDocumentControl object
    GDGI_genView	optr		;view to automatically connect to
    GDGI_genDisplay	optr		;display to automatically duplicate
    GDGI_genDisplayGroup optr		;display control to add displays to
    GDGI_protocolMajor	word	0
    GDGI_protocolMinor	word	1	;Protocol for new documents

GenDocumentGroupClass	endc

EndLibrary	ui
