I'm creating a webapp in Cappuccino, and I need a way to draw shapes (rectangles, images etc) onto a CPWindow. Is there any widget/control I can use to do this? Are there any controls like this in other frameworks like Sproutcore? Or do I have to implement my own?
I'd also like to know if there's a way of making shapes draggable like this?
In Cappuccino you can perform custom drawing in any view. To do this, override the
drawRect:method (of anything that inherits fromCPView, which is pretty much every control). You can either use the CPGraphics tools likeCPBezierPath, or you can draw using CoreGraphics with commands likeCGContextAddPath- to learn more about this latter style of drawing the Apple docs on Core Graphics for Mac OS X are helpful. Remember that Cappuccino is based on Objective-C and Cocoa.Here's an example view that draws a yellow star with a dotted border in a rounded rectangle, sized to fit the current view:
I extracted this from a larger set of drawing tests in Cappuccino.
Under the hood, Cappuccino will either use a canvas, when available, or VML when necessary (for some versions of IE).