开发者

how to write a layout manager?

I'd like write a layout manager for j2me. I already have widgets and panels (panel is a set of widgets in this context). Now I'd like to add dynimc layout management so when i call doLayout on the outer most panel, internal widgets and panels rearra开发者_开发知识库nge according device's width and height.

I was wondering whether there any well known patterns for layout managers.


Each UI object should return a "minimum size (w,h)". Then you need an algorithm that traverse all your objects and split the available area in chunks and assign each chunk to an object. You can Tree-Partition it based on the object relevance.


Common approach which I know is to keep each Displayable in Stack collection, such that current panel/screen should always be on top of Stack. And when user press "back" button you just should pop previous screen/panel on top of Stack.

Example can be found here


In my experience my layout managers have evolved to fit the platform (X11,VT100,Windows) and their characteristics. However I have found common characteristics. Here is a good read/starting point that incorporates design patterns into our GUI challenges.

Reference: Layout Manager using Design Patterns

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