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

	Copyright (c) GeoWorks 1991 -- All Rights Reserved

PROJECT:	PC GEOS
MODULE:		Include/Objects/Text/tCommon.def
FILE:		visC.def

REVISION HISTORY:
	Name	Date		Description
	----	----		-----------
	Tony	9/91		Initial version

DESCRIPTION:
	Common definitions for text objects

	$Id: tCommon.def,v 1.1 97/04/04 14:17:32 newdeal Exp $

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

SetDef __TCOMMON

StartLibrary text

UseLib stylesh.def
include sllang.def
include text.def

;------------------------------------------------------------------------------
;	Text Ranges
;------------------------------------------------------------------------------

; The VisTextRange structure is passed to many routines to indicate the range
; of text to act on.

; This constant can be placed in either VTR_start or VTR_end

TEXT_ADDRESS_PAST_END		=	0x00ffffff
TEXT_ADDRESS_PAST_END_HIGH	=	0x00ff
TEXT_ADDRESS_PAST_END_LOW	=	0xffff

VisTextRange	struct
    VTR_start	dword		;Start of range
    VTR_end	dword		;End of range
VisTextRange	ends

; Special value for VTR_start.high

VIS_TEXT_RANGE_SELECTION				= 0xffff
; Dexcription:
;	Indicates that the current selected area will be used.  Note that
;	for some operations (like paraAttr changes), the affected text will
;	actually be larger than the selection.

VIS_TEXT_RANGE_PARAGRAPH_SELECTION			= 0xfffe
; Dexcription:
;	Indicates that the current selected area will be used after being
;	adjusted to a paragraph boundry.

; Flags that can be passed along with a VisTextRange to routines for which
; the context is the range is not known.

;-----------------------------------------------------------------------------
;		CharAttrs
;-----------------------------------------------------------------------------

;	Structure of a charAttr

VisTextExtendedStyles	record
    VTES_BOXED:1
    VTES_BUTTON:1
    VTES_INDEX:1	;Text should be indexed
    VTES_ALL_CAP:1
    VTES_SMALL_CAP:1
    VTES_HIDDEN:1
    VTES_CHANGE_BAR:1
    VTES_BACKGROUND_COLOR:1
    VTES_NOWRAP:1       ; Text is not allowed to word wrap or break characters
    :7
VisTextExtendedStyles	end

;	Definition of a text charAttr element.

VisTextCharAttr	struct
    VTCA_meta		StyleSheetElementHeader	; Basic element management.
    VTCA_fontID		FontID			; The font id
    VTCA_pointSize	WBFixed			; Point size.
    VTCA_textStyles	TextStyle		; Text styles
    VTCA_color		ColorQuad		; Color.
    VTCA_trackKerning	sword			; Track kerning
    VTCA_fontWeight	byte			; The font weight
    VTCA_fontWidth	byte			; The font width
    VTCA_extendedStyles	VisTextExtendedStyles	; Extended styles
    VTCA_grayScreen	SystemDrawMask		; Foreground gray screen
    VTCA_pattern	GraphicPattern		; Foreground pattern
    VTCA_bgColor	ColorQuad		; Background color.
    VTCA_bgGrayScreen	SystemDrawMask		; Background gray screen
    VTCA_bgPattern	GraphicPattern		; Background pattern
    VTCA_reserved	byte 7 dup (0)
VisTextCharAttr	ends

.assert ((size VisTextCharAttr) and 1) eq 0

;	Default sizes.

VisTextDefaultSize etype byte
VTDS_8	enum VisTextDefaultSize
VTDS_9	enum VisTextDefaultSize
VTDS_10	enum VisTextDefaultSize
VTDS_12	enum VisTextDefaultSize
if not PZ_PCGEOS
VTDS_14	enum VisTextDefaultSize
else
VTDS_16	enum VisTextDefaultSize
endif
VTDS_18	enum VisTextDefaultSize
VTDS_24	enum VisTextDefaultSize
VTDS_36	enum VisTextDefaultSize


; Default charAttr record (incorporates the default sizes and color map modes).


;	There are are maximum of 32 default fonts (since the bitfield is
;	five bits wide).  Do not add fonts without consulting font people!

