1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef HSWIDGETPOSITIONINGONWIDGETADD_H |
|
19 #define HSWIDGETPOSITIONINGONWIDGETADD_H |
|
20 |
|
21 #include <QList> |
|
22 #include <QRectF> |
|
23 #include <QPointF> |
|
24 #include "hsutils_global.h" |
|
25 |
|
26 class HsWidgetHost; |
|
27 |
|
28 class HSUTILS_EXPORT HsWidgetPositioningOnWidgetAdd |
|
29 { |
|
30 public: |
|
31 virtual ~HsWidgetPositioningOnWidgetAdd() {} |
|
32 |
|
33 virtual QList<QRectF> convert(const QRectF &contentArea, |
|
34 const QList<QRectF> &existingRects, |
|
35 const QList<QRectF> &newRects, |
|
36 const QPointF &startPoint) = 0; |
|
37 |
|
38 static void setInstance(HsWidgetPositioningOnWidgetAdd *instance); |
|
39 static HsWidgetPositioningOnWidgetAdd *instance(); |
|
40 |
|
41 private: |
|
42 static HsWidgetPositioningOnWidgetAdd *mInstance; |
|
43 }; |
|
44 |
|
45 class HSUTILS_EXPORT HsAnchorPointInBottomRight : public HsWidgetPositioningOnWidgetAdd |
|
46 { |
|
47 public: |
|
48 QList<QRectF> convert(const QRectF &contentArea, |
|
49 const QList<QRectF> &existingRects, |
|
50 const QList<QRectF> &newRects, |
|
51 const QPointF &startPoint); |
|
52 |
|
53 }; |
|
54 |
|
55 class HSUTILS_EXPORT HsAnchorPointInCenter : public HsWidgetPositioningOnWidgetAdd |
|
56 { |
|
57 public: |
|
58 QList<QRectF> convert(const QRectF &contentArea, |
|
59 const QList<QRectF> &existingRects, |
|
60 const QList<QRectF> &newRects, |
|
61 const QPointF &startPoint); |
|
62 }; |
|
63 |
|
64 class HSUTILS_EXPORT HsWidgetOrganizer : public HsWidgetPositioningOnWidgetAdd |
|
65 { |
|
66 public: |
|
67 QList<QRectF> convert(const QRectF &contentArea, |
|
68 const QList<QRectF> &existingRects, |
|
69 const QList<QRectF> &newRects, |
|
70 const QPointF &startPoint); |
|
71 |
|
72 private: |
|
73 bool initAnchors(const QSizeF &areaSize); |
|
74 bool getAnchorPoint(const QSizeF &contentSize); |
|
75 bool searchWidthSpace(const QSizeF &contentSize); |
|
76 bool searchHeightSpace(int contentHeight); |
|
77 bool markReservedAnchors(); |
|
78 QPointF getAnchorCoordinates(int index); |
|
79 int getIndexForCoordinate(QPointF position); |
|
80 int lenghtInAnchorPoints(QVariant length); |
|
81 |
|
82 private: |
|
83 int mAnchorColumns; |
|
84 int mAnchorRows; |
|
85 int mAnchorDistance; |
|
86 QPointF mStartWidthAnchorPoint; |
|
87 QPointF mEndWidthAnchorPoint; |
|
88 QPointF mEndHeightAnchorPoint; |
|
89 // TODO: is there better way to store anchor points, perhaps with pointers? |
|
90 QList<bool> mAnchors; |
|
91 |
|
92 }; |
|
93 |
|
94 |
|
95 #endif // HSWIDGETPOSITIONINGONWIDGETADD_H |
|