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

	Copyright (c) GeoWorks 1989 -- All Rights Reserved

PROJECT:	PC GEOS
FILE:		win.def

DECLARER:	Kernel

DESCRIPTION:
	This file defines Window structures and routines.

	$Id: win.def,v 1.2 97/09/10 14:17:34 newdeal Exp $

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

SetDef	__WIN

StartKernel

WIN_ENTER_LEAVE_CONTROL		= FALSE	; Set to include code for:
					; WinMouseGrab, WinMouseRelease,
					; WinBranchInclude, WinBranchExclude
					; (Routines would have to be added 
					; back into .gp file, & here, as
					; well)  Nuked 3/92 as could only 
					; be used by global UI app under
					; new thread model, & they haven't
					; proved to be useful to it thus 
					; far.  Will keep the code around,
					; as an implementation could possibly
					; be useful at GenApplication level.

WIN_VIS_ENTER_LEAVE		= FALSE ; Set if MSG_META_RAW_VIS_ENTER &
					; MSG_META_RAW_VIS_LEAVE should be generated
					; by the window system


global WinGetWinScreenBounds:far

global WinOpen:far
global WinClose:far
global WinChangePriority:far
global WinScroll:far
global WinBitBlt:far
global GrBeginUpdate:far
global GrEndUpdate:far
global WinAckUpdate:far
global WinInvalReg:far

global WinLocatePoint:far

global WinGetInfo:far
global WinSetInfo:far

global WinApplyRotation:far
global WinApplyScale:far
global WinTransform:far
global WinUntransform:far
global WinTransformDWord:far
global WinUntransformDWord:far
global WinSetTransform:far
global WinApplyTransform:far
global WinSetNullTransform:far
global WinGetTransform:far

global WinGrabChange:far
global WinReleaseChange:far
global WinChangeAck:far
global WinEnsureChangeNotification:far

global WinMove:far
global WinResize:far

global WinDecRefCount:far

global WinApplyTranslation:far
global WinApplyTranslationDWord:far

global WinSuspendUpdate:far
global WinUnSuspendUpdate:far

global WinSetPtrImage:far
global WinRealizePalette:far

;------------------------------------------------------------------------------
;	Ptr image
;------------------------------------------------------------------------------

PtrImageValue	etype word
;
; Enumerated type passed as an alternative to an optr to a PointerDef in
; ImSetPtrImage:

PIV_NONE	enum PtrImageValue, 0
; No ptr image requested for level.
; IMPORTANT:  Keep the value of this enumerated constant to 0, so that a null
; optr results in no ptr image being requested.

PIV_VIDEO_DRIVER_DEFAULT	enum PtrImageValue
; Use video driver default ptr image

PIV_UPDATE	enum PtrImageValue
; Re-write current highest priority ptr image to the video driver.  Useful
; when changing PointerDef at previous optr, changing screens.



PtrImageLevel etype word, 0
;
; Enumerated type for ptr image level.  Each level may specify a particular
; mouse ptr image, or specify that the level does not currently have an image.
; The first (starting at lowest enumerated value) level which has a ptr image
; declared will be used at any given moment in time.
;
PIL_SYSTEM	enum PtrImageLevel	; reserved for future use

PIL_1		enum PtrImageLevel	; reserved for future use

PIL_FLOW	enum PtrImageLevel
; Used for UI quick transfer move/copy cursors

PIL_3		enum PtrImageLevel	; reserved for future use

PIL_GEODE	enum PtrImageLevel
; Overriding status of geode.  Used to indicate BUSY state, MODAL
; state for applications.  Applications & the UI should NOT set this directly
; using ImSetPtrImage, but instead use WinSetGeodePtrImage.  The window system
; then calls ImSetPtrImage whenever the active/implied geode changes, to set the
; PtrImage associated with that geode.

PIL_5		enum PtrImageLevel	; reserved for future use

PIL_GADGET	enum PtrImageLevel
; Gadget level.  Used for visible gadgets within windows, such as text object,
; control points, etc.  Applications & the UI should NOT set this directly 
; using ImSetPtrImage, but instead use WinSetPtrImage.  The window system
; then calls ImSetPtrImage whenever the active window changes, to set the
; PtrImage associated with that window.

