Changeset 7799


Ignore:
Timestamp:
Dec 1, 2007, 2:28:23 PM (17 years ago)
Author:
mikel
Message:

various corrections to HOWTO; added section on IB 2.x

Location:
trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/build_app.html

    r7435 r7799  
    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
  • trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/building_ui.html

    r7712 r7799  
    3535
    3636      <p>We'll begin by using Apple's InterfaceBuilder application to
    37         create a <em>nibfile</em>. The <em>nibfile</em> contains
     37        create a nibfile. The nibfile contains
    3838        archived versions of the Objective C objects that define the
    3939        application's user interface. When you launch an application,
     
    5151     
    5252
    53       <p class= "note"><em>NOTE:</em> If you have not installed Apple's Developer Tools, you should
     53      <p class= "note"><strong><em>NOTE:</em></strong> If you have not installed Apple's Developer Tools, you should
    5454        do that now. You will not be able to build the CurrencyConverter
    5555        example without them. The Developer Tools are distributed as an
     
    8181      new application's name appears in the menus as
    8282      "NewApplication". Save the new nibfile into the
    83       "currency-converter" folder that you created earlier (on <a href="making_project.html">this
    84       page</a>). Give it the name "CurrencyConverter.nib".</p>
     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>
    8591
    8692      <div class="note">
    87         <p><em>NOTE:</em> Most Objective C application projects use a main
     93        <p><strong><em>NOTE:</em></strong> Most Objective C application projects use a main
    8894        nibfile called "MainMenu.nib", and if you use XCode to create
    8995        a new application project, it creates a nibfile with that
     
    9298
    9399        <p>So, why do we tell you to use a different name? Clozure CL
    94           has a main nibfile built into, whose name is
     100          has a main nibfile built into it, whose name is
    95101          "MainMenu.nib". Normally you don't see it, and don't even
    96102          need to know that it exists. But the Clozure CL
     
    98104          copying resources from the Clozure CL application, so that
    99105          your new application has available to it all the built-in
    100           Clozure CL tools. In order to avoid any confusion between
    101           your application's nibfile and the MainMenu.nib built into
    102           Clozure CL, we ask you to name your nibfile
    103           "CurrencyConverter.nib".</p>
    104 
    105         <p>Just try to keep in mind that whenever Apple's tutorial
    106         refers to the "MainMenu.nib" file, it means the file we have
    107         named "CurrencyConverter.nib".</p>
     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>
    108117      </div>
    109118
     
    124133
    125134<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">
    126160  <h2>Adding Custom Classes to the nibfile</h2>
    127161</div>
    128162
    129 <p>The user interface for your application looks right, but before it
    130   can work right, we have to record some more information  in the
    131   nibfile about the classes of the objects. In the following sections
    132   we'll see how to write the Lisp code that defines your
    133   application's classes. Before we're done with InteraceBuilder we
    134   need to put references to those classes in the nibfile, so that
    135   your application will create the correct objects when it
    136   launches.</p>
     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>
    137168
    138169<p>When you use XCode to write an Objective C application,
     
    144175  that we use in the user interface.</p>
    145176
    146 <p>As you will see in the following sections, we'll be using Lisp code
    147   to define two Objective C classes: Converter, and
     177<p>As you will see in the following sections, we'll use Lisp code to
     178  define two Objective C classes: Converter, and
    148179  ConverterController. The Converter class implements the method that
    149180  performs the actual currency conversion for our application; the
     
    192223
    193224<p>That's all it takes to add an instance of a custom class to the
    194   nibfile. We do still have to add the ConverterController class, and
    195   we need to tell the nibfile a few more pieces of information about
    196   the two classes&mdash;specifically, we need to add the names of
    197   instance variables and actions, and we need to create the
    198   connections between the instances.</p>
     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>
    199228
    200229<div class="section-head">
     
    231260
    232261<p>In this application, the "convert:" action is the only action
    233   defined for the user interface, so we are done. In more complex
    234   applications you may need to define many actions and outlets.</p>
     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>
    235265
    236266<p>Now we'll connect outlets to objects and actions.</p>
     
    246276<p>Select the "ConverterController" instance in the nibfile's main
    247277  window, and Control-drag a connection to the "Exchange rate" text
    248   field in the application's main window. When you release the mouse
    249   button, InterfaceBuilder pops up a menu that lists the available
    250   outlets. Choose "rateField" from the menu. The "rateField" outlet
    251   of the "ConverterController" instance is now connected to the
    252   "Exchange rate" text field.</p>
     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>
    253284
    254285<p>Repeat the same steps for the "Dollars" field and the "Amount"
     
    274305<p>We need to add one more connection: from the "Convert" button in
    275306  the application window to the "ConverterController"
    276   instance. Control drag a connection from the "Convert" button to
    277   the "ConverterController" instance. InterfaceBuilder pops up a
    278   menu; choose the "convert:" action from the menu to connect the
    279   button to the action.</p>
     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>
    280312
    281313<p>The nibfile now contains descriptions of the needed cusstom
  • trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/conclusion.html

    r7435 r7799  
    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
  • trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/making_project.html

    r7709 r7799  
    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
  • trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/writing_lisp.html

    r7712 r7799  
    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
     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
    2020      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
    2121      the Model and View: The Controller</a>.</p>
     
    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 text field that is connected to
    174       the <code>amountField</code> outlet. The Objective C bridge
    175       converts Lisp-style names (like "amount-field") to Objective
    176       C-style names (like "amountField").</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>
    177183
    178184      <p>The <code>converter</code> field at launch time contains a
     
    201207      "convertCurrency:atRate:" method of the Converter class. It then
    202208      sets the text of the amount-field to reflect the result of the
    203       conversion. The only singificant difference between this
     209      conversion. The only significant difference between this
    204210      implementation and Apple's is that the code is written in Lisp
    205211      rather than Objective C.</p>
Note: See TracChangeset for help on using the changeset viewer.