classicui_plat/special_character_table_api/inc/AknCharMap.h
changeset 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *  Special character table control that is shown
       
    16 *  inside special character table dialog.
       
    17 *
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef AKNCHARMAP_H
       
    23 #define AKNCHARMAP_H
       
    24 
       
    25 #include <coecntrl.h>
       
    26 #include <AknUtils.h>
       
    27 #include <AknPictographDrawerInterface.h>
       
    28 
       
    29 // Maximum number of rows that fits visible to the screen.
       
    30 const TInt KSCTMaxVisibleRowsAPAC = 7;
       
    31 const TInt KSCTMaxVisibleRowsELAF = 8;
       
    32 #define KSCTMaxVisibleRows ( (AknLayoutUtils::Variant()==EApacVariant) ? KSCTMaxVisibleRowsAPAC : KSCTMaxVisibleRowsELAF )
       
    33 
       
    34 const TInt KCharMapCaseMask = 0xFF;
       
    35 
       
    36 enum TAknCharMapPictoMode
       
    37     {
       
    38     EAknCharMapPictoNoUse       = 0x00010000, 
       
    39     EAknCharMapPictoFirst       = 0x00020000
       
    40     };
       
    41 
       
    42 enum TAknCharMapEmotionMode
       
    43     {
       
    44     EAknCharMapEmotionNoUse     = 0x00040000, 
       
    45     EAknCharMapEmotionUse       = 0x00080000, 
       
    46     EAknCharMapEmotionFirst     = 0x00100000
       
    47     };
       
    48 
       
    49 enum TAknChaMapTableCase
       
    50     {
       
    51     EAknCharMapTableNull = -1,
       
    52     EAknCharMapTableSpecialChar = 0,
       
    53     EAknCharMapTablePicto,
       
    54     EAknCharMapTablePicto2
       
    55     };
       
    56 
       
    57 enum TAknChaMapStatusChanged
       
    58     {
       
    59     EAknCharNoSelection = -1,
       
    60     EAknCharSelectedSpecialCharacter = 0,
       
    61     EAknCharChangedCategory,
       
    62     EAknCharSelectedNextTableButton,
       
    63     EAknCharSelectedTableExitButton
       
    64     };
       
    65 
       
    66 
       
    67 class CEikScrollBarFrame;
       
    68 class CAknPictographInterface;
       
    69 class CAknCharMapHistory;
       
    70 class CAknCharMapExtension;
       
    71 class MAknSctFocusHandler;
       
    72 /**
       
    73  * Special character table control for AVKON
       
    74  *
       
    75  */
       
    76 class CAknCharMap : public CCoeControl, public MAknPictographAnimatorCallBack, public MEikScrollBarObserver
       
    77     {
       
    78 
       
    79     friend class CAknCharMapExtension;
       
    80 
       
    81 public: 
       
    82     
       
    83     /** 
       
    84     * Character table constructor
       
    85     *
       
    86     */
       
    87     IMPORT_C CAknCharMap();
       
    88     
       
    89     /** 
       
    90     * Character table destructor
       
    91     *
       
    92     */
       
    93     IMPORT_C ~CAknCharMap();
       
    94     
       
    95     /** 
       
    96     * Character table resource constructor.
       
    97     * 
       
    98     * @param aReader Special character table resource: SPECIAL_CHAR_TABLE
       
    99     * 
       
   100     */
       
   101     IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
       
   102 
       
   103     /**
       
   104     * Number of rows in special character map.
       
   105     *
       
   106     * @return Number of rows in special character map.
       
   107     *
       
   108     */
       
   109     IMPORT_C TInt HeightInRows();
       
   110     
       
   111     /**
       
   112     * Set the emotion mode for the special character table.
       
   113     *
       
   114     * @param aMode The emotion mode for the special character table 
       
   115     *      (EAknCharMapEmotionUse, EAknCharMapEmotionFirst, EAknCharMapEmotionNoUse).
       
   116     */
       
   117     IMPORT_C void SetEmotionModeL(TAknCharMapEmotionMode aMode);
       
   118     
       
   119     /**
       
   120     * Set the case for the special character table.
       
   121     *
       
   122     * @param aCharCase The case for the special character table 
       
   123     *      (EAknSCTLowerCase or EAknSCTUpperCase).
       
   124     */
       
   125     IMPORT_C void SetCharacterCaseL(TInt aCharCase);
       
   126 
       
   127     /**
       
   128     * Sets reference to the buffer where selected special character(s) are put.
       
   129     *
       
   130     * @param aSpecialChars Reference to the buffer where selected special characters are put.
       
   131     */
       
   132     IMPORT_C void SetBuffer(TDes& aSpecialChars);
       
   133     
       
   134     /**
       
   135     * Reads special characters from the resource. 
       
   136     *
       
   137     * @param aReader Special character table resource: SPECIAL_CHAR_TABLE
       
   138     *
       
   139     */
       
   140     void ReadCharSetFromResourceL(TResourceReader& aReader);
       
   141     
       
   142     /**
       
   143     * Reads special characters from the resource and add recent characters. 
       
   144     *
       
   145     * @param aReader Special character table resource: SPECIAL_CHAR_TABLE
       
   146     *
       
   147     */
       
   148     void ReadAndAddCharSetFromResourceL(TResourceReader& aReader);
       
   149 
       
   150 public: // from CCoeControl
       
   151     IMPORT_C TSize MinimumSize();
       
   152     IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode);
       
   153     IMPORT_C TCoeInputCapabilities InputCapabilities() const;
       
   154     IMPORT_C virtual void ActivateL();
       
   155 
       
   156 protected: // from CCoeControl
       
   157     IMPORT_C void SizeChanged();
       
   158     IMPORT_C void HandleResourceChange(TInt aType);
       
   159     IMPORT_C TInt CountComponentControls() const;
       
   160     IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
       
   161 
       
   162 public: // new functions
       
   163     void SetPictoMode(TAknCharMapPictoMode aMode);
       
   164     void SetCaseTableL(const RArray<TInt> & aCase);
       
   165     TInt LengthOfRecentChar();
       
   166 
       
   167 private: // from MAknPictographDrawerCallBack
       
   168     void DrawPictographArea();
       
   169 
       
   170 public: // new methods
       
   171     const TDesC* LowerCaseCharacters() const;
       
   172     const TDesC* UpperCaseCharacters() const;
       
   173     const TDesC* NumericCharacters() const;
       
   174     void CopyCharactersL( const CAknCharMap& aCharMap ); 
       
   175 
       
   176     TBool SwitchTablesL( TBool& aLayoutChanged );
       
   177     TInt PageCount() const;
       
   178     TInt CurrentPage() const;
       
   179     TInt NextPageL();
       
   180 
       
   181     void CreateOffscreenBackgroundL();
       
   182     void DrawOffscreenBackgroundIfRequired() const;
       
   183     void SetTitleL(TPtrC aTitle);
       
   184     const TDesC* Title() const;
       
   185     void DoLayout();
       
   186     
       
   187     TBool HasPictoInterface() const;
       
   188     
       
   189     /**
       
   190     * Get the case for the special character table.
       
   191     *
       
   192     * @return aCharCase The case for the special character table 
       
   193     *      (EAknSCTLowerCase, EAknSCTQwerty or EAknSCTUpperCase).
       
   194     */
       
   195     TInt CharacterCase();
       
   196 
       
   197     void DisableRecentCharsRow();
       
   198 
       
   199 protected:
       
   200     void Draw(const TRect& aRect) const;
       
   201 
       
   202     /**
       
   203     * Draw the special char inside the grid cell.
       
   204     * @param aGC, the graphic context;
       
   205     * @param aSctPosition, the rectangle inside the cell (exclude the cell edge).
       
   206     * @param aCharIndex, the index of the special char, used to determin
       
   207     *        whether the char is recent char or not.
       
   208     * @param aHighlighted, the flag to indicate if the char is highlighted.
       
   209     * @param aDrawBackground, the flag to indicate if it is neccessary to brush
       
   210     *        the back ground inside the cell.
       
   211     */
       
   212     void DrawItem(
       
   213         CWindowGc& aGc,
       
   214         const TRect& aSctPosition,
       
   215         TInt aCharIndex,
       
   216         TBool aHighlighted,
       
   217         TBool aDrawBackground ) const;
       
   218 
       
   219     /**
       
   220     * Draw the shade background inside the cell.
       
   221     * @param aGC, the graphic context;
       
   222     * @param aItemRect, the rectangle inside the cell (exclude the cell edge).
       
   223     * @param aCharIndex, the index of the special char, used to determin
       
   224     *        whether the char is recent char or not.
       
   225     * @param aHighlighted, the flag to indicate if the char is highlighted.
       
   226     * @param aDrawBackground, the flag to indicate if it is neccessary to brush
       
   227     *        the back ground inside the cell.
       
   228     */
       
   229     void DrawItemShade( CWindowGc& aGc, 
       
   230         const TRect& aItemRect, TInt aCharIndex,
       
   231         TBool aHighlighted,
       
   232         TBool aDrawBackground ) const;
       
   233 
       
   234     /**
       
   235     * Set the pen size, color, etc. before drawing the frame of a special char 
       
   236     * item. 
       
   237     * Note: The frame is inside the cell.
       
   238     *
       
   239     * @param aGC, the graphic context;
       
   240     */
       
   241     void SetItemFrameStyle( CWindowGc& aGc) const;
       
   242 
       
   243     /**
       
   244     * Draw the frame of a special char item.
       
   245     * Note: The frame is inside the cell.
       
   246     *
       
   247     * @param aGC, the graphic context;
       
   248     * @param aItemRect, the rectangle inside the cell (exclude the cell edge).
       
   249     * @param aCharIndex, the index of the special char, used to determin
       
   250     *        whether the char is recent char or not.
       
   251     * @param aHighlighted, the flag to indicate if the char is highlighted.
       
   252     * @param aDrawBackground, the flag to indicate if it is neccessary to brush
       
   253     *        the back ground inside the cell.
       
   254     */
       
   255     void DrawItemFrame( CWindowGc& aGc, 
       
   256         const TRect& aItemRect, TInt aCharIndex,
       
   257         TBool aHighlighted,
       
   258         TBool aDrawBackground ) const;
       
   259 
       
   260     /**
       
   261     * Set the pen size, color, etc. before drawing the thick frame of all 
       
   262     * recent chars. 
       
   263     * Note: The frame is always on the top of all SCT grid, or inside the
       
   264     * MenuSct.
       
   265     *
       
   266     * @param aGC, the graphic context;
       
   267     */
       
   268     void SetRecentCharFrameStyle( CWindowGc& aGc) const;
       
   269 
       
   270     /**
       
   271     * Draw the frame of all recent chars.
       
   272     * Note: The frame is always on the top of all SCT grid, or inside the
       
   273     * MenuSct.
       
   274     *
       
   275     * @param aGC, the graphic context;
       
   276     */
       
   277     void DrawRecentCharFrame( CWindowGc& aGc) const;
       
   278 
       
   279     /**
       
   280     * Set the pen size, color, etc. before drawing the SCT grid. 
       
   281     *
       
   282     * @param aGC, the graphic context;
       
   283     */
       
   284     void SetGridStyle( CWindowGc& aGc) const;
       
   285 
       
   286     /**
       
   287     * Draw the SCT grid. This is a better method. It will iterate
       
   288     * all visible special chars, and draw a simple rect around it.
       
   289     *
       
   290     * @param aGC, the graphic context;
       
   291     */
       
   292     void DrawGrid( CWindowGc& aGc) const;
       
   293 
       
   294     /**
       
   295     * Get How many special chars are visible in the current page,
       
   296     * or in the current MenuSct frame.
       
   297     * @return the number of the visible special chars.
       
   298     */
       
   299     TInt NumberOfVisibleChars() const;
       
   300 
       
   301     void DrawCursor() const;
       
   302     void MoveCursorL(TInt aX, TInt aY);
       
   303 
       
   304     void DrawCell( TInt aCursorPos, TBool aHighLighted ) const;
       
   305     TRect CursorRect( TInt aCursorPos, TInt aCharIndex ) const;
       
   306 
       
   307     void UpdateScrollIndicatorL();
       
   308 
       
   309     void DrawPicto(
       
   310         CWindowGc& aGc,
       
   311         const TRect& aSctPosition,
       
   312         TInt aCharIndex,
       
   313         TBool aHighlighted,
       
   314         TBool aDrawBackground ) const;
       
   315 
       
   316     HBufC* AppendTextL(HBufC* aChars, HBufC* aText);
       
   317     TInt SwitchAnotherTableL(TInt aIncrement);
       
   318 
       
   319     void CountMaxColumnsAndCellSizes();
       
   320 
       
   321     HBufC* CharsFromCase(TInt aCharCase) const;
       
   322     TInt PageCountFromChars(TDesC& aChar) const;
       
   323     TInt VisibleRows() const;
       
   324 
       
   325     void CreatePictoCharL();
       
   326     void AppendRecentCharL();
       
   327     HBufC* InsertSwitchCharAndHistoryToCharsBufL(HBufC* aCharsBuf, TChar aSwitchChar, const TDesC& aHistory);
       
   328     TBool IsRecentChar(TInt aIndex = 0) const;
       
   329     void SaveRecentDataL(TChar aChar);
       
   330     CAknCharMapExtension* Extension() const;
       
   331 
       
   332     void UpdateHeadingPane( TBool aUpdateTitle );
       
   333 
       
   334 public:
       
   335     /**
       
   336      * This function handles pointer events directed at the charmapdialog.
       
   337      * @param aPointerEvent The pointer event directed at the charmapdialog.
       
   338      */
       
   339     IMPORT_C virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   340     
       
   341     /**
       
   342     * From CCoeControl        
       
   343     * Sets iCharmapObserver to be as observer
       
   344     * @param aObserver pointer to observer
       
   345     */
       
   346     IMPORT_C void SetObserver( MCoeControlObserver* aObserver  );
       
   347  
       
   348 private: //from CCoeContrl
       
   349     void Reserved_1();
       
   350     void Reserved_2();
       
   351     
       
   352 public:
       
   353      /**
       
   354      * This function handles pointer events directed at the charmapdialog.
       
   355      * @param aScrollBar The scrollbar to be observed.
       
   356      * @param aEventType The incomming event type so that correct functionality can be done.
       
   357      */
       
   358     void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
       
   359     
       
   360     /** 
       
   361     * Constructs a special character row for edit menu.
       
   362     * 
       
   363     * @since 3.1
       
   364     */
       
   365     IMPORT_C void ConstructMenuSctRowL();
       
   366     
       
   367     /** 
       
   368     * Sets the rect which SCT should use to draw itself.
       
   369     * @param aRect The used rectangle.
       
   370     * @since 3.1
       
   371     */
       
   372     IMPORT_C void SetMenuSctRect( const TRect& aRect );
       
   373 
       
   374 
       
   375     /** 
       
   376     * Constructs a special character row for edit menu. Uses the given resource
       
   377     * of a dialog to construct the special character table. The recently used characters 
       
   378     * are only from the selected special character table. 
       
   379     * 
       
   380     * @since S60 3.1
       
   381     *
       
   382     * @param aResourceId    The resource id of the special character dialog which 
       
   383     *                       is used with editor.
       
   384     */
       
   385     IMPORT_C void ConstructMenuSctRowL(TInt aResourceId);
       
   386     
       
   387     /** 
       
   388     * Constructs a special character row for edit menu. Uses the given resource
       
   389     * of a dialog to construct the special character table. The recently used characters 
       
   390     * are only from the selected special character table. 
       
   391     * 
       
   392     * @since S60 3.2
       
   393     *
       
   394     * @param aResourceId    The resource id of the special character dialog which
       
   395     *                       is used with editor.
       
   396     */
       
   397     IMPORT_C void ConstructMenuSctRowFromDialogL(TInt aResourceId);
       
   398 
       
   399     /**
       
   400     * Highlight the row of recent used character according to argument.
       
   401     * @param aHighlight     the flag to indicate wheather the row is highlighted
       
   402     *                       or not.
       
   403     * @since S60 3.1
       
   404     */
       
   405     IMPORT_C void HighlightSctRow(TBool aHighlight);
       
   406 public:
       
   407     void SetStatusChanged(const TInt aStatusChanged);
       
   408     TInt StatusChanged();
       
   409     TInt CurrentCategory();
       
   410     TBool ChangeCategoryL(const TInt aCategory, TBool& aLayoutChanged );
       
   411     TInt Category();
       
   412     TBool IsSupportCategoryButtonUi() const;
       
   413     TBool IsJapaneseSctUi() const;
       
   414     const TDesC* TitleWithSelectingSpecialChar();
       
   415 
       
   416 private:
       
   417     void ChangeFocusSct(TBool aFocusOn);
       
   418     void CreateTitleWithSelectingSpecialCharL(const TDesC* aTitle);
       
   419 
       
   420 private:
       
   421     void DoHandleResourceChangeL(TInt aType);                                          
       
   422     void EnableCategoryButtonsL();
       
   423     void DisableCategoryButtonsL();    
       
   424     void EnableNavigationButtonsL();
       
   425     void DisableNavigationButtonsL();             
       
   426     void EnableCategoryInputFieldL();
       
   427     void DisableCategoryInputFieldL();   
       
   428                 
       
   429 public:                    
       
   430     TAknChaMapTableCase NextTableCase() const;
       
   431     CCoeControl* FocusedControl();
       
   432     MAknSctFocusHandler* FocusHandler();    
       
   433     TBool EnterControl(TInt aX, TInt aY);    
       
   434     void MoveFocus(TInt aX, TInt aY);              
       
   435     TBool LeaveControl();             
       
   436     TBool ExitWithKey(TInt aKeycode);    
       
   437     void UpdateInputFieldL(); 
       
   438     void RefreshNaviPageL();  
       
   439     TInt TableCount() const;
       
   440     TInt PrevPageL();    
       
   441     TInt RowMin(TInt aRow) const;
       
   442     TInt RowMax(TInt aRow) const;
       
   443     TInt ColMin(TInt aCol) const;
       
   444     TInt ColMax(TInt aCol) const;    
       
   445     TInt MaxCols() const;
       
   446     TBool TakeFocus();
       
   447     void ShowFocus();
       
   448     TPoint CursorPos();
       
   449 
       
   450 private:
       
   451     void HandleFocusStatusChanged(TBool aIsFocused=ETrue);
       
   452     TBool EmotionsAreAllReadyToDraw(TInt aIndex, TInt aCount) const;
       
   453     void GetFocusSctName(TChar& aChar, TDes& aName) const;
       
   454     TBool HaveBufferToAppendFocusSct() const;
       
   455     TBool AppendFocusSctToDestinationBufferL();
       
   456     TBool SwitchSctAndEmotionL();
       
   457 
       
   458 private:
       
   459     TBool iIsMirrored;
       
   460     const CFont* iFont;     // drawing text font
       
   461     
       
   462     TInt iGridItemWidth;    // grid cell width
       
   463     TInt iGridItemHeight;   // grid cell height
       
   464 
       
   465     TPoint iOffset;
       
   466     TPoint iGridTopLeft;
       
   467     
       
   468     TInt iRows;             // total rows of all chars
       
   469     TInt iMaxColumns;       // column count in current gird
       
   470     TInt iFirstVisibleRow;  // first row index in current page window
       
   471 
       
   472     TPoint iCursorPos;
       
   473     TPoint iOldCursorPos;
       
   474     mutable TBool iDrawnBefore;
       
   475 
       
   476     // shown table case
       
   477     TAknChaMapTableCase iChaMapTableCase;
       
   478     TInt iSpecialCharCase;
       
   479     
       
   480     // des buffer
       
   481     TDes* iFetcherCharsBuffer;
       
   482     
       
   483     // all the data buffers
       
   484     HBufC* iChars;
       
   485     HBufC* iCharsBufferFull;
       
   486     HBufC* iCharsBufferHalf;
       
   487     HBufC* iCharsBufferLower;
       
   488     HBufC* iCharsBufferUpper;
       
   489     HBufC* iCharsBufferNumeric;
       
   490     HBufC* iPictographsBuffer;
       
   491     HBufC* iPictographsBuffer2;
       
   492 
       
   493     CEikScrollBarFrame* iSBFrame;
       
   494 
       
   495     CAknPictographInterface* iPictoInterface;
       
   496     TBool iAnimated;
       
   497 
       
   498     CFbsBitmap* iOffscreenBg;
       
   499     CFbsBitmapDevice* iBitmapDevice;
       
   500     CFbsBitGc* iBitmapGc;
       
   501     TBool iHasBitmapBackground;  // Keeped only for Binary Compatibility  
       
   502     mutable TBool iOffscreenBgDrawn;
       
   503     
       
   504     // all kind of titles
       
   505     HBufC* iTitleDefault;
       
   506     HBufC* iTitleFull;
       
   507     HBufC* iTitleHalf;
       
   508     HBufC* iTitlePicto;
       
   509     HBufC* iTitlePicto2;
       
   510 
       
   511     TInt iCaseIndex;
       
   512     
       
   513     // cases info
       
   514     RArray<TInt>* iShowCasesRef;
       
   515     RArray<TInt> iSpecialCharCases;
       
   516     RArray<TInt> iPictographCases;
       
   517     
       
   518     // pages info
       
   519     RArray<TInt>* iShowPagesRef;
       
   520     RArray<TInt> iSpecialCharPages;
       
   521     RArray<TInt> iPictographPages;
       
   522 
       
   523     TAknPictographHeight iCurrentPictographHeight;
       
   524     CAknCharMapExtension* iExtension;
       
   525     CAknCharMapHistory* iCharMapHistory;
       
   526     
       
   527     TBool iSetRecentSct;        // ETrue is set when setting recent used characters to SCT
       
   528     TBool iSetRecentPic;        // ETrue is set when setting recent used characters to Picto
       
   529     TInt iStatusChanged;
       
   530     };
       
   531 
       
   532 #endif // __AKNCHARMAP_H__