VisTextDefaultFont	etype	byte
VTDF_BERKELEY		enum	VisTextDefaultFont	;Bitmap font
VTDF_CHICAGO		enum	VisTextDefaultFont	;Bitmap font
VTDF_BISON		enum	VisTextDefaultFont	;Bitmap font
VTDF_WINDOWS		enum	VisTextDefaultFont	;Bitmap font
VTDF_LED		enum	VisTextDefaultFont	;Bitmap font
VTDF_ROMA		enum	VisTextDefaultFont	;Bitmap font
VTDF_UNIVERSITY		enum	VisTextDefaultFont	;Bitmap font

VTDF_URW_ROMAN		enum	VisTextDefaultFont	;Nimbus-Q font
VTDF_URW_SANS		enum	VisTextDefaultFont	;Nimbus-Q font
VTDF_URW_MONO		enum	VisTextDefaultFont	;Nimbus-Q font
VTDF_URW_SYMBOLPS	enum	VisTextDefaultFont	;Nimbus-Q font
VTDF_CENTURY_SCHOOLBOOK	enum	VisTextDefaultFont	;Nimbus-Q font

VTDF_PIZZA_KANJI	enum	VisTextDefaultFont	;Bitmap font

VTDF_BITSTREAM_KANJI_HON_MINCHO	enum VisTextDefaultFont		;Bitstream font
VTDF_BITSTREAM_KANJI_SQUARE_GOTHIC	enum VisTextDefaultFont	;Bitstream font

VTDF_JSYS		enum	VisTextDefaultFont	;Bitmap font

VisTextDefaultCharAttr	record
    VTDCA_UNDERLINE:1
    VTDCA_BOLD:1
    VTDCA_ITALIC:1
    :1
    VTDCA_COLOR		Color:4
    VTDCA_SIZE		VisTextDefaultSize:3
    VTDCA_FONT		VisTextDefaultFont:5
VisTextDefaultCharAttr	end

; The initial charAttr of a text object.

VIS_TEXT_INITIAL_CHAR_ATTR	equ   (VTDS_12 shl offset VTDCA_SIZE) or (VTDF_BERKELEY)

VIS_TEXT_DEFAULT_POINT_SIZE	=	12

;-----------------------------------------------------------------------------
;		ParaAttrs
;-----------------------------------------------------------------------------

;	Limits for various paraAttr components

if PZ_PCGEOS
VIS_TEXT_MAX_PARA_WIDTH		= 3926		;138.5 cm
else
VIS_TEXT_MAX_PARA_WIDTH		= 4000
endif

VIS_TEXT_MIN_NON_ZERO_LINE_SPACING = 0 shl 8 + 128	;BBFixed constant

VIS_TEXT_MIN_NON_ZERO_LINE_SPACING_INT = 0		;WWFixed constants
VIS_TEXT_MIN_NON_ZERO_LINE_SPACING_FRAC = 32768

VIS_TEXT_MAX_LINE_SPACING	= 12 shl 8 + 0		;BBFixed constant

VIS_TEXT_MAX_LINE_SPACING_INT	= 12			;WWFixed constants
VIS_TEXT_MAX_LINE_SPACING_FRAC	= 0
		
VIS_TEXT_MIN_TEXT_FIELD_WIDTH	= 47		; Don't make this smaller!
VIS_TEXT_MIN_NON_ZERO_LEADING	= 1
VIS_TEXT_MAX_LEADING		= MAX_POINT_SIZE
VIS_TEXT_MAX_TABS		= 25

;	Right margin used by right justified single line objects

VIS_TEXT_ONE_LINE_RIGHT_MARGIN = VIS_TEXT_MAX_PARA_WIDTH

;	Structure of a paraAttr

; The size of a paraAttr can be computed by:

;	size = (size VisTextParaAttr) + (VTPA_numberOfTabs * (size Tab))


; Different types of borders on a paragraph.

ShadowAnchor	etype byte
SA_TOP_LEFT	enum ShadowAnchor
SA_TOP_RIGHT	enum ShadowAnchor
SA_BOTTOM_LEFT	enum ShadowAnchor
SA_BOTTOM_RIGHT	enum ShadowAnchor

VisTextParaBorderFlags	record
    VTPBF_LEFT:1			;Set if a border on the left
    VTPBF_TOP:1			;Set if a border on the top
    VTPBF_RIGHT:1		;Set if a border on the right
    VTPBF_BOTTOM:1		;Set if a border on the bottom
    VTPBF_DOUBLE:1		;Draw two line border
    VTPBF_DRAW_INNER_LINES:1	;Draw lines between bordered paragraphs
    VTPBF_SHADOW:1		;Set to use shadow
    :7
    VTPBF_ANCHOR	ShadowAnchor:2
