|
1 /* |
|
2 * Copyright (c) 2006 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: Place holder for brushes. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_ALFBRUSHARRY_H |
|
21 #define C_ALFBRUSHARRY_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <alf/alfownership.h> |
|
25 |
|
26 class CAlfBrush; |
|
27 class CAlfVisual; |
|
28 |
|
29 /** |
|
30 * Array for brushes. |
|
31 * |
|
32 * This client object can store owned items, but all the real objects |
|
33 * are on the server side. Also, the order of brushes is maintained on |
|
34 * the server side. |
|
35 * |
|
36 * Usage: |
|
37 * @code |
|
38 * |
|
39 * //Create Visual |
|
40 * CAlfTextVisual* textVisual = control.AppendVisualL( EAlfVisualTypeText, NULL ); |
|
41 * |
|
42 * //Create border brush |
|
43 * CAlfBorderBrush* borderBrush = CAlfBorderBrush::NewL( *iEnv, TAlfXYMetric(TAlfMetric(1)), |
|
44 * TAlfXYMetric(TAlfMetric(KAlfDefaultBorderBrushEdgeOffsetX, EAlfUnitPixel), |
|
45 * TAlfMetric(KAlfDefaultBorderBrushEdgeOffsetY, EAlfUnitPixel))); |
|
46 * |
|
47 * //Enable brush |
|
48 * textVisual->EnableBrushesL(); |
|
49 * |
|
50 * //Get brush array |
|
51 * CAlfBrushArray* brushArray = textVisual->Brushes(); |
|
52 * |
|
53 * //Append border brush in brush array, with ownership transfered |
|
54 * brushArray->AppendL( borderBrush, EAlfHasOwnership ); |
|
55 * |
|
56 * //removes and deletes border brush in brush array |
|
57 * brushArray->Remove(0); |
|
58 * |
|
59 * //Cleanup |
|
60 * delete iEnv; //Will delete visual , brush array as well. |
|
61 * |
|
62 * @endcode |
|
63 * |
|
64 * @lib alfclient.lib |
|
65 * @since S60 v3.2 |
|
66 */ |
|
67 NONSHARABLE_CLASS(CAlfBrushArray) : public CBase |
|
68 { |
|
69 |
|
70 public: |
|
71 |
|
72 /** |
|
73 * Constructor. |
|
74 */ |
|
75 static CAlfBrushArray* NewL( CAlfVisual& aOwner ); |
|
76 |
|
77 /** |
|
78 * Destructor. |
|
79 */ |
|
80 virtual ~CAlfBrushArray(); |
|
81 |
|
82 /** |
|
83 * Resets the array |
|
84 */ |
|
85 IMPORT_C void Reset(); |
|
86 |
|
87 /** |
|
88 * Appends a new brush to the array. |
|
89 * |
|
90 * @param aBrush Brush instance. |
|
91 * @param aOwnership Ownership of the brush. |
|
92 */ |
|
93 IMPORT_C void AppendL( CAlfBrush* aBrush, TAlfOwnership aOwnership ); |
|
94 |
|
95 /** |
|
96 * Inserts a brush to the array. |
|
97 * |
|
98 * @param aPos Index for the new brush instance. |
|
99 * @param aBrush Brush instance. |
|
100 * @param aOwnership Ownership of the brush. |
|
101 */ |
|
102 IMPORT_C void InsertL(TInt aPos, CAlfBrush* aBrush, TAlfOwnership aOwnership); |
|
103 |
|
104 /** |
|
105 * Removes a brush from the array. If the array has ownership of the |
|
106 * brush, it will be deleted. |
|
107 * |
|
108 * @param aPos Index of the brush instance to remove. |
|
109 */ |
|
110 IMPORT_C void Remove(TInt aPos); |
|
111 |
|
112 /** |
|
113 * Count the number of brushes in the array. |
|
114 * |
|
115 * @return Number of brushes. |
|
116 */ |
|
117 IMPORT_C TInt Count() const; |
|
118 |
|
119 /** |
|
120 * Returns a reference to a brush in the array. |
|
121 * |
|
122 * @param aPos Index. |
|
123 */ |
|
124 IMPORT_C CAlfBrush& operator [] (TInt aPos); |
|
125 |
|
126 /** |
|
127 * Returns a reference to a brush in the array. |
|
128 * |
|
129 * @param aPos Index. |
|
130 */ |
|
131 IMPORT_C CAlfBrush& At(TInt aPos); |
|
132 |
|
133 /** |
|
134 * @internal |
|
135 * |
|
136 * Called when a brush is deleted |
|
137 * @param aBrush Deleted brush |
|
138 */ |
|
139 void HandleBrushDestroyed( CAlfBrush& aBrush ); |
|
140 |
|
141 private: |
|
142 |
|
143 /** |
|
144 * Constructor. |
|
145 */ |
|
146 CAlfBrushArray(); |
|
147 |
|
148 /** |
|
149 * Constructor. |
|
150 */ |
|
151 void ConstructL( CAlfVisual& aOwner ); |
|
152 |
|
153 /** |
|
154 * Remove a brush, plus owned brushes. |
|
155 * @param aBrush Brushes owned by this brush array will be removed. |
|
156 * @param aPosIndex This brush index will be removed if it is >= 0. |
|
157 */ |
|
158 void RemoveBrush(CAlfBrush* aBrush, TInt aPosIndex = -1); |
|
159 |
|
160 private: // data |
|
161 |
|
162 // Private data structure. Owned. |
|
163 struct TPrivateData; |
|
164 TPrivateData* iData; |
|
165 |
|
166 }; |
|
167 |
|
168 #endif // C_ALFBRUSHARRY_H |