- Timestamp:
- Dec 2, 2007, 2:45:42 AM (17 years ago)
- Location:
- branches/working-0711/ccl/examples/cocoa/currency-converter
- Files:
-
- 3 added
- 3 deleted
- 10 edited
-
CurrencyConverter.nib/classes.nib (deleted)
-
CurrencyConverter.nib/designable.nib (added)
-
CurrencyConverter.nib/info.nib (deleted)
-
CurrencyConverter.nib/keyedobjects.nib (modified) ( previous)
-
CurrencyConverter.xib (added)
-
HOWTO.html (modified) (5 diffs)
-
HOWTO_files/pages/build_app.html (modified) (6 diffs)
-
HOWTO_files/pages/building_ide.html (deleted)
-
HOWTO_files/pages/building_ui.html (modified) (2 diffs)
-
HOWTO_files/pages/building_ui_tiger.html (added)
-
HOWTO_files/pages/conclusion.html (modified) (2 diffs)
-
HOWTO_files/pages/create_lisp.html (modified) (2 diffs)
-
HOWTO_files/pages/making_project.html (modified) (2 diffs)
-
HOWTO_files/pages/writing_lisp.html (modified) (9 diffs)
-
HOWTO_files/stylesheets/styles.css (modified) (1 diff)
-
currency-converter.lisp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO.html
r7435 r7803 15 15 <div class="subtitle"> 16 16 <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"> 18 18 Currency Converter</a> example<br/> 19 19 with OpenMCL … … 34 34 Cocoa application that is functionally identical to Apple's 35 35 <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"> 37 37 Currency Converter</a> example. The most important 38 38 difference between Apple's example and this one is that this … … 64 64 <p>It will be helpful in understanding this example if you can 65 65 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"> 67 67 Currency Converter</a> example while working through this 68 68 HOWTO. You might consider opening a separate window or tab, and … … 73 73 same. In particular, the Lisp example follows the same 74 74 <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"> 76 76 Model-View-Controller</a> paradigm that the Apple example 77 77 uses. If you are new to Cocoa programming, or if you are not … … 102 102 103 103 <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> 107 106 <li><p>Apple's XCode development tools</p></li> 108 107 <li><p>Apple's InterfaceBuilder application (included with XCode)</p></li> 109 108 <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> 112 110 <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"> 114 112 Currency Converter</a> example, for reference</p></li> 115 113 </ul> -
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/build_app.html
r7435 r7803 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 -
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/building_ui.html
r7435 r7803 20 20 describes in detail</a> how to do this.</p> 21 21 22 <div class="section-head"> 23 <h2>Apple's Tutorial</h2> 24 </div> 25 22 26 <p>Apple's tutorial explains how to use InterfaceBuilder to create the 23 27 user interface, and how to use XCode to create project files and … … 26 30 the part of the tutorial that explains how to use XCode.</p> 27 31 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—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 58 119 59 120 <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 121 called <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 62 124 nibfiles, and follow the instructions to create the Currency Converter 63 125 interface. (Remember that when the tutorial tells you to open and edit 64 126 "MainMenu.nib", you will instead open and edit your 65 127 "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 128 called <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 132 application. 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 74 318 <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> 76 320 </div> 77 321 -
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/conclusion.html
r7435 r7803 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 -
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/create_lisp.html
r7435 r7803 20 20 application to create and manage projects, to edit Objective C 21 21 source files, and to build the final application. In this HOWTO, 22 Clozure's OpenMCL application takes the place of XCode. The23 Lispproject structure is much simpler than the XCode project22 the Clozure CL application takes the place of XCode. The Lisp 23 project structure is much simpler than the XCode project 24 24 structure: to build the Lisp application we need only the 25 25 nibfile created in the previous section, and a single Lisp 26 26 source file.</p> 27 27 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> 36 29 37 30 <div class="subtitle"> … … 51 44 52 45 <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> 54 47 </div> 55 48 -
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/pages/making_project.html
r7435 r7803 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 41 41 application, though not all applications are as simple as this 42 42 currency converter. For more complex applications it makes sense 43 to split you UI into several nibfiles, and to split your43 to split your UI into several nibfiles, and to split your 44 44 implementation into several source files. The basic principle 45 45 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 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 the20 section <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjCTutorial/ chapter04/chapter_4_section_1.html">Implementing21 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> 22 22 23 23 <p>The Lisp code in this section of the HOWTO is considerably … … 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 "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> 177 187 178 188 <p>The final piece of the implementation is a definition of the … … 197 207 "convertCurrency:atRate:" method of the Converter class. It then 198 208 sets the text of the amount-field to reflect the result of the 199 conversion. The only si ngificant difference between this209 conversion. The only significant difference between this 200 210 implementation and Apple's is that the code is written in Lisp 201 211 rather than Objective C.</p> … … 208 218 209 219 <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> 211 221 </div> 212 222 -
branches/working-0711/ccl/examples/cocoa/currency-converter/HOWTO_files/stylesheets/styles.css
r7435 r7803 33 33 } 34 34 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 35 42 .inline-image { 36 43 text-align: center; -
branches/working-0711/ccl/examples/cocoa/currency-converter/currency-converter.lisp
r7435 r7803 43 43 (ccl::build-application :name "CurrencyConverter" 44 44 :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"))) 46 47 47 48 TODO NOTES:
Note:
See TracChangeset
for help on using the changeset viewer.
