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

	Copyright (c) GeoWorks 1990 -- All Rights Reserved

PROJECT:	PC GEOS
MODULE:		Impex
FILE:		impex.def

REVISION HISTORY:
	Name	Date		Description
	----	----		-----------
	jimmy	4/91		impex definition
	jenny	9/91		Cleaned up some.

DESCRIPTION:
	This file contains the description of ...

	$Id: impex.def,v 1.1 97/04/04 14:22:57 newdeal Exp $

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

SetDef		__IMPEX

StartLibrary 	impex

include ieCommon.def
UseLib	Objects/gFSelC.def

;-----------------------------------------------------------------------------
;		General Information
;-----------------------------------------------------------------------------
;
; For an application to fully support importing and exporting, it will need
; to have an instance each of ImportControlClass & ExportControlClass. The
; documentation for each of these classes resides under the declaration of
; that class.

;-----------------------------------------------------------------------------
;		ImportExportClass declaration
;-----------------------------------------------------------------------------

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

ImportExportClass	class	GenControlClass, master, variant
			uses	GenControlClass

;-----------------------------------
;	Description
;-----------------------------------

; This is an internal class used as a parent class for the Import & Export
; Class objects. No application nor library will ever want to use an object
; of this class, so don't do it!

;-----------------------------------
;	External messages
;-----------------------------------

;-----------------------------------
;	Internal messages
;-----------------------------------

MSG_IMPORT_EXPORT_SELECT_FORMAT					message
;
; Notify the import or export controller that a format has been selected
; by the user.
;
; Context:	Utility message sent out when the user selects a format
;		in a displayed list.
; Source:	FormatList object
; Destination:	ImportExportClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX	= Selected format # (item in list)
;		DX	= FormatInfo block handle
;		BP	= TRUE if "No Idea" choice is present;
;			  FALSE, otherwise
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_EXPORT_SELECT_FILE					message
;
; Sent to notify us that the user has selected a file for import
;
; Context:	Sent when user clicks on a file (or any other entry
;		in the GenFileSelector).
; Source:	GenFileSelectorClass object
; Destination:	ImportExportClass object
; Interception: Generally should not be intercepted.
;
; Pass:		BP	= GenFileSelectorEntryFlags
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_EXPORT_SHOW_ERROR					message
;
; Display an error dialog box to notify the user of a "bad thing"
;
; Context:	Utility message sent out when an error is determined. The
;		dialog will not block the execution thread, so there is
;		no feedback from the user in response to these messages.
; Source:	Anyone
; Destination:	ImportExportClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX:DX	= Optional argument string (NULL-terminated)
;		BP	= Chunk handle of error string (in Strings resource)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_EXPORT_FILE_SELECTION_INFO				message
;
; Sent whenever a selection is made in the file selector
;
; Context:	Utility message sent solely for the purpose of subclassing
;		the ImportExportControl inside a translation library.
;		Whenever a selection is made by the user in the file selector
;		located in the Import or Export dialog boxes, this message is
;		sent by the Impor/tExportControlClass to itself.
; Source:	ImportControlClass or ExportControlClass object
; Destination:	Method for a sub-class of ImportExportClass in a
;		translation library.
; Interception: Generally intercepted by a translation library, which,
;		when called to provide its Import or Export UI, has
;		returned a ClassStruct which is a sub-class of GenControl.
;		This ClassStruct has been stored as the superclass for
;		the ImportExportClass, thereby allowing a translation
;		library to get this message without actually having
;		an object of class ImportExportClass. Upon intercepting
;		this message, a translation library might open the
;		currently selected file, if any, and enable/disable
;		format options based on the data in the file. Please see
;		the documentation for TR_GET_IMPORT_UI & TR_GET_EXPORT_UI.
;		There is no need to pass this message on to your superclass.
;
; Pass:		DX:BP	= ImpexFileSelectionData
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_EXPORT_FREE_LIBRARY					message
;
; Perform a GeodeFreeLibrary on the passed library handle
;
; Context:	Utility message sent to avoid repeated loading of common
;		libraries as user switches between formats.
; Source:	Anyone
; Destination:	ImportExportClass object
; Interception: Should not be intercepted
;
; Pass:		CX	= Library handle (must be valid)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;


; The following messages are needed for ALLOW_FLOPPY_BASED_LIBS

MSG_IMPORT_EXPORT_FREE_LIBRARY_AND_FORMAT_UI			message
;
; Perform a GeodeFreeLibrary on the passed library handle and remove any
; format UI.
;
; Pass:		cx	= Library handle (must be valid)
; Return:	nothing
; Destroy:	ax, cx, dx, bp
;


protominor ImpexOpCompleted

MSG_IMPORT_EXPORT_OPERATION_COMPLETED				message
;
; Simple notification if an import/export operation was completed.
; Intercept at will - no need to call superclass as this is just
; for external use for things like "batch" import/export.
;
; Pass:		cx	= Boolean (TRUE if successful, FALSE if not)
; Return:	nothing
; Destroy:	nothing
;
protoreset

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