PIL_7		enum PtrImageLevel	; reserved for future use

PIL_WINDOW	enum PtrImageLevel
; Window level.  Background cursor to use.  Applications & the UI should
; NOT set this directly using ImSetPtrImage, but instead use WinSetPtrImage.
; The window system then calls ImSetPtrImage whenever the active window
; changes, to set the PtrImage associated with that window.

PIL_DEFAULT	enum PtrImageLevel
; Default ptr  (system? field? app?)


IM_IM_NUM_PTR_IMAGE_LEVELS	=	10	; # of image levels that the IM supports


global WinGeodeSetPtrImage:far
global WinGeodeGetInputObj:far
global WinGeodeSetInputObj:far
global WinGeodeGetParentObj:far
global WinGeodeSetParentObj:far
global WinGeodeSetActiveWin:far
global WinSysSetActiveGeode:far
global WinGeodeGetFlags:far
global WinGeodeSetFlags:far

;-

global WINOPEN:far
global WINCLOSE:far
global WINMOVE:far
global WINRESIZE:far
global WINDECREFCOUNT:far
global WINCHANGEPRIORITY:far
global WINSCROLL:far
global WINSUSPENDUPDATE:far
global WINUNSUSPENDUPDATE:far
global WINGETINFO:far
global WINSETINFO:far
global WINAPPLYROTATION:far
global WINAPPLYSCALE:far
global WINAPPLYTRANSLATION:far
global WINAPPLYTRANSLATIONDWORD:far
global WINTRANSFORM:far
global WINTRANSFORMDWORD:far
global WINUNTRANSFORM:far
global WINUNTRANSFORMDWORD:far
global WINSETTRANSFORM:far
global WINAPPLYTRANSFORM:far
global WINSETNULLTRANSFORM:far
global WINGETTRANSFORM:far
global WINGETWINSCREENBOUNDS:far
global GRBEGINUPDATE:far
global GRENDUPDATE:far
global WINACKUPDATE:far
global WININVALREG:far

global WINSETPTRIMAGE:far
global WINGEODESETPTRIMAGE:far
global WINGEODEGETINPUTOBJ:far
global WINGEODESETINPUTOBJ:far
global WINGEODEGETPARENTOBJ:far
global WINGEODESETPARENTOBJ:far
global WINGEODESETACTIVEWIN:far
global WINREALIZEPALETTE:far

;---------------------------------------------------------------------------
;		Display Types
;---------------------------------------------------------------------------

;	This type is used in DisplayType (to indicate what type of display
; is being used) and in VisMonikerListEntryType (to indicate what type of
; display a GString is especially well suited for). This info is copied into
; some specific UI objects, so the DRAW method for the object will know how to
; draw it.
;WARNING: update the UIC compiler if you change this list.

DisplaySize	etype byte		;MAX 4 VALUES!
DS_TINY		enum DisplaySize	;tiny screens: CGA, 256x320
DS_STANDARD	enum DisplaySize	;standard screens: EGA, VGA, HGC, MCGA
DS_LARGE	enum DisplaySize	;large screens: 800x600 SVGA
DS_HUGE		enum DisplaySize	;huge screens

DisplayAspectRatio	etype byte	;MAX 4 VALUES!
DAR_NORMAL	enum DisplayAspectRatio	;VGA, MCGA
DAR_SQUISHED	enum DisplayAspectRatio	;EGA, HGC (DAR_NORMAL normally used)
DAR_VERY_SQUISHED enum DisplayAspectRatio	;CGA
DAR_TV		enum DisplayAspectRatio	;TV

DisplayClass 	etype byte		;MAX 16 VALUES!
DC_TEXT		enum DisplayClass	;for display -- denotes that display is
					;character only (not implemented)
DC_GRAY_1 	enum DisplayClass	;1 bit/pixel gray scale
DC_GRAY_2	enum DisplayClass	;2 bit/pixel gray scale
DC_GRAY_4	enum DisplayClass	;4 bit/pixel gray scale
DC_GRAY_8	enum DisplayClass	;8 bit/pixel gray scale
DC_COLOR_2	enum DisplayClass	;2 bit/pixel color index
DC_COLOR_4	enum DisplayClass	;4 bit/pixel color index
DC_COLOR_8	enum DisplayClass	;8 bit/pixel color index
DC_CF_RGB	enum DisplayClass	;color with RGB values


