26
|
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 |
// SwtHyperLink.h
|
|
12 |
|
|
13 |
|
|
14 |
#ifndef SWTHYPERLINK_H
|
|
15 |
#define SWTHYPERLINK_H
|
|
16 |
|
|
17 |
|
|
18 |
#include "eswtmobileextensions.h"
|
|
19 |
#include "swtcontrolbase.h"
|
|
20 |
|
|
21 |
|
|
22 |
class MTouchFeedback;
|
|
23 |
|
|
24 |
|
|
25 |
/**
|
|
26 |
* The class encapsulating the S60 native implementation of HyperLink.
|
|
27 |
*
|
|
28 |
* It is a custom control that is a focusable text-only label which,
|
|
29 |
* when being selected, launches an external handler application according
|
|
30 |
* to the format construction parameter.
|
|
31 |
*
|
|
32 |
* @lib eswt.dll
|
|
33 |
*/
|
|
34 |
NONSHARABLE_CLASS(CSwtHyperLink)
|
|
35 |
: public CAknControl
|
|
36 |
, public ASwtControlBase
|
|
37 |
, public MSwtHyperLink
|
|
38 |
{
|
|
39 |
|
|
40 |
// New functions
|
|
41 |
public:
|
|
42 |
/**
|
|
43 |
* The constructor. Note that format parameter is passed in by calling SetFormat
|
|
44 |
* right after the construction.
|
|
45 |
* @param aDisplay The Display object
|
|
46 |
* @param aPeer The Java peer handle
|
|
47 |
* @param aParent The parent Composite
|
|
48 |
* @param aStyle Styles passed to the Java constructor (not the format)
|
|
49 |
* @return New CSwtHyperLink instance
|
|
50 |
*/
|
|
51 |
static CSwtHyperLink* NewL(MSwtDisplay& aDisplay,
|
|
52 |
TSwtPeer aPeer,
|
|
53 |
MSwtComposite& aParent,
|
|
54 |
TInt aStyle);
|
|
55 |
/**
|
|
56 |
* The destructor
|
|
57 |
*/
|
|
58 |
virtual ~CSwtHyperLink();
|
|
59 |
|
|
60 |
private:
|
|
61 |
CSwtHyperLink(MSwtDisplay& aDisplay, TSwtPeer aPeer, MSwtComposite& aParent, TInt aStyle);
|
|
62 |
void ConstructL();
|
|
63 |
void SwtHandleResourceChangeL(TInt aType);
|
|
64 |
void DrawText(CWindowGc& aGc,
|
|
65 |
const CFont* aFont,
|
|
66 |
const TDesC& aText,
|
|
67 |
const TRect& aTextRect,
|
|
68 |
const CGraphicsContext::TTextAlign& aAlignment) const;
|
|
69 |
void UpdateDefaultFontL();
|
|
70 |
void LaunchHandler();
|
|
71 |
TPtrC Scheme();
|
|
72 |
TRgb LinkColor() const;
|
|
73 |
TRgb LinkBgColor() const;
|
|
74 |
TRgb PressedLinkColor() const;
|
|
75 |
|
|
76 |
// From base class CCoeControl
|
|
77 |
|
|
78 |
public:
|
|
79 |
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
|
|
80 |
void HandleResourceChange(TInt aType);
|
|
81 |
protected:
|
|
82 |
TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
|
|
83 |
void SizeChanged();
|
|
84 |
void PositionChanged();
|
|
85 |
void FocusChanged(TDrawNow aDrawNow);
|
|
86 |
private:
|
|
87 |
void Draw(const TRect& aRect) const;
|
|
88 |
|
|
89 |
// From base class MSwtControl
|
|
90 |
|
|
91 |
protected:
|
|
92 |
CCoeControl& CoeControl();
|
|
93 |
const CCoeControl& CoeControl() const;
|
|
94 |
void ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
95 |
void HandlePointerEventL(const TPointerEvent& aPointerEvent);
|
|
96 |
public:
|
|
97 |
void SetForegroundL(const MSwtColor* aColor);
|
|
98 |
TSize ComputeSizeL(TInt aWHint, TInt aHHint);
|
|
99 |
TInt PressBackgroundPolicy() const;
|
|
100 |
|
|
101 |
// From base class ASwtControlBase
|
|
102 |
|
|
103 |
protected:
|
|
104 |
const MSwtFont& DefaultFont() const;
|
|
105 |
HBufC* MSKLabelL() const;
|
|
106 |
TBool IsKeyUsed(TUint aKeyCode) const;
|
|
107 |
|
|
108 |
// From base class MSwtHyperLink
|
|
109 |
|
|
110 |
public:
|
|
111 |
MSwtControl* Control();
|
|
112 |
void SetTextL(const TDesC& aText);
|
|
113 |
const TDesC* GetText();
|
|
114 |
void SetFormat(TInt aFormat);
|
|
115 |
|
|
116 |
// Data
|
|
117 |
private:
|
|
118 |
/**
|
|
119 |
* The hyperlink text set by HyperLink.setText in the Java API.
|
|
120 |
* This is returned from getText.
|
|
121 |
* Own.
|
|
122 |
*/
|
|
123 |
RBuf iOriginalText;
|
|
124 |
|
|
125 |
/**
|
|
126 |
* The hyperlink text that has been formatted.
|
|
127 |
* Own.
|
|
128 |
*/
|
|
129 |
RBuf iFormattedText;
|
|
130 |
|
|
131 |
/**
|
|
132 |
* The default font.
|
|
133 |
* Own.
|
|
134 |
*/
|
|
135 |
MSwtFont* iDefaultFont;
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Custom foreground color used by the non pressed link.
|
|
139 |
* Not own.
|
|
140 |
*/
|
|
141 |
const MSwtColor* iCustomFg;
|
|
142 |
|
|
143 |
/**
|
|
144 |
* The format of the hyperlink. Textual formatting done and the handler
|
|
145 |
* to launch depends on this.
|
|
146 |
*/
|
|
147 |
MSwtHyperLink::TFormat iFormat;
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Feedback instance.
|
|
151 |
* Not own.
|
|
152 |
*/
|
|
153 |
MTouchFeedback* iFeedback;
|
|
154 |
};
|
|
155 |
|
|
156 |
|
|
157 |
#endif // SWTHYPERLINK_H
|
|
158 |
|
|
159 |
|
|
160 |
|