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.
wxHyperTextWindow::wxHyperTextWindow
voidwxHyperTextWindowwxFrame *parent, int x, int y, int w, int h, int style
Constructor; for details see wxCanvas in the wxWindows class reference.
wxHyperTextWindow::wxHyperTextWindow
voidwxHyperTextWindow
Destructor.
wxHyperTextWindow::AddBlock
BoolAddBlockint xStart, int yStart, int xEnd, int yEnd, int blockType, int blockId
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.
wxHyperTextWindow::ClearBlock
BoolClearBlockint blockId
Clears the given block. The display will not change until the functions Compile and DisplayFileAt are called.
wxHyperTextWindow::ClearFile
voidClearFile
Clears the current hypertext file.
wxHyperTextWindow::Compile
voidCompile
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.
wxHyperTextWindow::DiscardEdits
voidDiscardEdits
Discards any edits (just sets the internal modified flag to FALSE).
wxHyperTextWindow::DisplayFile
voidDisplayFile
Draw the text at the point found by DisplayFileAt.
wxHyperTextWindow::DisplayFileAt
voidDisplayFileAtlong blockId, 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.
wxHyperTextWindow::DisplayFileAtTop
voidDisplayFileAtTop
Displays the file at the top (first section).
wxHyperTextWindow::DisplayNextSection
voidDisplayNextSection
Finds and displays the next section.
wxHyperTextWindow::DisplayPreviousSection
voidDisplayPreviousSection
Finds and displays the previous section.
wxHyperTextWindow::DrawOutline
voidDrawOutlinefloat x1, float y1, float x2, float y2
Draws a rectangular outline for rubber-banding using the given top-left and bottom-right coordinates
wxHyperTextWindow::FindBlock
wxTextChunk *FindBlocklong blockId
For a given block id, returns the text chunk at the start of the block.
wxHyperTextWindow::FindBlockForSection
longFindBlockForSectionwxNode *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.
wxHyperTextWindow::FindChunkAtBlock
wxNode *FindChunkAtBlocklong blockId
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.
wxHyperTextWindow::FindChunkAtLine
wxNode *FindChunkAtLinelong blockId
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.
wxHyperTextWindow::FindPosition
BoolFindPositionfloat mouseX, float mouseY, 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.
wxHyperTextWindow::GenerateId
longGenerateId
Generates a unique identifier for a block; may be overridden to supply a different generator.
wxHyperTextWindow::GetBlockText
voidGetBlockTextchar *buffer, int maxSize, long blockId
voidGetBlockTextchar *buffer, int maxSize, wxNode *node, long blockId
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.
wxHyperTextWindow::GetBlockType
intGetBlockTypelong blockId
Gets the type of the given block.
wxHyperTextWindow::GetCurrentSectionNumber
intGetCurrentSectionNumber
Gets the number of the currently-displayed section, starting from 1. Zero is returned if there are no section markers.
wxHyperTextWindow::GetEditMode
BoolGetEditMode
Returns TRUE if the hypertext window is editable.
wxHyperTextWindow::GetFirstSelection
longGetFirstSelection
Gets the first block selected. Use GetNextSelection for subsequent blocks. Returns -1 if no more selections.
wxHyperTextWindow::GetLinkTable
wxHashTable *GetLinkTable
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(); }
wxHyperTextWindow::GetNextSelection
longGetFirstSelection
Gets the next block selected (use GetFirstSelection to start. Returns -1 if no more selections.
wxHyperTextWindow::GetTitle
char *GetTitle
Returns NULL or the title (pointer to the hypertext window's local memory).
wxHyperTextWindow::LoadFile
BoolLoadFilechar *file
Loads the named file.
wxHyperTextWindow::Modified
BoolModified
Returns true if the user has modified the text.
wxHyperTextWindow::OnBeginDragLeft
voidOnBeginDragLeftfloat x, float y, long blockId, int keys
Called when the user starts to left-drag. Overrideable.
wxHyperTextWindow::OnBeginDragRight
voidOnBeginDragRightfloat x, float y, long blockId, int keys
Called when the user starts to right-drag. Overrideable.
wxHyperTextWindow::OnDragLeft
voidOnDragLeftBool draw, float x, float y, long blockId, int keys
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).
wxHyperTextWindow::OnDragRight
voidOnDragRightBool draw, float x, float y, long blockId, int keys
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).
wxHyperTextWindow::OnEndDragLeft
voidOnEndDragLeftfloat x, float y, long blockId, int keys
Called when the user finishes left-dragging. Overrideable.
wxHyperTextWindow::OnEndDragRight
voidOnEndDragRightfloat x, float y, long blockId, int keys
Called when the user finishes right-dragging. Overrideable.
wxHyperTextWindow::OnLeftClick
voidOnLeftClickfloat x, float y, int charPos, int linePos, long blockId, int keys
Called when the user left-clicks. Overrideable. The default behaviour when SHIFT is held down is to select or deselect the mouse-over block.
wxHyperTextWindow::OnRightClick
voidOnRightClickfloat x, float y, int charPos, int linePos, long blockId, int keys
Called when the user right-clicks. Overrideable.
wxHyperTextWindow::OnSelectBlock
voidOnSelectBlocklong blockId, Bool select
Called whenever a block is selected or deselected. Overridable.
wxHyperTextWindow::RestoreSection
voidRestoreSection
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.
wxHyperTextWindow::SaveFile
BoolSaveFilechar *file
Saves the hypertext file and index.
wxHyperTextWindow::SaveSection
voidSaveSection
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.
wxHyperTextWindow::SelectBlock
voidSelectBlockwxTextChunk * block, Bool select = TRUE
voidSelectBlocklong blockId, Bool select = 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.
wxHyperTextWindow::SetBlockType
voidSetBlockTypelong blockId, int blockType
Set the specified block to have the given type.
wxHyperTextWindow::SetEditMode
voidSetEditModeBool editable
Specifies whether the user should be able to mark up the text or not.
wxHyperTextWindow::SetIndexWriting
voidSetIndexWritingBool indexWriting
Specifies whether the built-in index and title should be written when SaveFile is called. The default is FALSE.
wxHyperTextWindow::SetMapping
voidSetMappingwxHyperTextMapping *mapping
Specify the set of block mappings for this window; this must be called.
wxHyperTextWindow::SetMargins
voidSetMarginsint left, int top
Sets the margins to leave to the left and top of the canvas when displaying text.
wxHyperTextWindow::SetTitle
voidSetTitlechar *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.