;The flags defined here work as hints to the user of the video driver
;WARNING: update the UIC compiler if you change this record.

DisplayType	record
	DT_DISP_SIZE DisplaySize:2	; size of display
					; aspect ratio of display
	DT_DISP_ASPECT_RATIO DisplayAspectRatio:2
	DT_DISP_CLASS DisplayClass:4	; class of driver (or closest match)
DisplayType	end


CASIO_DISPLAY_TYPE equ ((DS_TINY shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_GRAY_1 shl offset DT_DISP_CLASS))
CGA_DISPLAY_TYPE equ ((DS_TINY shl offset DT_DISP_SIZE) or (DAR_VERY_SQUISHED shl offset DT_DISP_ASPECT_RATIO) or (DC_GRAY_1 shl offset DT_DISP_CLASS))
EGA_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_SQUISHED shl offset DT_DISP_ASPECT_RATIO) or (DC_COLOR_4 shl offset DT_DISP_CLASS))
MEGA_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_SQUISHED shl offset DT_DISP_ASPECT_RATIO) or (DC_GRAY_1 shl offset DT_DISP_CLASS))
VGA_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_COLOR_4 shl offset DT_DISP_CLASS))
VGA8_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_COLOR_8 shl offset DT_DISP_CLASS))
VGA24_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_CF_RGB shl offset DT_DISP_CLASS))
SVGA_DISPLAY_TYPE equ ((DS_LARGE shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_COLOR_4 shl offset DT_DISP_CLASS))
SVGA8_DISPLAY_TYPE equ ((DS_LARGE shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_COLOR_8 shl offset DT_DISP_CLASS))
SVGA24_DISPLAY_TYPE equ ((DS_LARGE shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_CF_RGB shl offset DT_DISP_CLASS))
MCGA_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_GRAY_1 shl offset DT_DISP_CLASS))
HGC_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_SQUISHED shl offset DT_DISP_ASPECT_RATIO) or (DC_GRAY_1 shl offset DT_DISP_CLASS))
MINI_DISPLAY_TYPE equ ((DS_TINY shl offset DT_DISP_SIZE) or (DAR_NORMAL shl offset DT_DISP_ASPECT_RATIO) or (DC_GRAY_1 shl offset DT_DISP_CLASS))
TV8_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_TV shl offset DT_DISP_ASPECT_RATIO) or (DC_COLOR_8 shl offset DT_DISP_CLASS))
TV24_DISPLAY_TYPE equ ((DS_STANDARD shl offset DT_DISP_SIZE) or (DAR_TV shl offset DT_DISP_ASPECT_RATIO) or (DC_CF_RGB shl offset DT_DISP_CLASS))


DisplayModeOrientation		etype	byte, 0, 1
	DMO_NO_CHANGE		enum	DisplayModeOrientation
	DMO_DEFAULT		enum	DisplayModeOrientation
	DMO_PORTRAIT		enum	DisplayModeOrientation
	DMO_TOGGLE		enum	DisplayModeOrientation

DisplayModeColor		etype	byte, 0, 1
	DMC_NO_CHANGE		enum	DisplayModeColor
	DMC_DEFAULT		enum	DisplayModeColor
	DMC_INVERTED		enum	DisplayModeColor
	DMC_TOGGLE		enum	DisplayModeColor

DisplayModeDefinition		etype	byte, 0, 1
	DMD_NO_CHANGE		enum	DisplayModeDefinition
	DMD_DEFAULT		enum	DisplayModeDefinition
	DMD_HIGH		enum	DisplayModeDefinition
	DMD_TOGGLE		enum	DisplayModeDefinition

DisplayModeResolution		etype	byte, 0, 1
	DMR_NO_CHANGE		enum	DisplayModeResolution
	DMR_DEFAULT		enum	DisplayModeResolution
	DMR_HIGH		enum	DisplayModeResolution
	DMR_TOGGLE		enum	DisplayModeResolution


DisplayMode	record
	:8
	DM_color	:2
	DM_orientation	:2
	DM_definition	:2
	DM_resolution	:2
DisplayMode	end

;-----------------------------------------------------------------------------
;			Flags for window routines
;-----------------------------------------------------------------------------

