source: trunk/source/examples/cocoa/nib-loading/nib-loading.lisp @ 8479

Last change on this file since 8479 was 8479, checked in by mikel, 12 years ago

edits to the nob-loading HOWTO

File size: 1.5 KB
Line 
1;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: cl-user -*-
2;;;; ***********************************************************************
3;;;; FILE IDENTIFICATION
4;;;;
5;;;; Name:          nib-loading.lisp
6;;;; Version:       0.1
7;;;; Project:       cocoa examples
8;;;; Purpose:       examples of loading nibs dynamically in the IDE
9;;;;
10;;;; ***********************************************************************
11
12(in-package :ccl)
13
14(defun load-nibfile (nib-path)
15  (let* ((appclass (#_NSClassFromString (%make-nsstring "NSApplication")))
16         (app (#/sharedApplication appclass))
17         (app-zone (#/zone app))
18         (nib-name (%make-nsstring (namestring nib-path)))
19         (toplevel-objects-array (#/arrayWithCapacity: (@class ns-mutable-array) 8))
20         (context (#/dictionaryWithObjectsAndKeys: (@class ns-mutable-dictionary)
21                                                   app #@"NSNibOwner" 
22                                                   toplevel-objects-array #@"NSNibTopLevelObjects"))
23         (load-succeeded-p (#/loadNibFile:externalNameTable:withZone: (@class ns-bundle)
24                                                                      nib-name context app-zone)))
25    (values load-succeeded-p context)))
26
27(setf  *my-app*
28       (let* ((class-name (%make-nsstring "NSApplication"))
29              (appclass (#_NSClassFromString class-name)))
30         (#/release class-name)
31         (#/sharedApplication appclass)))
32
33
34#|
35(ccl::load-nibfile "/usr/local/openmcl/trunk/source/examples/cocoa/nib-loading/hello.nib")
36|#
Note: See TracBrowser for help on using the repository browser.