void CEditorContainer::CreateEditorL(void) { iEditor = new (ELeave) CEikRichTextEditor; iEditor->SetAknEditorFlags(EAknEditorFlagEnableScrollBars); iEditor->SetContainerWindowL(*this); iEditor->SetAvkonWrap(ETrue); iEditor->ConstructL(this, 0, 0, 0); iEditor->SetFocus(ETrue); iEditor->SetReadOnly(EFalse); iEditor->EnableCcpuSupportL(ETrue); iEditor->SetCursorPosL(0, EFalse); iEditor->SetAvkonWrap(ETrue); iEditor->SetInputCapabilitiesL(TCoeInputCapabilities::EAllText); iEditor->SetAknEditorAllowedInputModes(EAknEditorAllInputModes); iEditor->SetAknEditorInputMode(EAknEditorTextInputMode); iEditor->SetAknEditorCase(EAknEditorLowerCase); //iEditor->SetTextL(&_L("CIAO!!!!")); TFontSpec fontspec = LatinBold16()->FontSpecInTwips(); TCharFormat charFormat(fontspec.iTypeface.iName, fontspec.iHeight); TCharFormatMask charFormatMask; charFormat.iFontPresentation.iTextColor = KRgbBlack; charFormatMask.SetAttrib(EAttColor); charFormatMask.SetAttrib(EAttFontTypeface); charFormatMask.SetAttrib(EAttFontHeight); iEditor->ApplyCharFormatL(charFormat, charFormatMask); iEditor->UpdateScrollBarsL(); SizeChanged(); }
void CUiLoftAppView::SetTypefaceL(const TDesC& aTypeFace) { TCharFormat charFormat( aTypeFace, 3); TCharFormatMask charFormatMask; charFormatMask.SetAll(); iEditor->ApplyCharFormatL(charFormat, charFormatMask); }
void CWordTest::SetPictureAlignmentL(CEikRichTextEditor* aEditor,TFontPresentation::TAlignment aAlignment) { TCharFormat format; format.iFontPresentation.iPictureAlignment = aAlignment; TCharFormatMask mask; mask.SetAttrib(EAttFontPictureAlignment); aEditor->ApplyCharFormatL(format,mask); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ void CMyHelpContainer::ConstructL() { CreateWindowL(); iBgContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain,TRect(0,0,1,1), ETrue); iMirroRed = AknLayoutUtils::LayoutMirrored(); iEditor = new (ELeave) CEikRichTextEditor; iEditor->SetAknEditorFlags(EAknEditorFlagEnableScrollBars); iEditor->SetContainerWindowL(*this); iEditor->ConstructL(this,0,0,0); iEditor->CreateScrollBarFrameL(); iEditor->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EAuto, CEikScrollBarFrame::EAuto); TCharFormat charFormat; TCharFormatMask charFormatMask; _LIT(KFontArial,"Arial"); TRgb textcol; MAknsSkinInstance* skin = AknsUtils::SkinInstance(); AknsUtils::GetCachedColor(skin,textcol,KAknsIIDQsnTextColors,EAknsCIQsnTextColorsCG6); charFormat.iFontSpec = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont)->FontSpecInTwips(); charFormat.iFontPresentation.iTextColor = TLogicalRgb(textcol);; charFormatMask.SetAll(); iParaformMe = CParaFormatLayer::NewL(); iCharformMe = CCharFormatLayer::NewL(charFormat,charFormatMask); iRichMessageMe = CRichText::NewL(iParaformMe,iCharformMe); AddTextToEditorL(); iEditor->SetDocumentContentL(*iRichMessageMe); iEditor->SetDocumentContentL(*iRichMessageMe); iEditor->SetCursorPosL(0,EFalse); iEditor->SetFocus(EFalse); iEditor->SetFocusing(ETrue); TRect MyRect(CEikonEnv::Static()->EikAppUi()->ClientRect()); SetRect(MyRect); ActivateL(); DrawNow(); SizeChanged(); iEditor->ClearSelectionL(); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->MoveCursorL(TCursorPosition::EFPageUp, EFalse); iEditor->UpdateScrollBarsL(); iEditor->DrawNow(); }
void CUiLoftAppView::SetColorL(TRgb aColor) { TCharFormat charFormat; TCharFormatMask charFormatMask; charFormat.iFontPresentation.iTextColor = aColor; charFormatMask.SetAttrib(EAttColor); iEditor->ApplyCharFormatL(charFormat, charFormatMask); // iRtEd->SetBackgroundColorL(aColor); // It is possible to change the background color - if foreground and background // color is same, the text became invisible. }
void CHelpContainer::SetFontAndColor(const CFont* aFont, TRgb aColor) { TCharFormat charFormat; TCharFormatMask charFormatMask; charFormat.iFontPresentation.iTextColor = aColor; charFormatMask.SetAttrib(EAttColor); TFontSpec sFontSpec = aFont->FontSpecInTwips(); charFormatMask.SetAttrib(EAttFontTypeface); charFormatMask.SetAttrib(EAttFontHeight); charFormat.iFontSpec.iTypeface = sFontSpec.iTypeface; charFormat.iFontSpec.iHeight = sFontSpec.iHeight; iRtEd->ApplyCharFormatL(charFormat, charFormatMask); }
EXPORT_C void CGlobalText::GetCharFormat(TCharFormat& aFormat,TCharFormatMask& aVaries, TInt /*aPos*/,TInt /*aLength*/) const /** Gets the global text object's effective character formatting. Note that the last three arguments are not relevant to the global text implementation of this function. @param aFormat On return, contains the effective character formatting for the global text object. @param aVaries On return, a bitmask indicating which character format attributes vary over the range of characters selected. This is only relevant for rich text, so for global text returns a value of zero for all attributes. @param aPos This argument is not used for global text. @param aLength This argument is not used for global text. */ { iGlobalCharFormatLayer->SenseEffective(aFormat); aVaries.ClearAll(); }
void CEikListBoxTextEditor::UseFontL( CEikEdwin& aEditor, const CFont& aFont ) { _AKNTRACE_FUNC_ENTER; CGlobalText* globalText; TCharFormatMask defaultCharFormatMask; defaultCharFormatMask.SetAttrib(EAttFontTypeface); defaultCharFormatMask.SetAttrib(EAttFontHeight); TFontSpec fontspec = aFont.FontSpecInTwips(); TCharFormat defaultCharFormat( fontspec.iTypeface.iName, fontspec.iHeight ); iParaFormatLayer=CParaFormatLayer::NewL(); iCharFormatLayer=CCharFormatLayer::NewL(defaultCharFormat,defaultCharFormatMask); globalText=CGlobalText::NewL(iParaFormatLayer,iCharFormatLayer,CEditableText::ESegmentedStorage,5); CleanupStack::PushL(globalText); TCharFormat charFormat; TCharFormatMask charMask; iCharFormatLayer->Sense(charFormat,charMask); if ( fontspec.iFontStyle.Posture()==EPostureItalic ) { charMask.SetAttrib(EAttFontPosture); charFormat.iFontSpec.iFontStyle.SetPosture(EPostureItalic); } if ( fontspec.iFontStyle.StrokeWeight()==EStrokeWeightBold ) { charMask.SetAttrib(EAttFontStrokeWeight ); charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); } iCharFormatLayer->SetL(charFormat,charMask); CPlainText* old=aEditor.Text(); CleanupStack::Pop(); // globalText CleanupStack::PushL(old); // old is pushed because we're using EUseText in the subsequent call aEditor.SetDocumentContentL(*globalText,CEikEdwin::EUseText); CleanupStack::PopAndDestroy(); // old _AKNTRACE_FUNC_EXIT; }
void CTTGPSLoggerViewerContainer::ConstructL(const TRect& aRect) { CreateWindowL(); SetMopParent(iParent); TResourceReader rr; iEikonEnv->CreateResourceReaderLC(rr, R_TTGP_EDWIN_VIEWER); iEdwin = new (ELeave)CEikEdwin; iEdwin->SetContainerWindowL(*this); iEdwin->ConstructFromResourceL(rr); iEdwin->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn); CleanupStack::PopAndDestroy(); // rr { iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, //KAknsIIDQsnBgScreen, TRect(0, 0, 0, 0), // changed in SizeChanged() EFalse); iEdwin->SetSkinBackgroundControlContextL(iBgContext); TInt err(0); TRgb color; err = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6); if (err == KErrNone) { CCharFormatLayer* charformatLayer = CEikonEnv::NewDefaultCharFormatLayerL(); TCharFormat charFormat; TCharFormatMask charFormatMask; charformatLayer->Sense(charFormat, charFormatMask); charFormat.iFontPresentation.iTextColor = color; charFormatMask.SetAttrib(EAttColor); charformatLayer->SetL(charFormat, charFormatMask); iEdwin->SetCharFormatLayer(charformatLayer); } } iEdwinText.CreateL(8192); iPositionData = CTTGPSLoggerPositionData::NewL(); iNavigationDecorator = TTGPSLoggerCommon::PushNavigationDecoratorL(); TTGPSLoggerCommon::SetTextNavigationPane(_L("Reading...")); iItemNameModId = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_MODID); iItemNameModName = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_MODNAME); iItemNameLon = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_LON); iItemNameLat = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_LAT); iItemNameAlt = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_ALT); iItemNameSeaAlt = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_SEAALT); iItemNameGeoSep = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_GEOSEP); iItemNameHAcc = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_HACC); iItemNameVAcc = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_VACC); iItemNameHSpeed = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_HSPEED); iItemNameVSpeed = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_VSPEED); iItemNameTCourse = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_TCOURSE); iItemNameMCourse = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_MCOURSE); iItemNameHeading = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_HEADING); iItemNameMHeading = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_MHEADING); iItemNameHDOP = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_HDOP); iItemNameVDOP = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_VDOP); iItemNamePDOP = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_PDOP); iItemNameTDOP = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_TDOP); iItemNameSatNumInView = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_SATNUMINVIEW); iItemNameSatNumUsed = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_SATNUMUSED); iItemNameSatTime = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF32_GPSSTATUSVIEW_ITEM_SATTIME); iMsgCopyClipboard = CEikonEnv::Static()->AllocReadResourceL(R_TTGP_TBUF_MSG_COPY_CLIPBOARD); SetRect(aRect); ActivateL(); }
void CUiLoftAppView::ConstructL(const TRect& aRect) { // Create a window for this application view CreateWindowL(); const CFont* sysfont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont); TFontSpec sysfontspec = sysfont->FontSpecInTwips(); iIcons = new (ELeave) CArrayPtrFlat<CGulIcon>(10); JuikIcons::LoadIconsL( iIcons, KMyIconIds, KMyIconCount); AknIconUtils::SetSize(iIcons->At(0)->Bitmap(), TSize(70,70)); iEditor = new (ELeave) CEikRichTextEditor(); iEditor->SetContainerWindowL(*this); iEditor->ConstructL(this, 1000,1000,CEikEdwin::EAllowPictures | CEikEdwin::EReadOnly ,EGulFontControlAll,EGulAllFonts); //iEditor->SetRect(TRect(TSize(Rect().Width() - 10,Rect().Height()))); // iEditor-> CreateScrollBarFrameL()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn ); // CRichText* richtext = iEditor->RichText(); // InsertMyPictureL(0); // InsertMyPictureL(0); // richtext->AppendParagraphL(); // _LIT(KBy,"Repsu:"); // _LIT(KPost, "They are planning to cut my balls off..."); // _LIT(KTimestamp, "3 weeks, 4 days ago. "); // _LIT(KCommentCount, "6 Comments"); // auto_ptr<CParaFormat> paraFormat( CParaFormat::NewL() ); // paraFormat->iLeftMarginInTwips = 400; // TParaFormatMask paraMask; // paraMask.SetAttrib( EAttLeftMargin ); // TCharFormat charfmt; // charfmt.iFontSpec = sysfontspec; // TCharFormatMask charmask; // charmask.SetAll(); // richtext->InsertL( richtext->DocumentLength(), KBy); // richtext->ApplyCharFormatL( charfmt, charmask, 3, 5); // richtext->AppendParagraphL(); // richtext->InsertL( richtext->DocumentLength(), KPost); // TInt last = richtext->DocumentLength() - 1; // richtext->ApplyParaFormatL( paraFormat.get(), paraMask, last, 1); // richtext->AppendParagraphL(); // richtext->InsertL( richtext->DocumentLength(), KTimestamp); // richtext->AppendParagraphL(); // richtext->InsertL( richtext->DocumentLength(), KCommentCount); // last = richtext->DocumentLength() - 1; // richtext->ApplyParaFormatL( paraFormat.get(), paraMask, last, 1); // { // // TFontSpec fontspec = LatinBold19()->FontSpecInTwips(); // TCharFormat charFormat; // //fontspec.iTypeface.iName, // // fontspec.iHeight ); // TCharFormatMask charFormatMask; // // // Set text color // charFormat.iFontPresentation.iTextColor = KRgbBlue; // // // Activate the attributes // charFormatMask.SetAttrib(EAttColor); // // charFormatMask.SetAttrib(EAttFontTypeface); // // charFormatMask.SetAttrib(EAttFontHeight); // // Apply font to the whole text // // iEditor->SelectAllL(); // iEditor->SelectAllL(); // iEditor->ApplyCharFormatL(charFormat, charFormatMask); // iEditor->ClearSelectionL(); // } { CGlobalText *text=iEditor->GlobalText(); TCharFormat cf; TCharFormatMask cfm; text->GetCharFormat(cf,cfm,0,0); cf.iFontPresentation.iTextColor=TRgb(0); cfm.SetAttrib(EAttColor); CGraphicsDevice *dev=SystemGc().Device(); auto_ptr<CDesCArrayFlat> fontnames(new(ELeave)CDesCArrayFlat(5)); FontUtils::GetAvailableFontsL(*dev,*fontnames,EGulAllFonts); for(TInt i=0;i<fontnames->Count();i++) { cf.iFontSpec.iTypeface.iName=_L("LatinPlain12"); cfm.SetAttrib(EAttFontTypeface); text->ApplyCharFormatL(cf,cfm,text->DocumentLength(),0); text->InsertL(text->DocumentLength(),(*fontnames)[i]); text->InsertL(text->DocumentLength(),CPlainText::EParagraphDelimiter); cf.iFontSpec.iTypeface.iName=(*fontnames)[i]; cfm.SetAttrib(EAttFontTypeface); text->ApplyCharFormatL(cf,cfm,text->DocumentLength(),0); text->InsertL(text->DocumentLength(),(*fontnames)[i]); text->InsertL(text->DocumentLength(),CPlainText::EParagraphDelimiter); } } // TCharFormatMask charFormatMask; // _LIT(KFontArial,"Arial"); // TFontSpec MyeFontSpec (KFontArial, 8*10); // MyeFontSpec.iTypeface.SetIsProportional(ETrue); // TCharFormat charFormat(MyeFontSpec.iTypeface.iName, MyeFontSpec.iHeight); // charFormat.iFontPresentation.iTextColor=KRgbRed; // charFormatMask.SetAttrib(EAttColor ); // CCharFormatLayer* iCharform = CEikonEnv::NewDefaultCharFormatLayerL(); // iCharform->Sense( charFormat, charFormatMask ); // iCharform->SetL( charFormat, charFormatMask ); // iEditor->SetCharFormatLayer(iCharform); // } // // TFontSpec fontSpec(_L("Roman"),2); // // TCharFormat charFormat(fontSpec.iTypeface.iName, fontSpec.iHeight); // // richtext->ApplyCharFormatL(charFormat, charFormatMask, 0, 5); // { // const CFont* font = CEikonEnv::Static()->NormalFont(); // TFontSpec fontspec = font->FontSpecInTwips(); // TCharFormat cformat( fontspec.iTypeface.iName, fontspec.iHeight ); // TCharFormatMask cmask; // cmask.SetAttrib(EAttFontTypeface); // cmask.SetAttrib(EAttFontHeight); // SetSelectionL(0, 5); // iEditor->ApplyCharFormatL(cformat, cmask); // } // { // TInt len = richtext->DocumentLength(); // SetSelectionL(len - 32, len); // // const CFont* font = CEikonEnv::Static()->NormalFont(); // // TFontSpec fontspec = font->FontSpecInTwips(); // // fontspec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); // // CFont* myFont = NULL; // // User::LeaveIfError( iEikonEnv->ScreenDevice()->GetNearestFontInPixels(myFont,fontspec) ); // const CFont* font = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont); // TFontSpec myFontSpec = font->FontSpecInTwips(); // TCharFormat cformat( myFontSpec.iTypeface.iName, myFontSpec.iHeight ); // cformat.iFontPresentation.iTextColor = KRgbBlack; // TCharFormatMask cmask; // cmask.SetAll(); // iEditor->ApplyCharFormatL(cformat, cmask); // } // SetSelectionL(0,5); // SetColorL(KRgbBlue); iEditor->ActivateL(); SetRect(aRect); // Activate the window, which makes it ready to be drawn ActivateL(); }
/** * Constructs the text control with the complex fonts. */ void CComplexFontsControl::ConstructL(const CCoeControl* aParent) { User::LeaveIfError(iSemaphore.OpenGlobal(KSemaphore)); if (aParent) { SetContainerWindowL(*aParent); } else { CreateWindowL(); } // Create text object, text view and layout. iParaFormatLayer = CParaFormatLayer::NewL(); iCharFormatLayer = CCharFormatLayer::NewL(); // Create an empty rich text object iRichText = CRichText::NewL(iParaFormatLayer, iCharFormatLayer); iScreen = new(ELeave) CWsScreenDevice(ControlEnv()->WsSession()); User::LeaveIfError(iScreen->Construct()); // default screen used TPixelsAndRotation pixelsAndRotation; iScreen->GetDefaultScreenSizeAndRotation(pixelsAndRotation); // Create the text layout, (required by text view), // with the text object and a wrap width (=width of view rect) iLayout = CTextLayout::NewL(iRichText,pixelsAndRotation.iPixelSize.iWidth); // Create text view iTextView = CTextView::NewL(iLayout, pixelsAndRotation.iPixelSize, iScreen, iScreen, &Window(), 0, // no window group &iCoeEnv->WsSession()); // new view SetRect(TRect(TPoint(0, 0), pixelsAndRotation.iPixelSize)); // load up text iRichText->InsertL(0, KComplexFontsText); // break up into paragraphs for CRichText by replacing \n characters in original text // with CEditableText::EParagraphDelimiter TPtrC complexFontsTextPtr(KComplexFontsText); TInt eos = complexFontsTextPtr.Length(); for (TInt paragraphBreakLocation = 0; paragraphBreakLocation < eos; paragraphBreakLocation++) { if (complexFontsTextPtr[paragraphBreakLocation] == '\n') { iRichText->DeleteL(paragraphBreakLocation, 1); iRichText->InsertL(paragraphBreakLocation, CEditableText::EParagraphDelimiter); } } TCharFormat charFormat; TCharFormatMask charFormatMask; // format the first paragraph "Class RWindow" as orange and a bit bigger than the body charFormat.iFontPresentation.iTextColor= TLogicalRgb(TRgb(0x0099ff)); charFormatMask.SetAttrib(EAttColor); charFormat.iFontSpec.iHeight = KHeaderFontSize; charFormatMask.SetAttrib(EAttFontHeight); TInt headerLength = 0; TInt headerStart = iRichText->CharPosOfParagraph(headerLength, KHeadingParagraph); iRichText->ApplyCharFormatL(charFormat, charFormatMask, headerStart, headerLength); charFormatMask.ClearAll(); // format "Class" as Sans Serif charFormat.iFontSpec.iTypeface.iName = KNokiaSeries60Font; charFormatMask.SetAttrib(EAttFontTypeface); iRichText->ApplyCharFormatL(charFormat, charFormatMask, headerStart, 5); charFormatMask.ClearAll(); // make the rest of the text smaller charFormat.iFontSpec.iHeight = KBodyFontSize; charFormatMask.SetAttrib(EAttFontHeight); TInt textLength = iRichText->DocumentLength(); iRichText->ApplyCharFormatL(charFormat, charFormatMask, headerLength, textLength - headerLength); charFormatMask.ClearAll(); TParaFormatMask paraFormatMask; // crunch main body a bit closer together to show more on the little screen // and indent left margin iParaFormat.iLineSpacingInTwips = KBodyLineSpacing; paraFormatMask.SetAttrib(EAttLineSpacing); iParaFormat.iLineSpacingControl = CParaFormat::ELineSpacingExactlyInPixels; paraFormatMask.SetAttrib(EAttLineSpacingControl); iParaFormat.iLeftMarginInTwips = KBodyIndent; paraFormatMask.SetAttrib(EAttLeftMargin); iRichText->ApplyParaFormatL(&iParaFormat, paraFormatMask, headerLength, textLength - headerLength); paraFormatMask.ClearAll(); TInt length = 0; TInt start = 0; // put a grey background on "class RWindow : public RDrawableWindow;" start = iRichText->CharPosOfParagraph(length, KClassParagraph); iParaFormat.iFillColor = TLogicalRgb(TRgb(0xdddddd)); paraFormatMask.SetAttrib(EAttFillColor); iRichText->ApplyParaFormatL(&iParaFormat, paraFormatMask, start, length); paraFormatMask.ClearAll(); // make "Description" and "Derivation" subheadings bold charFormat.iFontSpec.iFontStyle.SetStrokeWeight(EStrokeWeightBold); charFormatMask.SetAttrib(EAttFontStrokeWeight); start = iRichText->CharPosOfParagraph(length, KDescriptionHeading); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start, length); start = iRichText->CharPosOfParagraph(length, KDerivationHeading); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start, length); charFormatMask.ClearAll(); // all the paragraphs between and including "Description" and "Derivation" are in sans serif // (the default CRichText font is serif) TInt paragraphNumber = 0; charFormat.iFontSpec.iTypeface.iName = KNokiaSeries60Font; charFormatMask.SetAttrib(EAttFontTypeface); for (paragraphNumber = KDescriptionHeading; paragraphNumber <= KDerivationHeading; paragraphNumber++) { start = iRichText->CharPosOfParagraph(length, paragraphNumber); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start, length); } charFormatMask.ClearAll(); // for each line in the "Derivation" section // progressively indent left margin // make class name blue underlined (it starts two characters after the // beginning of each paragraph and goes to the space before the '-') // make descriptive text sans serif (from the '-' to the end of the paragraph) paraFormatMask.SetAttrib(EAttLeftMargin); charFormat.iFontPresentation.iTextColor= TLogicalRgb(TRgb(0xA27316)); charFormat.iFontPresentation.iUnderline = EUnderlineOn; for (paragraphNumber = KFirstDerivation; paragraphNumber <= KLastDerivation; paragraphNumber++) { iParaFormat.iLeftMarginInTwips = (paragraphNumber - KFirstDerivation + 2)*KBodyIndent; start = iRichText->CharPosOfParagraph(length, paragraphNumber); iRichText->ApplyParaFormatL(&iParaFormat, paraFormatMask, start, length); TInt dash = 0; for (dash = start; dash < start + length; dash++) { if (complexFontsTextPtr[dash] == '-') { break; } } charFormatMask.SetAttrib(EAttColor); charFormatMask.SetAttrib(EAttFontUnderline); TInt classNameLength = (dash - 1) - (start + 2); iRichText->ApplyCharFormatL(charFormat, charFormatMask, start + 2, classNameLength); charFormatMask.ClearAll(); charFormatMask.SetAttrib(EAttFontTypeface); TInt descriptionLength = length - classNameLength - 4; iRichText->ApplyCharFormatL(charFormat, charFormatMask, dash, descriptionLength); charFormatMask.ClearAll(); } paraFormatMask.ClearAll(); if (!aParent) { ActivateL(); } }
void CWordStyleGallery::PostLayoutDynInitL() { DoCalcColumnWidthsL(); iStyleDescriptor=iCoeEnv->ReadDesCArrayResourceL(R_WORD_STYLE_GALLERY_DESCRIPTIONS); // iCoeEnv->ReadResource(iNormalName , R_WORD_NORMAL); iCoeEnv->ReadResource(iHotKey , R_WORD_HOTKEY); TInt pos=0; iStyleNameList->Reset(); iStyleNameList->AppendL(iNormalName); TBool styleChange; TInt keycount=iData.iHotKeyList.Count(); const CParaFormatLayer* style=iData.iText.ParagraphStyle(styleChange,iData.iSelection.LowerPos(),iData.iSelection.Length()); TInt count=iData.iStyleList.Count(); for (TInt i=0;i<count;i++) iStyleNameList->AppendL(iData.iStyleList.At(i).iStyle->iName); iStyleNameList->Sort(); TUid id=style->Type(); for (TInt k=0;k<iStyleNameList->Count();k++) { if (id==KNormalParagraphStyleUid) { if (iNormalName==(*iStyleNameList)[k]) { pos=k; break; } } else if(((CParagraphStyle*)style)->iName==(*iStyleNameList)[k]) { pos=k; break; } } // Make sure all styles have a hot key, even if it's not assigned // since any pasted styles will be missing hot key info if (keycount < count) { TInt idx; TInt keysToAdd = count-keycount; for (idx=0; idx<keysToAdd; idx++) iData.iHotKeyList.AppendL(KNoHotkey); } else if ( keycount > count ) { //too many, they should be the same so remove extras TInt idx; for (idx=keycount-1; idx>=count; idx--) iData.iHotKeyList.Delete(idx); } MergeArraysL(); ListBox()->CreateScrollBarFrameL(); ListBox()->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); ListBox()->Model()->SetItemTextArray(iStyleNameKeyList); ListBox()->Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); ListBox()->HandleItemAdditionL(); SetListBoxCurrentItem(EWordCidStyleNameList,pos); SetDeleteButton(); CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo); CCharFormatLayer* clayer=CONST_CAST(CCharFormatLayer*,(edwin->GlobalText())->GlobalCharFormatLayer()); CParaFormatLayer* player=CONST_CAST(CParaFormatLayer*,(edwin->GlobalText())->GlobalParaFormatLayer()); TCharFormatMask defaultCharFormatMask; TCharFormat defaultCharFormat; TInt fontAttributes=TTypeface::EProportional; defaultCharFormat.iFontSpec.iTypeface.SetAttributes(fontAttributes); defaultCharFormat.iFontSpec.iHeight=160; defaultCharFormatMask.SetAttrib(EAttFontHeight); defaultCharFormatMask.SetAttrib(EAttFontTypeface); clayer->SetL(defaultCharFormat,defaultCharFormatMask); // CParaFormat pFormat; TParaFormatMask pMask; pFormat.iLineSpacingInTwips=160; pMask.SetAttrib(EAttLineSpacing); player->SetL(&pFormat,pMask); // StyleDescriptionL(pos); SetLineNonFocusing(EWordCidStyleInfo); // }
void CWordStyleGallery::FillBufferL(const CParaFormatLayer& aParaFormatLayer) { CEikGlobalTextEditor* edwin=(CEikGlobalTextEditor*)Control(EWordCidStyleInfo); TCharFormat charFormat; TCharFormatMask charMask; CParaFormat* paraFormat=CParaFormat::NewLC(); TParaFormatMask paraMask; // // iCurrentDescription=HBufC::NewL(KDescriptionGranularity); TPtr buf=iCurrentDescription->Des(); TBool isNormalStyle=(aParaFormatLayer.Type()==KNormalParagraphStyleUid); if (!isNormalStyle) { const CParagraphStyle* flayer=REINTERPRET_CAST(const CParagraphStyle*,aParaFormatLayer.SenseBase()); TUid type=flayer->Type(); if (type==KNormalParagraphStyleUid) buf.Append(iNormalName); else buf.Append(flayer->iName); buf.Append('+'); } // if (isNormalStyle) iData.iText.GlobalCharFormatLayer()->Sense(charFormat,charMask); else REINTERPRET_CAST(const CParagraphStyle&,aParaFormatLayer).CharFormatLayer()->Sense(charFormat,charMask); aParaFormatLayer.SenseL(paraFormat,paraMask); // if (!charMask.IsNull()) { if (charMask.AttribIsSet(EAttFontTypeface)) DoAppendDescriptionL(charFormat.iFontSpec.iTypeface.iName); if (charMask.AttribIsSet(EAttFontHeight)) { TInt height=charFormat.iFontSpec.iHeight; height=(height+10)/20; TBuf<20> num; num.Num(height); TBuf<10> unit; iCoeEnv->ReadResource(unit,R_WORD_FONT_UNITS); num.Append(unit); DoAppendDescriptionL(num); } if (charMask.AttribIsSet(EAttFontPosture)) { if (charFormat.iFontSpec.iFontStyle.Posture()==EPostureItalic) DoAppendDescriptionL((*iStyleDescriptor)[EDesItalic]); } if (charMask.AttribIsSet(EAttFontStrokeWeight)) { if (charFormat.iFontSpec.iFontStyle.StrokeWeight()==EStrokeWeightBold) DoAppendDescriptionL((*iStyleDescriptor)[EDesBold]); } if (charMask.AttribIsSet(EAttFontPrintPos)) { TFontPrintPosition pos=charFormat.iFontSpec.iFontStyle.PrintPosition(); switch(pos) { case EPrintPosSuperscript: DoAppendDescriptionL((*iStyleDescriptor)[EDesSuperscript]); break; case EPrintPosSubscript: DoAppendDescriptionL((*iStyleDescriptor)[EDesSubscript]); break; default: break; } } if (charMask.AttribIsSet(EAttFontUnderline)) { if (charFormat.iFontPresentation.iUnderline==EUnderlineOn) DoAppendDescriptionL((*iStyleDescriptor)[EDesUnderline]); } if (charMask.AttribIsSet(EAttFontStrikethrough)) { if (charFormat.iFontPresentation.iStrikethrough==EStrikethroughOn) DoAppendDescriptionL((*iStyleDescriptor)[EDesStrikethrough]); } } if (!paraMask.IsNull()) { AppendDescriptionL(EAttLeftMargin,paraMask); AppendDescriptionL(EAttRightMargin,paraMask); AppendDescriptionL(EAttIndent,paraMask); if (paraMask.AttribIsSet(EAttAlignment)) DoAppendDescriptionL((*iStyleDescriptor)[EDesLeftAlign+paraFormat->iHorizontalAlignment]); AppendDescriptionL(EAttLineSpacing,paraMask); AppendDescriptionL(EAttSpaceBefore,paraMask); AppendDescriptionL(EAttSpaceAfter,paraMask); AppendDescriptionL(EAttKeepTogether,paraMask); AppendDescriptionL(EAttKeepWithNext,paraMask); AppendDescriptionL(EAttStartNewPage,paraMask); AppendDescriptionL(EAttWidowOrphan,paraMask); AppendDescriptionL(EAttBorderMargin,paraMask); AppendDescriptionL(EAttTopBorder,*paraFormat,paraMask); AppendDescriptionL(EAttBottomBorder,*paraFormat,paraMask); AppendDescriptionL(EAttLeftBorder,*paraFormat,paraMask); AppendDescriptionL(EAttRightBorder,*paraFormat,paraMask); AppendDescriptionL(EAttBullet,paraMask); AppendDescriptionL(EAttTabStop,*paraFormat,paraMask); } CleanupStack::PopAndDestroy(); // paraFormat edwin->SetTextL(iCurrentDescription); delete iCurrentDescription; iCurrentDescription=NULL; DrawEdwinL(); }
EXPORT_C TBandTestAction::TTestResult TReformatText::ExecuteL(TInt aDocPos, TInt aEditLength) { _LIT(KDes,"Reformat Text Action %d at pos %d and length %d."); TBuf<128> actionDesc; actionDesc.Format(KDes,iReformatAction,aDocPos,aEditLength); if ((aDocPos + aEditLength) > iTextViews.TmLayoutUnderTest().EndChar()) { return ENotExecuted; } TCharFormat charFormat; TCharFormatMask charFormatMask; switch (iReformatAction) { case EMakeBold: { TTmCharFormatLayer boldFormat; boldFormat.iMask.iFlags = 0; boldFormat.iMask.Set(TTmCharFormatMask::EBold); boldFormat.iFormat.iFontSpec.SetBold(ETrue); boldFormat.iFormat.GetTCharFormat(charFormat); boldFormat.iMask.GetTCharFormatMask(charFormatMask); break; } case EIncreaseFontSize: { CFbsFont* bigFont; TTmCharFormat charFormatBig; TFontSpec fsBig(_L("Arial"),24); TInt error = iDevice.GetNearestFontInPixels((CFont*&)bigFont,fsBig); if (error) User::Panic(_L("Could not create 24-pixel Arial"),error); charFormatBig.iFontSpec = bigFont->FontSpecInTwips(); charFormatBig.GetTCharFormat(charFormat); charFormatMask.SetAll(); iDevice.ReleaseFont(bigFont); break; } case EDecreaseFontSize: { CFbsFont* smallFont; TTmCharFormat charFormatSmall; TFontSpec fsSmall(_L("Arial"),8); TInt error = iDevice.GetNearestFontInPixels((CFont*&)smallFont,fsSmall); if (error) User::Panic(_L("Could not create 8-pixel Arial"),error); charFormatSmall.iFontSpec = smallFont->FontSpecInTwips(); charFormatSmall.GetTCharFormat(charFormat); charFormatMask.SetAll(); iDevice.ReleaseFont(smallFont); break; } case EChangeFont: { CFbsFont* newCourierFont; TTmCharFormat charFormatNewCourier; TFontSpec fsNewCourier(_L("New Courier"),17); //we should calculate this 17 from the current height, but I can only find that in //twips not pixels, and the conversion doesn't seem any too successful TInt error = iDevice.GetNearestFontInPixels((CFont*&)newCourierFont,fsNewCourier); if (error) User::Panic(_L("Could not create 17-pixel New Courier"),error); charFormatNewCourier.iFontSpec = newCourierFont->FontSpecInTwips(); charFormatNewCourier.GetTCharFormat(charFormat); charFormatMask.SetAll(); iDevice.ReleaseFont(newCourierFont); break; } default: return ENotExecuted; } iRichText.ApplyCharFormatL(charFormat, charFormatMask, aDocPos, aEditLength); TCursorSelection cursor(aDocPos, aDocPos+aEditLength); iTextViews.HandleFormatChangeL(cursor); return iValidator.ValidateL(actionDesc)? EPassed : EFailed; }