]> code.delx.au - comingnext/blob - ComingNext_SkinFetcher/src/ComingNext_SkinFetcherContainer.cpp
added first implementation of ComingNext Skin Fetcher app
[comingnext] / ComingNext_SkinFetcher / src / ComingNext_SkinFetcherContainer.cpp
1 /*
2 ========================================================================
3 Name : ComingNext_SkinFetcherContainer.cpp
4 Author : Michael Prager
5 Copyright : Licensed under GPLv3
6 Description :
7 ========================================================================
8 */
9 // [[[ begin generated region: do not modify [Generated System Includes]
10 #include <barsread.h>
11 #include <stringloader.h>
12 #include <eiklabel.h>
13 #include <eikenv.h>
14 #include <aknviewappui.h>
15 #include <eikappui.h>
16 #include <ComingNext_SkinFetcher.rsg>
17 // ]]] end generated region [Generated System Includes]
18
19 // [[[ begin generated region: do not modify [Generated User Includes]
20 #include "ComingNext_SkinFetcherContainer.h"
21 #include "ComingNext_SkinFetcherContainerView.h"
22 #include "ComingNext_SkinFetcher.hrh"
23 #include "ComingNext_SkinFetcherContainer.hrh"
24 // ]]] end generated region [Generated User Includes]
25
26 // [[[ begin generated region: do not modify [Generated Constants]
27 // ]]] end generated region [Generated Constants]
28
29 /**
30 * First phase of Symbian two-phase construction. Should not
31 * contain any code that could leave.
32 */
33 CComingNext_SkinFetcherContainer::CComingNext_SkinFetcherContainer()
34 {
35 // [[[ begin generated region: do not modify [Generated Contents]
36 iLabel1 = NULL;
37 // ]]] end generated region [Generated Contents]
38
39 }
40 /**
41 * Destroy child controls.
42 */
43 CComingNext_SkinFetcherContainer::~CComingNext_SkinFetcherContainer()
44 {
45 // [[[ begin generated region: do not modify [Generated Contents]
46 delete iLabel1;
47 iLabel1 = NULL;
48 // ]]] end generated region [Generated Contents]
49
50 }
51
52 /**
53 * Construct the control (first phase).
54 * Creates an instance and initializes it.
55 * Instance is not left on cleanup stack.
56 * @param aRect bounding rectangle
57 * @param aParent owning parent, or NULL
58 * @param aCommandObserver command observer
59 * @return initialized instance of CComingNext_SkinFetcherContainer
60 */
61 CComingNext_SkinFetcherContainer* CComingNext_SkinFetcherContainer::NewL(
62 const TRect& aRect, const CCoeControl* aParent,
63 MEikCommandObserver* aCommandObserver)
64 {
65 CComingNext_SkinFetcherContainer* self =
66 CComingNext_SkinFetcherContainer::NewLC(aRect, aParent,
67 aCommandObserver);
68 CleanupStack::Pop(self);
69 return self;
70 }
71
72 /**
73 * Construct the control (first phase).
74 * Creates an instance and initializes it.
75 * Instance is left on cleanup stack.
76 * @param aRect The rectangle for this window
77 * @param aParent owning parent, or NULL
78 * @param aCommandObserver command observer
79 * @return new instance of CComingNext_SkinFetcherContainer
80 */
81 CComingNext_SkinFetcherContainer* CComingNext_SkinFetcherContainer::NewLC(
82 const TRect& aRect, const CCoeControl* aParent,
83 MEikCommandObserver* aCommandObserver)
84 {
85 CComingNext_SkinFetcherContainer* self =
86 new (ELeave) CComingNext_SkinFetcherContainer();
87 CleanupStack::PushL(self);
88 self->ConstructL(aRect, aParent, aCommandObserver);
89 return self;
90 }
91
92 /**
93 * Construct the control (second phase).
94 * Creates a window to contain the controls and activates it.
95 * @param aRect bounding rectangle
96 * @param aCommandObserver command observer
97 * @param aParent owning parent, or NULL
98 */
99 void CComingNext_SkinFetcherContainer::ConstructL(const TRect& aRect,
100 const CCoeControl* aParent, MEikCommandObserver* aCommandObserver)
101 {
102 if (aParent == NULL)
103 {
104 CreateWindowL();
105 }
106 else
107 {
108 SetContainerWindowL(*aParent);
109 }
110 iFocusControl = NULL;
111 iCommandObserver = aCommandObserver;
112 InitializeControlsL();
113 SetRect(aRect);
114 ActivateL();
115 // [[[ begin generated region: do not modify [Post-ActivateL initializations]
116 // ]]] end generated region [Post-ActivateL initializations]
117
118 }
119
120 /**
121 * Return the number of controls in the container (override)
122 * @return count
123 */
124 TInt CComingNext_SkinFetcherContainer::CountComponentControls() const
125 {
126 return (int) ELastControl;
127 }
128
129 /**
130 * Get the control with the given index (override)
131 * @param aIndex Control index [0...n) (limited by #CountComponentControls)
132 * @return Pointer to control
133 */
134 CCoeControl* CComingNext_SkinFetcherContainer::ComponentControl(TInt aIndex) const
135 {
136 // [[[ begin generated region: do not modify [Generated Contents]
137 switch ( aIndex )
138 {
139 case ELabel1:
140 return iLabel1;
141 }
142 // ]]] end generated region [Generated Contents]
143
144 // handle any user controls here...
145
146 return NULL;
147 }
148
149 /**
150 * Handle resizing of the container. This implementation will lay out
151 * full-sized controls like list boxes for any screen size, and will layout
152 * labels, editors, etc. to the size they were given in the UI designer.
153 * This code will need to be modified to adjust arbitrary controls to
154 * any screen size.
155 */
156 void CComingNext_SkinFetcherContainer::SizeChanged()
157 {
158 CCoeControl::SizeChanged();
159 LayoutControls();
160 // [[[ begin generated region: do not modify [Generated Contents]
161
162 // ]]] end generated region [Generated Contents]
163
164 }
165
166 // [[[ begin generated function: do not modify
167 /**
168 * Layout components as specified in the UI Designer
169 */
170 void CComingNext_SkinFetcherContainer::LayoutControls()
171 {
172 iLabel1->SetExtent( TPoint( 19, 19 ), TSize( 323, 312 ) );
173 }
174 // ]]] end generated function
175
176 /**
177 * Handle key events.
178 */
179 TKeyResponse CComingNext_SkinFetcherContainer::OfferKeyEventL(
180 const TKeyEvent& aKeyEvent, TEventCode aType)
181 {
182 // [[[ begin generated region: do not modify [Generated Contents]
183
184 // ]]] end generated region [Generated Contents]
185
186 if (iFocusControl != NULL
187 && iFocusControl->OfferKeyEventL(aKeyEvent, aType)
188 == EKeyWasConsumed)
189 {
190 return EKeyWasConsumed;
191 }
192 return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
193 }
194
195 // [[[ begin generated function: do not modify
196 /**
197 * Initialize each control upon creation.
198 */
199 void CComingNext_SkinFetcherContainer::InitializeControlsL()
200 {
201 iLabel1 = new ( ELeave ) CEikLabel;
202 iLabel1->SetContainerWindowL( *this );
203 {
204 TResourceReader reader;
205 iEikonEnv->CreateResourceReaderLC( reader, R_COMING_NEXT_SKIN_FETCHER_CONTAINER_LABEL1 );
206 iLabel1->ConstructFromResourceL( reader );
207 CleanupStack::PopAndDestroy(); // reader internal state
208 }
209
210 }
211 // ]]] end generated function
212
213 /**
214 * Handle global resource changes, such as scalable UI or skin events (override)
215 */
216 void CComingNext_SkinFetcherContainer::HandleResourceChange(TInt aType)
217 {
218 CCoeControl::HandleResourceChange(aType);
219 SetRect(iAvkonViewAppUi->View(TUid::Uid(
220 EComingNext_SkinFetcherContainerViewId))->ClientRect());
221 // [[[ begin generated region: do not modify [Generated Contents]
222 // ]]] end generated region [Generated Contents]
223
224 }
225
226 /**
227 * Draw container contents.
228 */
229 void CComingNext_SkinFetcherContainer::Draw(const TRect& aRect) const
230 {
231 // [[[ begin generated region: do not modify [Generated Contents]
232 CWindowGc& gc = SystemGc();
233 gc.Clear( aRect );
234
235 // ]]] end generated region [Generated Contents]
236
237 }
238