2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: A default control in the status pane's title pane.
22 #include <AknControl.h>
27 class CAknTitlePaneExtension;
28 class CAknTitlePaneLabel;
29 class MAknTitlePaneObserver;
30 class TAknTextLineLayout;
33 * A default control in the status pane's title pane.
37 class CAknTitlePane : public CAknControl, public MCoeControlContext
43 IMPORT_C CAknTitlePane();
48 IMPORT_C ~CAknTitlePane();
51 * 2nd phase constructor.
53 IMPORT_C void ConstructL();
56 * Read title pane data from resource file and show it in
57 * the status pane's title pane.
59 IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
62 * Set a text and show it in the status pane's title pane.
63 * Descriptor is copied to the title pane control and ownership of
64 * the original descriptor is left to the application.
66 * @param aText Text to be shown on the title pane.
68 IMPORT_C void SetTextL( const TDesC& aText );
71 * Sets text to the title pane.
73 * @param aText New text. This object takes ownership of @c aText.
75 IMPORT_C void SetText( HBufC* aText );
78 * Set a text and show it in the status pane's title pane.
79 * If whole text does not fit into titlepane, it will be scrolled once
80 * and then shown in truncated form.
82 * Descriptor is copied to the title pane control and ownership
83 * of the original descriptor is left to the application.
87 * @param aText Text to be shown on the title pane.
88 * @param aScroll If @c ETrue text is scrolled when needed, otherwise not.
91 IMPORT_C void SetTextL( const TDesC& aText, TBool aScroll );
94 * Sets text to the title pane. If whole text does not fit into titlepane,
95 * it will be scrolled once and then shown in truncated form.
99 * @param aText New text. This object takes ownership of @c aText.
100 * If @c NULL is given then already existing text's
101 * scrollability will be changed according to @c aScroll.
102 * @param aScroll If ETrue text is scrolled when needed, otherwise not.
104 IMPORT_C void SetText( HBufC* aText, TBool aScroll );
107 * Returns text currently in the status pane's title pane.
108 * Ownership is not transferred.
110 * @return Text currently shown in the title pane.
112 inline const TDesC* Text() const;
115 * Set a picture to the title pane and show it in the
116 * status pane's title pane.
117 * Title pane object takes ownership of the picture.
118 * If @c NULL bitmap is passed, previously set image is shown.
120 * @param aBitmap Bitmap to be set on the title pane.
121 * @param aMaskBitmap Mask of the bitmap.
123 IMPORT_C void SetPicture( const CFbsBitmap* aBitmap,
124 const CFbsBitmap* aMaskBitmap = NULL );
127 * Set a picture from file and show it in the status pane's title pane.
129 * @param aFileName Name of the bitmap file.
130 * @param aMainId Index of the bitmap in the bitmap file.
131 * @param aMaskId Index of the bitmap's mask in the bitmap file.
133 IMPORT_C void SetPictureFromFileL( const TDesC& aFileName,
138 * Set a small picture to the title pane and show it in the
139 * status pane's title pane together with text.
141 * Title pane object takes ownership of the picture.
143 * If @c NULL bitmap is passed, previously set image is used.
147 * @param aBitmap Bitmap to be set on the title pane.
148 * @param aMaskBitmap Mask of the bitmap.
149 * @param aVisible If @c ETrue, picture is set visible. Otherwise only text is shown.
151 IMPORT_C void SetSmallPicture( const CFbsBitmap* aBitmap,
152 const CFbsBitmap* aMaskBitmap,
156 * Set data from resource file and show it in the status pane's title pane.
158 * @param aReader Resource reader of the title pane data.
160 IMPORT_C void SetFromResourceL( TResourceReader& aReader );
163 * Set default value to the status pane's title pane.
164 * Default value is the name of currently active application.
166 IMPORT_C void SetTextToDefaultL();
169 * Gets the maximum amount of text rows that title pane is able to display simultaneously
170 * in the currently active status pane layout. Typically the return value is
171 * either 2 (default portrait mode layout) or 1 (landscape mode layouts).
172 * In the extended status pane layouts the maximum number of lines is always 1.
174 * Since release 3.2, regardless of the status pane layout,
175 * the maximum number of lines is always 1.
179 * @return Maximum number of visible text lines.
181 IMPORT_C TInt MaxNumberOfVisibleTextRows() const;
184 * Sets the number of text rows that can be used to display the text.
185 * The largest allowed value is the the value returned from MaxNumberOfVisibleTextRows() and
186 * the minimum value is always 1.
190 * @param aRows Number of rows that can be used to display the text.
192 IMPORT_C void SetNumberOfVisibleTextRows( TInt aRows );
194 public: // From base class @c MCoeControlContext.
197 * Allows to modify graphics context before @c Draw.
199 * @param aGc Graphics context to be modified.
201 IMPORT_C virtual void PrepareContext( CWindowGc& aGc ) const;
203 protected: // From base class @c CCoeControl.
206 * Handles the size change events.
208 IMPORT_C virtual void SizeChanged();
211 * Handles the position change events.
213 IMPORT_C virtual void PositionChanged();
216 * Handles a change to the control's resources which are shared across
217 * the environment, e.g. skin change.
219 * @param aType Event type.
221 IMPORT_C virtual void HandleResourceChange( TInt aType );
224 * Returns number of controls inside the title pane control.
226 * @return Number of component controls.
228 IMPORT_C virtual TInt CountComponentControls() const;
231 * Returns a control determined by control index.
233 * @param aIndex Index of a control to be returned.
235 * @return Pointer to the control.
237 IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
239 public: // From base class @c CCoeControl.
242 * Handles pointer events.
244 * @param aPointerEvent Pointer event to be handled.
246 IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
248 public: // New methods
251 * Sets observer for title pane events.
253 * @param aObserver Pointer to title pane observer.
255 IMPORT_C void SetTitlePaneObserver( MAknTitlePaneObserver* aObserver );
257 private: // From base class @c CAknControl.
259 IMPORT_C void* ExtensionInterface( TUid aInterface );
264 * Gets title text label.
267 CEikLabel* TextLabel();
270 * Gets the title image.
273 CEikImage* TitleImage();
277 void CommonConstructL();
280 TInt FormatTitlePaneLabelL( const TInt aOneLineLayoutWidth,
281 const TInt aTwoLineLayoutWidth,
282 const CFont* aOneLineFont,
283 const CFont* aTwoLineFont );
285 void ReadFromResourceFileL( TResourceReader& aReader );
286 void SetSmallPictureFromFileL( const TDesC& aFileName, TInt aMainId, TInt aMaskId = -1 );
288 private: // From base class @c CCoeControl.
290 IMPORT_C virtual void Draw( const TRect& aRect ) const;
294 MAknTitlePaneObserver* iTitlePaneObserver;
297 void SizeChangedInNormalStatusPane();
298 void SizeChangedInExtendedStatusPane();
299 void SizeChangedInFlatStatusPane();
300 void SizeChangedInStaconPane();
301 RWindow* StatuspaneContainerWindow() const;
302 void SetupTitleLabelEffectL();
303 void SetContainerWindowNonFading( TBool aNonFading );
305 void SetupStaconPaneScrollEffectL();
306 void SetupFlatStatusPaneScrollEffectL();
307 void SetupNormalStatusPaneScrollEffectL();
308 void SetupFlatStatusPaneFadeEffectL();
309 void SetupExtendedStatusPaneScrollEffectL();
310 void SetupNoEffectL();
312 TBool TextFits( TAknTextLineLayout& aTextLayout );
314 private: // Member data
317 HBufC* iDefaultTitleText;
318 CAknTitlePaneLabel* iTitleLabel;
320 CAknTitlePaneExtension* iExtension;
323 inline const TDesC* CAknTitlePane::Text() const
325 return( iTitleText );
328 #endif // C_AKNTITLE_H