COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

	Copyright (c) Geoworks 1994 -- All Rights Reserved

PROJECT:	Condo viewer
MODULE:		viewer
FILE:		conview.def

AUTHOR:		Jonathan Magasin, Apr  8, 1994

MACROS:
	Name			Description
	----			-----------

REVISION HISTORY:
	Name	Date		Description
	----	----		-----------
	JM	4/ 8/94   	Initial revision


DESCRIPTION:
	Definitions for content library.
		
	$Id: conview.def,v 1.1 97/04/04 14:22:06 newdeal Exp $

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@

SetDef	__CONVIEW

StartLibrary	conview

UseLib	Objects/vTextC.def
UseLib	Objects/vLTextC.def
UseLib	Objects/vCntC.def
UseLib	Objects/helpCC.def		; for MAX_CONTEXT_NAME_LENGTH
UseLib	compress.def
include Objects/inputC.def
include timer.def
include ui.def
include	helpFile.def


;---------------------------------------------------------------------------
; Content Files and Help Files generated by the Condo Studio app
; use these structures, which are based on help files, see helpFile.def
;---------------------------------------------------------------------------

CONTENT_FILE_PROTO_MAJOR	equ	HELP_FILE_PROTO_MAJOR
CONTENT_FILE_PROTO_MINOR	equ	HELP_FILE_PROTO_MINOR

BOOK_FILE_PROTO_MAJOR	equ	2
BOOK_FILE_PROTO_MINOR	equ	0

;
; Record of Book tools/features to be enabled in Bookshelf
;
BookFeatureFlags	record
    BFF_BOOK_TITLE:1		; display Book title in context control
    BFF_FIND:1			; add FindControl
    BFF_SEND:1			; add print/copy capabilities
    BFF_UNUSED:9
; Below are bits corresponding to NavControl features, they must be
; in this order.  If they change here, they must change in CNCFeatures
    BFF_MAIN_PAGE:1		; add main page trigger/tool
    BFF_HISTORY:1		; add history list
    BFF_PREV_NEXT:1		; add prev/next page trigger/tool
    BFF_BACK:1			; add go back trigger/tool
BookFeatureFlags end


; default set of book features

DEFAULT_VIEWER_FEATURES	= mask BFF_PREV_NEXT or \
			  mask BFF_HISTORY or \
			  mask BFF_BACK or \
			  mask BFF_MAIN_PAGE or \
			  mask BFF_BOOK_TITLE or \
			  mask BFF_FIND or \
			  mask BFF_SEND

; default set of book tools

DEFAULT_VIEWER_TOOLS = 	DEFAULT_VIEWER_FEATURES and \
			not (mask BFF_BOOK_TITLE) 
				
.assert (offset BFF_MAIN_PAGE eq offset CNCF_MAIN_PAGE)
.assert (offset BFF_BACK eq offset CNCF_BACK)
.assert (offset BFF_PREV_NEXT eq offset CNCF_PREV_NEXT)
.assert (offset BFF_HISTORY eq offset CNCF_HISTORY)

;-----------------------------------------------------------------------------
;	Header structures for Book and Content Files
;-----------------------------------------------------------------------------

BookFileHeader	struct
    BFH_protocolMajor	word			;
    BFH_protocolMinor	word			;
    BFH_featureFlags	BookFeatureFlags	;features enabled for this book
    BFH_toolFlags	BookFeatureFlags	;tool features enabled 
    BFH_count		word			;# of content files in book
    BFH_nameList	word			;block handle of list
						; containing BFH_count entries
						; of FileLongName with names
						; of the book's content files
    BFH_firstFile	word			;index into follwing list
						; of first file to load
    BFH_firstPage	ContextName 		;name of first page to load
    BFH_path		PathName		;path under USERDATA where
						; content files are stored
BookFileHeader	ends

;
; This is based on the HelpFileMapBlock structure in helpFile.def
;
ContentFileMapBlock	struct
    CFMB_protocolMajor	word	
    CFMB_protocolMinor	word	
    CFMB_flags		HelpFileFlags
    CFMB_compressType	HelpCompressType
    CFMB_dictionary	word		;VM handle of dictionary, if any
    CFMB_names		word		;VM handle of names array
    CFMB_charAttrs	word		;VM handle of char attributes
    CFMB_paraAttrs	word		;VM handle of paragraph attributes
    CFMB_types		word		;VM handle of type attributes
    CFMB_graphics	word		;VM handle of graphics
    CFMB_reserved	byte 20 dup (?)	;reserved for future use
ContentFileMapBlock	ends

; 
; PageNameArrayElement is an extension of the HelpFileNameArrayElement
; which is used in the content files to hold navigational information
; about a page.  It *must* be the same size as HelpFileNameArrayElement.
;

