Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

TFileEditor Class Reference

Specialized derivative of TEditor for editing the contents of a file. More...

#include <editors.h>

Inheritance diagram for TFileEditor::

TEditor TView TObject TStreamable List of all members.

Public Methods

 TFileEditor (const TRect &bounds, TScrollBar *aHScrollBar, TScrollBar *aVScrollBar, TIndicator *aIndicator, const char *aFileName)
virtual void doneBuffer ()
virtual void handleEvent (TEvent &)
virtual void initBuffer ()
Boolean loadFile ()
Boolean save ()
Boolean saveAs ()
Boolean saveFile ()
virtual Boolean setBufSize (uint newSize)
virtual void shutDown ()
virtual void updateCommands ()
virtual Boolean valid (ushort)

Static Public Methods

TStreamablebuild ()

Public Attributes

char fileName [PATH_MAX]

Static Public Attributes

const char* const name

Protected Methods

 TFileEditor (StreamableInit)
virtual void write (opstream &)
virtual void* read (ipstream &)

Detailed Description

TFileEditor is a specialized derivative of TEditor for editing the contents of a file.

Definition at line 1185 of file editors.h.


Constructor & Destructor Documentation

TFileEditor::TFileEditor ( const TRect & bounds,
TScrollBar * aHScrollBar,
TScrollBar * aVScrollBar,
TIndicator * aIndicator,
const char * aFileName )
 

Creates a TFileEditor object with the given scroll bars and indicator and loads the contents of the file given in `aFileName'.

If the file is not found or invalid, an error message will be displayed and the object's valid() member function will return False.

The options variable is set to ofSelectable and the eventMask is set to allow the handling of broadcast events.

Any of `aHScrollBar', `aVScrollBar' or `aIndicator' arguments can be set to 0 if you do not want them.

TFileEditor::TFileEditor ( StreamableInit ) [protected]
 

Each streamable class needs a "builder" to allocate the correct memory for its objects together with the initialized virtual table pointers.

This is achieved by calling this constructor with an argument of type StreamableInit.


Member Function Documentation

TStreamable * TFileEditor::build ( ) [static]
 

Called to create an object in certain stream-reading situations.

Reimplemented from TEditor.

void TFileEditor::doneBuffer ( ) [virtual]
 

Deletes the buffer.

Reimplemented from TEditor.

void TFileEditor::handleEvent ( TEvent & event ) [virtual]
 

Calls TEditor::handleEvent(), then handles cmSave and cmSaveAs commands.

The cmSave command invokes save(); the cmSaveAs command invokes saveAs().

Reimplemented from TEditor.

void TFileEditor::initBuffer ( ) [virtual]
 

Allocates bufSize bytes of memory for the file editor buffer.

Reimplemented from TEditor.

Boolean TFileEditor::loadFile ( )
 

Reads the fileName file from disk and checks for errors.

Returns True if all is well; otherwise returns False. Depending on the reason for failure, the edOutOfMemory or edReadError dialog box is displayed with a call to editorDialog.

void * TFileEditor::read ( ipstream & is ) [protected, virtual]
 

Reads from the input stream `is'.

Reimplemented from TEditor.

Boolean TFileEditor::save ( )
 

Calls saveAs() if the file being edited is "Untitled" (that is, no fileName is allocated) and returns the return value from saveAs().

If there is a valid fileName, saveFile() is invoked, and save() returns the return value of saveFile().

Boolean TFileEditor::saveAs ( )
 

Invokes the edSaveAs dialog, which prompts for a "save as" file name. If a valid file name is supplied, the current text will be saved with this name using the saveFile() member function.

See also:
editorDialog

The file editor's owner is informed of this event via a broadcast cmUpdateTitle message. saveAs() returns True if the saveFile() call is successful, otherwise False is returned.

False is also returned if the edSaveAs dialog is cancelled.

Boolean TFileEditor::saveFile ( )
 

Saves the fileName file to disk. Returns False if the save fails; otherwise returns True. If editorFlags has the efBackupFiles bit set, a backup file is created.

The edCreateError or edWriteError dialog box will be displayed to indicate the reason for failure if save fails.

See also:
editorDialog

Boolean TFileEditor::setBufSize ( uint newSize ) [virtual]
 

Overrides TEditor::setBufSize() to grow and shrink the buffer.

Will grow and shrink the buffer in 4K byte increments. gapLen data member is adjusted appropriately.

Reimplemented from TEditor.

void TFileEditor::shutDown ( ) [virtual]
 

Undocumented.

Reimplemented from TEditor.

void TFileEditor::updateCommands ( ) [virtual]
 

Calls TEditor::updateCommands(), then enables the cmSave and cmSaveAs commands. These commands are only valid if the selected view is an editor, otherwise they should be disabled.

Reimplemented from TEditor.

Boolean TFileEditor::valid ( ushort command ) [virtual]
 

Overrides TEditor::valid() to warn that the file might need saving before the program exits.

The edSaveUntitled or edSaveModify dialogs are displayed as appropriate.

See also:
editorDialog

Returns False if the user cancels the save.

Reimplemented from TEditor.

void TFileEditor::write ( opstream & os ) [protected, virtual]
 

Writes to the output stream `os'.

Reimplemented from TEditor.


Member Data Documentation

char TFileEditor::fileName
 

The name of the file being edited.

Definition at line 1191 of file editors.h.

const char *const TFileEditor::name [static]
 

Undocumented.

Reimplemented from TEditor.

Definition at line 1320 of file editors.h.


The documentation for this class was generated from the following file:
Generated at Sat Sep 22 20:19:25 2001 for TVision by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001