|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __COECNTRL_H__ |
|
17 #define __COECNTRL_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <e32base.h> |
|
21 #include <w32std.h> |
|
22 #include <gulalign.h> |
|
23 #include <coedef.h> |
|
24 #include <coecobs.h> |
|
25 #include <coehelp.h> |
|
26 #include <coeinput.h> |
|
27 #include <coemop.h> |
|
28 #include <coemain.h> |
|
29 #include <coefont.h> |
|
30 #include <coetextdrawer.h> |
|
31 #include <coecontrolarray.h> |
|
32 |
|
33 #include <coecoloruse.h> // class TCoeColorUse |
|
34 |
|
35 class TResourceReader; |
|
36 class CCoeEnv; |
|
37 class MCoeControlContext; |
|
38 class CCoeControlStorage; |
|
39 |
|
40 class MCoeLayoutManager; |
|
41 class TCoeZoomWithType; |
|
42 class CCoeFontProvider; |
|
43 |
|
44 // forward declarations. |
|
45 class CCoeControl; |
|
46 class CCoeTextDrawerBase; |
|
47 |
|
48 /** Interface to be used if a control elects to be a background drawer. |
|
49 |
|
50 Parent controls can elect to take responsibility for drawing the background for their child |
|
51 controls. To achieve this, they should aggregate an object that implements this interface. |
|
52 CCoeControl::SetBackground() accepts the object and sets it as the background drawer |
|
53 |
|
54 @see CCoeControl::EnableWindowTransparency() |
|
55 @publishedAll |
|
56 @released |
|
57 */ |
|
58 class MCoeControlBackground |
|
59 { |
|
60 public: |
|
61 /** Draw the background for a given control. |
|
62 The text drawer that shall be used to draw text on the specific background can be |
|
63 fetched through the GetTextDrawer() method. |
|
64 |
|
65 @param aGc Graphics context used for drawing |
|
66 @param aControl The control being drawn (may be a child of the drawer) |
|
67 @param aRect The area to be redrawn |
|
68 |
|
69 @publishedAll |
|
70 @released |
|
71 */ |
|
72 virtual void Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const = 0; |
|
73 /** |
|
74 This function retrieves the text drawer associated with the background. |
|
75 @param aTextDrawer The text drawer associated with the background. This may be null. The default implementation |
|
76 always sets this to 0. |
|
77 @param aDrawingControl The control that is requesting the text drawer. |
|
78 */ |
|
79 IMPORT_C virtual void GetTextDrawer(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl) const; |
|
80 protected: |
|
81 IMPORT_C MCoeControlBackground(); |
|
82 private: |
|
83 IMPORT_C virtual void MCoeControlBackground_Reserved1(); |
|
84 IMPORT_C virtual void MCoeControlBackground_Reserved2(); |
|
85 IMPORT_C virtual void MCoeControlBackground_Reserved3(); |
|
86 IMPORT_C virtual void MCoeControlBackground_Reserved4(); |
|
87 IMPORT_C virtual void MCoeControlBackground_Reserved5(); |
|
88 private: |
|
89 TInt iMCoeControlBackground_Reserved1(); |
|
90 }; |
|
91 |
|
92 /** Abstract interface for defining a control's hit region. |
|
93 |
|
94 This could be implemented by a CCoeControl-derived class to |
|
95 define hit region checking. The object is installed by calling CCoeControl::SetHitTest(). |
|
96 |
|
97 The hit region is the area inside the control's rectangle in which pointer events are handled. |
|
98 It can be any shape, not necessarily rectangular. |
|
99 |
|
100 @publishedAll |
|
101 @released |
|
102 */ |
|
103 class MCoeControlHitTest |
|
104 { |
|
105 public: |
|
106 /** Tests whether a pointer event occurred inside the control's hit region. |
|
107 This function is called by CCoeControl::HandlePointerEventL(). |
|
108 |
|
109 @param aPoint The position of the pointer event. |
|
110 @return ETrue if the specified point lies inside the hit region, EFalse if not. |
|
111 |
|
112 @publishedAll |
|
113 @released |
|
114 */ |
|
115 virtual TBool HitRegionContains(const TPoint& aPoint, const CCoeControl& aControl) const = 0; |
|
116 protected: |
|
117 IMPORT_C MCoeControlHitTest(); |
|
118 private: |
|
119 IMPORT_C virtual void MCoeControlHitTest_Reserved1(); |
|
120 IMPORT_C virtual void MCoeControlHitTest_Reserved2(); |
|
121 private: |
|
122 TInt iMCoeControlHitTest_Reserved1; |
|
123 }; |
|
124 |
|
125 |
|
126 /** |
|
127 Control base class from which all other controls are derived. |
|
128 |
|
129 @publishedAll |
|
130 @released |
|
131 */ |
|
132 class CCoeControl : public CBase, public MObjectProvider |
|
133 { |
|
134 public: |
|
135 enum TZoomType |
|
136 { |
|
137 EAbsoluteZoom, // absolute |
|
138 ERelativeZoom // relative to parent's zoom |
|
139 }; |
|
140 public: |
|
141 // Construction and destruction |
|
142 IMPORT_C CCoeControl(); |
|
143 IMPORT_C CCoeControl(CCoeEnv* aCoeEnv); |
|
144 IMPORT_C ~CCoeControl(); |
|
145 IMPORT_C TBool ComponentArrayExists() const; |
|
146 public: // Virtuals (see more related non-virtuals further down) |
|
147 // Key input |
|
148 IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
149 // Visual state |
|
150 IMPORT_C virtual void MakeVisible(TBool aVisible); |
|
151 IMPORT_C virtual void SetDimmed(TBool aDimmed); |
|
152 // Construction |
|
153 IMPORT_C virtual void SetContainerWindowL(const CCoeControl& aContainer); |
|
154 IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader); |
|
155 IMPORT_C virtual void ActivateL(); |
|
156 // Focus |
|
157 IMPORT_C virtual void PrepareForFocusLossL(); |
|
158 IMPORT_C virtual void PrepareForFocusGainL(); |
|
159 // Control proximity |
|
160 IMPORT_C virtual void SetAdjacent(TInt aAdjacent); |
|
161 IMPORT_C virtual void SetNeighbor(CCoeControl* aNeighbor); |
|
162 IMPORT_C virtual TBool HasBorder() const; // deprecated from 9.2 |
|
163 // Control size |
|
164 IMPORT_C virtual TSize MinimumSize(); |
|
165 // Resource change handling |
|
166 IMPORT_C virtual void HandleResourceChange(TInt aType); |
|
167 // Logical color use (for Java) |
|
168 IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; |
|
169 // User help |
|
170 IMPORT_C virtual void GetHelpContext(TCoeHelpContext& aContext) const; |
|
171 // Text input |
|
172 IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const; |
|
173 public: |
|
174 // Environment |
|
175 inline CCoeEnv* ControlEnv() const; |
|
176 // Container window |
|
177 IMPORT_C RDrawableWindow* DrawableWindow() const; |
|
178 IMPORT_C TBool OwnsWindow() const; |
|
179 IMPORT_C TBool IsBackedUp() const; |
|
180 IMPORT_C void SetContainerWindowL(RWindow& aWindow); // deprecated from 9.2 |
|
181 IMPORT_C void SetContainerWindowL(RBackedUpWindow& aWindow); // deprecated from 9.2 |
|
182 // Control parent |
|
183 IMPORT_C CCoeControl* Parent(); |
|
184 IMPORT_C const CCoeControl* Parent() const; |
|
185 IMPORT_C virtual TInt SetParent(CCoeControl* aParent); |
|
186 // Size and position |
|
187 IMPORT_C TRect Rect() const; |
|
188 IMPORT_C void SetRect(const TRect& aRect); |
|
189 IMPORT_C void SetExtent(const TPoint& aPosition,const TSize& aSize); |
|
190 IMPORT_C void SetExtentToWholeScreen(); |
|
191 IMPORT_C TSize Size() const; |
|
192 IMPORT_C void SetSize(const TSize& aSize); |
|
193 IMPORT_C TPoint Position() const; |
|
194 IMPORT_C TPoint PositionRelativeToScreen() const; |
|
195 IMPORT_C void SetPosition(const TPoint& aPosition); |
|
196 IMPORT_C TInt MaximumWidth() const; |
|
197 IMPORT_C TInt SetMaximumWidth(TInt aMaxWidth); |
|
198 // Layout |
|
199 IMPORT_C MCoeLayoutManager* LayoutManager() const; |
|
200 IMPORT_C virtual void SetLayoutManagerL(MCoeLayoutManager* aLayout); |
|
201 IMPORT_C virtual TBool RequestRelayout(const CCoeControl* aChildControl); |
|
202 // Visibility |
|
203 IMPORT_C TBool IsVisible() const; |
|
204 IMPORT_C void SetComponentsToInheritVisibility(TBool aInherit=ETrue); |
|
205 // Dimmed |
|
206 IMPORT_C TBool IsDimmed() const; |
|
207 // State observer |
|
208 IMPORT_C void SetObserver(MCoeControlObserver* aObserver); |
|
209 IMPORT_C MCoeControlObserver* Observer() const; |
|
210 // Focus |
|
211 IMPORT_C TBool IsFocused() const; |
|
212 IMPORT_C void SetFocus(TBool aFocus,TDrawNow aDrawNow=ENoDrawNow); |
|
213 IMPORT_C void SetNonFocusing(); |
|
214 IMPORT_C void SetFocusing(TBool aFocusing); |
|
215 IMPORT_C TBool IsNonFocusing() const; |
|
216 // Drawing (see also Draw() below) |
|
217 IMPORT_C void DrawNow() const; |
|
218 IMPORT_C void DrawNow(const TRect &aRect) const; |
|
219 IMPORT_C void DrawDeferred() const; |
|
220 IMPORT_C CWindowGc& SystemGc() const; |
|
221 IMPORT_C TInt SetCustomGc(CWindowGc* aGraphicsContext); |
|
222 IMPORT_C CWindowGc* CustomGc() const; |
|
223 // Control context (background color etc). Deprecated (use MCoeControlBackground) |
|
224 IMPORT_C void SetControlContext(MCoeControlContext* aContext); // deprecated from 9.2 |
|
225 IMPORT_C void CopyControlContextFrom(const CCoeControl* aControl); // deprecated from 9.2 |
|
226 IMPORT_C MCoeControlContext* ControlContext() const; // deprecated from 9.2 |
|
227 // Pointer events |
|
228 IMPORT_C void SetPointerCapture(TBool aCapture=ETrue); |
|
229 IMPORT_C void ClaimPointerGrab(TBool aSendUpEvent=ETrue); |
|
230 IMPORT_C TInt ClaimPointerGrab(TInt aPointerNumber, TBool aSendUpEvent); |
|
231 IMPORT_C void IgnoreEventsUntilNextPointerUp(); |
|
232 IMPORT_C void SetGloballyCapturing(TBool aGlobal); |
|
233 // Pointer hit test |
|
234 IMPORT_C TInt SetHitTest(const MCoeControlHitTest* aHitTestControl); |
|
235 IMPORT_C const MCoeControlHitTest* HitTest() const; |
|
236 // Logical colors |
|
237 IMPORT_C void OverrideColorL(TInt aLogicalColor,TRgb aColor); |
|
238 IMPORT_C TBool GetColor(TInt aLogicalColor,TRgb& aColor) const; |
|
239 // Control background |
|
240 IMPORT_C void DrawBackground(const TRect& aRect) const; |
|
241 IMPORT_C void DrawForeground(const TRect& aRect) const; |
|
242 IMPORT_C const MCoeControlBackground* Background() const; |
|
243 IMPORT_C const MCoeControlBackground* FindBackground() const; |
|
244 IMPORT_C void SetBackground(const MCoeControlBackground* aBackground); |
|
245 // Zooming |
|
246 IMPORT_C void SetZoomFactorL(TInt aZoomFactor, TZoomType aZoomType = ERelativeZoom); |
|
247 IMPORT_C TZoomFactor AccumulatedZoom() const; |
|
248 IMPORT_C const TCoeZoomWithType* ZoomWithType() const; |
|
249 // Font provider (see ScreenFont() below) |
|
250 IMPORT_C const CCoeFontProvider& FindFontProvider() const; |
|
251 IMPORT_C void SetFontProviderL(const CCoeFontProvider& aFontProvider); |
|
252 // Text baseline (virtuals) |
|
253 IMPORT_C virtual TInt TextBaselineOffset(const TSize& aSize) const; |
|
254 IMPORT_C virtual void SetTextBaselineSpacing(TInt aSpacing); |
|
255 // Input capabilities |
|
256 IMPORT_C TCoeInputCapabilities RecursivelyMergedInputCapabilities() const; |
|
257 // Interface access |
|
258 IMPORT_C void SetMopParent(MObjectProvider* aParent); |
|
259 // Instance identification |
|
260 IMPORT_C TInt UniqueHandle() const; |
|
261 IMPORT_C TInt SetUniqueHandle(TInt aUniqueHandle); |
|
262 public: // Pointer events (virtuals) |
|
263 IMPORT_C virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
264 protected: // Virtuals. Override to handle these events. |
|
265 IMPORT_C virtual void HandlePointerBufferReadyL(); // See HandlePointerEventL() |
|
266 // Change of focus |
|
267 IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow); |
|
268 // Change of size and position |
|
269 IMPORT_C virtual void SizeChanged(); |
|
270 IMPORT_C virtual void PositionChanged(); |
|
271 public: |
|
272 // Component control access |
|
273 IMPORT_C virtual TInt CountComponentControls() const; |
|
274 IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const; |
|
275 IMPORT_C TInt Index(const CCoeControl* aControl) const; |
|
276 protected: |
|
277 // Control state |
|
278 IMPORT_C TBool IsActivated() const; |
|
279 IMPORT_C TBool IsBeingDestroyed() const; |
|
280 // Component ownership |
|
281 IMPORT_C void InitComponentArrayL(); |
|
282 IMPORT_C CCoeControlArray& Components(); |
|
283 IMPORT_C const CCoeControlArray& Components() const; |
|
284 // Container window |
|
285 IMPORT_C RWindow& Window() const; |
|
286 IMPORT_C RBackedUpWindow& BackedUpWindow() const; |
|
287 IMPORT_C void CloseWindow(); |
|
288 IMPORT_C void CreateWindowL(); |
|
289 IMPORT_C void CreateWindowL(const CCoeControl* aParent); |
|
290 IMPORT_C void CreateWindowL(RWindowTreeNode& aParent); |
|
291 IMPORT_C void CreateWindowL(RWindowGroup* aParent); |
|
292 IMPORT_C void CreateBackedUpWindowL(RWindowTreeNode& aParent); |
|
293 IMPORT_C void CreateBackedUpWindowL(RWindowTreeNode& aParent,TDisplayMode aDisplayMode); |
|
294 IMPORT_C void EnableWindowTransparency(); |
|
295 // Size and position |
|
296 IMPORT_C void SetCornerAndSize(TGulAlignment aCorner,const TSize& aSize); |
|
297 IMPORT_C void SetSizeWithoutNotification(const TSize& aSize); |
|
298 // Font access |
|
299 IMPORT_C const CFont& ScreenFont(const TCoeFont& aFont) const; |
|
300 // Text drawer |
|
301 IMPORT_C CCoeTextDrawerBase& TextDrawer(TInt aKey = KErrNotFound) const; |
|
302 // Pointer events |
|
303 IMPORT_C void EnableDragEvents(); |
|
304 IMPORT_C void HandleRedrawEvent(const TRect& aRect) const; |
|
305 IMPORT_C void SetAllowStrayPointers(); |
|
306 IMPORT_C CCoeControl* GrabbingComponent() const; |
|
307 IMPORT_C CCoeControl* GrabbingComponent(TInt aPointer) const; |
|
308 IMPORT_C TBool CapturesPointer() const; |
|
309 // Drawing |
|
310 IMPORT_C TBool IsReadyToDraw() const; |
|
311 IMPORT_C TBool IsBlank() const; |
|
312 IMPORT_C void SetBlank(); |
|
313 IMPORT_C void SetCanDrawOutsideRect(); |
|
314 IMPORT_C void ActivateGc() const; |
|
315 IMPORT_C void DeactivateGc() const; |
|
316 IMPORT_C void ResetGc() const; |
|
317 // State events |
|
318 IMPORT_C void ReportEventL(MCoeControlObserver::TCoeEvent aEvent); |
|
319 // Resource changes |
|
320 IMPORT_C void HandleComponentControlsResourceChange(TInt aType); |
|
321 // Copy Constructor and Assignment Operator |
|
322 inline CCoeControl(const CCoeControl& aControl); |
|
323 inline CCoeControl& operator=(const CCoeControl& aControl); |
|
324 protected: |
|
325 friend class CCoeControlArray; |
|
326 IMPORT_C virtual void HandleControlArrayEventL(CCoeControlArray::TEvent aEvent, const CCoeControlArray* aArray, CCoeControl* aControl, TInt aControlId); |
|
327 private: // reserved |
|
328 IMPORT_C virtual void Reserved_CCoeControl_10(); |
|
329 IMPORT_C virtual void Reserved_CCoeControl_11(); |
|
330 IMPORT_C virtual void Reserved_CCoeControl_12(); |
|
331 IMPORT_C virtual void Reserved_CCoeControl_13(); |
|
332 private: |
|
333 IMPORT_C virtual void GetTextDrawer(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl, TInt aKey) const; |
|
334 private: // reserved |
|
335 IMPORT_C virtual void Reserved_CCoeControl_8(); |
|
336 IMPORT_C virtual void Reserved_CCoeControl_9(); |
|
337 protected: // from MObjectProvider |
|
338 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
339 private: // from MObjectProvider |
|
340 IMPORT_C MObjectProvider* MopNext(); |
|
341 private: |
|
342 // Drawing (override this to draw) |
|
343 IMPORT_C virtual void Draw(const TRect& aRect) const; |
|
344 protected: |
|
345 // Debugging |
|
346 IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const; |
|
347 private: // reserved |
|
348 IMPORT_C virtual void Reserved_2(); |
|
349 public: // but not exported |
|
350 void ProcessPointerEventL(const TPointerEvent& aPointerEvent); |
|
351 void ProcessPointerBufferReadyL(); |
|
352 void RecursivelyMergeInputCapabilities(TCoeInputCapabilities& aInputCapabilities) const; |
|
353 void WriteInternalStateNowL(RWriteStream& aWriteStream) const; |
|
354 void NotifyFontChange(const CCoeFontProvider* aFontProvider); |
|
355 void RemoveFromParent(); |
|
356 void RefetchPixelMappingL(); |
|
357 public: // deprecated |
|
358 inline TInt SetGc(CWindowGc* aGraphicsContext) const; |
|
359 inline CWindowGc* GetGc() const; |
|
360 private: |
|
361 friend class CCoeRedrawer; |
|
362 void DrawComponents(const TRect& aRect) const; |
|
363 void DrawWindowOwningComponentsNow() const; |
|
364 void DrawWindowOwningComponentsNow(const TRect &aRect) const; |
|
365 void SetGrabbed(TBool aGrabbed, TInt aPointerNumber); |
|
366 TBool IsGrabbed(TInt aPointerNumber = 0) const; |
|
367 void DoMakeVisible(TBool aVisible); |
|
368 void CheckPointerEventPurge() const; |
|
369 void RecursivelyMergeTextDrawers(CCoeTextDrawerBase*& aTextDrawer, const CCoeControl* aDrawingControl, TInt aKey) const; |
|
370 CCoeControl* WindowOwningParent(); |
|
371 const CCoeControl* WindowOwningParent() const { return const_cast<CCoeControl*>(this)->WindowOwningParent(); } |
|
372 const CCoeControl* SearchParent(const CCoeControl* aParentToFind) const; |
|
373 TInt SetZoomWithType(TCoeZoomWithType* aZoomWithType); |
|
374 TCoeZoomWithType* GetZoomWithType() const; |
|
375 TInt SetFontProvider(const CCoeFontProvider* aFontProvider); |
|
376 const CCoeFontProvider* GetFontProvider() const; |
|
377 TInt FindColor(TInt aLogicalColor) const; |
|
378 void ActivateGcRecursive() const; |
|
379 void DeactivateGcRecursive() const; |
|
380 void ReportControlStateChange(MCoeControlStateObserver::TCoeState aType); |
|
381 TInt ValidateAdvancedPointerNumber( const TPointerEvent& aPointerEvent ) const; |
|
382 void ControlClaimPointerGrab(TInt aPointerNumber); |
|
383 public: |
|
384 IMPORT_C void EnableReportControlStateChange(TBool aState); |
|
385 |
|
386 protected: |
|
387 CCoeEnv* iCoeEnv; |
|
388 MCoeControlContext* iContext; // deprecated |
|
389 TPoint iPosition; |
|
390 TSize iSize; |
|
391 private: |
|
392 TInt iFlags; |
|
393 RDrawableWindow* iWin; |
|
394 CCoeControlStorage* iData; |
|
395 MObjectProvider* iMopParent; |
|
396 }; |
|
397 |
|
398 |
|
399 /** |
|
400 Gets the control environment object for this control. |
|
401 |
|
402 @return The control's control environment object. |
|
403 */ |
|
404 inline CCoeEnv* CCoeControl::ControlEnv() const |
|
405 { return(iCoeEnv); } |
|
406 |
|
407 /** |
|
408 Deprecated. See CCoeControl::SetCustomGc(). |
|
409 @deprecated |
|
410 */ |
|
411 inline TInt CCoeControl::SetGc(CWindowGc* aGraphicsContext) const |
|
412 { return const_cast<CCoeControl*>(this)->SetCustomGc(aGraphicsContext); } |
|
413 |
|
414 /** |
|
415 Deprecated. See CCoeControl::CustomGc(). |
|
416 @deprecated |
|
417 */ |
|
418 inline CWindowGc* CCoeControl::GetGc() const |
|
419 { return CustomGc(); } |
|
420 |
|
421 |
|
422 #endif // __COECNTRL_H__ |