⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editorcontainer.cpp

📁 symbian socket development
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	
	}
				
/**
 *	Draw container contents.
 */				
void CEditorContainer::Draw( const TRect& aRect ) const
	{
	// [[[ begin generated region: do not modify [Generated Contents]
	CWindowGc& gc = SystemGc();
	gc.Clear( aRect );
	
	// ]]] end generated region [Generated Contents]
	
	}
				
void CEditorContainer::SetRichText1FormattingL()
	{
	// [[[ begin generated region: do not modify [Generated GlobalText formatting]
	
	// ]]] end generated region [Generated GlobalText formatting]
	
	}
void CEditorContainer::SetFont(const CFont* cfont)
	{
		/*
	TCursorSelection cs = iRichText1->Selection();
	
	SetSelectionL(cs.iCursorPos, cs.iAnchorPos-1);
	*/

	TFontSpec fontspec = cfont->FontSpecInTwips();
	TCharFormat charFormat( fontspec.iTypeface.iName, fontspec.iHeight );
	TCharFormatMask charFormatMask;
	
	charFormatMask.SetAttrib(EAttFontTypeface);
	charFormatMask.SetAttrib(EAttFontHeight);
	iRichText1->ApplyCharFormatL(charFormat, charFormatMask);
	
	//Echo(R_TYPE_DIALOG_TBUF_INDICATOR_FONT);

	}

void CEditorContainer::SetCharacterBIUAttribL(CEikGlobalTextEditor::TFontStyleFlags aFontFlags)
	{
	iRtEd->BoldItalicUnderlineEventL(aFontFlags);
	//Echo(R_TYPE_DIALOG_TBUF_INDICATOR_CHARACTER_FORMAT);
	}

