How can plugin provide a "Paint(g as Graphics)" event?

[quote=315659:@Thomas Tempelmann]Alfred, I appreciate you trying to explain this to me. I must admit that I still only understand half of it as I am not doing any Plugin development. I only started this thread because I want this feature, and Christian said he can’t make it work. Then, here, Björn said so, too. Then you said “try this”. But you never said that you know that this will work - so, do you only suspect it could work, or did you actually manage to implement a “Paint(g as Graphics)” event for a plugin-based control that’s invoked by a NSView’s drawRect or similar overwritten method? Or Björn, did Alfred’s example open your eyes and now you agree that this can be done?

And yes, I undertstand that NSCell-based TableViews are an older concept, but I need it for (a) 10.6 support and (b) because it makes things easier for simulating a ListBox control.[/quote]

I don’t understand either how it is supposed to work Thomas. But Alfred has a habit of getting things to work so I would not rule it out even if we do not fully understand it.

The HostedPlugin example does not cut it:

static REALcontrolBehaviour sLevelIndicatorBehavior = {
	RatingControlInitializer,
	RatingControlFinalizer,
	NULL, // redrawFunction
	NULL, // clickFunction
	NULL, // mouseDragFunction
	NULL, // mouseUpFunction
	NULL, // gainedFocusFunction
	NULL, // lostFocusFunction
	NULL, // keyDownFunction
	NULL, // openFunction
	NULL, // closeFunction
	NULL, // backgroundIdleFunction
	NULL, // drawOffscreenFunction
	NULL, // setSpecialBackground
	NULL, // constantChanging
	NULL, // droppedNewInstance
	NULL, // mouseEnterFunction
	NULL, // mouseExitFunction
	NULL, // mouseMoveFunction
	NULL, // stateChangedFunction
	NULL, // actionEventFunction
	RatingControlHandleGetter
};

Because when you implement the ControlHandleGetter (see above) the redraw call back I mentioned is not invoked. So don’t implement this getter and use the following in the openFunction behavior:

#if TARGET_COCOA
	REALwindow rwin = REALGetControlWindow(instance);
	if (rwin) {
		NSWindow* nswin = REALGetWindowHandle(rwin);
		[[nswin contentView] addSubview:yourTarget];
	}
#endif

All I can say is that it is not made up.