Home » Developing U++ » UppHub » Grid helper
Grid helper [message #30432] |
Thu, 30 December 2010 17:38  |
|
In the past I ran quite a few times into situation where I needed to position several Ctrls into a rectangular grid. Doing this correctly (so that everything is scaled properly when resizing etc.) is a nightmare. So I decided to write a helper Ctrl called Grid (do not confuse with GridCtrl ), which does all the dirty work.
The basic idea is that Grid gives you a x*y equidistant ParentCtrls, that are resized and positioned as necessary, so you don't have to care about that. Inside these ParentCtrls you can put any Ctrls you want (zero or more). The interesting parts of interface look like this: Grid();
Grid(int x,int y);
Grid& SetSize(int x,int y);
Grid& SetXSize(int x);
Grid& SetYSize(int y);
Grid& SetColor(class Color color);
Grid& ShowGrid(bool show=true);
Grid& NoGrid()
ParentCtrl& Get(int x,int y);
Instead of grid.Get(x,y), you can also use grid[x][y].
The attached archive includes the Grid class, .usc file and simple example app (see the screenshot in next post).
Best regards,
Honza
PS: I am aware that ArrayCtrl or GridCtrl could do the same job, but I believe that in many cases it would be overkill...
-
Attachment: Grid.zip
(Size: 3.12KB, Downloaded 320 times)
[Updated on: Thu, 30 December 2010 17:42] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Wed May 07 03:08:38 CEST 2025
Total time taken to generate the page: 0.03154 seconds
|