void CEditorContainer::SetColor(TRgb aColor)
	{
	TCharFormat charFormat;
	TCharFormatMask charFormatMask;

	charFormat.iFontPresentation.iTextColor = aColor;
	charFormatMask.SetAttrib(EAttColor);
	iRichText1->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 CEditorContainer::Echo(TInt aMessage)
	{
		TBuf<32> buf;
		CEikonEnv::Static()->ReadResource(buf, aMessage);
		//iLabel1->SetTextL(buf);
	}

void CEditorContainer::DrawPictureL(TInt index)
	{
	InsertMyPictureL(index);
	//InsertMyPicture1L(KRightImagePositionInTheText);
	DrawNow();
	}

void CEditorContainer::InsertMyPictureL(TInt index/*aPos*/)
	{
//	CMyPicture* picture;
////	// Create a CPicture derived class which will draw our image, depending this Size
//	picture = new( ELeave )CMyPicture(TSize(KKImageWidth,KImageHeight),
//		*(iBitmap->At(iBitmap->Count()-1)/*process the last item of iBitmap*/));
//	CleanupStack::PushL(picture);
////	// Prepare the Picture header, which will be instered into the Richtext
//	TPictureHeader header;
//	header.iPicture =TSwizzle<CPicture>(picture);
//	//iRtEd->RichText()->InsertL( aPos,header); 
//	iRichText1->RichText()->InsertL(aPos, header);
//		CleanupStack::Pop(); // picture - Richtext take the ownership 
	
	//TInt index = 1;
	CGulIcon *icon = iconArray->At(index);
	CMyPicture* picture;
		
		// Create a CPicture derived class which will draw our image, depending this Size
		picture = new( ELeave )CMyPicture(TSize(100, 100), *icon->Bitmap()); /*process the last item of iBitmap*/
		CleanupStack::PushL(picture);
		// Prepare the Picture header, which will be instered into the Richtext
		TPictureHeader header;
		header.iPicture =TSwizzle<CPicture>(picture);
		TInt aPos = iRichText1->CursorPos();
		iRichText1->RichText()->InsertL( aPos, header); 
		DrawNow();
		iRichText1->SetCursorPosL(aPos+1, EFalse);
		CleanupStack::Pop(); // picture - Richtext take the ow
	}

void CEditorContainer::InsertMyPicture1L(TInt aPos)
	{
//	CMyPicture* picture;
////	// Create a CPicture derived class which will draw our image, depending this Size
//	picture = new( ELeave )CMyPicture(TSize(KKImageWidth,KImageHeight),
//		*(iBitmap->At(iBitmap->Count()-2)/*process the last item of iBitmap*/));
//	CleanupStack::PushL(picture);
////	// Prepare the Picture header, which will be instered into the Richtext
//	TPictureHeader header;
//	header.iPicture =TSwizzle<CPicture>(picture);
//	//iRtEd->RichText()->InsertL( aPos,header); 
//	TInt CursorPosition = iRichText1->CursorPos();
//	iRichText1->RichText()->InsertL(CursorPosition, header);
//	iRichText1->SetCursorPosL(CursorPosition+1, EFalse);
//	DrawNow();	
//	CleanupStack::Pop(); // picture - Richtext take the ownership 
		
//	CMyPicture* picture;
//	picture = new( ELeave )CMyPicture(TSize(KKImageWidth,KImageHeight), *myBitmap);
//	CleanupStack::PushL(picture);
//	TPictureHeader header;
//	header.iPicture =TSwizzle<CPicture>(picture);
//	TInt CursorPosition = iRichText1->CursorPos();
//	iRichText1->RichText()->InsertL(CursorPosition, header);
//	iRichText1->SetCursorPosL(CursorPosition+1, EFalse);
//	
//	DrawNow();
//	CleanupStack::Pop(); // picture - Richtext take the ownership 
	}



void CEditorContainer::PrepareBitmapL()
	{
//	#ifndef __SERIES60_3X__
//	TFileName name(KImageBitmapFile);
//	CompleteWithAppPath( name );
//	// windows build wants to install apps on rom drive ( "z:\" )
//	// but we want the data from "c:\" instead
//	
//	#ifdef __WINS__
//	name[ 0 ] = 'C';
//	#endif
//
//    #else // 3rd ed

//    RFs fsSession;
//    User::LeaveIfError(fsSession.Connect());
//    //CleanupClosePushL( fsSession );
//    TFileName name,name1;
//    fsSession.PrivatePath( name );
//    fsSession.PrivatePath(name1);
//    name.Append( KImageBitmapFile );
//    name1.Append( KImageBitmapFile1 );
//    User::InfoPrint(name1);
//    User::InfoPrint(name);
    
//	#ifndef __WINS__
//    // insert the drive to the private path
//    TParsePtrC parse(
//        (CEikonEnv::Static()->EikAppUi()->Application())->AppFullName() );
//    name.Insert( 0, parse.Drive() );
//    
//    #endif

//	#endif
    
	// Create and Load the Bitmap
//	CFbsBitmap* bitmap = new( ELeave )CFbsBitmap;
//	CleanupStack::PushL(bitmap);
//	User::LeaveIfError(bitmap->Load(name ,0));
//	
//	
//	//we have to free the memory at the Destructor() -> store the bitmap memory address
//	iBitmap->AppendL(bitmap);
//
//	CleanupStack::Pop(); //bitmap - container free bitmap at the destructor
//	  CArrayPtr< CGulIcon >* icons = new(ELeave) CAknIconArray(1);
//	  CleanupStack::PushL( icons );
	
	
	 
	 
	 CFbsBitmap* addressIcon = NULL;
	 CFbsBitmap* addressIconMask = NULL;
	 CFbsBitmap* emailIcon = NULL;
	 CFbsBitmap* emailIconMask = NULL;
	 CFbsBitmap* faxIcon = NULL;
	 CFbsBitmap* faxIconMask = NULL;

	
//	CFbsBitmap* bitmap;
//	CFbsBitmap* mask;
//	
//	bitmap = iEikonEnv->CreateBitmapL(KImageBitmapFile, i);
//	CleanupStack::PushL( bitmap);
//	mask = iEikonEnv->CreateBitmapL(KImageBitmapFile, i);
//	CleanupStack::PushL( mask); 
//	
//	icons->AppendL( CGulIcon::NewL( bitmap, mask ) );
//
//	 CleanupStack::Pop(2); // bitmap, mask 
	 
	 for(TInt i=0; i<3; i++)
	    	{
	 addressIcon = iEikonEnv->CreateBitmapL(KImageBitmapFile, i);
				CleanupStack::PushL( addressIcon );
				// Load the mask for mail icon 
				addressIconMask = iEikonEnv->CreateBitmapL(KImageBitmapFile, i);
				CleanupStack::PushL( addressIconMask ); 
	    
		CGulIcon* addressListIcon = CGulIcon::NewL( addressIcon, addressIconMask );

	    CleanupStack::Pop( 2 ); // addressIcon, addressIconMask    

	    CleanupStack::PushL( addressListIcon );

	    iconArray->AppendL( addressListIcon );
	    CleanupStack::Pop();
		}

	
//	CFbsBitmap* bitmap1 = new( ELeave )CFbsBitmap;
//		CleanupStack::PushL(bitmap1);
//		User::LeaveIfError(bitmap1->Load(name1));
//		
//		
//		//we have to free the memory at the Destructor() -> store the bitmap memory address
//		iBitmap->AppendL(bitmap1);
//
//		CleanupStack::Pop(); //bitmap - container free bitmap at the destructor
//	#ifdef __SERIES60_3X__
//    CleanupStack::PopAndDestroy(1, &fsSession);
//    #endif
	// last item in iBitmap array is ready to Insert
	}

void CEditorContainer::Prepare()
	{

	// Lower Case 
	iRichText1->SetAknEditorCase(EAknEditorLowerCase);
	// Fixed case
	
	iRichText1->SetAknEditorFlags
		(
		EAknEditorFlagFixedCase| //Set up the Allowed Cases
		EAknEditorFlagEnableScrollBars // Set up the scroller
		);
	}

void CEditorContainer::SetupL()
	{
    // One way to remove the selection
	//iRtEd->ClearSelectionL();
	
	// Copy-Paste Support is allowed in Edwin but we can disable
	// to do that uncomment the following line
	//iRtEd->EnableCcpuSupportL(EFalse);
	iRichText1->EnableCcpuSupportL(ETrue);
	// Another way to remove the selection.
	iRichText1->SetCursorPosL(0, EFalse);
	
	iRichText1->UpdateScrollBarsL();
	SizeChanged();
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -