|
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 the License "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 * Multiple Windows' WindowManager. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef __MULTIPLE_WINDOWS_WINDOWMANAGER_H__ |
|
22 #define __MULTIPLE_WINDOWS_WINDOWMANAGER_H__ |
|
23 |
|
24 // INCLUDES FILES |
|
25 #include "WmlBrowserBuild.h" |
|
26 #include "Preferences.h" |
|
27 #include <e32base.h> |
|
28 #include <BrCtlDefs.h> |
|
29 #include "WindowObserver.h" |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CBrowserWindow; |
|
33 class MApiProvider; |
|
34 class CBrowserContentView; |
|
35 class MWindowInfoProvider; |
|
36 class CWindowInfo; |
|
37 class CBrowserWindowQue; |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 /** |
|
42 * Interface to query several API implementations via Window class. |
|
43 * |
|
44 * @lib Browser.app |
|
45 * @since Series 60 3.0 |
|
46 */ |
|
47 class CBrowserWindowManager : public CBase, |
|
48 public MPreferencesObserver |
|
49 { |
|
50 public: // constructors / destructor |
|
51 |
|
52 static CBrowserWindowManager* NewLC( |
|
53 MApiProvider& aApiProvider, |
|
54 CBrowserContentView& aContentView, |
|
55 TInt aMaxWindowCount ); |
|
56 static CBrowserWindowManager* NewL( |
|
57 MApiProvider& aApiProvider, |
|
58 CBrowserContentView& aContentView, |
|
59 TInt aMaxWindowCount ); |
|
60 ~CBrowserWindowManager(); |
|
61 |
|
62 public: // accessing windows / window data |
|
63 |
|
64 TInt WindowCount() const; |
|
65 |
|
66 inline TInt MaxWindowCount() const; |
|
67 |
|
68 // @returns window object |
|
69 // possible error codes: KErrNotFound, KErrGeneral |
|
70 // searching for a window identified by an Id |
|
71 TInt Window( TInt aWindowId, CBrowserWindow*& aWindow ); |
|
72 |
|
73 // @returns window object |
|
74 // possible error codes: KErrNotFound, KErrGeneral |
|
75 // searching for a window identified by an Id |
|
76 CBrowserWindow* FindWindowL( |
|
77 const TDesC& aTargetName ); |
|
78 |
|
79 CBrowserWindow* CurrentWindow() const; |
|
80 |
|
81 inline MApiProvider* ApiProvider() const; |
|
82 |
|
83 inline CBrowserContentView* ContentView() const; |
|
84 |
|
85 CArrayFixFlat<CWindowInfo*>* GetWindowInfoL( |
|
86 MWindowInfoProvider* aWindowInfo ); |
|
87 |
|
88 inline void SetUserExit( TBool aUserExit ); |
|
89 |
|
90 void SendCommandToAllWindowsL( TInt aCommand ); |
|
91 |
|
92 /** |
|
93 * Adds an observer which is notified about window events |
|
94 * @param aObserver The observer which will receive window events. |
|
95 * @since series 60 3.1 |
|
96 */ |
|
97 void AddObserverL( MWindowObserver* aObserver ); |
|
98 |
|
99 /** |
|
100 * Removes an observer which won`t be notified about window events. |
|
101 * @param aObserver The observer which will not receive |
|
102 * further window events. |
|
103 * @since 3.1 |
|
104 */ |
|
105 void RemoveObserver( MWindowObserver* aObserver ); |
|
106 |
|
107 /** |
|
108 * Notifies the observer about an event. |
|
109 * @param aEvent The type of the event. |
|
110 * @since 3.1 |
|
111 */ |
|
112 void NotifyObserversL( TWindowEvent aEvent, TInt aWindowId = 0 ); |
|
113 |
|
114 public: // window management |
|
115 |
|
116 // possible leave codes: KErrNoMemory |
|
117 // Window specific settings are read from ApiProvider().Preferences() |
|
118 // based on the current state |
|
119 CBrowserWindow* CreateWindowL( |
|
120 TInt aParentId, |
|
121 const TDesC* aTargetName ); |
|
122 |
|
123 /** |
|
124 * Deletes a window. |
|
125 * @param aWindowId the window to be deleted |
|
126 * @param aUserInitiated: user or script initiated the process |
|
127 * @return the windowId should be activated or 0 |
|
128 */ |
|
129 TInt DeleteWindowL( TInt aWindowId, TBool aForceDelete = EFalse ); |
|
130 |
|
131 // possible leave codes: KErrNotFound |
|
132 TInt SwitchWindowL( TInt aWindowId, TBool aDraw = ETrue ); |
|
133 |
|
134 // is there any content in the window? |
|
135 inline TBool IsContentExist() const; |
|
136 |
|
137 // content was shown in the window |
|
138 inline void SetContentExist( TBool aValue ); |
|
139 |
|
140 // Sets the type of content in the view |
|
141 void SetCurrentWindowViewState(TBrCtlDefs::TBrCtlState aViewState, TInt aValue); |
|
142 |
|
143 //Closes all windows except the current one |
|
144 void CloseAllWindowsExceptCurrent(); |
|
145 |
|
146 public: // from MPreferencesObserver |
|
147 |
|
148 /** |
|
149 * Observer for Preference changes |
|
150 */ |
|
151 virtual void HandlePreferencesChangeL( |
|
152 const TPreferencesEvent aEvent, |
|
153 TPreferencesValues& aValues, |
|
154 TBrCtlDefs::TBrCtlSettings aSettingType ); |
|
155 |
|
156 protected: |
|
157 |
|
158 CBrowserWindowManager( |
|
159 MApiProvider& aApiProvider, |
|
160 CBrowserContentView& aContentView, |
|
161 TInt aMaxWindowCount ); |
|
162 /** |
|
163 * 2nd phase constructor |
|
164 */ |
|
165 void ConstructL(); |
|
166 |
|
167 // searching for a window identified by its Id and TargetName |
|
168 // returns with the Window |
|
169 TInt Window( |
|
170 TInt aParentId, |
|
171 const TDesC* aTargetName, |
|
172 CBrowserWindow*& aWindow, |
|
173 CBrowserWindowQue* aStartingItem ) const; |
|
174 |
|
175 // searching for a window identified by its Id |
|
176 // returns with the Queue element of that Window |
|
177 TInt Window( |
|
178 TInt aWindowId, |
|
179 CBrowserWindowQue*& aWindowQue, |
|
180 CBrowserWindowQue* aStartingItem ) const; |
|
181 |
|
182 // really delete a window |
|
183 TInt DeleteOneWindowL( TInt aWindowId ); |
|
184 |
|
185 // removes already deleted (status) windows from the queue |
|
186 void RemoveDeletedWindowsL(); |
|
187 |
|
188 private: |
|
189 static TInt iWindowIdGenerator; // for generating window's id |
|
190 MApiProvider* iApiProvider; // not owned |
|
191 CBrowserContentView* iContentView; // not owned |
|
192 TInt iMaxWindowCount; |
|
193 TInt iWindowCount; |
|
194 TInt iDeletedWindowCount; |
|
195 CBrowserWindowQue* iWindowQueue; // head of the windows |
|
196 CBrowserWindowQue* iCurrentWindow; // points to the current window |
|
197 TBool iUserExit; |
|
198 TBool iIsContentExist; |
|
199 CArrayPtrFlat< MWindowObserver >* iObservers; |
|
200 }; |
|
201 |
|
202 #include "BrowserWindowManager.inl" |
|
203 |
|
204 #endif // __MULTIPLE_WINDOWS_WINDOWMANAGER_H__ |
|
205 |
|
206 // End of File |