Initializing Your Word-Processing View
You can initialize your word-processing view in theViewSetupFormScript
method. The TXWord implementation of this method calls the inheritedViewSetupFormScript
method and then initializes the store, as shown in Listing 3-1.Listing 3-1 Initializing a word-processing view
The *ViewSetupFormScript:
func() begin inherited:?ViewSetupFormScript(); // store data in a VBO, not in NewtonScript memory :SetStore(GetDefaultStore()); // cache box top value for use in GetTextHeight method self.ourGlobalBoxTopCoordinate := :GlobalBox().top; constant kMaxScrollHeight := 32767; :SetGeometry(true, :localbox().right, kMaxScrollHeight, Relbounds(0,0,0,0)); end
protoTXView:*SetStore
method, which is called in the TXWord program'sViewSetupFormScript
method, specifies which store is used to contain the text edited in your word-processing view. This is normally the same as your soup entry's store. You can (as TXWord does) call theGetDefaultStore
function to retrieve the default store and use that.The TXWord
ViewSetupFormScript
method sets the scroll height to a very large number (32767), which ensures that the user can see all of the text. Note that this is used for a non-paged view; if you specify a paged view in your*SetGeometry
call (true
as the value of the first argument), you must specify the actual size of an individual page as the scroll height value.Although TXWord does not use margins, it still must provide a margins rectangle frame as the last parameter in the call to *
SetGeometry
. The call toRelbounds
returns a rectangle frame.
- Note
- You can call the *
SetStore
method of your word-processing view only once, and you must call it while the view is being created (before theViewSetupDoneScript
method is called). If you do not call *SetStore
, your text defaults to being RAM based.![]()
Setting Up Your Word-Processing View
You can initialize your word-processing view with the current document by reading the document data from your soup after the view has been completely set up. The TXWord program initializes its view in theViewSetupDoneScript
method, as shown in Listing 3-2.Listing 3-2 Setting up a word-processing view
The TXWord implementation ofViewSetupDoneScript:
func() begin :SetupScrollers(); :GetSoupData(); SetKeyView(self, 0); inherited:?ViewSetupDoneScript(); end
ViewSetupDoneScript
calls the following four methods:
- the
editor:SetupScrollers
method to set up the scrollers. This method, which you must call if you have scrollers, is shown in Listing 3-3.- the
editor:GetSoupData
method to read the document most recently written by TXWord from the current store, and then display that document. TheGetSoupData
method is described in "Reading a Word-Processing Document From a Soup".- the
SetKeyView
function to establish the word-processing view as the key view, which means that the view will receive keystrokes from the user. For more information about key views and theSetKeyView
function, see Chapter 4, "Keyboard Enhancements."- the inherited
ViewSetupDoneScript
method.
Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help