|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * This contains all the state specific logic of the bio-control. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #ifndef WMLSTATE_H |
|
22 #define WMLSTATE_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "WMLBC.hrh" |
|
26 |
|
27 #include <w32std.h> |
|
28 #include <coedef.h> |
|
29 #include <MsgEditor.hrh> |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 |
|
33 class CCoeControl; |
|
34 class CEikMenuPane; |
|
35 class CWmlBioControl; |
|
36 class CWmlSubItemBase; |
|
37 class TCoeHelpContext; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Interface common for all the states. |
|
43 */ |
|
44 NONSHARABLE_CLASS( MWmlState ) |
|
45 { |
|
46 public: |
|
47 virtual ~MWmlState() {}; |
|
48 public: // These must be implemented for each different state. |
|
49 // See the CWmlBioControl interface for explanations when these |
|
50 // methods are called and what's their purpose. |
|
51 virtual void SetAndGetSizeL( TSize& aSize ) = 0; |
|
52 virtual TBool HandleBioCommandL( TInt aCommand ) = 0; |
|
53 virtual TRect CurrentLineRect() const = 0; |
|
54 virtual TBool IsFocusChangePossible( TMsgFocusDirection aDirection ) const = 0; |
|
55 virtual HBufC* HeaderTextLC() const = 0; |
|
56 virtual void OptionMenuPermissionsL( TUint32& aPermissions ) const = 0; |
|
57 virtual void SetMenuCommandSetL( CEikMenuPane& aMenuPane ) = 0; |
|
58 virtual TInt VirtualHeight() = 0; |
|
59 virtual TInt VirtualVisibleTop() = 0; |
|
60 virtual TBool IsCursorLocation( TMsgCursorLocation aLocation ) const = 0; |
|
61 virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
62 TEventCode aType ) = 0; |
|
63 virtual void SizeChanged() = 0; |
|
64 virtual void FocusChanged( TDrawNow aDrawNow ) = 0; |
|
65 virtual void CreateViewerL( const CCoeControl& aContainer ) = 0; |
|
66 virtual TBool CursorInFirstLine() const = 0; |
|
67 |
|
68 virtual void GetHelpContext(TCoeHelpContext& aHelpContext) const = 0; |
|
69 |
|
70 protected: // State transition logic. |
|
71 |
|
72 /** |
|
73 * Called when entered to this state. |
|
74 * @param aState enumeration for the state. |
|
75 * Enumeration is used to check if it's legal |
|
76 * to enter this state. |
|
77 */ |
|
78 virtual void EnterL( TWmlState aState ) = 0; |
|
79 |
|
80 |
|
81 private: |
|
82 |
|
83 friend class CWmlStateFactory; |
|
84 }; |
|
85 |
|
86 /** |
|
87 * CWmlStateFactory owns the states and it's used to access |
|
88 * the current state. |
|
89 */ |
|
90 NONSHARABLE_CLASS( CWmlStateFactory ) : public CBase |
|
91 { |
|
92 public: |
|
93 |
|
94 /** |
|
95 * Creates the new CWmlStateFactory object. |
|
96 * @param aBioControl reference to the biocontrol. |
|
97 */ |
|
98 static CWmlStateFactory* NewL( CWmlBioControl& aBioControl ); |
|
99 |
|
100 /** |
|
101 * Destructor. |
|
102 */ |
|
103 ~CWmlStateFactory(); |
|
104 |
|
105 public: |
|
106 |
|
107 /** |
|
108 * Defines the initial state from the item count. |
|
109 * @param aAPCount count of Accesspoint items. |
|
110 * @param aMMSCount count of MMS setting items. |
|
111 * @param aBMCount count of Bookmark items. |
|
112 */ |
|
113 void SetInitialStateL( |
|
114 const TInt aBMCount ); |
|
115 |
|
116 /** |
|
117 * Get the current state object. |
|
118 * @return reference to the current state object. |
|
119 */ |
|
120 MWmlState& State() const; |
|
121 |
|
122 protected: |
|
123 |
|
124 /** |
|
125 * Do the construction. |
|
126 * @param aBioControl reference to the biocontrol. |
|
127 */ |
|
128 void ConstructL( CWmlBioControl& aBioControl ); |
|
129 |
|
130 private: |
|
131 |
|
132 /** |
|
133 * Constructor, hidden from outsiders. |
|
134 */ |
|
135 CWmlStateFactory() {}; |
|
136 |
|
137 /** |
|
138 * Change the state to the inquired one. |
|
139 * @param aState enumeration of the desired state. |
|
140 * If the state transisition is not possible keeps the |
|
141 * current stete. |
|
142 */ |
|
143 void ChangeStateL( TWmlState aState ); |
|
144 |
|
145 private: // Concrete state objects. |
|
146 |
|
147 //// Pointer to the single state object. |
|
148 MWmlState* iStateSingle; |
|
149 |
|
150 //// Pointer to the biocontrol |
|
151 CWmlBioControl* iBioControl; |
|
152 |
|
153 /// Pointer to the current state. NOT DESCRETE OBJECT. |
|
154 MWmlState* iState; |
|
155 |
|
156 private: // State enumerations |
|
157 |
|
158 /// Current state as enumeration. |
|
159 TWmlState iStateEnum; |
|
160 |
|
161 private: |
|
162 friend class CWmlState; |
|
163 }; |
|
164 |
|
165 /** |
|
166 * Common base class for all the state objects. |
|
167 */ |
|
168 NONSHARABLE_CLASS( CWmlState ) : public CBase, |
|
169 public MWmlState |
|
170 { |
|
171 protected: |
|
172 /** |
|
173 * Constructor. |
|
174 * @param aStateFactory pointer to the state factory. |
|
175 * @param aBioControl reference to the biocontrol. |
|
176 */ |
|
177 CWmlState( CWmlStateFactory* aStateFactory, |
|
178 CWmlBioControl& aBioControl); |
|
179 |
|
180 protected: // State transition logic. |
|
181 |
|
182 /** |
|
183 * Accesses the factory ChangeStateL-method. |
|
184 * @param aNextState enumeration for the next state. |
|
185 */ |
|
186 //void ChangeStateL( TWmlState aNextState ); |
|
187 |
|
188 private: |
|
189 |
|
190 /** |
|
191 * Default constructor. |
|
192 */ |
|
193 CWmlState() {}; |
|
194 |
|
195 protected: |
|
196 |
|
197 /// Pointer to the state factory, not owned. |
|
198 CWmlStateFactory* iStateFactory; |
|
199 |
|
200 /// Pointer to the bio control. |
|
201 CWmlBioControl* iBioControl; |
|
202 |
|
203 /// Current state. |
|
204 TWmlState iState; |
|
205 }; |
|
206 |
|
207 /** |
|
208 * Single state. |
|
209 */ |
|
210 NONSHARABLE_CLASS( CWmlStateSingle ) : public CWmlState |
|
211 { |
|
212 public: |
|
213 CWmlStateSingle( CWmlStateFactory* aStateFactory, |
|
214 CWmlBioControl& aBioControl); |
|
215 ~CWmlStateSingle(); |
|
216 public: // These must be implemented for each different state. |
|
217 void SetAndGetSizeL( TSize& aSize ); |
|
218 TBool HandleBioCommandL( TInt aCommand ); |
|
219 TRect CurrentLineRect() const; |
|
220 TBool IsFocusChangePossible( TMsgFocusDirection aDirection ) const; |
|
221 HBufC* HeaderTextLC() const; |
|
222 void OptionMenuPermissionsL( TUint32& aPermissions ) const; |
|
223 void SetMenuCommandSetL( CEikMenuPane& aMenuPane ); |
|
224 TInt VirtualHeight(); |
|
225 TInt VirtualVisibleTop(); |
|
226 TBool IsCursorLocation( TMsgCursorLocation aLocation ) const; |
|
227 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
228 TEventCode aType ); |
|
229 void SizeChanged(); |
|
230 void FocusChanged( TDrawNow aDrawNow ); |
|
231 void CreateViewerL( const CCoeControl& aContainer ); |
|
232 TBool CursorInFirstLine() const; |
|
233 |
|
234 void GetHelpContext(TCoeHelpContext& aHelpContext) const; |
|
235 protected: // State transition logic. |
|
236 void EnterL( TWmlState aState ); |
|
237 }; |
|
238 |
|
239 #endif // WMLSTATE_H |
|
240 |
|
241 // End of file |