当前位置: 首页>>代码示例>>C++>>正文


C++ TFont::Create方法代码示例

本文整理汇总了C++中TFont::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ TFont::Create方法的具体用法?C++ TFont::Create怎么用?C++ TFont::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TFont的用法示例。


在下文中一共展示了TFont::Create方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: _CreateFunctionButtons

/**
 * 创建功能按键
 *
 * \param pApp
 *
 * \return 
 */
Int32 TMainMenuForm::_CreateFunctionButtons(TApplication* pApp)
{
	Int32 bnRetCod = 0; 
	TRectangle obBtnRec(0,0,0,0); //初始(left, top, w, h)
	TFont tFont;	

	tFont.Create(FONT_BUTTON_CAPTION, FONT_BUTTON_CAPTION);
	
	//use to function buttons ID
	for(int i=0; i<ARR_SIZE(m_nFunMenuBtnID); i++)
	{
		m_nFunMenuBtnID[i] = 0;

		const TBitmap * pImgNormal = TResource::LoadConstBitmap(MainMenuItems[i].nNmIconID);
		const TBitmap * pImgDown = TResource::LoadConstBitmap(MainMenuItems[i].nHLIconID);
		obBtnRec.SetRect(FUNCTION_BUTTON_X + (FUNCTION_BUTTON_W *(i%3)) , FUNCTION_BUTTON_Y + (FUNCTION_BUTTON_H *(i/3)), FUNCTION_BUTTON_W, FUNCTION_BUTTON_H);
		TMaskButton* pFunMenuBtn =new TMaskButton;
		if(pFunMenuBtn->Create(this))
		{
			Int32 CaptionX = 0;
			TFont tFont;	

			tFont.Create(FONT_BUTTON_CAPTION, FONT_BUTTON_CAPTION);
			pFunMenuBtn->SetBounds(&obBtnRec); 	
			m_nFunMenuBtnID[i] = pFunMenuBtn->GetId();
			pFunMenuBtn->SetImage(pImgNormal,(FUNCTION_BUTTON_W-pImgNormal->GetWidth())/2,(FUNCTION_BUTTON_H-pImgNormal->GetHeight())/2 - 10); 
			pFunMenuBtn->SetSelImage(pImgDown,(FUNCTION_BUTTON_W-pImgDown->GetWidth())/2,(FUNCTION_BUTTON_H-pImgDown->GetHeight())/2 - 10);	
			if(TUString::StrLen(MainMenuItems[i].pszTitle) == 0)
			{
				CaptionX = (FUNCTION_BUTTON_W - GetShowAllStringWidth((TUChar *)TResource::LoadConstString(MainMenuItems[i].nStrID), tFont))/2;			
				pFunMenuBtn->SetCaption(TResource::LoadConstString(MainMenuItems[i].nStrID), CaptionX, FUNCTION_CAPTION_Y);
			}
			else
			{
				CaptionX = (FUNCTION_BUTTON_W - GetShowAllStringWidth((TUChar *)MainMenuItems[i].pszTitle, tFont))/2;			
				pFunMenuBtn->SetCaption(MainMenuItems[i].pszTitle, CaptionX, FUNCTION_CAPTION_Y);			
			}
			pFunMenuBtn->SetColor(RGB_COLOR_BLACK,RGB_COLOR_WHITE,RGB_COLOR_BLACK,RGB_COLOR_WHITE,RGB_COLOR_BLACK,RGB_COLOR_WHITE);
			pFunMenuBtn->SetFont(tFont);
			pFunMenuBtn->SetEnabled(TRUE);
		}
		else
		{
			bnRetCod ++;
		}
	}
			
	return bnRetCod;
}
开发者ID:pengjohn,项目名称:RenRen,代码行数:56,代码来源:RenRenForm_MainMenu.cpp

示例2: CtrlAddItemToCoolBarList_Lable

