
- Patrick Simmons
Editor
IEditor
Editor Methods
| Editor() | Constructor for the Editor class starting with empty editor |
| AddLine() | Adds a single line to the end of the editor control |
| NumLines() | Returns number of lines in the editor control |
| GetLine() | Returns a single line from the editor control for a one based line number |
| CurrentLine() | Returns the current one based line number |
| Clear() | Clear entire contents of the editor control |
| AddTextChangedHandler() | Registers an event handler for a text changed event using a method reference |
| AddTextChangedHandler() | Registers an event handler for a text changed event using an IEditor reference |
| OnTextChanged() | Virtual method to handle TextChanged events - can be overridden |
IEditor Methods
| OnTextChanged() | Virtual method to handle TextChanged events |
Derived Classes
None
See Also
Class Hierarchy, Frame, ChildFrame, Dialog, Edit, TextChangedEvent
public method Editor(Window Parent, int XPos, int YPos, int Width, int Height, bool ReadOnly = false)
Parameters
Parent
Parent window for the editor control
XPos
One based X position of control relative to parent
YPos
One based Y position of control relative to parent
Width
Initial width of the control in pixels
Height
Initial height of the control in pixels
ReadOnly
Allow editing if ReadOnly is false
Return Value
None
Description
Constructor for the Editor class. This implementation creates an empty multi-line editor control, and the script needs to add lines of data using the AddLine() method.
Editor Class
public method Editor(Window Parent, int XPos, int YPos, int Width, int Height, string FileName, bool ReadOnly = false)
Parameters
Parent
Parent window for the editor control
XPos
One based X position of control relative to parent
YPos
One based Y position of control relative to parent
Width
Initial width of the control in pixels
Height
Initial height of the control in pixels
FileName
ASCII contents to be used and modified in editor control
ReadOnly
Allow editing if ReadOnly is false
Return Value
None
Description
Constructor for the Editor class. This implementation reads the contents of the ASCII file specified by FileName. Each ASCII records creates a new line in the multi-line editor control. If the ReadOnly flag is false, executing the Save() method will cause the file to be updated with the latest contents of the editor control.
Editor Class
public method Editor(Window Parent, int XPos, int YPos, int Width, int Height, TextStream Stream, bool ReadOnly = false)
Parameters
XPos
One based X position of control relative to parent
YPos
One based Y position of control relative to parent
Width
Initial width of the control in pixels
Height
Initial height of the control in pixels
Stream
Text stream to be used and modified in editor control
ReadOnly
Allow editing if ReadOnly is false
Return Value
None
Description
Constructor for the Editor class. This implementation reads the contents of the TextStream object and populates the editor control with it. Each record in the stream becomes a separate line in the editor.
If preferred, the Save() method can then be used to write modified data back to the text stream.
Editor Class
public method AddLine(string Record)
Parameters
Record
Text string to be added as a new line to editor
Return Value
None
Description
This method adds a new line to the end of the editor control by appending it to the existing data.
Editor Class
public method<int> NumLines()
Parameters
None
Return Value
Number of lines in editor
Description
This method returns the number of separate lines in the editor control.
Editor Class
public method<string> GetLine(int LineNumber)
Parameters
LineNumber
One based line number in editor
Return Value
Line in editor based on line number
Description
This method returns the line number from the editor using the one based line number passed into the method.
Editor Class
public method<int> CurrentLine()
Parameters
None
Return Value
Current line number
Description
This method returns the one based line number where the cursor is currently located within the editor control.
Editor Class
public method Clear()
Parameters
None
Return Value
None
Description
This method clears the entire contents of the editor control without invoking the TextChangedEvent handlers.
Editor Class
public method<string> FileName()
Parameters
None
Return Value
File name specified in constructor
Description
This method returns the file name which was specified in the constructor, if applicable. If the constructor was called that does not specify a file name, this method will return an empty string.
Editor Class
public method<TextStream> Stream()
Parameters
None
Return Value
Text stream specified in constructor (or null)
Description
This method returns the TextStream object which was provided in the constructor. Null is returned if a different constructor was used.
Editor Class
public method<bool> Save(string FileName)
Parameters
FileName
File name to save data to
Return Value
True if success
Description
This method saves the current contents of the editor control to a file. If the FileName argument to this method is an empty string, the file name specified in the constructor is used (as long as the editor is not read only), and the contents of the editor control are written to that file. If the FileName argument to this method is not empty, that file name is used instead (regardless of whether a different file name was specified in the constructor), and the contents are written to that file (even if the editor is specified as read only).
The method returns true if the save operation is performed successfully, and false if not.
Editor Class
public method<bool> Save(TextStream Stream = null)
Parameters
Stream
Text stream where data is saved to
Return Value
True if success
Description
This method saves the current contents of the editor control to a TextStream object. If null is passed in as the Stream argument, the text stream passed into the constructor is used (as long as read only is false), and the contents are written to the stream starting at its current location, with each line in the editor becoming a separate record in the text stream. If the Stream argument is not null, then the data is written to that text stream instead (even if the read only flag is true)
The method returns true if the save operation is performed successfully, and false if not.
Editor Class
public method AddTextChangedHandler(TextChangedHandler Handler, Base ExtraObject = null)
Parameters
Handler
Method reference to be executed when the event occurs
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers a method reference to be executed when a "text changed" event occurs within the Editor control. Each time a character is typed into the Edit control, this event will be sent. It provides a copy of the "old string" and the "new string" for the line in question. This event occurs "after the fact", the text has already been modified, but it allows the script to perform validation on the new data. The text can also be restored to "old string" if preferred.
As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an event sent to one thread can be handled by event handlers executing in one or more other threads.
The TextChangedHandler data type represents a method reference specific to a handler for TextChangedEvent. TextChangedHandler is defined as follows:
public type<method<TextChangedEvent,Base>> TextChangedHandler
Given this definition, the method handler must be defined with the following signature (name can be anything):
public method TextChangedMethod(TextChangedEvent event, Base Extra) { }.
Editor Class
public method AddTextChangedHandler(IEditor Interface, Base ExtraObject = null)
Parameters
Interface
Reference to an IEditor object
ExtraObject
Optional object which will be sent along to each event handler when it is executed
Return Value
NONE
Description
This method registers an IEditor interface object to be executed when a "text changed" event occurs for this Editor control. An optional object can also be registered which will be sent to each event handler as it is executed.
As is true with all Aztec event handling, this method can be called by any thread. When the event occurs, each registered event handler is scheduled to execute within the thread that registered it. So an event sent to one thread can be handled by event handlers executing in one or more other threads.
When the text is modified in the Editor control, the OnTextChanged() method within the IEditor object will be executed.
Editor Class
public method virtual OnTextChanged(TextChangedEvent TextEvent, Base ExtraObject)
Parameters
TextEvent
TextChangedEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This method is the event handler for TextChangedEvent for the Edit control. It is invoked internally when a character is typed into the Edit control.. This method in turn executes every registered handler with the same argument list which comes in. Both implementations of the Editor.AddTextChangedHandler() method register the event handlers which get invoked by this method.
If this method is overridden by a class derived from Edit, it must call this implementation of the method if it needs to execute handlers registered with the Editor.AddTextChangedHandler() methods.
Editor Class
public method virtual OnTextChanged(TextChangedEvent TextEvent, Base ExtraObject)
Parameters
TextEvent
TextChangedEvent object associated with the event
ExtraObject
Optional object sent along from when it was registered
Return Value
NONE
Description
This virtual method is the event handler for TextChangedEvent within the IEditor interface class. The method which overrides it is invoked for TextChangedEvent within an Editor object when the interface object is registered with the Editor.AddTextChangedHandler() method.
IEditor Class