// ---- End Project Data ---- // ---- File Buttons.t ---- // Before Script for "baseView" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. baseView := {title: "Buttons", viewBounds: {top: 0, left: 0, right: 240, bottom: 336}, viewSetupFormScript: func() begin // resize to fit on all "small" newtons. local b := GetAppParams(); constant kMaxWidth := 240; constant kMaxHeight := 336; self.viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop, MIN(b.appAreaWidth, kMaxWidth), MIN(b.appAreaHeight, kMaxHeight)); end, _proto: protoApp, debug: "baseView" }; // Before Script for "label1" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. label1 := /* child of baseView */ {text: "Example of a popup text button:", viewBounds: {left: 9, top: 17, right: 193, bottom: 41}, viewJustify: 0, viewFont: simpleFont9, _proto: protoStaticText, debug: "label1" }; // View label1 is declared to baseView // ---- File protoAdjustoButton ---- // Before Script for "_userproto000" // Copyright, © 1994 Apple Computer. All rights reserved. _userproto000 := {buttonHeight: 13, textSpacer: 8, viewSetupFormScript: func() begin viewBounds := RelBounds(viewBounds.left, viewBounds.top, StrFontWidth(text, viewFont) + textSpacer, buttonHeight) ; end, viewChangedScript: func(slot, view) begin inherited:?viewChangedScript(slot, view) ; if slot = 'text then :SyncView(); // SyncView causes the viewSetupFormScript to be called again, // which sets the size based on the text. end, _proto: protoTextButton }; // ---- Back in File Buttons.t ---- // Before Script for "PopupButton" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. PopupButton := /* child of baseView */ {text: "PopUp", viewBounds: {left: 75, top: 35, right: 147, bottom: 51}, popupList: ["No", "No Way", "Never", "OK,Just Once"], pickActionScript: func(index) // note you need to implement pickActionScript if you have a popupList begin // MUST unhilite the button :Hilite(nil); // do application specific stuff Print("Selected index no " & index); end, pickCancelledScript: func() begin // MUST unhilite the button :Hilite(nil) ; // do app specific stuff if any Print("Popup cancelled"); end, viewClickScript: func(unit) begin // need to override the viewCLickScript of protoTextButton // to get the correct hilite behavior for a popup if :TrackHilite(unit) then begin local l := :LocalBox(); // according to the UI specs, the popup should share a border // with the button, in this case, it is the right border DoPopUp(popupList, l.right+3, l.top, self); end; // IMPORTANT: if TrackHilite succeds, the button will // remain hilited until unhilited. This is done in BOTH // the pickActionScript AND the pickCancelledScript end, _proto: _userproto000, debug: "PopupButton" }; // View PopupButton is declared to baseView // After Script for "PopupButton" thisView := PopupButton; // need to add the pop character to the button title thisView.text := kPopChar && thisView.text ; // Before Script for "label2" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. label2 := /* child of baseView */ {text: "Example of a movable palette of buttons:", viewBounds: {left: 9, top: 74, right: 193, bottom: 106}, viewJustify: 0, viewFont: simpleFont9, _proto: protoStaticText, debug: "label2" }; // Before Script for "label3" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. label3 := /* child of baseView */ {text: "Example of buttons that show states using drawing:", viewBounds: {left: 9, top: 168, right: 196, bottom: 196}, viewJustify: 0, viewFont: simpleFont9, _proto: protoStaticText, debug: "label3" }; // Before Script for "statusButton" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. statusButton := /* child of baseView */ {viewFlags: 513, viewFormat: 83887089, viewBounds: {left: 28, top: 103, right: 202, bottom: 145}, viewClickScript: func(unit) begin :Drag(unit, nil); // move the button palette true; end, viewclass: 74, debug: "statusButton" }; // Before Script for "butt1" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. butt1 := /* child of statusButton */ {text: "First", viewBounds: {left: 18, top: 18, right: 58, bottom: 34}, buttonClickScript: func() begin Print("Button 1 clicked -- buttonPalette"); end, _proto: _userproto000, debug: "butt1" }; // View butt1 is declared to statusButton // ---- File protoAdjustoClusterButton ---- _userproto001 := {viewBounds: {left: 8, top: 2, right: 0, bottom: 0}, viewJustify: 8389638, viewChangedScript: func(slot, view) begin inherited:?viewChangedScript(slot, view) ; if slot = 'text then begin :Parent():SyncChildren(); :Parent():Dirty(); end end, _proto: _userproto000 }; // ---- Back in File Buttons.t ---- // Before Script for "butt2" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. butt2 := /* child of statusButton */ {text: "Second", buttonClickScript: func() begin Print("Button 2 clicked -- buttonPalette"); end, viewBounds: {left: 8, top: 18, right: 0, bottom: 0}, _proto: _userproto001, debug: "butt2" }; // View butt2 is declared to statusButton // Before Script for "butt3" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. butt3 := /* child of statusButton */ {text: "Third", buttonClickScript: func() begin Print("Button 3 clicked -- buttonPalette"); end, viewBounds: {left: 8, top: 18, right: 0, bottom: 0}, _proto: _userproto001, debug: "butt3" }; // View butt3 is declared to statusButton // Before Script for "_view000" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. _view000 := /* child of statusButton */ {text: "Move me around!", viewBounds: {left: 7, top: 2, right: 97, bottom: 11}, _proto: protoStaticText }; // Before Script for "StateButton" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. StateButton := /* child of baseView */ {text: "Status", viewBounds: {left: 75, top: 200, right: 142, bottom: 223}, viewJustify: 5, theState: 'closed, viewSetupFormScript: func() begin // create the triangle object closedTShape := MakePolygon('[5,5,10,10,5,15,5,5]); openTShape := MakePolygon('[0,10,10,10,5,15,0,10]); end, OpenTShape: nil, ClosedTShape: nil, viewDrawScript: // draw a notification inside the button func() begin if (theState = 'closed) then :DrawShape(ClosedTShape, nil); if (theState = 'open) then :DrawShape(OpenTShape, nil); end, buttonClickScript: func() begin // switch between two states if theState = 'closed then theState := 'open; else theState := 'closed; :Dirty(); // force a dirty after this end, viewFormat: 67306065, _proto: protoTextButton, debug: "StateButton" }; // Before Script for "label4" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. label4 := /* child of baseView */ { text: "Example of Button that looks like the protoShowBar (used for filing):", viewBounds: {left: 9, top: 249, right: 193, bottom: 281}, viewJustify: 0, viewFont: simpleFont9, _proto: protoStaticText, debug: "label4" }; // Before Script for "showBarButton" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. showBarButton := /* child of baseView */ {text: "Button", buttonClickScript: // When clicked, call DoPopUp and send over the array of labels. func() begin // Note that we are creating the frame array in RAM, why? Well, // if the frame was pre-defined in the slot, it would be a ROM-readonly // entity, and we would be unable to change the items on the flight -- // unless you cloned the whole frame and started to add more array entries // to this cloned RAM object. Anyway, you are able to do both, I just showed // the dynamic way of doing this, and I'm sure there are more designed ways // to add entries to the popup frame. pop := SetLength([], 6); // preallocate an array // Create the frame. // Only one should have the mark, decide this here as well pop[0] := { item: "Unfiled", mark: $ }; IF currentSelection = 0 THEN pop[0].mark := $\u221A; pop[1] := { item: "Business", mark: $ }; IF currentSelection = 1 THEN pop[1].mark := $\u221A; pop[2] := { item: "Private", mark: $ }; IF currentSelection = 2 THEN pop[2].mark := $\u221A; pop[3] := { item: "Important", mark: $ }; IF currentSelection = 3 THEN pop[3].mark := $\u221A; pop[4] := 'pickSeparator; pop[5] := { item: "Everything", mark: $ }; IF currentSelection = 5 THEN pop[5].mark := $\u221A; DoPopUp(pop, 0, 2, self); // Another thing to remember with dynamic popups is that if you don't // know the length and width of the strings, you have to precalculate // this information using StrFontWidth and maybe truncate using StrTruncate. end, viewBounds: {left: 74, top: 290, right: 145, bottom: 301}, pickActionScript: // Update the label text in the button with the newly defined // value. func(index) begin // Get access to the newly selected value, and store it currentSelection := index; // Create new text and set it SetValue(self, 'text, $\uFC01 && pop[currentSelection].item); end, currentSelection: nil, viewSetupFormScript: func() begin currentSelection := 0; // default label // In real life we would maybe get a default label and stuff it // in here based on the currentSelection, or then do as I did below, // create an undefined label, forcing the end user to select a // label. Maybe a default label is a more user friendly thing to // do... text := $\uFC01 && "Undefined"; end, viewFormat: 337, pop: nil, _proto: protoTextButton, debug: "showBarButton" }; // Before Script for "line1" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. line1 := /* child of baseView */ {viewBounds: {left: 1, top: 68, right: 244, bottom: 70}, _proto: protoBorder, debug: "line1" }; // Before Script for "line2" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. line2 := /* child of baseView */ {viewBounds: {left: 1, top: 161, right: 244, bottom: 163}, _proto: protoBorder, debug: "line2" }; // Before Script for "line3" // Copyright © 1993, 1994 by Apple Computer, Inc. All rights reserved. line3 := /* child of baseView */ {viewBounds: {left: -6, top: 241, right: 237, bottom: 243}, _proto: protoBorder, debug: "line3" }; // ---- Beginning of section for non used Layout files ---- // End of output