;
; Layer priority equates.  Windows layers are ordered by layer priority.  All
; windows belonging to a given layer ID are kept together. (0 is
; converted to LAYER_PRIO_STD in WinOpen)
;
LayerPriority 		etype byte
LAYER_PRIO_MODAL 	enum LayerPriority, 6	; For system-modal dialog boxes,
						; when layer is on screen
LAYER_PRIO_ON_TOP 	enum LayerPriority, 8	; For "screen-floating" boxes
LAYER_PRIO_STD		enum LayerPriority, 12	; Standard layer priority
LAYER_PRIO_ON_BOTTOM	enum LayerPriority, 14	; Window stays on bottom

;
; Window priority equates.  Windows are ordered within their layer by window
; priority.  (0 is converted to WIN_PRIO_STD in WinOpen)
;
WinPriority 		etype byte
WIN_PRIO_POPUP 		enum WinPriority, 4	; For standard menus, while in
						; stay-up mode or drag mode,
						; temporary popup menus
WIN_PRIO_MODAL		enum WinPriority, 6	; For modal dialog boxes,
WIN_PRIO_ON_TOP 	enum WinPriority, 8	; For misc which is supposed
						; to appear "on top" of rest of
						; application
WIN_PRIO_COMMAND	enum WinPriority, 10	; For Comand windows, non-modal
						; dialogs, torn-off menus
WIN_PRIO_STD		enum WinPriority, 12	; Standard window priority
WIN_PRIO_ON_BOTTOM	enum WinPriority, 14	; Window stays on bottom


; WinPassFlags.  The following flags are passed to a number of window system
; routines.  Since each routine uses a different subset of these flags, check
; the routine header for the routine you're calling before passing the
; flag to it.  As a quick reference, the routines using each flag are listed
; in parenthesis after the flag below.
;
WinPriorityData	record
	WPD_LAYER LayerPriority:4
	WPD_WIN WinPriority:4; Priority value for window. Windows
WinPriorityData	end


WinPassFlags	record
	WPF_CREATE_GSTATE:1	;set if a gstate should be created along with
				; window (WinOpen)
	WPF_ROOT:1		;set if creating a root window (WinOpen)
	WPF_SAVE_UNDER:1	;set if window should be created w/save under
				; (WinOpen)
	WPF_INIT_EXCLUDED:1	;init as being the head of a branch which is
				; excluded from being an implied window, &
				; therefore won't receive MSG_META_UNIV_ENTER,
				; MSG_META_VIS_ENTER's. (WinOpen)
	WPF_PLACE_BEHIND:1	;indicates window should be placed behind other
				; windows in its priority group.  If clear,
				; then window will be placed in front.
				; (WinOpen, WinChangePriority)
	WPF_PLACE_LAYER_BEHIND:1;indicates whether layer should be placed behind
				; other layers within its priority group. If
				; clear, then layer will be placed in front.
				; (WinOpen, WinChangePriority)
	WPF_LAYER:1		;set if operation applies to all windows having
				; layerID (WinChangePriority)
	WPF_ABS:1		;whether size/offset passed is absolute
				; or relative to current
				; (WinScroll, WinMove, WinResize)
	WPF_PRIORITY WinPriorityData:8
WinPassFlags	end

				; The following allows the above structure
				; to look slightly different for WinOpen --
				; this bit allows the creation of a suspended
				; window (WPF_ABS bit not used for WinOpen,
				; & hence is being reused for this purpose)
WPF_INIT_SUSPENDED	equ	<WPF_ABS>



WinColorFlags	record
	WCF_RGB:1		;set if using RGB colors, clear for indexed.
	WCF_TRANSPARENT:1	;indicates window does not have a background
				; color, & that owner must draw entire contents
				; of window.
	WCF_PLAIN:1		;indicates window is one color only &
				; therefore the window system may perform all
				; draw operations for it.  (No MSG_META_EXPOSED's
				; are sent)

	WCF_MASKED:1		;indicates window is "masked". (INTERNAL)
	WCF_DRAW_MASK:1		;indicates drawing window "mask". (INTERNAL)

	WCF_MAP_MODE:3		; graphics color mapping mode
WinColorFlags	end

