// 窗口初始化 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 ); } } else { for( nIndex = 0; nIndex < nListItems; nIndex++) { 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; //好友名字 TUString::StrUtf8ToStrUnicode(pszFriendName, (const Char *)Response->friends[nIndex].fname); nFriendNameId[nIndex] = lpItem->AddCtrl(CTL_CLASS_RICHVIEW, 20, 5); TRichView* pFriendName = static_cast<TRichView*>(GetControlPtr(nFriendNameId[nIndex])); TRectangle Rc_FriendName(OFFSET_X, ItemHeight, SCR_W - 40 , 20); pFriendName->SetBounds(&Rc_FriendName); objFontType = pFriendName->GetFont(); objFontType.Create(FONT_CONTENT_DETAIL, FONT_CONTENT_DETAIL); pFriendName->SetFont(objFontType); //pFriendName->SetColor(CTL_COLOR_TYPE_FORE,RGB_COLOR_BLUE); pFriendName->SetWordWrapAttr(TRUE); pFriendName->SetTransparent(TRUE); pFriendName->SetEnabled(TRUE); pFriendName->SetScrollBarMode(CTL_SCL_MODE_NONE); pFriendName->SetMaxVisibleLines(1, TRUE); pFriendName->SetCaption(pszFriendName,FALSE); pFriendName->GetBounds(&Rc_Temp); ItemHeight = ItemHeight + Rc_Temp.Height() + 5; lpItem->SetHeight(ItemHeight - (rect.Y() - Rc_CoolBarList.Y()) + 10 ); } } } } //:TODO:Add subject info lpRowList->BeginUpdate(); lpRow = lpRowList->AppendRow(); lpRowList->EndUpdate(); //add Item if(lpRow) { //nothing to do } } } } return TRUE; }
CGRect CCXEGLView::getFrame() { TRectangle rc; GetClientBounds(&rc); return (CGRect((float)rc.X(), (float)rc.Y(), (float)rc.Width(), (float)rc.Height())); }
Int32 TUserInfoDetailForm::_SetCoolBarList(TApplication* pApp) { TBarRowList *lpRowList = NULL; TBarRow *lpRow = NULL; TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_InfoCoolBarList)); if (pCoolBarList) { #if 0 TRectangle rc; Int32 oldTop = 0; pCoolBarList->GetBounds(&rc); oldTop = rc.Y(); pCoolBarList->SetBounds(RC_LIST_NORMAL); pCoolBarList->GetBounds(&rc); rc.SetRect(rc.X(),oldTop,rc.Width(),rc.Height()); pCoolBarList->SetBounds(&rc); #endif TBarListItem* lpItem = NULL; lpRowList = pCoolBarList->Rows(); if (lpRowList) { lpRowList->BeginUpdate(); for(int i=0; i < lpRowList->Count(); i++) { lpRow = lpRowList->GetRow(i); if(lpRow) { for(int j = 0; j < lpRow->Count(); j++) { lpItem = lpRow->GetItem(j); if(lpItem) { Int32 ItemHeight = 60;//设置详情列表默认高度为60 lpItem->SetCaption(NULL); lpItem->SetIndicatorType(itNone); lpItem->SetHeight(ItemHeight); } } } } //取第一行的特别item,调整高度 lpRow = lpRowList->GetRow(0); if(lpRow) { TRectangle Rc_Temp; //HomeTown lpItem = lpRow->GetItem(3); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_HomeTownValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } } //取第二行的特别item,调整高度 lpRow = lpRowList->GetRow(1); if(lpRow) { TRectangle Rc_Temp; //MSN lpItem = lpRow->GetItem(3); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MSNValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } //email lpItem = lpRow->GetItem(6); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EmailValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } //教育背景 lpItem = lpRow->GetItem(7); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EduValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } //工作经历 lpItem = lpRow->GetItem(8); if(lpItem) { Int32 ItemHeight = 60; TRichView* pView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CareerValueView)); pView->GetBounds(&Rc_Temp); ItemHeight = 20 + Rc_Temp.Height() + 20; if(ItemHeight > 60) lpItem->SetHeight(ItemHeight); } } lpRowList->EndUpdate(); } } return TRUE; }