示例#1
0
//添加Button控件到CoolBarList, 
// pszString必须是动态的(非Static)
// nWidth 为0 -- 自动长度
Int32 CtrlAddItemToCoolBarList_Button(TWindow*pWin,  TBarListItem* pListItem, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TUChar* pszString)
{
	TRectangle obBtnRec(0,0,0,0);
	Int32 nButtonId = pListItem->AddCtrl(CTL_CLASS_BUTTON, 20, 5);
	TButton* pButton = static_cast<TButton*>(pWin->GetControlPtr(nButtonId));

	obBtnRec.SetRect(nX, nY, nWidth, nHeight);
	pButton->SetBounds(&obBtnRec);
	pButton->SetEnabled(TRUE);
	pButton->SetCaption(pszString,FALSE);
	return nButtonId;
}
示例#2
0
Int32 CtrlAddItemToPanel_Button(TWindow*pWin,  TPanel* pPanel, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TUChar* pszString)
{
	TRectangle obBtnRec(0,0,0,0);
	TButton* pButton = new TButton();
	Int32 nButtonId = -1;
	if(pButton->Create(pPanel))
	{
		 nButtonId = pButton->GetId();

		obBtnRec.SetRect(nX, nY, nWidth, nHeight);
		pButton->SetBounds(&obBtnRec);
		pButton->SetEnabled(TRUE);
		pButton->SetCaption(pszString,FALSE);
	}
	return nButtonId;
}
示例#3
0
//设置应用标题栏按钮
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;
}
示例#4
0
Int32 SetAppBitmapButton(TWindow * pWindow, Int32 NomalBtnID, Int32 OverBtnID)
{
	Int32 m_BtnID = 0;
	TButton *pBtn;
	TRectangle BtnRC(TITLE_BUTTON_X, TITLE_BUTTON_Y, TITLE_BUTTON_W, TITLE_BUTTON_H);

	const TBitmap * pNormalBmp = TResource::LoadConstBitmap(NomalBtnID);//APP_RE_ID_BITMAP_write_but
	const TBitmap * pOverBmp = TResource::LoadConstBitmap(OverBtnID);//APP_RE_ID_BITMAP_write_but_over
		
	pBtn = new TButton;	
	if(pBtn->Create(pWindow))
	{		
		pBtn->SetBounds(&BtnRC);	
		m_BtnID = pBtn->GetId();	
		
		pBtn->SetCaption(TUSTR_Kx_NULL,FALSE);
		pBtn->SetStyles(BTN_STYLES_GRAPGICS);
		pBtn->SetImage(pNormalBmp,0);
		pBtn->SetImage(pOverBmp,1);		
		pBtn->Show(TRUE);
	}
	return m_BtnID;
}
示例#5
0
Int32 SetAppTitleButton(TWindow * pWindow, const TUChar* pszResTxt, int ButtonPosition)
{
	Int32 m_BtnID = 0;
	
	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);
	
	Coord  nWidth = 0;
	Int32 nResIDNormal = 0;
	Int32 nResIDOver = 0;
	int nFontSize = 0;

	//根据显示文本的长短设置图标及文字大小
	switch( TUString::StrLen(pszResTxt) )
	{
		case 2:
			{
			 nWidth = TITLE_BUTTON_W;
			nFontSize = FONT_NORMAL;
			nResIDNormal = APP_KA_ID_BITMAP_button53;
			nResIDOver = APP_KA_ID_BITMAP_button53_over;				
			}
			break;
		case 3:
			{
			 nWidth = TITLE_BUTTON_W;
			nFontSize = FONT_NORMAL;
			nResIDNormal = APP_KA_ID_BITMAP_button53;
			nResIDOver = APP_KA_ID_BITMAP_button53_over;				
			}
			break;
		case 4:
			{
			 nWidth = TITLE_BUTTON_W;
			nFontSize = FONT_NORMAL;
			nResIDNormal = APP_KA_ID_BITMAP_button53;
			nResIDOver = APP_KA_ID_BITMAP_button53_over;				
			}
			break;
		case 5:
			{
			 nWidth = TITLE_BUTTON_W;
			nFontSize = FONT_MIDDLE;
			nResIDNormal = APP_KA_ID_BITMAP_button53;
			nResIDOver = APP_KA_ID_BITMAP_button53_over;				
			}
			break;
		case 6:
		default:
			{
			 nWidth = TITLE_BUTTON_W;
			nFontSize = FONT_SMALL;
			nResIDNormal = APP_KA_ID_BITMAP_button53;
			nResIDOver = APP_KA_ID_BITMAP_button53_over;				
			}
			break;

	}

	TFont tFont;	
	const TBitmap* pNormalBmp = TResource::LoadConstBitmap(nResIDNormal);
	const TBitmap* pOverBmp = TResource::LoadConstBitmap(nResIDOver);
	tFont.Create(nFontSize, nFontSize, FONT_STYLE_BOLD);
	
	TButton* pBtn = new TButton;	
	if(pBtn->Create(pWindow))
	{		
		BtnRC_Left.SetWidth(nWidth);
		BtnRC_Right.SetWidth(nWidth);
		BtnRC_Right.SetX(SCR_W-TITLE_BUTTON_X-nWidth);
			
		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(pszResTxt,FALSE);
		pBtn->SetStyles(BTN_STYLES_GRAPGICS);
		pBtn->SetImage(pNormalBmp,0);
		pBtn->SetImage(pOverBmp,1);		
		pBtn->Show(TRUE);
	}

	return m_BtnID;
}