; WinInvalFlag
; This flag is passed to the window transformation routines and signals 
; whether an invalidation should take place or not.  For the normal usage of 
; those routines, one should invalidate the window.  It is useful to avoid
; the invalidation, however, if a few of them are being called sequentially
WinInvalFlag	etype	byte, 0, 1
WIF_INVALIDATE		enum	WinInvalFlag		; -invalidate the win
WIF_DONT_INVALIDATE	enum	WinInvalFlag		; -don't

; WinError
; This enum is returned by a few of the Window Translation routines to indicate
; what type of error occured.  See individual routines
WinError	etype	word, 0, 1
WE_COORD_OVERFLOW	enum	WinError		; 16-bit coord overflow
WE_WINDOW_CLOSING	enum	WinError		; window is closing
WE_GSTRING_PASSED	enum	WinError		; gstring handle passed 

;-----------------------------------------------------------------------------
;			Types for WinGetInfo and WinSetInfo
;-----------------------------------------------------------------------------

WinInfoType 		etype word, 0, 2
WIT_PRIVATE_DATA 	enum WinInfoType
WIT_COLOR 		enum WinInfoType
WIT_INPUT_OBJ 		enum WinInfoType
WIT_EXPOSURE_OBJ 	enum WinInfoType
WIT_STRATEGY 		enum WinInfoType
WIT_FLAGS 		enum WinInfoType
WIT_LAYER_ID 		enum WinInfoType
WIT_PARENT_WIN 		enum WinInfoType
WIT_FIRST_CHILD_WIN 	enum WinInfoType
WIT_LAST_CHILD_WIN 	enum WinInfoType
WIT_PREV_SIBLING_WIN 	enum WinInfoType
WIT_NEXT_SIBLING_WIN 	enum WinInfoType
WIT_PRIORITY	 	enum WinInfoType

;
; W_regFlags
;
WinRegFlags	record
	WRF_DELAYED_WASH:1	;set if window has WRF_DELAYED_V set, & the
				; routine DoWashOut is called to fill the
				; window's invalid region with the background
				; color.  Will cause the fill to be done when
				; the window block is V'd
	WRF_DELAYED_V:1		;set if window should not be V'd until
				; validation operation is complete.  Used to
				; insure that no two V'd windows ever have
				; overlapping W_maskReg's at any one instant.
	WRF_SIBLING_VALID:1	;set if parent window's W_childReg contains
				; running sum of regions of windows to the
				; left of this one in the tree (W_siblingReg).
	WRF_EXPOSE_PENDING:1	;means that a MSG_META_EXPOSED has been sent out,
				; and neither GrBeginUpdate nor WinUpdateAck
				; has been called yet.
	WRF_CLOSED:1		;set if this window has been closed, but not
				; yet freed.
	WRF_INVAL_TREE:1	;set if this window is being invalidated from
				; WinInvalTree and may need DoWashOut even if
				; the entire window is already invalidated.
	:2
WinRegFlags	end


if      (WIN_ENTER_LEAVE_CONTROL)
WinPtrFlags	record
	WPF_WIN_GRABBED:1	;set if window has grabbed mouse input
	WPF_WIN_BRANCH_EXCLUDED:1;set if window is excluded from mouse input
	WPF_PTR_IN_UNIV:1	;set if ptr is in universe of window (RAW).
				; this is NOT synchronous with the UI thread
	WPF_PTR_IN_VIS:1	;set if ptr is in visible region of window (RAW)
				; this is NOT synchronous with the UI thread
	WPF_UNIV_ENTERED:1	;set if in the middle of a MSG_META_UNIV_ENTER/
				; MSG_META_UNIV_LEAVE pair (NOT synchronous)
	WPF_VIS_ENTERED:1	;set if in the middle of a MSG_META_VIS_ENTER/
				; MSG_META_VIS_LEAVE pair (NOT synchronous)
	:2
WinPtrFlags	end
else
WinPtrFlags	record
	WPF_PTR_IN_UNIV:1	;set if ptr is in universe of window (RAW).
				; this is NOT synchronous with the UI thread
	WPF_PTR_IN_VIS:1	;set if ptr is in visible region of window (RAW)
				; this is NOT synchronous with the UI thread
	:6
WinPtrFlags	end
endif

EndKernel
