<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I'm a mac guy, not windows, but just so you know, your code works just fine on a mac (i.e. the button shows immediately on being added to the window). The only thing I can think to try might be to call (#/setNeedsDisplay: (#/contentView my-window1) #$YES) to force a window re-draw after the button is added. That shouldn't be necessary, but who knows ...<div><br></div><div>Paul</div><div><br><div><div>On Jul 26, 2011, at 3:02 PM, Greg Bennett wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div bgcolor="#FFFFFF" text="#000000">
<font size="+1"><font face="Arial">Good morning from Greg Bennett<br>
I am trying to understand the relationship between the handling
of subviews and<br>
the display of their host windows/views under MS-Windows. <br>
<br>
What follows is a blow-by-blow account of my attempts to follow
two of the supplied examples, <br>
which I realise are directed to those using Mac OS rather than
Windows. <br>
<br>
If I this is not the right place for such posts, or if I have
been too verbose, please let me know.<br>
Perhaps there is documentation about what I observe. If so, I
should be delighted to receive a<br>
pointer to it.<br>
<br>
I have used ;-> to show lines returned by CCL<br>
<br>
Thanks for any and all advice and comment<br>
Cheers /Greg Bennett<br>
<br>
;; In Clozure CL Version 1.7-dev-r14869 (WindowsX8632)!<br>
;; Running under Windows7 Pro 64bit<br>
;; Using 32bit executables and listener <br>
<br>
;; Initially, code from
ccl/examples/cocoa/ui-elements//HOWTO.html<br>
(in-package :ccl)<br>
;->#<Package "CCL"><br>
<br>
;; First sequence<br>
;; (a) allocate my-window1<br>
;; (b) equip it with attributes<br>
;; (c) show it<br>
;; (d) allocate my-button<br>
;; (e) equip it too<br>
;; (f) add my-button as a subview to my-window1<br>
;; (g) add a label to my-button<br>
<br>
(setf my-window1 (#/alloc (@class ns-window)))<br>
;->#<NS-WINDOW [uninitialized] (#x3591640)><br>
(ns:with-ns-rect (r 100 100 400 300)<br>
(#/initWithContentRect:styleMask:backing:defer: <br>
my-window1 <br>
r <br>
(logior #$NSTitledWindowMask <br>
#$NSClosableWindowMask <br>
#$NSMiniaturizableWindowMask <br>
#$NSResizableWindowMask)<br>
#$NSBackingStoreBuffered<br>
#$NO))<br>
;->;Compiler warnings :<br>
;->; In an anonymous lambda form at position 93: Undeclared
free variable MY-WINDOW1<br>
;->#<NS-WINDOW <NSWindow 0x03591640> (#x3591640)>
<br>
(#/makeKeyAndOrderFront: my-window1 nil)<br>
;->NIL<br>
<br>
;;; .. and there is the window<br>
<br>
(setf my-button (#/alloc ns:ns-button))<br>
;->#<NS-BUTTON [uninitialized] (#x36981D0)><br>
(ns:with-ns-rect (frame 10 10 72 32)<br>
(#/initWithFrame: my-button frame)<br>
(#/setButtonType: my-button #$NSMomentaryPushInButton)<br>
(#/setImagePosition: my-button #$NSNoImage)<br>
(#/setBezelStyle: my-button #$NSRoundedBezelStyle))<br>
;->;Compiler warnings :<br>
;->; In an anonymous lambda form at position 183:
Undeclared free variable MY-BUTTON (4 references)<br>
;->NIL <br>
(#/addSubview: (#/contentView my-window1) my-button)<br>
;->NIL<br>
<br>
;;; and my-window1 is unchanged in appearance<br>
<br>
;;; Check on the subviews of my-window1<br>
<br>
(#/subviews (#/contentView my-window1))<br>
;->#<NS-MUTABLE-ARRAY (<br>
;-> "<NSButton[0x36981d0] frame: {{10, 10}, {72, 32}}>"<br>
;-> ) (#x35F19E8)><br>
<br>
;;; so the data structure behind my-window1 seems to know about
the button<br>
<br>
(let ((label (%make-nsstring "Hello!")))<br>
(#/setTitle: my-button label)<br>
(#/release label))<br>
;->;Compiler warnings :<br>
;->; In an anonymous lambda form at position 57: Undeclared
free variable MY-BUTTON<br>
;->NIL <br>
<br>
;;; nothing shows in my-window1<br>
<br>
;; Second sequence with my-window2 for my-window1 <br>
;; switching adding the subview and showing the window<br>
;; (a) allocate my-window2<br>
;; (b) equip it with attributes<br>
;; (f) add my-button as a subview to my-window2<br>
;; (c) show my-window2<br>
<br>
(setf my-window2 (#/alloc (@class ns-window)))<br>
;->#<NS-WINDOW [uninitialized] (#x35D8C50)><br>
(ns:with-ns-rect (r 100 100 400 300)<br>
(#/initWithContentRect:styleMask:backing:defer: <br>
my-window2 <br>
r <br>
(logior #$NSTitledWindowMask <br>
#$NSClosableWindowMask <br>
#$NSMiniaturizableWindowMask <br>
#$NSResizableWindowMask)<br>
#$NSBackingStoreBuffered<br>
#$NO))<br>
;->;Compiler warnings :<br>
;->; In an anonymous lambda form at position 93: Undeclared
free variable MY-WINDOW2<br>
;->#<NS-WINDOW <NSWindow 0x035d8c50>
(#x35D8C50)> <br>
(#/addSubview: (#/contentView my-window2) my-button)<br>
;->NIL<br>
(#/makeKeyAndOrderFront: my-window2 nil) <br>
;->NIL<br>
<br>
;;; There is my-window2 complete with button which shows Hello!<br>
;;; Hence the label was indeed added to the button under<br>
;;; the First sequence.<br>
<br>
::: It seems that I can assemble a composite view and then
successfully display<br>
;;; the whole thing, but not display part of it and then add the
rest. But what<br>
;;; follows has me wondering about such a simple dichotomy ..<br>
<br>
;;; Third sequence<br>
;;; Now some code from
<a class="moz-txt-link-freetext" href="http://trac.clozure.com/ccl/wiki/CocoaBridge">http://trac.clozure.com/ccl/wiki/CocoaBridge</a><br>
;;; but operating in the :ccl package still<br>
(defclass red-view (ns:ns-view)<br>
()<br>
(:metaclass ns:+ns-object))<br>
;->#<OBJC:OBJC-CLASS RED-VIEW (#x35EA810)><br>
(objc:defmethod (#/drawRect: :void) ((self red-view) (rect
:<NSR>ect))<br>
(#/set (#/redColor ns:ns-color))<br>
(#_NSRectFill (#/bounds self)))<br>
;->|-[RedView drawRect:]|<br>
(defun show-red-window ()<br>
(ccl::with-autorelease-pool<br>
(let* ((rect (ns:make-ns-rect 0 0 300 300))<br>
(w (make-instance 'ns:ns-window<br>
:with-content-rect rect<br>
:style-mask (logior #$NSTitledWindowMask<br>
#$NSClosableWindowMask<br>
#$NSMiniaturizableWindowMask)<br>
:backing #$NSBackingStoreBuffered<br>
:defer t)))<br>
(#/setTitle: w #@"Red")<br>
(#/setContentView: w (#/autorelease (make-instance
'red-view)))<br>
(#/center w)<br>
(#/orderFront: w nil)<br>
(#/contentView w))))<br>
;->SHOW-RED-WINDOW <br>
(defmacro with-focused-view (view &body forms)<br>
`(when (#/lockFocusIfCanDraw ,view)<br>
(unwind-protect<br>
(progn ,@forms)<br>
(#/unlockFocus ,view)<br>
(#/flushGraphics (#/currentContext
ns:ns-graphics-context))<br>
(#/flushWindow (#/window ,view)))))<br>
;->WITH-FOCUSED-VIEW<br>
(setf *v* (show-red-window))<br>
;->#<RED-VIEW <RedView[0x45726578] frame: {{3, 3},
{300, 300}}> (#x45726578)><br>
<br>
;;; there is the red window<br>
<br>
;;; Modify the "More drawing" code of this example to<br>
;;; (1) draw a line diagonally across the view, and<br>
;;; (2) omit the "hello world" text <br>
<br>
(with-focused-view *v*<br>
(let* ((path (#/bezierPath ns:ns-bezier-path)))<br>
(#/moveToPoint: path (ns:make-ns-point 10 10))<br>
(#/lineToPoint: path (ns:make-ns-point 300 300))<br>
(#/stroke path)<br>
))<br>
;;; now there is a diagonal line (lower left -> upper right)<br>
<br>
;;; Add my-button to this<br>
(#/addSubview: *v* my-button)<br>
<br>
;;; There is the button too (with "Hello!"), BUT with a piece of
the<br>
;;; diagonal line missing (from (0,0) to just above the "e"<br>
;;; on the button.<br>
<br>
;;; Thus I have been able to make a piece of a view, show it,
and<br>
;;; then add to it, unlike what happened in the First sequence.
<br>
<br>
;;; So is it possible that my-button really was drawn in my
first sequence,<br>
;;; but in the background colour of its window ?<br>
<br>
;; add a title to the button<br>
(#/setTitle: my-button #@"Zootlewirdle")<br>
;;;the title has changed, showing just the quartet ("rdle") <br>
;;; so that I can modify part of an already displayed view.<br>
<br>
Again, thanks for any and all assistance. <br>
</font></font>
</div>
_______________________________________________<br>Openmcl-devel mailing list<br><a href="mailto:Openmcl-devel@clozure.com">Openmcl-devel@clozure.com</a><br>http://clozure.com/mailman/listinfo/openmcl-devel<br></blockquote></div><br></div></body></html>