VisTextParaBorderFlags	end

VisTextNumberType	etype	word
VTNT_NUMBER			enum	VisTextNumberType
VTNT_LETTER_UPPER_A		enum	VisTextNumberType
VTNT_LETTER_LOWER_A		enum	VisTextNumberType
VTNT_ROMAN_NUMERAL_UPPER	enum	VisTextNumberType
VTNT_ROMAN_NUMERAL_LOWER	enum	VisTextNumberType

VisTextParaAttrAttributes	record
    VTPAA_JUSTIFICATION	Justification:2
    VTPAA_KEEP_PARA_WITH_NEXT:1
    VTPAA_KEEP_PARA_TOGETHER:1			;Don't break up paragraph
    VTPAA_ALLOW_AUTO_HYPHENATION:1		;Use VisTextHyphenationInfo
    VTPAA_DISABLE_WORD_WRAP:1
    VTPAA_COLUMN_BREAK_BEFORE:1
    VTPAA_PARA_NUMBER_TYPE VisTextNumberType:3
    VTPAA_DROP_CAP:1				;Use VisTextDropCapInfo
    VTPAA_KEEP_LINES:1				;Use VisTextKeepInfo
    :4
VisTextParaAttrAttributes	end

VisTextHyphenationInfo	record
    VTHI_HYPHEN_MAX_LINES:4 = 3-1
    VTHI_HYPHEN_SHORTEST_WORD:4 = 5-1
    VTHI_HYPHEN_SHORTEST_PREFIX:4 = 3-1
    VTHI_HYPHEN_SHORTEST_SUFFIX:4 = 3-1
VisTextHyphenationInfo	end

VisTextKeepInfo	record
    VTKI_TOP_LINES:4	; # lines at start of PP to keep togather
    VTKI_BOTTOM_LINES:4	; # lines at end of PP to keep togather
VisTextKeepInfo	end

VisTextDropCapInfo	record
    VTDCI_CHAR_COUNT:4 = 1-1	; # characters for drop cap charAttr
    VTDCI_LINE_COUNT:4 = 3-1	; # lines for drop cap
    VTDCI_POSITION:4 = 1-1	; 0 is full drop cap
				; lineCount-1 is full tall cap
    :4
VisTextDropCapInfo	end

VIS_TEXT_MIN_STARTING_NUMBER		=	-1000
VIS_TEXT_MAX_STARTING_NUMBER		=	60000
VIS_TEXT_DEFAULT_STARTING_NUMBER	=	62000

;--------

;	Default paraAttrs

PIXELS_PER_INCH		=	72

;
; Intrinsic width for a tab character if there are no tabstops which apply
; to it.
;
TAB_INTRINSIC_WIDTH	= 18		; 1/4 inch.

VisTextDefaultDefaultTab etype byte
VTDDT_NONE		enum VisTextDefaultDefaultTab
VTDDT_HALF_INCH		enum VisTextDefaultDefaultTab
VTDDT_INCH		enum VisTextDefaultDefaultTab
VTDDT_CENTIMETER	enum VisTextDefaultDefaultTab

VisTextDefaultParaAttr	record
    VTDPA_JUSTIFICATION		Justification:2
    VTDPA_DEFAULT_TABS		VisTextDefaultDefaultTab:2
    VTDPA_LEFT_MARGIN:4			;In units of half inches
    VTDPA_PARA_MARGIN:4			;In units of half inches
    VTDPA_RIGHT_MARGIN:4		;In units of half inches -- 0 means
					;VIS_TEXT_MAX_PARA_ATTR_SIZE
VisTextDefaultParaAttr	end


;	The initial paraAttr for a text object

VIS_TEXT_INITIAL_PARA_ATTR =	( (0*2) shl offset VTDPA_LEFT_MARGIN ) or \
				( (0*2) shl offset VTDPA_PARA_MARGIN ) or \
				( (0*2) shl offset VTDPA_RIGHT_MARGIN ) or \
				( VTDDT_HALF_INCH shl offset VTDPA_DEFAULT_TABS ) or \
				( J_LEFT shl offset VTDPA_JUSTIFICATION )


;--------


; There is code that assumes that a paraAttr is an even number of bytes long.
; As you add and delete bytes from the paraAttr use the 'VTPA_reserved' field
; to word align stuff.

