home *** CD-ROM | disk | FTP | other *** search
- Macintosh
- Sample Code Notes
- _____________________________________________________________________________
- Developer Technical Support
-
- #14: CPlusTESample
-
- Written by: Andrew Shebanow
-
- Versions: 1.00 April 1989
- 1.1 July 1989
- 1.2 February 1990
-
- Components: CPlusTESample.make February 1, 1990
- TApplicationCommon.h February 1, 1990
- TApplication.h February 1, 1990
- TDocument.h February 1, 1990
- TECommon.h February 1, 1990
- TESample.h February 1, 1990
- TEDocument.h February 1, 1990
- TApplication.cp February 1, 1990
- TDocument.cp February 1, 1990
- TESample.cp February 1, 1990
- TEDocument.cp February 1, 1990
- TESampleGlue.a February 1, 1990
- TApplication.r February 1, 1990
- TESample.r February 1, 1990
- _____________________________________________________________________________
-
- CPlusTESample is an example application that demonstrates how to
- initialize the commonly used Toolbox managers, operate
- successfully under MultiFinder, handle desk accessories, and
- create, grow, and zoom windows. It demonstrates fundamental
- TextEdit toolbox calls and TextEdit automatic scrolling, and it
- shows how to create and maintain scroll bar controls.
-
- This version of TESample has been substantially reworked in C++ to
- show how a ╥typical╙ object-oriented program could be written. To
- this end, what was once a single source code file has been
- restructured into a set of classes which demonstrate the
- advantages of object-oriented programming.
-
- There are four main classes in this program. Each one of these
- has a definition (.h) file and an implementation (.cp) file.
-
- The TApplication class does all of the basic event handling and
- initialization necessary for Macintosh Toolbox applications. It
- maintains a list of TDocument objects and passes events to the
- correct TDocument class when appropriate.
-
- The TDocument class does all of the basic document handling work.
- TDocuments are objects that are associated with a window. Methods
- are provided to deal with update, activate, mouse-click, key-down,
- and other events. Some additional classes which implement a
- linked list of TDocument objects are provided.
-
- The TApplication and TDocument classes together define a basic
- framework for Macintosh applications, without having any specific
- knowledge about the type of data being displayed by the
- application╒s documents. They are a (very) crude implementation of
- the MacApp application model, without the sophisticated view
- hierarchies or any real error handling.
-
- The TESample class is a subclass of TApplication. It overrides
- several TApplication methods, including those for handling menu
- commands and cursor adjustment, and it does some necessary
- initialization. Note that we only need to override nine methods
- to create a useful application class.
-
- The TEDocument class is a subclass of TDocument. This class
- contains most of the special-purpose code for text editing. In
- addition to overriding most of the TDocument methods, it defines a
- number of additional methods which are used by the TESample class
- to get information on the document state.
-
-