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

	Copyright (c) GeoWorks 1989 -- All Rights Reserved

PROJECT:	PC GEOS
FILE:		Objects/gDocCtrl.def

DECLARER:	UI

DESCRIPTION:
	This file defines GenDocumentControlClass.

	$Id: gDocCtrl.def,v 1.1 97/04/04 14:20:13 newdeal Exp $

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

SetDef	__GDOCCTRL

StartLibrary	ui

;
; GenApplication GCN lists to be placed on:
;	GAGCNLT_SELF_LOAD_OPTIONS
;	MGCNLT_ACTIVE_LIST
;	MGCNLT_APP_STARTUP

GenDocumentControlClass	class	GenControlClass

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

MSG_GEN_DOCUMENT_CONTROL_DISPLAY_DIALOG		message
;
; Display the standard dialog box for (new empty/new/import/...)
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_NEW_DOC		message
;
; Initiate creation of a new document.  This will normally either cause a new
; document to be created immediately or it will cause a dialog box to appear
; asking what type of document to create.
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_USE_TEMPLATE_DOC	message
;
; Initiate creation of a new document via a template.
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_OPEN_DOC		message
;
; Initiate opening of a document.  This will normally cause a dialog box to
; appear asking the user which file to open.
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_IMPORT_DOC		message
;
; Initiate import.
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_SAVE_DOC		message
;
; Initiate saving of a document.  If the target document is unnamed, this
; involves a dialog box (the save as dialog box).
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_SAVE_AS_DOC	message
;
; Initiate saving of a document to a file with a different name.  This will
; normally cause a dialog box to appear asking the user what the new file
; name should be.
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_SAVE_AS_TEMPLATE_DOC	message
;
; Initiate saving of a document as a form with a different name.  This will
; normally cause a dialog box to appear asking the user what the new file
; name should be.
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_COPY_TO_DOC	message
;
; Initiate copying a document.
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_EXPORT_DOC	message
;
; Initiate exporting a document.
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_SET_TYPE_DOC	message
;
; Initiate changing the type for a document
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_INITIATE_SET_PASSWORD_DOC	message
;
; Initiate changing the password for a document
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

;--------

MSG_GEN_DOCUMENT_CONTROL_GET_ATTRS	message
;
; Get the DocumentControlAttrs
;
; Pass: 	none
; Return: 	ax - DocumentControlAttrs
;		cx, dx, bp - unchanged

MSG_GEN_DOCUMENT_CONTROL_GET_FEATURES	message
;
; Get the DocumentControlFeatures
;
; Pass: 	none
; Return: 	ax - DocumentControlFeatures
;		cx, dx, bp - unchanged

;MSG_GEN_PATH_GET			message
;
; Returns null-terminated path of files currently being shown.
;
; Pass:		dx:bp - address to which to copy. if dx is 0, the path is
;			copied to a block allocated on the global heap and
;			cx is ignored.
;		cx - size of buffer (may be zero)
; Return:	carry set if error (path won't fit in the passed buffer or is
;			invalid):
; 			ax - number of bytes required (0 => path is invalid)
;			cx - disk handle of path
;		carry clear if ok:
;			if dx:bp passed as far pointer:
;				dx:bp - filled with path (fptr preserved)
;			if dx 0:
;				dx - handle of block containing the path
;			cx - disk handle of path
;

;MSG_GEN_PATH_SET	message