PageNameArrayElement		struct
    PNAE_meta		VisTextNameArrayElement
    PNAE_nextPage	word		;token of next page
    PNAE_prevPage	word		;token of previous page
    PNAE_upPage		word		;token of page at the previous
					;   hierarchical level
    PNAE_pageNumber	word		;real page number, counting from 1
					;   (used for Goto page #)
PageNameArrayElement		ends

.assert (size PageNameArrayElement eq size HelpFileNameArrayElement)

;
;  Description of data sent with GWNT_CONTENT_CONTEXT_CHANGE.
;  (sent to GAGCNLT_NOTIFY_CONTENT_CONTEXT_CHANGE)
;
NotifyNavContextChangeFlags   record
    :10
    NNCCF_prevEnabled:1                 ;Does page have a prev page?
    NNCCF_nextEnabled:1                 ;Does page have a next page?
    NNCCF_updateHistory:1             	;Clear: don't update history
					; because NavControl already knows
					; about the change
    NNCCF_retnWithState:1		;Set: NavControl doesn't need to 
					; update history list, because
 					; the history list is restored from 
					; state
    NNCCF_displayTOC:1			;Set: TOC for this file is displayed
    NNCCF_displayMain:1                 ;Set: main page for this book
					; is displayed.
NotifyNavContextChangeFlags   end
 
;
; Notification structure sent when the currently displayed context changes.
;
NotifyNavContextChange        struct
     NNCC_flags                	NotifyNavContextChangeFlags
     NNCC_filename     		FileLongName    ;file name to link to
     NNCC_context      		ContextName     ;context name to link to
     NNCC_page      		word	  	;page number
     NNCC_counter      		word            ;used to insure uniqueness
     NNCC_bookFeatures		BookFeatureFlags;used to specify which
						; controller features should
						; be disabled all the time 
						; because the book does not
						; have them set.
NotifyNavContextChange        ends

;
;  Description of data sent with GWNT_CONTENT_BOOK_CHANGE 
;  (sent to GAGCNLT_NOTIFY_CONTENT_BOOK_CHANGE)
;
NotifyContentBookChangeFlags   record
    :14
    NCBCF_retnWithState:1		;Set: NavControl doesn't need to
					; free history list
    NCBCF_alreadyFreedHistoryList:1	;Set: NavControl already freed the 
					; history list for this notification
NotifyContentBookChangeFlags   end

;
; Notification structure sent when the currently open book changes.
;
NotifyContentBookChange	struct
    NCBC_flags		NotifyContentBookChangeFlags
    NCBC_bookname	FileLongName		;name of new book
    NCBC_features	BookFeatureFlags	;features set for new book
    NCBC_tools		BookFeatureFlags	;tools set for new book
NotifyContentBookChange ends


;-----------------------------------------------------------------------------
;		Class Definitions
;-----------------------------------------------------------------------------


;-----------------------------------------------------------------------------
;		ContentGenViewClass
;-----------------------------------------------------------------------------

ContentGenViewClass	class	GenViewClass

;
; Keep dimensions small enough for width and height to
; fit into one word (each).
;
CONTENT_GEN_VIEW_INITIAL_HEIGHT		equ	400
CONTENT_GEN_VIEW_INITIAL_WIDTH		equ	400


ContentTextRequestFlags	record
	:10					;word align for swat
       CTRF_searchMatch:1			;Text is being displayed to 
						; show a search match
       CTRF_searchText:1			;All operations should be done
						; on text object whose optr is
						; stored in CSD_searchObject
       CTRF_resetPath:1				;If set, we are loading a new
						; book, or a book-less content
						; file, and should reset the
						; ContentGenView's path.
       CTRF_noBookFile:1			;If set, we are loading
						; a content file with no
						; associated book file.
       CTRF_restoreFromState:1                 	;If set, we are restoring
						; from state
       CTRF_needContext:1                      	;If set, Nav needs to be told
                                                ; the context we are going to
ContentTextRequestFlags       end
;
; Structure passed to some of the ContentGenView messages used
; for displaying a particular page of text.
;
ContentTextRequest            struct
      CTR_diskhandle  	word
      CTR_pathname    	PathName
      CTR_bookname    	FileLongName
      CTR_filename    	FileLongName
      CTR_context     	ContextName
      CTR_flags       	ContentTextRequestFlags
      CTR_featureFlags	BookFeatureFlags
      CTR_toolFlags	BookFeatureFlags
ContentTextRequest    ends
 


;-----------------------------------------------------------------------------
;		Messages
;-----------------------------------------------------------------------------
MSG_CGV_CREATE_TREE				message
;
; Internal only:  Called by MSG_META_ATTACH to 
; create and attach the content's tree, which
; consists of a VisContent subclass and a VisText
; subclass.

MSG_CGV_CREATE_FILE_SELECTOR			message
;
; Internal only:  When the view attaches, it creates a file
; selector so that books can be loaded.
;
;	Pass: nothing
;	Retn: nothing
;	Destr: nothing

MSG_CGV_LOAD_BOOK				message
;
; Opens the book selected in the Open Book file selector.
;
;	Pass:  nothing
;	Return:	ax 	- LoadFileError
;			  LFE_NO_ERROR if file successfully loaded
;			  LFE_ERROR_OPENING_BOOK if error opening book file
;			  LFE_ERROR_SETTING_PATH if error setting content path
;			  LFE_ERROR_DISPLAYING_FILE if error opening and 
;				displaying content file
;			  LFE_ERROR_FILE_ALREADY_OPEN if requested book is open
;	Destr: cx,dx,bp

MSG_CGV_LOAD_BOOK_LOW				message
;
; Loads the book specified in the passed ContentTextRequest
;
;	Pass:  ss:bp - ContentTextRequest
;		CTR_bookname	- name of book file
;		CTR_pathname	- book's path
;		CTR_diskhandle	- book's disk
;	Retn:  ax    - LoadFileError
;	Destr: cx,dx,bp

MSG_CGV_DELETE_BOOK	message
;
; Deletes the file selected in the Open Book file selector
;
;	Pass:	nothing
; 	Retn:	nothing
;	Destr:	ax, cx, dx, bp

MSG_CGV_LOAD_CONTENT_FILE	message
;
; Loads the content file specified in the passed ContentTextRequest.
;
; Context:	This message is meant to be used by developers
;		who want their app to load a specific content file.
;
; Destination:  Any ContentGenView object.
; Interception: Should not be necessary.
;
; 	Pass:	ss:bp - ContentTextRequest
;			- CTR_diskhandle set to content file disk, 
;				or StandardPath constant
;			- CTR_pathname set to content file path
;			- CTR_bookname set to book file (null if no book
;				associated with this content file)
;			- CTR_filename set to content file to open
;			- CTR_context set to page to load
;			- CTR_featureFlags set to the features to enable.
;			- CTR_toolFlags set to the tools to enable.
;			- CTR_flags 
;			    CTRF_noBookFile
;				= 1 if there is not a book file associated
;				  with this content file, which will disable
;				  ability to have the bookname as the primary
;				  moniker.
;				= 0 if there is a book file associated with
;				  this content file.
;
;	Return:	carry set if error loading file
;		ax 	- LoadFileError
;			  LFE_NO_ERROR if file successfully loaded
;			  LFE_ERROR_SETTING_PATH if error setting path
;			  LFE_ERROR_DISPLAYING_FILE if error opening and 
;				displaying file
;	Destroyed:	cx, dx, bp

LoadFileError		etype	word
LFE_NO_ERROR			enum	LoadFileError
LFE_ERROR_SETTING_PATH		enum	LoadFileError
LFE_ERROR_DISPLAYING_FILE	enum	LoadFileError
LFE_ERROR_NO_BOOK_SELECTED	enum	LoadFileError
LFE_BOOK_NOT_FOUND		enum	LoadFileError
LFE_ERROR_INVALID_BOOK		enum 	LoadFileError
LFE_BOOK_PROTOCOL_ERROR		enum 	LoadFileError
LFE_ERROR_BOOK_HAS_NO_FILES	enum	LoadFileError
LFE_ERROR_LOADING_SEARCH_FILE	enum	LoadFileError
LFE_ERROR_LOADING_CONTEXT	enum	LoadFileError
LFE_ERROR_SETTING_BOOK_PATH	enum	LoadFileError

MSG_CGV_FOLLOW_LINK				message
;
; Follow a hyperlink.  Called by MSG_META_END_SELECT handler.
;
;	Pass: 		cx - token of link name
;			dx - token of link file (-1 for same file)
;	Return: 	nothing
;	Destroyed:	ax,bp 

MSG_CGV_FOLLOW_LINK_LOW				message
;
; Follow the link specified in the ContentTextRequest.
;
; Context:	This message is send out by the MSG_CGV_FOLLOW_LINK
;		handler.
; Destination:  Any ContentGenView object.
;
; Interception: This message is meant to be intercepted to determine the 
;		the link destination. You might also want to intercept this
;		message to modify the context or filename before the link
;		is followed. Call the superclass to actually follow the link.
;
; Pass:		ss:bp	- ContentTextRequest
;			  CTR_filename - file we're going to
;			  CTR_context  - page we're going to in that file
; Return:	nothing
; Destroyed:	ax, cx, dx

MSG_CGV_GET_LINK_NAME	message
;
; Return the name of the link.  This message is provided for
; applications that want to subclass ContentGenViewClass.  This message
; should ONLY be sent to the ContentGenViewClass object by itself when it
; receives a MSG_CGV_FOLLOW_LINK (before calling the
; superclass), as that's the only time that the tokens will be valid.
;
; Pass:		ss:bp	= CGVGetLinkNameParams
;			  linkToken - token of link name
;			  fileToken - token of file name (-1 for same)
;			
; Return:	ss:bp	= filled in CGVGetLinkNameParams
;			  linkName and fileName filled in
; Destroyed:	ax, cx, dx

CGVGetLinkNameParams	struct
	CGVGLNP_linkToken	word	
	CGVGLNP_fileToken	word
	CGVGLNP_linkName	ContextName
	CGVGLNP_fileName	FileLongName
CGVGetLinkNameParams	ends

MSG_CGV_GET_POINTER_IMAGE			message
;
; Get the appropriate pointer image for the mouse pointer depending
; on whether the current position is over a hyperlink.
;
; Pass:		cx - context token
; Return:	ax - MouseReturnFlags with MRF_SET_POINTER_IMAGE
;		^lcx:dx - OD of pointer image (if MRF_SET_POINTER_IMAGE)
;

MSG_CGV_DISPLAY_TEXT				message
;
; Handle request to display a specified context.
;
;	Pass: ss:bp - ContentTextRequest params
;		CTR_filename - name of file
;		CTR_context - name of context
;		CTR_flags - controls how tools/features are updated
;	Retn: carry set if error
;	Destroyed:	ax,cx,dx,bp 

MSG_CGV_GOTO_PAGE_FOR_NAV			message
;
; Goto the previous, next, or a specified page.
; 
;	Pass: cx - ContentNavControlGotoPageType
;	      dx - specific page to go to if cx = CNCGPT_SPECIFIC_PAGE
;	Destroyed:	ax,cx,dx,bp 

MSG_CGV_DISPLAY_TOC				message
;
; Display the Book's main page (the page named "TOC" in the file
; whose name is stored in CONTENT_MAIN_FILE vardata).
;
;	Pass: 		nothing
;	Return: 	nothing
;	Destroyed:	ax,cx,dx,bp 