//添加Label控件到CoolBarList, 
// pszString必须是动态的(非Static)
// nWidth 为0 -- 自动长度
Int32 CtrlAddItemToCoolBarList_Lable(TWindow*pWin,  TBarListItem* pListItem, Coord nX, Coord nY, Coord nWidth, Int32 FontSize, TUChar* pszString, ColorRefType Color)
{
	TRectangle obBtnRec(0,0,0,0);
	Int32 nLabelNameId = pListItem->AddCtrl(CTL_CLASS_LABEL, 0, 0);
	TLabel* pLabelName = static_cast<TLabel*>(pWin->GetControlPtr(nLabelNameId));
	if(nWidth == 0)
	{
		nWidth = 80;
		obBtnRec.SetRect(nX, nY, nWidth, FontSize);
		pLabelName->SetBounds(&obBtnRec);
		pLabelName->SetAutoSize(TRUE);

		CtrlSetFont((TCtrl*)pLabelName, FontSize, Color);
		pLabelName->SetCaption(pszString,FALSE);
	}
	else
	{
		obBtnRec.SetRect(nX, nY, nWidth, FontSize+6);	//调整高度,防止字体底部被截断
		pLabelName->SetBounds(&obBtnRec);
		pLabelName->SetAutoSize(FALSE);
		pLabelName->SetScrollMode(lsmNone);

		TFont tFont;
		tFont.Create(FontSize, FontSize);
		ShowAsShort((TCtrl *)pLabelName, pszString, tFont);
		pLabelName->SetFont(tFont);
		pLabelName->SetColor(CTL_COLOR_TYPE_FORE, Color);
	}

	pLabelName->SetEnabled(FALSE);
	
	return nLabelNameId;
}
开发者ID:pengjohn,项目名称:kaixin,代码行数:36,代码来源:gui_common.cpp

示例3: CtrlAddItemToWin_Label

Int32 CtrlAddItemToWin_Label(TWindow*pWin, Coord nX, Coord nY, Coord nWidth, Int32 FontSize, TUChar* pszString, ColorRefType Color)
{
	TLabel* pLabel = new TLabel();
	Int32  nLabelID = 0;

	if(pLabel->Create(pWin))	
	{
		TRectangle obBtnRec(0,0,0,0);
		if(nWidth == 0)
		{
			nWidth = 80;
			obBtnRec.SetRect(nX, nY, nWidth, FontSize);
			pLabel->SetBounds(&obBtnRec);
			pLabel->SetAutoSize(TRUE);

			CtrlSetFont((TCtrl*)pLabel, FontSize, Color);
			pLabel->SetCaption(pszString,FALSE);
		}
		else
		{
			obBtnRec.SetRect(nX, nY, nWidth, FontSize);
			pLabel->SetBounds(&obBtnRec);
			pLabel->SetAutoSize(FALSE);
			pLabel->SetScrollMode(lsmNone);

			TFont tFont;
			tFont.Create(FontSize, FontSize);
			ShowAsShort((TCtrl *)pLabel, pszString, tFont);
			pLabel->SetFont(tFont);
			pLabel->SetColor(CTL_COLOR_TYPE_FORE, Color);
		}
	}
	return nLabelID;
}
开发者ID:pengjohn,项目名称:kaixin,代码行数:34,代码来源:gui_common.cpp

示例4: CtrlSetFont

//设置控件文本大小颜色
TFont CtrlSetFont(TCtrl *pCtrl, Int32 nFontSize, ColorRefType nColor)
{
	TFont tFont;
	tFont.Create(nFontSize, nFontSize);
	pCtrl->SetColor(CTL_COLOR_TYPE_FORE, nColor);
	return pCtrl->SetFont(tFont);
}
开发者ID:pengjohn,项目名称:kaixin,代码行数:8,代码来源:gui_common.cpp

示例5: SetAppTilte

