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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __COECCNTX_H__
17 #define __COECCNTX_H__
23 /** Interface to allow sharing of graphics settings between controls.
25 The interface provides functions to set the graphics context of a control
26 before drawing. If a control has its iContext member set, the UI Control Framework
27 calls functions defined by this interface when a control is about to be drawn.
28 Developers must implement PrepareContext(), which is called by the framework,
29 to initialise the control's window with the required graphics settings.
31 To use control contexts, a control should inherit from an MCoeControlContext-derived
32 class. To share the context between controls, this control should then be
33 set as the context for all controls that wish to share it. This is done by
34 setting the iContext member of each of the controls, using CCoeControl::SetControlContext()
35 and CCoeControl::CopyControlContextFrom().
39 class MCoeControlContext
42 IMPORT_C virtual void ActivateContext(CWindowGc& aGc,RDrawableWindow& aWindow) const;
43 IMPORT_C virtual void ResetContext(CWindowGc& aGc) const;
44 IMPORT_C virtual void PrepareContext(CWindowGc& aGc) const;
46 IMPORT_C MCoeControlContext();
49 IMPORT_C virtual void MCoeControlContext_Reserved1();
50 IMPORT_C virtual void MCoeControlContext_Reserved2();
53 TInt iMCoeControlContext_Reserved1;
56 /** Brush and pen graphics context.
58 This class allows an MCoeControlContext to be instantiated and used to set
59 brush and pen properties before drawing a control.
63 class CCoeBrushAndPenContext : public CBase, public MCoeControlContext
66 IMPORT_C static CCoeBrushAndPenContext* NewL();
68 IMPORT_C void SetBrushStyle(CWindowGc::TBrushStyle aBrushStyle);
69 IMPORT_C void SetBrushColor(TRgb aColor);
70 IMPORT_C void SetBrushBitmap(const CFbsBitmap& aBitmap);
71 IMPORT_C void SetPenColor(TRgb aColor);
73 IMPORT_C CWindowGc::TBrushStyle BrushStyle() const;
74 IMPORT_C TRgb BrushColor() const;
75 IMPORT_C const CFbsBitmap& BrushBitmap() const;
76 IMPORT_C TRgb PenColor() const;
77 protected: // from MCoeControlContext
78 IMPORT_C void PrepareContext(CWindowGc& aGc) const;
80 CCoeBrushAndPenContext();
82 CWindowGc::TBrushStyle iBrushStyle;
84 const CFbsBitmap* iBitmap;
89 /** Protocol for sharing brush settings used in graphics operations.
91 It can be used to set brush and pen properties before drawing a control.
93 The mixin provides a default implementation of a control context. It implements
94 PrepareContext() to initialise brush settings used in graphics operations.
95 Its data members are public so that the brush style, brush colour and brush
96 pattern can be set by application code.
100 class MCoeControlBrushContext : public MCoeControlContext
103 /** Cause vtable & typeinfo to be exported */
104 IMPORT_C MCoeControlBrushContext();
105 protected: // from MCoeControlContext
106 IMPORT_C void PrepareContext(CWindowGc& aGc) const;
108 /** Brush style. (Not required if iBitmap is set.) */
109 CWindowGc::TBrushStyle iBrushStyle;
110 /** Brush colour. (Not required if iBitmap is set.) */
112 /** Brush pattern. */
113 const CFbsBitmap* iBitmap;
116 TInt iMCoeControlBrushContext_Reserved1;