uiacceltk/hitchcock/Client/src/alftextstyle.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006 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:   Text style
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <AknFontProvider.h>
       
    21 #include "alf/alftextstyle.h"
       
    22 #include "alf/alfgencomponent.h"
       
    23 #include "alf/alftextstylemanager.h"
       
    24 #include "alf/alftexturemanager.h"
       
    25 #include "alf/alfbitmapprovider.h"
       
    26 #include "alf/alfenv.h"
       
    27 #include "alflogger.h"
       
    28 #include "alf/alfconstants.h"
       
    29 #include "uiacceltk/HuiFont.h"
       
    30 
       
    31 /**
       
    32  * Constants that are uset to set/reset local definition flags.
       
    33  * Local definition flags describe which text style attributes are set/defined
       
    34  * locally in this particular text style, and which cascade from the parent.
       
    35  */
       
    36 const TInt  KTextColorDefined =         0x00000001;
       
    37 //const TInt  KBackgroundColorDefined =   0x00000002;
       
    38 const TInt  KTextSizeDefined =          0x00000004;
       
    39 const TInt  KUnderlineDefined =         0x00000008;
       
    40 const TInt  KStrikeThroughDefined =     0x00000010;
       
    41 const TInt  KStrokeWeightDefined =      0x00000020;
       
    42 const TInt  KPostureDefined =           0x00000040;
       
    43 const TInt  KFontDefined =              0x00000080;
       
    44 
       
    45 #ifndef ALF_RASTER_TEXT
       
    46 
       
    47 
       
    48 // Private data
       
    49 struct CAlfTextStyle::TPrivateData
       
    50     {
       
    51     CAlfTextStyleManager* iManager; // Not owned.
       
    52     CAlfGenComponent* iComms;       // Owned.
       
    53     TInt iId; // Owned.
       
    54     TInt iParentId; // Owned.
       
    55     TInt iFontStyleId; // Owned
       
    56     TInt iLocalDefinitionFlags; // Owned.
       
    57     TRgb iTextColor; // Owned.
       
    58     TBool iIsUnderline; // Owned.
       
    59     TBool iIsStrikeThrough; // Owned.
       
    60     TBool iIsPreconfigured; // Owned.
       
    61     TInt iServerHandle; // Serverside id
       
    62     };
       
    63 
       
    64 // ======== MEMBER FUNCTIONS ========
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // Constructor
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CAlfTextStyle::CAlfTextStyle()
       
    71 	: iData(NULL)
       
    72 	{
       
    73 	}
       
    74     
       
    75 // ---------------------------------------------------------------------------
       
    76 // Destructor
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79 CAlfTextStyle::~CAlfTextStyle()
       
    80 	{
       
    81     if(iData)
       
    82 	    {
       
    83     	delete iData->iComms;
       
    84     	iData->iComms = NULL;
       
    85 	    }
       
    86 	delete iData;
       
    87 	iData = NULL;
       
    88 	}
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // Constructs a new CAlfTextStyle object
       
    92 // ---------------------------------------------------------------------------
       
    93 //
       
    94 CAlfTextStyle* CAlfTextStyle::NewL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams)
       
    95 	{
       
    96 	CAlfTextStyle* self = CAlfTextStyle::NewLC(aEnv, aId, aImplementationId, aConstructionParams);        
       
    97     CleanupStack::Pop(self);
       
    98     return self;			
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // Constructs a new CAlfTextStyle object
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 CAlfTextStyle* CAlfTextStyle::NewLC(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams)
       
   106 	{
       
   107 	CAlfTextStyle* self = new( ELeave ) CAlfTextStyle();
       
   108     CleanupStack::PushL(self);
       
   109     self->ConstructL(aEnv, aId, aImplementationId, aConstructionParams);
       
   110     return self;			
       
   111 	}
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // Return font style id
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TInt CAlfTextStyle::FontStyleId() const
       
   118     {
       
   119 	return iData->iFontStyleId;
       
   120     }
       
   121     
       
   122 // ---------------------------------------------------------------------------
       
   123 // Set font style id
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CAlfTextStyle::SetFontStyleId(TInt aFontStyleId)
       
   127     {
       
   128 	iData->iFontStyleId = aFontStyleId;
       
   129     
       
   130     // The changes are not reflected in Hitchcockcore because Hitchcockcore
       
   131     // text style object does not store this info        
       
   132     }
       
   133     
       
   134 // ---------------------------------------------------------------------------
       
   135 // Return parent id
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 EXPORT_C TInt CAlfTextStyle::ParentId() const
       
   139     {
       
   140 	return iData->iParentId;
       
   141     }
       
   142     
       
   143 // ---------------------------------------------------------------------------
       
   144 // Set parent id
       
   145 // ---------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C void CAlfTextStyle::SetParentId(TInt aParentId)
       
   148     {
       
   149     if(!iData->iIsPreconfigured)
       
   150         {
       
   151         iData->iParentId = aParentId;
       
   152         
       
   153         // Reflect the changes also in Hitchcockcore        
       
   154         // Convert the parent id from client domain to session domain.
       
   155     	CAlfTextStyle* parentStyle = iData->iManager->TextStyle(aParentId);    	        
       
   156 	    TPckgC<TInt> buf(parentStyle->Comms()->Identifier());
       
   157 	    TBuf8<1> dum;
       
   158 	    
       
   159 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetParent, buf, dum);
       
   160 	
       
   161 	    if ( err != KErrNone )
       
   162 	        {
       
   163 	        __ALFLOGSTRING1( "CAlfTextStyle::SetParentId panic error %d", err )
       
   164 	        User::Invariant();
       
   165 	        }        
       
   166         }    
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // Return Id
       
   171 // ---------------------------------------------------------------------------
       
   172 //
       
   173 EXPORT_C TInt CAlfTextStyle::Id() const
       
   174     {
       
   175 	return iData->iId;
       
   176     }
       
   177     
       
   178 // ---------------------------------------------------------------------------
       
   179 // Return text color
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 EXPORT_C TRgb CAlfTextStyle::TextColor() const
       
   183     {
       
   184 	if(iData->iIsPreconfigured)
       
   185 		{
       
   186 	    TBufC8<1> inDum;
       
   187 	    TRgb textColor;
       
   188 	    TPckg<TRgb> outBuf(textColor);
       
   189 	    
       
   190 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleTextColor, inDum, outBuf);
       
   191 	    
       
   192 	    if ( err != KErrNone )
       
   193 	        {
       
   194 	        __ALFLOGSTRING1( "CAlfTextStyle::TextColor ignore error %d", err )
       
   195 	        } 
       
   196 	        
       
   197 	    return textColor;	
       
   198 		}
       
   199     if(iData->iLocalDefinitionFlags & KTextColorDefined)
       
   200         {
       
   201         return iData->iTextColor;
       
   202         }
       
   203     return iData->iManager->TextStyle(iData->iParentId)->TextColor();
       
   204     }
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // Sets the color of the text rasterized with this style.
       
   208 // ---------------------------------------------------------------------------
       
   209 //
       
   210 EXPORT_C void CAlfTextStyle::SetTextColor(const TRgb& aTextColor)
       
   211     {
       
   212     if(!iData->iIsPreconfigured)
       
   213         {
       
   214         iData->iTextColor = aTextColor;
       
   215         iData->iLocalDefinitionFlags |= KTextColorDefined;
       
   216         
       
   217         TPckgC<TRgb> buf(aTextColor);
       
   218         TBuf8<1> dum;
       
   219         
       
   220         TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetTextColor, buf, dum);
       
   221 
       
   222         if ( err != KErrNone )
       
   223             {
       
   224             __ALFLOGSTRING1( "CAlfTextStyle::SetTextColor panic error %d", err )
       
   225             User::Invariant();
       
   226             }     
       
   227         }
       
   228     }
       
   229     
       
   230 // ---------------------------------------------------------------------------
       
   231 // Returns the text size of this style in screen size independent units (twips).
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TInt CAlfTextStyle::TextSizeInTwips(TBool aIsDecoratedSize) const
       
   235     {
       
   236     TInt textSizeInTwips = 0;
       
   237     
       
   238     TPckgC<TInt> buf(aIsDecoratedSize);
       
   239     TPckg<TInt> outBuf(textSizeInTwips);
       
   240     
       
   241     TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSizeInTwips, buf, outBuf);
       
   242     
       
   243     if ( err != KErrNone )
       
   244         {
       
   245         __ALFLOGSTRING1( "CAlfTextStyle::TextSizeInTwips ignore error %d", err )
       
   246         } 
       
   247         
       
   248     return textSizeInTwips;
       
   249     }
       
   250     
       
   251 // ---------------------------------------------------------------------------
       
   252 // Set text size
       
   253 // ---------------------------------------------------------------------------
       
   254 //
       
   255 EXPORT_C void CAlfTextStyle::SetTextSizeInTwips(TInt aTextSizeInTwips, TBool aIsDecoratedSize)
       
   256     {
       
   257     if(!iData->iIsPreconfigured)
       
   258         {
       
   259         TInt2 params(aTextSizeInTwips, aIsDecoratedSize);
       
   260         TPckgC<TInt2> buf(params);       
       
   261         TBuf8<1> dum;
       
   262         
       
   263         TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetTextSizeInTwips, buf, dum);
       
   264 
       
   265         if ( err != KErrNone )
       
   266             {
       
   267             __ALFLOGSTRING1( "CAlfTextStyle::SetTextSizeInTwips panic error %d", err )
       
   268             User::Invariant();
       
   269             }     
       
   270         }
       
   271     }
       
   272     
       
   273 // ---------------------------------------------------------------------------
       
   274 // Get text size
       
   275 // ---------------------------------------------------------------------------
       
   276 //
       
   277 EXPORT_C TInt CAlfTextStyle::TextSizeInPixels(TBool aIsDecoratedSize) const
       
   278 	{
       
   279 	TInt textSizeInPixels = 0;
       
   280 
       
   281     TPckgC<TInt> buf(aIsDecoratedSize);
       
   282 	TPckg<TInt> outBuf(textSizeInPixels);
       
   283 	
       
   284 	TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSizeInPixels, buf, outBuf);
       
   285 	
       
   286 	if ( err != KErrNone )
       
   287 		{
       
   288 	    __ALFLOGSTRING1( "CAlfTextStyle::TextSizeInPixels ignore error %d", err )
       
   289 		}
       
   290 	        
       
   291 	return textSizeInPixels;
       
   292 	}
       
   293     
       
   294  // ---------------------------------------------------------------------------
       
   295  // Set text size
       
   296  // ---------------------------------------------------------------------------
       
   297  //
       
   298 EXPORT_C void CAlfTextStyle::SetTextSizeInPixels(TInt aTextSizeInPixels, TBool aIsDecoratedSize)
       
   299     {
       
   300     if(!iData->iIsPreconfigured)
       
   301         {
       
   302         TInt2 params(aTextSizeInPixels, aIsDecoratedSize);
       
   303         TPckgC<TInt2> buf(params);   
       
   304         TBuf8<1> dum;
       
   305         
       
   306         TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetTextSizeInPixels, buf, dum);
       
   307 
       
   308         if ( err != KErrNone )
       
   309             {
       
   310             __ALFLOGSTRING1( "CAlfTextStyle::SetTextSizeInPixels panic error %d", err )
       
   311             User::Invariant();
       
   312             }
       
   313         }
       
   314     }
       
   315     
       
   316 // ---------------------------------------------------------------------------
       
   317 // Is bold
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 EXPORT_C TBool CAlfTextStyle::IsBold() const
       
   321     {
       
   322 	TBufC8<1> inDum;
       
   323 	TBool isBold = EFalse;
       
   324 	TPckg<TBool> outBuf(isBold);
       
   325 	
       
   326 	TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleIsBold, inDum, outBuf);
       
   327 	
       
   328 	if ( err != KErrNone )
       
   329 		{
       
   330 	    __ALFLOGSTRING1( "CAlfTextStyle::IsBold ignore error %d", err )
       
   331 		}
       
   332 	        
       
   333 	return isBold;
       
   334     }
       
   335     
       
   336 // ---------------------------------------------------------------------------
       
   337 // Set bold
       
   338 // ---------------------------------------------------------------------------
       
   339 //
       
   340 EXPORT_C void CAlfTextStyle::SetBold(TBool aIsBold)
       
   341     {
       
   342     if(!iData->iIsPreconfigured)
       
   343         {
       
   344         TPckgC<TInt> buf(aIsBold);
       
   345         TBuf8<1> dum;
       
   346         
       
   347         TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetBold, buf, dum);
       
   348 
       
   349         if ( err != KErrNone )
       
   350             {
       
   351             __ALFLOGSTRING1( "CAlfTextStyle::SetBold panic error %d", err )
       
   352             User::Invariant();
       
   353             }
       
   354         }    
       
   355     }
       
   356     
       
   357 // ---------------------------------------------------------------------------
       
   358 // Is italic
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 EXPORT_C TBool CAlfTextStyle::IsItalic() const
       
   362     {
       
   363 	TBufC8<1> inDum;
       
   364 	TBool isItalic = EFalse;
       
   365 	TPckg<TBool> outBuf(isItalic);
       
   366 	
       
   367 	TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleIsItalic, inDum, outBuf);
       
   368 	
       
   369 	if ( err != KErrNone )
       
   370 		{
       
   371 	    __ALFLOGSTRING1( "CAlfTextStyle::IsItalic ignore error %d", err )
       
   372 		}
       
   373 	        
       
   374 	return isItalic;
       
   375     }
       
   376     
       
   377 // ---------------------------------------------------------------------------
       
   378 // Set italic
       
   379 // ---------------------------------------------------------------------------
       
   380 //
       
   381 EXPORT_C void CAlfTextStyle::SetItalic(TBool aIsItalic)
       
   382     {
       
   383     if(!iData->iIsPreconfigured)
       
   384 	    {
       
   385 	    TPckgC<TInt> buf(aIsItalic);
       
   386 	    TBuf8<1> dum;
       
   387 	    
       
   388 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetItalic, buf, dum);
       
   389 	
       
   390 	    if ( err != KErrNone )
       
   391 	        {
       
   392 	        __ALFLOGSTRING1( "CAlfTextStyle::SetItalic panic error %d", err )
       
   393 	        User::Invariant();
       
   394 	        }
       
   395 	    }    
       
   396     }
       
   397     
       
   398 // ---------------------------------------------------------------------------
       
   399 // Is underlined
       
   400 // ---------------------------------------------------------------------------
       
   401 //
       
   402 EXPORT_C TBool CAlfTextStyle::IsUnderline() const
       
   403     {
       
   404 	if(iData->iIsPreconfigured)
       
   405 		{
       
   406 	    TBufC8<1> inDum;
       
   407 	    TBool isUnderline = EFalse;
       
   408 	    TPckg<TBool> outBuf(isUnderline);
       
   409 	    
       
   410 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleIsUnderline, inDum, outBuf);
       
   411 	    
       
   412 	    if ( err != KErrNone )
       
   413 	        {
       
   414 	        __ALFLOGSTRING1( "CAlfTextStyle::IsUnderline ignore error %d", err )
       
   415 	        } 
       
   416 	        
       
   417 	    return isUnderline;
       
   418 		}	
       
   419     if(iData->iLocalDefinitionFlags & KUnderlineDefined)
       
   420         {
       
   421         return iData->iIsUnderline;
       
   422         }
       
   423     return iData->iManager->TextStyle(iData->iParentId)->IsUnderline();
       
   424     }
       
   425     
       
   426 // ---------------------------------------------------------------------------
       
   427 // Set underlined
       
   428 // ---------------------------------------------------------------------------
       
   429 //
       
   430 EXPORT_C void CAlfTextStyle::SetUnderline(TBool aIsUnderline)
       
   431     {
       
   432     if(!iData->iIsPreconfigured)
       
   433         {
       
   434         iData->iIsUnderline = aIsUnderline;
       
   435         iData->iLocalDefinitionFlags |= KUnderlineDefined;
       
   436         
       
   437 	    TPckgC<TInt> buf(aIsUnderline);
       
   438 	    TBuf8<1> dum;
       
   439 	    
       
   440 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetUnderline, buf, dum);
       
   441 	
       
   442 	    if ( err != KErrNone )
       
   443 	        {
       
   444 	        __ALFLOGSTRING1( "CAlfTextStyle::SetUnderline panic error %d", err )
       
   445 	        User::Invariant();
       
   446 	        }
       
   447         }
       
   448     }
       
   449     
       
   450 // ---------------------------------------------------------------------------
       
   451 // Is strike through
       
   452 // ---------------------------------------------------------------------------
       
   453 //
       
   454 EXPORT_C TBool CAlfTextStyle::IsStrikeThrough() const
       
   455     {
       
   456 	if(iData->iIsPreconfigured)
       
   457 		{
       
   458 	    TBufC8<1> inDum;
       
   459 	    TBool isStrikeThrough = EFalse;
       
   460 	    TPckg<TBool> outBuf(isStrikeThrough);
       
   461 	    
       
   462 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleIsStrikeThrough, inDum, outBuf);
       
   463 	    
       
   464 	    if ( err != KErrNone )
       
   465 	        {
       
   466 	        __ALFLOGSTRING1( "CAlfTextStyle::IsStrikeThrough ignore error %d", err )
       
   467 	        } 
       
   468 	        
       
   469 	    return isStrikeThrough;
       
   470 		}	
       
   471     if(iData->iLocalDefinitionFlags & KStrikeThroughDefined)
       
   472         {
       
   473         return iData->iIsStrikeThrough;
       
   474         }
       
   475     return iData->iManager->TextStyle(iData->iParentId)->IsStrikeThrough();
       
   476     }
       
   477     
       
   478 // ---------------------------------------------------------------------------
       
   479 // Set strike through
       
   480 // ---------------------------------------------------------------------------
       
   481 //
       
   482 EXPORT_C void CAlfTextStyle::SetStrikeThrough(TBool aIsStrikeThrough)
       
   483     {
       
   484     if(!iData->iIsPreconfigured)
       
   485         {
       
   486         iData->iIsStrikeThrough = aIsStrikeThrough;
       
   487         iData->iLocalDefinitionFlags |= KStrikeThroughDefined;
       
   488         
       
   489 	    TPckgC<TInt> buf(aIsStrikeThrough);
       
   490 	    TBuf8<1> dum;
       
   491 	    
       
   492 	    TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetStrikeThrough, buf, dum);
       
   493 	
       
   494 	    if ( err != KErrNone )
       
   495 	        {
       
   496 	        __ALFLOGSTRING1( "CAlfTextStyle::SetStrikeThrough panic error %d", err )
       
   497 	        User::Invariant();
       
   498 	        }
       
   499         }
       
   500     }
       
   501 
       
   502 // ---------------------------------------------------------------------------
       
   503 // Get the typeface
       
   504 // ---------------------------------------------------------------------------
       
   505 //
       
   506 void CAlfTextStyle::GetTypeface( TTypeface& aTypeface ) const
       
   507 	{
       
   508     TBufC8<1> inDum;
       
   509 	TPckg<TTypeface> outBuf( aTypeface );
       
   510 	
       
   511 	TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleGetTypeface, inDum, outBuf);
       
   512 	
       
   513 	if ( err != KErrNone )
       
   514 		{
       
   515 	    __ALFLOGSTRING1( "CAlfTextStyle::GetTypeface ignore error %d", err )
       
   516 		}
       
   517 	        
       
   518 	return;
       
   519 	}
       
   520 	
       
   521 // ---------------------------------------------------------------------------
       
   522 // Get the typeface
       
   523 // ---------------------------------------------------------------------------
       
   524 //
       
   525 EXPORT_C HBufC* CAlfTextStyle::TypefaceNameL( ) const
       
   526 	{
       
   527        TBufC8<1> inDum;
       
   528        TTypeface aTypeface;
       
   529 	TPckg<TTypeface> outBuf( aTypeface );
       
   530 	
       
   531 	TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleGetTypeface, inDum, outBuf);
       
   532 	
       
   533 	if ( err != KErrNone )
       
   534 		{
       
   535 	    __ALFLOGSTRING1( "CAlfTextStyle::TypefaceName ignore error %d", err )
       
   536 		}
       
   537         return aTypeface.iName.AllocL();	        
       
   538 	}
       
   539 	
       
   540  // ---------------------------------------------------------------------------
       
   541  // Set Text Pane Height In Pixels
       
   542  // ---------------------------------------------------------------------------
       
   543  //
       
   544 EXPORT_C void CAlfTextStyle::SetTextPaneHeightInPixels(TInt aTextPaneHeight, TBool aIsDecoratedSize)
       
   545     {
       
   546     if(!iData->iIsPreconfigured)
       
   547         {
       
   548         TInt2 params(aTextPaneHeight, aIsDecoratedSize);
       
   549         TPckgC<TInt2> buf(params);   
       
   550         TBuf8<1> dum;
       
   551         
       
   552         TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleSetTextPaneHeightInPixels, buf, dum);
       
   553 
       
   554         if ( err != KErrNone )
       
   555             {
       
   556             __ALFLOGSTRING1( "CAlfTextStyle::SetTextPaneHeightInPixels panic error %d", err )
       
   557             User::Invariant();
       
   558             }
       
   559         }
       
   560     }
       
   561 	
       
   562 	
       
   563 // ---------------------------------------------------------------------------
       
   564 // ConstructL
       
   565 // ---------------------------------------------------------------------------
       
   566 //
       
   567 void CAlfTextStyle::ConstructL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams)
       
   568     {
       
   569 	if(!iData)
       
   570 		{
       
   571 	    iData = new (ELeave) TPrivateData;
       
   572 	    iData->iComms = NULL;
       
   573 	    iData->iId = 0;
       
   574 	    iData->iLocalDefinitionFlags = 0;
       
   575 	    iData->iManager = 0;
       
   576 	    iData->iParentId = 0;
       
   577 	    iData->iFontStyleId = 0;
       
   578 	    iData->iIsUnderline = EFalse;
       
   579 	    iData->iIsStrikeThrough = EFalse;
       
   580 	    iData->iIsPreconfigured = EFalse;
       
   581 		}
       
   582 	
       
   583     if (!iData->iComms)
       
   584         {
       
   585         iData->iComms = CAlfGenComponent::NewL(
       
   586             aEnv,
       
   587             aImplementationId, 
       
   588             0,
       
   589             aConstructionParams);  
       
   590         }    
       
   591     iData->iId = aId;
       
   592     iData->iManager = &aEnv.TextStyleManager();
       
   593     iData->iIsPreconfigured = (aImplementationId == EAlfPreconfiguredTextStyleCreate) ? ETrue : EFalse;
       
   594     iData->iServerHandle = KErrNotFound;
       
   595     }
       
   596 
       
   597 // ---------------------------------------------------------------------------
       
   598 // Return Alf general component instance
       
   599 // ---------------------------------------------------------------------------
       
   600 //
       
   601 CAlfGenComponent* CAlfTextStyle::Comms() const
       
   602 	{
       
   603 	return iData->iComms;
       
   604 	}
       
   605 	
       
   606 // ---------------------------------------------------------------------------
       
   607 // Return serverside id
       
   608 // ---------------------------------------------------------------------------
       
   609 //
       
   610 TInt CAlfTextStyle::ServerHandle() const
       
   611     {
       
   612     if (iData->iServerHandle != KErrNotFound)
       
   613         {
       
   614         return iData->iServerHandle;    
       
   615         }
       
   616     else
       
   617         {
       
   618         TPckg<TInt> buf(iData->iServerHandle);   
       
   619         TBuf8<1> dum;        
       
   620         TInt err = iData->iComms->DoSynchronousCmd(EAlfTextStyleServerHandle, dum, buf);        
       
   621         if ( err != KErrNone )
       
   622             {
       
   623             __ALFLOGSTRING1( "CAlfTextStyle::ServerHandle panic error %d", err )
       
   624             User::Invariant();
       
   625             }
       
   626         return iData->iServerHandle;
       
   627         }            
       
   628     }
       
   629 #else
       
   630 NONSHARABLE_CLASS(CTextBitmapProvider):public CBase, public MAlfBitmapProvider
       
   631     {
       
   632     public: 
       
   633     virtual void ProvideBitmapL(TInt /*aId*/, CFbsBitmap*& aBitmap, CFbsBitmap*& aMaskBitmap)
       
   634         {
       
   635         aBitmap = iColorBitmap;
       
   636         iColorBitmap = 0;
       
   637         aMaskBitmap = iAlphaBitmap;
       
   638         iAlphaBitmap= 0;
       
   639         }
       
   640         
       
   641     ~CTextBitmapProvider()
       
   642         {
       
   643         delete iColorBitmap;
       
   644         delete iAlphaBitmap;
       
   645         }
       
   646         
       
   647     CFbsBitmap* iColorBitmap;
       
   648     CFbsBitmap* iAlphaBitmap;
       
   649     };
       
   650     
       
   651 // Private data
       
   652 struct CAlfTextStyle::TPrivateData
       
   653     {
       
   654     CAlfTextStyleManager* iManager; // Not owned.
       
   655     TInt iId; // Owned.
       
   656     TInt iParentId; // Owned.
       
   657     TInt iFontStyleId; // Owned
       
   658     TInt iLocalDefinitionFlags; // Owned.
       
   659     TRgb iTextColor; // Owned.
       
   660     TBool iIsUnderline; // Owned.
       
   661     TBool iIsStrikeThrough; // Owned.
       
   662     THuiFont iFont; // cool
       
   663     CTextBitmapProvider* iBitmapProvider;
       
   664     };
       
   665 
       
   666 // ======== MEMBER FUNCTIONS ========
       
   667 
       
   668 // ---------------------------------------------------------------------------
       
   669 // Constructor
       
   670 // ---------------------------------------------------------------------------
       
   671 //
       
   672 CAlfTextStyle::CAlfTextStyle()
       
   673 	: iData(NULL)
       
   674 	{
       
   675 	}
       
   676     
       
   677 // ---------------------------------------------------------------------------
       
   678 // Destructor
       
   679 // ---------------------------------------------------------------------------
       
   680 //
       
   681 CAlfTextStyle::~CAlfTextStyle()
       
   682 	{
       
   683     if(iData)
       
   684 	    {
       
   685     	//delete iData->iComms;
       
   686     	//iData->iComms = NULL;
       
   687 	    delete iData->iBitmapProvider;
       
   688 	    }
       
   689 	delete iData;
       
   690 	iData = NULL;
       
   691 	}
       
   692 
       
   693 // ---------------------------------------------------------------------------
       
   694 // Constructs a new CAlfTextStyle object
       
   695 // ---------------------------------------------------------------------------
       
   696 //
       
   697 CAlfTextStyle* CAlfTextStyle::NewL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams)
       
   698 	{
       
   699 	CAlfTextStyle* self = CAlfTextStyle::NewLC(aEnv, aId, aImplementationId, aConstructionParams);        
       
   700     CleanupStack::Pop(self);
       
   701     return self;			
       
   702 	}
       
   703 
       
   704 // ---------------------------------------------------------------------------
       
   705 // Constructs a new CAlfTextStyle object
       
   706 // ---------------------------------------------------------------------------
       
   707 //
       
   708 CAlfTextStyle* CAlfTextStyle::NewLC(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& aConstructionParams)
       
   709 	{
       
   710 	CAlfTextStyle* self = new( ELeave ) CAlfTextStyle();
       
   711     CleanupStack::PushL(self);
       
   712     self->ConstructL(aEnv, aId, aImplementationId, aConstructionParams);
       
   713     return self;			
       
   714 	}
       
   715 
       
   716 // ---------------------------------------------------------------------------
       
   717 // Return font style id
       
   718 // ---------------------------------------------------------------------------
       
   719 //
       
   720 TInt CAlfTextStyle::FontStyleId() const
       
   721     {
       
   722 	return iData->iFontStyleId;
       
   723     }
       
   724     
       
   725 // ---------------------------------------------------------------------------
       
   726 // Set font style id
       
   727 // ---------------------------------------------------------------------------
       
   728 //
       
   729 void CAlfTextStyle::SetFontStyleId(TInt aFontStyleId)
       
   730     {
       
   731 	iData->iFontStyleId = aFontStyleId;
       
   732     ReportChanged();
       
   733     }
       
   734     
       
   735 // ---------------------------------------------------------------------------
       
   736 // Return parent id
       
   737 // ---------------------------------------------------------------------------
       
   738 //
       
   739 EXPORT_C TInt CAlfTextStyle::ParentId() const
       
   740     {
       
   741 	return iData->iParentId;
       
   742     }
       
   743     
       
   744 // ---------------------------------------------------------------------------
       
   745 // Set parent id
       
   746 // ---------------------------------------------------------------------------
       
   747 //
       
   748 EXPORT_C void CAlfTextStyle::SetParentId(TInt aParentId)
       
   749     {
       
   750     iData->iParentId = aParentId;
       
   751     ReportChanged();
       
   752     }
       
   753 
       
   754 // ---------------------------------------------------------------------------
       
   755 // Return Id
       
   756 // ---------------------------------------------------------------------------
       
   757 //
       
   758 EXPORT_C TInt CAlfTextStyle::Id() const
       
   759     {
       
   760 	return iData->iId;
       
   761     }
       
   762     
       
   763 // ---------------------------------------------------------------------------
       
   764 // Return text color
       
   765 // ---------------------------------------------------------------------------
       
   766 //
       
   767 EXPORT_C TRgb CAlfTextStyle::TextColor() const
       
   768     {
       
   769     if(iData->iLocalDefinitionFlags & KTextColorDefined)
       
   770         {
       
   771         return iData->iTextColor;
       
   772         }
       
   773     return iData->iManager->TextStyle(iData->iParentId)->TextColor();
       
   774     }
       
   775 
       
   776 // ---------------------------------------------------------------------------
       
   777 // Sets the color of the text rasterized with this style.
       
   778 // ---------------------------------------------------------------------------
       
   779 //
       
   780 EXPORT_C void CAlfTextStyle::SetTextColor(const TRgb& aTextColor)
       
   781     {
       
   782     iData->iTextColor = aTextColor;
       
   783     iData->iLocalDefinitionFlags |= KTextColorDefined;
       
   784     ReportChanged();
       
   785     }
       
   786     
       
   787 // ---------------------------------------------------------------------------
       
   788 // Returns the text size of this style in screen size independent units (twips).
       
   789 // ---------------------------------------------------------------------------
       
   790 //
       
   791 EXPORT_C TInt CAlfTextStyle::TextSizeInTwips(TBool /*aIsDecoratedSize*/) const
       
   792     {
       
   793     TFontSpec spec = Font()->FontSpec();
       
   794     TInt size = spec.iHeight;
       
   795             
       
   796     return size;
       
   797     }
       
   798     
       
   799 // ---------------------------------------------------------------------------
       
   800 // Set text size
       
   801 // ---------------------------------------------------------------------------
       
   802 //
       
   803 EXPORT_C void CAlfTextStyle::SetTextSizeInTwips(TInt aTextSizeInTwips, TBool /*aIsDecoratedSize*/)
       
   804     {
       
   805 	TFontSpec spec = OwnFont()->FontSpec();
       
   806     
       
   807     spec.iHeight = aTextSizeInTwips;
       
   808     Font()->SetFontSpec(spec);
       
   809     iData->iLocalDefinitionFlags |= KTextSizeDefined;
       
   810     ReportChanged();
       
   811     }
       
   812     
       
   813 // ---------------------------------------------------------------------------
       
   814 // Get text size
       
   815 // ---------------------------------------------------------------------------
       
   816 //
       
   817 EXPORT_C TInt CAlfTextStyle::TextSizeInPixels(TBool /*aIsDecoratedSize*/) const
       
   818 	{
       
   819     TFontSpec spec = Font()->FontSpec();
       
   820     CWsScreenDevice* screenDevice = CCoeEnv::Static()->ScreenDevice();
       
   821     TInt textsizeInPix = screenDevice->VerticalTwipsToPixels(spec.iHeight);
       
   822             
       
   823     return textsizeInPix;
       
   824  	}
       
   825     
       
   826  // ---------------------------------------------------------------------------
       
   827  // Set text size
       
   828  // ---------------------------------------------------------------------------
       
   829  //
       
   830 EXPORT_C void CAlfTextStyle::SetTextSizeInPixels(TInt aTextSizeInPixels, TBool /*aIsDecoratedSize*/)
       
   831     {
       
   832     TFontSpec spec = OwnFont()->FontSpec(); 
       
   833     CWsScreenDevice* screenDev = CCoeEnv::Static()->ScreenDevice();
       
   834     
       
   835     TInt textsizeInTwips = screenDev->VerticalPixelsToTwips(aTextSizeInPixels);
       
   836     spec.iHeight = textsizeInTwips;
       
   837     Font()->SetFontSpec(spec);
       
   838     iData->iLocalDefinitionFlags |= KTextSizeDefined;
       
   839     ReportChanged();
       
   840 	}
       
   841     
       
   842 // ---------------------------------------------------------------------------
       
   843 // Is bold
       
   844 // ---------------------------------------------------------------------------
       
   845 //
       
   846 EXPORT_C TBool CAlfTextStyle::IsBold() const
       
   847     {
       
   848     TFontSpec spec = Font()->FontSpec();
       
   849     return spec.iFontStyle.StrokeWeight();
       
   850     }
       
   851     
       
   852 // ---------------------------------------------------------------------------
       
   853 // Set bold
       
   854 // ---------------------------------------------------------------------------
       
   855 //
       
   856 EXPORT_C void CAlfTextStyle::SetBold(TBool aIsBold)
       
   857     {
       
   858     TFontSpec spec = OwnFont()->FontSpec();
       
   859 	spec.iFontStyle.SetStrokeWeight((aIsBold ? EStrokeWeightBold : EStrokeWeightNormal));
       
   860     Font()->SetFontSpec(spec);
       
   861     iData->iLocalDefinitionFlags |= KStrokeWeightDefined;    
       
   862     ReportChanged();
       
   863     }
       
   864     
       
   865 // ---------------------------------------------------------------------------
       
   866 // Is italic
       
   867 // ---------------------------------------------------------------------------
       
   868 //
       
   869 EXPORT_C TBool CAlfTextStyle::IsItalic() const
       
   870     {
       
   871     TFontSpec spec = Font()->FontSpec();
       
   872     return spec.iFontStyle.Posture();
       
   873     }
       
   874     
       
   875 // ---------------------------------------------------------------------------
       
   876 // Set italic
       
   877 // ---------------------------------------------------------------------------
       
   878 //
       
   879 EXPORT_C void CAlfTextStyle::SetItalic(TBool aIsItalic)
       
   880     {
       
   881     TFontSpec spec = OwnFont()->FontSpec();
       
   882 	spec.iFontStyle.SetPosture((aIsItalic ? EPostureItalic : EPostureUpright));
       
   883     Font()->SetFontSpec(spec);
       
   884     iData->iLocalDefinitionFlags |= KPostureDefined;
       
   885     ReportChanged();
       
   886     }
       
   887     
       
   888 // ---------------------------------------------------------------------------
       
   889 // Is underlined
       
   890 // ---------------------------------------------------------------------------
       
   891 //
       
   892 EXPORT_C TBool CAlfTextStyle::IsUnderline() const
       
   893     {
       
   894     if(iData->iLocalDefinitionFlags & KUnderlineDefined)
       
   895         {
       
   896         return iData->iIsUnderline;
       
   897         }
       
   898     return iData->iManager->TextStyle(iData->iParentId)->IsUnderline();
       
   899     }
       
   900     
       
   901 // ---------------------------------------------------------------------------
       
   902 // Set underlined
       
   903 // ---------------------------------------------------------------------------
       
   904 //
       
   905 EXPORT_C void CAlfTextStyle::SetUnderline(TBool aIsUnderline)
       
   906     {
       
   907     iData->iIsUnderline = aIsUnderline;
       
   908     iData->iLocalDefinitionFlags |= KUnderlineDefined;
       
   909     ReportChanged();
       
   910     }
       
   911     
       
   912 // ---------------------------------------------------------------------------
       
   913 // Is strike through
       
   914 // ---------------------------------------------------------------------------
       
   915 //
       
   916 EXPORT_C TBool CAlfTextStyle::IsStrikeThrough() const
       
   917     {
       
   918     if(iData->iLocalDefinitionFlags & KStrikeThroughDefined)
       
   919         {
       
   920         return iData->iIsStrikeThrough;
       
   921         }
       
   922     return iData->iManager->TextStyle(iData->iParentId)->IsStrikeThrough();
       
   923     }
       
   924     
       
   925 // ---------------------------------------------------------------------------
       
   926 // Set strike through
       
   927 // ---------------------------------------------------------------------------
       
   928 //
       
   929 EXPORT_C void CAlfTextStyle::SetStrikeThrough(TBool aIsStrikeThrough)
       
   930     {
       
   931     iData->iIsStrikeThrough = aIsStrikeThrough;
       
   932     iData->iLocalDefinitionFlags |= KStrikeThroughDefined;
       
   933     ReportChanged();
       
   934     }
       
   935 
       
   936 // ---------------------------------------------------------------------------
       
   937 // Get the typeface
       
   938 // ---------------------------------------------------------------------------
       
   939 //
       
   940 void CAlfTextStyle::GetTypeface( TTypeface& aTypeface ) const
       
   941 	{
       
   942     TFontSpec spec = Font()->FontSpec();
       
   943     aTypeface = spec.iTypeface; // Structure copy
       
   944 	}
       
   945 	
       
   946 // ---------------------------------------------------------------------------
       
   947 // Get the typeface
       
   948 // ---------------------------------------------------------------------------
       
   949 //
       
   950 EXPORT_C HBufC* CAlfTextStyle::TypefaceNameL( ) const
       
   951 	{
       
   952 	return Font()->FontSpec().iTypeface.iName.AllocL();
       
   953 	}
       
   954 	
       
   955  // ---------------------------------------------------------------------------
       
   956  // Set Text Pane Height In Pixels
       
   957  // ---------------------------------------------------------------------------
       
   958  //
       
   959 EXPORT_C void CAlfTextStyle::SetTextPaneHeightInPixels(TInt aTextPaneHeight, TBool /*aIsDecoratedSize*/)
       
   960     {
       
   961     TFontSpec oldFontSpec = Font()->FontSpec(); 
       
   962     
       
   963     // now generate a font with the new text pane height 
       
   964     CWsScreenDevice* screenDev = CCoeEnv::Static()->ScreenDevice();
       
   965     TAknFontSpecification aknFs(Font()->Category(), oldFontSpec, screenDev);
       
   966     aknFs.SetTextPaneHeight(aTextPaneHeight);
       
   967 
       
   968     // and get its corresponding spec
       
   969     TFontSpec newFontSpec;
       
   970     TInt foundIndex(KErrNotFound);
       
   971     AknFontProvider::GetFontSpecFromMetrics(*screenDev, 0, aknFs, newFontSpec, foundIndex);
       
   972 
       
   973     if(foundIndex != KErrNotFound)
       
   974         {
       
   975         TInt textsizeInTwips = screenDev->VerticalPixelsToTwips(newFontSpec.iHeight);
       
   976         newFontSpec.iHeight = textsizeInTwips;
       
   977         OwnFont()->SetFontSpec(newFontSpec);
       
   978         iData->iLocalDefinitionFlags |= KTextSizeDefined;
       
   979         }
       
   980     }
       
   981 
       
   982 // ---------------------------------------------------------------------------
       
   983 // CAlfTextStyle::RasterizeLineL
       
   984 // Rasterizes the given string on to the target texture using this text style.
       
   985 // ---------------------------------------------------------------------------
       
   986 //
       
   987 void CAlfTextStyle::RasterizeLineL(const TDesC& aTextLine, CAlfTexture** aTargetTexture)
       
   988 	{
       
   989 	// Calculate the pixel extents of the text line.
       
   990 	TSize textureSize = LineExtentsL(aTextLine);
       
   991 	
       
   992 	//TSize maxTextureSize = (*aTargetTexture)->MaxTextureSize();
       
   993 
       
   994     if (!iData->iBitmapProvider)
       
   995         {
       
   996         iData->iBitmapProvider = new (ELeave) CTextBitmapProvider();
       
   997         }
       
   998     
       
   999     if ( !iData->iBitmapProvider->iColorBitmap || textureSize != iData->iBitmapProvider->iColorBitmap->SizeInPixels())  
       
  1000         {
       
  1001         // could resize existing instead..    
       
  1002         delete iData->iBitmapProvider->iColorBitmap;
       
  1003         iData->iBitmapProvider->iColorBitmap = 0;
       
  1004         // Create target alpha bitmap to rasterize the text onto.
       
  1005 	    iData->iBitmapProvider->iColorBitmap = new (ELeave) CFbsBitmap();    
       
  1006 	    User::LeaveIfError(iData->iBitmapProvider->iColorBitmap->Create(textureSize, EGray256));
       
  1007         }
       
  1008 	
       
  1009 	// Create the bitmap device to be used in rasterization.
       
  1010     CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iData->iBitmapProvider->iColorBitmap);
       
  1011 	CleanupStack::PushL(device);
       
  1012 	
       
  1013 	// Create drawing context.
       
  1014 	CFbsBitGc* gc = 0;
       
  1015 	User::LeaveIfError(device->CreateContext(gc));
       
  1016 	CleanupStack::PushL(gc);
       
  1017 	
       
  1018 	// Prepare the bitmap for drawing.
       
  1019 	gc->SetBrushColor(KRgbBlack);
       
  1020 	gc->Clear();
       
  1021 	
       
  1022 	// Draw the text onto the bitmap.    
       
  1023 	gc->SetPenColor(KRgbWhite);
       
  1024 		
       
  1025 	// Do underlining
       
  1026 	gc->SetUnderlineStyle(IsUnderline() ? EUnderlineOn : EUnderlineOff);
       
  1027 	// Do strikethrough
       
  1028 	gc->SetStrikethroughStyle(IsStrikeThrough() ? EStrikethroughOn : EStrikethroughOff);
       
  1029 	
       
  1030 	//if(iClippingEnabled)
       
  1031 	//{
       
  1032     //	gc->SetClippingRect(iClipRect);
       
  1033 	//}
       
  1034     
       
  1035 	// Rasterize text string using the configured font.
       
  1036 	Font()->RasterizeLineL(aTextLine, *gc);
       
  1037 	
       
  1038 	// Destroy graphics context and drawing device.
       
  1039 	CleanupStack::PopAndDestroy(gc);
       
  1040 	CleanupStack::PopAndDestroy(device);
       
  1041     
       
  1042 
       
  1043 	delete iData->iBitmapProvider->iAlphaBitmap;
       
  1044 	iData->iBitmapProvider->iAlphaBitmap = NULL;
       
  1045 	
       
  1046     // todo: proper flagging, e.g. use directly        
       
  1047     *aTargetTexture = &CAlfEnv::Static()->TextureManager().CreateTextureL(KAlfAutoGeneratedTextureId, 
       
  1048                                                                         iData->iBitmapProvider,
       
  1049                                                                         EAlfTextureFlagDefault); 
       
  1050 	}
       
  1051 
       
  1052 // ---------------------------------------------------------------------------
       
  1053 // THuiTextStyle::LineExtentsL
       
  1054 // Provides dimensions of the rasterization of the given string. 
       
  1055 // ---------------------------------------------------------------------------
       
  1056 //
       
  1057 TSize CAlfTextStyle::LineExtentsL(const TDesC& aTextLine)
       
  1058 	{    
       
  1059 	// Retrieve the non-decorated line extents from the used font.
       
  1060 	return Font()->LineExtentsL(aTextLine);
       
  1061 	}
       
  1062 // ---------------------------------------------------------------------------
       
  1063 // ConstructL
       
  1064 // ---------------------------------------------------------------------------
       
  1065 //
       
  1066 void CAlfTextStyle::ConstructL(CAlfEnv& aEnv, TInt aId, TInt aImplementationId, const TDesC8& /*aConstructionParams*/)
       
  1067     {
       
  1068 	if(!iData)
       
  1069 		{
       
  1070 	    iData = new (ELeave) TPrivateData;
       
  1071 	    iData->iId = 0;
       
  1072 	    iData->iLocalDefinitionFlags = 0;
       
  1073 	    iData->iManager = 0;
       
  1074 	    iData->iParentId = 0;
       
  1075 	    iData->iFontStyleId = aImplementationId;
       
  1076 	    iData->iIsUnderline = EFalse;
       
  1077 	    iData->iIsStrikeThrough = EFalse;
       
  1078 		iData->iBitmapProvider = 0;
       
  1079 		}
       
  1080 	
       
  1081 /*    if (!iData->iComms)
       
  1082         {
       
  1083         iData->iComms = CAlfGenComponent::NewL(
       
  1084             aEnv,
       
  1085             aImplementationId, 
       
  1086             0,
       
  1087             aConstructionParams);  
       
  1088         }*/
       
  1089            
       
  1090     iData->iId = aId;
       
  1091     //iData->iManager = &aEnv.TextStyleManager();
       
  1092     //iData->iIsPreconfigured = (aImplementationId == EAlfPreconfiguredTextStyleCreate) ? ETrue : EFalse;
       
  1093     //iData->iServerHandle = KErrNotFound;
       
  1094     iData->iBitmapProvider = new (ELeave) CTextBitmapProvider();
       
  1095     }
       
  1096 
       
  1097 CAlfGenComponent* CAlfTextStyle::Comms() const
       
  1098 	{
       
  1099     return 0;
       
  1100 	}
       
  1101 	
       
  1102 TInt CAlfTextStyle::ServerHandle() const
       
  1103     {
       
  1104     return KErrNotFound;
       
  1105     }
       
  1106 	
       
  1107 THuiFont* CAlfTextStyle::Font() const
       
  1108     {
       
  1109     if(iData->iLocalDefinitionFlags & KFontDefined)
       
  1110         {
       
  1111         return &iData->iFont;
       
  1112         }
       
  1113         
       
  1114     return iData->iManager->TextStyle(iData->iParentId)->Font();
       
  1115     }
       
  1116     
       
  1117 THuiFont* CAlfTextStyle::OwnFont()
       
  1118     {
       
  1119     if(!(iData->iLocalDefinitionFlags & KFontDefined))
       
  1120         {
       
  1121         SetFont(iData->iManager->TextStyle(iData->iParentId)->Font());
       
  1122         }
       
  1123     
       
  1124     return Font();
       
  1125     }
       
  1126 
       
  1127 void CAlfTextStyle::SetFont(THuiFont* aFont)
       
  1128     {
       
  1129     if (aFont)
       
  1130         {
       
  1131         iData->iFont = *aFont;
       
  1132         iData->iLocalDefinitionFlags |= KFontDefined;
       
  1133         }
       
  1134     else    
       
  1135         {
       
  1136         iData->iLocalDefinitionFlags &= ~KFontDefined;
       
  1137         }
       
  1138         
       
  1139     ReportChanged();
       
  1140     }
       
  1141 
       
  1142 void CAlfTextStyle::ReportChanged()
       
  1143     {
       
  1144     if (iData->iManager)
       
  1145         { // when creating platform style, manager is not ready yet
       
  1146         iData->iManager->RefreshVisuals(iData->iId);    
       
  1147         }
       
  1148     }
       
  1149 
       
  1150 void CAlfTextStyle::SetManager(CAlfTextStyleManager* aManager)
       
  1151     {
       
  1152     iData->iManager = aManager;
       
  1153     }
       
  1154 #endif