I'm trying to create a "component" which is basically a view that has a border around its content. What I've done so far is the following (simplified version): <view name="bordered_panel" width="200" height="100" bgcolor="white"> <view name="outer_frame" x="5" y="5" width="${immediateparent.width - 10}" height="${immediateparent.height - 10}" bgcolor="black"> <view name="inside_frame" x="1" y="1" width="${immediateparent.width - 2}" height="${immediateparent.height - 2}" bgcolor="white"> <view name="content" x="5" y="5" width="${immediateparent.width - 10}" height="${immediateparent.height - 10}"> <text resize="true">The contents</text> </view> </view> </view> </view> Which seems very complicated just to do that simple border and add some padding (margin) around the contents. So, if we refactored this into a class: <class name="bordered_panel" width="200" height="100" bgcolor="white" defaultplacement="content"> <view name="outer_frame" x="5" y="5" width="${immediateparent.width - 10}" height="${immediateparent.height - 10}" bgcolor="black"> <view name="inside_frame" x="1" y="1" width="${immediateparent.width - 2}" height="${immediateparent.height - 2}" bgcolor="white"> <view name="content" x="5" y="5" width="${immediateparent.width - 10}" height="${immediateparent.height - 10}" /> </view> </view> </class> which would allow me to do something more simple like: <bordered_panel width="300" height="100"> <text resize="true">This is now the new content</text> </bordered_panel> So, after the class is created, the using of it is definitely simpler and elegant. However, I don't feel comfortable with the actual class definition. I think it feels like a heavy definition for such a simple task. (Note: my actual class extends basecomponent in order to make is style-aware and defines _applystyle as apropriate so colors are not always hardcoded but it uses styles, if applicable). I know it could even be further enhanced into accepting inset and bordersize values to specify the margin around the content and the thickness of the border, but we can put than on the side for the moment. My question: Is there a better/more elegant way of doing this? Thanks, Daniel |
_______________________________________________ Laszlo-user mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-user
