Browse code
Cleanup main: buttons don't work because not wired
Ed L authored on 09/01/2018 09:40:56
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -112,87 +112,24 @@ |
112 | 112 |
[button set-target :pointer result] |
113 | 113 |
[button set-action :pointer do-magic])))) |
114 | 114 |
|
115 |
-(defparameter *main-task* nil) |
|
116 | 115 |
(defun main () |
117 |
- ;; (break) |
|
118 |
- (setf *main-task* |
|
119 |
- (trivial-main-thread:with-body-in-main-thread (:blocking t) |
|
120 |
- (with-selectors ((shared-application "sharedApplication") |
|
121 |
- (process-info "processInfo") |
|
122 |
- (process-name "processName") |
|
123 |
- (set-activation-policy "setActivationPolicy:") |
|
124 |
- ;; (init-with-content-rect "initWithContentRect:styleMask:backing:defer:") |
|
125 |
- (set-title "setTitle:") |
|
126 |
- (run "run") |
|
127 |
- (activate-ignoring-other-apps "activateIgnoringOtherApps:") |
|
128 |
- (make-key-and-order-front "makeKeyAndOrderFront:") |
|
129 |
- (cascade-top-left-from-point "cascadeTopLeftFromPoint:") |
|
130 |
- (add-item "addItem:") |
|
131 |
- (set-main-menu "setMainMenu:") |
|
132 |
- (init-with-title "initWithTitle:action:keyEquivalent:") |
|
133 |
- (set-submenu "setSubmenu:") |
|
134 |
- (init-with-encoding "initWithCString:length:") |
|
135 |
- (content-view "contentView") |
|
136 |
- (add-subview "addSubview:") |
|
137 |
- (set-target "setTarget:") |
|
138 |
- (set-action "setAction:") |
|
139 |
- terminate? |
|
140 |
- ;; (application-should-terminate "applicationShouldTerminate:") |
|
141 |
- ;; (set-delegate "setDelegate:") |
|
142 |
- ;; (finish-launching "finishLaunching") |
|
143 |
- alloc new autorelease |
|
144 |
- ) |
|
145 |
- [#@NSAutoReleasePool new] |
|
146 |
- [#@NSApplication shared-application] |
|
147 |
- [objc-runtime::ns-app set-activation-policy :int 0] |
|
148 |
- |
|
149 |
- (let ((app-delegate (objc-runtime::objc-allocate-class-pair #@NSObject |
|
150 |
- "AppDelegate" |
|
151 |
- 0))) |
|
152 |
- (objc-runtime::add-pointer-ivar app-delegate "window") |
|
153 |
- (objc-runtime::add-pointer-ivar app-delegate "delegate")) |
|
154 |
- |
|
155 |
- (let* ((bundle [#@NSBundle @(mainBundle)]) |
|
156 |
- (nib [[#@NSNib @(alloc)] @(initWithNibNamed:bundle:) |
|
157 |
- :pointer @"MainMenu" |
|
158 |
- :pointer bundle])) |
|
159 |
- (cffi:with-foreign-object (p :pointer) |
|
160 |
- [nib @(instantiateWithOwner:topLevelObjects:) |
|
161 |
- :pointer objc-runtime::ns-app |
|
162 |
- :pointer p])) |
|
163 |
- [ objc-runtime::ns-app activate-ignoring-other-apps :boolean t] |
|
164 |
- [ objc-runtime::ns-app run] |
|
165 |
- ;; (break) |
|
166 |
- #+null |
|
167 |
- (let* ((application-name [[#@NSProcessInfo process-info] process-name])) |
|
168 |
- (let* ((menubar [[#@NSMenu new] autorelease]) |
|
169 |
- (app-menu-item [[#@NSMenuItem new] autorelease]) |
|
170 |
- (app-menu [[#@NSMenu new] autorelease]) |
|
171 |
- (quit-name [[#@NSString alloc] init-with-encoding :string "Quit" :uint 4]) |
|
172 |
- (key [[#@NSString alloc] init-with-encoding :string "q" :uint 1]) |
|
173 |
- (quit-menu-item |
|
174 |
- [[[#@NSMenuItem alloc] init-with-title :pointer quit-name :pointer terminate? :string key] autorelease])) |
|
175 |
- [menubar add-item :pointer app-menu-item] |
|
176 |
- [app-menu add-item :pointer quit-menu-item] |
|
177 |
- [app-menu-item set-submenu :pointer app-menu] |
|
178 |
- [objc-runtime::ns-app set-main-menu :pointer menubar] ) |
|
179 |
- |
|
180 |
- (with-point (p (20 20)) |
|
181 |
- (let* ((foreign-rect (make-rect 10 10 120 120)) |
|
182 |
- (the-window (init-window [#@NSWindow alloc] foreign-rect 1 2 nil)) |
|
183 |
- (the-button |
|
184 |
- (init-with-frame [#@NSButton alloc] (make-rect 10 10 100 35))) |
|
185 |
- (the-button1 |
|
186 |
- (init-with-frame [#@NSButton alloc] (make-rect 10 55 100 35))) |
|
187 |
- ) |
|
188 |
- |
|
189 |
- [the-button set-title :pointer @"Click me!"] |
|
190 |
- (make-button-delegate the-button) |
|
191 |
- (make-button-delegate the-button1) |
|
192 |
- [(value-for-key the-window "contentView") add-subview :pointer the-button] |
|
193 |
- [(value-for-key the-window "contentView") add-subview :pointer the-button1] |
|
194 |
- [the-window cascade-top-left-from-point :pointer p] |
|
195 |
- [the-window set-title :pointer application-name] |
|
196 |
- [the-window make-key-and-order-front :pointer (cffi:null-pointer)] |
|
197 |
- [ objc-runtime::ns-app activate-ignoring-other-apps :boolean t] |
|
198 |
- [ objc-runtime::ns-app run]))))))) |
|
116 |
+ (trivial-main-thread:with-body-in-main-thread (:blocking t) |
|
117 |
+ [#@NSAutoReleasePool @(new) ] |
|
118 |
+ [#@NSApplication @(sharedApplication) ] |
|
119 |
+ [objc-runtime::ns-app @(setActivationPolicy:) :int 0] |
|
120 |
+ |
|
121 |
+ (let ((app-delegate (objc-runtime::objc-allocate-class-pair |
|
122 |
+ #@NSObject "AppDelegate" 0))) |
|
123 |
+ (objc-runtime::add-pointer-ivar app-delegate "window") |
|
124 |
+ (objc-runtime::add-pointer-ivar app-delegate "delegate")) |
|
125 |
+ |
|
126 |
+ (let* ((bundle [#@NSBundle @(mainBundle)]) |
|
127 |
+ (nib [[#@NSNib @(alloc)] @(initWithNibNamed:bundle:) |
|
128 |
+ :pointer @"MainMenu" |
|
129 |
+ :pointer bundle])) |
|
130 |
+ (cffi:with-foreign-object (p :pointer) |
|
131 |
+ [nib @(instantiateWithOwner:topLevelObjects:) |
|
132 |
+ :pointer objc-runtime::ns-app |
|
133 |
+ :pointer p])) |
|
134 |
+ [objc-runtime::ns-app @(activateIgnoringOtherApps:) :boolean t] |
|
135 |
+ [objc-runtime::ns-app @(run) ])) |