KFlowRects proposal (planned for next Monday)

Matthew Woehlke mw_triad at users.sourceforge.net
Mon Aug 6 17:22:12 BST 2007


I would like to add (next Monday) this class to kdelibs (probably kdeui? 
where is a good place?). This class takes some information about items 
and "flows" them in a container. The container is a rectangle, with 
fixed-size items and fixed spacing between the items. The purpose it to 
determine the coordinates of the n'th item by "flowing" items in the 
container with the requested size and spacing.

So if you have 7 items with different sized containers, this sort of 
gives an idea what it going on:

+---------+
| 1 2 3 4 |
| 5 6 7   |
|         |
+---------+

+--------+
| 1 2 3  |
| 4 5 6  |
| 7      |
+--------+

The API looks something like this (pseudocode, please ignore not-consts, 
not-references, etc.):

void setContainerSize(QRect container)
void setContainerSize(QSize container) // sets top-left to (0,0)
void setContainerSize(int x, int y, int w, int h)
void setContainerSize(int w, int h) // sets top-left to (0,0)

void setItemSize(QSize size)
void setItemSize(int w, int h)

void setItemSpacing(int h, int v)
void setItemHSpacing(int h)
void setItemVSpacing(int v)

// the useful part :-)
QRect itemPos(int index)


I will use as my API-freeze excuse that I am moving/improving a kdefx 
class (KPixmapSplitter) :-). In fact the only change (besides naming) is 
that the ctors no longer require a QPixmap to set the container size.

Suggestions for better names welcomed. Also getters are probably wanted. 
Are the convenience overloads too much? (Should there be ctors that look 
like setContainerSize? Although I would like to not have anything 
unchangeable after construction...)

-- 
Matthew
"Braaaaaaaaiins!" -- Zombies





More information about the kde-core-devel mailing list