; ImpexDataClasses allows an application select from among a broad class
; of data types, only some of which an application will choose to support
;
; If you add any new data classes, you must add a structure to the
; array defined in Impex/UI/uiImpexFormatsAndLibs.asm under "tokenTable"

ImpexDataClasses 	record
    IDC_TEXT:1
    IDC_GRAPHICS:1
    IDC_SPREADSHEET:1
    IDC_FONT:1
    :12
ImpexDataClasses 	end

NUMBER_IMPEX_DATA_CLASSES	= 4	; postscript is a subset of graphics,
					;  so there are 4 data classes, but
					;  5 tokens.

; The tokens expected for each type of translation library class

XLAT_TOKEN_TEXT_12		=	'T' or ('L' shl 8)
XLAT_TOKEN_TEXT_34		=	'T' or ('X' shl 8)

XLAT_TOKEN_GRAPHICS_12		=	'T' or ('L' shl 8)
XLAT_TOKEN_GRAPHICS_34		=	'G' or ('R' shl 8)

XLAT_TOKEN_SPREADSHEET_12	=	'T' or ('L' shl 8)
XLAT_TOKEN_SPREADSHEET_34	=	'S' or ('S' shl 8)

XLAT_TOKEN_FONT_12		=	'T' or ('L' shl 8)
XLAT_TOKEN_FONT_34		=	'F' or ('N' shl 8)

XLAT_TOKEN_POSTSCRIPT_12	=	'T' or ('L' shl 8)
XLAT_TOKEN_POSTSCRIPT_34	=	'P' or ('S' shl 8)

; Structure passed with MSG_IMPORT_EXPORT_FILE_SELECTION_INFO
;
ImpexFileSelectionData	struct
    IFSD_selection	FileLongName
    IFSD_path		PathName
    IFSD_disk		word
    IFSD_type		GenFileSelectorEntryFlags
ImpexFileSelectionData	ends


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


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

TempImportExportData	struct
    TIED_formatUI	optr			; OD of duplicated format UI
    TIED_formatLibrary	hptr			; handle of library for above
TempImportExportData	ends

TEMP_IMPORT_EXPORT_DATA			vardata	TempImportExportData


;-----------------------------------
;	Attrs
;-----------------------------------

ATTR_IMPORT_EXPORT_TRANSPARENT_MODE	vardata
;
; Used when the DocuumentControl is integrated with the Import/Export
; system. Causes the ImportControl and ExportControl objects to display
; different error messages and in general act a bit differently from
; the "normal" mode, where the user explicitly chooses Import or
; Export from a menu somewhere.

protominor ImpexOpCompleted

ATTR_IMPORT_EXPORT_HIDE_ERRORS		vardata
;
; Used when the Import/ExportControl is not to show any error messages.

protoreset

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

ImportExportClass	endc



;-----------------------------------------------------------------------------
;		ImportControlClass declaration
;-----------------------------------------------------------------------------

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

ImportControlClass	class	ImportExportClass

;-----------------------------------
;	How importing works
;-----------------------------------

;-----------------------------------
;	External messages
;-----------------------------------

MSG_IMPORT_CONTROL_SET_DATA_CLASSES				message
;
; Sets the data classes for which import is possible. The names of
; the file formats which belong to these data classes will be displayed
; to the user in the Import dialog box. If the message is sent while
; the Import dialog box is visible to the user, the list of formats
; will be re-built.
;
; Context:	Utility message sent to change the formats the user can
;		choose from
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX	= ImpexDataClasses
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_GET_DATA_CLASSES				message
;
; Gets the data classes for which import is currently possible. 
;
; Context:	Utility message sent to find state of the object
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	CX	= ImpexDataClasses
;		Nothing - destroyed
;

MSG_IMPORT_CONTROL_SET_ACTION		 			message
;
; Sets the message to be sent upon beginning an import and the
; destination to send it to
;
; Context:	Utility message sent to change the recipient of notification
;		that an import has been requested by the user.
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX:DX	= Destination OD
;		BP	= Message
;			 (see parameter documention for ICI_message below)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_SET_MSG		 			message
;
; Sets the message to be sent when an import is initiated.
;
; Context:	Utility message sent to change the recipient of notification
;		that an import has be requested by the user.
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX = Message
;			 (see parameter documention for ICI_message below)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_GET_ACTION					message
;
; Gets the destination OD & message for import notification.
;
; Context:	Utility message for finding out where notification
;   	    	of beginning import is sent and what message is used.
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	CX:DX	= Destination OD
;		BP	= Message
;		Nothing - destroyed
;