//创建应用标题默认居中
//pApp --应用指针
//TitleStringResId --标题字串ID, 默认为0
//TitleString --标题字串,默认为空NULL
//color--标题颜色,默认为白:RGB_COLOR_WHITE
//nFontSize 字体大小
//返回控件ID
Int32 SetAppTilte(TWindow * pWindow, Int32 nTitleStringResId, TUChar* pTitleString, ColorRefType Color, Int32 nFontSize)
{
	Int32 m_TitleCtlID = 0;

	TCtrl *m_TitleContrl;
	TRectangle TitleRC(0,0,0,0);
	TRectangle WindowRC(0, 0, 0, 0);
	TFont tFont;
	Int32 nTitleWidth = 0;
	Boolean bNeedShort = FALSE;
	TUChar sTitleString[128] ={0};

	if(nTitleStringResId == 0)//说明传进的是字串
	{
		if(pTitleString)
		{
			TUString::StrNCopy(sTitleString, pTitleString, sizeof(sTitleString));
		}
	}
	else
	{
		TUString::StrNCopy(sTitleString, TResource::LoadConstString(nTitleStringResId), sizeof(sTitleString));
	}
	
	tFont.Create(nFontSize, nFontSize,  FONT_STYLE_BOLD);
	nTitleWidth = GetShowAllStringWidth(sTitleString,tFont);
	if(nTitleWidth > SCR_W - (TITLE_BUTTON_X + TITLE_BUTTON_W)*2 )
	{
		bNeedShort = TRUE;
		nTitleWidth = SCR_W - (TITLE_BUTTON_X + TITLE_BUTTON_W)*2 - 10;
	}
	
	pWindow->GetBounds(&WindowRC);	
	TitleRC.SetRect((WindowRC.Width()-nTitleWidth)/2, (TITLEBAR_H- nFontSize)/2, nTitleWidth, nFontSize);
	
	m_TitleContrl = new TLabel;
	
	if(m_TitleContrl->Create(pWindow))
	{		
		m_TitleContrl->SetBounds(&TitleRC);	
		m_TitleCtlID = m_TitleContrl->GetId();	

		m_TitleContrl->SetFont(tFont);
		m_TitleContrl->SetColor(CTL_COLOR_TYPE_FORE,Color);
		m_TitleContrl->SetEnabled(FALSE);
		m_TitleContrl->SetCaption(sTitleString,FALSE);
		if(bNeedShort)
			ShowAsShort(m_TitleContrl, sTitleString, tFont);
		m_TitleContrl->Show(TRUE);
	}

	return m_TitleCtlID;
}
开发者ID:pengjohn,项目名称:kaixin,代码行数:60,代码来源:gui_common.cpp

示例6: SetAppTitleButton

//设置应用标题栏按钮
Int32 SetAppTitleButton(TWindow * pWindow, Int32 nResId, int ButtonPosition)
{
	Int32 m_BtnID = 0;
	TButton *pBtn;
	TRectangle BtnRC_Left(TITLE_BUTTON_X, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H);	
	TRectangle BtnRC_Right(SCR_W-TITLE_BUTTON_X-TITLE_BUTTON_W, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H);
	TFont tFont;

	const TBitmap * pNormalBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_button53);
	const TBitmap * pOverBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_button53_over);

	if(TUString::StrLen(TResource::LoadConstString(nResId)) <= 2)
		tFont.Create(FONT_NORMAL, FONT_NORMAL, FONT_STYLE_BOLD);
	else
		tFont.Create(FONT_MIDDLE, FONT_MIDDLE, FONT_STYLE_BOLD);
	pBtn = new TButton;	
	if(pBtn->Create(pWindow))
	{		
		if(ButtonPosition == TITLE_BUTTON_LEFT)
			pBtn->SetBounds(&BtnRC_Left);	
		else
			pBtn->SetBounds(&BtnRC_Right);	
		m_BtnID = pBtn->GetId();	

		pBtn->SetFont(tFont);
		pBtn->SetColor(CTL_COLOR_TYPE_FORE,RGB_COLOR_WHITE);
		pBtn->SetColor(CTL_COLOR_TYPE_BACK,RGB_COLOR_WHITE);
		pBtn->SetColor(CTL_COLOR_TYPE_FOCUS_FORE,RGB_COLOR_WHITE);
		pBtn->SetColor(CTL_COLOR_TYPE_FOCUS_BACK,RGB_COLOR_WHITE);
		
		pBtn->SetCaption(TResource::LoadConstString(nResId),FALSE);
		pBtn->SetStyles(BTN_STYLES_GRAPGICS);
		pBtn->SetImage(pNormalBmp,0);
		pBtn->SetImage(pOverBmp,1);		
		pBtn->Show(TRUE);
	}

	return m_BtnID;
}
开发者ID:pengjohn,项目名称:kaixin,代码行数:40,代码来源:gui_common.cpp

示例7: GetShowAllStringWidthEx

Int32 GetShowAllStringWidthEx(TUChar* pCaptionString, Int32 FontSize)
{
	TFont objFontType;
	objFontType.Create(FontSize, FontSize);
	return GetShowAllStringWidth(pCaptionString, objFontType);
}
开发者ID:pengjohn,项目名称:kaixin,代码行数:6,代码来源:gui_common.cpp

示例8: CreateDetailItemControl

