Changeset 7803


Ignore:
Timestamp:
Dec 2, 2007, 10:45:42 AM (13 years ago)
Author:
gb
Message:

Sync with trunk

Location:
branches/working-0711/ccl/examples/cocoa/currency-converter
Files:
3 added
3 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO.html

    r7435 r7803  
    1515    <div class="subtitle">
    1616      <h2>Creating Apple's <a
    17       href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter01/chapter_1_section_1.html">
     17      href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/index.html">
    1818            Currency Converter</a> example<br/>
    1919          with OpenMCL
     
    3434      Cocoa application that is functionally identical to Apple's
    3535      <a
    36       href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter01/chapter_1_section_1.html">
     36      href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/index.html">
    3737        Currency Converter</a> example. The most important
    3838        difference between Apple's example and this one is that this
     
    6464      <p>It will be helpful in understanding this example if you can
    6565      easily refer to Apple's <a
    66       href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter01/chapter_1_section_1.html">
     66      href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/index.html">
    6767        Currency Converter</a> example while working through this
    6868      HOWTO. You might consider opening a separate window or tab, and
     
    7373      same. In particular, the Lisp example follows the same
    7474      <a
    75       href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter02/chapter_2_section_3.html#//apple_ref/doc/uid/20002050-TPXREF104">
     75      href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/02Essence/chapter_2_section_4.html#//apple_ref/doc/uid/TP40000863-CH3-DontLinkElementID_6">
    7676        Model-View-Controller</a> paradigm that the Apple example
    7777        uses. If you are new to Cocoa programming, or if you are not
     
    102102
    103103      <ul>
    104         <li><p>A PowerPC Mac (future versions of this HOWTO will also
    105         support Intel Macs)</p></li>
    106         <li><p>Mac OS X Tiger (version 10.4.x)</p></li>
     104        <li><p>Mac OS X Tiger (version 10.4.x) or Mac OS X Leopard
     105        (version 10.5.x)</p></li>
    107106        <li><p>Apple's XCode development tools</p></li>
    108107        <li><p>Apple's InterfaceBuilder application (included with XCode)</p></li>
    109108        <li><p>A recent version of OpenMCL</p></li>
    110         <li><p>The OpenMCL Cocoa IDE (see <a href="HOWTO_files/pages/building_ide.html">this sidebar</a> for
    111         instructions on building it)</p></li>
     109        <li><p>Clozure CL.app</p></li>
    112110        <li><p>The Apple <a
    113       href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter01/chapter_1_section_1.html">
     111      href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/index.html">
    114112        Currency Converter</a> example, for reference</p></li>
    115113      </ul>
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/build_app.html

    r7435 r7803  
    1919      application bundle. Apple's tutorial relies on XCode to build
    2020      the application from Objective C source files; we will use the
    21       OpenMCL IDE to build it from our Lisp source file.</p>
     21      Clozure CL IDE to build it from our Lisp source file.</p>
    2222
    2323      <p>We build the application using the optional
    24       BUILD-APPLICATION feature, distributed as part of OpenMCL. The
     24      BUILD-APPLICATION feature, distributed as part of Clozure CL. The
    2525      steps to build the Cocoa application are:</p>
    2626
     
    3131      </ul>
    3232
    33       <p>This sequence of steps causes OpenMCL to construct a Cocoa
     33      <p>This sequence of steps causes Clozure CL to construct a Cocoa
    3434      application bundle and write out the application executable to
    3535      it, then quit. If all goes well, you should be able to run the
     
    4444    <div class="body-text">
    4545      <ol>
    46         <li><p>Launch the OpenMCL IDE. It's safest to build the
     46        <li><p>Launch the Clozure CL IDE. It's safest to build the
    4747        application with a fresh IDE session, so if you have it
    4848        running, you may wish to quit and relaunch before following
     
    6666        <li><p>Run BUILD-APPLICATION (be sure to correct the pathname
    6767        to your CurrencyConverter nibfile. It is safest to use a full,
    68         absolute pathname):</p>
     68        absolute pathname&mdash;not the relative pathname you see
     69        below):</p>
    6970          <p><pre>
    7071(ccl::build-application :name "CurrencyConverter"
     
    119120      <p>You'll notice when you run the application that, even though
    120121      you named it CurrencyConverter, the name in the main menu
    121       appears as "OpenMCL". That's because OS X takes the
     122      appears as "Clozure CL". That's because OS X takes the
    122123      application's name, not from the application bundle's name, nor
    123124      from the running code, but from an InfoPlist.strings file hidden
     
    128129
    129130      <p>Find the entry named "CFBundleName" and change its value
    130       from "OpenMCL" to "CurrencyConverter". The application's name
     131      from "Clozure CL" to "CurrencyConverter". The application's name
    131132      in the main menu bar should now appear correctly, as
    132133      "CurrencyConverter". You may also want to change the other
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/building_ui.html

    r7435 r7803  
    2020      describes in detail</a> how to do this.</p>
    2121
     22<div class="section-head">
     23  <h2>Apple's Tutorial</h2>
     24</div>
     25
    2226<p>Apple's tutorial explains how to use InterfaceBuilder to create the
    2327  user interface, and how to use XCode to create project files and
     
    2630  the part of the tutorial that explains how to use XCode.</p>
    2731
    28 <p>Begin by launching InterfaceBuilder, which you will find in the
    29   "/Developer/Applications/" folder. Create a new nibfile by using
    30   InterfaceBuilder's "Starting Point" dialog. If the "Starting Point"
    31   dialog doesn't appear when you launch InterfaceBuilder, you can
    32   display it by choosing "New" from the File menu. Choose "Cocoa
    33   Application", and click the "New" button to create the
    34   nibfile.</p>
    35 
    36     <div class="subtitle">
    37       <img src="../images/ibwin1.jpg"alt=""
    38            border='0'/>
    39     </div>
    40 
    41 
    42 <p>Save the nibfile in your "currency-converter" folder. Name it
    43   "CurrencyConverter.nib". Apple's tutorial names it "MainMenu.nib",
    44   but we won't use that name. When building an application with
    45   OpenMCL, we gradually change the behavior of the OpenMCL application
    46   until it behaves the way we want for our application. OpenMCL's IDE
    47   already has a nibfile built into it with the name "MainMenu.nib",
    48   and if we wanted to use that name for the CurrencyConverter
    49   application, we would have to replace OpenMCL's "MainMenu.nib". It's
    50   generally a good idea to avoid destroying or replacing things unless
    51   you really have to, so, in order to preserve the OpenMCL nibfile,
    52   give yours the name "CurrencyConverter.nib".</p>
    53 
    54 <p>Now you can use this nibfile to create your application's user
    55   interface. When Apple's tutorial tells you to find and open the main
    56   nibfile created by XCode, use your "CurrencyConverter.nib"
    57   instead.</p>
     32<div class="section-head">
     33  <h2>Using InterfaceBuilder to Create the UI</h2>
     34</div>
     35
     36      <p>We'll begin by using Apple's InterfaceBuilder application to
     37        create a nibfile. The nibfile contains
     38        archived versions of the Objective C objects that define the
     39        application's user interface. When you launch an application,
     40        Mac OS X uses the archived objects in the nibfile to create the
     41        windows and menus you see on the screen. </p>
     42
     43      <p>Start by locating Apple's InterfaceBuilder application. If
     44        you installed Apple's Developer Tools, InterfaceBuilder should
     45        be in the folder "/Developer/Applications/":</p>
     46
     47      <div class="inline-image">
     48        <img src="../images/finder-win1.jpg"alt=""
     49             border='0'/>
     50      </div>
     51     
     52
     53      <p class= "note"><strong><em>NOTE:</em></strong> If you have not installed Apple's Developer Tools, you should
     54        do that now. You will not be able to build the CurrencyConverter
     55        example without them. The Developer Tools are distributed as an
     56        optional install with Mac OS X 10.5 ("Leopard"). Look for the
     57        "XCode Tools" package in the "Optional Installs" folder on the
     58        Mac OS 10.5 install disk.</p>
     59
     60      <p>Once you have located InterfaceBuilder, double-click to launch
     61        the application. InterfaceBuilder presents a window you can use
     62        to choose a template for the nibfile you are going to create.</p>
     63
     64      <div class="inline-image">
     65        <img src="../images/ibwin-leopard1.jpg"alt=""
     66             border='0'/>
     67      </div>
     68
     69      <p>Click the "Application" icon and then click the "Choose" button to
     70        create an application nibfile. InterfaceBuilder creates a new
     71        application nibfile, but doesn't immediately save it. The
     72        Objective C objects that represent the new application's
     73        interface appear in a new untitled window:</p>
     74
     75      <div class="inline-image">
     76        <img src="../images/ibwin-leopard2.jpg"alt=""
     77             border='0'/>
     78      </div>
     79
     80      <p>The intial window and menubar also appear on the screen. The
     81      new application's name appears in the menus as
     82      "NewApplication". Save the new nibfile into the
     83      "currency-converter" folder that you created earlier
     84      (on <a href="making_project.html">this
     85      page</a>). InterfaceBuilder 3.0 gives you a choice of file
     86      formats when you save a new nibfile; use the "NIB 3.x"
     87      format&mdash;the "XIB 3.x" format works fine for editing your
     88      user interface, but will not work correctly if you try to use it
     89      in a working application. Give the new file the name
     90      "CurrencyConverter.nib".</p>
     91
     92      <div class="note">
     93        <p><strong><em>NOTE:</em></strong> Most Objective C application projects use a main
     94        nibfile called "MainMenu.nib", and if you use XCode to create
     95        a new application project, it creates a nibfile with that
     96        name. Apple's CurrencyConverter tutorial assumes that the
     97        name of the main nibfile is "MainMenu.nib".</p>
     98
     99        <p>So, why do we tell you to use a different name? Clozure CL
     100          has a main nibfile built into it, whose name is
     101          "MainMenu.nib". Normally you don't see it, and don't even
     102          need to know that it exists. But the Clozure CL
     103          application-building tools create a new application by
     104          copying resources from the Clozure CL application, so that
     105          your new application has available to it all the built-in
     106          Clozure CL tools. We ask you to name your nibfile
     107          "CurrencyConverter.nib" so that it can coexist with the
     108          Clozure CL main nibfile without causing any problems.</p>
     109
     110        <p>This difference between a Lisp project and an Objective C
     111        project might be a little confusing at first. Just try to keep
     112        in mind that whenever Apple's tutorial refers to the
     113        "MainMenu.nib" file, it means the file we have just created
     114        and named "CurrencyConverter.nib". In a Clozure CL project,
     115        "MainMenu.nib" is the name of the main Lisp nibfile, not your
     116        application's main nibfile.</p>
     117      </div>
     118
    58119
    59120<p>Skip straight to the part of Apple's tutorial
    60 called <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter03/chapter_3_section_3.html">Creating
    61 the Currency Converter Interface</a>. Read the introduction to
     121called <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_1.html#//apple_ref/doc/uid/TP40000863-CH7-SW1">Defining
     122    the View: Building the User Interface</a>. Read
     123  the introduction to
    62124nibfiles, and follow the instructions to create the Currency Converter
    63125interface. (Remember that when the tutorial tells you to open and edit
    64126"MainMenu.nib", you will instead open and edit your
    65127"CurrencyConverter.nib".) When you reach the end of the section
    66 called <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter03/chapter_3_section_6.html">Defining
    67 the Converter Class</a>, you are done creating the interface for your
    68 application. Save your nibfile and continue with the next section of
    69 this HOWTO, on writing the Lisp code that provides the application's
    70 behavior.</p>
    71 
    72 <p></p>
    73      
     128called <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_5.html#//apple_ref/doc/uid/TP40000863-CH7-DontLinkElementID_38">Test
     129    the Interface</a>, and move on to the short section afterward
     130  called <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/05View/chapter_5_section_6.html#//apple_ref/doc/uid/TP40000863-CH7-DontLinkElementID_39">What's Next</a>,
     131  you are done creating the interface for your
     132application. Save your nibfile and continue with the next section.</p>
     133
     134<div class="section-head">
     135  <h2>What if You Need to Use InterfaceBuilder 2.x?</h2>
     136</div>
     137
     138<p>If you are still using Mac OS X 10.4.x ("Tiger"), you can still
     139  create a working nibfile and you can still follow the instructions
     140  in this HOWTO to create a Cocoa application with Clozure CL. The
     141  main obstacle to doing so is that the earlier versions of
     142  InterfaceBuilder have a significantly different user interface, and
     143  so you may find it hard to follow Apple's tutorial when working with
     144  InterfaceBuilder.</p>
     145
     146<p>If you are working with Mac OS X 10.4.x ("Tiger"), you can
     147  look <a href="building_ui_tiger.html">here</a> to find a description
     148  of how to build the user interface files with the earlier version of
     149  InterfaceBuilder. When you have finished building your user
     150  interface, you can continue with the <a href="create_lisp.html">next
     151  section</a>, "Creating a Lisp File".</p>
     152
     153<p>One other thing: if you are using Mac OS X 10.4.x ("Tiger"), you
     154  will be able to build Cocoa applications only on PPC Macs. The
     155  Clozure CL Objective C support for Intel systems works only on Mac
     156  OS X 10.5.x ("Leopard").</p>
     157
     158
     159<div class="section-head">
     160  <h2>Adding Custom Classes to the nibfile</h2>
     161</div>
     162
     163<p>Once the user interface for your application looks right, there is
     164  still one important task to complete before you can use it. You must
     165  record some information in the nibfile about the classes of the
     166  objects, so that the application can create them with the right
     167  connections in place.</p>
     168
     169<p>When you use XCode to write an Objective C application,
     170  InterfaceBuilder can read the Objective C header files and use the
     171  information in them to create descriptions of the classes in the
     172  Objective C code. When the application is written in Lisp,
     173  InterfaceBuilder can't read the class descriptions from the code,
     174  and so we'll have to manually tell the nibfile about any classes
     175  that we use in the user interface.</p>
     176
     177<p>As you will see in the following sections, we'll use Lisp code to
     178  define two Objective C classes: Converter, and
     179  ConverterController. The Converter class implements the method that
     180  performs the actual currency conversion for our application; the
     181  ConverterController class provides communication between the user
     182  interface and the Converter object. We need a way to create instaces
     183  of these two classes in the nibfile, so that launching the
     184  application creates these instances and the connections between them
     185  and the rest of the user interface.</p>
     186
     187<div class="section-head">
     188  <h2>Create Instances of Custom Classes</h2>
     189</div>
     190
     191<p>In InterfaceBuilder's Library window, select the Cocoa Objects and
     192  Controllers view:</p>
     193
     194      <div class="inline-image">
     195        <img src="../images/ibwin-leopard3.jpg"alt=""
     196             border='0'/>
     197      </div>
     198
     199<p>Drag an Object from the Library window and drop it into the main
     200  CurrencyConverter window:</p>
     201
     202      <div class="inline-image">
     203        <img src="../images/ibwin-leopard4.jpg"alt=""
     204             border='0'/>
     205      </div>
     206
     207<p>Now tell InterfaceBuilder the name of the new object's class. With
     208  the Object icon selected in the main CurrencyConverter window,
     209  choose the Identity tab of the Inspector. At the top of the
     210  Identity view is a "Class" field; type the name of your custom
     211  class (in this case, "Converter") into the "Class" field and save
     212  the nibfile:</p>
     213
     214      <div class="inline-image">
     215        <img src="../images/ibwin-leopard5.jpg"alt=""
     216             border='0'/>
     217      </div>
     218
     219<p>Repeat the previous steps to create an instance of the
     220  ConverterController class: drag an "Object" icon and drop it in the
     221  main CurrencyConverter window. Then, change the name of the
     222  Object's class to "ConverterController".</p>
     223
     224<p>That's all it takes to add an instance of a custom class to the
     225  nibfile. We do still have to add the names of instance variables and
     226  actions, and we need to create the connections between the
     227  instances.</p>
     228
     229<div class="section-head">
     230  <h2>Add Outlets and Actions</h2>
     231</div>
     232
     233<p>Now, using the "+" button below the "Class Outlets" section of the
     234  Inspector, add outlets to the ConverterController class. The
     235  outlets you need to add are named "amountField", "converter",
     236  "dollarField", and "rateField".</p>
     237
     238      <div class="inline-image">
     239        <img src="../images/ibwin-leopard6.jpg"alt=""
     240             border='0'/>
     241      </div>
     242
     243<p>We'll connect each of the "field" outlets to one of the text
     244  fields in the CurrencyConverter UI, and we'll connect the
     245  "converter" outlet to the Converter instance that we created
     246  before. When the application launches, it creates the Converter and
     247  ConverterController instances and establishes the connections that
     248  we specify in the nibfile.</p>
     249
     250
     251<p>First, though, we need to tell the nibfile about actions as well as
     252  outlets. With the "ConverterController" instance selected, use the
     253  "+" button below the "Class Actions" section to add a new
     254  action. Name the action "convert:":</p>
     255
     256      <div class="inline-image">
     257        <img src="../images/ibwin-leopard7.jpg"alt=""
     258             border='0'/>
     259      </div>
     260
     261<p>In this application, the "convert:" action is the only action
     262  defined for the user interface, so we are done with actions now. In
     263  more complex applications you may need to define many actions and
     264  outlets.</p>
     265
     266<p>Now we'll connect outlets to objects and actions.</p>
     267
     268<div class="section-head">
     269  <h2>Add Connections</h2>
     270</div>
     271
     272<p>InterfaceBuilder enables you to connect objects by
     273  "Control-dragging" from one to another. To "Control-drag", you hold
     274  down the Control key while dragging from one object to the next.</p>
     275
     276<p>Select the "ConverterController" instance in the nibfile's main
     277  window, and Control-drag a connection to the "Exchange rate" text
     278  field in the application's main window. (Be sure to connect to the
     279  text field, not to its label!) When you release the mouse button,
     280  InterfaceBuilder pops up a menu that lists the available
     281  outlets. Choose "rateField" from the menu. The "rateField" outlet of
     282  the "ConverterController" instance is now connected to the "Exchange
     283  rate" text field.</p>
     284
     285<p>Repeat the same steps for the "Dollars" field and the "Amount"
     286  field, connecting them to the "dollarField" and "amountField"
     287  outlets, respectively.</p>
     288
     289<p>Finally, Control-drag a connection from the "ConverterController"
     290  instance to the "Converter" instance. Choose "converter" from the
     291  popup menu to connect the "converter" field of the
     292  "ConverterController" instance to the "Converter" instance.</p>
     293
     294<p>To confirm that the connections are correct, you can use the
     295  Connections view in the inspector. With the "ConverterController"
     296  instance selected, click the blue arrow icon at the top of the
     297  Inspector window to display connections. You should see a list of
     298  outlets and the types of objects they are connected to:</p>
     299
     300      <div class="inline-image">
     301        <img src="../images/ibwin-leopard8.jpg"alt=""
     302             border='0'/>
     303      </div>
     304
     305<p>We need to add one more connection: from the "Convert" button in
     306  the application window to the "ConverterController"
     307  instance. Control drag a connection from the "Convert" button in the
     308  application window to the "ConverterController" instance in the
     309  nibfile's main window. InterfaceBuilder pops up a menu; choose the
     310  "convert:" action from the menu to connect the button to the
     311  action.</p>
     312
     313<p>The nibfile now contains descriptions of the needed cusstom
     314  classes and their connections. You can continue with the next
     315  section, which explains how to write the Lisp code that implements
     316  the application's behavior.</p>
     317
    74318    <div class="nav">
    75       <p><a href="../../HOWTO.html">start</a>|<a href="building_ui.html">previous</a>|<a href="create_lisp.html">next</a></p>
     319      <p><a href="../../HOWTO.html">start</a>|<a href="making_project.html">previous</a>|<a href="create_lisp.html">next</a></p>
    76320    </div>
    77321
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/conclusion.html

    r7435 r7803  
    1515    <div class="body-text">
    1616      <p>This concludes our HOWTO on building the Apple
    17       CurrencyConverter example in Lisp with OpenMCL. Your own Lisp
     17      CurrencyConverter example in Lisp with Clozure CL. Your own Lisp
    1818      applications are likely to be considerably more complex than the
    1919      Currency Converter, which, after all, just does a simpe
     
    2929      standalone Cocoa applications.</p>
    3030
    31       <p>You should now be able to use OpenMCL to accomplish anything
     31      <p>You should now be able to use Clozure CL to accomplish anything
    3232      that an Objective C user can accomplish with Cocoa. Good luck!</p>
    3333
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/create_lisp.html

    r7435 r7803  
    2020      application to create and manage projects, to edit Objective C
    2121      source files, and to build the final application. In this HOWTO,
    22       Clozure's OpenMCL application takes the place of XCode. The
    23       Lisp project structure is much simpler than the XCode project
     22      the Clozure CL application takes the place of XCode. The Lisp
     23      project structure is much simpler than the XCode project
    2424      structure: to build the Lisp application we need only the
    2525      nibfile created in the previous section, and a single Lisp
    2626      source file.</p>
    2727     
    28       <p>Before you continue, make sure you have followed the
    29       instructions
    30       in <a href="HOWTO_files/pages/building_ide.html">this
    31       sidebar</a> on building the OpenMCL IDE. We'll use the IDE to
    32       create and load Lisp files.</p>
    33 
    34       <p>Once you have a working IDE, launch it by double-clicking
    35       the OpenMCL application. OpenMCL displays a Listener window:</p>
     28      <p>Double-click Clozure CL to launch it. Clozure CL displays a Listener window:</p>
    3629
    3730      <div class="subtitle">
     
    5144
    5245    <div class="nav">
    53       <p><a href="../../HOWTO.html">start</a>|<a href="writing_lisp.html">next</a></p>
     46      <p><a href="../../HOWTO.html">start</a>|<a href="building_ui.html">previous</a>|<a href="writing_lisp.html">next</a></p>
    5447    </div>
    5548
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/making_project.html

    r7435 r7803  
    1919    <div class="body-text">
    2020      <p>This HOWTO is distributed with example files that include a
    21       working nibfile and a Lisp source file, named
    22       "CurrencyConverter.nib" and "CurrencyConverter.lisp",
    23       respectively. You can build a working copy of
    24       the example application by using these files, but, if you wish
    25       to understand how to build your own Lisp application projects,
    26       you should probably follow the instructions here to create your
    27       own source file and nibfile, and use the example files only for
    28       reference in case something goes wrong.</p>
     21      working <em>nibfile</em> (a file of user-interface objects,
     22      named "CurrencyConverter.nib") and a Lisp source file (named
     23      "CurrencyConverter.lisp"). You can build a working copy of the
     24      example application by using these files, but you probably
     25      shouldn't. If you want to understand how to build your own Lisp
     26      application projects, you should follow the instructions here to
     27      create your own source file and nibfile, and use the example
     28      files only for reference in case something goes wrong.</p>
    2929    </div>
    3030
     
    3636      <p>First, create a project folder to hold the files you are
    3737      going to create. When your project is complete, the folder will
    38       contain a <em>nibfile</em> that defines the user interface, and
     38      contain a nibfile that defines the user interface, and
    3939      a Lisp source file that defines the behavior of the
    4040      application. Those two files are really all there is to a Lisp
    4141      application, though not all applications are as simple as this
    4242      currency converter. For more complex applications it makes sense
    43       to split you UI into several nibfiles, and to split your
     43      to split your UI into several nibfiles, and to split your
    4444      implementation into several source files. The basic principle
    4545      remains the same, however: nibfiles define your user interface,
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/writing_lisp.html

    r7435 r7803  
    1515    <div class="body-text">
    1616      <p>In this section we'll write Lisp code that duplicates the
    17       features provided by the Objective C code in Apple's example. In
    18       Apple's example, the explanation of the Objective C code begins
    19       with the
    20       section <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/chapter04/chapter_4_section_1.html">Implementing
    21       Currency Converter</a>.</p>
     17      features provided by the Objective C code in Apple's
     18      tutorial. In Apple's tutorial, the explanation of the Objective
     19      C code begins with the
     20      section <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/06Controller/chapter_6_section_1.html#//apple_ref/doc/uid/TP40000863-CH8-SW1">Bridging
     21      the Model and View: The Controller</a>.</p>
    2222
    2323      <p>The Lisp code in this section of the HOWTO is considerably
     
    2525      because we can ignore the conventions that XCode uses for
    2626      laying out source files. We can just write all our definitions
    27       into a single Lisp source file, and load that file into OpenMCL
     27      into a single Lisp source file, and load that file into Clozure CL
    2828      when we are ready to build the application.</p>
    2929
     
    3737      <pre>(in-package "CCL")</pre>
    3838
    39       <p>OpenMCL's Objective C bridge code is defined in the "CCL"
     39      <p>Clozure CL's Objective C bridge code is defined in the "CCL"
    4040      package. Usually, when building an application, you'll create a
    4141      package for that application and import the definitions you need
     
    6868      simple wrinkles. First, the superclass it inherits from is the
    6969      NS-OBJECT class in the "NS" package. NS-OBJECT is an Objective C
    70       class, the ancestor of all Objective C objects. This CLOSE
     70      class, the ancestor of all Objective C objects. This CLOS
    7171      definition actually creates a new Objective C class named
    7272      "Converter".</p>
    7373
    74       <p>We tell OpenMCL how to build the right kind of class object
     74      <p>We tell Clozure CL how to build the right kind of class object
    7575      by including the :METACLASS option in the definition:</p>
    7676
     
    9494      <p>This is the method that actually does the currency
    9595      conversion. It's very simple&mdash;really, it just multiples
    96       currency times rate. Most of the text in the definition is
     96      <code>currency</code> times <code>rate</code>. Most of the text in the definition is
    9797      Objective C bridge code that links the definition to the right
    9898      class with the right argument and return types.</p>
     
    102102
    103103      <p>The syntax <code>#/convertCurrency:atRate:</code> uses the
    104       "#/" reader macro to read a symbol in mixed case, so that you
    105       can see in your code the same name that Objective C uses for the
    106       method, without worrying about how the name might be converted
    107       between Lisp and Objective C conventions. The number of
    108       arguments to an Objective C method is the number of colons in
    109       the name, plus one. Each colon indicates an argument, and there
    110       is always an extra "self" argument that refers to the object
    111       that receives the message. These are normal Objective C
    112       conventions, but we perhaps need to emphasize the details, since
    113       we are using Lisp code to call the Objective C methods.</p>
     104      "#/" reader macro to read a symbol with case preserved, so that
     105      you can see in your code the same name that Objective C uses for
     106      the method, without worrying about how the name might be
     107      converted between Lisp and Objective C conventions.</p>
     108
     109      <p>The number of arguments to an Objective C method is the
     110      number of colons in the name, plus one. Each colon indicates an
     111      argument, and there is always an extra "self" argument that
     112      refers to the object that receives the message. These are normal
     113      Objective C conventions, but we perhaps need to emphasize the
     114      details, since we are using Lisp code to call the Objective C
     115      methods.</p>
    114116
    115117      <p>We indicate the return type and the types of arguments in
     
    169171
    170172      <p>Each field in the definition of the ConverterController class
    171       corresponds to one of the UI fields that you created in
    172       InterfaceBuilder. For example, <code>amount-field</code>
    173       corresponds to the "Amount in Other Currency" text field. The
    174       exception is the <code>converter</code> field, which at launch
    175       time contains a reference to the Converter object, whose class
    176       definition is in the previous section.</p>
     173      is an outlet that will be used to store a reference to one of
     174      the UI fields that you created in InterfaceBuilder. For
     175      example, <code>amount-field</code> will be connected to the
     176      "Amount" text field.</p>
     177
     178      <p>Why did we spell the name "amount-field" in Lisp code, and
     179      "amountField" when creating the outlet in InterfaceBuilder?  The
     180      Objective C bridge automatically converts Lisp-style field names
     181      (like "amount-field") to Objective C-style field names (like
     182      "amountField"), when handling class definitions.</p>
     183
     184      <p>The <code>converter</code> field at launch time contains a
     185      reference to the Converter object, whose class definition is in
     186      the previous section.</p>
    177187
    178188      <p>The final piece of the implementation is a definition of the
     
    197207      "convertCurrency:atRate:" method of the Converter class. It then
    198208      sets the text of the amount-field to reflect the result of the
    199       conversion. The only singificant difference between this
     209      conversion. The only significant difference between this
    200210      implementation and Apple's is that the code is written in Lisp
    201211      rather than Objective C.</p>
     
    208218
    209219    <div class="nav">
    210       <p><a href="../../HOWTO.html">start</a>|<a href="build_app.html">next</a></p>
     220      <p><a href="../../HOWTO.html">start</a>|<a href="create_lisp.html">previous</a>|<a href="build_app.html">next</a></p>
    211221    </div>
    212222
  • branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/stylesheets/styles.css

    r7435 r7803  
    3333}
    3434
     35.note {
     36        font: 12pt Georgia, "Times New Roman", Times, serif;
     37        margin-left: 6em;
     38        margin-right: 6em;
     39        text-indent: 0em;
     40}
     41
    3542.inline-image {
    3643        text-align: center;
  • branches/working-0711/ccl/examples/cocoa/currency-converter/currency-converter.lisp

    r7435 r7803  
    4343  (ccl::build-application :name "CurrencyConverter"
    4444                          :main-nib-name "CurrencyConverter"
    45                           :nibfiles '(#P"/Users/mikel/Valise/clozure/openmcl/example-code/currency-converter/CurrencyConverter.nib")))
     45                          :directory "/Users/mikel/Desktop/"
     46                          :nibfiles '(#P"/usr/local/openmcl/trunk/ccl/examples/cocoa/currency-converter/CurrencyConverter.xib")))
    4647
    4748TODO NOTES:
Note: See TracChangeset for help on using the changeset viewer.