MSG_IMPORT_CONTROL_SET_ATTRS					message
;
; Sets the attributes for an ImportControl object.
;
; Context:	Utility message sent to change the attributes for this object
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX	= ImportControlAttrs
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_GET_ATTRS					message
;
; Gets the attributes for an ImportControl object.
;
; Context:	Utility message sent to find state of the object
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	CX	= ImportControlAttrs
;		Nothing - destroyed
;

MSG_IMPORT_CONTROL_GET_FILE_SELECTOR_OFFSET			message
;
; Get the offset of the import file selector
;
; Context:	The controller needs to know the import file selector offset.
; Source:	ImportControlClass object
; Destination:	ImportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		IMPORTCF_BASIC feature. Need not be passed to superclass.
;
; Pass:		DX	= ImportControlFeatures bitmask
;
; Return:	CX	= offset of import file selector
;		Nothing destroyed
;

MSG_IMPORT_CONTROL_GET_FORMAT_LIST_OFFSET			message
;
; Get the offset of the import format list
;
; Context:	The controller needs to know the import format list offset.
; Source:	ImportControlClass object
; Destination:	ImportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		IMPORTCF_BASIC feature. Need not be passed to superclass.
;
; Pass:		DX	= ImportControlFeatures bitmask
;
; Return:	CX	= offset of import format list
;		Nothing destroyed
;

MSG_IMPORT_CONTROL_GET_FILE_MASK_OFFSET				message
;
; Get the offset of the import file mask
;
; Context:	The controller needs to know the import file mask offset.
; Source:	ImportControlClass object
; Destination:	ImportControlClass object
; Interception:	May be intercepted by app if app has turned off the
;		IMPORTCF_FILE_MASK feature. Need not be passed to superclass.
;
; Pass:		DX	= ImportControlFeatures bitmask
;
; Return:	CX	= offset of import file mask
;		Nothing destroyed
;

MSG_IMPORT_CONTROL_GET_FORMAT_UI_PARENT_OFFSET			message
;
; Get the offset of the import format UI parent
;
; Context:	The controller needs to know the offset of the
;		import format UI parent object.
; Source:	ImportControlClass object
; Destination:	ImportControlClass object
; Interception:	May be intercepted by app if app has turned off the
;		IMPORTCF_FORMAT_OPTIONS feature. Need not be passed to
;		superclass.
;
; Pass:		DX	= ImportControlFeatures bitmask
;
; Return:	CX	= offset of import format UI parent
;		Nothing destroyed
;

MSG_IMPORT_CONTROL_GET_APP_UI_PARENT_OFFSET			message
;
; Get the offset of the import app UI parent
;
; Context:	The controller needs to know the offset of the
;		import app UI parent object.
; Source:	ImportControlClass object
; Destination:	ImportControlClass object
; Interception:	May be intercepted by app if app has turned off the
;		IMPORTCF_BASIC feature. Need not be passed to superclass.
;
; Pass:		DX	= ImportControlFeatures bitmask
;
; Return:	CX	= offset of import app UI parent
;		Nothing destroyed.
;

MSG_IMPORT_CONTROL_GET_IMPORT_TRIGGER_OFFSET			message
;
; Get the offset of the import trigger.
;
; Context:	The controller needs to know the import trigger offset.
; Source:	ImportControlClass object
; Destination:	ImportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		IMPORTCF_IMPORT_TRIGGER feature. Need not be passed to
;		superclass.
;
; Pass:		DX	= ImportControlFeatures bitmask
;
; Return:	CX	= offset of import trigger	
;		Nothing destroyed
;

MSG_IMPORT_CONTROL_IMPORT_COMPLETE				message
; 
; Sent by the application when it has completed the import.
;
; Context:	Sent after an application has obtained all the data it
;		requires from the transfer format passed to it in the
;		ImpexTranslationParams structure sent out on import.
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		SS:BP	= ImpexTranslationParams (structure passed to app earlier)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

;-----------------------------------
;	Internal messages
;-----------------------------------

MSG_IMPORT_CONTROL_SET_FILE_MASK				message
;
; Set the file mask string (eg. "*.FOO") to be used by the FileSelector
; in displaying files to the user 
;
; Context:	Sent when the user hits return after editing the file
;		specification string, or when a new format is selected.
; Source:	Text object of self
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_IMPORT					message
;
;  Initiate an import with the selected file.
;
; Context:	The user has clicked on the "Import" trigger
; Source:	Import trigger
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_CANCEL					message
;
; Cancel the import
;
; Context:	The user has clicked on the "Cancel" trigger
; Source:	Aforementioned GenTrigger
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_IMPORT_CONTROL_CONTINUE_IMPORT				message
;
; Redwood-only, called after all necessary files have been saved or closed, to 
; do the real meat of the import work.
;

; The following messages are needed for ALLOW_FLOPPY_BASED_LIBS

MSG_IMPORT_CONTROL_NEW_LIBRARY_DISK				message
;
; Rescan disk for translation libraries.
;
; Pass:		nothing
; Return:	nothing
; Destroy:	ax, cx, dx, bp
;

