Objects of this class represent a canvas on which hypertext files are drawn. Most of the functionality of the library is accessed through this class.
Note that the class defines behaviour for OnEvent and OnPaint.
=1=10mm void wxHyperTextWindow(wxFrame *parent, intx, inty, intw, inth, intstyle)
Constructor; for details see wxCanvas in the wxWindows class reference.
=1=10mm void ∼wxHyperTextWindow(void)
Destructor.
=1=10mm Bool AddBlock(intxStart, intyStart, intxEnd, intyEnd, intblockType, intblockId)
Adds a block from the first row/column to the second row/column, with given type and unique identifier. The display will not change until the functions Compile and DisplayFileAt are called.
=1=10mm Bool ClearBlock(intblockId)
Clears the given block. The display will not change until the functions Compile and DisplayFileAt are called.
Clears the current hypertext file.
Compiles the current hypertext file, that is, traverses the block structure of the file associating actual fonts and other attributes to text chunks. This must be done before a file may be displayed, and may also require the functions SaveSection and RestoreSection to be called in order to save and restore the current position in the file, since compilation destroys section pointers.
After a Compile (which is necessary after marking up or any operation which affects the display) the file must be displayed with DisplayFileAt or RestoreSection.
=1=10mm void DiscardEdits(void)
Discards any edits (just sets the internal modified flag to FALSE).
=1=10mm void DisplayFile(void)
Draw the text at the point found by DisplayFileAt.
=1=10mm void DisplayFileAt(longblockId, Bool refresh = TRUE)
Positions the file at the given block, drawing the text only if refresh is TRUE. If blockId is -1, the file is displayed at the top.
=1=10mm void DisplayFileAtTop(void)
Displays the file at the top (first section).
=1=10mm void DisplayNextSection(void)
Finds and displays the next section.
=1=10mm void DisplayPreviousSection(void)
Finds and displays the previous section.
=1=10mm void DrawOutline(floatx1, floaty1, floatx2, floaty2)
Draws a rectangular outline for rubber-banding using the given top-left and bottom-right coordinates
=1=10mm wxTextChunk * FindBlock(longblockId)
For a given block id, returns the text chunk at the start of the block.
=1=10mm long FindBlockForSection(wxNode *sectionNode)
Pointers to blocks which mark sections are stored in the data member sections. This function takes a node which is known to point to a text chunk marking a block, and returns the block id. This is a fairly trivial function since it just gets the wxTextChunk from the node and returns its block_id.
=1=10mm wxNode * FindChunkAtBlock(longblockId)
For a given block id, returns the position in the text chunks list of the first CHUNK_START_LINE chunk before the block. A wxNode pointer is returned to allow the programmer to efficiently traverse the text chunks list from this point. The data stored in this node is a wxTextChunk object.
This function may not be very useful for programmers; it is mainly for internal use. Normally functions returning and taking block ids are used for manipulating blocks.
=1=10mm wxNode * FindChunkAtLine(longblockId)
For a given block id, returns the position in the text chunks list of the first chunk on the given line. A wxNode pointer is returned to allow the programmer to efficiently traverse the text chunks list from this point. The data stored in this node is a wxTextChunk object.
This function may not be very useful for programmers; it is mainly for internal use. Normally functions returning and taking block ids are used for manipulating blocks.
=1=10mm Bool FindPosition(floatmouseX, floatmouseY, int *charPos, int *linePos, long *blockId)
Finds the character and line position of the given point, plus the id of the block found. Returns FALSE if no character was found at this position.
Generates a unique identifier for a block; may be overridden to supply a different generator.
=1=10mm void GetBlockText(char *buffer, intmaxSize, longblockId)
=1=10mm void GetBlockText(char *buffer, intmaxSize, wxNode *node, longblockId)
Gets the plain text bounded by the given block, stripping out any block codes. The second form is more efficient since it takes a node containing a pointer to the wxTextChunk, and doesn't have to search for the block.
=1=10mm int GetBlockType(longblockId)
Gets the type of the given block.
=1=10mm int GetCurrentSectionNumber(void)
Gets the number of the currently-displayed section, starting from 1. Zero is returned if there are no section markers.
=1=10mm Bool GetEditMode(void)
Returns TRUE if the hypertext window is editable.
=1=10mm long GetFirstSelection(void)
Gets the first block selected. Use GetNextSelection for subsequent blocks. Returns -1 if no more selections.
=1=10mm wxHashTable * GetLinkTable(void)
Returns the hypertext window's hash table used for storing links between blocks. Objects of type HypertextItem are stored in the table, containing a destination filename and destination block id; these objects must be indexed by the source block id, to store a link between a source block and destination block.
This is only relevant if using the built-in index facility, rather than implementing your own index. You need to put and get explicitly, and writing to a file will use this table for saving the index. For example:
if (GetLinkTable()->Get(block_id)) MainFrame->SetStatusText("This block already linked!"); else if (hySelection->block_id > -1) { GetLinkTable()->Put(block_id, new HypertextItem(hySelection->filename, hySelection->block_id)); modified = TRUE; SelectBlock(hySelection->block_id, FALSE); Compile(); DisplayFile(); }
=1=10mm long GetFirstSelection(void)
Gets the next block selected (use GetFirstSelection to start. Returns -1 if no more selections.
Returns NULL or the title (pointer to the hypertext window's local memory).
=1=10mm Bool LoadFile(char *file)
Loads the named file.
Returns true if the user has modified the text.
=1=10mm void OnBeginDragLeft(floatx, floaty, longblockId, intkeys)
Called when the user starts to left-drag. Overrideable.
=1=10mm void OnBeginDragRight(floatx, floaty, longblockId, intkeys)
Called when the user starts to right-drag. Overrideable.
=1=10mm void OnDragLeft(Booldraw, floatx, floaty, longblockId, intkeys)
Called when the user is in the middle of a drag operation; called once with draw equal to FALSE and with x and y equal to the old values, then again with draw equal to TRUE and updated x and y (to allow erase/draw operations).
=1=10mm void OnDragRight(Booldraw, floatx, floaty, longblockId, intkeys)
Called when the user is in the middle of a drag operation; called once with draw equal to FALSE and with x and y equal to the old values, then again with draw equal to TRUE and updated x and y (to allow erase/draw operations).
=1=10mm void OnEndDragLeft(floatx, floaty, longblockId, intkeys)
Called when the user finishes left-dragging. Overrideable.
=1=10mm void OnEndDragRight(floatx, floaty, longblockId, intkeys)
Called when the user finishes right-dragging. Overrideable.
=1=10mm void OnLeftClick(floatx, floaty, intcharPos, intlinePos, longblockId, intkeys)
Called when the user left-clicks. Overrideable. The default behaviour when SHIFT is held down is to select or deselect the mouse-over block.
=1=10mm void OnRightClick(floatx, floaty, intcharPos, intlinePos, longblockId, intkeys)
Called when the user right-clicks. Overrideable.
=1=10mm void OnSelectBlock(longblockId, Boolselect)
Called whenever a block is selected or deselected. Overridable.
=1=10mm void RestoreSection(void)
When a call is made to Compile, the current pointer to the current section becomes invalid, since all sections are recalculated. You need to SaveSection before Compile, followed by RestoreSection after the Compile, in order to restore the display to the previous state.
=1=10mm Bool SaveFile(char *file)
Saves the hypertext file and index.
=1=10mm void SaveSection(void)
When a call is made to Compile, the current pointer to the current section becomes invalid, since all sections are recalculated. You need to call this before Compile, followed by RestoreSection after the Compile, in order to restore the display to the previous state.
=1=10mm void SelectBlock(wxTextChunk *block, Boolselect = TRUE)
=1=10mm void SelectBlock(longblockId, Boolselect = TRUE)
If select is TRUE, select the existing block, marking it in cyan (colour screens) or in inverse video (monochrome screens). If select is FALSE, deselect the block. The first form is more efficient since no search need be done for the block.
Note that Compile must be called before this call has any visible effect.
=1=10mm void SetBlockType(longblockId, intblockType)
Set the specified block to have the given type.
=1=10mm void SetEditMode(Booleditable)
Specifies whether the user should be able to mark up the text or not.
=1=10mm void SetIndexWriting(BoolindexWriting)
Specifies whether the built-in index and title should be written when SaveFile is called. The default is FALSE.
=1=10mm void SetMapping(wxHyperTextMapping *mapping)
Specify the set of block mappings for this window; this must be called.
=1=10mm void SetMargins(intleft, inttop)
Sets the margins to leave to the left and top of the canvas when displaying text.
=1=10mm void SetTitle(char *title)
Sets the title of the hypertext window (allocates its own memory), to be written to the index file if index writing mode is on.