; Set path whose contents will be shown.
;
; Pass:	 	cx:dx - null-terminated pathname; may not be in the same
;			block as the object receiving this message.
;			(if null, uses root directory of disk specified by
;			 disk handle; if relative, path is taken current to
;			 selector's current path)
;		bp - disk handle of path, or StandardPath constant
;			(if 0, will use object's current disk handle)
; Return:	carry set if path couldn't be set (was invalid):
; 			ax - error code (FileError)
; 		carry clear if path successfully set:
; 			ax - destroyed
;		cx, dx, bp - destroyed
;

MSG_GEN_DOCUMENT_CONTROL_GET_TOKEN	message
;
; Get the token
;
; Pass: 	cx:dx - address to store token
; Return: 	cx, dx, bp - unchnged
;		ax - destroyed

MSG_GEN_DOCUMENT_CONTROL_GET_CREATOR	message
;
; Get the creator token
;
; Pass: 	cx:dx - address to store creator token
; Return: 	cx, dx, bp - unchnged
;		ax - destroyed

MSG_GEN_DOCUMENT_CONTROL_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_CONTROL_SAVE_AS_CANCELLED	message
;
; Cancel pressed in save as box
;
; Pass: 	none
; Return: 	ax, cx, dx, bp - destroyed

DocumentFileChangedParams	struct
    DFCP_name		FileLongName
    DFCP_diskHandle	hptr
    DFCP_path		PathName
    DFCP_display	optr
    DFCP_document	optr
DocumentFileChangedParams	ends

MSG_GEN_DOCUMENT_CONTROL_FILE_CHANGED	message
;
; Update things that depend on the file name
;
; Pass:
;	ss:bp - DocumentFileChangedParams
; Return: 	ax, cx, dx, bp - destroyed

MSG_GEN_DOCUMENT_CONTROL_CONFIGURE_FILE_SELECTOR	message
;
; Configure file selector.  This message can be sub-classed to modify
; the behavior of the file selectors that the document control uses
;
; Pass:
;	cx:dx - file selector
;	bp - GenDocumentControlAttrs
;				
; Return:
;	none

MSG_GEN_DOCUMENT_CONTROL_OPEN_IMPORT_SELECTED	message
;
; The user has selected a file to import in the import UI attached to the
; open dialog box.  An unnamed document will be created and a
; MSG_GEN_DOCUMENT_IMPORT will be sent to it.
;
; Pass:
;	ss:bp - ImpexTranslationParams
;				
; Return:
;	none

MSG_GEN_DOCUMENT_CONTROL_FILE_EXPORTED	message
;
; Notification that a file has been successfully exported.
;
; Pass:
;	none
;				
; Return:
;	none

MSG_GEN_DOCUMENT_CONTROL_OPEN_DEFAULT_DOC	message
;
; Open the default document
;
; Pass:
;	none
;				
; Return:
;	none

MSG_GEN_DOCUMENT_CONTROL_IMPORT_CANCELLED	message
;
; Notification that import has been cancelled
;
; Pass:
;	none
;				
; Return:
;	none

protominor UINewFor21

MSG_GEN_DOCUMENT_CONTROL_INITIATE_MOVE_TO_DOC	message
;
; Initiate moving a document.
;
; Pass: 	none
; Return:	ax, cx, dx, bp - destroyed

protoreset

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

ATTR_GEN_DOCUMENT_CONTROL_NO_EMPTY_DOC_IF_NOT_ABOVE	vardata	UIInterfaceLevel
;
; This attribute says that user cannot create empty documents unless the
; user level is at least the given level

HINT_GEN_DOCUMENT_CONTROL_NO_PROGRESS_DIALOG_ON_UPDATE_MAJOR	vardata
;
; This hint will prevent a progress dialog from appearing when updating a
; document with an earlier and incompatible protocol number.

HINT_GEN_DOCUMENT_CONTROL_PROGRESS_DIALOG_ON_UPDATE_MINOR	vardata
;
; This hint will cause a progress dialog to appear when updating a document
; with an earlier but compatible protocol number.

;ATTR_GEN_PATH_DATA			vardata GenFilePath
;
;	This is defined in GenClass, but you can use it with a UI document
;	control to set the initial path in which the default document will
;	be found/created, etc. You can set the GFP_disk field to a StandardPath
;	constant to have it start in that standard directory (with GFP_path
;	being a subdirectory of that . In the absence of this attribute, the
;	document control will start out in SP_DOCUMENT.
;

ATTR_GEN_DOCUMENT_CONTROL_FILE_LIST_TITLE	vardata	lptr
;	This attr allows the user to set the heading of the file list in the
;	GenDocumentControl. By default, "Document" is used.
;

protominor UINoFileList

HINT_DOCUMENT_CONTROL_NO_FILE_LIST		vardata
;
; Specifies that the document control should not initially show the file
; list nor return to the list when a document is closed.
;

protoreset

protominor UINewDocWarning

ATTR_GEN_DOCUMENT_CONTROL_NEW_DOC_WARNING	vardata lptr
;
; Specifies warning string to show when File:New is used.
;

protoreset

;-----------------------------------------------------------------------------
;		Constants & Structures (GenControl related)
;-----------------------------------------------------------------------------

; Features flags (used with ATTR_GEN_CONTROL_REQUIRE_UI and
; ATTR_GEN_CONTROL_PROHIBIT_UI)

; Note that the document control is special here.  Most controllers just have
; a set of features bits that can be turned off at will.  The document
; control's ui and behavior is guided by the "mode" set in the instance data.
; The mode (viewer, shared single or shared multiple) affects the UI present.
; This UI can be further restricted using the bits below.

GDCFeatures	record
    GDCF_NEW:1				;replaced with switch documents in
					;transparent mode
    GDCF_OPEN_CLOSE:1
    GDCF_QUICK_BACKUP:1
    GDCF_SAVE:1
    GDCF_SAVE_AS:1
    GDCF_COPY:1
    GDCF_EXPORT:1
    GDCF_REVERT:1
    GDCF_RENAME:1			;requires an auto-savable file
    GDCF_EDIT_USER_NOTES:1
    GDCF_SET_TYPE:1
    GDCF_SET_PASSWORD:1
    GDCF_SAVE_AS_TEMPLATE:1
    GDCF_SET_EMPTY_DOCUMENT:1
    GDCF_SET_DEFAULT_DOCUMENT:1
GDCFeatures	end

GDC_SUGGESTED_INTRODUCTORY_FEATURES = 0

GDC_SUGGESTED_BEGINNING_FEATURES = GDC_SUGGESTED_INTRODUCTORY_FEATURES or \
				   mask GDCF_QUICK_BACKUP or \
				   mask GDCF_COPY or \
				   mask GDCF_RENAME or \
				   mask GDCF_EXPORT or \
				   mask GDCF_EDIT_USER_NOTES

GDC_SUGGESTED_INTERMEDIATE_FEATURES = GDC_SUGGESTED_BEGINNING_FEATURES or \
				      mask GDCF_SAVE_AS or \
				      mask GDCF_REVERT or \
				      mask GDCF_SET_PASSWORD

GDC_SUGGESTED_ADVANCED_FEATURES = GDC_SUGGESTED_INTERMEDIATE_FEATURES or \
				  mask GDCF_SET_TYPE or \
				  mask GDCF_SAVE_AS_TEMPLATE or \
				  mask GDCF_SET_EMPTY_DOCUMENT or \
				  mask GDCF_SET_DEFAULT_DOCUMENT

; Toolbox features flags (used with ATTR_GEN_CONTROL_REQUIRE_TOOLBOX_UI and
; ATTR_GEN_CONTROL_PROHIBIT_TOOLBOX_UI)

GDCToolboxFeatures	record
    GDCTF_NEW_EMPTY:1
    GDCTF_USE_TEMPLATE:1
    GDCTF_OPEN:1
    GDCTF_CLOSE:1
    GDCTF_SAVE:1
    GDCTF_QUICK_BACKUP:1
GDCToolboxFeatures	end

NotifyDocumentChange	struct
    NDC_attrs		GenDocumentAttrs
    NDC_type		GenDocumentType
    NDC_fileHandle	hptr
    NDC_emptyExists	BooleanByte
    NDC_defaultExists	BooleanByte
NotifyDocumentChange	ends

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

GDCTask		etype	byte
GDCT_NONE		enum	GDCTask
GDCT_NEW		enum	GDCTask
GDCT_OPEN		enum	GDCTask
GDCT_USE_TEMPLATE	enum	GDCTask
GDCT_SAVE_AS		enum	GDCTask
GDCT_COPY_TO		enum	GDCTask
GDCT_DIALOG		enum	GDCTask
GDCT_TYPE		enum	GDCTask
GDCT_PASSWORD		enum	GDCTask
GDCT_MOVE_TO		enum	GDCTask

GenDocumentControlMode	etype	byte
GDCM_VIEWER		enum	GenDocumentControlMode
GDCM_SHARED_SINGLE	enum	GenDocumentControlMode
GDCM_SHARED_MULTIPLE	enum	GenDocumentControlMode

GenDocumentControlAttrs	record

	; File attributes

    GDCA_MULTIPLE_OPEN_FILES:1		;Allows multiple files to be open
    GDCA_MODE GenDocumentControlMode:2
    GDCA_DOS_FILE_DENY_WRITE:1		;If GDCA_VM_FILE not set, then open
					; standard DOS file deny-write
    GDCA_VM_FILE:1			;Documents stored in VM files
    GDCA_NATIVE:1			;If GDCA_VM_FILE not set, documents
    					; stored in format native to the
					; filesystem
    GDCA_SUPPORTS_SAVE_AS_REVERT:1	;Document uses "save as"

	; Current state

    GDCA_DOCUMENT_EXISTS:1		;At least one document exists
    GDCA_CURRENT_TASK GDCTask:4		;current task being performed
    GDCA_DO_NOT_SAVE_FILES:1		;Working model support...

	; Version 2.1 and above
	
    GDCA_FORCE_DEMAND_PAGING:1		;Forces demand-paging of documents,
					;even on systems that force documents
					;completely into memory for space
					;reasons.
    :2
GenDocumentControlAttrs	end


GenDocumentControlFeatures	record

	; File features

    GDCF_READ_ONLY_SUPPORTS_SAVE_AS_REVERT:1
					;Allow read-only files to be edited
    GDCF_SINGLE_FILE_CLEAN_CAN_NEW_OPEN:1	;Although multiple files are
						;not allowed, new and open
						;can be handled when the
						;document is clean
    GDCF_SUPPORTS_TEMPLATES:1		;Supports template documents
    GDCF_SUPPORTS_USER_SETTABLE_EMPTY_DOCUMENT:1
    GDCF_SUPPORTS_USER_SETTABLE_DEFAULT_DOCUMENT:1
    GDCF_SUPPORTS_USER_MAKING_SHARED_DOCUMENTS:1

	; UI features

    GDCF_NAME_ON_PRIMARY:1		;Display doc name on primary

	; more File features

    GDCF_SINGLE_DOCUMENT:1		;Supports single document: no
					;Open/New... and Close in File menu
    :8
GenDocumentControlFeatures	end

GenFileSelectorType	etype	byte
GFST_DOCUMENTS		enum	GenFileSelectorType
GFST_EXECUTABLES	enum	GenFileSelectorType
GFST_NON_GEOS_FILES	enum	GenFileSelectorType
GFST_ALL_FILES		enum	GenFileSelectorType

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

    GDCI_documentToken		GeodeToken <>	; document's token

    GDCI_selectorType	GenFileSelectorType GFST_DOCUMENTS

    GDCI_attrs		GenDocumentControlAttrs \
			 (GDCM_SHARED_SINGLE shl offset GDCA_MODE) or \
			 mask GDCA_VM_FILE or \
			 mask GDCA_SUPPORTS_SAVE_AS_REVERT or \
			 (GDCT_NEW shl offset GDCA_CURRENT_TASK)

    GDCI_features	GenDocumentControlFeatures \
			 mask GDCF_READ_ONLY_SUPPORTS_SAVE_AS_REVERT or \
			 mask GDCF_SINGLE_FILE_CLEAN_CAN_NEW_OPEN or \
			 mask GDCF_SUPPORTS_TEMPLATES or \
			 mask GDCF_SUPPORTS_USER_SETTABLE_EMPTY_DOCUMENT or \
			 mask GDCF_SUPPORTS_USER_SETTABLE_DEFAULT_DOCUMENT or\
			 mask GDCF_SUPPORTS_USER_MAKING_SHARED_DOCUMENTS or \
			 mask GDCF_NAME_ON_PRIMARY

    GDCI_docAttrs	GenDocumentAttrs ;attributes for target doc
    GDCI_docType	GenDocumentType	;attributes for target doc
    GDCI_docFileHandle	hptr
	noreloc GDCI_docFileHandle
    GDCI_emptyExists	BooleanByte
    GDCI_defaultExists	BooleanByte

    GDCI_enableDisableList lptr	;list of objects to enable/disable
					;depending on whether a document is
					;present
    GDCI_openGroup	optr		;objects to include in 'open' box
    GDCI_importGroup	optr		;import objects for 'open' dialog box
    GDCI_useTemplateGroup optr		;objects to include in 'use temp' box
    GDCI_saveAsGroup	optr		;objects to include in 'save as' box
    GDCI_exportGroup	optr		;export objects for 'save as' dialog
    GDCI_dialogGroup	optr		;objects for main dialog
    GDCI_userLevelGroup	optr		;dialog for set user level

    GDCI_noNameText	lptr		;text to use if displaying no file name
    GDCI_defaultFile	lptr		;name of default file (0 if none)
					;GEOS character set
    GDCI_templateDir	lptr		;directory name for templates
    GDCI_documentGroup	optr		;GenDocumentGroup object
    GDCI_targetDocName	FileLongName

    GDCI_dialogNewText	lptr		;text to use for "New" in big dialog
    GDCI_dialogTemplateText lptr	;text to use for Template" in big dialog
    GDCI_dialogOpenDefaultText lptr	;text to use for "Open Default" in big
    GDCI_dialogImportText lptr		;text to use for "Import" in big dialog
    GDCI_dialogOpenText	lptr		;text to use for "Open" in big dialog
    GDCI_dialogUserLevelText lptr	;text to use for "Cancel" in big dialog

    GDCI_dialogNewMoniker lptr		;moniker to use for "New" in big
    GDCI_dialogTemplateMoniker lptr	;moniker to use for Template" in big
    GDCI_dialogOpenDefaultMoniker lptr	;moniker to use for "Open Default" in
    GDCI_dialogImportMoniker lptr	;moniker to use for "Import" in big
    GDCI_dialogOpenMoniker lptr		;moniker to use for "Open" in big
    GDCI_dialogUserLevelMoniker lptr	;moniker to use for "Cancel" in big

GenDocumentControlClass	endc

EndLibrary	ui
