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

	Copyright (c) GeoWorks 1989 -- All Rights Reserved

PROJECT:	PC GEOS
FILE:		uDialog.def

DECLARER:	UI

DESCRIPTION:
	This file defines UI dialog box structures and routines.

	$Id: uDialog.def,v 1.1 97/04/04 14:22:46 newdeal Exp $

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

SetDef	__UDIALOG

StartLibrary	ui

include	Objects/gInterC.def	; for GenInteractionType

global UserDoDialog:far		; To invoke a modal dialog box
; See /staff/pcgeos/Library/User/Doc/UserDoDialog.doc for documentation.

global UserCreateDialog:far
global UserDestroyDialog:far

global USERCREATEDIALOG:far
global USERDESTROYDIALOG:far

global USERSTANDARDDIALOG:far	; Standard modal dialog boxes
global USERSTANDARDDIALOGOPTR:far	; Standard modal dialog boxes

global USERDODIALOG:far
UserStandardDialog	equ	USERSTANDARDDIALOG
UserStandardDialogOptr	equ	USERSTANDARDDIALOGOPTR

;
; Parameters to UserStandardDialog
;


;----------------------------------------------------------------------------

;
; This is used to determine what glyph to put into the dialog box displayed
; by UserStandardDialog if a custom box is desired.
;
CustomDialogType	etype	byte
CDT_QUESTION		enum	CustomDialogType
	; Ask the user a question, such as "Save changes to 'foo' before
	; quitting ?" -- The associated text should normally end in a
	; question mark
CDT_WARNING		enum	CustomDialogType
	; Warning the user "This action can cause loss of data"
CDT_NOTIFICATION	enum	CustomDialogType
	; Notifying the user "New mail has arrived"
CDT_ERROR		enum	CustomDialogType
	; Error condition "cannot open file"; error beep when dialog is
	; displayed

;
; This is passed to UserStandardDialog if a custom dialog box is desired.
;
CustomDialogBoxFlags	record
    CDBF_SYSTEM_MODAL:1
    CDBF_DIALOG_TYPE		CustomDialogType:2
    CDBF_INTERACTION_TYPE	GenInteractionType:4

    CDBF_DESTRUCTIVE_ACTION:1=0
    ; This flag signals that the affirmative response to this dialog
    ; denotes a destructive action, and shouldn't be given the
    ; interaction default.  a HINT_TRIGGER_DESTRUCTIVE_ACTION will be
    ; placed on the trigger having an IC_YES interaction command.
    ; This flag can only be used on a GIT_MULTIPLE_RESPONSE dialog.

    :8
CustomDialogBoxFlags	end

;
; When using CDBF_INTERACTION_TYPE = GIT_MULTIPLE_RESPONSE, a table of
; response trigger monikers and response values must be provided
;
StandardDialogResponseTriggerEntry	struct
	SDRTE_moniker		optr
	SDRTE_responseValue	InteractionCommand
StandardDialogResponseTriggerEntry	ends

StandardDialogResponseTriggerTable	struct
	SDRTT_numTriggers	word
	SDRTT_triggers		label	StandardDialogResponseTriggerEntry
StandardDialogResponseTriggerTable	ends

;
; These are the parameters passed to UserStandardDialog and
; MSG_GEN_APPLICATION_DO_STANDARD_DIALOG
;
StandardDialogParams	struct
    SDP_customFlags	CustomDialogBoxFlags	<>
    SDP_customString	fptr
    SDP_stringArg1	fptr
    SDP_stringArg2	fptr
    SDP_customTriggers	fptr.StandardDialogResponseTriggerTable
    SDP_helpContext	fptr
StandardDialogParams	ends

;
; These are the parameters passed to UserStandardDialogOptr
; (must be in same order as StandardDialogParams)
;
StandardDialogOptrParams	struct
    SDOP_customFlags	CustomDialogBoxFlags
    SDOP_customString	optr
    SDOP_stringArg1	optr
    SDOP_stringArg2	optr
    SDOP_customTriggers	fptr.StandardDialogResponseTriggerTable
    SDOP_helpContext	fptr
StandardDialogOptrParams	ends

.assert (offset SDOP_customFlags eq offset SDP_customFlags)
.assert (offset SDOP_customString eq offset SDP_customString)
.assert (offset SDOP_stringArg1 eq offset SDP_stringArg1)
.assert (offset SDOP_stringArg2 eq offset SDP_stringArg2)
.assert (offset SDOP_customTriggers eq offset SDP_customTriggers)
.assert (offset SDOP_helpContext eq offset SDP_helpContext)

;
; Macro to test UserStandardDialog responses
;
TestUserStandardDialogResponses	macro	errorCode, response1, response2, response3
	local	TUSDR_okay
if ERROR_CHECK
	cmp	ax, IC_NULL		; always valid
	je	TUSDR_okay
	cmp	ax, response1
	je	TUSDR_okay
    ifnb <response2>
	cmp	ax, response2
	je	TUSDR_okay
    endif
    ifnb <response3>
	cmp	ax, response3
	je	TUSDR_okay
    endif
	ERROR	errorCode
TUSDR_okay:
endif
endm

EndLibrary	ui
