complex packing problem



I have a large number of small, identical widgets that I need to arrange in a grid. The trick is, I want the dimensions of the grid to change with the toplevel's window size, and the widgets to be packed in a linear order that tracks the grid dimensions.

For example, if I have 12 widgets A - L, and the toplevel is approximately square, I want them to pack this way:

A  E  I
B  F  J
C  G  K
D  H  L

But if the user resizes the window to be long and skinny left-to- right, I want them to go this way:

A  C  E  G  I  K
B  D  F  H  J  L

Similarly, if the user makes the window skinny vertically:

A  G
B  H
C  I
D  J
E  K
F  L

Can anyone suggest a general strategy for making this work? In practice, the number of widgets will be in the hundreds, not 12.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]