MSG_IMPORT_CONTROL_GET_FORMAT_GROUP_OFFSET			message
;
; Get the offset of the FormatGroup
;
; Pass:		nothing
; Return:	cx = offset of FormatGroup
; Destroy:	nothing
;

MSG_IMPORT_CONTROL_GET_FILE_SELECT_GROUP_OFFSET			message
;
; Get the offset of the FileSelectGroup
;
; Pass:		nothing
; Return:	cx = offset of FileSelectGroup
; Destroy:	nothing
;

MSG_IMPORT_CONTROL_INSERT_LIBRARY_DISK_RESPONSE			message
;
; Sent when user responds to "insert library disk" dialog
;
; Pass:		cx = InteractionCommand
; Return:	nothing
; Destroy:	ax, cx, dx, bp
;

MSG_IMPORT_CONTROL_GET_FILE_SELECTOR				message
;
; Returns the optr of the file selector, if built out.
;
; Pass:		nothing
; Return:	^lcx:dx = GenFileSelector, or carry set if not built
; Destroy:	ax, bp
;

protominor ImpexOpCompleted

MSG_IMPORT_CONTROL_AUTO_DETECT_FILE_FORMAT			message
;
; EXTERNAL MESSAGE
; Tries to auto-detect the format of the file currently selected for import.
;
; Pass:		nothing
; Return:	carry set if unable to auto-detect format, otherwise clear.
; Destroy:	ax
; Side Effects:	Sets format selector to "No idea".
;

protoreset

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

ImportControlAttrs	record
    ICA_IGNORE_INPUT:1			; ignore input while import occurs
    ICA_NON_DOCUMENT_IMPORT:1		; non-document imports only
    :14
ImportControlAttrs	end

; Features flags (used with ATTR_GEN_CONTROL_REQUIRE/PROHIBIT_UI)
;
ImportControlFeatures	record
    IMPORTCF_PREVIEW_TRIGGER:1		; not currently used
    IMPORTCF_IMPORT_TRIGGER:1		; import trigger
    IMPORTCF_FORMAT_OPTIONS:1		; import format UI parent,
					;  under which is placed any
					;  UI specific to the
					;  currently selected format
    IMPORTCF_FILE_MASK:1		; import file mask
    IMPORTCF_BASIC:1			; import file selector,
					;  import format list, and
					;  import app UI parent, under
					;  which is placed any UI
					;  specific to the app
    IMPORTCF_GLYPH:1			; glyph at top of import
					;  dialog box
ImportControlFeatures	end

IMPORTC_DEFAULT_FEATURES	equ	mask IMPORTCF_GLYPH or \
					mask IMPORTCF_BASIC or \
					mask IMPORTCF_FILE_MASK or \
					mask IMPORTCF_FORMAT_OPTIONS or \
					mask IMPORTCF_IMPORT_TRIGGER

; Toolbox features flags used with ATTR_GEN_CONTROL_REQUIRE/PROHIBIT_TOOLBOX_UI
;
ImportControlToolboxFeatures	record
    IMPORTCTF_DIALOG_BOX:1
ImportControlToolboxFeatures	end

IMPORTC_DEFAULT_TOOLBOX_FEATURES	equ	mask IMPORTCTF_DIALOG_BOX

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

    ICI_attrs		ImportControlAttrs	; attributes for the object
    ICI_dataClasses	ImpexDataClasses	; data type available for import
    ICI_destination	optr			; destination for import message
    ICI_message		word			; message sent for import
	;
	; Synopsis:	Perform the import of the passed data
	;
	; Pass:		SS:BP	= ImpexTranslationParams
	;
	; Returns:	Nothing
	;		AX, CX, DX, BP - destroyed


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


;-----------------------------------
;	Attrs
;-----------------------------------

ATTR_IMPORT_CONTROL_APP_UI		vardata	optr
;
; Attribute to allow applications to add their own UI to the Import DB.
; The generic tree whose optr is stored here nust *not* be set USABLE.
; Use this in lieu of ATTR_GEN_CONTROL_APP_UI.

ATTR_IMPORT_CONTROL_CANCEL_DESTINATION	vardata	optr
ATTR_IMPORT_CONTROL_CANCEL_MESSAGE	vardata	word


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

ImportControlClass	endc



;-----------------------------------------------------------------------------
;		ExportControlClass declaration
;-----------------------------------------------------------------------------

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

ExportControlClass	class	ImportExportClass

;-----------------------------------
;	How exporting works
;-----------------------------------

;-----------------------------------
;	External messages
;-----------------------------------