MSG_CGV_UNUSED_1				message

MSG_CGV_CLIPBOARD_SEND				message
;
; Copy the selected text to the clipboard.  If no text
; is selected, then copy the whole page to the clipboard.
;
;	Pass: nothing
;	Retn: nothing
;	Destr: ax, dx, bp


MSG_CGV_UNUSED_2				message

MSG_CGV_GET_DOC_SIZE				message
;
; Gets the width and height of the view.
;	Note: Assumes width/height will fit into
;	      words, not dwords.
;
;	Pass:  nothing
;	Retn:  cx = width of view
;	       dx = height of view
;	Destr: nothing

MSG_CGV_INIT_FILE_SELECTOR			message
;
; Bring up the view's file selector so that a new file
; may be opened.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: ax,cx,dx,bp

MSG_CGV_GET_TEXT_OD				message
;
;  Returns the ContentText object's optr.
;
;	Pass:  nothing
;	Retn:  carry set if no text object
;		^lcx:dx - the ContentText object
;	Destr: nothing

MSG_CGV_CHANGE_PRIMARY_MONIKER			message
;
; Changes the primary's moniker to be the passed string.
; Or to the default moniker if BFF_BOOK_TITLE is not set.
;
; Context:	This message is sent when a new book is loaded or
;		when MSG_CGV_LOAD_CONTENT_FILE is used with 
;		CTRF_noBookFile = 1. Developers may want to subclass
;		this message to avoid the primary moniker being changed
;		to the default "Book Reader". 
;
; Destination:  Any ContentGenView object.
; Interception: This message can be intercepted to change the default
;		behavior.
;
;	Pass:  	cx:dx 	= fptr to source null-terminated text string
;		bp	= book features (BookFeatureFlags)
;	Retn:  	nothing
;	Destr:  ax, cx, dx, bp

