Exemplo n.º 1
0
Arquivo: Cell.cpp Projeto: BBkBlade/e
void DiffLineCell::CalcSubCells(const wxString& text, const wxColour& fc, const wxColour& bc) {
	unsigned int wordstart = 0;
	unsigned int char_id = 0;

	for(char_id = 0; char_id < text.length(); ++char_id) {
		if (line_width < width) {
			if (text[char_id] == '\n') {
				if (wordstart < char_id) {
					wxString word = text.substr(wordstart, char_id-wordstart);
					WordCell *newcell = new WordCell(dc, word);
					newcell->SetStyle(fc, bc);
					AddSubCell(newcell);
				}
				NewlineImageCell *newcell = new NewlineImageCell(dc); // NewlineMarker
				newcell->SetStyle(fc, bc);
				AddSubCell(newcell);
				wordstart = char_id + 1;
			}
			else if (text[char_id] != ' ') {
				if (text[char_id] == '\t') {
					if (wordstart < char_id) {
						wxString word = text.substr(wordstart, char_id-wordstart);
						WordCell *newcell = new WordCell(dc, word);
						newcell->SetStyle(fc, bc);
						AddSubCell(newcell);
					}
					TabImageCell *newcell = new TabImageCell(dc); // TabMarker
					newcell->SetStyle(fc, bc);
					AddSubCell(newcell);
					wordstart = char_id + 1;
				}
				else if (char_id && (text[char_id-1] == ' ' || text[char_id-1] == '-')) {
					// End of word-cell reached
					wxString word = text.substr(wordstart, char_id-wordstart);
					WordCell *newcell = new WordCell(dc, word);
					newcell->SetStyle(fc, bc);
					AddSubCell(newcell);
					wordstart = char_id;
				}
			}
		}
	}

	if (wordstart != text.size() && line_width < width) {
		// Add last word
		wxString word = text.substr(wordstart);
		WordCell *newcell = new WordCell(dc, word);
		newcell->SetStyle(fc, bc);
		AddSubCell(newcell);
		wordstart = char_id;
	}
}
void doublelinebox::CreateItemDrawerL(void)
{
	CALLSTACKITEM_N(_CL("doublelinebox"), _CL("CreateItemDrawerL"));

	itemd=COptionalFormattedCellListBoxData::NewL();

	CleanupStack::PushL(itemd);

	TMargins marg, marg2;
	marg.iBottom=marg.iTop=marg.iLeft=marg.iRight=0;
	marg2.iBottom=marg2.iTop=marg2.iRight=0;
	marg2.iLeft=2;

	TInt iBtCount=4;
	TInt iBtWidth=16;
	TInt iBtWidth2=20;

	//Name of contact
	AddSubCell(itemd, marg, TSize(176- 3*16-3, rowheight), TPoint(16, 0), 13, CGraphicsContext::ELeft);
	itemd->SetSubCellFontL(iCells-1, LatinBold12() );
	
	//Textual PresenceInfo
	TInt infoIndex=AddSubCell(itemd, marg2, TSize(176-3-iBtCount*iBtWidth-2*iBtWidth2, rowheight), TPoint(0, rowheight), 
		rowheight+13, CGraphicsContext::ELeft);

	// Contact Icon (type of number)
	AddSubCell(itemd, marg, TSize(16, rowheight), TPoint(0, 0), 16, CGraphicsContext::ECenter, ETrue);

	// Ringing volume
	AddSubCell(itemd, marg, TSize(16, rowheight), TPoint(144, 0), 16, CGraphicsContext::ECenter, ETrue);

	// Vibrator
	AddSubCell(itemd, marg, TSize(16, rowheight), TPoint(160, 0), 16, CGraphicsContext::ECenter, ETrue);

	// Calendar
	TInt cal=AddSubCell(itemd, marg, TSize(iBtWidth, rowheight), TPoint(134-4*iBtWidth, rowheight), 32, 
		CGraphicsContext::ECenter, ETrue, infoIndex);
#ifdef __WINS__
	TBuf<50> msg=_L("***calendar index: ");
	msg.AppendNum(cal);
	RDebug::Print(msg);
#endif

	// Desktop
	AddSubCell(itemd, marg, TSize(iBtWidth, rowheight), TPoint(134-3*iBtWidth, rowheight), 32, 
		CGraphicsContext::ECenter, ETrue, infoIndex);
	// Laptop
	AddSubCell(itemd, marg, TSize(iBtWidth, rowheight), TPoint(134-2*iBtWidth, rowheight), 32, CGraphicsContext::ECenter, 
		ETrue, infoIndex);
	// PDA
	AddSubCell(itemd, marg, TSize(iBtWidth, rowheight), TPoint(134-1*iBtWidth, rowheight), 32, CGraphicsContext::ECenter, 
		ETrue, infoIndex);

	// BT buddies
	AddSubCell(itemd, marg, TSize(iBtWidth2, rowheight), TPoint(134, rowheight), 32, CGraphicsContext::ECenter, 
		ETrue, infoIndex);

	// other phones
	AddSubCell(itemd, marg, TSize(iBtWidth2, rowheight), TPoint(154, rowheight), 32, CGraphicsContext::ECenter, 
		ETrue, infoIndex);

	//Marked or not
	AddSubCell(itemd, marg, TSize(14, rowheight), TPoint(160, 0), 16, CGraphicsContext::ECenter, ETrue);

	iItemDrawer=new (ELeave) drawer(iPresenceModel, LatinBold12(), 
		itemd, book, iLog, this);

	CleanupStack::Pop();	
}
void CContextMediaBox::LayoutSubcells()
{
	CEikonEnv* iEikEnv=CEikonEnv::Static();
	
	TFontSpec fontSpec = LatinPlain12()->FontSpecInTwips();
	fontSpec.iFontStyle.SetPosture(EPostureItalic );
	iEikEnv->ScreenDevice()->GetNearestFontInTwips(iLatinPlainItalic12, fontSpec);

	//Thumbnail (image size = 48*36)
	if (!iStandAlone) {
		TMargins no_marg, image_marg, text_marg, text_marg_2;
		
		no_marg.iBottom=no_marg.iTop=no_marg.iLeft=no_marg.iRight=0;
		
		image_marg.iTop = 5;
		image_marg.iLeft = 2;
		image_marg.iRight = 2;
		image_marg.iBottom=4;
		
		text_marg.iBottom=2;
		text_marg.iTop=0;
		text_marg.iLeft=2;
		text_marg.iRight=3;
		
		text_marg_2.iBottom=2;
		text_marg_2.iTop=0;
		text_marg_2.iLeft=0;
		text_marg_2.iRight=2;
		

	    // not supported for scalable layout
		AddSubCell(image_marg, TSize(52, 48), iEikEnv->DenseFont(), TPoint(0, 0),
			0, CGraphicsContext::ECenter, ETrue);

		AddSubCell(text_marg, TSize(104, 15), LatinPlain12(), TPoint(52, 0), 13);

		AddSubCell(text_marg, TSize(20, 15), LatinBold12(), TPoint(156, 0), 13,
			CGraphicsContext::ERight);


		//text line 1 box 1
		AddSubCell(text_marg_2, TSize(94, 16), iLatinPlainItalic12,
			TPoint(50, 18), 29, CGraphicsContext::ERight);

		//text line 1 box 2
		AddSubCell(text_marg_2, TSize(32, 16), iLatinPlainItalic12,
			TPoint(144, 18), 29, CGraphicsContext::ERight);

		//text line 2 box 1
		AddSubCell(text_marg_2, TSize(94, 14), iLatinPlainItalic12,
			TPoint(50, 33), 43, CGraphicsContext::ERight);

		//text line 2 box 2
		AddSubCell(text_marg_2, TSize(32, 14), iLatinPlainItalic12,
			TPoint(144, 33), 43, CGraphicsContext::ERight);
	}
	else 
		{
			TSize itemSize = View()->ItemSize();
			TJuikLayoutItem parent( TRect(TPoint(0,0), itemSize) );
			// Text
			{				
				TMargins marg = Juik::FromMargins8( Layout().GetLayoutItemL( LG_medialistbox, LI_medialistbox__name_margins ).Margins() );
				TJuikLayoutItem subL = parent.Combine( Layout().GetLayoutItemL( LG_medialistbox, LI_medialistbox__name ) );
				AddSubCell(marg, subL.Size(), subL.Font(), subL.Rect().iTl, subL.Baseline() );
			}

			// count
			{
				TMargins marg = Juik::FromMargins8( Layout().GetLayoutItemL( LG_medialistbox, LI_medialistbox__count_margins ).Margins() );
				TJuikLayoutItem subL = parent.Combine( Layout().GetLayoutItemL( LG_medialistbox, LI_medialistbox__count ) );
				AddSubCell(marg, subL.Size(), subL.Font(), subL.Rect().iTl, subL.Baseline(), CGraphicsContext::ERight );
			}
		}
}