Changeset 7799
- Timestamp:
- Dec 1, 2007, 2:28:23 PM (17 years ago)
- Location:
- trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages
- Files:
-
- 1 added
- 5 edited
-
build_app.html (modified) (6 diffs)
-
building_ui.html (modified) (11 diffs)
-
building_ui_tiger.html (added)
-
conclusion.html (modified) (2 diffs)
-
making_project.html (modified) (2 diffs)
-
writing_lisp.html (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/build_app.html
r7435 r7799 19 19 application bundle. Apple's tutorial relies on XCode to build 20 20 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> 22 22 23 23 <p>We build the application using the optional 24 BUILD-APPLICATION feature, distributed as part of OpenMCL. The24 BUILD-APPLICATION feature, distributed as part of Clozure CL. The 25 25 steps to build the Cocoa application are:</p> 26 26 … … 31 31 </ul> 32 32 33 <p>This sequence of steps causes OpenMCL to construct a Cocoa33 <p>This sequence of steps causes Clozure CL to construct a Cocoa 34 34 application bundle and write out the application executable to 35 35 it, then quit. If all goes well, you should be able to run the … … 44 44 <div class="body-text"> 45 45 <ol> 46 <li><p>Launch the OpenMCL IDE. It's safest to build the46 <li><p>Launch the Clozure CL IDE. It's safest to build the 47 47 application with a fresh IDE session, so if you have it 48 48 running, you may wish to quit and relaunch before following … … 66 66 <li><p>Run BUILD-APPLICATION (be sure to correct the pathname 67 67 to your CurrencyConverter nibfile. It is safest to use a full, 68 absolute pathname):</p> 68 absolute pathname—not the relative pathname you see 69 below):</p> 69 70 <p><pre> 70 71 (ccl::build-application :name "CurrencyConverter" … … 119 120 <p>You'll notice when you run the application that, even though 120 121 you named it CurrencyConverter, the name in the main menu 121 appears as " OpenMCL". That's because OS X takes the122 appears as "Clozure CL". That's because OS X takes the 122 123 application's name, not from the application bundle's name, nor 123 124 from the running code, but from an InfoPlist.strings file hidden … … 128 129 129 130 <p>Find the entry named "CFBundleName" and change its value 130 from " OpenMCL" to "CurrencyConverter". The application's name131 from "Clozure CL" to "CurrencyConverter". The application's name 131 132 in the main menu bar should now appear correctly, as 132 133 "CurrencyConverter". You may also want to change the other -
trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/building_ui.html
r7712 r7799 35 35 36 36 <p>We'll begin by using Apple's InterfaceBuilder application to 37 create a <em>nibfile</em>. The <em>nibfile</em>contains37 create a nibfile. The nibfile contains 38 38 archived versions of the Objective C objects that define the 39 39 application's user interface. When you launch an application, … … 51 51 52 52 53 <p class= "note">< em>NOTE:</em> If you have not installed Apple's Developer Tools, you should53 <p class= "note"><strong><em>NOTE:</em></strong> If you have not installed Apple's Developer Tools, you should 54 54 do that now. You will not be able to build the CurrencyConverter 55 55 example without them. The Developer Tools are distributed as an … … 81 81 new application's name appears in the menus as 82 82 "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—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> 85 91 86 92 <div class="note"> 87 <p>< em>NOTE:</em> Most Objective C application projects use a main93 <p><strong><em>NOTE:</em></strong> Most Objective C application projects use a main 88 94 nibfile called "MainMenu.nib", and if you use XCode to create 89 95 a new application project, it creates a nibfile with that … … 92 98 93 99 <p>So, why do we tell you to use a different name? Clozure CL 94 has a main nibfile built into , whose name is100 has a main nibfile built into it, whose name is 95 101 "MainMenu.nib". Normally you don't see it, and don't even 96 102 need to know that it exists. But the Clozure CL … … 98 104 copying resources from the Clozure CL application, so that 99 105 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> 108 117 </div> 109 118 … … 124 133 125 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"> 126 160 <h2>Adding Custom Classes to the nibfile</h2> 127 161 </div> 128 162 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> 137 168 138 169 <p>When you use XCode to write an Objective C application, … … 144 175 that we use in the user interface.</p> 145 176 146 <p>As you will see in the following sections, we'll be using Lisp code147 todefine two Objective C classes: Converter, and177 <p>As you will see in the following sections, we'll use Lisp code to 178 define two Objective C classes: Converter, and 148 179 ConverterController. The Converter class implements the method that 149 180 performs the actual currency conversion for our application; the … … 192 223 193 224 <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—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> 199 228 200 229 <div class="section-head"> … … 231 260 232 261 <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> 235 265 236 266 <p>Now we'll connect outlets to objects and actions.</p> … … 246 276 <p>Select the "ConverterController" instance in the nibfile's main 247 277 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> 253 284 254 285 <p>Repeat the same steps for the "Dollars" field and the "Amount" … … 274 305 <p>We need to add one more connection: from the "Convert" button in 275 306 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> 280 312 281 313 <p>The nibfile now contains descriptions of the needed cusstom -
trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/conclusion.html
r7435 r7799 15 15 <div class="body-text"> 16 16 <p>This concludes our HOWTO on building the Apple 17 CurrencyConverter example in Lisp with OpenMCL. Your own Lisp17 CurrencyConverter example in Lisp with Clozure CL. Your own Lisp 18 18 applications are likely to be considerably more complex than the 19 19 Currency Converter, which, after all, just does a simpe … … 29 29 standalone Cocoa applications.</p> 30 30 31 <p>You should now be able to use OpenMCL to accomplish anything31 <p>You should now be able to use Clozure CL to accomplish anything 32 32 that an Objective C user can accomplish with Cocoa. Good luck!</p> 33 33 -
trunk/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/making_project.html
r7709 r7799 19 19 <div class="body-text"> 20 20 <p>This HOWTO is distributed with example files that include a 21 working nibfile and a Lisp source file, named22 "CurrencyConverter.nib" and "CurrencyConverter.lisp",23 respectively. You can build a working copy of24 the example application by using these files, but, if you wish25 to understand how to build your own Lisp application projects,26 you should probably follow the instructions here to create your27 own source file and nibfile, and use the example files only for28 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> 29 29 </div> 30 30 … … 36 36 <p>First, create a project folder to hold the files you are 37 37 going to create. When your project is complete, the folder will 38 contain a <em>nibfile</em>that defines the user interface, and38 contain a nibfile that defines the user interface, and 39 39 a Lisp source file that defines the behavior of the 40 40 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 15 15 <div class="body-text"> 16 16 <p>In this section we'll write Lisp code that duplicates the 17 features provided by the Objective C code in Apple's example. In18 Apple's example, the explanation of the Objective C code begins19 with the17 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 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 21 the Model and View: The Controller</a>.</p> … … 25 25 because we can ignore the conventions that XCode uses for 26 26 laying out source files. We can just write all our definitions 27 into a single Lisp source file, and load that file into OpenMCL27 into a single Lisp source file, and load that file into Clozure CL 28 28 when we are ready to build the application.</p> 29 29 … … 37 37 <pre>(in-package "CCL")</pre> 38 38 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" 40 40 package. Usually, when building an application, you'll create a 41 41 package for that application and import the definitions you need … … 68 68 simple wrinkles. First, the superclass it inherits from is the 69 69 NS-OBJECT class in the "NS" package. NS-OBJECT is an Objective C 70 class, the ancestor of all Objective C objects. This CLOS E70 class, the ancestor of all Objective C objects. This CLOS 71 71 definition actually creates a new Objective C class named 72 72 "Converter".</p> 73 73 74 <p>We tell OpenMCL how to build the right kind of class object74 <p>We tell Clozure CL how to build the right kind of class object 75 75 by including the :METACLASS option in the definition:</p> 76 76 … … 94 94 <p>This is the method that actually does the currency 95 95 conversion. It's very simple—really, it just multiples 96 currency times rate. Most of the text in the definition is96 <code>currency</code> times <code>rate</code>. Most of the text in the definition is 97 97 Objective C bridge code that links the definition to the right 98 98 class with the right argument and return types.</p> … … 102 102 103 103 <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> 114 116 115 117 <p>We indicate the return type and the types of arguments in … … 169 171 170 172 <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> 177 183 178 184 <p>The <code>converter</code> field at launch time contains a … … 201 207 "convertCurrency:atRate:" method of the Converter class. It then 202 208 sets the text of the amount-field to reflect the result of the 203 conversion. The only si ngificant difference between this209 conversion. The only significant difference between this 204 210 implementation and Apple's is that the code is written in Lisp 205 211 rather than Objective C.</p>
Note:
See TracChangeset
for help on using the changeset viewer.