MSG_CGV_EVAL_FILE_SELECTOR_PRESS		message
;
; Internal:  File selector uses this as its action msg.  The
; CGView determines if the user is opening a file, and calls
; CGV_LOAD_FILE if so.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: ax,cx,dx,bp

MSG_CGV_SET_SIMPLE_BOUNDS			message
;
; Internal: Calls GenViewSetSimpleBounds on the CGView to set
; the scrolling bounds of the view to be width=cx, height=dx.
;
;	Pass:  cx=width
;	       dx=height
;	Retn:  nothing
;	Destr: nothing


MSG_CGV_STRING_NOT_FOUND			message
;
; Internal:  ContentText calls this view with this message
; when it doesn't find the target string in itself.  This
; message then continues/terminates the search depending on
; whether there's still content to be (loaded and) searched.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: nothing

MSG_CGV_UPDATE_SCROLLBARS			message
;
; Internal:  Enables/disables the scrollbars as is appropriate 
; for the displayed text and view size.
;
;	Pass: ss:bp - UpdateScrollbarParams
;	Retn: nothing
;	Destr: everything

UpdateScrollbarParams	struct
    USP_viewWidth	word
    USP_viewHeight	word
    USP_textWidth	word
    USP_textHeight	word
UpdateScrollbarParams	ends

MSG_CGV_GET_UPDATE_SCROLLBARS_STATE		message
;
; Internal: Determines whether scrollbars should be updated or not, 
; based on state of TEMP_CONTENT_IGNORE_UPDATE_SCROLLBARS_COUNT vardata.
;
;	Pass:	nothing
;	Return:	cx = 0 if vardata present 
;		cx = non-zero if vardata not present 
;

MSG_CGV_IGNORE_UPDATE_SCROLLBARS		message
;
; Internal: Increments the TEMP_CONTENT_IGNORE_UPDATE_SCROLLBARS_COUNT
; vardata, adding the vardata if necessary.
;
;	Pass:	nothing
;	Return:	nothing
;
;

