Re: objective-c bridge question
On Oct 14, 2010, at 10:50 AM, Dave Fox wrote:
>
>
>> For reference, here's a short list of things I couldn't see how to
>> do in CAPI, and so needed to drop down to the Objective-C API to
>> reproduce (these are all features inherited from the
>> Gambit-Scheme/Objective-C version of my app):
>>
>> - make a window with the standard disclosure lozenge at the top
>> right (for showing and hiding a toolbar)
>
> As Sven already mentioned, this is supported in LispWorks 6.0.
I really need to upgrade. Real Soon Now, after I've driven the wolf a few steps farther from my door.
>
>> - make unbordered buttons with transparent backgrounds
>
> Please could you clarify what you mean here? What is actually drawn on
> screen and how are they different when pressed or disabled? Which
> Objective-C API did you use?
I have two cases, both of which use PNG images with transparent backgrounds as the button image. As one example, consider the Trash Can image used in the Mac OS X dock. Imagine a button that shows its empty image when there are no currently-deleted items, and which shows its full image when there are currently-deleted items. With a well-designed icon like that one, the image itself is quite sufficient for use as a control; no additional button decorations are needed; indeed, adding them just makes the button look bulky and clumsy.
In order to get the effect I want for the buttons in question, I use code like the following.
In one case, for a button that responds to a click, with a transient highlighted state as long as the mouse button is held down on the button:
(invoke view "setBordered:" nil)
(invoke view "setTitle:" label)
(invoke view "setImagePosition:" $NSImageAbove)
(invoke view "setButtonType:" $NSMomentaryChangeButton)
(invoke view "setImage:" $unhighlighted-image)
(invoke view "setAlternateImage:" $highlighted-image)
The second case is identical, except that the button acts as a toggle, so instead of a button Type of $NSMomentaryChangeButton, I use $NSToggleButton. (I didn't notice these Cocoa constants being predefined in Lispworks as they are with CCL when using the Cocoa headers, so I manually defined them. I may, of course, simply have overlooked them.)
>
>> - make an NSSearchField element
>
> This will be in the next LispWorks product release. (There's no date
> set for that yet.)
Great!
>> - make a multi-column-list-panel that draws itself with alternating
>> background colors
>
> We will consider adding that.
As Jochen Schmidt mentioned, when using an NSTableView I get that effect by doing:
(invoke table-view "setUsesAlternatingRowBackgroundColors:" t)
Of course, using NSTableView rather than multi-column-list-panel carries with it the cost of considerably more use of the Cocoa APIs--I have to define an implementation of NSDataSource and the appropriate methods for it, and that means defined its protocol first, and so forth.
It does, however, work, so thanks!
--me