2 * Copyright (c) 2002-2007 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.
15 * General Avkon Utilities. Includes:
23 #ifndef __AKNUTILS_H__
24 #define __AKNUTILS_H__
37 #include <AknsConstants.h>
39 #include <AknLayout.lag>
41 // These are for listbox column lengths (These are used to allocate memory from stack while drawing listboxes, they should be as small as possible, but not smaller!)
42 const TInt KMaxColumnDataLength = 80; // This is maximum length of data for one listbox column -- after that the data is truncated before drawing.
43 const TInt KMaxTotalDataLength = 8*KMaxColumnDataLength; // max of 5 columns can have full 80 characters...
45 /** AVKON utility module
47 * From this file, you can find several tools for making application development easier for S60
49 * 1) Conversion modules to convert coordinate data from european LAF to usable formats
50 * AknLayoutUtils, TAknLayoutRect, TAknLayoutText
51 * 2) Utilities to clip text
52 * 3) Part of selection service implementation
53 * 4) Different classes that help using listboxes
54 * 5) Handling colors in AKN_LAF_COLOR macro.
55 * 6) Resource readers for different purposes
56 * 7) Utility to find files without specifying the drive letter or path
61 class CEikTextListBox;
62 class CEikColumnListBox;
63 class CEikFormattedCellListBox;
65 class CEikSettingsListBox;
75 class CAknColumnListBox;
76 class CEikSecretEditor;
79 class TAknFontSpecification;
81 class TAknWindowLineLayout;
82 class TAknMultiLineTextLayout;
83 class TAknTextLineLayout;
86 * Egul library had methods to clip text from right side, this class includes methods to clip from both sides.
87 * It does add 3 dots to the end of the text.
89 const TInt KDefaultClipWidth = -1;
90 const TUint KDefaultClipChar = TUint(0x2026);
92 // Constant to use in AknLayoutUtils to indicate that the parameter is not to be used as a override value
93 const TInt KAknLayoutUtilsDoNotOverride = -1;
97 * Text truncating and wrapping methods in this class do not support
98 * text that requires conversion from logical to visual form,
99 * e.g. Arabic/Hebrew, Thai and Hindi text. Code that needs to support that
100 * kind of text should use corresponding methods in AknBidiTextUtils instead.
111 /** ClipToFit() Generic clipping
113 @param aBuffer String that needs to be clipped. will be modified by this call
114 @param aFont Font used in the code
115 @param aMaxWidthInPixels Maximum length of text that will not be clipped.
116 @param aDir Where is the text clipped from. EDoNotClip, EClipFromEnd, EClipFromBeginning.
117 @param aClipWidth The length of the text after clipping. KDefaultClipWidth will make it use aMaxWidthInPixels.
118 @param aClipString The representation of three dots. (not really used anywhere - use the default value always or "")
120 returns true if the text was clipped and 3 dots were added.
123 IMPORT_C static TBool ClipToFit(TDes& aBuffer,
125 TInt aMaxWidthInPixels,
126 TClipDirection aDir=EClipFromEnd,
127 TInt aClipWidth = KDefaultClipWidth,
128 const TDesC &aClipString=_L("..."));
130 /** ClipToFit() for clipping text inside lists
132 * NOTICE: This method cannot handle situation where the text may dynamically change its size! Especially when you have bitmaps on the right side!
134 * This needs to be done AFTER the listbox has done its SizeChanged()!
136 IMPORT_C static TBool ClipToFit(TDes& aBuffer,
138 CEikFormattedCellListBox *aListBox,
140 TInt aSubCellNumber);
142 /** ClipToFit() for clipping text inside lists
144 * NOTICE: This method cannot handle situation where the text may dynamically change its size! Especially when you have bitmaps on the right side!
146 * This needs to be done AFTER the listbox has done its SizeChanged()!
148 IMPORT_C static TBool ClipToFit(TDes& aBuffer,
150 CEikColumnListBox *aListBox,
156 static TBool DoClipToFit(
159 TInt aMaxWidthInPixels,
162 const TDesC& aClipString );
165 * Wraps a string to an array of pointers.
166 * The number of lines and line widths are specified by aLineWidthArray.
167 * The pointers in aWrappedArray point to positions inside aWrappedString.
169 * @param aStringToWrap String that needs to be wrapped
170 * @param aLineWidthArray Line widths in pixels
171 * @param aFont Used font
172 * @param aWrappedArray Pointers to wrapped lines
174 IMPORT_C static void WrapToArrayL(
175 const TDesC& aStringToWrap,
176 const CArrayFix<TInt>& aLineWidthArray,
178 CArrayFix<TPtrC>& aWrappedArray);
181 * Wraps a string to an array of pointers.
182 * Constant line width is given.
183 * The pointers in aWrappedArray point to positions inside aWrappedString.
185 * @param aStringToWrap String that needs to be wrapped
186 * @param aLineWidth Constant line width in pixels
187 * @param aFont Used font
188 * @param aWrappedArray Pointers to wrapped lines
190 IMPORT_C static void WrapToArrayL(
191 const TDesC& aStringToWrap,
194 CArrayFix<TPtrC>& aWrappedArray );
197 * Wraps a string to an array of pointers and clips at the end
198 * of the last line if there aren't enough lines to accomodate
199 * the entire text. When clipping three dots are inserted at the
200 * end of the last line.
201 * The number of lines and line widths are specified by aLineWidthArray.
202 * The pointers in aWrappedArray point to positions inside aWrappedString.
204 * Expect the string to be modified if clipping is needed.
205 * (Clipping character KEllipsis is inserted at the ending point)
207 * @param aStringToWrap String that needs to be wrapped
208 * @param aLineWidthArray Line widths in pixels
209 * @param aFont Used font
210 * @param aWrappedArray Pointers to wrapped lines
212 IMPORT_C static void WrapToArrayAndClipL(
214 const CArrayFix<TInt>& aLineWidthArray,
216 CArrayFix<TPtrC>& aWrappedArray );
219 * Chops a string when a line break character is encountered.
220 * Clips at the end of each line if there isn't enough space
222 * When clipping, KEllipsis (shown as 3 dots) is inserted at
223 * the end of the line.
224 * The number of lines and line widths are specified by aLineWidthArray.
225 * The pointers in aChoppedArray point to positions inside aStringToChop.
227 * Expect the string to be modified if clipping is needed
228 * (Clipping character KEllipsis is inserted in the end of the lines)
230 * @param aStringToChop String that needs to be chopped
231 * @param aLineWidthArray Line widths in pixels
232 * @param aFont Used font
233 * @param aChoppedArray Pointers to chopped lines
235 IMPORT_C static void ChopToArrayAndClipL(
237 const CArrayFix<TInt>& aLineWidthArray,
239 CArrayFix<TPtrC>& aChoppedArray);
242 * Chops a string when a line break character is encountered.
243 * Clips at the end of each line if there isn't enough space
245 * When clipping, KEllipsis (shown as 3 dots) is inserted at
246 * the end of the line.
247 * Constant line width is given.
248 * The pointers in aChoppedArray point to positions inside aStringToChop.
250 * Expect the string to be modified if clipping is needed
251 * (Clipping character KEllipsis is inserted in the end of the lines)
253 * @param aStringToChop String that needs to be chopped
254 * @param aLineWidth Constant line width in pixels
255 * @param aFont Used font
256 * @param aChoppedArray Pointers to chopped lines
258 IMPORT_C static void ChopToArrayAndClipL(
262 CArrayFix<TPtrC>& aChoppedArray );
265 * Wraps a string (aStringToWrap) into lines according to the
266 * number of lines and line widths specified in aLineWidthArray.
267 * Inserts '\n' at the end of lines.
268 * Copies the result into aWrappedString.
269 * Leaves if aWrappedString isn't big enough.
271 * @param aStringToWrap String that needs to be wrapped
272 * @param aLineWidthArray Lines widths in pixels
273 * @param aFont Used font
274 * @param aWrappedString Wrapped string
276 IMPORT_C static void WrapToStringL(
277 const TDesC& aStringToWrap,
278 const CArrayFix<TInt>& aLineWidthArray,
280 TDes& aWrappedString );
283 * Wraps a string (aStringToWrap) into lines according to the
284 * number of lines and line widths specified in aLineWidthArray.
285 * Inserts '\n' at the end of lines.
286 * Clips the last line if there aren't enough lines to
287 * fit the entire string.
288 * Copies the result into aWrappedString.
289 * Leaves if aWrappedString isn't big enough.
291 * @param aStringToWrap String that needs to be wrapped
292 * @param aLineWidthArray Width of lines in pixels
293 * @param aFont Used font
294 * @param aWrappedString Wrapped string
296 IMPORT_C static void WrapToStringAndClipL(
297 const TDesC& aStringToWrap,
298 const CArrayFix<TInt>& aLineWidthArray,
300 TDes& aWrappedString );
303 * This routine is used to strip away a set of characters from
306 * Useful for example for listboxes to make sure strings from
307 * network or typed by the end user does not have tab or linefeed
308 * characters. (as those will make listbox broken.)
310 * @param aDes Parameter to change
311 * @param aCharacters A set of characters to remove
313 * There exists predefined character sets to remove:
315 * KAknStripListControlChars (\t's and \n's and \r's)
317 IMPORT_C static void StripCharacters(TDes &aDes, const TDesC &aCharacters);
320 * This routine is used to replace all control chars with a single
321 * character, usually a whitespace.
323 * @param aDes Parameter to change
324 * @param aCharacters A set of characters to remove
325 * @param aReplacement a character used as replacement
328 * KAknReplaceListControlChars (\t's and \n's)
330 IMPORT_C static void ReplaceCharacters(TDes &aDes, const TDesC &aChars, TChar aReplacement);
333 * This routine is used to remove extra whitespaces from text before
336 * @param aDes Parameter to change
337 * @param aWhiteSpaceCharacters A set of whitespace characters to remove
339 IMPORT_C static void PackWhiteSpaces(TDes &aDes, const TDesC &aWhiteSpaceChars);
341 // non-exported implementation
343 static void WrapToStringL(
344 const TDesC& aStringToWrap,
345 const CArrayFix<TInt>& aLineWidthArray,
347 TDes& aWrappedString,
349 TInt aDirectionality );
351 static void WrapToArrayL(
353 const CArrayFix<TInt>* aLineWidthArray,
355 CArrayFix<TPtrC>& aWrappedArray,
358 TInt aDirectionality );
360 static void ChopToArrayAndClipL(
362 const CArrayFix<TInt>* aLineWidthArray,
364 CArrayFix<TPtrC>& aChoppedArray,
368 * This utility is used to see if a text is empty according to the conventions of
372 * @return ETrue if the text is empty according to Avkon
374 static TBool IsEmptyText( const TDesC& aTextToTest );
377 * This routine is used to convert between arabic-indic digits and european digits.
378 * based on existing language setting. So it'll convert any digit from the string
379 * to use either european digits or arabic-indic digits based on current settings.
381 * NOTE: THis method can be also called in european release. The method is required
382 * to do the correct thing with all the languages.
384 * This method should only be used just before displaying the number as unicode string.
385 * Also, never store the converted string as unicode.
388 * @param aDes Parameter to change
390 IMPORT_C static void LanguageSpecificNumberConversion(TDes &aDes);
393 * This routine is used to convert digits from any digit format to another format eg. from
394 * european digits to arabic-indic digits.
397 * @param aDes Parameter to change. It can contain digits from several digit types.
398 * @param aDigitType Destination digit type.
400 IMPORT_C static void ConvertDigitsTo( TDes& aDes, TDigitType aDigitType );
403 * Convenience routine to obtain the directionality of the current input language
404 * This routine will attempt to access this information in a system-efficient way.
406 * This is not to be confused with either the directionality of the display text
407 * language or (a closely associated concept) the layout direction of the UI
408 * (accessed via AknLayoutUtils::LayoutMirrored() )
411 * @return TBidiText::ELeftToRight if the current input language is left to right
412 * TBidiText::ERightToLeft if the current input langauge is right to left
414 IMPORT_C static TBidiText::TDirectionality CurrentScriptDirectionality();
417 * Method used to constrain the digit type to use to that consisted with the current input language
420 * @returns TDigitType consistent with the current input language
422 static TDigitType InputLanguageFilteredDigitType();
425 * Method used to constrain the digit type to use to that consisted with the current display text language
428 * @returns TDigitType consistent with the current input language
430 static TDigitType DisplayTextLanguageFilteredDigitType();
433 * Returns the digit type to be used for editors that are purely numeric in quality.
436 * @returns TDigitType to use for purely numeric editors
438 IMPORT_C static TDigitType NumericEditorDigitType();
441 * This routine is used to convert between arabic-indic digits and european digits.
442 * based on existing language setting. So it'll convert any digit from the string
443 * to use either european digits or arabic-indic digits based on current settings.
445 * This routine builds in the constraints imposed by current display text languages.
447 * The number of characters in the buffer is not changed by this routine. It can therefore be
448 * safely used easily with existing (modifiable) descriptors.
450 * This method should only be used just before displaying the number as unicode descriptor.
451 * Never store the converted string.
454 * @param aDes Parameter to change
456 IMPORT_C static void DisplayTextLanguageSpecificNumberConversion(TDes &aDes);
459 * Returns the digit type to be used for editors that are alphanumeric.
460 * (Note that these editors may be configurable to be purely numeric - that is have a numeric
461 * mode, but they remain alphanumeric editors for the sake of this API.)
463 * This may be useful for instance for input processors that convert numeric key events to the
464 * currently set input digit type.
467 * @returns TDigitType to editors with alphanumeric capability
469 IMPORT_C static TDigitType TextEditorDigitType();
471 enum TDigitModeQueryType {
472 EDigitModeEditorDefault, // in editors by default whether western or foreign digits are used (gen.editors, both text and numbers)
473 EDigitModeUserModifiableEditor, // in editors whether user can modify digitmode with keypad
474 EDigitModeShownToUser, // in all components when displaying digits
475 EDigitModeNumberEditor, // number, time, date, notification texts (1st group of editors)
476 EDigitModeLatinNumberEditor // e-mail, password, PIN codes, etc. (3rd group, where only latin can be used)
479 * This routine can be used to check what modes digits can be on.
481 * It uses input language, display language and the setting from general settings
482 * to calculate whether foreign digits need to be used.
484 * This is useful for editor implementation and anyone that needs to convert
485 * digits for display.
488 * @param aQueryType what is the situation where the digits are to be used.
489 * @returns ETrue to indicate whether digit conversions need to be used.
490 * @returns EFalse to indicate that no conversion is needed.
492 IMPORT_C static TBool DigitModeQuery(TDigitModeQueryType aQueryType = EDigitModeShownToUser);
495 * Converts a filename ABCDE.EXT to format which is suitable for display.
496 * This method is needed for bi-directional language support.
497 * The method adds directionality markers to the filename so that the
498 * filename can correctly be rendered to screen.
502 * @param aDes contains the file name in logical format.
503 * @returns file name in logical format with needed directionality markers.
505 IMPORT_C static HBufC* ConvertFileNameL(const TDesC& aDes);
510 * Do not use. This method will be removed.
512 IMPORT_C static HBufC* LoadScalableTextL(CCoeEnv& aCoe, TInt aResourceId);
516 * Do not use. This method will be removed.
518 IMPORT_C static HBufC* LoadScalableTextLC(CCoeEnv& aCoe, TInt aResourceId);
522 * Do not use. This method will be removed.
524 IMPORT_C static TInt LoadScalableText(CCoeEnv& aCoe, TInt aResourceId, TDes& aBuffer );
528 * Do not use. This method will be removed.
530 IMPORT_C static HBufC* ClipAccordingScreenOrientationLC(CCoeEnv& aCoe, HBufC* aBuf);
533 * Utility method used in scalable UI for choosing the longest fitting text variant.
534 * Truncating and wrapping methods in classes AknTextUtils and AknBidiTextUtils do
535 * the choice by themselves, so whenever they are used to process the text, it is not
536 * necessary to call this method.
538 * Applications do not need to call this method if they pass their localized texts
539 * to Avkon's UI components.
543 * @param aText Text containing one or many variants with varying text widths,
544 * separated with the character 0x0001. The text is supposed to be
546 * @param aFont Font used to render the text.
547 * @param aMaxWidthInPixels Max width in pixels.
549 * @ret Longest fitting text. If none of the variants fits,
550 * the shortest one in pixels is returned.
552 IMPORT_C static TPtrC ChooseScalableText(
555 TInt aMaxWidthInPixels );
558 _LIT(KAknStripTabs, "\t");
559 _LIT(KAknStripListControlChars, "\t\n");
560 _LIT(KAknReplaceTabs, "\t");
561 _LIT(KAknReplaceListControlChars, "\t\n");
562 _LIT(KAknCommonWhiteSpaceCharacters, " \n\t\r");
565 * These are part of Selection service and they should be called by application's HandleCommandL() to get
566 * menus and cba's handled automatically for selection service.
568 * The right way to implement these would be to have dialogs with names "Selection List", "MultiSelection List"
569 * and "Markable list" and make them keep a listbox inside it. (look at CAknPopupList, it does similar things)
571 * See CAknSelectionListDialog and CAknMarkableListDialog from aknselectionlist.h, they provide better
572 * interface for applications.
574 class AknSelectionService
577 /** Helper function to implement ProcessCommandL() for selection list dialogs
579 IMPORT_C static void HandleSelectionListProcessCommandL(
581 CEikListBox* aListBox);
583 /** Helper function to implement ProcessCommandL() for selection list dialogs
585 IMPORT_C static void HandleMultiselectionListProcessCommandL(
587 CEikListBox* aListBox);
589 /** Helper function to implement ProcessCommandL() for markable list dialogs
591 IMPORT_C static void HandleMarkableListProcessCommandL(
593 CEikListBox* aListBox);
595 /** Helper function to implement ProcessCommandL() for menu lists
597 IMPORT_C static TKeyResponse HandleMenuListOfferKeyEventL(
598 const TKeyEvent& aKeyEvent,
600 CEikListBox* aListBox);
602 /** Helper function to implement DynInitMenuPaneL() for markable list dialogs
604 IMPORT_C static void HandleMarkableListDynInitMenuPane(
607 CEikListBox *aListBox);
609 /** Helper function to implement DynInitMenuPaneL() for markable list dialogs
611 IMPORT_C static void HandleMarkableListDynInitMenuItem(
613 CEikListBox *aListBox,
615 TBool aCanBeAppliedToMultipleItems);
617 /** Helper function to implement command handling for markable list dialogs
619 IMPORT_C static void HandleMarkableListUpdateAfterCommandExecution(
620 CEikListBox *aListBox);
622 /** Helper function to position list highlight correctly after item removal
624 IMPORT_C static void HandleItemRemovalAndPositionHighlightL(
625 CEikListBox *aListBox,
626 TInt aValueOfCurrentItemIndexBeforeRemoval,
627 TBool aCurrentItemWasRemoved);
629 // This one updates selectionindexes too.
630 /** Helper function to position list highlight correctly after item removal
632 * It also updates selection index array based on information about which
633 * items were removed.
635 IMPORT_C static void HandleItemRemovalAndPositionHighlightL(
636 CEikListBox *aListBox,
637 TInt aValueOfCurrentItemIndexBeforeRemoval,
638 CArrayFix<TInt> &aIndexesOfRemovedItemsBeforeRemoval);
643 class CAknSearchField;
646 * This class implements find requirements from component specifications. This
647 * class works also as documentation of how to use different find components.
648 * (The implementation has been copied from the example application which
649 * implements find and replaced the code with calls to these static functions).
651 * There is no reason for an application to use this class directly.
652 * Application should use CAknSelectionListDialog instead. This class is public
653 * only because sometimes it is necessary to access the low level behaviour of
654 * find to implement similar functionality in places independent of find; or if
655 * @c CAknSelectionListDialog is not used for some reason.
662 * Implements the event handlers for the find pane. This method must be
663 * called when a @c ProcessCommandL event is received and a find pane is on
666 * @param aCommand Command id.
667 * @param aListBox Pointer to listbox control.
668 * @param aSearchField Pointer to search field control.
669 * @param aParentControl Parent control.
671 IMPORT_C static void HandleFindPopupProcessCommandL(
673 CEikListBox* aListBox,
674 CAknSearchField* aSearchField,
675 CCoeControl* aParentControl);
678 * Handles key events for the find pane. This method must be called when
679 * control receives @c OfferKeyEventL event.
681 * @param aKeyEvent The key event.
682 * @param aType The type of key event:@c TEventCode.
683 * @param aListBoxParent Pointer to the parent control.
684 * @param aListBox Pointer to listbox control.
685 * @param aSearchField Pointer to search field control.
686 * @param isFindPopup @c ETrue if popup find pane, @c EFalse if normal find
688 * @param aNeedRefresh @c ETrue when find pane is redrawn.
690 IMPORT_C static TKeyResponse HandleFindOfferKeyEventL(
691 const TKeyEvent& aKeyEvent,
693 CCoeControl* aListBoxParent,
694 CEikListBox* aListBox,
695 CAknSearchField* aSearchField,
697 TBool &aNeedRefresh);
700 * Do not use this method.
702 * @deprecated Use @c AknFind::HandleFixedFindSizeChanged() and
703 * @c AknFind::HandlePopupFindSizeChanged instead.
706 IMPORT_C static void HandleFindSizeChanged(
707 CCoeControl* aParentControl,
708 CEikListBox* aListBox,
709 CAknSearchField* aSearchField,
710 TBool ispopup = ETrue,
711 TInt aFindWindowResourceId = R_AVKON_POPUP_FIND_WINDOW,
712 TInt aListAreaId = R_AVKON_LIST_GEN_PANE,
713 TInt aListResourceIdWithFindPopup =
714 R_AVKON_LIST_GEN_PANE_WITH_FIND_POPUP,
715 TInt aFindWindowParentResourceId =
716 R_AVKON_MAIN_PANE_WITH_STATUS_PANE);
719 * This is the new typesafe (and easier to use) version of @c
720 * HandleFindSizeChanged(). Use this instead of (deprecated) @c
721 * HandleFindSizeChanged().
723 * @param aParentControl Parent control.
724 * @param aListBox Column list, optional and available only with column
726 * @param aSearchField Pointer to search field control.
728 IMPORT_C static void HandleFixedFindSizeChanged(
729 CCoeControl* aParentControl,
730 CAknColumnListBox* aListBox, // only available with column lists
731 CAknSearchField* aSearchField);
734 * This is the new typesafe(and easier to use) version of @c
735 * HandleFindSizeChanged(). Use this instead of (deprecated) @c
736 * HandleFindSizeChanged().
738 * @param aParentControl Parent control.
739 * @param aListBox Pointer to listbox control.
740 * @param aSearchField Pointer to search field control.
742 IMPORT_C static void HandlePopupFindSizeChanged(
743 CCoeControl* aParentControl,
744 CEikListBox* aListBox, //available with all lists.
745 CAknSearchField* aSearchField);
748 * Creates layout for a find pane and for a list. This method must be called
749 * in @c SizeChanged() method of an container.
753 * @param aParentControl Parent control.
754 * @param aListBox Pointer to listbox control.
755 * @param aSearchField Pointer to search field control.
756 * @param aFindWindow LAF specific table line for find window.
757 * @param aListArea LAF specific table for list box area.
758 * @param aIsPopup @c ETrue if popup find pane, @c EFalse if normal find
760 * @param aFindWindowParent LAF specific table line for find parent.
762 IMPORT_C static void HandleFindSizeChangedLayouts(
763 CCoeControl* aParentControl,
764 CEikListBox* aListBox,
765 CAknSearchField* aSearchField,
766 const TAknWindowLineLayout& aFindWindow,
767 const TAknWindowLineLayout& aListArea,
769 const TAknWindowLineLayout& aFindWindowParent );
774 * Checks if @c aItemText matches @c aSearchText.
776 * @param aItemText List box item text.
777 * @param aSearchText Searched text.
779 * @return @c ETrue if list box item text @c aItemText matches @c
780 * aSearchText otherwise @c EFalse.
782 IMPORT_C static TBool IsFindMatch(const TDesC& aItemText,
783 const TDesC& aSearchText);
786 * Tests if aCh is a word separator character as described in S60.
788 * @param aCh Comperative character.
790 * @return @c ETrue if aCh is a word separator character as described in
791 * S60 otherwise @c EFalse.
793 IMPORT_C static TBool IsFindWordSeparator(TChar aCh);
797 * Checks if @c aItemText matches @c aSearchText.
798 * Calls UpdateNextCharsL() if findutil is not supported.
801 * @param aItemText List box item text.
802 * @param aSearchText Searched text.
803 * @param aNextChars Reference to the next characters for the adaptive search grid
804 * The HBufC buffer may be re-allocated by this method.
805 * In that case the pointer reference is modified to point to the re-allocated object.
807 * @return @c ETrue if list box item text @c aItemText matches @c
808 * aSearchText otherwise @c EFalse.
810 IMPORT_C static TBool IsAdaptiveFindMatch( const TDesC& aItemText,
811 const TDesC& aSearchText,
812 HBufC*& aNextChars );
815 * Update next characters if find pane state was changed.
818 * @param aNextChars Next characters for the adaptive search grid
819 * @param aCh Criteria from the search field.
821 static void UpdateNextCharsL( HBufC*& aNextChars, TChar aCh );
824 * For Devanagari adaptive search
825 * Update next characters if find pane state was changed.
828 * @param aNextChars reference to the next characters for the adaptive search grid
829 * @param aItemString string we are searching.
831 static void UpdateNextCharsL( HBufC*& aNextChars, const TDesC& aItemString );
834 * Update next chars from the list box item text, when search field if empty.
835 * This need to be done for update next characters for adaptive grid
836 * works faster then calling IsAdaptiveFindMatch().
839 * @param aNextChars Reference to the next characters for the adaptive search grid
840 * The HBufC buffer may be re-allocated by this method.
841 * In that case the pointer reference is modified to point to the re-allocated object.
842 * @param aItemString List box item text.
844 IMPORT_C static void UpdateNextCharsFromString( HBufC*& aNextChars, const TDesC& aItemString );
847 * Update next chars from the list box item text according to the bitflag.
848 * Use to exclude columns from the listbox string. For example icon index columns.
851 * @param aInputText List box item text
852 * @param aColumnFlag The bit flag shows which columns take into account
853 * @param aOutText Updated list box item text accoding to bit flag
855 IMPORT_C static void UpdateItemTextAccordingToFlag( const TDesC& aInputText,
856 TBitFlags32 aColumnFlag,
860 * Helper function to handle find pane's visibility.
862 * @param aSearchField Pointer to search field control.
863 * @param ispopup @c ETrue if popup find pane, @c EFalse if normal find
865 * @param textchanged @c ETrue when text in @c CAknSearchField has changed.
866 * @param aNeedRefresh @c ETrue when find pane is redrawn.
868 static void HandleFindPaneVisibility(CAknSearchField* aSearchField,
871 TBool &aNeedRefresh);
876 * Utility class to initialize editor control. Use this in conjunction with @c
877 * AknLayoutUtils::LayoutEdwin(). The class is not fully implemented yet.
883 /** Basic elements that are needed for the basic editing functions. */
884 struct SAknEditorParameters
886 /** The maximum available space that can be used for one text. */
889 /** Size of the editing window. */
893 * Character case effects on the style of entering characters.
894 * Available alternatives are Upper case, Lower case and Text case.
899 * Specifies from which edge the current line is filled with the
900 * inserted characters.
904 /** Is user allowed to move the insertion point. */
905 TBool iAllowedToMoveInsertionPoint;
907 /** Is cursor blinking or not. */
910 /** Is overflow active or not. */
911 TBool iOverflowYesNo;
914 IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, TInt aResourceId);
915 IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, TResourceReader& aReader);
916 IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin, const SAknEditorParameters &aParams);
919 * Configures edwin editor. Use AknLayoutUtils::LayoutEdwin() with this method.
921 * @param aEdwin Edwins created with new.
922 * @param aEditingSpace maximum number of characters for the editor
923 * @param aEditingWindow maximum number of lines in the editor
924 * @param aCharacterCase initial character case:
925 * EAknEditorCharactersUpperCase = EAknEditorUpperCase,
926 * EAknEditorCharactersLowerCase = EAknEditorLowerCase,
927 * EAknEditorCharactersTextCase = EAknEditorTextCase,
928 * EAknEditorCharactersTitleCase = EAknEditorTitleCase
930 * @param aJustification alignment for the editor text ( EAknEditorAlignCenter,
931 * EAknEditorAlignLeft, EAknEditorAlignRight)
932 * @param aAllowedToMoveInsertionPoint user can move cursor
933 * @param aCursorYesNo is cursor visible or not.
934 * @param aOverflowYesNo
936 IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin,
941 TBool aAllowedToMoveInsertionPoint,
943 TBool aOverflowYesNo);
946 * Configures edwin editor. Use AknLayoutUtils::LayoutEdwin() with this method.
948 * @param aEdwin Edwins created with new.
949 * @param aEditingSpace maximum number of characters for the editor
950 * @param aEditingWindow maximum number of lines in the editor
951 * @param aCharacterCase initial character case:
952 * EAknEditorCharactersUpperCase = EAknEditorUpperCase,
953 * EAknEditorCharactersLowerCase = EAknEditorLowerCase,
954 * EAknEditorCharactersTextCase = EAknEditorTextCase,
955 * EAknEditorCharactersTitleCase = EAknEditorTitleCase
957 * @param aJustification alignment for the editor text ( EAknEditorAlignCenter,
958 * EAknEditorAlignLeft, EAknEditorAlignRight)
959 * @param aAllowedToMoveInsertionPoint user can move cursor
960 * @param aCursorYesNo is cursor visible or not.
961 * @param aOverflowYesNo
962 * @param aIsResizeable is edwin resizeable (one line editor should use EFalse, in order to have proper scrolling)
964 IMPORT_C static void ConstructEditingL(CEikEdwin* aEdwin,
969 TBool aAllowedToMoveInsertionPoint,
971 TBool aOverflowYesNo,
976 /** Automatic numbering for list items. (DEPRECATED)
977 * Just create this kind of object and attach it to a listbox, and you'll
978 * have automatic numbering.
981 * You'll need to call UpdateL() each time you modify the listbox's model!
983 class CListBoxNumbers : public CBase
986 IMPORT_C CListBoxNumbers(CEikTextListBox* aListBox);
987 IMPORT_C void ConstructL();
988 IMPORT_C void UpdateL();
990 CEikTextListBox* iListBox;
993 class CAknListBoxFilterItems;
996 * This class shows how application should build its model for filtered
997 * items. Application should not use this directly, if it has it's own model
998 * or if there's any special things needed for @c MatchableTextArray.
999 * Application can derive from this though. All listboxes use
1000 * @c CAknFilteredTextListBoxModel by default. @c CreateFilter() call
1004 class CAknFilteredTextListBoxModel : public CTextListBoxModel, public MDesCArray
1006 public: // public interface for apps
1008 * Creates a @c CAknListBoxFilterItems and thus enables filtering of list
1010 * @param aListBox List box from which one or more items can be selected.
1011 * @param aSearchField Search field control.
1013 IMPORT_C void CreateFilterL(CEikListBox* aListBox, CAknSearchField* aSearchField);
1015 * removes previously added filter from model
1017 IMPORT_C void RemoveFilter();
1019 * Access function for the filter.
1020 * @return Pointer to the listbox filter.
1022 IMPORT_C CAknListBoxFilterItems* Filter() const;
1026 IMPORT_C ~CAknFilteredTextListBoxModel();
1027 public: // from CTextListBoxMode
1029 * Implementation of @c CTextListBoxModel::NumberOfItems()
1030 * @return The number of items the list box has.
1032 IMPORT_C virtual TInt NumberOfItems() const;
1034 * Returns the text of the specified item.
1035 * @param aItemIndex Index to the item.
1036 * @return The text of item in given index.
1038 IMPORT_C virtual TPtrC ItemText(TInt aItemIndex) const;
1039 public: // from MEikTextListBoxModel (default filtering string conversions)
1041 * Implementation of @c CTextListBoxModel::MatchableTextArray()
1042 * @return Pointer to the text array.
1044 IMPORT_C const MDesCArray* MatchableTextArray() const;
1047 CAknListBoxFilterItems* iFilter; // owned
1048 private: // From MdesCArray (these implement default matchabletextarray for filtering.)
1049 IMPORT_C TInt MdcaCount() const;
1050 IMPORT_C TPtrC MdcaPoint(TInt aIndex) const;
1051 private: // from MListBoxModel
1052 IMPORT_C virtual TAny* MListBoxModel_Reserved();
1056 * Listbox item filtering. This class is designed to be stored inside
1057 * a listbox model and the model should call this in its @c NumberOfItems()
1058 * and @c ItemText() implementation. The model must be given to this class
1059 * and it must have @c MatchableTextArray() implemented correctly.
1060 * @c HandleOfferKeyEvent() should be called from the same offer key event
1061 * implementation which forwards the keys to listbox and search field
1063 * If you have both markable list and find at the same time, you should call
1064 * @c ResetFiltering() before executing the command for marked items. This
1065 * ensures that the ListBox's @c SelectionIndexes() returns all items instead
1066 * of only those items that are visible. Selected *items can be found under
1067 * @c CAknListBoxFilterItems::SelectionIndexes().
1072 class CAknListBoxFilterItems : public CBase, public MCoeControlObserver
1076 * Base class default constructor.
1077 * @param aListBox Listbox to be filtered,
1078 * @param aSearchField Listbox search field.
1079 * @param aModel Listbox model,
1080 * @param aView A list box view that displays the list items which are
1081 * currently visible in a list box.
1083 IMPORT_C CAknListBoxFilterItems(
1084 CEikListBox *aListBox,
1085 CAknSearchField *aSearchField,
1086 MListBoxModel *aModel,
1087 CListBoxView *aView);
1090 * This is for setting empty list text.
1092 IMPORT_C void ConstructL(); // for setting empty list text.
1094 * This function is to be called when filter is cleared.
1096 IMPORT_C void ResetFilteringL();
1098 * This function will update filter items state from the search field and
1099 * listbox. Also updates selection indexes.
1101 IMPORT_C void UpdateCachedDataL(); // updates iOldSearchCriteria and selection indexes.
1103 * Destructor. Frees all resources owned by the object prior to its
1106 IMPORT_C ~CAknListBoxFilterItems();
1110 * This one gives all indices, not just the ones that are visible.
1111 * @return Pointer to the array that has all indices.
1113 IMPORT_C CArrayFix<TInt> *SelectionIndexes();
1115 * This will synchronise the selection indices from the listbox.
1116 * If you use @c SelectionIndexes(), call this before it.
1117 * This is heavy operation and goes through all list items.
1119 IMPORT_C void UpdateSelectionIndexesL();
1121 * This will synchronise the selected index from the listbox.
1122 * If you use @c SelectionIndexes(), call this before it.
1123 * This is heavy operation and goes through all list items.
1124 * @param aVisibleIndex Index to be updated.
1126 IMPORT_C void UpdateSelectionIndexL(TInt aVisibleIndex);
1128 public: // Applications should call this in their listbox model implementation
1130 * This is used to ask how many list items are available after filter has
1131 * been used. Counts visible list items.
1132 * @return Number of items visible.
1134 IMPORT_C TInt FilteredNumberOfItems() const;
1136 * This is used to fetch the content of a list item after filter has been
1138 * @param aVisibleItemIndex The index of visible item.
1139 * @return Index to the original item array.
1141 IMPORT_C TInt FilteredItemIndex(TInt aVisibleItemIndex) const;
1143 public: // Needed to change the correct item.
1146 * Returns number of original list items.
1147 * @return Number of all items.
1149 IMPORT_C TInt NonFilteredNumberOfItems() const; // this always returns >= FilteredNumberOfItems()
1151 * Finds the list item on the screen when the item array index is given.
1152 * @param aOriginalIndex Item index.
1153 * @return Matching index from original array. Returns -1 if the Index is
1156 IMPORT_C TInt VisibleItemIndex(TInt aOriginalIndex) const;
1159 * For building @c MdcaPoint() of the model's @c MatchableTextArray.
1160 * This method builds the default value for @c MatchableTextArray.
1161 * @param aText Pointer descriptor.
1162 * @return Modified text.
1164 IMPORT_C TPtrC DefaultMatchableItemFromItem(TPtrC aText);
1168 * Applications should call this in @c OfferKeyEventL() which gives keys to
1169 * listbox and search field.
1171 IMPORT_C void HandleOfferkeyEventL();
1175 * When you change the list item array you should call this method.
1177 IMPORT_C void HandleItemArrayChangeL();
1179 public: // MCoeControlObserver
1181 * Sets the observer.
1182 * @param aObserver Pointer to the observer.
1184 IMPORT_C void SetObserver(MCoeControlObserver *aObserver);
1186 * Editor sends messages to this object as control events.
1187 * @param aControl The control that sent the event.
1188 * @param aEventType The event type.
1190 IMPORT_C void HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType);
1194 * Sends key events to FEP. This is used to resend key event to FEP if
1195 * @c AknFind's @c HandleOfferKeyEventL() gets the key while search field
1196 * has no focus. If search field has a focus, the key events go directly to
1197 * the editor and this is not called.
1198 * @param aValue The character code for an @c EEventKey.
1200 IMPORT_C void DeferredSendKeyEventToFepL(TUint aValue);
1202 * This gets called from @c DeferredSendKeyEventToFepL().
1203 * This does the actual sending of a key event. Does not support more than
1204 * one event at the time.
1205 * @param aFilterItems Pointer to the @c CAknListBoxFilterItems object.
1206 * @return Always returns 0.
1208 static TInt IdleCallBack(TAny *aFilterItems);
1210 public: // For size changed
1212 * @c AknFind uses this to inform us who is the parent control owning the
1213 * listbox and search field. This control should be window-owning control and
1214 * it will be used to resize the listbox when changes to the filtering
1216 * @param aControl Pointer to the control.
1218 IMPORT_C void SetParentControl(CCoeControl *aControl);
1220 * @c AknFind uses this to inform us that we have popup find. Applications
1221 * shouldn't call this.
1223 IMPORT_C void SetPopup();
1225 public: // For detaching and attaching list, findbox, model and view...
1227 * Attaches or detaches list used by the filtering.
1229 * @param aListBox Pointer to listbox or @c NULL.
1231 IMPORT_C void SetListBox(CEikListBox *aListBox);
1233 * Attaches or detaches find pane used by the filtering.
1235 * @param aSearchField Pointer to findbox or @c NULL.
1237 IMPORT_C void SetSearchField(CAknSearchField *aSearchField);
1239 * Attaches or detaches list model used by the filtering.
1241 * @param aModel a pointer to list model or @c NULL.
1243 IMPORT_C void SetModel(MListBoxModel *aModel);
1245 * Attaches or detaches list view used by the filtering.
1247 * @param aView a pointer to list view or @c NULL.
1249 IMPORT_C void SetView(CListBoxView *aView);
1253 * This function just returns pointer to the search field.
1254 * @return Pointer to the search field.
1256 IMPORT_C CCoeControl *FindBox() const;
1259 * An improved version of DeferredSendKeyEventToFepL. It sends a
1260 * @c TKeyEvent rather than just key code. Thus the correct key
1261 * event can be send to FEP on QWERTY keyboard.
1263 * @param aEvent Event send to FEP.
1265 void DeferredSendFullKeyEventToFepL(const TKeyEvent& aEvent);
1268 void NoCriteriaL(TBool aUpdateAS = ETrue); // remove criteria completely.
1269 void TightenCriteriaL(const TDesC& aCriteria); // slow operation (do when adding new characters to search criteria)
1270 void ReleaseCriteriaL(const TDesC& aCriteria); // very slow operation (do when removing characters from search criteria)
1271 // EmptyListText handling
1272 void InstallEmptyTextL();
1273 void UninstallEmptyTextL();
1274 // Selections -- these methods form a pair,
1275 // you must call Fetch first and then push.
1276 void FetchSelectionIndexesFromListBoxL();
1277 void PushSelectionIndexesToListBoxL();
1278 void ClearNextChars();
1279 TBool IsAdaptiveSearch() const;
1281 // HandleItemAddition without ResetFilteringL() call
1282 void HandleItemAdditionL();
1283 void HandleItemRemovalL();
1285 TBool IsItemVisible(const TDesC& aMatchableItemString, const TDesC& aSearchText);
1286 static TBool IsSeparatorCharacter(TChar c);
1287 TBool IsItemSelected(TInt aRealIndex) const;
1289 CArrayFix<TInt> *iShownIndexes; // own // uses non-filtered indexes
1290 CArrayFix<TInt> *iSelectionIndexes; // own // this uses non-filtered indexes
1291 HBufC *iOldSearchCriteria; // own
1292 MListBoxModel *iModel;
1293 CListBoxView *iView;
1295 HBufC* iEmptyListText; // own
1296 CEikListBox* iListBox;
1297 CAknSearchField* iSearchField;
1298 TBuf<256> iMatchableText;
1299 MCoeControlObserver *iObserver;
1300 CFindExtension *iExtension;
1302 CCoeControl *iParentControl;
1304 TBool iDisableChangesToShownIndexes;
1308 /** Removing optimization that breaks listbox views
1309 * A view which removes optimization from CListBoxView which breaks with lists where all items are not
1312 * CListBoxView* MakeViewClassInstanceL() { return new(ELeave) NoOptimizationView<CListBoxView>; }
1315 class NoOptimizationView : public T
1318 virtual void VScrollTo(TInt aNewTopItemIndex, TRect& aMinRedrawRect)
1321 if (this->RedrawDisabled())
1323 if (this->iTopItemIndex == aNewTopItemIndex)
1325 aMinRedrawRect.SetRect(this->iViewRect.iTl,this->iViewRect.Size());
1326 this->SetTopItemIndex(aNewTopItemIndex);
1327 this->Draw(&aMinRedrawRect);
1333 /** This is private class, do not use it except for drawing controls!
1335 * Do not use it in applications.
1342 static void DrawLines(CGraphicsContext* aGc,
1343 const TRect& mainpane,
1345 IMPORT_C static void ReplaceColumn(TPtr aTarget, TDesC* aSource,
1346 TDesC* aReplacement, TChar aColumnSeparator,
1352 * Resource reader class
1354 * This is utility class for reading listbox resouces.
1356 * This should be derived from and it reads resource file for you.
1358 * This seems to be only used by listbox resource readers. (Do not use it in applications)
1360 struct SAknLayoutGfx;
1361 struct SAknLayoutText;
1362 struct SAknLayoutCmd;
1363 struct SAknLayoutGfx;
1365 struct SAknLayoutPos
1367 TInt l, t, r, b, W, H;
1369 typedef SAknLayoutPos ItemType;
1370 static void ReadResource(TResourceReader& aReader, ItemType& aTarget);
1372 template<class T> class CArrayReader;
1373 class CAknGenericReader : public CBase
1376 IMPORT_C void ConstructL(TInt aResourceId);
1377 IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
1378 IMPORT_C ~CAknGenericReader();
1380 IMPORT_C const SAknLayoutGfx* GfxItem(TInt aIndex) const;
1381 IMPORT_C const SAknLayoutText* TextItem(TInt aIndex) const;
1382 IMPORT_C const SAknLayoutCmd* CmdItem(TInt aIndex) const;
1383 IMPORT_C const SAknLayoutGfx* AreaItem(TInt aIndex) const;
1385 CArrayReader<SAknLayoutGfx>* iGfx;
1386 CArrayReader<SAknLayoutText>* iText;
1387 CArrayReader<SAknLayoutCmd>* iCmd;
1388 CArrayReader<SAknLayoutGfx>* iArea;
1395 // Use this to mark that the position in LAF specification is empty.
1396 const TInt AknLayoutUtilsNoValue = ELayoutEmpty;
1398 /** Utility classes to build layout based on European LAF from resource files. (can be used by applications)
1400 * Methods in this class are designed to be called from your control's SizeChanged() method!
1402 * This class knows the specification's coordinate data format and ensures that different types of
1403 * controls are positioned and setup correctly according to European LAF.
1405 * This class helps you with positioning labels, controls, rects and other things to according to LAF specification.
1406 * (It is NOT trivial to get it correct and this adjusts easily to changes in the LAF specification - if you're not
1407 * using this, remember to read the whole LAF specification - especially the beginning and the end with color and
1408 * especially how text margins and widths interact!!)
1410 * (idea of this class is that when specification of one component changes, only resource file needs to be changed and when you
1411 * get new product with new specification format, only this module needs to be changed and resources rewritten from the specification.
1412 * And when component's specification changes, only the component need to be changed (usually only change is what components are
1413 * inside it and how it calls this module.).. => all controls have common format that decides its layout!
1415 * Parent rectangles are always coordinates of LAF specification's parent rectangle in the screen.
1417 * To use this, call one of the methods in your SizeChanged() and then you'll need to make sure you
1418 * draw the area between controls using ClearBetweenRects() call from egul library. (CCoeControl::Rect() helps with that...)
1420 * A Tip: You do not want to use any dynamic calculation of layouts! It is almost always an error to do so!
1421 * => Do not allow layouts that have not been specified!
1423 * (If LAF spec has many numbers and you need to dynamically choose between them, then keep the numbers in
1424 * code as function-local using SAknLayoutText/SAknLayoutRect/... -structs..)
1426 * You'll want to use TAknLayoutRect and TAknLayoutText too to build layout
1427 * for your custom controls.
1429 class AknLayoutUtils
1433 struct SAknLayoutText
1435 TInt iFont, iC, iL, iR, iB, iW, iJ;
1437 struct SAknLayoutTextMultiline
1439 TInt iFont, iC, iL, iR, iB, iW, iJ, iNumberOfLinesShown, iNextLineB;
1441 typedef SAknLayoutTextMultiline SAknLayoutLabel;
1442 typedef SAknLayoutTextMultiline SAknLayoutEdwin;
1443 typedef SAknLayoutText SAknLayoutMfne;
1444 typedef SAknLayoutText SAknLayoutSecEd;
1445 struct SAknLayoutRect
1447 TInt iC, iL, iT, iR, iB, iW, iH;
1449 typedef SAknLayoutRect SAknLayoutControl;
1450 typedef SAknLayoutRect SAknLayoutImage;
1453 * Deprecated! Do not use!
1455 IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
1456 const TRect& aLabelParent,
1458 const CFont* aCustomFont=0);
1461 * Deprecated! Do not use!
1463 IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
1464 const TRect& aLabelParent,
1465 TResourceReader& aReader,
1466 const CFont* aCustomFont=0);
1468 /** Layouts a label via a structure of layout parameters
1469 @param aLayout the structure
1471 IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
1472 const TRect& aLabelParent,
1473 const SAknLayoutLabel& aLayout,
1474 const CFont *aCustomFont=0);
1476 /** Layouts a label via a layout compiler output
1477 @param aLayout a define from aknlayout.lag file
1479 IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
1480 const TRect& aLabelParent,
1481 const TAknMultiLineTextLayout& aLayout,
1482 const CFont *aCustomFont=0);
1484 /** Layouts a label via a layout compiler output
1485 @param aLayout a define from aknlayout.lag file
1487 IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
1488 const TRect& aLabelParent,
1489 const TAknTextLineLayout& aLayout,
1490 const CFont *aCustomFont=0);
1492 /** Layouts a label via parameters from the specification
1493 @param aLayout a define from aknlayout.lag file
1494 @param font font id, ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19 etc..
1495 @param C colour index, 0..255
1496 @param l left margin
1497 @param r right margin
1498 @param B Baseline from top of the parent rectangle
1499 @param W text width in pixels
1500 @param J justification. ELayoutAlignNone; ELayoutAlignCenter; ELayoutAlignLeft; ELayoutAlignRight; ELayoutAlignBidi
1501 @param NextLineB baseline of 2nd line for multi-line labels/editors
1502 @param aCustomFont a font used, if resource file uses EFontCustom
1504 IMPORT_C static void LayoutLabel(CEikLabel* aLabel,
1505 const TRect& aLabelParent,
1509 TInt J, TInt NextLineB=0,
1510 const CFont* aCustomFont=0);
1513 * Deprecated! Do not use!
1515 IMPORT_C static void LayoutEdwin(CEikEdwin* aEdwin,
1516 const TRect& aEdwinParent,
1518 TInt aNumberOfLines = 0,
1519 const CFont* aCustomFont=0,
1520 TBool aMinimizeEdwinView=EFalse);
1522 * Deprecated! Do not use!
1524 IMPORT_C static void LayoutEdwin(CEikEdwin* aEdwin,
1525 const TRect& aEdwinParent,
1526 TResourceReader& aReader,
1527 TInt aNumberOfLines = 0,
1528 const CFont* aCustomFont=0,
1529 TBool aMinimizeEdwinView=EFalse);
1531 /** Layouts an editor via a structure of layout parameters
1532 @param aLayout the structure
1534 IMPORT_C static void LayoutEdwin(CEikEdwin* aEdwin,
1535 const TRect& aEdwinParent,
1536 const SAknLayoutEdwin& aLayout,
1537 const CFont* aCustomFont=0,
1538 TBool aMinimizeEdwinView=EFalse);
1540 /** Layouts an editor via a structure of layout parameters
1541 @param aLayout the structure
1544 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1545 const TRect& aEdwinParent,
1546 const TAknMultiLineTextLayout& aLayout,
1547 const CFont* aCustomFont=0,
1548 TBool aMinimizeEdwinView=EFalse);
1550 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1551 const TRect& aEdwinParent,
1552 const TAknMultiLineTextLayout& aLayout,
1553 TAknsQsnTextColorsIndex aOverrideColor,
1554 const CFont* aCustomFont=0,
1555 TBool aMinimizeEdwinView=EFalse );
1559 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1560 const TRect& aEdwinParent,
1561 const TAknTextLineLayout& aLayout,
1562 const CFont* aCustomFont=0,
1563 TBool aMinimizeEdwinView=EFalse );
1565 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1566 const TRect& aEdwinParent,
1567 const TAknTextLineLayout& aLayout,
1568 TAknsQsnTextColorsIndex aOverrideColor,
1569 const CFont* aCustomFont=0,
1570 TBool aMinimizeEdwinView=EFalse );
1573 * Routine to perform standard layout of a CEikEdwin editor. Two elements from the S60 layout data are required:
1574 * The rectangle of the containing layout element, and the TAknTextLineLayout object created for the contained text pane element.
1576 * Override parameters can be supplied for a different number of lines, a different baseline separation,
1577 * or substituted skin color. Various "Do Not Override" values are to be passed if the values passed in aLayout are to be used.
1578 * Refer to the parameters' documentation.
1580 * The lower extent of the editor to be laid out (whether driven by the NumberOfLinesToShow()
1581 * feature of the TAknTextLineLayout object, or overridden by aNumberOfLinesToShowOverRide)
1582 * will not extend below the lower limit of the rectangle aEdwinParent. Thus the number of
1583 * lines formatted is limited, and is available as an output parameter.
1585 * The height of the editor is also restricted by any value previously set in
1586 * CEikEdwin::SetMaximumHeightInLines().
1590 * @param aEdwin pointer to the editor to be laid out
1591 * @param aEdwinParent rectangle of the containing layout element
1592 * @param aLayout object representing the layout of the text pane implemented by this editor
1593 * @param aNumberOfLinesToShowOverride number of lines overriding aLayout, if not KAknLayoutUtilsDoNotOverride
1594 * @param aBaselineSeparationOverride vertical separation of baselines overriding aLayout, if not KAknLayoutUtilsDoNotOverride
1595 * @param aOverrideColor Avkon Skins color index to override with, if
1596 * not (TAknsQsnTextColorsIndex)KAknLayoutUtilsDoNotOverride
1597 * @param aNumberOfVisibleLines Number of lines of editor actually laid out.
1599 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1600 const TRect& aEdwinParent,
1601 const TAknTextLineLayout& aLayout,
1602 TInt aNumberOfLinesToShowOverRide,
1603 TInt aBaselineSeparationOverRide,
1604 TAknsQsnTextColorsIndex aOverrideColor,
1605 TInt& aNumberOfVisibleLines );
1607 /** Layouts an editor via parameters from the specification
1608 @param aLayout a define from aknlayout.lag file
1609 @param font font id, ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19 etc..
1610 @param C colour index, 0..255
1611 @param l left margin
1612 @param r right margin
1613 @param B Baseline from top of the parent rectangle
1614 @param W text width in pixels
1615 @param J justification. ELayoutAlignNone; ELayoutAlignCenter; ELayoutAlignLeft; ELayoutAlignRight; ELayoutAlignBidi
1616 @param aNumberOfLinesShown number of lines visible for the editor
1617 @param NextLineB baseline of 2nd line for multi-line labels/editors
1618 @param aMinimizeEdwinView whether to use minimum size. You need to use MinimizedEdwinRect() if you use ETrue here.
1620 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1621 const TRect& aEdwinParent,
1629 TInt aNumberOfLinesShown,
1630 TInt aNextLineBaseline,
1631 const CFont* aCustomFont=0 ,
1632 TBool aMinimizeEdwinView=EFalse );
1634 IMPORT_C static void LayoutEdwin( CEikEdwin* aEdwin,
1635 const TRect& aEdwinParent,
1643 TInt aNumberOfLinesShown,
1644 TInt aNextLineBaseline,
1645 TAknsQsnTextColorsIndex aOverrideColor,
1646 const CFont* aCustomFont=0 ,
1647 TBool aMinimizeEdwinView=EFalse );
1648 /** Use this, if you give aMinimizeEdwinView to LayoutEdwin as true.
1649 * The edwin will not draw the whole rectangle allocated for the control.
1651 IMPORT_C static TRect MinimizedEdwinRect(const CEikEdwin *aEdwin);
1655 * Deprecated! Do not use!
1657 IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
1658 const TRect& aMfneParent,
1661 * Deprecated! Do not use!
1663 IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
1664 const TRect& aMfneParent,
1665 TResourceReader& aReader);
1667 IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
1668 const TRect& aMfneParent,
1669 const SAknLayoutMfne& aLayout);
1671 IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
1672 const TRect& aMfneParent,
1673 const TAknTextLineLayout& aLayout);
1675 IMPORT_C static void LayoutMfne(CEikMfne* aMfne,
1676 const TRect& aMfneParent,
1677 TInt font, TInt C, TInt l, TInt r,
1678 TInt B, TInt W, TInt J);
1681 * Deprecated! Do not use!
1683 IMPORT_C static void LayoutControl(CCoeControl* aControl,
1684 const TRect& aControlParent,
1687 * Deprecated! Do not use!
1689 IMPORT_C static void LayoutControl(CCoeControl* aControl,
1690 const TRect& aControlParent,
1691 TResourceReader& aReader);
1693 IMPORT_C static void LayoutControl(CCoeControl* aControl,
1694 const TRect& aControlParent,
1695 const SAknLayoutControl& aLayout);
1697 IMPORT_C static void LayoutControl(CCoeControl* aControl,
1698 const TRect& aControlParent,
1699 const TAknWindowLineLayout& aLayout);
1701 IMPORT_C static void LayoutControl(CCoeControl* aControl,
1702 const TRect& aControlParent,
1703 TInt /*C*/, TInt l, TInt t, TInt r, TInt b,
1707 * Deprecated! Do not use!
1709 IMPORT_C static void LayoutImage(CEikImage* aImage,
1710 const TRect& aParent,
1713 * Deprecated! Do not use!
1715 IMPORT_C static void LayoutImage(CEikImage* aImage,
1716 const TRect& aParent,
1717 TResourceReader& aReader);
1719 IMPORT_C static void LayoutImage(CEikImage* aImage,
1720 const TRect& aParent,
1721 const SAknLayoutControl& aLayout);
1723 IMPORT_C static void LayoutImage(CEikImage* aImage,
1724 const TRect& aParent,
1725 const TAknWindowLineLayout& aLayout);
1727 IMPORT_C static void LayoutImage(CEikImage* aImage,
1728 const TRect& aParent,
1729 TInt C, TInt l, TInt t, TInt r, TInt b,
1732 /** Sets CEikSecretEditor's position, colors and fonts based on LAF specification
1735 IMPORT_C static void LayoutSecretEditor(CEikSecretEditor* aSecEd,
1736 const TRect& aParent,
1737 const SAknLayoutText& aLayout);
1739 IMPORT_C static void LayoutSecretEditor(CEikSecretEditor* aSecEd,
1740 const TRect& aParent,
1741 const TAknTextLineLayout& aLayout);
1744 /** Different conversions
1745 * Fonts: ELatinPlain12, ELatinBold12, ELatinBold13, ELatinBold17, ELatinBold19, ENumberPlain5, EClockBold30, ELatinClock14, EFontCustom
1746 * EAknLogicalFontPrimaryFont, EAknLogicalFontSecondaryFont, EAknLogicalFontTitleFont,
1747 * Alignments: ELayoutAlignNone, ELayoutAlignCenter, ELayoutAlignLeft, ELayoutAlignRight, ELayoutAlignBidi with these..
1749 IMPORT_C static TRect TextRectFromCoords(const TRect& aParent,
1755 IMPORT_C static TRect RectFromCoords(const TRect& aParent,
1756 TInt l, TInt t, TInt r, TInt b,
1760 * Method to return a useable system font reference from a S60 font enumeration from among
1761 * the supported list.
1763 * This method should only be used if application code needs to render its own graphics. That is, it
1764 * is not using S60 controls and furthermore not using the recommended methods
1765 * AknLayoutUtils::LayoutEdwin(), AknLayoutUtils::LayoutLabel() or AknLayoutUtils::LayoutSecretEditor().
1767 * Fonts returned by this are not recommended to be stored in clients' member data, but should be
1768 * accessed when they are required for use.
1770 * Applications that are written to run with their layout dynamically adapting to different screen sizes
1771 * should use only the values found in the S60 logical font enumeration, TAknLogicalFontId.
1773 * @param aFontId Input S60 font id.
1774 * @param aCustomFont Font to return if aFontId is given as EFontCustom
1775 * @return const pointer to a system font, or aCustomFont
1777 IMPORT_C static const CFont* FontFromId(TInt aFontId, const CFont* aCustomFont=0);
1780 * Method to return a system font reference from a S60 font id. This will always conform to type CAknLayoutFont
1782 * This method should only be used if application code needs to render its own graphics. That is, it
1783 * is not using S60 controls and furthermore not using the recommended methods
1784 * AknLayoutUtils::LayoutEdwin(), AknLayoutUtils::LayoutLabel() or AknLayoutUtils::LayoutSecretEditor().
1786 * Fonts returned by this are not recommended to be stored in clients' member data, but should be
1787 * accessed when they are required for use.
1789 * Applications that are written to run with their layout dynamically adapting to different screen sizes
1790 * should use only the values found in the S60 logical font enumeration, TAknLogicalFontId.
1792 * @param aFontId Input S60 font id.
1793 * @param aCustomFont Font to return if aFontId is given as EFontCustom
1794 * @return const pointer to a system font, or aCustomFont
1796 IMPORT_C static const CAknLayoutFont* LayoutFontFromId(TInt aId,
1797 const CAknLayoutFont *aCustomFont = 0);
1800 * Return a fully constructed CAknLayoutFont object based upon the specification passed in.
1801 * The Avkon font specifiation object uses TAknFontCategory to determine the font.
1803 * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
1805 * @param aSpec S60 font specification object
1806 * @return pointer to a CAknLayoutFont object, owned by the caller
1808 IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL(
1809 const TAknFontSpecification& aSpec );
1812 * Return a fully constructed CAknLayoutFont object based upon the typeface and specification passed in.
1813 * The TTypeface object contains a typeface name that is used as the primary key to select a font.
1814 * The S60 font specifiation object is also used, but any value of TAknFontCategory passed in is reset to
1815 * EAknFontCategoryUndefined, and is not used to select the font.
1817 * The font object is returned as non-const, since it is owned and will eventually be deleted by the client.
1819 * @param aTypeface Symbian Typface object
1820 * @param aSpec S60 font specification object
1821 * @return pointer to a CAknLayoutFont object, owned by the caller
1823 IMPORT_C static CAknLayoutFont* CreateLayoutFontFromSpecificationL(
1824 const TTypeface& aTypeface,
1825 const TAknFontSpecification& aSpec);
1828 * Deprecated! Do not use!
1830 IMPORT_C static const CFont* FontFromName(const TDesC& aName);
1832 IMPORT_C static CGraphicsContext::TTextAlign TextAlignFromId(TInt aId);
1834 IMPORT_C static TGulAlignment GulAlignFromId(TInt aId);
1836 IMPORT_C static TInt CursorHeightFromFont(const TFontSpec& aFont);
1838 IMPORT_C static TInt CursorWidthFromFont (const TFontSpec& aFont);
1840 IMPORT_C static TInt CursorAscentFromFont(const TFontSpec& aFont);
1842 IMPORT_C static void CursorExtensionsFromFont(const TFontSpec& /*aFont*/,
1843 TInt& aFirstExtension,
1844 TInt& aSecondExtension);
1846 IMPORT_C static TInt HighlightLeftPixelsFromFont (const TFontSpec& aFont);
1848 IMPORT_C static TInt HighlightRightPixelsFromFont(const TFontSpec& aFont);
1849 static void HighlightExtensionsFromFont(const TInt fontid,
1850 TInt& aLeft, TInt& aRight,
1851 TInt& aTop, TInt& aBottom);
1854 * Access the system font array to see if there is a font that matches the
1855 * font specification presented in Twips. Device map is also passed in case the
1856 * system font array has fonts from different devices.
1858 * A null return value means that the system font array is not constructed yet, or does
1859 * not contain a font that has the same TFontSpec or device map.
1861 * @param aSpec Symbian font specification object to match
1862 * @param aMap Device map to disambiguate fonts on different devices
1863 * @return NULL if no match was found; otherwise a CAknLayoutFont pointer
1865 static const CAknLayoutFont* MatchFontFromSystemFontArray(
1866 const TFontSpec& aSpec, MGraphicsDeviceMap* aMap );
1868 IMPORT_C static TBool LayoutMirrored();
1871 * This method returns build variant based on which flag is active,
1872 * __AVKON_ELAF__ or __AVKON_APAC__.
1874 * If you need to decide which layout to use, do not do it based on this method.
1875 * Instead, use CAknEnv::GetCurrentLayoutId().
1877 * @return current variant
1879 IMPORT_C static EVariantFlag Variant();
1881 IMPORT_C static ESubVariantFlag SubVariant();
1883 IMPORT_C static void OverrideControlColorL(
1884 CCoeControl& aControl,
1885 TLogicalColor aLogicalColor,
1889 * This method returns the default scrollbar type for the given application.
1890 * For non-layout aware applications (e.g. legacy apps designed for 176x208 screen)
1891 * this method returns always EArrowHead. But for layout aware apps the returned type
1892 * may vary depending on the type of scrollbar which has been set as preferred
1893 * scrollbar type in the device.
1895 * Note that applications may use freely whatever scrollbartype, this method only
1896 * returns the default scrollbartype for the application.
1899 * @param aApplication Application of which default scrollbar type is requested.
1900 * @return Default scrollbar type for the given application
1902 IMPORT_C static CEikScrollBarFrame::TScrollBarType DefaultScrollBarType(CAknAppUiBase* aApplication);
1905 * This method sets the layout for vertical scrollbar of the given scrollbar frame. Layout
1906 * can freely only be set for EDoubleSpan type scrollbars.
1909 * @param aScrollBarFrame Scrollbarframe of which vertical scrollbar layout will be set.
1910 * @param aControlParent Rect of the parent control of the scrollbarframe.
1911 * @param aLayout Layout for the vertical scrollbar.
1914 * This method can also be useful when layout of the scrollbar needs to be changed for scrollbars
1915 * which are owned by some other components such as e.g. ListBoxes, Editors or Grids.
1919 * // Get a pointer to scrollbarframe of the listbox
1920 * CEikScrollBarFrame* frame = iListBox->ScrollBar();
1922 * // Get the layout data
1923 * TAknWindowLineLayout layout = GetMyListBoxLayout();
1924 * Trect parentRect = GetMyListBoxParentRect();
1927 * AknLayoutUtils::LayoutVerticalScrollBar(frame, parentRect, layout);
1929 * // The layout for scrollbar is now set.
1932 IMPORT_C static void LayoutVerticalScrollBar(
1933 CEikScrollBarFrame* aScrollBarFrame,
1934 const TRect& aControlParent,
1935 const TAknWindowLineLayout& aLayout);
1938 * This method sets the layout for horizontal scrollbar of the given scrollbar frame. Layout
1939 * can freely only be set for EDoubleSpan type scrollbars.
1942 * @param aScrollBarFrame Scrollbarframe of which horizontal scrollbar layout will be set.
1943 * @param aControlParent Rect of the parent control of the scrollbarframe.
1944 * @param aLayout Layout for the horizontal scrollbar.
1947 * Usage of this method is similar as for LayoutVerticalScrollBar().
1950 IMPORT_C static void LayoutHorizontalScrollBar(
1951 CEikScrollBarFrame* aScrollBarFrame,
1952 const TRect& aControlParent,
1953 const TAknWindowLineLayout& aLayout);
1955 public: // Metrics API
1960 enum TAknLayoutMetrics
1965 /** Window that fills the entire screen. */
1968 /** Indicates common components for most of the applications. */
1971 /** The application main pane is used in all the applications */
1974 /** Control pane. */
1977 /** The signal pane is used to indicate signal strength. */
1980 /** The context pane is used to indicate an active application. */
1983 /** Used to indicate the subject or the name of the main pane content.*/
1986 /** The battery pane is used to indicate battery strength. */
1990 * The universal indicator pane is used to indicate items that require
1991 * the user's attention while browsing applications.
1993 EUniversalIndicatorPane,
1996 * The navi pane is used to indicate navigation within an application,
1997 * to provide context sensitive information to the user while entering
1998 * or editing data, or to show additional information.
2003 * A fixed find pane is used with lists instead of the find pop-up
2007 /** Wallpaper pane. */
2011 * The universal indicator pane is used to indicate items that require
2012 * the user's attention while browsing applications.
2016 /** Used generally to display small sized graphics or heading texts. */
2019 /** Used generally to display large sized icons or heading texts. */
2023 * Used generally to display data entered by the user. Overlaps with
2029 * Used generally to display additional icons. Overlaps with
2034 /** @deprecated, do not use */
2035 EStatusPaneSecondary,
2037 /** deprecated, do not use */
2038 EControlPaneSecondary,
2040 /** Top part of status and control panes in landscape layout. */
2043 /** Bottom part of status and control panes in landscape layout. */
2049 /** Bottom part of status pane in landscape layout. */
2050 EStatusPaneBottom = EStatusPaneSecondary,
2052 /** Bottom part of control pane in landscape layout. */
2053 EControlPaneBottom = EControlPaneSecondary,
2055 /** Top part of control pane in landscape layout. */
2056 EControlPaneTop = EControlPane,
2058 /** Top part of status pane in landscape layout. */
2059 EStatusPaneTop = EStatusPane
2064 * Fills given TRect with rectangle for given layout component.
2065 * Returns EFalse for status pane descendants if requested
2066 * layout component is not available in current layout. For
2067 * other components returns always ETrue (returned rectangle is
2068 * from layout definition).
2071 * @param aParam Layout component to be queried.
2072 * @param aRect Resulting rectangle.
2073 * @param ETrue If requested value was available.
2076 IMPORT_C static TBool LayoutMetricsRect(TAknLayoutMetrics aParam, TRect& aRect);
2079 * This method returns size of rectangle for given layout component.
2080 * Returns EFalse for status pane descendants if requested
2081 * layout component is not available in current layout. For
2082 * other components returns always ETrue (returned size is
2083 * from layout definition).
2086 * @param aParam Layout component to be queried.
2087 * @param aSize Resulting size.
2088 * @param ETrue If requested value was available.
2091 IMPORT_C static TBool LayoutMetricsSize(TAknLayoutMetrics aParam, TSize& aSize);
2094 * This method returns position of top left corner for given layout component.
2095 * Returns EFalse for status pane descendants if requested
2096 * layout component is not available in current layout. For
2097 * other components returns always ETrue (returned position is
2098 * from layout definition).
2101 * @param aParam Layout component to be queried.
2102 * @param aPos Resulting position.
2103 * @param ETrue If requested value was available.
2106 IMPORT_C static TBool LayoutMetricsPosition(TAknLayoutMetrics aParan, TPoint& aPos);
2109 * This method returns a new value for a baseline, based upon a value for bottom and
2110 * a value for height. For legacy layout data, the baseline will be correct, and this
2111 * method will detect that it is a legacy font id and just return aBottom.
2112 * However, for scalable layout data, the bottom value will be hidden inside
2113 * the old baseline variable, so call this method passing in 'iB', NOT passing in 'ib'
2114 * ... e.g.: (the following line is an example, so is ok to have commented out code)
2115 * TInt newbaseline = CorrectBaseline(myLayoutLine.iB, myLayoutLine.iFont);
2118 * @param aBottom Baseline or Bottom value of text pane (found in TAknTextLineLayout.iB)
2119 * @param aFontId FontId of text pane (for scalable layouts, this will encode the height)
2120 * @return new Baseline value
2122 static TInt CorrectBaseline(TInt aParentHeight, TInt aBaseline, TInt aFontId);
2125 * This method updates fontid if it has ELayoutEmpty or parent relative values
2127 static void CorrectFontId(TRect aParent, TInt at, TInt aH, TInt ab, TInt &aFontId);
2130 * This method tells if the scalable layout interface is available.
2133 * @return ETrue if scalable layout interface can be used, otherwise EFalse.
2135 IMPORT_C static TBool ScalableLayoutInterfaceAvailable();
2138 * Enumeration of CBA's possible locations.
2141 enum TAknCbaLocation
2143 EAknCbaLocationBottom, //landscape and portrait
2144 EAknCbaLocationRight, //only landscape
2145 EAknCbaLocationLeft //only landscape
2149 * This method tells location of softkeys (CBA) field in current running application.
2150 * Possible location of softkeys are bottom (portrait and landscape), left and right
2154 * @return TAknCbaLocation
2156 IMPORT_C static TAknCbaLocation CbaLocation();
2159 * Used by pop-ups to align themselves around the given highlighted area.
2160 * @param aHighlightRect Highlighted area.
2161 * @param aControl Control whose position should be calculated,
2162 * @return TRect Size and position of pop-up.
2164 static TRect HighlightBasedRect( const TRect& aHighlightRect, CCoeControl* aControl );
2167 * Flags for main_pane status
2169 enum TAknMainPaneState
2171 EAknMainPaneForTinyStatusPane = 0x0001 // for 3x4 grid or app shell list views
2173 IMPORT_C static TAknMainPaneState MainPaneState();
2176 * This method can be used to check whether pen support is enabled.
2177 * @return ETrue if pen support is enabled, otherwise EFalse.
2179 IMPORT_C static TBool PenEnabled();
2182 * This method can be used to check whether MSK support is enabled.
2183 * @return ETrue if MSK support is enabled, otherwise EFalse.
2185 IMPORT_C static TBool MSKEnabled();
2188 * Utility method to be used along side LayoutEdwin methods that take number of lines or
2189 * baseline separation overrides.
2191 * This routine returns the edwin height in pixels required to fit exactly the passed-in layout,
2192 * or the layout with overridden baseline separation and/or number of lines.
2194 * The vertical position of the editor is also returned. Note that the correct
2195 * height of the parent layout item is needed in order for this to be calculated properly.
2197 * Note that this API does not cause a layout of the editor.
2201 * @param aParentHeight Height of the parent layout item
2202 * @param aLayout S60 layout object for the text to be laid out in the editor
2203 * @param aBaselineSeparationOverride vertical separation of baselines overriding aLayout, if not KAknLayoutUtilsDoNotOverride
2204 * aLayout, if not KAknLayoutUtilsDoNotOverride
2205 * @param aNumberOfLinesToShowOverride number of lines overriding aLayout,
2206 * if not KAknLayoutUtilsDoNotOverride
2207 * @param aEdwinVerticalPositionRelativeToParent Returns the vertical postion of the editor
2208 * relative to its parent when laid out.
2209 * @param aEdwinHeight The height required in pixels to fit the required number of laid
2210 * out lines plus highlights.
2212 IMPORT_C static void GetEdwinVerticalPositionAndHeightFromLines(
2214 const TAknTextLineLayout& aLayout,
2215 TInt aBaselineSeparationOverRide,
2216 TInt aNumberOfLinesToShowOverRide,
2217 TInt& aEdwinVerticalPositionRelativeToParent,
2222 * Utility routine to give the number of text lines that will completely fit,
2223 * including room for highlights, within the given height, when the passed in layout is
2226 * Note that the NumberOfLinesShown() value from the TAknTextLineLayout object is not taken into
2227 * consideration. This routine ignores it, and returns number of lines based upon the font metrics,
2228 * hightlight specification, and the passed in maximum height.
2230 * Note that this API does not cause a layout of the editor.
2234 * @param aLayout S60 layout object for the text to be laid out in the editor
2235 * @param aBaselineSeparationOverride vertical separation of baselines
2236 * overriding aLayout, if not KAknLayoutUtilsDoNotOverride
2237 * @param aMaxHeight Input maximum height to use for the editor.
2238 * @param aUsedHeight Returns the number of pixels required for the lines that fit
2239 * @return The number of lines which completely fit
2241 IMPORT_C static TInt EdwinLinesWithinHeight (
2242 const TAknTextLineLayout& aLayout,
2243 TInt aBaselineSeparationOverride,
2249 /** Low level drawing based on European LAF document (can be used by application's custom controls)
2251 * This class reads AVKON_LAYOUT_TEXT resources
2253 class TAknLayoutText
2256 IMPORT_C TAknLayoutText();
2257 /** Read resources and calculate information needed to draw text.
2259 * LayoutText() call should be placed to control's SizeChanged() method.
2261 IMPORT_C void LayoutText(const TRect& aParent, TInt aResourceId,
2262 const CFont* aCustomFont=0);
2264 IMPORT_C void LayoutText(const TRect& aParent, TResourceReader& aReader,
2265 const CFont* aCustomFont=0);
2267 IMPORT_C void LayoutText(const TRect& aParent,
2268 const AknLayoutUtils::SAknLayoutText& aLayout,
2269 const CFont* aCustomFont=0);
2271 IMPORT_C void LayoutText(const TRect& aParent,
2272 const TAknTextLineLayout& aLayout,
2273 const CFont* aCustomFont=0);
2275 IMPORT_C void LayoutText(const TRect& aParent, TInt fontid,
2276 TInt C, TInt l, TInt r, TInt B, TInt W, TInt J,
2277 const CFont* aCustomFont=0);
2279 /** Do the actual drawing, should be placed to control's Draw() method.
2281 IMPORT_C void DrawText(CGraphicsContext& aGc, const TDesC& aText) const;
2284 * In case of bidirectional text, which is already converted from logical to
2285 * visual order, use this method with parameter
2286 * aUseLogicalToVisualConversion EFalse.
2288 IMPORT_C void DrawText(
2289 CGraphicsContext& aGc,
2291 TBool aUseLogicalToVisualConversion ) const;
2293 IMPORT_C void DrawText(
2294 CGraphicsContext& aGc,
2296 TBool aUseLogicalToVisualConversion,
2297 const TRgb &aColor) const;
2301 /** This returns rectangle that is used to draw the text.
2303 * This allows you to divide screen space for egul's TextUtils::ClearBetweenRect()
2304 * without knowing exact coordinates => when coordinates change, your code
2305 * does not need to change.
2307 IMPORT_C TRect TextRect() const;
2308 const CFont *Font() const { return iFont; }
2309 TRgb Color() const { return AKN_LAF_COLOR_STATIC(iColor); }
2310 CGraphicsContext::TTextAlign Align() const { return iAlign; }
2312 * Returns the baseline position for the font set in this object.
2313 * This value, together with TextRect(), are the metrics that are used to
2314 * parametrise a call to DrawText, for example:
2315 * void CGraphicsContext::DrawText(
2316 * const TDesC& aText,
2317 * const TRect& aBox,
2318 * TInt aBaselineOffset,
2319 * TTextAlign aAlignment = ELeft,
2320 * TInt aLeftMargin = 0);
2322 * TAknLayoutText's own DrawText methods are recommended, however.
2324 * Notice that this value is relative to the top of the TextRect() rectangle,
2325 * which is generally made to bound all accents. Thus this offset value
2326 * is usually larger than the CFont::AscentInPixels value.
2329 * @return distance in pixels measured from the top of the textpane down to the baseline
2331 TInt BaselineOffset() const;
2334 const CFont *iFont; // not owned..
2337 CGraphicsContext::TTextAlign iAlign;
2338 friend class CBubbleOutlookNumberEntry;
2341 /** Low level rectangle management based on European LAF document (can be used by application's custom controls)
2343 * This allows you to draw images, rectangles, lines or just calculate rectangles based on LAF spec.
2345 * This class reads AVKON_LAYOUT_RECT resources.
2347 * Instances of this class should be placed inside controls for reading low level layout from resources.
2349 class TAknLayoutRect
2352 IMPORT_C TAknLayoutRect();
2353 /** LayoutRect should be called from control's SizeChanged() method.
2355 IMPORT_C void LayoutRect(const TRect &aParent, TInt aResourceId);
2356 IMPORT_C void LayoutRect(const TRect &aParent, TResourceReader &aReader);
2357 IMPORT_C void LayoutRect(const TRect &aParent,
2358 const AknLayoutUtils::SAknLayoutRect &aLayout);
2360 IMPORT_C void LayoutRect(const TRect &aParent,
2361 const TAknWindowLineLayout &aLayout);
2363 IMPORT_C void LayoutRect(const TRect &aParent,
2364 TInt C, TInt l, TInt t, TInt r, TInt b,
2367 /** Color() can be called from control's Draw() method.
2369 DO NOT CALL it in SizeChanged(), ConstructL() or ActivateL() method, because
2370 it messes up color scheme changes. Especially if you're using colors 226-248.
2371 If you store color values, be prepared to update TRgb's you store when color
2372 palette is changed! Best thing to do is to make your Draw() methods call
2375 IMPORT_C TRgb Color() const;
2376 /** Rect() can be called from control's Draw() or in SizeChanged() as input for some other table's layout code.
2378 IMPORT_C TRect Rect() const;
2379 TBool Valid() const;
2381 /** DrawRect() and DrawImage() should be called from control's Draw() method.
2383 IMPORT_C void DrawRect(CWindowGc& aGc) const;
2384 IMPORT_C void DrawOutLineRect(CWindowGc& aGc) const;
2385 IMPORT_C void DrawImage(CBitmapContext& aGc, CFbsBitmap* aBitmap, CFbsBitmap* aMask) const;
2392 * Helper functions for drawing empty lists and window shadows
2398 Draws standard empty list
2399 @param aRect the client rectangle
2400 @param aGc the graphics context
2401 @param aText text for empty list in format "Line1\nLine2"
2403 IMPORT_C static void DrawEmptyList(
2409 Draws empty list for setting item editing
2410 @param aRect the rectangle of setting page's content
2411 @param aGc the graphics context
2412 @param aText text for empty list in format "Line1\nLine2"
2414 IMPORT_C static void DrawEmptyListForSettingPage(
2417 TPtrC text); // only for setting page with empty layout.
2420 Draws empty list for lists with find
2421 @param aRect the client rectangle
2422 @param aGc the graphics context
2423 @param aText text for empty list in format "Line1\nLine2"
2425 IMPORT_C static void DrawEmptyListWithFind(
2426 const TRect& aClientRect,
2428 TPtrC aText); // only for fixed find pane used with single graphics listbox.
2431 Draws empty list for lists with heading
2432 @param aRect the client rectangle
2433 @param aGc the graphics context
2434 @param aText text for empty list in format "Line1\nLine2"
2436 IMPORT_C static void DrawEmptyListHeading(
2437 const TRect &aClientRect,
2439 TPtrC aText); // only heading style lists.
2441 // The following is optimization for drawing window shadows.
2443 Draws a window shadow
2444 @param aCoverRect the area covered by the shadow
2445 @param aSecondShadowRect the area used for second shadow
2446 @param aFirstShadowRect the area of first shadow
2447 @param aOutliineFrameRect the area of black outline frame
2448 @param aInsideAreaRect the area of content inside the window
2450 IMPORT_C static void DrawWindowShadow(
2452 const TAknLayoutRect& aCoverRect,
2453 const TAknLayoutRect& aSecondShadowRect,
2454 const TAknLayoutRect& aFirstShadowRect,
2455 const TAknLayoutRect& aOutlineFrameRect,
2456 const TAknLayoutRect& aInsideAreaRect);
2461 * The main implementation routine for empty list drawing.
2462 * @param aRect the client rectangle
2463 * @param aGc the graphics context
2464 * @param aText text for empty list in one of following formats:
2466 * layouts with large font:
2468 * "Long line. This will be wrapped to 2 lines and 2nd will be trunca..."
2471 * layout with 1 line of large font and up to 3 lines with small font:
2472 * "Line 1\nLong line, will be wrapped up to 3 lines with small font and..."
2475 * @param aLayoutLine1 Resource id of AVKON_LAYOUT_TEXT for first line layout
2476 * @param aLayoutLine2 Resource id of AVKON_LAYOUT_TEXT for second line layout
2478 IMPORT_C static void DrawEmptyListImpl( const TRect& aRect,
2482 TInt aLayoutLine2 );
2487 * Helper functions for drawing empty lists and window shadows
2489 class AknDrawWithSkins
2493 Draws standard empty list
2494 @param aRect the client rectangle
2495 @param aGc the graphics context
2496 @param aText text for empty list in format "Line1\nLine2"
2498 IMPORT_C static void DrawEmptyList(
2502 CCoeControl *aControl);
2505 Draws empty list for setting item editing
2506 @param aRect the rectangle of setting page's content
2507 @param aGc the graphics context
2508 @param aText text for empty list in format "Line1\nLine2"
2510 IMPORT_C static void DrawEmptyListForSettingPage(
2514 CCoeControl *aControl); // only for setting page with empty layout.
2517 Draws empty list for lists with find
2518 @param aRect the client rectangle
2519 @param aGc the graphics context
2520 @param aText text for empty list in format "Line1\nLine2"
2522 IMPORT_C static void DrawEmptyListWithFind(
2523 const TRect& aClientRect,
2526 CCoeControl *aControl); // only for fixed find pane used with single graphics listbox.
2529 Draws empty list for lists with heading
2530 @param aRect the client rectangle
2531 @param aGc the graphics context
2532 @param aText text for empty list in format "Line1\nLine2"
2534 IMPORT_C static void DrawEmptyListHeading(
2535 const TRect &aClientRect,
2538 CCoeControl *aControl); // only heading style lists.
2540 // The following is optimization for drawing window shadows.
2542 Draws a window shadow
2543 @param aCoverRect the area covered by the shadow
2544 @param aSecondShadowRect the area used for second shadow
2545 @param aFirstShadowRect the area of first shadow
2546 @param aOutliineFrameRect the area of black outline frame
2547 @param aInsideAreaRect the area of content inside the window
2549 IMPORT_C static void DrawWindowShadow(
2551 const TAknLayoutRect& aCoverRect,
2552 const TAknLayoutRect& aSecondShadowRect,
2553 const TAknLayoutRect& aFirstShadowRect,
2554 const TAknLayoutRect& aOutlineFrameRect,
2555 const TAknLayoutRect& aInsideAreaRect,
2556 CCoeControl *aControl);
2563 // Browser and calculator fonts will not be placed here. Application
2564 // can use them themselves with CEikonEnv::Static()->Font() call.
2565 IMPORT_C const CFont *LatinPlain12();
2566 IMPORT_C const CFont *LatinBold12();
2567 IMPORT_C const CFont *LatinBold13();
2568 IMPORT_C const CFont *LatinBold16(); // since 2.0
2569 IMPORT_C const CFont *LatinBold17();
2570 IMPORT_C const CFont *LatinBold19();
2571 IMPORT_C const CFont *NumberPlain5();
2572 IMPORT_C const CFont *ClockBold30();
2573 IMPORT_C const CFont *LatinClock14();
2574 const CFont *CalcBold21();
2575 const CFont *CalcOperBold21();
2576 const CFont *CalcOperBold13();
2580 IMPORT_C const CFont *ApacPlain12();
2581 IMPORT_C const CFont *ApacPlain16();
2585 * CompletePathWithAppPath
2586 * All the components that are specified in the given descriptor (drive letter,
2587 * path and file name, including extension) are put into the result;
2588 * any missing components (path and drive letter) are taken from the app's path.
2590 * Can be used e.g. to load a bitmap file when an application don't know where
2591 * it has been installed.
2594 * TFilename fname = _L("\testdir\pics.mbm"); // Use _LIT instead
2595 * CompletePathWithAppPath( fname );
2597 * fname == "c:\testdir\pics.mbm" if application was installed to c:
2600 * TFilename fname = _L("pics.mbm"); // Use _LIT instead
2601 * CompletePathWithAppPath( fname );
2603 * fname == "c:\system\apps\myapp\pics.mbm" if application was
2604 * installed to c:\system\apps\myapp
2606 * @param aFileName FileName which will be completed with application's path
2607 * @return Error code if an error occured. In case of an error aFileName will
2610 IMPORT_C TInt CompleteWithAppPath( TDes& aFileName );
2613 * Test whether the value falls within the parent relative range
2614 * as defined in AknLayout2Def.h
2618 * @return ETrue if value is within the parent relative range, EFalse otherwise
2620 TBool IsParentRelative(TInt aVal);
2623 * Returns default input language that corresponds to the UI language.
2626 * @param aUiLanguage Language code of the UI language
2627 * @return Language code of the default input language
2629 IMPORT_C TInt DefaultInputLanguageFromUILanguage(const TInt aUiLanguage);
2632 * Sets the key block mode.
2633 * Has the same functionality as SetKeyBlockMode in AknAppUi,
2634 * but this can be used from a non app-framework application.
2635 * The default mode blocks simultaneous key presses.
2636 * @param aMode @c ENoKeyBlock if no key block, otherwise
2637 * @c EDefaultBlockMode
2639 IMPORT_C void SetKeyblockMode( TAknKeyBlockMode aMode );
2641 namespace AknDateTimeUtils
2644 * Converts given UTC time to home time.
2645 * This conversion is used e.g. when showing time stamps of files in UI.
2646 * In Symbian OS file system, time stamps are in UTC time, but in UI
2647 * they should be shown in home time.
2649 * @param aTime UTC time to be converted to home time.
2652 IMPORT_C void ConvertUtcTimeToHomeTime( TTime& aTime );
2655 #define KAknLanguageMask 0x3FF
2656 #define KAknDialectMask 0xFC00
2658 namespace AknLangUtils
2661 * Returns the RFC 3066 tag of the current display language.
2663 * @ret RFC 3066 tag, ownership transferred to the caller.
2665 IMPORT_C HBufC* DisplayLanguageTagL();
2667 TLanguage UserLanguage();
2672 * Helper functions for Popups
2680 * Calculates proper position for a popup control. Returned value depends
2681 * on currently active layout and softkey visibility.
2683 * @param aSize The size of the popup.
2684 * @param aSoftkeysVisible ETrue if softkeys are visible.
2685 * @return Corrent popup position.
2687 IMPORT_C static TPoint Position( const TSize& aSize,
2688 TBool aSoftkeysVisible );
2691 * Calculates proper position for a popup control. Returned value depends
2692 * on currently active layout and softkey visibility which is checked from
2693 * aControl via MOP chain.
2695 * @param aSize The size of the popup.
2696 * @param aControl Control who's position should be calculated.
2697 * @return Corrent popup position.
2699 IMPORT_C static TPoint Position( const TSize& aSize,
2700 CCoeControl* aControl );
2705 * Helper functions for Lists
2713 * Draws a separator line between list items.
2715 * @param aGc Graphics context where separator is drawn to.
2716 * @param aRect Rectangle occupied by the item that is separated.
2717 * @param aColor Text color used in item. Separator is drawn with this
2718 * color and additional alpha mask.
2720 IMPORT_C static void DrawSeparator( CGraphicsContext& aGc,
2721 const TRect& aRect, const TRgb& aColor );
2724 #endif // __AKNUTILS_H__