MSG_EXPORT_CONTROL_SET_DATA_CLASSES				message
;
; Sets the data classes for which export is possible. The names of
; the file formats which belong to these data classes will be displayed
; to the user in the Export dialog box. If the message is sent while
; the Export dialog box is visible to the user, the list of formats
; will be re-built.
;
; Context:	Utility message sent to change the formats the user can
;		choose from
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX	= ImpexDataClasses
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_EXPORT_CONTROL_GET_DATA_CLASSES				message
;
; Gets the data classes for which export is currently possible.
;
; Context:	Utility message sent to find state of the object
; Source:	Anyone
; Destination:	ImportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	CX	= ImpexDataClasses
;		Nothing - destroyed
;

MSG_EXPORT_CONTROL_SET_ACTION		 			message
;
; Sets the message to be sent upon beginning an export and the
; destination to send it to
;
; Context:	Utility message sent to change the recipient of notification
;		that an export has been requested by the user.
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX:DX	= Destination OD
;		BP	= Message
;			 (see parameter documention for ECI_message below)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_EXPORT_CONTROL_SET_MSG		 			message
;
; Sets the message to be sent when an Export is initiated.
;
; Context:	Utility message sent to change the recipient of notification
;		that an export has be requested by the user.
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX	= Message
;			 (see parameter documention for ECI_message below)
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_EXPORT_CONTROL_GET_ACTION					message
;
; Gets the destination OD & message for export notification
;
; Context:	Utility message for finding out where notification
;   	    	of beginning export is sent and what message is used.
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	CX:DX	= Destination OD
;		BP	= Message
;		Nothing - destroyed
;

MSG_EXPORT_CONTROL_SET_ATTRS					message
;
; Sets the attributes for an ExportControl object
;
; Context:	Utility message sent to change the attributes for this object
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		CX	= ExportControlAttrs
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

MSG_EXPORT_CONTROL_GET_ATTRS					message
;
; Gets the attributes for an ExportControl object
;
; Context:	Utility message sent to find state of the object
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	CX	= ExportControlAttrs
;		Nothing - destroyed
;

MSG_EXPORT_CONTROL_GET_FILE_SELECTOR_OFFSET			message
;
; Get the offset of the export file selector
;
; Context:	The controller needs to know the export file selector offset.
; Source:	ExportControlClass object
; Destination:	ExportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		EXPORTCF_BASIC feature
;
; Pass:		DX	= ExportControlFeatures bitmask
;
; Return:	CX	= offset of export file selector
;		Nothing destroyed
;

MSG_EXPORT_CONTROL_GET_FORMAT_LIST_OFFSET			message
;
; Get the offset of the export format list
;
; Context:	The controller needs to know the export format list offset.
; Source:	ExportControlClass object
; Destination:	ExportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		EXPORTCF_BASIC feature
;
; Pass:		DX	= ExportControlFeatures bitmask
;
; Return:	CX	= offset of export format list
;		Nothing destroyed
;

MSG_EXPORT_CONTROL_GET_FILE_NAME_OFFSET				message
;
; Get the offset of the export file name
;
; Context:	The controller needs to know the export file name offset.
; Source:	ExportControlClass object
; Destination:	ExportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		EXPORTCF_BASIC feature
;
; Pass:		DX	= ExportControlFeatures bitmask
;
; Return:	CX	= offset of export file name
;		Nothing destroyed
;

MSG_EXPORT_CONTROL_GET_FORMAT_UI_PARENT_OFFSET			message
;
; Get the offset of the export format UI parent
;
; Context:	The controller needs to know the offset of the
;		export format UI parent object.
; Source:	ExportControlClass object
; Destination:	ExportControlClass object
; Interception:	May be intercepted by app if app has turned off the
;		EXPORTCF_FORMAT_OPTIONS feature
;
; Pass:		DX	= ExportControlFeatures bitmask
;
; Return:	CX	= offset of export format UI parent
;		Nothing destroyed
;

MSG_EXPORT_CONTROL_GET_APP_UI_PARENT_OFFSET			message
;
; Get the offset of the export app UI parent
;
; Context:	The controller needs to know the offset of the
;		export app UI parent object.
; Source:	ExportControlClass object
; Destination:	ExportControlClass object
; Interception:	May be intercepted by app if app has turned off the
;		EXPORTCF_BASIC feature
;
; Pass:		DX	= ExportControlFeatures bitmask
;
; Return:	CX	= offset of export app UI parent
;		Nothing destroyed
;

MSG_EXPORT_CONTROL_GET_EXPORT_TRIGGER_OFFSET			message
;
; Get the offset of the export trigger.
;
; Context:	The controller needs to know the export trigger offset.
; Source:	ExportControlClass object
; Destination:	ExportControlClass object
; Interception:	Should be intercepted by app if app has turned off the
;		EXPORTCF_EXPORT_TRIGGER feature
;
; Pass:		DX	= ExportControlFeatures bitmask
;
; Return:	CX	= offset of export trigger	
;		Nothing destroyed
;

MSG_EXPORT_CONTROL_EXPORT_COMPLETE				message
; 
; Sent by the application when it has completed the export
;
; Context:	Sent after an application has created the transfer format
;		to be exported to another data format
; Source:	Anyone
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		SS:BP	= ImpexTranslationParams (structure passed to app earlier,
;			  with GTP_transferVMChain filled in).
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;


