This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Prototype Powertool: VisualBlock
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
One of the coolest objects in the graphics/view framework for VisualWorks is the VisualBlock.
VisualBlock is a block with a bounds. Many of the views/widgets we put together are just a fancy displayOn: message. It came in really handy, in creating an "icon" that was two OpaqueImages side by side. Given the desire to create an "aggregate" icon by showing two OpaqueImages side by side, you have a couple of choices:
Create a special object. A subclass of VisualComponent. Two instance variables. Add the various bounds messages. Your displayOn: message. If this is a very common thing to do in your system, then this is actually probably the right thing to do.
Synthesize a new OpaqueImage which is the two put together. Means you have to create a separate Mask and Pixmap, draw the OpaqueImage figures/shapes onto it at the right places. Return a new OpaqueImage after turning them back into Images. Kind of yecky, and it'll work the heck out of your graphics server.
To me, the VisualBlock is very appealing. It was quick and easy to throw together. I can experiment with different layouts. And it doesn't thrash the graphics layer.
VisualBlock exists under the current "wrappers" framework, I have no idea if there's such a thing for Pollock yet. But if there's not, I'll bet its one of the first things I slap together.