|
1 /******************************************************************************* |
|
2 * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - S60 implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 |
|
13 #ifndef SWTLABEL_H |
|
14 #define SWTLABEL_H |
|
15 |
|
16 |
|
17 #include <eiklabel.h> |
|
18 #include <eikspace.h> |
|
19 #include "swtcontrolbase.h" |
|
20 #include "eswtwidgetscore.h" |
|
21 |
|
22 |
|
23 /** |
|
24 * CSwtLabel |
|
25 * @lib eswt |
|
26 */ |
|
27 NONSHARABLE_CLASS(CSwtLabel) |
|
28 : public CAknControl |
|
29 , public ASwtControlBase |
|
30 , public MSwtLabel |
|
31 { |
|
32 // New methods |
|
33 public: |
|
34 static CSwtLabel* NewL(MSwtDisplay& aDisplay, |
|
35 TSwtPeer aPeer, MSwtComposite& aParent, TInt aStyle); |
|
36 |
|
37 protected: |
|
38 CSwtLabel(MSwtDisplay& aDisplay, TSwtPeer aPeer, MSwtComposite& aParent, TInt aStyle); |
|
39 ~CSwtLabel(); |
|
40 void ConstructL(); |
|
41 |
|
42 private: |
|
43 void CreateImageL(); |
|
44 void CreateTextL(); |
|
45 void CreateSeparatorL(); |
|
46 void ClipTextL(TInt aWHint); |
|
47 TSize ComputeTextSizeL(TInt aWHint, TInt aHHint); |
|
48 TInt CalcWrappedTextHeightL(TInt aWidth); |
|
49 TInt CalcWrappedTextWidth(TInt aHeight); |
|
50 void WrapTextL(TInt aWHint, TInt aHHint); |
|
51 void WrapTextL(TSize aSize); |
|
52 void RetrieveDefaultFontL(); |
|
53 TSize MinimumSize() const; |
|
54 TInt MinimumWidth() const; |
|
55 TInt MinimumHeight() const; |
|
56 TInt MinimumHeight(TInt aLineCount) const; |
|
57 void DoSetFontL(const CFont* aFont); |
|
58 void SwtHandleResourceChangeL(TInt aType); |
|
59 |
|
60 // From CCoeControl |
|
61 public: |
|
62 void SetDimmed(TBool aDimmed); |
|
63 CCoeControl* ComponentControl(TInt aIndex) const; |
|
64 TInt CountComponentControls() const; |
|
65 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
66 void HandleResourceChange(TInt aType); |
|
67 protected: |
|
68 void Draw(const TRect& aRect) const; |
|
69 void FocusChanged(TDrawNow aDrawNow); |
|
70 void PositionChanged(); |
|
71 void SizeChanged(); |
|
72 TTypeUid::Ptr MopSupplyObject(TTypeUid aId); |
|
73 void DrawSeparator(CWindowGc& aGc) const; |
|
74 TRect CalcAndUpdateSeparatorRect(); |
|
75 void ResizeSeparatorImages(); |
|
76 |
|
77 // From MSwtControl |
|
78 public: |
|
79 CCoeControl& CoeControl(); |
|
80 const CCoeControl& CoeControl() const; |
|
81 TBool IsFocusable(TInt aReason = KSwtFocusByApi) const; |
|
82 void ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
83 void SetForegroundL(const MSwtColor* aColor); |
|
84 TSize ComputeSizeL(TInt aWHint, TInt aHHint); |
|
85 void SetFontL(const MSwtFont* aFont); |
|
86 |
|
87 // From ASwtControlbase |
|
88 protected: |
|
89 const MSwtFont& DefaultFont() const; |
|
90 |
|
91 // From MSwtLabel |
|
92 public: |
|
93 MSwtControl* Control(); |
|
94 TInt GetAlignment() const; |
|
95 void SetAlignment(TInt aAlignment); |
|
96 void SetImageL(const MSwtImage* aImage); |
|
97 void SetTextL(const TDesC& aText); |
|
98 |
|
99 // Data |
|
100 private: |
|
101 CFbsBitmap* iSeparatorHead; |
|
102 CFbsBitmap* iSeparatorHeadMask; |
|
103 CFbsBitmap* iSeparatorCenter; |
|
104 CFbsBitmap* iSeparatorCenterMask; |
|
105 CFbsBitmap* iSeparatorTail; |
|
106 CFbsBitmap* iSeparatorTailMask; |
|
107 TRect iSeparatorHeadRect; |
|
108 TRect iSeparatorCenterRect; |
|
109 TRect iSeparatorTailRect; |
|
110 TInt iSeparatorThickness; |
|
111 CEikLabel* iEikLabel; // Symbian label, owned, may be NULL |
|
112 HBufC* iOriginalText; // The original text set with the method SetText(). |
|
113 TInt iOriginalTextLineCount;// Count how many lines are in the text ('\n') |
|
114 MSwtFont* iDefaultFont; // The text's default font, owned, NULL only if iText is NULL |
|
115 const MSwtImage* iImage; // The image to draw, may be NULL, ref counted |
|
116 const MSwtColor* iForegroundColor; // The set foreground color |
|
117 TBool iDashedLineSeparatorInUse; |
|
118 }; |
|
119 |
|
120 |
|
121 #endif // SWTLABEL_H |