;-----------------------------------
;	Internal messages
;-----------------------------------

MSG_EXPORT_CONTROL_EXPORT					message
;
;  Initiate an export into the selected file
;
; Context:	The user has clicked on the "Export" trigger
; Source:	Export trigger
; Destination:	ExportControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		AX, CX, DX, BP - destroyed
;

; The following messages are needed for ALLOW_FLOPPY_BASED_LIBS

MSG_EXPORT_CONTROL_NEW_LIBRARY_DISK				message
;
; Rescan disk for translation libraries.
;
; Pass:		nothing
; Return:	nothing
; Destroy:	ax, cx, dx, bp
;

MSG_EXPORT_CONTROL_CANCEL					message
;
; Cancel export
;
; Pass:		nothing
; Return:	nothing
; Destroy:	ax, cx, dx, bp
;

MSG_EXPORT_CONTROL_GET_FORMAT_GROUP_OFFSET			message
;
; Get the offset of the FormatGroup
;
; Pass:		nothing
; Return:	cx = offset of FormatGroup
; Destroy:	nothing
;

MSG_EXPORT_CONTROL_GET_FILE_SELECT_GROUP_OFFSET			message
;
; Get the offset of the FileSelectGroup
;
; Pass:		nothing
; Return:	cx = offset of FileSelectGroup
; Destroy:	nothing
;

MSG_EXPORT_CONTROL_INSERT_LIBRARY_DISK_RESPONSE			message
;
; Sent when user responds to "insert library disk" dialog
;
; Pass:		cx = InteractionCommand
; Return:	nothing
; Destroy:	ax, cx, dx, bp
;

MSG_EXPORT_CONTROL_GET_FILE_NAME_FIELD				message
;
; Returns the optr of the text object holding the new file name.
;
; Context:	You might want to muck with the name in the text object.
;
; Pass:		nothing
; Return:	^lcx:dx = text obj optr, or carry set if not built
; Destroyed:	nothing
;

MSG_EXPORT_CONTROL_GET_FORMAT_LIST				message
;
; Returns the optr of the text object holding the new file name.
;
; Context:	Call to get the format list if you want to select
;		the output format automatically.
;
; Pass:		nothing
; Return:	^lcx:dx = format list optr, or carry set if not built
; Destroyed:	nothing
;

MSG_EXPORT_CONTROL_GET_FILE_SELECTOR				message
;
; Returns the optr of the file selector, if built out.
;
; Pass:		nothing
; Return:	^lcx:dx = GenFileSelector, or carry set if not built
; Destroy:	nothing
;

;-----------------------------------
;	Constants
;-----------------------------------

ExportControlAttrs	record
    ECA_IGNORE_INPUT:1			; ignore input while export occurs
    :15
ExportControlAttrs	end

; Features flags (used with ATTR_GEN_CONTROL_REQUIRE/PROHIBIT_UI)
;
ExportControlFeatures	record
    EXPORTCF_EXPORT_TRIGGER:1		; export trigger
    EXPORTCF_FORMAT_OPTIONS:1		; export format UI parent,
					;  under which is placed any UI
					;  specific to the currently
					;  selected format
    EXPORTCF_BASIC:1			; export file selector,
					;  export format list,
					;  export file name, and
					;  export app UI parent, under
					;  which is placed any UI
					;  specific to the app
    EXPORTCF_GLYPH:1			; glyph at top of export
					;  dialog box
ExportControlFeatures	end

EXPORTC_DEFAULT_FEATURES	equ	mask EXPORTCF_BASIC or \
					mask EXPORTCF_FORMAT_OPTIONS or \
					mask EXPORTCF_EXPORT_TRIGGER

; Toolbox features flags used with ATTR_GEN_CONTROL_REQUIRE/PROHIBIT_TOOLBOX_UI
;
ExportControlToolboxFeatures	record
    EXPORTCTF_DIALOG_BOX:1
ExportControlToolboxFeatures	end

EXPORTC_DEFAULT_TOOLBOX_FEATURES	equ	mask EXPORTCTF_DIALOG_BOX


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

    ECI_attrs		ExportControlAttrs	; attributes for the object
    ECI_dataClasses	ImpexDataClasses	; data type available for import
    ECI_destination	optr			; destination for import message
    ECI_message		word			; message sent for import
	;
	; Synopsis:	Perform the export of the current data
	;
	; Pass:		SS:BP	= ImpexTranslationParams
	;
	; Returns:	AX:BP	= VMChain containing transfer format
	;			= 0:0 if error
	;		CX, DX - destroyed

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

;-----------------------------------
;	Attrs
;-----------------------------------