VisTextParaAttr	struct
    VTPA_meta		StyleSheetElementHeader
    VTPA_borderFlags	VisTextParaBorderFlags	; Border type.
    VTPA_borderColor	ColorQuad		; Color for borders
    VTPA_attributes	VisTextParaAttrAttributes	; Other attributes.

    VTPA_leftMargin	word			; Margins -- Unsigned
    VTPA_rightMargin	word			; The right margin is an offset
						; from the RIGHT edge of the
						; object
    VTPA_paraMargin	word

						;** See note on line height
						;** calculation below
    VTPA_lineSpacing	BBFixed	<>		; Line spacing -- unsigned
						; 1.0 is normal line spacing
    VTPA_leading	word			; unsigned, 13.3

	; extra space above/below paragraph, in points (13.3)

    VTPA_spaceOnTop	word			; Unsigned -- 0.0 is normal
    VTPA_spaceOnBottom	word			; spacing

    VTPA_bgColor	ColorQuad
    VTPA_numberOfTabs	byte			; # of tabs in paraAttr.

    VTPA_borderWidth	byte			; Border width (pixels * 8)
    VTPA_borderSpacing	byte			; Border spacing (pixels * 8)
    VTPA_borderShadow	byte			; Border shadow (pixels * 8)
    VTPA_borderGrayScreen SystemDrawMask	; Gray screen for border
    VTPA_bgGrayScreen	SystemDrawMask		; Gray screen for bg color
    VTPA_borderPattern	GraphicPattern		; Border pattern
    VTPA_bgPattern	GraphicPattern		; Background pattern
    VTPA_defaultTabs	word			; Spacing for default tabs: 13.3
    VTPA_startingParaNumber word		; Paragraph number
    VTPA_prependChars	char 4 dup (0)		; Characters to prepend at the
						; start of each paragraph
    VTPA_hyphenationInfo VisTextHyphenationInfo
    VTPA_keepInfo	VisTextKeepInfo
    VTPA_dropCapInfo	VisTextDropCapInfo
    VTPA_nextStyle	word
    VTPA_language	StandardLanguage

if DBCS_PCGEOS
    VTPA_miscMode	TextMiscModeFlags
    VTPA_reserved	byte 14 dup (0)
else
    VTPA_reserved	byte 15 dup (0)
endif

    VTPA_tabList	label	byte
VisTextParaAttr	ends

.assert ((size VisTextParaAttr) and 1) eq 0

VisTextMaxParaAttr	struct
    VTMPA_paraAttr	VisTextParaAttr
    VTMPA_tabs		Tab VIS_TEXT_MAX_TABS dup (<>)
VisTextMaxParaAttr	ends



;-----------------------------------------------------------------------------
;		/* Macros for element arrays */
;-----------------------------------------------------------------------------

ELEMENT_ARRAY_HEADER macro type, struct, count
	TextElementArrayHeader < 
	<<count, size struct, 0, size TextElementArrayHeader>,
	EA_FREE_LIST_TERMINATOR>, type, 0 >
endm

CHAR_ATTR_ELEMENT_ARRAY_HEADER macro count
    ELEMENT_ARRAY_HEADER TAT_CHAR_ATTRS, VisTextCharAttr, <count>
endm

PARA_ATTR_ELEMENT_ARRAY_HEADER macro count
	TextElementArrayHeader <
	<<count, 0, 0, size TextElementArrayHeader>,
	EA_FREE_LIST_TERMINATOR>, TAT_PARA_ATTRS, 0>
endm

CHAR_ATTR_FONT_SIZE_STYLE_COLOR macro ref, font, psize, tstyle, color
    VisTextCharAttr <<<<ref, 0>>, CA_NULL_ELEMENT>, font, <0, psize>, tstyle,
	<color, CF_INDEX, 0>, 0, FWI_MEDIUM, FW_NORMAL, <>, SDM_100, <>,
	<C_WHITE, CF_INDEX, 0>, SDM_0, <>, <>>
endm

CHAR_ATTR_SS_FONT_SIZE_STYLE_COLOR macro ss, ref, font, psize, tstyle, color
    VisTextCharAttr <<<<ref, 0>>, ss>, font, <0, psize>, tstyle,
	<color, CF_INDEX, 0>, 0, FWI_MEDIUM, FW_NORMAL, <>, SDM_100, <>,
	<C_WHITE, CF_INDEX, 0>, SDM_0, <>, <>>
endm

CHAR_ATTR_FONT_SIZE macro font, psize
    CHAR_ATTR_FONT_SIZE_STYLE_COLOR 3, <font>, <psize>, <>, C_BLACK
endm

