Beispiel #1
0
//添加Image控件到CoolBarList, 
// pszString必须是动态的(非Static)
// nWidth 为0 -- 自动长度
Int32 CtrlAddItemToCoolBarList_Image(TWindow*pWin,  TBarListItem* pListItem, Coord nX, Coord nY, Coord nWidth, Int32 nHeight, TBitmap * pBmp)
{
	TRectangle obBtnRec(0,0,0,0);
	Int32 nImageId = pListItem->AddCtrl(CTL_CLASS_IMAGE, 0, 0);
	TImage* pImage = static_cast<TImage*>(pWin->GetControlPtr(nImageId));

	obBtnRec.SetRect(nX, nY, nWidth, nHeight);
	pImage->SetBounds(&obBtnRec);
	pImage->SetBitmap(pBmp);
	pImage->SetEnabled(TRUE);
	return nImageId;
}
Beispiel #2
0
Int32 CtrlAddItemToPanel_Image(TWindow*pWin, TPanel* pPanel, Coord nX, Coord nY, Coord nWidth, Coord nHeight, TBitmap * pBmp)
{
	TImage* pImage = new TImage();
	Int32 nImageId = 0;
	
	if(pImage->Create(pPanel))
	{
		TRectangle obBtnRec(0,0,0,0);

		nImageId=pImage->GetId();
		obBtnRec.SetRect(nX, nY, nWidth, nHeight);
		pImage->SetBounds(&obBtnRec);
		pImage->SetBitmap(pBmp);
		pImage->SetEnabled(TRUE);
	}
	
	return nImageId;
}
Beispiel #3
0
Boolean TInitForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{
	for(int i=0; i<LOADING_FORM_DOT_NUM; i++)
	{
		TImage* pTImage = new TImage;
		if(pTImage->Create(this))
		{
			TRectangle obBtnRec(DOT_X+((SCR_W - DOT_X*2)/LOADING_FORM_DOT_NUM)*i, DOT_Y, DOT_W, DOT_H);
			nDotID[i] = pTImage->GetId();//save button ID
			pTImage->SetBounds(&obBtnRec); 	
			pTImage->SetBitmapByResId (APP_KA_ID_BITMAP_Loading_dot); 
		}
	}

	_DrawDot(pApp, nLoadStep);
	m_nTimerId = TIMER_Create(1000, TIMER_MODE_AUTORUN | TIMER_MODE_PERIOD, NULL, 0, 0);	
	return TRUE;
}
// 窗口初始化
Boolean TFeedGetFangleForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent)
{
	int iRet = eFailed;
	
	m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT);
	SetAppTilte(this, APP_RE_ID_STRING_Fangle_Count);

	//从对应Json中获取数据,用于更新UI
	iRet = RenRenAPI_JsonParse(RR_FeedGetFangle, (void **)&Response);	
	if( Response == NULL || iRet != 0 )
	{
		return FALSE;
	}

	TCoolBarList* pTCoolBarList = NULL;
	TRectangle mTRectangle(0,0,0,0);

	if(Response->nArraySize == 0)
	{
		//无回复提示
		TPanel* pTPanel = NULL;
		pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel));

		TCtrl* mControlTImage;
		TCtrl* mControlTLabel;
		TImage* pTImage = NULL;
		TLabel* pTLabel = NULL;
		mControlTImage = new TImage;
		if(mControlTImage->Create(pTPanel))
		{
			mTRectangle.SetRect(8,10,50,50);
			mControlTImage->SetBounds(&mTRectangle);
			pTImage = static_cast<TImage*>(mControlTImage);
			pTImage->SetBitmap(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_comment_img_with_frame));
			pTImage->SetBounds(&mTRectangle);
		}
		mControlTLabel = new TLabel;
		if(mControlTLabel->Create(pTPanel))
		{
			mTRectangle.SetRect((mTRectangle.X() + mTRectangle.Width()),(mTRectangle.Y()+ 10) ,200,50);
			mControlTLabel->SetBounds(&mTRectangle);
			pTLabel = static_cast<TLabel*>(mControlTLabel);
			pTLabel->SetCaption(TResource::LoadConstString(APP_RE_ID_STRING_NothingFangle), FALSE);
		}
		 
		goto OutCoolBarList;
	}


	pTCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList));
	if(pTCoolBarList)
	{
		mTRectangle.SetRect(6,0,308,412);
		TBarListItem* pTBarListItem = NULL;
		TBarRowList* pTBarRowList = NULL;
		TBarRow* pTBarRow = NULL;
		TFont mTFont;
		pTBarRowList = pTCoolBarList->Rows();
		if(pTBarRowList)
		{
			pTBarRowList->BeginUpdate();
			pTBarRowList->Clear();
			pTBarRow = pTBarRowList->AppendRow();
			if(pTBarRow)
			{
				pTBarRow->SetCaption(NULL);
				for(int i = 0; i < Response->nArraySize; ++i)
				{
					
					Coord mItemHeight = 0;
					pTBarListItem = pTBarRow->AppendItem();
					if(pTBarListItem)
					{	
												
						pTBarListItem->SetCaption(NULL);
						pTBarListItem->SetTitle(NULL);
						pTBarListItem->SetIndicatorType(itDefault);
						pTBarListItem->SetValue(1);

						CtrlAddItemToCoolBarList_Image(this, pTBarListItem, 10,10, 16, 16, (TBitmap*)TResource::LoadConstBitmap(APP_RE_ID_BITMAP_FeedType_comment));

						TUChar buf[256] = {0};
						char   szbuf[512] = {0};
						strcpy(szbuf,Response->Array[i].name);
						strcat(szbuf,Response->Array[i].prefix);
						if(strcmp(Response->Array[i].title,"") != 0)
						{
							strcat(szbuf,"'");
							strcat(szbuf,Response->Array[i].title);
							strcat(szbuf,"'");
						}
						strcat(szbuf,Response->Array[i].sufix);
						TUString::StrUtf8ToStrUnicode(buf, (Char *)szbuf);

						CtrlAddItemToCoolBarList_RichView(this, pTBarListItem, 30, 10, SCR_W - 70, &mItemHeight, FONT_NORMAL, buf, RGB_COLOR_BLACK);
						
						TUString::StrUtf8ToStrUnicode(buf, (const Char *)Response->Array[i].time);
						CtrlAddItemToCoolBarList_Lable(this, pTBarListItem, 30, mItemHeight + 20, 0, FONT_SMALL, buf, RGB_COLOR_LIGHTBLUE);

						mItemHeight = mItemHeight + 40;
						pTBarListItem->SetHeight(mItemHeight);
						//pTBarListItem->SetHeight(60);
					}
				}
			}
			
			pTBarRowList->EndUpdate();
		}
	}

OutCoolBarList:

	return TRUE;
}