ATTR_EXPORT_CONTROL_APP_UI		vardata	optr
;
; Attribute to allow applications to add their own UI to the Export DB.
; The generic tree whose optr is stored here nust *not* be set USABLE.
; Use this in lieu of ATTR_GEN_CONTROL_APP_UI.


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

TEMP_EXPORT_CONTROL_IMPEX_THREAD_INFO	vardata	hptr
;
; Internal: Temporary storage for ImpexThreadInfo handle
;

ExportControlClass	endc


;-----------------------------------------------------------------------------
;		ImpexMapControlClass declaration
;-----------------------------------------------------------------------------

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

ImpexMapControlClass	class   GenControlClass

;-----------------------------------------------------------------------------
;		Methods
;-----------------------------------------------------------------------------

;-----------------------------------------------------------------------------
;		Internal methods
;-----------------------------------------------------------------------------
MSG_IMC_UNMAP						message
;
; Remove a mapped entry from the map list 
;
; Context:	The user has clicked on the "UnMap" trigger
; Source:	UnMap trigger
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		AX, BX, SI, DI - destroyed
;
MSG_IMC_MAP_ENTRY					message
;
; Mapps the currently selected source entry to 
; the currently selected destination entry
;
; Context:	The user has clicked on the "Map" trigger
; Source:	Map trigger
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		AX, BX, CX, DX, SI, DI, BP - destroyed
;
MSG_IMC_REQUEST_SOURCE_MONIKER				message
;
; Get the moniker for the source map list
;
; Context:	Sent when you initialize the source map list	
; Source:	ImpexMapSourceList
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		bp - identifier
;
; Return:	Nothing
;		AX, BX, CX, DX, SI, DI - destroyed
;
MSG_IMC_REQUEST_DEST_MONIKER				message
;
; Get the moniker for the destination map list
;
; Context:	Sent when you initialize the destination map list	
; Source:	ImpexMapDestList
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		bp - identifier
;
; Return:	Nothing
;		AX, BX, CX, DX, SI, DI - destroyed
;
MSG_IMC_REQUEST_MAP_MONIKER				message
;
; Get the moniker for the map list
;
; Context:	Sent when you click on the "Map" button.	
; Source:	ImpexMapMapList
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		bp - identifier
;
; Return:	Nothing
;		AX, BX, CX, DX, SI, DI - destroyed
;
MSG_IMC_MAP_DONE	message
;
; Put up a warning dialog box if no fields have been mapped  
;
; Context:	Sent when you click on "Done" trigger
; Source:	Done trigger
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		BX, SI, DS - destroyed
;
MSG_IMC_MAP_CANCEL	message
;
; Deletes the map list block and re-init the map list 
;
; Context:	The user has clicked on the "Cancel" trigger
; Source:	Cancel trigger
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	Nothing
;		BX - destroyed
;
MSG_IMC_MAP_GET_MAP_DATA	message
;
; Return handle of map list block 
;
; Context:	Import or export is about to commence.
; Source:	Database Translation Library
; Destination:	ImpexMapControlClass object
; Interception: Generally should not be intercepted.
;
; Pass:		Nothing
;
; Return:	DX - handle of map list block
;
;-----------------------------------------------------------------------------
;		Hints
;-----------------------------------------------------------------------------

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

SOURCE		equ	0	
DESTINATION	equ	1

; Features flags (used with ATTR_GEN_CONTROL_REQUIRE_UI and
; ATTR_GEN_CONTROL_PROHIBIT_UI)

IMCFeatures	record
    :7,
    IMCF_MAP:1
IMCFeatures	end

IMC_DEFAULT_FEATURES equ mask IMCF_MAP

IMC_DEFAULT_TOOLBOX_FEATURES equ 0

IMC_MAP_MONIKER_SIZE		equ	1024	

ImpexMapFlags	record
	IMF_IMPORT:1,
	IMF_EXPORT:1,
	:6
ImpexMapFlags	end

DefaultFieldNameUsage	etype	byte, 	0
	DFNU_FIELD	enum	DefaultFieldNameUsage
	DFNU_COLUMN	enum	DefaultFieldNameUsage
	DFNU_FIXED	enum	DefaultFieldNameUsage

ImpexMapFileInfoHeader	struc
	IMFIH_base		LMemBlockHeader
	IMFIH_fieldChunk	word
	IMFIH_numFields		word
	IMFIH_flag		DefaultFieldNameUsage
ImpexMapFileInfoHeader	ends

MapListBlockHeader	struc
	MLBH_base		LMemBlockHeader
	MLBH_numDestFields	word
	MLBH_chunk1		word
MapListBlockHeader	ends

ChunkMapList		struc
	CML_source	word
	CML_dest	word
ChunkMapList		ends

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

	IMCI_dataBlock1		word		; application data block
	IMCI_dataBlock2		word		; trans. lib. data block
	IMCI_childBlock		word
	IMCI_mapListBlock	word
	IMCI_flags		ImpexMapFlags

ImpexMapControlClass	endc



