[Openmcl-devel] Using the COCOA BRIDGE

Oscar Chappel oachappel at yahoo.com
Fri Jun 30 17:37:14 UTC 2017


Hello,
I have just implemented the show-red-window function described in the COCOA BRIDGE page.  When I execute the function I get an instance of the RED-VIEW class that I can inspect and describe.  I can not get this instance to display itself.  Here is the source code:

(in-package "CL-USER")

(require "COCOA")

(defclass red-view (ns:ns-view)
  ()
  (:metaclass ns:+ns-object))

(objc:defmethod (#/drawRect: :void) ((self red-view) (rect :<NSR>ect))
  (#/set (#/redColor ns:ns-color))
  (#_NSRectFill (#/bounds self)))

(defun show-red-window ()
  (ccl::with-autorelease-pool
      (let* ((rect (ns:make-ns-rect 0 0 300 300))
             (w (make-instance 'ns:ns-window
                  :with-content-rect rect
                  :style-mask (logior #$NSTitledWindowMask
                                      #$NSClosableWindowMask
                                      #$NSMiniaturizableWindowMask)
                  :backing #$NSBackingStoreBuffered
                  :defer t)))
        (#/setTitle: w #@"Red Window")
        (#/setContentView: w (#/autorelease (make-instance 'red-view)))
        (#/center w)
        (#/orderFront: w nil)
        (#/contentView w))))

The results of executing show-red-window and describing the resulting instance:

(setf win (show-red-window))
#<RED-VIEW <RedView: 0x6180001203c0> (#x6180001203C0)>
? win
#<RED-VIEW <RedView: 0x6180001203c0> (#x6180001203C0)>
? (describe win)
#<RED-VIEW <RedView: 0x6180001203c0> (#x6180001203C0)>
Class: #<OBJC:OBJC-CLASS RED-VIEW (#x60800005C020)>
Wrapper: #<CCL::CLASS-WRAPPER RED-VIEW #x302000EB514D>
Instance slots
NS:ISA: #<A Foreign Pointer #x1DE0800005C021>
NS:_NEXT-RESPONDER: #<NS-WINDOW <NSWindow: 0x6100001ed200> (#x6100001ED200)>
NS:_FRAME: #<NS-RECT 300 X 300 @ 0,0 (#x6180001203D0) #x302000F7B72D>
NS:_BOUNDS: #<NS-RECT 300 X 300 @ 0,0 (#x6180001203F0) #x302000F7ADDD>
NS:_SUPERVIEW: #<NS-VIEW <NSThemeFrame: 0x306192f0> (#x306192F0)>
NS:_SUBVIEWS: #<A Null Foreign Pointer>
NS:_WINDOW: #<NS-WINDOW <NSWindow: 0x6100001ed200> (#x6100001ED200)>
NS:_G-STATE: #<A Null Foreign Pointer>
NS:_FRAME-MATRIX: #<A Null Foreign Pointer>
NS:_LAYER: #<A Null Foreign Pointer>
NS:_DRAG-TYPES: #<A Null Foreign Pointer>
NS:_VIEW-AUXILIARY: #<A Foreign Pointer (:*
                                         (:STRUCT
                                          :_<NSV>IEW<A>UXILIARY)) #x2191340>
NS:_V-FLAGS: #<A Foreign Pointer (:* (:STRUCT :__<VF>LAGS)) #x618000120450>
NS:_V-FLAGS-2: #<A Foreign Pointer (:* (:STRUCT :__<VF>LAGS2)) #x618000120454>

Am I missing something?  Can anyone help me out?  Thanks.

Oscar Chappel




More information about the Openmcl-devel mailing list