home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Newton Platform Info / Newton 2.0 Sample Code / System Data & Built In Apps / PeoplePicker-1 / PeoplePicker.text < prev    next >
Encoding:
Text File  |  1995-11-25  |  5.8 KB  |  218 lines  |  [TEXT/MPS ]

  1. // Text of project PeoplePicker written on 11/25/95 at 5:03 PM
  2. // Beginning of text file projectData
  3. /*
  4. **      Newton Developer Technical Support Sample Code
  5. **        
  6. **      PeoplePicker,  Demostrates the basic People picker.
  7. **
  8. **      by Stephen Harris, Newton Developer Technical Support
  9. **
  10. **      Copyright © 1993-1995 by Apple Computer, Inc.  All rights reserved.
  11. **
  12. **      You may incorporate this sample code into your applications without
  13. **      restriction.  This sample code has been provided "AS IS" and the
  14. **      responsibility for its operation is 100% yours.  You are not
  15. **      permitted to modify and redistribute the source as "DTS Sample Code."
  16. **      If you are going to re-distribute the source, we require that you
  17. **      make it clear in the source that the code was descended from
  18. **      Apple-provided sample code, but that you've made changes.
  19. */
  20.  
  21. /*This PeoplePicker demonstrates the basic peoplePicker.
  22. */
  23.  
  24.  
  25. constant kAppTitle:= "The People Picker";
  26.  
  27.  
  28. // constants for the type of people picker
  29.  
  30. constant kTypePickerArray := '[
  31.     {item: "People", dataClass: |NameRef.People|},
  32.     {item: "Phone numbers", dataClass: |NameRef.Phone|},
  33.     {item: "Fax numbers", dataClass: |NameRef.Fax|},
  34.     {item: "Email addresses", dataClass: |NameRef.email|},
  35.     {item: "Meeting places", dataClass: |NameRef.meetingPlace|},
  36. ] ;
  37.  
  38. // End of text file projectData
  39. // Beginning of file peoplePicker.t
  40.  
  41. // Before Script for "appBase"
  42. // ©1993-1995 Apple Computer, Inc.  All rights reserved.
  43.  
  44.  
  45. appBase :=
  46.     {viewBounds: {left: 0, top: 0, right: 240, bottom: 336},
  47.      viewFlags: 1,
  48.      viewFormat: 0,
  49.      declareSelf: 'base,
  50.      title: kAppTitle,
  51.      viewSetupFormScript:
  52.        func()
  53.        begin
  54.            // set up the display
  55.            local b:= GetAppParams();
  56.            self.ViewBounds:= RelBounds(b.appAreaLeft,b.appAreaTop,b.appAreaWidth,b.appAreaHeight);
  57.        end,
  58.      ReorientToScreen:
  59.        func()
  60.        begin
  61.            :syncView();
  62.            :RedoChildren();
  63.        end,
  64.      viewQuitScript:
  65.        func()
  66.        begin
  67.            //memory reclaim project
  68.            peoplePicker.selected:= nil;
  69.        end,
  70.      debug: "appBase",
  71.      viewClass: 74
  72.     };
  73.  
  74. _view000 :=
  75.     {viewBounds: {left: 0, top: 0, right: 240, bottom: 16}, _proto: @229};
  76. AddStepForm(appBase, _view000);
  77.  
  78.  
  79.  
  80. peoplePicker :=
  81.     {viewFlags: 1,
  82.      selected: nil,
  83.      dataClass:
  84.        //set this slot to either nameRef.fax, nameRef.people,nameRef.meetingPlace, or nameRef.email
  85.        '|nameRef.people|,
  86.      viewBounds: {left: 0, top: 30, right: 0, bottom: -55},
  87.      suppressCloseBox: true,
  88.      debug: "peoplePicker",
  89.      viewClass: 74
  90.     };
  91. AddStepForm(appBase, peoplePicker);
  92. StepDeclare(appBase, peoplePicker, 'peoplePicker);
  93.  
  94. // After Script for "peoplePicker"
  95. thisView := peoplePicker;
  96. // make the template a peoplePicker
  97. // NOTE: this is only because the current platform file
  98. //         does not have protoPeoplePicker defined yet
  99. RemoveSlot(thisView, 'viewClass);
  100. RemoveSlot(thisView, 'viewFlags);
  101. thisView._proto:= protoPeoplePicker; 
  102.  
  103.  
  104.  
  105. _view001 :=
  106.     {
  107.      buttonClickScript:
  108.        func()
  109.        begin
  110.            whatSelected:open();
  111.        end,
  112.      text: "What is selected",
  113.      viewBounds: {left: -100, top: 10, right: -10, bottom: 24},
  114.      viewJustify: 8396966,
  115.      _proto: @226
  116.     };
  117. AddStepForm(appBase, _view001);
  118.  
  119.  
  120.  
  121. _view002 :=
  122.     {text: " DataClass",
  123.      viewBounds: {left: 10, top: 0, right: 75, bottom: 0},
  124.      viewFlags: 515,
  125.      currentType: 0,
  126.      buttonClickScript:
  127.        func()
  128.        begin
  129.            self.popup := Clone(kTypePickerArray) ;
  130.            popup[currentType] := Clone(popup[currentType]) ;
  131.            popup[currentType].mark := kCheckMarkChar ;
  132.            
  133.            inherited:ButtonClickScript();        // call the inherited version to unhilite the button
  134.        end,
  135.      pickActionScript:
  136.        func(itemSelected)
  137.        begin
  138.            currentType := itemSelected ;
  139.        
  140.            inherited:?pickActionScript(itemSelected);        // call the inherited version to unhilite the button    
  141.        
  142.            // NOTE: the following code will NOT update the cursor
  143.            //            for the listPicker, it will not "filter" out
  144.            //            items (e.g. changing to meetingPlace will not remove just people)
  145.        
  146.            peoplePicker:ChangeDataClass(popup[itemSelected].dataClass) ;
  147.            peoplePicker:Update() ;
  148.        end,
  149.      viewJustify: 8401094,
  150.      _proto: @386
  151.     };
  152. AddStepForm(appBase, _view002);
  153.  
  154.  
  155.  
  156. _view003 := {_proto: @401};
  157. AddStepForm(appBase, _view003);
  158.  
  159.  
  160.  
  161. whatSelected :=
  162.     {viewBounds: {left: -1, top: 72, right: 106, bottom: 188},
  163.      debug: "whatSelected",
  164.      _proto: @180
  165.     };
  166. AddStepForm(appBase, whatSelected);
  167. StepDeclare(appBase, whatSelected, 'whatSelected);
  168.  
  169. _view004 :=
  170.     {
  171.      buttonClickScript:
  172.        func(textIndex)
  173.        begin
  174.            print("selected index " & textIndex);
  175.        end,
  176.      viewBounds: {left: 0, top: 0, right: 0, bottom: 116},
  177.      viewFont: ROM_fontSystem9,
  178.      viewLines: 6,
  179.      viewSetupFormScript:
  180.        func()
  181.        begin
  182.            //call the getSelected fucntion with true to return only the items that are currently selected'
  183.            //note: as items are selected nameRef's are created and put in the selected array.  The 
  184.            //getSelected function returns an array of the selected items and removes all other nameRef's
  185.            
  186.            local myArray := [];
  187.            foreach item in peoplePicker:getSelected(true) do
  188.            begin
  189.                if item.company then
  190.                    AddArraySlot(myArray,(item.company));
  191.                if item.name then
  192.                    AddArraySlot(myArray,(item.name.first && item.name.last));
  193.                if item.group then
  194.                    AddArraySlot(myArray,(item.group));
  195.            end;
  196.        
  197.            self.listItems := myArray;
  198.            :SetupList();
  199.        end,
  200.      listItems: nil,
  201.      viewJustify: 48,
  202.      viewFormat: 1,
  203.      useScrollers: true,
  204.      _proto: @228
  205.     };
  206. AddStepForm(whatSelected, _view004);
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. constant |layout_peoplePicker.t| := appBase;
  214. // End of file peoplePicker.t
  215.  
  216.  
  217.  
  218.