;-----------------------------------------------------------------------------
;		Impex routines called by translation libraries
;-----------------------------------------------------------------------------

IMPEX_TEMP_VM_FILE	equ	0xffff
IMPEX_TEMP_NATIVE_FILE	equ	0x0000

global	ImpexCreateTempFile:far
;
; Utility routine to create and open a unique temporary file to be used by
; a translation library for import or export.
;
; Pass:		ES:DI	= file name buffer
;		AX	= IMPEX_TEMP_VM_FILE or IMPEX_TEMP_NATIVE_FILE
;
; Return:	ES:DI	= file name buffer filled
;		BP	= new file handle
;		AX	= TransError (0 = no error)
;		BX	= memory handle of error text if ax = TE_CUSTOM
;
; Destroyed:	Nothing
;

global	ImpexDeleteTempFile:far
;
; Utility routine to close and delete a temporary file that was created by
; calling ImpexCreateMetafile.
;
; Pass:		DS:DX	= file name buffer
;		BX	= file handle of open metafile
;		AX	= IMPEX_TEMP_VM_FILE or IMPEX_TEMP_NATIVE_FILE
;		
; Return:	AX	= TransError (0 = no error)
;		BX	= memory handle of error text if ax = TE_CUSTOM
;
; Destroyed:	Nothing
;

global	ImpexImportFromMetafile:far
;
; Convert a metafile to a transfer format, by calling an intermediate
; metafile conversion library. This is to be used by translation libraries
; that use an intermediate metafile format.
;
; Pass:		BX	= handle of metafile translation library to use
;		AX	= routine number of library routine to call
;		DI	= handle of VM file to hold transfer format
;		BP	= handle of the metafile (open for read)
;		DS, SI	= additional data for metafile library as needed
;
; Return:	DX:CX	= VM chain containing transfer format
;		AX	= TransError code (0 = no error)
;		BX	= memory handle of error text if ax = TE_CUSTOM
;
; Destroyed:	Nothing
;

global	ImpexExportToMetafile:far
;
; Convert a transfer format to a metafile, by calling an intermediate
; metafile conversion library. This is to be used by translation libraries
; that use an intermediate metafile format.
;
; Pass:		BX	= handle of metafile translation library to use
;		AX	= entry point number of library routine to call
;		DX:CX	= VM chain containing transfer format
;		DI	= VM file handle of transfer format
;		BP	= handle of the metafile (open for read/write)
;		DS, SI	= additional data for metafile library as needed
;
; Return:	AX	= TransError code (0 = no error)
;		BX	= memory handle of error text if ax = TE_CUSTOM
;
; Destroyed:	Nothing
;

global	ImpexUpdateImportExportStatus:far
;
; Apprise the user of the status of an import or export. This routine should
; only be called by translation libraries, and can be called at any time
; during the import/export process. If a translation library chooses not
; to call this function, the default import/export message will be displayed.
;
; Pass:		DS:SI	= String to display to user
;			  (NULL string to not display a new string)
;		AX	= Percentage completed so far (0->100)
;			  (-1 to not display any percentage)
; 
; Return:	AX	= TRUE to continue import/export
;				- or -
;			= FALSE to discontinue import/export ASAP
;
; Destroyed:	Nothing
;

global	ImpexImportExportCompleted:far
;
; A utility routine called by an application to send back notification to
; an ImportControl or ExportControl object that the requested import or
; export operation has been completed. For import, an application will
; simply pass back a pointer to the passed ImpexTranslationParams. For export,
; the application must complete the GTP_transferVMChain field, and then
; pass the entire structure
;
; Pass:		SS:BP	= ImpexTranslationParams
;
; Return:	Nothing
;
; Destroyed:	Nothing
;

global	FormatEnum:far
;
; Enumerates translation libraries.
;
; Pass:		ds	= if called internally from within Impex library,
;			  the segment of the block containing FormatList
;			  object, so it can report errors that way.  When
;			  calling this routine from outside the Impex lib,
;			  pass NULL_SEGMENT in ds.
;
;		dx	= mask IFA_IMPORT_CAPABLE
;				 - or -
;			= mask IFA_EXPORT_CAPABLE
;		bx	= ImpexDataClasses
;
; Return:	bx	= FormatInfo block handle
;		cx	= # of formats available
;		carry	= clear
;			 - or -
;		cx	= ImpexError
;		carry	= Set		
;
; Destroyed:	ax, dx, di, bp
;

;-----------------------------------------------------------------------------
;	C Versions
;-----------------------------------------------------------------------------

global	IMPEXCREATETEMPFILE:far
global	IMPEXDELETETEMPFILE:far
global  IMPEXIMPORTFROMMETAFILE:far
global  IMPEXEXPORTTOMETAFILE:far
global	IMPEXUPDATEIMPORTEXPORTSTATUS:far
global	IMPEXIMPORTEXPORTCOMPLETED:far

EndLibrary	impex