CHAR_ATTR_FONT_SIZE_STYLE macro font, psize, tstyle
    CHAR_ATTR_FONT_SIZE_STYLE_COLOR 3, <font>, <psize>, <tstyle>, C_BLACK
endm


PARA_ATTR_SS_JUST_LEFT_RIGHT_PARA_TABS macro ss, ref, just, left, right, para, deftabs, tabs
    VisTextParaAttr <<<<ref, 0>>, ss>,
	<0, 0, 0, 0, 0, 0, SA_TOP_LEFT>, <C_BLACK, CF_INDEX, 0>,
	<just, 0, 0, 0, 0, 0, 0, 0, 0>, left, right, para,
	<0, 1>, 0, 0, 0, <C_WHITE, CF_INDEX, 0>,
	tabs, 1*8, 2*8, 1*8, SDM_100, SDM_0, <>, <>, deftabs,
	VIS_TEXT_DEFAULT_STARTING_NUMBER, <0,0,0,0>, <>, <>, <>,
	CA_NULL_ELEMENT, SL_ENGLISH, <>>
endm

PARA_ATTR_JUST_LEFT_RIGHT_PARA_TABS macro ref, just, left, right, para, tabs
	PARA_ATTR_SS_JUST_LEFT_RIGHT_PARA_TABS CA_NULL_ELEMENT, <ref>, \
		<just>, \
		<(left)*PIXELS_PER_INCH>, <(right)*PIXELS_PER_INCH>, \
		<(para)*PIXELS_PER_INCH>, <PIXELS_PER_INCH/2*8>, <tabs>
endm

TAB_POS_TYPE_LEADER_ANCHOR_GRAY_WIDTH_SPACING macro pos, type, leader, anchor, gray, width, spacing
    Tab <(pos)*PIXELS_PER_INCH, <leader, type>, gray, width, spacing, anchor>
endm

TAB_POS_TYPE macro pos, type
    TAB_POS_TYPE_LEADER_ANCHOR_GRAY_WIDTH_SPACING <pos>, <type>, TL_NONE, \
							'.', SDM_100, 0, 0
endm

GRAPHIC_ELEMENT_ARRAY_HEADER macro count
    ELEMENT_ARRAY_HEADER TAT_GRAPHICS, VisTextGraphic, <count>
endm

TYPE_ELEMENT_ARRAY_HEADER macro count
    ELEMENT_ARRAY_HEADER TAT_TYPES, VisTextType, <count>
endm

TYPE_ELEMENT_NONE macro
    VisTextType <<<1,0>>, -1, -1, -1>
endm

NAME_ARRAY_HEADER macro count
    NameArrayHeader <<< count , 0, 0, size NameArrayHeader>,
			EA_FREE_LIST_TERMINATOR>,
			(size VisTextNameData)>
endm

;-----------------------------------------------------------------------------
;		Attributes
;-----------------------------------------------------------------------------

; VisTextStorageFlags reflect the type of data structures used to store
; the text object's data

VisTextStorageFlags	record
    VTSF_LARGE:1		;If set: this object uses the large storage
				;        format and the bits below are unused
				;If clear: this object uses the model storage
				;        format are the bits below are used
    VTSF_MULTIPLE_CHAR_ATTRS:1	;If set:
				;  VTI_charAttrRuns = check handle of charAttr runs
				;If not set:
				;  if (VTTF_defaultCharAttr)
				;    VTI_charAttrRuns is a VisTextDefaultCharAttrs
				;  else
				;    VTI_charAttrRuns = chunk handle of charAttr
    VTSF_MULTIPLE_PARA_ATTRS:1	;If set:
				;  VTI_paraAttrRuns = check handle of paraAttr runs
				;If not set:
				;  if (VTI_paraAttrRuns != 0)
				;    VTI_paraAttrRuns = chunk handle of paraAttr
				;  else
				;    use default paraAttr
    VTSF_TYPES:1
    VTSF_GRAPHICS:1
    VTSF_DEFAULT_CHAR_ATTR:1
    VTSF_DEFAULT_PARA_ATTR:1
    VTSF_STYLES:1
VisTextStorageFlags	end

;
; We need an additional flag for passing to MSG_VIS_TEXT_CHANGE_ELEMENT_ARRAY.
; Since VTSF_DEFAULT_CHAR_ATTR can't be passed to this routine, we use it
; to represent VTSF_NAMES.
;
VTSF_NAMES	equ	mask VTSF_DEFAULT_CHAR_ATTR

EndLibrary	text
