{\rtf1\mac\deff2 {\fonttbl{\f0\fswiss Chicago;}{\f2\froman New York;}{\f3\fswiss Geneva;}{\f4\fmodern Monaco;}{\f13\fnil Zapf Dingbats;}{\f14\fnil Bookman;}{\f15\fnil N Helvetica Narrow;}{\f16\fnil Palatino;}{\f18\fnil Zapf Chancery;}{\f20\froman Times;} {\f21\fswiss Helvetica;}{\f22\fmodern Courier;}{\f23\ftech Symbol;}{\f33\fnil Avant Garde;}{\f34\fnil New Century Schlbk;}{\f55\fnil Code 3 of 9;}{\f1904\fnil AppleIcon;}{\f2029\fnil Nadianne;}{\f2052\fnil Zeal;}{\f12899\fnil AppleGaramond LtIt;} {\f12900\fnil AppleGaramond BkIt;}{\f12901\fnil AppleGaramond BdIt;}{\f12902\fnil AppleGaramond Lt;}{\f12903\fnil AppleGaramond Bk;}{\f12904\fnil AppleGaramond Bd;}}{\colortbl\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blu e255; \red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\ green255\blue0;\red255\green255\blue255;}{\stylesheet{\f16 \sbasedon222\snext0 Normal;}{\s1\tx360 \f20\fs20 \sbasedon222\snext1 Normal;}{\s2\tx360 \i\f20\fs20 \sbasedon1\snext2 Byline;}{\s3\tx360 \b\f20\fs20 \sbasedon2\snext3 Head1;}{\s4\tx360 \i\f20\fs20 \sbasedon3\snext4 Head2;}{\s5\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx 1800\tx1980\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 \f22\fs20 \sbasedon1\snext5 Code;}{\s6\fi-180\li360\tx360 \f20\fs20 \sbasedon222\snext6 BulletList;}{\s7 \i\f20\fs20\cf1 \sbasedon222\snext7 Caption;}}\margl720\margr720\margt720\margb720\deftab360\ftnbj\fracwidth \sectd \linemod0\cols1 \pard\plain \s2\keep\tx360 \i\f20\fs20 {\b\fs28 Tales From the View Sytem\par }\pard \s2\keep\tx360 {\plain \i\f20 Michael S. Engber \par }\pard \s2\keep\tx360 {\plain \i\f20 Apple Computer, PIE Technical Support\line Copyright \'a9 1993 - Michael S. Engber\par }\pard \s2\keep\tx360 {\plain \i\f20 \par }\pard\plain \f16 {\f20 This article was published in the November 1993 issue of PIE Developers magazine. For information about PIE Developers, contact Creative Digital Systems at CDS.SEM@APPLELINK.APPLE.COM or 415.621.4252.}\par \pard\plain \s3\tx360 \b\f20\fs20 {\plain \b\f20 \par }\pard\plain \tx360\tx540\tx675 \f16 {\f20 This article presents details about the Newton\rquote s view system that are often overlooked or misun-derstood. You can write significant Newton applications without knowing all these details (largely due to NTK \rquote s ease of use), but ultimately, you need to understand many of the topics presented here. \par }\pard \tx360 {\f20 \tab This is not an introductory article. It\rquote s designed to be read on your second or third pass through understanding the Newton\rquote s view system. Don\rquote t ex pect to understand everything it contains the first time you read it. This article assumes that the reader knows the basics of NewtonScript (especially proto and parent inheritance) and has some experience using NTK to write Newton applications.\par }\pard\plain \s3\tx360 \b\f20\fs20 {\plain \b\f20 \par }\pard \s3\keep\tx360 {\plain \b\f20 Templates vs. Views\par }\pard\plain \tx360 \f16 {\f20 Views are not created by NTK. In NTK you lay out templates. Views are frames created in RAM by the Newton\rquote s view system. Views use templates as their prototypes. The difference between views and templates seems obvious enough, but in practice, it\rquote s easy to get confused. Figure 1 illustrates the relationship between a typical view, template, and prototype.\par }\pard \tx360 {\f20 \par \par }\pard \qc\tx360 {{\pict\macpict\picw444\pich148 045601850042021901fe001102ff0c00ffffffff003d00000185000002040000021b00000 000000000a0008200a10064000a53504e5403e80001000000a10064000e53504e540cd001 85003d021b020400a10064000a53504e540bb80001000000a10064001a53504e540c26018 f003d021b00b000040002ffffffffffffff ff00a10064000a53504e540c940000000000a10096000c050000000200000000000000000 1000a0185003d021b0204002c000a001607436f757269657200030016000d000c002e0004 000000000028019d0042027b0d00002a0c0a205f706172656e743a0d002a0c09205f70726 f746f3a0d00002a0c102076696577434f62 6a6563743a20c90d002a0c027d0d002a0c010d00002a0c010d00002a0c010d00002a0c010 d00002a0c072f2f766965770d00002a0c0a2f2f28696e2052414d2900a0009700a1006400 0a53504e540bb80001000000a10064001a53504e540c26018f00c7021b017100040002fff fffffffffffff00a10064000a53504e540c 940000000000a10096000c0500000002000000000000000028019d00cc027b0d00002a0c0 9205f70726f746f3a0d00002a0c0f2076696577426f756e64733a20c90d00002a0c0e2076 696577466c6167733a20c90d002a0c182076696577536574757046726f6d5363726970743 a20c90d002a0c142076696577436c69636b 5363726970743a20c90d002a0c0920746578743a20c90d00002a0c0320c90d00002a0c027 d0d002a0c0b2f2f74656d706c6174650d00002a0c162f2f286f6e2050434d43494120524f 4d20636172642900a0009700a10064002253504e540cee000200100056000000260000005 6000000000000000000000000008000a100 64000a53504e540bb80002000200a10064000e53504e540c9e01a500830185008300a0008 c002201a5008300ec0071001e0185007e019100880191008301910088018500830191007e 0191008300a0008d00a10064000a53504e540bb80002000200a10064000e53504e540c9e0 1b1007d01b100ca00a0008c002201b1007d 41000071001e01ac00be01b600ca01b100be01b600be01b100ca01ac00be01b100be00a00 08d00a10064000a53504e540bb80002000200a10064000e53504e540c9e01a4010b01a401 7e00a0008c002201a4010b67000071001e019f017201a9017e01a4017201a9017201a4017 e019f017201a4017200a0008d00a1006400 0853504e540cee000000a10064000a53504e540bb80001000000a10064001a53504e540c2 6018f0180021b020400040002ffffffffffffffff00a10064000a53504e540c9400000000 00a10096000c0500000002000000000000000028019d0185010d002a0c0f3c73797374656 d2070726f746f3e0d00002a0c010d00002a 0c010d00002a0c010d00002a0c010d00002a0c010d00002a0c010d00002a0c010d00002a0 c0c2f2f70726f746f747970650d002a0c112f2f28696e204e6577746f6e20524f4d290000 a0009700a10064000653504e5403e900a0008300ff}}{\f20 \par }\pard \qc\tx360 {\f20 \par \par }\pard \qc\tx360 Figure 1 - A typical view/template/proto relationship. {\f20 \par }\pard \qc\tx360 {\f20 \par \par }\pard \tx360 {\f20 \tab Note several things about Figure 1:\par \par }\pard\plain \s6\fi-180\li360\keep\tx360 \f20\fs20 {\plain \f20 \bullet \tab The view has very few slots, just _parent, _proto, and viewCObject. Views inherit most of the slots and methods they need. This lets views remain small, which is important since they take up space in RAM. Note: if the view has declared children, it woul d contain a slot for each declared child. Details regarding these slots are discussed later in this article.\par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab Figure 1 shows why the slot assignment rules work the way they do. Recall, if you change the value of a slot inherited from the _proto chain, a new slot is created in the frame to hold the new value (rather than modifying the inherited slot). If we look at the figure, we can see that only the view is in RAM. Modifying the inherited slot is not even possible. So, even though a view frame starts out very small, it grows over time as slots g et modified. This growth is usually very small, since in practice, views seldom ever modify more than one or two slots.\par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab The template does not have a _parent slot.This might be surprising since NTK displays templates using a parent-child hierarchy. NTK actually uses the hierarchy which exists among the view objects created from the templates.\par }\pard\plain \li360\tx360 \f16 {\f20 \par }\pard \tx360 {\f20 Table 1 on the next page is a quiz to test your understanding of the distinction between views and templates.\par \par }\pard \qc\tx360 {{\pict\macpict\picw469\pich186 0b3a0000000d00ba01e2001102ff0c00ffffffff000000000000000001e2000000ba00000 0000000001e0001000a0000000000ba01e2002c000800140554696d657300030014000d00 0c002e00040000ff00001000ba01e200ba01e20028000a017a0874656d706c61746500001 5d080002936047669657700220000000d00 000023000000220000000e190000320001002800010029002200000028000000200000002 900000174002200000175000000220000017634000022000001ab00000022000001ac3400 0022000001e100000023000000220001000d000b003200010028000d00290022000101750 00b0022000101ab000b0022000101e1000b 0028001700120231290000157e4000291b0e63726561746564206279204e544b0022000d0 00d00000022000d000e19000032000e0028000e00290022000d002800000020000d002900 0d01740022000d017500000022000d017634000022000d01ab00000022000d01ac3400002 2000d01e100000022000e000d000b003200 0e0028001a00290022000e0175000b0022000e01ab000b0022000e01e1000b00280024001 20232290000157e4000291b126f6e6c792072657369646520696e2052414d0022001a000d 00000022001a000e19000032001b0028001b00290022001a002800000020001a0029001a0 1740022001a017500000022001a01763400 0022001a01ab00000022001a01ac34000022001a01e100000022001b000d000b0032001b0 028002700290022001b0175000b0022001b01ab000b0022001b01e1000b00280031001202 332900000a000000000000000000340034000d0035002800157e40002b1b010768616e646 c6573002c000a001607436f757269657200 03001600152580002925073a486964652829000003001400152580002931022c200003001 600152580002906153a4f70656e28292c20616e64203a436c6f7365282900000300140015 258000299309206d6573736167657300003400340175003501ab0034003401ab003501e10 0220027000d000000220027000e19000032 0028002800280029002200270028000000200027002900270174002200270175000000220 027017634000022002701ab00000022002701ac34000022002701e1000000220028000d00 0c00320028002800350029002200280175000c0022002801ab000c0022002801e1000c002 8003f00120234290000157e4000291b2e72 657369646520696e20737465704368696c6472656e20616e6420766965774368696c64726 56e2061727261797300220035000d000000220035000e1900003200360028003600290022 0035002800000020003500290035017400220035017500000022003501763400002200350 1ab00000022003501ac34000022003501e1 000000220036000d000b00320036002800420029002200360175000b0022003601ab000b0 022003601e1000b0028004c0012023529000034004f000d0050002800157e40002b1b0139 636f6465206d6f64696669657320746865697220736c6f74732061742072756e74696d652 02d2070726566657261626c792c20757369 6e672000030016001564000028004d01350853657456616c7565000034004f0175005001a b0034004f01ab005001e100220042000d000000220042000e190000320043002800430029 0022004200280000002000420029004201740022004201750000002200420176340000220 04201ab00000022004201ac340000220042 01e1000000220043000d000c00320043002800500029002200430175000c0022004301ab0 00c0022004301e1000c000300140028005a00120236290000157e4000291b267573652073 797374656d2070726f746f7320696e2074686569722070726f746f20736c6f74730022005 0000d000000220050000e19000032005100 2800510029002200500028000000200050002900500174002200500175000000220050017 634000022005001ab00000022005001ac34000022005001e1000000220051000d000b0032 00510028005d0029002200510175000b0022005101ab000b0022005101e1000b002800670 0120237290000157e4000291b1570617373 656420746f204164645374657056696577000022005d000d00000022005d000e190000320 05e0028005e00290022005d002800000020005d0029005d01740022005d01750000002200 5d017634000022005d01ab00000022005d01ac34000022005d01e100000022005e000d000 b0032005e0028006a00290022005e017500 0b0022005e01ab000b0022005e01e1000b0028007400120238290000157e4000291b38757 375616c6c7920636f6e7461696e732066657720736c6f74732028696e6865726974732c20 6d6f7374206f662069747320736c6f7473290022006a000d00000022006a000e190000320 06b0028006b00290022006a002800000020 006a0029006a01740022006a017500000022006a017634000022006a01ab00000022006a0 1ac34000022006a01e100000022006b000d000b0032006b0028007700290022006b017500 0b0022006b01ab000b0022006b01e1000b0028008100120239290000157e4000291b15757 375616c6c792072657369646520696e2052 4f4d0000220077000d000000220077000e190000320078002800780029002200770028000 000200077002900770174002200770175000000220077017634000022007701ab00000022 007701ac34000022007701e1000000220078000d000b00320078002800840029002200780 175000b0022007801ab000b0022007801e1 000b0028008e00120331302900340091000d0092002800157e40002b1b010c72657475726 e65642062792000000300160015774000293a123a4368696c64566965774672616d657328 29003400910175009201ab0034009101ab009201e100220084000d000000220084000e190 00032008500280085002900220084002800 0000200084002900840174002200840175000000220084017634000022008401ab0000002 2008401ac34000022008401e1000000220085000d000c0032008500280092002900220085 0175000c0022008501ab000c0022008501e1000c000300140028009c00120331312900157 e4000291b1372657475726e656420627920 446562756728290000220092000d000000220092000e19000032009300280093002900220 0920028000000200092002900920174002200920175000000220092017634000022009201 ab00000022009201ac34000022009201e1000000220093000d000b003200930028009f002 9002200930175000b0022009301ab000b00 22009301e1000b002800a900120331322900157e4000291b0a69732061206672616d65002 2009f000d00000022009f000e1900003200a0002800a000290022009f002800000020009f 0029009f01740022009f017500000022009f017634000022009f01ab00000022009f01ac3 4000022009f01e10000002200a0000d000b 003200a0002800ac0029002200a00175000b002200a001ab000b002200a001e1000b00280 0b600120331332900157e4000291b0c686173206120706172656e74002200ac000d000000 2200ac000e1900003200ad002800ad0029002200ac00280000002000ac002900ac0174002 200ac01750000002200ac01763400002200 ac01ab0000002200ac01ac3400002200ac01e10000002200ad000d000b003200ba000d00b a000e002200b9000d000000230000002200b9000e1900003200ad002800b90029003200ba 002800ba0029002200b900280000002000b9002900b90174002200ad0175000b003200ba0 17500ba0176002200b901750000002200b9 01763400002200ad01ab000b003200ba01ab00ba01ac002200b901ab0000002200b901ac3 400002200ad01e1000b003200ba01e100ba01e2002200b901e1000000230000003200b901 e200ba01eb00ff}}{\f20 \par }\pard \qc\tx360 {\f20 \par }\pard \tx360 {\f20 \par }\pard \qc\tx360 Table 1 - A template vs. view quiz.\par \pard \tx360 {\f20 \par }\pard\plain \s3\tx360 \b\f20\fs20 {\plain \b\f20 \par }\pard \s3\keep\tx360 {\plain \b\f20 Templates vs. Prototypes\par }\pard\plain \tx360 \f16 {\f20 The distinction between templates and prototypes is a bit subtle. I could even argue that, technically, there is no difference. However, it\rquote s useful to draw the distinction, especially since NTK enforces this distinction. The things you drag out in NTK are templates. The NTK palette that you make selections from contains prototypes (well, viewClasses too, but we won\rquote t go into that now). In general, templates contain prototypes in their _proto slot.\par }\pard\plain \s3\tx360 \b\f20\fs20 {\plain \b\f20 \par }\pard \s3\keep\tx360 {\plain \b\f20 viewChildren and stepChildren\par }\pard\plain \tx360 \f16 {\f20 The viewChildren and stepChildren slots both contain template arrays. These arrays are used to create a view\rquote s children when the parent view is first created. In general, you use stepChildren for children you define, and the system uses viewChildren for its children. For example, if you create a template based on ProtoFloatNGo, the close box is provided by the system and its template is in the viewChildren array. The templates you add are put into the stepChildren array by NTK. Normally, you need not concern yourself with these details, unless you\rquote re explicitly defining a template as a NewtonScript frame rather than dragging it out graphically from the palette.\par }\pard \tx360 {\f20 \tab Always remember: \ldblquote viewChildren and stepChildren contain templates, not views.\rdblquote Dereferencing some unsuspecting element of your stepChildren or viewChildren array and sending it a Hide message does absolutely no good. It generates an error. If you need acc ess to the views that are created from your viewChildren and stepChildren templates, use the ChildViewFrames message. It returns an array of all the views created from }{\i\f20 both}{\f20 the viewChildren and stepChildren. The viewChildren views are first, followed by the stepChildren views in sibling order (the order they show up in NTK browser). In the FloatNGo example described earlier, ChildViewFrames returns an array whose first eleme nt is a close-box view, followed by all the views for the items you define.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Why viewChildren and stepChildren?\par }\pard\plain \tx360 \f16 {\f20 If there is only one slot, say the viewChildren slot, then your template\rquote s viewChildren slot overrides the viewChildren slot of your template\rquote s proto. Returning to the ProtoFloatNGo example, the close box would be missing. When the view system instantiates the view, it only sees the items you define and in this case misses the close box.\par \tab This problem can be resolved by searching the entire proto chain for viewChildren slots when creating a view. But this is inefficient. Instead, a parallel slot is used. It\rquote s unfortunate that the term stepChildren makes the stepChildren slot sound inferior in some way. The only difference between stepChildren and viewChildren is that the views created from viewChildren are first in the ChildViewFrames array.\par }\pard \tx360 {\f20 \par }\pard\plain \s2\tx360 \i\f20\fs20 {\plain \i\f20 Note: At first glance this may appear to be a problem for user protos\endash you might expect the stepChildren slot in your template to override the stepChildren slot in the userProto it\rquote s based on. This isn\rquote t a problem because NTK combines the stepChildren of the entire proto chain when it compiles your template. This process doesn\rquote t occur until you build your package, so you\rquote re normally unaware of it. If you look at your view\rquote s stepChildren slot in the inspector, however, you will see all your template\rquote s children plus any children defined in its proto. \par }\pard \s2\tx360 {\plain \i\f20 \tab It may seem possible to combine all the stepChildren and viewChildren at compile time and use one slot to reference all of them. This is not possible\endash the viewChildren are defined in templates in the Newton ROM and aren\rquote t available at compile time. \par }\pard\plain \tx360 \f16 {\f20 \par }\pard\plain \s3\keep\tx360 \b\f20\fs20 {\plain \b\f20 Declaring Views\par }\pard\plain \tx360 \f16 {\f20 Declaring a view allows you to access it symbolically. For example, if you declare a view SomeDeclaredView then you can write code like }{\f22 SomeDeclaredView:Open()}{\f20 to display it. In NTK you declare views using the Template Info\'c9 command. Both the view being declared and the view to which it\rquote s being declared must be named. You select the view you want to declare and execute the Template Info\'c9 command (Special menu). Figure 2 shows the dialog which appears. You name the view using the edit text field, and use the Allow Access From checkbox and popup to declare the view. Only named parent views appear in the pop up.\par }\pard \tx360 {\f20 \par \par \par }\pard \qc\tx360 {{\pict\macpict\picw362\pich138 279800000000008a016a001102ff0c00ffffffff0000000000000000016a0000008a00000 000000000a0008200a10064000a53504e5403e80001000000a10064000e53504e540cd000 bb006b014501d500a10064000a53504e540bb8000a000100a10064001253504e540c30fff fffff00000000008a016a00a10064000a53 504e540c9400010001001e0001000a00000000008a016a000900000000000000000031000 00000008a016a00a10064000653504e54623e00a0008e0098816c000000000070016c0000 0000000000000048000000480000000000080001000800000000005d8e900000000000000 008800000ff0000ffffffffffff0000ffff ffffcccc0000ffffffff99990000ffffffff66660000ffffffff33330000ffffffff00000 000ffffccccffff0000ffffcccccccc0000ffffcccc99990000ffffcccc66660000ffffcc cc33330000ffffcccc00000000ffff9999ffff0000ffff9999cccc0000ffff99999999000 0ffff999966660000ffff999933330000ff ff999900000000ffff6666ffff0000ffff6666cccc0000ffff666699990000ffff6666666 60000ffff666633330000ffff666600000000ffff3333ffff0000ffff3333cccc0000ffff 333399990000ffff333366660000ffff333333330000ffff333300000000ffff0000ffff0 000ffff0000cccc0000ffff000099990000 ffff000066660000ffff000033330000ffff000000000000ccccffffffff0000ccccffffc ccc0000ccccffff99990000ccccffff66660000ccccffff33330000ccccffff00000000cc ccccccffff0000cccccccccccc0000cccccccc99990000cccccccc66660000cccccccc333 30000cccccccc00000000cccc9999ffff00 00cccc9999cccc0000cccc999999990000cccc999966660000cccc999933330000cccc999 900000000cccc6666ffff0000cccc6666cccc0000cccc666699990000cccc666666660000 cccc666633330000cccc666600000000cccc3333ffff0000cccc3333cccc0000cccc33339 9990000cccc333366660000cccc33333333 0000cccc333300000000cccc0000ffff0000cccc0000cccc0000cccc000099990000cccc0 00066660000cccc000033330000cccc0000000000009999ffffffff00009999ffffcccc00 009999ffff999900009999ffff666600009999ffff333300009999ffff000000009999ccc cffff00009999cccccccc00009999cccc99 9900009999cccc666600009999cccc333300009999cccc0000000099999999ffff0000999 99999cccc0000999999999999000099999999666600009999999933330000999999990000 000099996666ffff000099996666cccc00009999666699990000999966666666000099996 66633330000999966660000000099993333 ffff000099993333cccc00009999333399990000999933336666000099993333333300009 99933330000000099990000ffff000099990000cccc000099990000999900009999000066 660000999900003333000099990000000000006666ffffffff00006666ffffcccc0000666 6ffff999900006666ffff666600006666ff ff333300006666ffff000000006666ccccffff00006666cccccccc00006666cccc9999000 06666cccc666600006666cccc333300006666cccc0000000066669999ffff000066669999 cccc000066669999999900006666999966660000666699993333000066669999000000006 6666666ffff000066666666cccc00006666 66669999000066666666666600006666666633330000666666660000000066663333ffff0 00066663333cccc0000666633339999000066663333666600006666333333330000666633 330000000066660000ffff000066660000cccc00006666000099990000666600006666000 06666000033330000666600000000000033 33ffffffff00003333ffffcccc00003333ffff999900003333ffff666600003333ffff333 300003333ffff000000003333ccccffff00003333cccccccc00003333cccc999900003333 cccc666600003333cccc333300003333cccc0000000033339999ffff000033339999cccc0 00033339999999900003333999966660000 3333999933330000333399990000000033336666ffff000033336666cccc0000333366669 999000033336666666600003333666633330000333366660000000033333333ffff000033 333333cccc000033333333999900003333333366660000333333333333000033333333000 0000033330000ffff000033330000cccc00 0033330000999900003333000066660000333300003333000033330000000000000000fff fffff00000000ffffcccc00000000ffff999900000000ffff666600000000ffff33330000 0000ffff000000000000ccccffff00000000cccccccc00000000cccc999900000000cccc6 66600000000cccc333300000000cccc0000 000000009999ffff000000009999cccc00000000999999990000000099996666000000009 99933330000000099990000000000006666ffff000000006666cccc000000006666999900 0000006666666600000000666633330000000066660000000000003333ffff00000000333 3cccc000000003333999900000000333366 6600000000333333330000000033330000000000000000ffff000000000000cccc0000000 000009999000000000000666600000000000033330000eeee000000000000dddd00000000 0000bbbb000000000000aaaa0000000000008888000000000000777700000000000055550 00000000000444400000000000022220000 0000000011110000000000000000eeee000000000000dddd000000000000bbbb000000000 000aaaa000000000000888800000000000077770000000000005555000000000000444400 0000000000222200000000000011110000000000000000eeee000000000000dddd0000000 00000bbbb000000000000aaaa0000000000 0088880000000000007777000000000000555500000000000044440000000000002222000 00000000011110000eeeeeeeeeeee0000dddddddddddd0000bbbbbbbbbbbb0000aaaaaaaa aaaa000088888888888800007777777777770000555555555555000044444444444400002 22222222222000011111111111100000000 00000000000000000070016a000000000070016a0000000981ff81ff97ff010000000d00f f812a812a9a2a0355ff0000000d00ff81f581f59af50355ff0000000d00ff81f581f59af5 0355ff0000000f01fff583fa99f582fa04f555ff0000002400ff81f5fcf5fbffe4f501fff ff6f501fffff1f501fffff4f5feff81f5f3 f50355ff0000002801fff583faf9f501ffffe2f501fffff6f501fffff1f501fffff5f501f ffff1f582fa04f555ff0000004000ff81f5faf501fffffdf5fdfffef5f8fffef5fcfffef5 01fffffef5fdfffef5fdfffef5fdfff9f501fffffef5fcfffef5fdfffef5fdff81f5f9f50 355ff0000006701fff583faf9f501fffffe f520fffff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffef 501fffffef501fffffef505fffff5f5fffffaf501fffffef505fffff5f5fffffef501ffff fef505fffff5f5fffffaf582fa04f555ff0000006100ff81f5faf501fffffef51dfffff5f 5fffff5f5fffff5f5fffff5f5fffff5f5ff fff5f5fffff5f5fffffef5fcfffef501fffffef505fffff5f5fffffaf501fffffef505fff ff5f5fffffef501fffffef505fffff5f5ffff81f5faf50355ff0000005e01fff583faf9f5 01fffffef5fbff1ff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffff5f5fffff 5f5fffffef501fffffef5fbfffaf501ffff fef505fffff5f5fffffef501fffffef505fffff5f5fffffaf582fa04f555ff0000005e00f f81f5faf501fffffef501fffffbf51dfffff5f5fffff5f5fffff5f5fffff5f5fffff5f5ff fff5f5fffff5f5fffffef501fffffef501fffff6f501fffffef505fffff5f5fffffef501f ffffef505fffff5f5ffff81f5faf50355ff 0000006701fff583faf9f501fffffef501fffffef520fff5f5fffff5f5fffff5f5fffff5f 5fffff5f5fffff5f5fffff5f5fffff5f5fffffef501fffffef501fffffef500fffaf501ff fffef505fffff5f5fffffef501fffffef505fffff5f5fffffaf582fa04f555ff000000500 0ff81f5faf501fffffdf5fdfffef50bffff f5f5fffff5f5fffff5f5fcfffef501fffffef5fcfffdf501fffffef5fdfff9f501fffffef 505fffff5f5fffffef501fffffdf5fdff81f5f9f50355ff0000001401fff583fae0f501ff ffbcf582fa04f555ff0000001200ff81f5e1f501ffff81f5bcf50355ff0000000d00ff81f 581f59af50355ff0000000c00ff81558155 995502ff0000000f01fff7818081809c8004f780ff0000001102fff78081ff81ff9eff052 af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff780ff810081 00a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff 780ff81008100a00006ff2af780ff000000 1303fff780ff81008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2af 780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff780ff81008100 a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff78 0ff81008100a00006ff2af780ff00000013 03fff780ff81008100a00006ff2af780ff0000001703fff780ffd10081ff81ffe0fff1000 6ff2af780ff0000001b03fff780ffd10000ff81008100e20000fff10006ff2af780ff0000 001b03fff780ffd10000ff81008100e20000fff10006ff2af780ff0000001f03fff780ffd 10002ff000081ff81ffe6ff020000fff100 06ff2af780ff0000001f03fff780ffd10002ff000081ff81ffe6ff020000fff10006ff2af 780ff0000002703fff780fff600feff0200ffffe20002ff000081ff81ffe6ff020000fff1 0006ff2af780ff0000002d03fff780fff600feff0200ffffe20002ff0000f9ff0000f3fff c0081ff82ff020000fff10006ff2af780ff 0000003803fff780fff600fbff010000feff010000fafffe00fefffd0001fffffc0002ff0 000e7ff000081ff81ff020000fff10006ff2af780ff0000004e03fff780fff600fbfffd00 10ffff00ffff00ffff00ffff00ffff00fffff70004ff0000ff00feff0a00ff0000ffff000 0ffff00fcff0000feff000081ff81ff03ff 0000fff10006ff2af780ff0000005003fff780fff60002ffff00feff010000fdff0900fff f00ffff00ffff00fcfff70007ff0000ffff00ff00feff0c00ff00ffff00ffff00ff00ff00 fefffe0081ff81ff020000fff10006ff2af780ff0000005003fff780fff60002ffff00fef f1100ffff00ffff00ffff00ffff00ffff00 fffff40007ff0000ffff00ff00feff0100fffd0006ffff00ff00ff00fbff000081ff82ff0 20000fff10006ff2af780ff0000005503fff780fff60007ffff0000ffff0000fdff0a00ff ff00ffff00ffff0000fefffd0001fffffc0002ff0000feff0000fdff0200ff00fbff0200f f00feff0000feff000081ff82ff020000ff f10006ff2af780ff0000003303fff780ffd10002ff0000feff0000fdff0400ffff0000fdf f0200ff00fdfffe0081ff81ff020000fff10006ff2af780ff0000001f03fff780ffd10002 ff000081ff81ffe6ff020000fff10006ff2af780ff0000001f03fff780ffd10002ff00008 1ff81ffe6ff020000fff10006ff2af780ff 0000001b03fff780ffd10000ff81008100e20000fff10006ff2af780ff0000001b03fff78 0ffd10000ff81008100e20000fff10006ff2af780ff0000001b03fff780ffd10000ff8100 8100e20000fff10006ff2af780ff0000001703fff780ffd10081ff81ffe0fff10006ff2af 780ff0000001303fff780ff81008100a000 06ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff780ff8 1008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff00000013 03fff780ff81008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2af78 0ff0000001303fff780ff81008100a00006 ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff780ff810 08100a00006ff2af780ff0000001503fff780ff8100cf00c4ff8f0006ff2af780ff000000 1b03fff780ffd000f5ff8c0000ffc60000ff8f0006ff2af780ff0000002103fff780ffd00 001fffff90001ffff8c0000ffc60000ff8f 0006ff2af780ff0000002403fff780ffd00002ff00fffb0002ff00ff8c0000ffc60001fff f900006ff2af780ff0000004403fff780ffd00003ff0000fffd0003ff0000fffa0001ffff fe00feff0000feffea0001ffffdc00fcffe20000ffee0000fff10000ffeb0001ffff90000 6ff2af780ff0000004803fff780ffd00000 fffe0003ff0000fffe0000fffa0001fffffd0005ffff0000ffffea0001ffffdc0001ffffd f0000fffe00feffe40001ffffeb0001ffff900006ff2af780ff0000008f03fff780ffd000 00fffd0001fffffd0000fffb00fdfffe0007ffff0000ffff0000feff030000fffffd0001f ffffa00fdfffe00fefffe00fefffe00feff fe00fdff010000fdfffc0001fffffd00fcff010000feff010000fafffd0001fffffc0002f f0000fcfffc0000fffe000aff00ffff0000ffff0000fffc0000fffe0000ffeb0001ffff90 0006ff2af780ff0000009403fff780ffd00000fffd0001fffffd0000fffb00fdfffe000df fff0000ffff00ffff00ffff0000fbfff900 fdff150000ffff00ffff00ffff00ffff00ffff00ffff00fffffd0001fffff900fdff01000 0fefffe000dffff00ffff00ffff00ffff00fffff70002ff0000fcfffb0002ff00fffe000c ff00ff0000ff0000ff00ff00fffd0000ffeb0001ffff900006ff2af780ff0000009003fff 780ffd00000fffe0003ff0000fffe0000ff fc00fbff0f0000ffff0000ffff00ffff00ffff0000fbfffa00fbff0200fffffd0001fffff d00fcff010000fefffe00fefffb0001fffffd0001fffffd000dffff00ffff00ffff00ffff 00fffff70002ff0000fcfffb0002ff00fffe0001ff00fdff060000ff00ff00fffd0000ffe b0001ffff900006ff2af780ff0000009603 fff780ffd00003ff0000fffd0003ff0000fffc0013ffff0000ffff0000ffff0000ffff00f fff00fffffe00fdfff90014ffff0000ffff00ffff00ffff00ffff00ffff00fffffa0001ff fffd0001fffffc0001fffffd0001fffffd000dffff00ffff00ffff00ffff00fffff70000f ffe00fefff90000fffd0002ff00fffb0002 ff00fffc0000ffeb0001ffff900006ff2af780ff0000009003fff780ffd00002ff00fffb0 002ff00fffc000fffff0000ffff0000ffff0000ffff0000fefffd00fdfff90007ffff0000 ffff0000fefffe00fefffe00feff010000fdff010000fdfffb0001fffffd0001fffffc00f eff090000ffff00ffff00fffffe0001ffff fc0000fff30000fffd0004ff0000fffffd0002ff00fffc0000ffeb0001ffff900006ff2af 780ff0000002203fff780ffd00001fffff90001ffff8c0000ffc60001ffff900006ff2af7 80ff0000001c03fff780ffd000f5ff8c0000ffc60001ffff900006ff2af780ff0000001a0 3fff780ff8100cf0000ffc60001ffff9000 06ff2af780ff0000001a03fff780ff8100cf0000ffc60001ffff900006ff2af780ff00000 01a03fff780ff8100cf0000ffc60001ffff900006ff2af780ff0000002203fff780ff8100 cf0000ffee0000fff200feffec0001ffff900006ff2af780ff0000002203fff780ff8100c f0000ffdf0000fffe0000ffed0001ffff90 0006ff2af780ff0000003403fff780ff8100cf0000fff50000fffe000aff00ffff0000fff f0000fffc0000fffc0000ffed0001ffff900006ff2af780ff0000003403fff780ff8100cf 0000fff40002ff00fffe000cff00ff0000ff0000ff00ff00fffc0000ffec0001ffff90000 6ff2af780ff0000003303fff780ff8100cf 0000fff40002ff00fffe0001ff00fdff060000ff00ff00fffd0000ffeb0001ffff900006f f2af780ff0000002e03fff780ff8100cf0000fff30000fffd0002ff00fffb0002ff00fffd 0000ffea0001ffff900006ff2af780ff0000003003fff780ff8100cf0000fff30000fffd0 004ff0000fffffd0002ff00fffe00fcffed 0001ffff900006ff2af780ff0000001a03fff780ff8100cf0000ffc60001ffff900006ff2 af780ff0000001a03fff780ff8100cf0000ffc60001ffff900006ff2af780ff0000001503 fff780ff8100cf00c3ff900006ff2af780ff0000001503fff780ff8100cc00c6ff900006f f2af780ff0000001303fff780ff81008100 a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff78 0ff81008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000 001303fff780ff81008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2 af780ff0000001303fff780ff81008100a0 0006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff780f f81008100a00006ff2af780ff0000001703fff780ff81008100f000c3ffef0006ff2af780 ff0000001703fff780ff81008100f200bffff10006ff2af780ff0000001703fff780ff810 08100f300bdfff20006ff2af780ff000000 1b03fff780ff81008100f400fcffc500fcfff30006ff2af780ff0000002103fff780ff810 0c000c7ffef00fefffe00c7fffe00fefff30006ff2af780ff0000002b03fff780ff8100c2 0001ffffc70001fffff200fdff0200ffffc70002ffff00fdfff40006ff2af780ff0000002 903fff780ff8100c20000ffc50000fff200 feff020000ffc50002ff0000fefff40006ff2af780ff0000002703fff780ff8100c30000f fc30000fff300feff0100ffc30001ff00fefff40006ff2af780ff0000002703fff780ff81 00c30000ffc30000fff300feff0100ffc30001ff00fefff40006ff2af780ff0000003e03f ff780ff8100c30000fff600fdffdf0001ff fff60000fff300feff0100ffe900fdfffe0001fffffe0001ffffe90001ff00fefff40006f f2af780ff0000004603fff780ff8100c30000fff70001fffffe0000ffe00001fffff60000 fff300feff0100ffea000dffff0000ffff0000ffff0000ffffe80001ff00fefff40006ff2 af780ff0000005103fff780ff8100c30000 fff70001fffffa00fdfffe00fcfffd00fefffd00fdfffe0001fffff60000fff300feff010 0ffea000cffff0000ffff0000ffff00ffffe70001ff00fefff40006ff2af780ff0000005d 03fff780ff8100c30000fff70001fffffb0000fffe001cffff0000ffff0000ffff0000fff f0000ff0000ffff0000ffff0000fffff600 00fff300feff0100ffea0007ffff0000ffff0000fdffe60001ff00fefff40006ff2af780f f0000005703fff780ff8100c30000fff70001fffffa00fcff0b0000ffff0000ffff0000ff fffc0009ffff0000ffff0000fffff60000fff300feff0100ffea0007ffff0000ffff0000f effe50001ff00fefff40006ff2af780ff00 00005703fff780ff8100c30000fff70001fffffb0011ffff0000ffff0000ffff0000ffff0 000fffffc00fbff030000fffff60000fff300feff0100ffea0007ffff0000ffff0000fdff e60001ff00fefff40006ff2af780ff0000005b03fff780ff8100c30000fff70001fffffb0 011ffff0000ffff0000ffff0000ffff0000 fffffc0001fffffb0001fffff60000fff300feff0100ffea000cffff0000ffff0000ffff0 0ffffe70001ff00fefff40006ff2af780ff0000006403fff780ff8100c30000fff70001ff fffe001bff0000ffff0000ffff0000ffff0000ffff0000ffff0000ff0000fffffe0004ff0 000fffff60000fff300feff0100ffea000d ffff0000ffff0000ffff0000ffffe80001ff00fefff40006ff2af780ff00000098816c007 00000008a016c00000000000000000048000000480000000000080001000800000000005d 90cc0000000000000008800000ff0000ffffffffffff0000ffffffffcccc0000ffffffff9 9990000ffffffff66660000ffffffff3333 0000ffffffff00000000ffffccccffff0000ffffcccccccc0000ffffcccc99990000ffffc ccc66660000ffffcccc33330000ffffcccc00000000ffff9999ffff0000ffff9999cccc00 00ffff999999990000ffff999966660000ffff999933330000ffff999900000000ffff666 6ffff0000ffff6666cccc0000ffff666699 990000ffff666666660000ffff666633330000ffff666600000000ffff3333ffff0000fff f3333cccc0000ffff333399990000ffff333366660000ffff333333330000ffff33330000 0000ffff0000ffff0000ffff0000cccc0000ffff000099990000ffff000066660000ffff0 00033330000ffff000000000000ccccffff ffff0000ccccffffcccc0000ccccffff99990000ccccffff66660000ccccffff33330000c cccffff00000000ccccccccffff0000cccccccccccc0000cccccccc99990000cccccccc66 660000cccccccc33330000cccccccc00000000cccc9999ffff0000cccc9999cccc0000ccc c999999990000cccc999966660000cccc99 9933330000cccc999900000000cccc6666ffff0000cccc6666cccc0000cccc66669999000 0cccc666666660000cccc666633330000cccc666600000000cccc3333ffff0000cccc3333 cccc0000cccc333399990000cccc333366660000cccc333333330000cccc333300000000c ccc0000ffff0000cccc0000cccc0000cccc 000099990000cccc000066660000cccc000033330000cccc0000000000009999ffffffff0 0009999ffffcccc00009999ffff999900009999ffff666600009999ffff333300009999ff ff000000009999ccccffff00009999cccccccc00009999cccc999900009999cccc6666000 09999cccc333300009999cccc0000000099 999999ffff000099999999cccc00009999999999990000999999996666000099999999333 30000999999990000000099996666ffff000099996666cccc000099996666999900009999 6666666600009999666633330000999966660000000099993333ffff000099993333cccc0 00099993333999900009999333366660000 9999333333330000999933330000000099990000ffff000099990000cccc0000999900009 99900009999000066660000999900003333000099990000000000006666ffffffff000066 66ffffcccc00006666ffff999900006666ffff666600006666ffff333300006666ffff000 000006666ccccffff00006666cccccccc00 006666cccc999900006666cccc666600006666cccc333300006666cccc000000006666999 9ffff000066669999cccc0000666699999999000066669999666600006666999933330000 666699990000000066666666ffff000066666666cccc00006666666699990000666666666 66600006666666633330000666666660000 000066663333ffff000066663333cccc00006666333399990000666633336666000066663 33333330000666633330000000066660000ffff000066660000cccc000066660000999900 006666000066660000666600003333000066660000000000003333ffffffff00003333fff fcccc00003333ffff999900003333ffff66 6600003333ffff333300003333ffff000000003333ccccffff00003333cccccccc0000333 3cccc999900003333cccc666600003333cccc333300003333cccc0000000033339999ffff 000033339999cccc000033339999999900003333999966660000333399993333000033339 9990000000033336666ffff000033336666 cccc000033336666999900003333666666660000333366663333000033336666000000003 3333333ffff000033333333cccc0000333333339999000033333333666600003333333333 330000333333330000000033330000ffff000033330000cccc00003333000099990000333 30000666600003333000033330000333300 00000000000000ffffffff00000000ffffcccc00000000ffff999900000000ffff6666000 00000ffff333300000000ffff000000000000ccccffff00000000cccccccc00000000cccc 999900000000cccc666600000000cccc333300000000cccc0000000000009999ffff00000 0009999cccc000000009999999900000000 9999666600000000999933330000000099990000000000006666ffff000000006666cccc0 0000000666699990000000066666666000000006666333300000000666600000000000033 33ffff000000003333cccc000000003333999900000000333366660000000033333333000 0000033330000000000000000ffff000000 000000cccc0000000000009999000000000000666600000000000033330000eeee0000000 00000dddd000000000000bbbb000000000000aaaa00000000000088880000000000007777 0000000000005555000000000000444400000000000022220000000000001111000000000 0000000eeee000000000000dddd00000000 0000bbbb000000000000aaaa0000000000008888000000000000777700000000000055550 000000000004444000000000000222200000000000011110000000000000000eeee000000 000000dddd000000000000bbbb000000000000aaaa0000000000008888000000000000777 70000000000005555000000000000444400 0000000000222200000000000011110000eeeeeeeeeeee0000dddddddddddd0000bbbbbbb bbbbb0000aaaaaaaaaaaa0000888888888888000077777777777700005555555555550000 44444444444400002222222222220000111111111111000000000000000000700000008a0 16a00700000008a016a0000005303fff780 ff8100c30000fff600fdfffd00fcff070000ffff0000fffffe00fefffd00fdfffe0001fff ff60000fff300feff0100ffe900fdfffe0001fffffe0001ffffe90001ff00fefff40006ff 2af780ff0000002703fff780ff8100c30000ffc30000fff300feff0100ffc30001ff00fef ff40006ff2af780ff0000002703fff780ff 8100c30000ffc30000fff300feff0100ffc30001ff00fefff40006ff2af780ff000000270 3fff780ff8100c30000ffc30000fff300feff0100ffc30001ff00fefff40006ff2af780ff 0000002903fff780ff8100c20000ffc50000fff200feff020000ffc50002ff0000fefff40 006ff2af780ff0000002b03fff780ff8100 c20001ffffc70001fffff200fdff0200ffffc70002ffff00fdfff40006ff2af780ff00000 02103fff780ff8100c000c7ffef00fefffe00c7fffe00fefff30006ff2af780ff0000001b 03fff780ff81008100f400fcffc500fcfff30006ff2af780ff0000001703fff780ff81008 100f300bdfff20006ff2af780ff00000017 03fff780ff81008100f200bffff10006ff2af780ff0000001703fff780ff81008100f000c 3ffef0006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303ff f780ff81008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0 000001303fff780ff81008100a00006ff2a f780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff780ff8100810 0a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff0000001303fff7 80ff81008100a00006ff2af780ff0000001303fff780ff81008100a00006ff2af780ff000 0001303fff780ff81008100a00006ff2af7 80ff0000001102fff78081ff81ff9eff052af780ff0000001002fff780812a812a9d2a04f 780ff0000000d00ff81f781f79af70380ff0000000c00ff81808180998002ff0000000981 ff81ff97ff01000000a0008f00a10064000653504e5403e900a0008300ff}}{\f20 \par }\pard \qc\tx360 {\f20 \par \par }\pard \qc\tx360 Figure 2 - The NTK\rquote s Template Info dialog.\par \pard \qc\tx360 {\f20 \par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 What Declaring Really Does\par }\pard\plain \tx360 \f16 {\f20 Declaring a view does several things. First, it creates a slot in the parent view. The slot\rquote s name is the name of the declared view and the slot\rquote s value points to the new view. Because of this it\rquote s a bad idea to pick view names like _proto or viewClickScript. Deciding where to declare a view amounts to deciding where you want that view\rquote s slot to go. \par }\pard \tx360 {\f20 \tab Remember, NTK only d eals with templates. Views are declared. NTK sets up the templates with the correct information (like their names) needed for the declarations. The view system actually takes care of the work when the views are created. The details of this process are disc ussed in more detail later in this article. \par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Where to Declare a View\par }\pard\plain \tx360 \f16 {\f20 Consider the view hierarchy shown in Figure 3. If we declare view3 in view2, then scripts in view2, view3, and view4 have access to view3 (since the slot is in view2). View3 and view4 ge t access through parent inheritance (scripts in view3 could also use self}{\f22 )}{\f20 \endash view1 is left out in the cold. If we declare view3 to view1, instead, everyone has access. Alternately, if view2 is declared to view1 then view1 can access view3 using }{\f22 view2.view3}{\f20 .\par }\pard \tx360 {\f20 \par \par }\pard \qc\tx360 {\plain \i {\pict\macpict\picw181\pich133 00db00120014009700c91101a10064000c574f524400000000009700c901000a000000000 09700c93000120014009600c83000290021008900c0300049003200780071a10096000c01 00000001000000000000002c000a001607436f75726965720300160d000c2e00040000000 02b1d22057669657731a00097a10096000c 0100000001000000000000002b0e1a057669657732a00097a10096000c010000000100000 0000000002b1420057669657733a0009730004a0076007900b5a10096000c010000000100 0000000000002b4401057669657734a00097ff}}{\f20 \par }\pard \qc\tx360 {\f20 \par }\pard \qc\tx360 Figure 3 - An example view hierarchy.{\f20 \par }\pard \tx360 {\f20 \par \par }\pard \tx360 {\f20 \tab You should declare a view to a common ancestor of all the views that need access to it. You can simply declare everyone to your application\rquote s base view (everyone\rquote s ancestor), but you may not want to do that bec ause of potential name conflicts, efficiency considerations (to be discussed later), and most importantly, because it entirely eliminates the challenge of deciding where to declare a view.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Why is Declaring Necessary\par }\pard\plain \tx360 \f16 {\f20 On the surface, declare seems just like a convenient way to create a view slot containing self. Couldn\rquote t we achieve the same effect by simply having each view we want declared do something like: \par }\pard \tx360 {\f20 \par }{\f22 :Parent().myName := self;}{\f20 \par \par }\pard \tx360 {\f20 in its viewSetupDoneScript? In addition to allowing symbolic access to a view, declaring a view also ensures that it is preallocated (the view frame consisting of the _parent, _proto, and viewCObject is made ahead of time). This means that declare has some overhead associated with it\endash not a lot, but you should only declare the views that you need to access.\par }\pard \tx360 {\f20 \tab Note that invisible views are never created unless they are declared. This makes sense if you think about it\endash if they aren\rquote t declared there is nowhere to send the Open (or Show) message. The declare mechanism is necessary t o handle the case of initially invisible views like dialog boxes. If the declared view is initially visible then you can write code in its viewSetupDoneScript to achieve the desired effect. The decision is up to you. Most people find it easier to just to u se the declare mechanism.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Preallocation\par }\pard\plain \tx360 \f16 {\f20 It\rquote s important to understand the difference between preallocating and opening a view. A preallocated view has its _parent and _proto slots set up and its viewCObject slot set to nil. This actually uses very little R AM. When the view is opened, a more substantial object is allocated in RAM and viewCObject is set to reference it. You can check if a view is opened by checking if its viewCObject slot is non-nil.\par }\pard \tx360 {\f20 \tab When a preallocated context is initially created, its _parent slot is set to reference the view to which it\rquote s declared. This may or may not be its true parent (it may be a grandparent). When it\rquote s time to use the preallocated context to open the declared view, the _parent slot is changed to the true parent. Since this happens before the declared view\rquote s viewSetupFormScript is executed, you\rquote re normally unaware of all this. There is one case, however, where this can affect you. If the declared view is initially invisible it doesn\rquote t get opened automatically\endash you have to explicitly open it. Its _parent slot doesn\rquote t get updated automatically. This problem rarely occurs in practice. Most views are either declared to their parent or are initially visible.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Declare Implementation Details\par }\pard\plain \tx360 \f16 {\f20 In order to accomplish pre-allocation, declaring a view creates some extra slots in both the template being declared and the template to which the view is declared. In the template being declared, a preallocatedContext slot is created which contains the name you gave it in NTK. Before a view i s created from a template, the view system first checks for a preallocatedContext slot in the template. If the slot exists, then this view has been declared (and allocated)\endash this preallocated view is used instead of creating a new one. The symbol in the preallocatedContext slot is used to find the preallocated view\endash the parent chain is searched for a slot with this name. \par }\pard \tx360 {\f20 \tab A template with declared views has a slot for each declared view. These slots\rquote names are the names of the views being declared. They are initialized to nil. \par }\pard \tx360 {\f20 \tab A template with declared views also has a stepAllocateContext slot. This slot contains an array with two entries per declared view. The two entries are the declared view\rquote s name and a reference to the declared view\rquote s template. In system-defined templates and protos there is a similar allocateContext slot. The stepAllocateContext slot is for declared stepChildren, the allocateContext slot is for declared viewChildren.\par }\pard \tx360 {\f20 \tab The stepAllocateContext and allocateContext slots are used when a view is opened, in order to pre-allocate all the declared subviews. For each pair of entries in these arrays, there is a slot in the view. The slot\rquote s name (the subview\rquote s declared name) is the first element of the pair. The slot contains a preallocated view.\par }\pard \tx360 {\f20 \tab T o try and help you visualize all these details, consider the simple case of two views, view1 and view2, with view2 declared to view1. Figure 4a shows the visual hierarchy; Figure 4b shows some of the underlying data structures.These details are rarely of m uch practical use, but if you\rquote re crawling around in the Inspector and see these weird slots in your templates, you\rquote ll know they\rquote re part of the declare mechanism.\par }\pard \tx360 {\f20 \par \par }\pard \qc\tx360 {\plain \i {\pict\macpict\picw129\pich63 01820061004000a000c1001102ff0c00ffffffff004000000061000000c1000000a000000 000000000a0008200a10064000a53504e5403e80001000000a10064000e53504e540cd000 61004000a000c100a10064000a53504e540bb8000400020001000a0061004000a000c1003 00061004000a000c100a10064000a53504e 540bb8000400020030007a005d009400a400a10064000a53504e540bb80001000000a1006 4001a53504e540c26007b005e008f009100040002ffffffffffffffff00a10064000a5350 4e540c940000000000a10096000c050000000200000000000000002c000a001607436f757 269657200030016000d000c002e00040000 0000002b638905766965773200a0009700a10064000a53504e540bb80001000000a100640 01a53504e540c26006100460075007300040002ffffffffffffffff00a10064000a53504e 540c940000000000a10096000c0500000002000000000000000028006f004b05766965773 100a0009700a10064000653504e5403e900 a0008300ff}}{\f20 \par }\pard \tx360 {\f20 \par }\pard \qc\tx360 Figure 4a - A simple declaration.\par \par \par \pard \qc\tx360 {\plain \i {\pict\macpict\picw357\pich184 055c016f006e022701d3001102ff0c00ffffffff00690000016c000001d80000022900000 000000000a0008200a10064000a53504e5403e80001000000a10064000e53504e540cd001 6c0069022901d800a10064000a53504e540bb80001000000a10064001a53504e540c26016 c006901c800e300040002ffffffffffffff ff00a10064000a53504e540c940000000000a10096000c050000000200000000000000000 1000a016c0069022901d8002c000a001607436f757269657200030016000d000c002e0004 000000000028017a006e027b0d00002a0c0c205f706172656e743a20c90d002a0c09205f7 0726f746f3a0d00002a0c10207669657743 4f626a6563743a20c90d002a0c082076696577323a0d002a0c027d0d002a0c072f2f76696 577310000a0009700a10064000a53504e540bb80001000000a10064001a53504e540c2601 6c00f301c801d800040002ffffffffffffffff00a10064000a53504e540c940000000000a 10096000c05000000020000000000000000 28017a00f8027b0d00002a0c0b205f70726f746f3a20c90d00002a0c0c2076696577323a2 06e696c0d002a0c202073746570416c6c6f63617465436f6e746578743a205b7669657732 2c205d0d002a0c02c90d002a0c027d0d002a0c122f2f766965773127732074656d706c617 46500a0009700a10064002253504e540cee 000200100056000000260000005600000000000000000000000000f200a10064000a53504 e540bb80002000200a10064000e53504e540c9e018e00a9018e00f600a0008c0022018e00 a941000071001e018900ea019300f6018e00ea019300ea018e00f6018900ea018e00ea00a 0008d00a10064000853504e540cee000000 a10064000a53504e540bb80001000000a10064001a53504e540c2601d90069022900e3000 40002ffffffffffffffff00a10064000a53504e540c940000000000a10096000c05000000 0200000000000000002801e7006e027b0d00002a0c0a205f706172656e743a0d002a0c092 05f70726f746f3a0d00002a0c1020766965 77434f626a6563743a20c90d002a0c027d0d002a0c072f2f76696577320000a0009700a10 064000a53504e540bb80001000000a10064001a53504e540c2601d900f3022901c5000400 02ffffffffffffffff00a10064000a53504e540c940000000000a10096000c05000000020 0000000000000002801e700f8027b0d0000 2a0c0b205f70726f746f3a20c90d00002a0c1d20707265616c6c6f6361746564436f6e746 578743a2076696577322c0d00002a0c0320c90d00002a0c027d0d002a0c122f2f76696577 3227732074656d706c61746500a0009700a10064002253504e540cee00020010005600000 02600000056000000000000000000000000 00ec00a10064000a53504e540bb80002000200a10064000e53504e540c9e01f000af01bc0 0af00a0008c002201f000af00d80071001e01bc00aa01c800b401c800af01c800b401bc00 af01c800aa01c800af00a0008d00a10064000a53504e540bb80002000200a10064000e535 04e540c9e01fb00a901fb00f600a0008c00 2201fb00a941000071001e01f600ea020000f601fb00ea020000ea01fb00f601f600ea01f b00ea00a0008d00a10064000a53504e540bb80002000200a10064000e53504e540c9e01a7 00a101dd00a100a0008c002201a700a1002a0071001e01d1009c01dd00a601d100a101d10 09c01dd00a101d100a601d100a100a0008d 00a10064000a53504e540bb80003000200a10064000e53504e540c9e019a01c701dd01840 0a0008c0022019a01c7c63a0071001e01d0018401dd019101d4018d01d0018901dd018401 d8019101d4018d00a0008d00a10064000653504e5403e900a0008300ff}}{\f20 \par }\pard \qc\tx360 {\f20 \par \par }\pard \qc\tx360 Figure 4b - The data structures underlying Figure 4a.\par \pard \qc\tx360 {\f20 \par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 View Opening and Closing\par }\pard\plain \tx360 \f16 {\f20 When a view is opened, all of its declared subviews are preallocated. When a view is closed, all those slots containing the preallocated views are set to nil. Declare keeps pre-allocation exactly one step ahead of you. At any point in time, all the open vi ews have their declared children preallocated, ready to be opened. Closed views can\rquote t do anything anyway, so setting their pre-allocation slots to nil allows garbage collection.\par }\pard \tx360 {\f20 \tab When a view is closed, the slots containing the preallocated contexts are set to nil instead of being deleted. For your application\rquote s base view, this has an interesting implication. The first time your base view is opened, a slot for each declared view is created. When your base view is closed, those slots are not deleted. If you\rquote re looking for memory leaks by comparing free memory before you open and after you close your application, you\rquote ll see a slight discrepancy the first time you open and close it due to these new slots. This shouldn\rquote t be a probl em on subsequent opens and closes.\par }\pard \tx360 {\f20 \tab Pre-allocation happens early in the view opening process, before the viewSetupFormScript is called. When it comes time to instantiate subviews, if the subview has a preallocated context, that preallocated context is used, otherwise a new one is created. B ecause pre-allocation occurs so early in the view instantiation process, there is a subtle bug that can arise in your program. If you declare a view (let\rquote s call it X), and send it an Open message in your viewSetupFormScri pt, it already has its visible flag set\endash two viewCObjects get created. One is created when you send the open message in your viewSetupFormScript; the other as a result of the normal view instantiation process. The symptom you see in your program is that you close X and it\rquote s still there. You can even look at X in the Listener and see that its viewCObject is nil, but there is an extra viewCObject floating around, still being drawn. Unfortunately, the view system doesn\rquote t check for this anomaly during view insta ntiation and handle it more gracefully.\par }\pard \tx360 {\f20 \tab There are two pieces of advice that you should follow which avoid this problem entirely. First, if a view can be opened naturally, let it be opened. Don\rquote t explicitly call Open. Second, don\rquote t send Open messages, or any other messages, to your children until your viewSetup-DoneScript executes. Your children are not created until your viewSetupDoneScript executes.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Declaring Your Base View\par }\pard\plain \tx360 \f16 {\f20 Conceptually, your base view is declared to the root view automatically after your package is downloaded and your InstallScript runs. It\rquote s name is your AppSymbol. That\rquote s why }{\f22 GetRoot().AppSymbol}{\f20 returns your base view. In NTK, you set your application\rquote s AppSymbol in the Settings\'c9 dialog.\par }\pard \tx360 {\f20 \tab The preceding comment is qualified with \ldblquote conceptually\rdblquote because your base view isn\rquote t installed in the root view by the declare mechanism I\rquote ve already described. The end result is the same\endash your base view is preallocated in the root view\endash but the process isn\rquote t the same (you\rquote ll note your base view\rquote s template doesn\rquote t have a preallocatedContext slot).\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Declaring Linked Subviews\par }\pard\plain \tx360 \f16 {\f20 The linked subviews feature of NTK adds a twist to declaring views. The best way to think of a linked subview is as a place holder and a linked-layout. You drag the place holder (the LinkedSubview icon from the proto palette) to the parent you want your vi ew to actually have. Then you use the Link Layout\'c9 command to link it to a layout. The place holder is just that, a place holder. The linked layout is substituted for the place holder wh en your project is compiled. All traces of the place holder are lost, except\'c9\par \tab If you want to declare a linked subview, you should name and declare just the place holder. You do not need to name or declare the linked-layout. In fact, you are unable to declare the linked-layout because its Allow Access popup menu is empty \endash it appears to have no parents. You may want to name the linked-layout so that its children can be declared to it. There is no need to give it the same name you gave the link, but it\rquote s a good idea. Figure 5 illustrates these points.\par }\pard \tx360 {\f20 \par \par }\pard \qc\tx360 {\plain \i {\pict\macpict\picw261\pich147 03e200d0009c016301a1001102ff0c00ffffffff009c000000d0000001a10000016300000 000000000a0008200a10064000a53504e5403e80001000000a10064000e53504e540cd000 d0009c016301a100a10064000a53504e540bb8000400020001000a00d0009c016301a1003 000d0009c0163010c00a10064000a53504e 540bb8000400020030010d00a4013d010200a10064000a53504e540bb800040002003000d 2012b015201a100a10064000a53504e540bb8000400020030010601400121017a00a10064 000a53504e540bb8000400020030013001490148018300a10064000a53504e540bb800010 00000a10064001a53504e540c26010d00a2 0139010700040002ffffffffffffffff00a10064000a53504e540c940000000000a100960 00c050000000200000000000000002c000a001607436f757269657200030016000d000c00 2e0004000000000028011b00a7010d002a0c0472656e0d002a0c0d28706c616365686f6c6 46572290000a0009700a10064000a53504e 540bb80001000000a10064001a53504e540c2601090143011d017700050002fffffffffff fffff00a10064000a53504e540c940000000000a10096000c050000000200000000000000 0001000a00d0009c011901a1002801170148066368696c64310000a0009700a10064000a5 3504e540bb80001000000a10064001a5350 4e540c260131014a0145017e00050002ffffffffffffffff00a10064000a53504e540c940 000000000a10096000c0500000002000000000000000001000a00d0009c014101a1002b07 28066368696c64320000a0009700a10064000a53504e540bb80001000000a10064001a535 04e540c2600d5012d010101a000040002ff ffffffffffffff00a10064000a53504e540c940000000000a10096000c050000000200000 0000000000001000a00d0009c016301a1002800e30132077374696d70790d002a0c10286c 696e6b65642d6c61796f7574290d00a0009700a10064000a53504e540bb80001000000a10 064001a53504e540c2600d400a000e800e2 00050002ffffffffffffffff00a10064000a53504e540c940000000000a10096000c05000 00002000000000000000001000a00d0009c00e401a1002800e200a5086261736556696577 0000a0009700a10064002253504e540cee000200100056000000260000005600000000000 0000000000000000000a10064000a53504e 540bb80003000200a10064000e53504e540c9e0114013f0122010000a0008c0001000a00d 0009c016301a100220114013fcd0b0071001e011a01000125010d011f010c011a010b0122 01000125010d011f010c00a0008d00a10064000653504e5403e900a0008300ff}}{\f20 \par }\pard \qc\tx360 {\f20 \par \par }\pard \qc\tx360 {\f20\fs20 \par }\pard \qc Figure 5 - A place holder and linked-layout relationship.\par \pard \qc\tx360 {\f20 \par }\pard \tx360 {\f20 \par }\pard \tx360 {\f20 \tab Declare ren to baseView and declare child1 and child2 to stimpy. You are unable to declare stimpy to anyone because it appears to have no parents. This is not a problem\endash you really want to declare ren anyway. When you declare child1 and child2, the only place to declare them is stimpy; baseView is not in the popup because stimpy appears to have no parents. This is a limitation of using linked views. If baseView needs to access these children you can use code references like }{\f22 ren.child1}{\f20 .\par }\pard \tx360 {\f20 \tab Note that the names chosen for the place holder and the linked-layout (ren and stimpy) are not the same, but they could be. The symbol stimpy is not available at runtime. If child1 or child2 need to refer to their parent, they should use ren. This illustr ates why it\rquote s a good idea to name your place holder and linked layout identically\endash the code is clearer. It\rquote s kind of strange for child1 and child2 to refer to their pa rent as ren, a symbol defined outside the linked-layout in which they\rquote re defined.\par }\pard \tx360 {\f20 \par }\pard\plain \s3\keep\tx360 \b\f20\fs20 {\plain \b\f20 Dynamically Adding Views\par }\pard\plain \tx360 \f16 {\f20 Adding views dynamically actually turns out to be a complex issue. I describe several techniques in the following sections. You need to pick the one most appropriate to your situation.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Don\rquote t Create Views Dynamically\par }\pard\plain \tx360 \f16 {\f20 The canonical case is a dialog box. You should create the dialog ahead of time (probably using the linked view feature of NTK) and declare it to your base view. Then at runtime open and c lose it as you please.This is the preferred method\endash it\rquote s by far the simplest and least error prone.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Don\rquote t Create Views Dynamically\endash Yourself\par }\pard\plain \tx360 \f16 {\f20 Perhaps you need to create a group of subviews, but you don\rquote t know the exact number until runtime. For example, your application may need to compute the number of subviews based on screen size (to maintain compatibility with future products). The best way to accomplish this is to compute your stepChildren array in your viewSetupChildrenScript. Just put in the templates you want and the view system handles creating the actual views.\par }\pard \tx360 {\f20 \tab If you\rquote re going to adjust the size of your stepChildren array using AddArraySlot it had better be in RAM. You might need to do:\par }\pard \tx360 {\f20 \par }\pard\plain \s5\keep\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800 \tx1980\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 \f22\fs20 {\plain \f22 if not HasSlot(self, \lquote stepChildren) then\line \tab self.stepChildren := Clone(self.stepChildren)\par }\pard \s5\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800\tx19 80\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 {\plain \f22 \par }\pard\plain \tx360 \f16 {\f20 HasSlot is used to test if the viewChildren slot already exists in RAM in the view itself. If the viewChildren already exist, you don\rquote t need to do anything. Using }{\f22 self.stepchildren}{\f20 in the condition instead of HasSlot doesn\rquote t work because the _proto chain is followed into ROM. All the explicit selfs are needed lest you accidentally get the stepChildren slot of your parent.\par }\pard \tx360 {\f20 \tab If you want to modify the contents of the stepChildren array after your view is created, and create new views, use the RedoChildren method. First make the changes you want to the stepChildren array, then send your view a RedoChildren method. All of the vi ew\rquote s current children are closed and removed, the viewSetupChildrenScript is called, and then a new set of chi ldren is created from the stepChildren array. Note that reordering stepChildren and then calling RedoChildren is a way to re-order your child views dynamically.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 If You Insist, There\rquote s AddStepView\par }\pard\plain \tx360 \f16 {\f20 If you really want to create a template at runtime and then make a view from it, use the global function AddStepView. It takes two arguments: the parent view you want your view added to and the template to use in making the view. It returns the view that i s created. Be sure to save this return value so you can access the view later.\par }\pard \tx360 {\f20 \tab AddStepView doesn\rquote t force a redraw. You need to either:\par \par }\pard\plain \s6\fi-180\li360\keep\tx360 \f20\fs20 {\plain \f20 \bullet \tab Send the new view a Dirty message; \par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab Send the view\rquote s parent a Dirty message. This is useful if you\rquote re adding multiple views\endash one Dirty and they all show up at once (if you\rquote re adding several views, you should also consider using the RedoChildren technique); or\par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab If the template has the visible bit cleared, just send the new view a Show message. This is useful if you want the view to appear with some sort of special effect.\par }\pard\plain \li180\tx360 \f16 {\f20 \par }\pard \tx360 {\f20 In ad dition to creating the view, AddStepView also adds its template to the stepChildren array. This means that the stepChildren array needs to be in RAM so it can be expanded or AddStepView will fail. See the previous comments on ensuring your stepChildren arr ay is in RAM. Do not use AddStepView in your viewSetupFormScript or your viewSetupChildrenScript\endash it doesn\rquote t work. Instead, append your template to the stepChildren array and let the view system do the rest of the work. There is another function, AddView, w hich works like AddStepView, except it adds the template to the viewChildren array. You should use AddStepView, since the viewChildren slot is reserved for system use.\par }\pard \tx360 {\f20 \tab There is also a pair of functions, RemoveStepView and RemoveView, that are designed to undo the effect of AddStepView and AddView. These functions take one argument, the view (not the template), and remove that view. Unfortunately, they do not remove the corresponding template from the stepChildren or viewChildren slot. You have to do this y ourself. If you do not take care of this, your stepChildren slot builds up all these old templates which waste RAM and which may surprise you if something forces a RedoChildren (all the \ldblquote removed\rdblquote views\rquote ghosts suddenly come back to life).\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 BuildContext\par }\pard\plain \tx360 \f16 {\f20 Another function that is occasionally useful is BuildContext. It takes one argument, a template. It makes a view and returns it. The view\rquote s parent is the root view. The template is not added to any viewChildren or stepChildren array. Basically, you get a free-agent view.\par \tab Normally, you shouldn\rquote t need BuildContext. It\rquote s useful when you need to create a view from code that isn\rquote t part of an application (when there\rquote s no base view to use as a parent). For instance, if your InstallScript or RemoveScript needs to prompt the user with a dialog, you need to use BuildContext to create the dialog.\par }\pard \tx360 {\f20 \par }\pard\plain \s4\keep\tx360 \i\f20\fs20 {\plain \i\f20 Creating Templates\par }\pard\plain \tx360 \f16 {\f20 All but the first of the techniques presented require you to create templates. You can do this using NewtonScript to define a frame. You have to remember whe ther the oneLineOnly bit gets set in the viewFlags slot or in the viewJustify slot. It\rquote s easy to mess up.\par }\pard \tx360 {\f20 \tab I recommend creating a user proto in NTK and then using it as a template. That allows you to take advantage of NTK\rquote s slot editors. At runtime you can access the user proto as PT_. If there are slots whose value you can\rquote t compute ahead of time, le ave them out of the user proto, and at runtime create a frame with those slots set properly and proto off the user proto. \par }\pard \tx360 {\f20 \tab A typical example might be computing the bounds on the fly. If you define all the static slots in a user proto in a file called dynoTemplate, you can create the template you need using code like:\par }\pard \tx360 {\f20 \par }\pard\plain \s5\keep\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800 \tx1980\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 \f22\fs20 {\plain \f22 template := \{ viewBounds: RelBounds (\par }\pard \s5\keep\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800 \tx1980\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 {\plain \f22 \tab \tab \tab \tab \tab \tab \tab \tab x, y, wid, hgt),\line _proto: PT_dynoTemplate \} \par }\pard \s5\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800\tx19 80\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 {\plain \f22 \par }\pard\plain \tx360 \f16 {\f20 This really shows off the advantage of a prototype-based object system. You create a small object on the fly and use inheritance to get the rest of the values you need. Your template is only a two slot view in RAM. The user proto sits on the card with the rest of your application. The conventional RAM-wasting alternative is :\par }\pard \tx360 {\f20 \par }\pard\plain \s5\keep\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800 \tx1980\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 \f22\fs20 {\plain \f22 template := Clone (PT_dynoTemplate);\line template.viewBounds := RelBounds (x, y, wid, hgt);\par }\pard \s5\tx225\tx360\tx540\tx720\tx900\tx1080\tx1260\tx1440\tx1620\tx1800\tx19 80\tx2160\tx2340\tx2520\tx2700\tx2880\tx3060\tx3240 {\plain \f22 \par }\pard\plain \tx360 \f16 {\f20 You should also note that for creating views arranged in a table, there is a function called LayoutTable which calculates all the bounds. It returns an array of templates. See the }{\i\f20 Newton Programmer\rquote s Guide}{ \f20 for details.\par }\pard \tx360 {\f20 \par }\pard\plain \s3\keep\tx360 \b\f20\fs20 {\plain \b\f20 Summary of Dynamic View Advice\par }\pard\plain \s4\tx360 \i\f20\fs20 {\plain \i\f20 \par }\pard\plain \s6\fi-180\li360\keep\tx360 \f20\fs20 {\plain \f20 \bullet \tab Avoid adding views dynamically; use declare and invisible views instead. Barring that, add your templates to the stepChildren array in your viewSetUpChildrenScript.\par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab Do not send messages to or set slots in templates. This is most commonly done in code that uses the stepChildren array instead of :ChildViewFrames(). It also happens when people use the template passed to AddStepView instead of the view it returns.\par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab The stepChildren array must be in RAM before you can modify it. Remember, \ldblquote never try to write to ROM\endash it wastes your time and annoys the ROM.\rdblquote \par }\pard \s6\fi-180\li360\keep\tx360 {\plain \f20 \bullet \tab Do not anger AddView.\par \bullet \tab Use NTK to define as much of your template as possible.\par }\pard \s6\fi-180\li360\tx360 {\plain \f20 \par }\pard\plain \sl240\tx360 \f16 {\b\i\f23 p\par \par }\pard \qc\sl240\tx360 {{\pict\macpict\picw469\pich186 0be00000000d00ba01e2001102ff0c00ffffffff000000000000000001e2000000ba00000 0000000001e0001000a0000000000ba01e2002c000800140554696d657300030014000d00 0c002e00040000ff00001000ba01e200ba01e20028000a017a0874656d706c61746500001 5d080002936047669657700220000000d00 000023000000220000000e190000320001002800010029002200000028000000200000002 900000174002200000175000000220000017634000022000001ab00000022000001ac3400 0022000001e100000023000000220001000d000b003200010028000d00290022000101750 00b0022000101ab000b0022000101e1000b 0028001700120231290000157e4000291b0e63726561746564206279204e544b0015c8000 0280017017a01580022000d000d00000022000d000e19000032000e0028000e0029002200 0d002800000020000d0029000d01740022000d017500000022000d017634000022000d01a b00000022000d01ac34000022000d01e100 000022000e000d000b0032000e0028001a00290022000e0175000b0022000e01ab000b002 2000e01e1000b0028002400120232290000157e4000291b126f6e6c792072657369646520 696e2052414d001524400028002401b001580022001a000d00000022001a000e190000320 01b0028001b00290022001a002800000020 001a0029001a01740022001a017500000022001a017634000022001a01ab00000022001a0 1ac34000022001a01e100000022001b000d000b0032001b0028002700290022001b017500 0b0022001b01ab000b0022001b01e1000b00280031001202332900000a000000000000000 000340034000d0035002800157e40002b1b 010768616e646c6573002c000a001607436f75726965720003001600152580002925073a4 86964652829000003001400152580002931022c200003001600152580002906153a4f7065 6e28292c20616e64203a436c6f7365282900000300140015258000299309206d657373616 7657300003400340175003501ab001575c0 0028003101b001580034003401ab003501e100220027000d000000220027000e190000320 0280028002800290022002700280000002000270029002701740022002701750000002200 27017634000022002701ab00000022002701ac34000022002701e1000000220028000d000 c0032002800280035002900220028017500 0c0022002801ab000c0022002801e1000c0028003f00120234290000157e4000291b2e726 57369646520696e20737465704368696c6472656e20616e6420766965774368696c647265 6e206172726179730015bd000028003f017a015800220035000d000000220035000e19000 03200360028003600290022003500280000 00200035002900350174002200350175000000220035017634000022003501ab000000220 03501ac34000022003501e1000000220036000d000b003200360028004200290022003601 75000b0022003601ab000b0022003601e1000b0028004c0012023529000034004f000d005 0002800157e40002b1b0139636f6465206d 6f64696669657320746865697220736c6f74732061742072756e74696d65202d207072656 6657261626c792c207573696e672000030016001564000028004d01350853657456616c75 65000034004f0175005001ab00030014001564000028004c01b001580034004f01ab00500 1e100220042000d000000220042000e1900 0032004300280043002900220042002800000020004200290042017400220042017500000 0220042017634000022004201ab00000022004201ac34000022004201e100000022004300 0d000c00320043002800500029002200430175000c0022004301ab000c0022004301e1000 c0028005a00120236290000157e4000291b 267573652073797374656d2070726f746f7320696e2074686569722070726f746f20736c6 f7473001575800028005a017a015800220050000d000000220050000e1900003200510028 0051002900220050002800000020005000290050017400220050017500000022005001763 4000022005001ab00000022005001ac3400 0022005001e1000000220051000d000b003200510028005d0029002200510175000b00220 05101ab000b0022005101e1000b0028006700120237290000157e4000291b157061737365 6420746f204164645374657056696577000015cb4000280067017a01580022005d000d000 00022005d000e19000032005e0028005e00 290022005d002800000020005d0029005d01740022005d017500000022005d01763400002 2005d01ab00000022005d01ac34000022005d01e100000022005e000d000b0032005e0028 006a00290022005e0175000b0022005e01ab000b0022005e01e1000b00280074001202382 90000157e4000291b38757375616c6c7920 636f6e7461696e732066657720736c6f74732028696e6865726974732c206d6f7374206f6 62069747320736c6f7473290015c4000028007401b001580022006a000d00000022006a00 0e19000032006b0028006b00290022006a002800000020006a0029006a01740022006a017 500000022006a017634000022006a01ab00 000022006a01ac34000022006a01e100000022006b000d000b0032006b002800770029002 2006b0175000b0022006b01ab000b0022006b01e1000b0028008100120239290000157e40 00291b15757375616c6c792072657369646520696e20524f4d000015780000280081017a0 15800220077000d000000220077000e1900 0032007800280078002900220077002800000020007700290077017400220077017500000 0220077017634000022007701ab00000022007701ac34000022007701e100000022007800 0d000b00320078002800840029002200780175000b0022007801ab000b0022007801e1000 b0028008e00120331302900340091000d00 92002800157e40002b1b010c72657475726e65642062792000000300160015774000293a1 23a4368696c64566965774672616d65732829003400910175009201ab0003001400157740 0028008e01b001580034009101ab009201e100220084000d000000220084000e190000320 08500280085002900220084002800000020 0084002900840174002200840175000000220084017634000022008401ab0000002200840 1ac34000022008401e1000000220085000d000c0032008500280092002900220085017500 0c0022008501ab000c0022008501e1000c0028009c00120331312900157e4000291b13726 57475726e65642062792044656275672829 00001571000028009c01b0015800220092000d000000220092000e1900003200930028009 3002900220092002800000020009200290092017400220092017500000022009201763400 0022009201ab00000022009201ac34000022009201e1000000220093000d000b003200930 028009f0029002200930175000b00220093 01ab000b0022009301e1000b002800a900120331322900157e4000291b0a6973206120667 2616d650015cb00002800a9017a0158001574c00029360158000022009f000d0000002200 9f000e1900003200a0002800a000290022009f002800000020009f0029009f01740022009 f017500000022009f017634000022009f01 ab00000022009f01ac34000022009f01e10000002200a0000d000b003200a0002800ac002 9002200a00175000b002200a001ab000b002200a001e1000b002800b60012033133290015 7e4000291b0c686173206120706172656e740015cac0002800b601b00158002200ac000d0 000002200ac000e1900003200ad002800ad 0029002200ac00280000002000ac002900ac0174002200ac01750000002200ac017634000 02200ac01ab0000002200ac01ac3400002200ac01e10000002200ad000d000b003200ba00 0d00ba000e002200b9000d000000230000002200b9000e1900003200ad002800b90029003 200ba002800ba0029002200b90028000000 2000b9002900b90174002200ad0175000b003200ba017500ba0176002200b901750000002 200b901763400002200ad01ab000b003200ba01ab00ba01ac002200b901ab0000002200b9 01ac3400002200ad01e1000b003200ba01e100ba01e2002200b901e100000023000000320 0b901e200ba01eb00ff}}{\f20 \par }\pard \qc\sl240\tx360 {\f20 \par \par }\pard \qc\sl240\tx360 Table 2 - The template vs. view quiz answers.{\f20 \par }}