protominor	ProtoNewForJedi
MSG_CGV_GET_BOOK_FEATURE_FLAGS		message
;
; Returns the BookFeatureFlags for the current book.
;
;	Pass:	nothing
;	Return:	ax - feature BookFeatureFlags
;		dx - tool BookFeatureFlags 
;
;
protoreset

;-----------------------------------------------------------------------------
;		Internal vardata
;-----------------------------------------------------------------------------

CONTENT_BOOKNAME				vardata char
;
; Holds the name of the opened book.  

CONTENT_BOOK_DISK_HANDLE			vardata word
;
; Holds the disk handle of the opened book.  

CONTENT_BOOK_PATHNAME				vardata char
;
; Holds the relative pathname of the opened book.  

CONTENT_MAIN_FILE				vardata char
;
; When a "book" is opened, this field is set so that we will
; know which file to open first, and which file to go to if the
; user hits the "Begin" button.
;

CONTENT_COVER_PAGE				vardata char
;
; When a "book" is opened, this field is set so that we know which page
; to load first (from the file CONTENT_MAIN_FILE).  (This is distinct from
; the book's main page, which is the page named TOC in CONTENT_MAIN_FILE.)

CONTENT_FILENAME				vardata char
;
; Internal only: If this exists, it contains the name of the file
; the Content Viewer should load.

CONTENT_LINK					vardata	char
;
; Internal only: If this exists, it contains the name of the page
; that should be loaded from the file specified by CONTENT_FILENAME.


ContentSearchFlags	record
    CSF_searchOptions 	SearchOptions:8		;CODE DEPENDS ON SearchOptions
						; BEING IN HIGH BYTE OF FLAG
	:4				
    CSF_getNextPage:1				;Search ended right on a page
						; boundary, so get next page
						; before proceeding.
    CSF_matchFound:1				;Set if a match was found at
    						; some point during the current
						; active search
    CSF_inStartFile:1				;Search has wrapped all the 
						;  way back to the start file
    CSF_searchWrapped:1				;Set if search has wrapped
						;  to first or last file
ContentSearchFlags	end

ContentSearchData	struct
	CSD_flags		ContentSearchFlags
	CSD_currentOffset	word
	CSD_searchObject	optr		; OD of text object for search
	CSD_curFile		hptr		; currently open file handle
        CSD_nameArrayVM		word		; VM handle of name array
	CSD_fileNumber		word		; book's content file number
	CSD_pageNumber		word		; name array elt # of page
	CSD_compressLib		hptr		; compression library geode
	CSD_startFile		FileLongName	; filename search started in
	CSD_startContext	word		; context # search started at
	CSD_searchStruct	hptr		; SearchReplaceStruct
ContentSearchData	ends

CONTENT_SEARCH_DATA				vardata	ContentSearchData
;
; Internal only: Holds data to keep track of where we are in the current
; 		 search. 

TEMP_DELETING_CURRENT_BOOK			vardata
;
; Current book is being deleted, so once all files are deleted,
; a Null notification should be sent to controllers so they can reset
; their UI.
;


;JM: Need come back and take care of this.
ATTR_CONTENT_CUSTOM_POINTER_IMAGE		vardata optr
;
; Optr to custom pointer for when the mouse is over a link.
;
; eg:
;	hints = {
;		ATTR_CONTENT_CUSTOM_POINTER_IMAGE {
;			optr customPointer
;		}
;	}
;
; NOTE: the pointer image should be in a sharable, non-duplicated block.
; NOTE: if it is not, use UN_OPTR and and add vardataReloc to the object.
;

TEMP_CONTENT_IGNORE_UPDATE_SCROLLBARS_COUNT	vardata	byte

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

    CGVI_bookFeatures	BookFeatureFlags
    CGVI_bookTools	BookFeatureFlags
    CGVI_curFile	hptr
    CGVI_nameArrayVM	word			;VM handle of name array
    CGVI_compressLib	hptr			;Handle of compress lib.
    CGVI_page		word			;Current page.
    CGVI_fileFlags	HelpFileFlags		;...for current file
    CGVI_fileSelector	hptr			;Handle of block
						;containing file
						;selector branch.

ContentGenViewClass	endc	

;-----------------------------------------------------------------------------
;		ContentDocClass
;-----------------------------------------------------------------------------

ContentDocClass		class	VisContentClass
ContentDocClass		endc

;-----------------------------------------------------------------------------
;		ContentTextClass
;-----------------------------------------------------------------------------

ContentTextClass	class	VisTextClass

MSG_CT_LOAD_FROM_DB_ITEM_FORMAT_AND_FREE_BLOCK	message
;
; Load text from block of uncompressed data, then free the block.
; Avoids deadlock problem.
;
;	Pass: 	 	bp - handle of block containing data
;			cx - segment of locked block
;	Return:		nothing
;	Destroyed:	ax, cx, dx, bp
;

MSG_CT_LOAD_FROM_DB_ITEM_FORMAT_AND_UPDATE_SCROLLBARS	message
;
; Loads a new page into the text object and tells
; the view to update its scrollbars.
;
;	Pass:  cx:dx = ptr to data to load
;	Retn:  nothing
;	Destr: nothing

MSG_CT_LOAD_FROM_DB_ITEM_AND_UPDATE_SCROLLBARS		message
;
; Loads a new page into the text object and tells
; the view to update its scrollbars.
;
;	Pass:  cx.dx = db item to load
;	       bp    = VM file handle to use (0 to use
;		       VTI_vmFile
;	Retn:  nothing
;	Destr: nothing

MSG_CT_FREE_STORAGE_AND_FILE				message
;
; Calls self with MSG_VIS_TEXT_FREE_STORAGE and THEN closes VM file.
; Will send a notification message to the ContentGenView when done.
;
;	Pass:  bp - VM file handle
;	       cx - notification message to send to ContentGenView
;		    when storage and file have been freed (0 for none)
;	Return: nothing
;	Destroyed: ax, cx, dx, bp
;

MSG_CT_TELL_VIEW_UPDATE_SCROLLBARS			message
;
; Tells the view to update its scrollbars, passing
; the view its (the text's) minimum width and its
; height (corresponding to the view's current width.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: nothing

MSG_CT_PRINT_START_PRINTING				message
;
; Draws the whole or selected text to the passed gstate 
; for the print controller.
;
; Context:	This message is sent to the ContentText by the 
;		ContentGenView when it receives	a 
;		MSG_PRINT_START_PRINTING message from the print 
;		controller.
;
; Destination:  Any ContentText object.
; Interception: Should not need to be intercepted.
;
;	Pass:  	cx:dx	= OD of the PrintControlClass object
;		bp	= GState handle to print (draw) to
;	Retn:  	nothing
;	Destr:  ax, cx, dx, bp

MSG_CT_PRINT_CONTENT_TEXT				message
;
; Draws the ContentText to the passed gstate for the 
; print controller.
;
; Context:	This message is sent to the ContentText by the 
;		MSG_CT_PRINT_START_PRINTING handler.
;
; Destination:  Any ContentText object.
; Interception: Should not need to be intercepted.
;
;	Pass:  	cx:dx	= OD of the PrintControlClass object
;		bp	= GState handle to print (draw) to
;	Retn:  	nothing
;	Destr:  ax, cx, dx, bp

MSG_CT_INVERT_HOTSPOTS				message
;
; Inverts the area of all hotspots into the passed gstate
;
; Context:	This message will be sent from the MSG_VIS_DRAW handler,
;		as well as after adding or deleting the
;		TEMP_CONTENT_TEXT_INVERT_HOTSPOTS property.
;
; Destination:  Any ContentText object.
; Interception: Should not need to be intercepted.
;
;	Pass:  	bp	= GState handle to print (draw) to
;	Retn:  	nothing
;	Destr:  ax

MSG_CT_TOGGLE_INVERT_AND_INVERT				message
;
; Toggles whether the object has TEMP_CONTENT_TEXT_INVERT_HOTSPOTS, then
; inverts all hotspots to bring us up to date.
;
;	Pass:  	nothing
;	Retn:  	nothing
;	Destr:  ax

MSG_CT_UNSELECT_TEXT					message
;
; If there is a range of text selected, clear the selection by
; setting the select start and end at the old select start.
;
;	Pass:  	nothing
;	Retn:  	nothing
;	Destr:  ax, cx, dx, bp

;-----------------------------------------------------------------------------
;		Vardata
;-----------------------------------------------------------------------------
ContentTextLinkSelection	struct
    CTLS_contextToken		word
    CTLS_fileToken		word
    CTLS_selectStart		dword
    CTLS_graphicTopLeft		Point
ContentTextLinkSelection	ends

TEMP_CONTENT_TEXT_LINK_SELECTION	vardata ContentTextLinkSelection

TEMP_CONTENT_TEXT_NO_DELETE		vardata
;
; If this vardata is present ContentTextClass will ignore calls to
; MSG_VIS_TEXT_DELETE_ALL_TEXT.  This is necessary to avoid a bug in
; the VM code where it erroneously tries to compress a read-only file
; in the process of freeing all the graphic VMChains.  If the graphic runs
; are deleted first (by the call to MSG_VIS_TEXT_FREE_STORAGE, which calls
; MSG_VIS_TEXT_DELETE_TEXT), this bug can be avoided.
;

TEMP_CONTENT_TEXT_INVERT_HOTSPOTS	vardata
;
; If this vardata is present, ContentTextClass will invert all its
; hotspots whenever drawn.
;

TEMP_CONTENT_TEXT_NO_DRAW		vardata
;
; If this vardata is present, ContentTextClass will not draw itself.
; Used when in the process of deleting the currently opened book.
; Needed because in some cases when the text redraws after 
; MSG_CT_FREE_STORAGE_AND_FILE has been called, it will hang while
; trying to draw a line.  I don't know why in some cases it happens and
; not in others.
;

ContentTextClass	endc



;----------------------------------------------------------------------
;		ContentNavControlClass
;----------------------------------------------------------------------
	
ContentNavControlClass	class	GenControlClass

;-----------------------------------------------------------------------------
;		CONSTANTS and STRUCTURES
;-----------------------------------------------------------------------------

;
; Type used by NavControl to tell the ContentGenView to go to the
; previous, next, or a specific page (as opposed to following links,
; which requires ContentNavTextRequest).
;
ContentNavControlGotoPageType		etype	word, 0
CNCGPT_PREVIOUS_PAGE	enum	ContentNavControlGotoPageType
CNCGPT_NEXT_PAGE	enum	ContentNavControlGotoPageType
CNCGPT_SPECIFIC_PAGE	enum	ContentNavControlGotoPageType


;-----------------------------------------------------------------------------
;		MESSAGES
;-----------------------------------------------------------------------------

MSG_CNC_GOTO_HISTORY				message
;
; Display the text of the currently selected history entry
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: nothing

MSG_CNC_GO_BACK					message
;
; Go back to the previous entry in the history list.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: nothing

MSG_CNC_NEXT_PAGE				message
;
; Tell ContentGenView to display the next page.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: cx

MSG_CNC_PREVIOUS_PAGE				message
;
; Tell ContentGenView to display the previous page.
;
;	Pass:  nothing
;	Retn:  nothing
;	Destr: cx

MSG_CNC_GOTO_TOC				message
;
; Tell ContentGenView to display the main page (TOC) of the Book.
;
;	Pass: nothing
;	Retn: nothing
;	Destr: ax (method)

MSG_CNC_GET_HISTORY_LIST_MONIKER		message
;
; Used by history list to get its entries.
;

MSG_CNC_GET_STATE_BLOCK				message
;
; Gets the handle of the block holding this history list so that
; it can be saved to state when the application shuts down to DOS.
;
;	Pass: nothing
;	Retn: cx = block handle
;	Destr: nothing

MSG_CNC_FREE_HISTORY_LIST					message
;
; Get rid of the history list and reinitialize the go back index.
;	
;	Pass: nothing
;	Retn: nothing
;	Destr: nothing

MSG_CNC_INITIATE_HISTORY_LIST					message
;
; INTERNAL.  Initiate the history list interaction in response to
; user activating the history feature or tool.
;	
;	Pass: nothing
;	Retn: nothing
;	Destr: nothing

protominor 	ProtoNewForJedi

MSG_CNC_ENABLE_DISABLE_FEATURES_AND_TOOLS			message
;
; This message has no default handler.  It was added so that
; ContentNavControl subclasses can know when tools and features are
; being enabled or disabled, because a feature's availability has
; changed by moving to a new page or opening a new book.
;
;	Pass: 	cl - CNCFeaturesAndTools to be enabled 
;		ch - CNCFeaturesAndTools to be disabled 
;	Return:	nothing
;

CNCFeaturesAndTools	record
    CNCFAT_MAIN_PAGE:1		;Main page feature
    CNCFAT_HISTORY:1		;History list feature
    CNCFAT_PREV:1		;prev feature
    CNCFAT_NEXT:1		;next feature
    CNCFAT_BACK:1		;back feature
	:3
CNCFeaturesAndTools	end

protoreset

;-----------------------------------------------------------------------------
;		Constants & Structures
;-----------------------------------------------------------------------------
; features flags (used with ATTR_GEN_CONTROL_REQUIRE_UI and
; ATTR_GEN_CONTROL_PROHIBIT_UI)
;
; NOTE:  Feature and tool records must be identical.

;
; The BookFeatureFlags record expects these flags to be in this order.
; If you change them here, you must change BookFeatureFlags as well.
;

CNCFeatures	record
    :12
    CNCF_MAIN_PAGE:1		;Go to book's main page.
    CNCF_HISTORY:1		;History list interaction.
    CNCF_PREV_NEXT:1		;prev/next page triggers
    CNCF_BACK:1			;Go back one history list entry
CNCFeatures	end

CNCToolboxFeatures	record
    :12
    CNCTF_MAIN_PAGE:1		;Go to book's main page tool.
    CNCTF_HISTORY:1		;History list tool
    CNCTF_PREV_NEXT:1		;prev/next page tools
    CNCTF_BACK:1		;Go back tool
CNCToolboxFeatures	end

CNC_DEFAULT_FEATURES equ	mask CNCF_PREV_NEXT \
				or mask CNCF_MAIN_PAGE \
				or mask CNCF_BACK \
				or mask CNCF_HISTORY
				 

CNC_DEFAULT_TOOLBOX_FEATURES equ mask CNCTF_PREV_NEXT \
				or mask CNCTF_MAIN_PAGE \
				or mask CNCTF_BACK \
				or mask CNCTF_HISTORY


;-----------------------------------------------------------------------------
;		Internal Vardata
;-----------------------------------------------------------------------------

TEMP_CONVIEW_DETACH_RECEIVED			vardata
;
; Internal only: If this exists, the controller has received MSG_META_DETACH
; and will ignore any updates received after this.


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

    CNCI_historyBlock	hptr			;Handle of history interaction
    CNCI_historyList	hptr			;Handle of history list
    CNCI_gobackIndex	word			;Index into history list

ContentNavControlClass	endc


;----------------------------------------------------------------------
;		ContentFindControlClass
;----------------------------------------------------------------------

; NOTE:	When the ContentFindControl object is declared in the application
;	.ui file, it's output needs to be set to the ContentGenView object.
	
ContentFindControlClass	class	GenControlClass

;-----------------------------------------------------------------------------
;		MESSAGES
;-----------------------------------------------------------------------------

MSG_CFC_INITIATE_SEARCH_CONTROL				message
;
; Bring up the SearchReplaceControl object, creating one if necessary.
;
;	Pass: 		nothing
;	Return: 	nothing
;	Destroyed:	ax,cx,dx,bp 

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

; Features flags (used with ATTR_GEN_CONTROL_REQUIRE_UI and
; ATTR_GEN_CONTROL_PROHIBIT_UI)

CFCFeatures	record
    :15
    CFCF_FIND:1
CFCFeatures	end

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

CFCToolboxFeatures	record
    :15
    CFCTF_FIND:1
CFCToolboxFeatures	end

CFC_DEFAULT_FEATURES equ mask CFCF_FIND

CFC_DEFAULT_TOOLBOX_FEATURES equ mask CFCTF_FIND

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

        CFCI_searchController   optr            ; optr of the search controller

ContentFindControlClass	endc


;----------------------------------------------------------------------
;		ContentSendControlClass
;----------------------------------------------------------------------

; NOTE:	When the ContentSendControl object is declared in the application
;	.ui file, it's output needs to be set to the ContentGenView object.

ContentSendControlClass	class	GenControlClass

;-----------------------------------------------------------------------------
;		MESSAGES
;-----------------------------------------------------------------------------

MSG_CSC_INIT_SEND_DIALOG				message
;
;  Update the text description in the send dialog depending on text 
;  selection state, then initiate it.
;
;	Pass: 		nothing
;	Return: 	nothing
;	Destroyed:	ax,cx,dx,bp 

MSG_CSC_SEND_TEXT					message
;
;  Send a the selected text/page to either the clipboard or
;  the printer (via print controller).
;
;	Pass: 		nothing
;	Return: 	nothing
;	Destroyed:	ax,cx,dx,bp 

MSG_CSC_PRINT_TEXT					message
;
;  Print the current text selection or page.
;
;	Pass: 		nothing
;	Return: 	nothing
;	Destroyed:	ax,cx,dx,bp 

MSG_CSC_COPY_TEXT					message
;
;  Copy current text selection or page to clipboard.
;
;	Pass: 		nothing
;	Return: 	nothing
;	Destroyed:	ax,cx,dx,bp 

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

ContentSendOptionItemType		etype	word
CSOIT_CLIPBOARD		enum	ContentSendOptionItemType
CSOIT_PRINTER		enum	ContentSendOptionItemType

ContentSendDialogDescripionType		etype	word
CSDDT_PAGE	enum	ContentSendDialogDescripionType
CSDDT_SELECTION	enum	ContentSendDialogDescripionType

; Features flags (used with ATTR_GEN_CONTROL_REQUIRE_UI and
; ATTR_GEN_CONTROL_PROHIBIT_UI)

CSCFeatures	record
    :15
    CSCF_SEND:1
CSCFeatures	end

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

CSCToolboxFeatures	record
    :15
    CSCTF_SEND:1
CSCToolboxFeatures	end

CSC_DEFAULT_FEATURES equ mask CSCF_SEND

CSC_DEFAULT_TOOLBOX_FEATURES equ mask CSCTF_SEND

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

	CSCI_sendDialog		optr		; optr of the send dialog
						;  or null if it does not exist
	CSCI_printController	optr		; optr of the print controller
						;  or null if it does not
						;  exist
	CSCI_dialogDescription	ContentSendDialogDescripionType
						; Set to CSDDT_SELECTION if
						;  there is currently a text
						;  selection. Set to CSDDT_PAGE
						;  if no selection.
ContentSendControlClass	endc


;----------------------------------------------------------------------
;		ContextControlClass
;----------------------------------------------------------------------

ContextControlClass	class	GenControlClass

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

; features flags (used with ATTR_GEN_CONTROL_REQUIRE_TOOLBOX_UI and
; ATTR_GEN_CONTROL_PROHIBIT_TOOLBOX_UI)

CCToolboxFeatures	record
    :15
    CCTF_TITLE_BAR:1		;Is there a title bar?
CCToolboxFeatures	end

CCFeatures	record
    :15
    CCF_TITLE_BAR:1		;Is there a title bar?
CCFeatures	end

CC_DEFAULT_TOOLBOX_FEATURES equ mask CCTF_TITLE_BAR
CC_DEFAULT_FEATURES	    equ 0

ContextControlClass	endc


EndLibrary	conview