Int32 TCommentDetailForm::CreateDetailItemControl(Int32 itemIndex,Int32 itemHeight, TPanel *pTPanel, int ctrlGroupIndex)
{
	Int32 bnRetCod = 0;	
	TRectangle obBtnRec(100,50,150,30);	//初始(left, top, w, h)
	TFont tFont;

	Int32 nCtrlHeight = (itemIndex == 0)?0:(itemHeight*(ctrlGroupIndex)-20);

	TUChar pszNameString[32];
	TUChar pszDateTimeString[32];
	TUChar pszContentString[1024];
	TUChar pszTemp[32];

	memset(pszNameString, 0, sizeof(pszNameString));
	memset(pszDateTimeString, 0, sizeof(pszDateTimeString));
	memset(pszContentString, 0, sizeof(pszContentString));
	memset(pszTemp, 0, sizeof(pszTemp));


	if(m_pResponse == NULL) return  bnRetCod;


	Int32 Fuid = 0;
	TUChar TUCharFuid[32];
	TUString::StrUtf8ToStrUnicode(TUCharFuid,(const Char *)KaiXinUserInfo.uid);
	Fuid = TUString::StrAToI(TUCharFuid);
	if(m_pResponse->comments[itemIndex].fuid == Fuid)
	{
		TUString::StrCopy(pszNameString, TResource::LoadConstString(APP_KA_ID_STRING_Me));
	}
	else	
	{
		TUString::StrUtf8ToStrUnicode(pszNameString , (const Char *)m_pResponse->comments[itemIndex].fname);
	}

	if(itemIndex==0)
	{
		if(this->m_appCommentDetailType == ReceivedUserCommentDetail||this->m_appCommentDetailType == SentUserCommentDetail)
		{
			//TUString::StrUtf8ToStrUnicode(pszTemp , TResource::LoadConstString(APP_KA_ID_STRING_UserCommentIs));
			TUString::StrCat(pszNameString,TResource::LoadConstString(APP_KA_ID_STRING_UserCommentIs));										
		}
		else if(this->m_appCommentDetailType == FriendCommentDetail)
		{
			TUString::StrUtf8ToStrUnicode(pszTemp ,(const Char *)m_pResponse->title);
			TUString::StrCopy(pszNameString,pszTemp);
			//TUString::StrUtf8ToStrUnicode(pszTemp ,TResource::LoadConstString(APP_KA_ID_STRING_CommentIs));
			TUString::StrCat(pszNameString,TResource::LoadConstString(APP_KA_ID_STRING_CommentIs));						
		}
		else
		{
			TUString::StrUtf8ToStrUnicode(pszTemp ,(const Char *)m_pResponse->title);
			TUString::StrCat(pszNameString,pszTemp);
			//TUString::StrUtf8ToStrUnicode(pszTemp ,TResource::LoadConstString(APP_KA_ID_STRING_CommentIs));
			TUString::StrCat(pszNameString,TResource::LoadConstString(APP_KA_ID_STRING_CommentIs));						
		}
	}
	else
	{
		//TUString::StrUtf8ToStrUnicode(pszTemp , TResource::LoadConstString(APP_KA_ID_STRING_ReplyIs));
		TUString::StrCat(pszNameString,TResource::LoadConstString(APP_KA_ID_STRING_ReplyIs));										
	}




	//ctime
	//TUString::StrIToA(pszDateTimeString , m_pResponse->comments[itemIndex].ctime);

	//content
	TUString::StrUtf8ToStrUnicode( pszContentString , (const Char *)m_pResponse->comments[itemIndex].abscont ); 


	//const TBitmap * pImgBg = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_UserCommentReplyBG);
	//SetBackGroundBitmap(pImgBg,0);

	if(pTPanel)
	{		
		if(itemIndex == 0)//First item
		{

			m_obContrl[m_nCtlIDCount] =new TLabel;		
			obBtnRec.SetRect(5,5,60,12);
			if(m_obContrl[m_nCtlIDCount]->Create(pTPanel))
			{	
				TUChar pszMTypeString[32];

				m_obContrl[m_nCtlIDCount]->SetBounds(&obBtnRec);	
				m_iaCreateCtlID[m_nCtlIDCount] = m_obContrl[m_nCtlIDCount]->GetId();	

				TUString::StrUtf8ToStrUnicode(pszMTypeString , (const Char *)m_pResponse->mtype);					
				if( TUString::StrAToI(pszMTypeString) )//悄悄话//m_pResponse->comments[i].mtype 
				{
					m_obContrl[m_nCtlIDCount]->SetCaption(TUSTR_Kx_UserComment_QQH,FALSE);
				}
				else
				{
					m_obContrl[m_nCtlIDCount]->SetCaption(TUSTR_Kx_Profile_None_Title,FALSE);
				}
				//自适应文字大小
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:kaixin,代码行数:101,代码来源:KaiXinAPI_CommentDetail.cpp

示例9: _OnCommentDetailControl

Int32 TCommentDetailForm::_OnCommentDetailControl(TApplication * pApp)
{
	Int32 bnRetCod = 0;	
	TPanel* pTPanel;	
	TRectangle obBtnRec(100,50,150,30);	//初始(left, top, w, h)
	TFont tFont;

	Int32 nShowItemNum = 0;
	Int32 itemHeight = 150;

	m_nTitleReplyBtnID = SetTilteButton(pApp); 
	m_nTitleLblID = SetFormTilte(pApp); 

	//创建TPanel: CommentForm_CommentDetailPanel
	m_obContrl[m_nCtlIDCount] =new TPanel;	
	obBtnRec.SetRect(0, TITLEBAR_H, SCR_W, 370);
	if(m_obContrl[m_nCtlIDCount]->Create(this))
	{		
		m_obContrl[m_nCtlIDCount]->SetBounds(&obBtnRec);	
		m_iaCreateCtlID[m_nCtlIDCount] = m_obContrl[m_nCtlIDCount]->GetId();
		m_iaTPanelID[0] = m_obContrl[m_nCtlIDCount]->GetId();//Save TPanel ID

		m_obContrl[m_nCtlIDCount]->SetTransparent(TRUE);//设置透明
		m_obContrl[m_nCtlIDCount]->SetFrameWidth(0);//设置边框	
		m_obContrl[m_nCtlIDCount]->SetEnabled(TRUE);
		m_obContrl[m_nCtlIDCount]->Show(TRUE);	
	}
	else
	{
		bnRetCod++;
	}
	m_nCtlIDCount++;


	//创建普通button: 回复
	m_obContrl[m_nCtlIDCount] =new TButton ;
	obBtnRec.SetRect(80,420,50,30);
	if(m_obContrl[m_nCtlIDCount]->Create(this))
	{
		m_obContrl[m_nCtlIDCount]->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_Reply),TRUE);
		m_obContrl[m_nCtlIDCount]->SetBounds(&obBtnRec);
		tFont = m_obContrl[m_nCtlIDCount]->GetFont();
		tFont.Create(14, 14);
		m_obContrl[m_nCtlIDCount]->SetFont(tFont);
		// 保存控件ID,以便处理消息
		m_iaCreateCtlID[m_nCtlIDCount] = m_obContrl[m_nCtlIDCount]->GetId();
		m_nReplyBtnID = m_obContrl[m_nCtlIDCount]->GetId();//save reply button ID
		m_obContrl[m_nCtlIDCount]->Show(TRUE);		
	}
	else
	{
		bnRetCod++;
	}
	// 增加生成控件数量
	m_nCtlIDCount++;

	//创建普通button: 删除
	m_obContrl[m_nCtlIDCount] =new TButton ;
	obBtnRec.SetRect(160,420,50,30);
	if(m_obContrl[m_nCtlIDCount]->Create(this))
	{
		m_obContrl[m_nCtlIDCount]->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_Delete),TRUE);
		m_obContrl[m_nCtlIDCount]->SetBounds(&obBtnRec);
		tFont = m_obContrl[m_nCtlIDCount]->GetFont();
		tFont.Create(14, 14);
		m_obContrl[m_nCtlIDCount]->SetFont(tFont);
		// 保存控件ID,以便处理消息
		m_iaCreateCtlID[m_nCtlIDCount] = m_obContrl[m_nCtlIDCount]->GetId();
		m_nDeleteBtnID = m_obContrl[m_nCtlIDCount]->GetId();//save delete button ID
		m_obContrl[m_nCtlIDCount]->Show(TRUE);		
	}
	else
	{
		bnRetCod++;
	}
	// 增加生成控件数量
	m_nCtlIDCount++;



	//一下的控件都在TPanel中
	//创建Label 悄悄话		

	pTPanel = static_cast< TPanel* >(this->GetControlPtr(m_iaTPanelID[0]));

	if(pTPanel)
	{	
		CreateDetailItemControl(0,itemHeight, pTPanel, 0);	

		nShowItemNum = (this->m_nCommentDetailItemNum>COMMENTDETAIL_MAXITEM)?(COMMENTDETAIL_MAXITEM-1):(m_nCommentDetailItemNum-1);
		int startItem = (this->m_nCommentDetailItemNum>COMMENTDETAIL_MAXITEM)?(this->m_nCommentDetailItemNum-COMMENTDETAIL_MAXITEM):1;
		//历史留言详情
		int ctrlGroupIndex = 1;
		for(int i=startItem; i< this->m_nCommentDetailItemNum; i++)
		{			
			CreateDetailItemControl(i,itemHeight, pTPanel, ctrlGroupIndex);
			ctrlGroupIndex++;
		}

		pTPanel->Show(TRUE);
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:kaixin,代码行数:101,代码来源:KaiXinAPI_CommentDetail.cpp

示例10: _OnWinInitEvent

// 窗口初始化
Boolean TGardenListForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{
	int iRet = eFailed;
	int nIndex = 0;
	TBarRowList *lpRowList = NULL;
	TRectangle Rc_CoolBarList;

	nListItems =0;
	Response = NULL;
	iRet = KaiXinAPI_JsonParse(KX_GardenList, (void **)&Response);

	m_BackBtn = SetAppBackButton(this); 
	SetAppTilte(this, APP_KA_ID_STRING_Garden);	

	if(iRet == 1)
	{
		TBarRow *lpRow = NULL;
		TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_KA_ID_GardenListForm_GardenListCoolBarList));
		if (pCoolBarList)
		{
			TBarListItem* lpItem = NULL;

			pCoolBarList->SetBounds(RC_LIST_LARGE);
			pCoolBarList->GetBounds(&Rc_CoolBarList);
			lpRowList = pCoolBarList->Rows();
			//add row
			if (lpRowList)
			{
				lpRowList->BeginUpdate();
				lpRowList->Clear();
				lpRow = lpRowList->AppendRow();
				lpRowList->EndUpdate();
				if(lpRow)
				{
					//Title 
					lpItem = lpRow->AppendItem();
					if(lpItem)	
					{
						TFont objFontType;
						Int32 ItemHeight = 0;
						TRectangle rect;
						TRectangle Rc_Temp;
						TUChar pszSubTitle[64] = {0};

						lpItem->GetBounds(rect);
						lpItem->SetCaption(NULL);						
						lpItem->SetIndicatorType(itNone);

						ItemHeight = ItemHeight + 30;

						TUString::StrPrintF(pszSubTitle, TResource::LoadConstString(APP_KA_ID_STRING_SubTitleGarden),TResource::LoadConstString(APP_KA_ID_STRING_Friend));
						Int32 nTitlelabelId = lpItem->AddCtrl(CTL_CLASS_LABEL, 20, 5);
						TLabel* pTitlelabel = static_cast<TLabel*>(GetControlPtr(nTitlelabelId));
						TRectangle Rc_Titlelabel(OFFSET_X, ItemHeight, SCR_W - 20, 20);
						pTitlelabel->SetBounds(&Rc_Titlelabel);
						objFontType = pTitlelabel->GetFont();
						objFontType.Create(FONT_CONTENT, FONT_CONTENT);
						pTitlelabel->SetFont(objFontType); 
						pTitlelabel->SetCaption(pszSubTitle,FALSE);
						pTitlelabel->GetBounds(&Rc_Temp);

						ItemHeight = ItemHeight + Rc_Temp.Height() + 30;					
						lpItem->SetHeight(ItemHeight);	
					}						

					// 好友列表
					nListItems = Response->nSize_friends;
					if(nListItems == 0)
					{
						lpItem = lpRow->AppendItem();
						if(lpItem)
						{
							TFont objFontType;
							TUChar pszFriendName[32] = {0};
							Int32 ItemHeight = 0;
							TRectangle rect;
							TRectangle Rc_Temp;

							lpItem->GetBounds(rect);
							lpItem->SetCaption(NULL);						
							lpItem->SetIndicatorType(itNone);

							ItemHeight = ItemHeight + rect.Y() + 15;

							//好友的花园里还没有成熟的果实				
							Int32 nNoneHarvestId = lpItem->AddCtrl(CTL_CLASS_LABEL, 20, 5);
							TLabel* pNoneHarvest = static_cast<TLabel*>(GetControlPtr(nNoneHarvestId));
							TRectangle Rc_NoneHarvest(OFFSET_X, ItemHeight, SCR_W - 40 , 20);
							pNoneHarvest->SetBounds(&Rc_NoneHarvest);
							objFontType = pNoneHarvest->GetFont();
							objFontType.Create(FONT_CONTENT_DETAIL, FONT_CONTENT_DETAIL);
							pNoneHarvest->SetFont(objFontType);
							pNoneHarvest->SetColor(CTL_COLOR_TYPE_FORE,RGB_COLOR_GRAY);
							pNoneHarvest->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_NoneHarvestGarden),FALSE);
							pNoneHarvest->GetBounds(&Rc_Temp);		
							ItemHeight = ItemHeight + Rc_Temp.Height() + 10;

							lpItem->SetHeight(ItemHeight - (rect.Y() - Rc_CoolBarList.Y()) + 10 );
						}
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:kaixin,代码行数:101,代码来源:KaiXinAPI_GardenList.cpp

示例11: _SetDataToCtrls

void TUserInfoDetailForm::_SetDataToCtrls(TApplication* pApp)
{
	if(this->Response && Response->nSize_friends != 0)
	{
		TFont objFontType;				
		TUChar pszState[1024] = {0};
		TUChar pszStateTime[32] = {0};	
		TUChar pszLogoPath[256] = {0};	
		TUChar pszUserName[32] = {0};	
		TRectangle Rc_Temp;
		TRectangle rect;

		TMaskButton* pUserHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_UserDetailHeadMaskButton));

		TBitmap* pDownLoadBitmap = NULL;
		//Photo, 先读取磁盘cache
		pDownLoadBitmap = LoadImgByUrl(Response->friends[0].flogo90);
		//磁盘cache无文件,再下载
		if( pDownLoadBitmap == NULL)
		{
			TRectangle rc;

			KaiXinAPICommon_DownloadPhoto(Response->friends[0].flogo90, this->GetWindowHwndId(), 0 );	
			const TBitmap * pBmp = TResource::LoadConstBitmap(APP_KA_ID_BITMAP_Default);
			pUserHeadMBtn->GetBounds(&rc);
			pUserHeadMBtn->SetEnabled(FALSE);
			pUserHeadMBtn->SetCaption(TUSTR_Kx_NULL,0,0);
			pUserHeadMBtn->SetImage(pBmp,(rc.Width()-pBmp->GetWidth())/2, (rc.Height()-pBmp->GetHeight())/2);			
		}
		else
		{
			TRectangle rc;				
			pUserHeadMBtn->GetBounds(&rc);
			pUserHeadMBtn->SetEnabled(FALSE);
			pUserHeadMBtn->SetCaption(TUSTR_Kx_NULL,0,0);

			pPhotoBmp = TBitmap::Create(PHOTO_W, PHOTO_H, pDownLoadBitmap->GetDepth());
			pPhotoBmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255));	

			pUserHeadMBtn->SetImage(pPhotoBmp,(rc.Width()-pPhotoBmp->GetWidth())/2, (rc.Height()-pPhotoBmp->GetHeight())/2);			

			//释放图片
			pDownLoadBitmap->Destroy();
			pDownLoadBitmap = NULL;			
		}


		//用户名
		TRichView *pUserName = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_NameLbl));
		if(pUserName)
		{
			TUString::StrUtf8ToStrUnicode(pszUserName , (const Char *)Response->friends[0].fname);			
			objFontType = pUserName->GetFont();
			objFontType.Create(FONT_LARGE_NAME, FONT_LARGE_NAME);
			pUserName->SetFont(objFontType);
			pUserName->SetColor(CTL_COLOR_TYPE_FORE, RGB(67, 67, 135));
			pUserName->SetTransparent(TRUE);
			pUserName->SetCaption(pszUserName, FALSE);
			pUserName->SetEnabled(TRUE);			
		}

		//用户状态
		TPanel*pPanel = static_cast<TPanel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_StateContPanel));
		TRichView* pRichView = new TRichView();
		Int32 nRichViewId = 0;
		if(pRichView->Create(pPanel))	
		{
			TRectangle obBtnRec(0,0,0,0);
			pPanel->GetBounds(&obBtnRec);
			obBtnRec.SetX(0);
			obBtnRec.SetY(0);
			pRichView->SetBounds(&obBtnRec);
		
			TUString::StrUtf8ToStrUnicode(pszState, (Char*)Response->friends[0].state);
			objFontType = pRichView->GetFont();
			objFontType.Create(FONT_STATE, FONT_STATE);
			pRichView->SetFont(objFontType);
			pRichView->SetCaption(pszState,FALSE);

			pRichView->SetEnabled(FALSE);
			pRichView->SetWordWrapAttr(TRUE);
			pRichView->SetTransparent(TRUE);
			pRichView->SetScrollBarMode(CTL_SCL_MODE_NONE);
			pRichView->SetUnderLine(TRUE);
			Int32 nLineCount =  pRichView->GetLinesCount();
			if(nLineCount <7)
				nLineCount = 7;
		
			pRichView->SetMaxVisibleLines(nLineCount, TRUE);
		}		
		

		//状态更新时间
		TRichView* pStateTime = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_StateTimeLbl));		
		if(pStateTime)
		{
			objFontType = pStateTime->GetFont();
			objFontType.Create(FONT_OTHER_INFO, FONT_OTHER_INFO);
			pStateTime->SetFont(objFontType); 
			pStateTime->SetColor(CTL_COLOR_TYPE_FORE, RGB_COLOR_GRAY);
//.........这里部分代码省略.........
开发者ID:pengjohn,项目名称:kaixin,代码行数:101,代码来源:KaiXinAPI_UserInfoDetail.cpp

示例12: rcMemWnd

	CCXBitmapDC::CCXBitmapDC(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize)
        : m_pBitmap(NULL)
	{
        TUChar *pText = NULL; 
        do 
        {
            // create font
            TFont font;
            CCX_BREAK_IF(! font.Create(0, (Int32)fontSize));

            // text
            Int32 len = strlen(text) + 1;
            CCX_BREAK_IF(! (pText = new TUChar[len]));
            TUString::StrGBToUnicode(pText, (Char*)text);

            // calculate text size
            if (CGSize::CGSizeEqualToSize(dimensions, CGSizeZero))
            {
                m_tSize.width = font.CharsWidth(pText,len);
                m_tSize.height = font.LineHeight();
            }else
            {
                m_tSize = dimensions;
            }

            Int16 width = (Int16)m_tSize.width;
            Int16 height = (Int16)m_tSize.height;

            // create bitmap
            CCX_BREAK_IF(! (m_pBitmap = TBitmap::Create(width, height, 32)));

            // create memory window
            if (s_pMemWnd)
            {
                TRectangle rcMemWnd(0, 0, 0, 0);
                s_pMemWnd->GetClientBounds(&rcMemWnd);
                if (rcMemWnd.Width() < width || rcMemWnd.Height() < height)
                {
                    s_pMemWnd->CloseWindow();
                    s_pMemWnd = NULL;
                }
            }

            do 
            {
                // if memery window is already break
                CCX_BREAK_IF(s_pMemWnd);

                CCX_BREAK_IF(! (s_pMemWnd = new TWindow(CCXApplication::sharedApplication())));

                Coord nCurrentWidth = CCXApplication::GetCurrentApplication()->GetScreenWidth();
                Coord nCurrentHeight = CCXApplication::GetCurrentApplication()->GetScreenHeight();
                
                Coord nMemWndW = (width >= nCurrentWidth) ? width : nCurrentWidth;
                Coord nMemWndH = (height >= nCurrentHeight) ? height : nCurrentHeight;
                CCX_BREAK_IF(s_pMemWnd->CreateMemWindow(nMemWndW, nMemWndH,screenTransparentFormat));
                delete s_pMemWnd;
                s_pMemWnd = NULL;
            } while (0);

            CCX_BREAK_IF(! s_pMemWnd);
            
            // create DC
            TDC dc(s_pMemWnd);
            // set DC styles
            UInt32 styles = GUI_API_STYLE_SPECIFY_FORE_COLOR |  GUI_API_STYLE_ROP_MODE_TRANSPARENT |
                GUI_API_STYLE_SPECIFY_BACK_COLOR | GUI_API_STYLE_ALIGNMENT_MIDDLE | GUI_API_STYLE_SPECIFY_FONT;

            switch (alignment)
            {
            case UITextAlignmentLeft:
                styles |= GUI_API_STYLE_ALIGNMENT_LEFT;
                break;
            case UITextAlignmentCenter:
                styles |= GUI_API_STYLE_ALIGNMENT_CENTER;
                break;
            case UITextAlignmentRight:
                styles |= GUI_API_STYLE_ALIGNMENT_RIGHT;
                break;
            default:
                styles |= GUI_API_STYLE_ALIGNMENT_CENTER;
                break;
            }

            s_pMemWnd->GetMemWindowTBitmapPtr()->Fill32(RGBA(0, 0, 0, 0), 0, 0, width, height);

            TRectangle rect(0, 0, width, height);
            dc.DrawTextInRectangleEx(pText, 0, RGBA(255,255,255,255), RGBA(0,0,0,255), font, &rect, styles);

            dc.ReadBitmap(m_pBitmap, 0, 0);

        } while (0);
        if (pText)
        {
            delete[] pText;
            pText = NULL;
        }
	}
开发者ID:geniikw,项目名称:myFirst2DGame,代码行数:98,代码来源:CCXBitmapDC.cpp


注:本文中的TFont::Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。