// /// Create a bitmap & get its handle, given an other bitmap /// Used by ctors here and in derived classes. Assumes Handle can be /// written over, & adds handle to reference container. // void TBitmap::Create(const TBitmap& src) { TMemoryDC memDC1; TMemoryDC memDC2; BITMAP bm; src.GetObject(bm); if (bm.bmPlanes != 1 || bm.bmBitsPixel != 1) { // create a color bitmap (Assume screen compatible) TScreenDC dc; Handle = ::CreateCompatibleBitmap(dc, bm.bmWidth, bm.bmHeight); } else // create a mono bitmap Handle = ::CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, 0); CheckValid(); RefAdd(Handle, Bitmap); memDC1.SelectObject(src); memDC2.SelectObject(*this); memDC2.BitBlt(TRect(TPoint(0, 0), TSize(bm.bmWidth, bm.bmHeight)), memDC1, TPoint(0, 0), SRCCOPY); }
template<typename I, typename O> int denoiseNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, bool dump = true) { NLMeansDenoiser<I, O> *denoiser = new NLMeansDenoiser<I, O>(sigma, dump); TBitmap<I> *input = new TBitmap<I>(); if (!input->loadBitmap(inputfile, inputtype)){ std::cout << "Input bitmap " << inputfile << " failed to load!\n"; std::cin.get(); return 0; } DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), input->getSize(), 1, false, input)); DenoiserOutput<O> *dOutput = denoiser->denoise(dInput); LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration()); dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype); input->unloadBitmap(); std::cin.get(); _CrtDumpMemoryLeaks(); // prints mem leaks return 0; }
// /// Add new cel(s) to the CelArray - return index of new addition. /// No mask bitmap is added. // int TCelArray::Add(const TBitmap& image) { int width = image.Width(); int count = width / CelSize().cx; if (!MaybeResize(count)) return -1; OwlCopyBmp(*Bitmap, image, CelOffset(NCelsUsed,0), image.Size()); int index = NCelsUsed; NCelsUsed += count; TRACEX(OwlGadget, 1, "TCelArray @" << (void*)this << " added bitmap @" << (void*)&image); return index; }
// /// Constructs a TImageList from a bitmap, slicing it up into a horizontal array of /// the given number of evenly sized images. // !CQ add an optional mask color? or mask? // TImageList::TImageList(const TBitmap& bmp, uint flags, int imageCount, int growBy) { if (!TCommCtrl::IsAvailable()) TXCommCtrl::Raise(); if (!imageCount) imageCount = 1; ImageSize = TSize(bmp.Width() / imageCount, bmp.Height()); Bitmap = 0; Handle = TCommCtrl::Dll()->ImageList_Create(ImageSize.cx, ImageSize.cy, flags, imageCount, growBy); CheckValid(); WARNX(OwlCommCtrl, !Handle, 0, "Cannot create ImageList"); // Use masked support with 3dFace color as background color // Add(bmp, TColor::Sys3dFace); // !CQ }
//--------------------------------------------------------------------------- void __fastcall TFormMain::ApplicationEventsMessage(tagMSG &Msg, bool &Handled) { try { if (Msg.message == WM_HOTKEY && Msg.wParam == IDHOTKEY) { DebugOutput("ReghotKey press"); TBitmap *screenshot = new TBitmap; this->WinGrab(screenshot); if (this->Ftp->Connected() == false) this->Ftp->Connect(); if (this->Ftp->Connected() == false) throw new Exception("Ftp not connected"); TMemoryStream *mem = new TMemoryStream; screenshot->SaveToStream(mem); this->Ftp->Put(mem, this->EditPwd->Text+"/"+Now().DateString()+"_"+ Now().TimeString()+".jpg", false, 0); ShowMessage("”спех."); } } catch (Exception *e) { DebugOutput(e->Message); ShowMessage("Error."); } }
template<typename I, typename O> int denoiseMLTNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, int numinstances = 1, bool dump = true) { MLTNLMeansDenoiser<I, O> *denoiser = new MLTNLMeansDenoiser<I, O>(r, f, k, sigma, numinstances, dump); DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile); // load bitmaps into DenoiserInput for (int i = 1; i <= numinstances; ++i) { TBitmap<I> *inputBitmap = new TBitmap<I> ; std::string stri = std::to_string(i); Assert(inputBitmap->loadBitmap(inputfile + "_" + stri, inputtype), "Input bitmap no."+ stri +" failed to load!"); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), inputBitmap->getSize(), 1, false, inputBitmap)); } DenoiserOutput<O> *dOutput = denoiser->denoise(dInput); LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration()); dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype); for (int i = 0; i < numinstances; ++i) { dInput->getImageBlocks()[i]->getBitmap()->unloadBitmap(); } std::cin.get(); _CrtDumpMemoryLeaks(); // prints mem leaks return 0; }
void PresetButtonControl::OnPaint(DibBitmap *pbm) { bool fSet = (m_wf & kfCtlSet) != 0; Rect rcForm; m_pfrm->GetRect(&rcForm); bool fSelected = m_pfrm->IsControlInside(this); Rect rcT = m_rc; rcT.Offset(rcForm.left, rcForm.top); if (fSelected) { pbm->Fill(rcT.left + 1, rcT.top + 1, rcT.Width() - 2, rcT.Height() - 2, GetColor(kiclrButtonFillHighlight)); } TBitmap *ptbm; if (fSet) ptbm = m_ptbmDown; else ptbm = m_ptbmUp; if (ptbm != NULL) ptbm->BltTo(pbm, m_rc.left + rcForm.left + 1, m_rc.top + rcForm.top + 1); }
void CheckBoxControl::OnPaint(DibBitmap *pbm) { Rect rcForm; m_pfrm->GetRect(&rcForm); // Draw up / down image (if present) TBitmap *ptbm; bool fPenDownInside = m_pfrm->IsControlInside(this); if (fPenDownInside) { ptbm = m_fChecked ? s_ptbmOnDown : s_ptbmOffDown; } else { ptbm = m_fChecked ? s_ptbmOnUp : s_ptbmOffUp; } // Center the text horizontally and draw to the right of the checkbox Font *pfnt = gapfnt[m_ifnt]; int cy = pfnt->GetHeight(); Size siz; ptbm->GetSize(&siz); ptbm->BltTo(pbm, m_rc.left + rcForm.left, m_rc.top + (cy - siz.cy) / 2 + rcForm.top - 1); gapfnt[m_ifnt]->DrawText(pbm, m_szLabel, m_rc.left + rcForm.left + siz.cx, m_rc.top + rcForm.top); }
/** * 从profile中读取大头像, 如果本地没有则进行下载 * * \param pApp * \param ResponseInfoPhoto * * \return */ Boolean TPhotosGetAlbumsForm::_UpdateProfilePhoto(TApplication* pApp, tResponseUsersGetInfo* ResponseInfoPhoto) { if(ResponseInfoPhoto == NULL) return FALSE; if(ResponseInfoPhoto->nArraySize > 0) { TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(ResponseInfoPhoto->Array[0].headurl); if(pDownLoadBitmap == NULL) { RenRenAPICommon_DownloadPhoto(ResponseInfoPhoto->Array[0].headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX); } else { TMaskButton* pLogo = NULL; pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID)); if(pLogo) { TRectangle rc; TBitmap * pProfileImageTmp = NULL; //Profile的头像 pLogo->GetBounds(&rc); pProfileImageTmp = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImageTmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pLogo->SetCaption(TUSTR_Re_NULL,0,0); pLogo->SetImage(pProfileImageTmp, (rc.Width()-pProfileImageTmp->GetWidth())/2, (rc.Height()-pProfileImageTmp->GetHeight())/2); pLogo->Draw(); //如果先Desroy,则会崩溃,很奇怪,原因不明,暂时这么处理 if( pProfileImage != NULL) { pProfileImage->Destroy(); pProfileImage = NULL; } pProfileImage = pProfileImageTmp; } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } } return TRUE; }
Boolean TPagesGetListForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { int iRet = eFailed; tResponsePagesGetList* Response = NULL; //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_Refresh,TITLE_BUTTON_LEFT); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); SetAppTilte(this, APP_RE_ID_STRING_Pages); //从对应Json中获取数据,用于更新UI iRet = RenRenAPI_JsonParse(RR_PagesGetList, (void **)&Response); //:TODO: //Panel -> CoolBarList->pRowList->pBarRow->pListItem TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if (pCoolBarList) { TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); pRowList = pCoolBarList->Rows(); if (pRowList) { pRowList->BeginUpdate(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); //数量统计 { TBarListItem* lpItem = NULL; TUChar pszTitle[64] = {0}; lpItem = pBarRow->AppendItem(); if (lpItem) { Int32 StringWidth = 0; TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_PagesCount), Response->nArraySize); StringWidth = GetShowAllStringWidth(pszTitle, FONT_MIDDLE) + 5; //多预留一些 CtrlAddItemToCoolBarList_Lable(this, lpItem, (COOLBARLIST_WIDTH-StringWidth)/2, 10, StringWidth, FONT_MIDDLE, pszTitle); lpItem->SetHeight(10*2+FONT_MIDDLE); lpItem->SetEnabled(FALSE); } } //以下为增加列表项 for (int i = 0; i < Response->nArraySize; i++) { TUChar pszString[4096] = {0}; Coord nHeight = 0; Int32 nItemHeight = 0; pListItem = pBarRow->AppendItem(); if (pListItem) { //属性设置 pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itNone); //头像,需要做缩放 //先读取磁盘cache, 无文件再下载 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(Response->Array[i].headurl); if( pDownLoadBitmap != NULL) { gItemData[i].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); gItemData[i].MaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmp,(TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { gItemData[i].MaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default),(TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); //因为第一项为数据统计, 所以参数需要+1 RenRenAPICommon_DownloadPhoto(Response->Array[i].headurl, this->GetWindowHwndId(), i ); } #if 1 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name); CtrlAddItemToCoolBarList_Lable(this , pListItem , NAME_X, NAME_Y, 0, FONT_NORMAL,pszString, RGB_COLOR_LIGHTBLUE); TUString::StrPrintF(pszString , TResource::LoadConstString(APP_RE_ID_STRING_FriendNumFormat), Response->Array[i].fans_count); CtrlAddItemToCoolBarList_Lable(this, pListItem, COUNT_INFO_X, COUNT_INFO_Y, 0, FONT_SMALL, pszString, RGB_COLOR_GRAY); pListItem->SetHeight(COOLBARLIST_HEIGHT); #else //带描述的布局 //姓名 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name); CtrlAddItemToCoolBarList_RichView(this , pListItem , 65, 5, 240, &nHeight, FONT_NORMAL,pszString, RGB_COLOR_LIGHTBLUE); nItemHeight = 5 + nHeight; //描述 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].desc); CtrlAddItemToCoolBarList_RichView(this , pListItem , 65, nHeight + 5, 240, &nHeight, FONT_NORMAL,pszString, RGB_COLOR_BLACK); //成员个数 TUString::StrPrintF(pszString , TResource::LoadConstString(APP_RE_ID_STRING_FriendNumFormat), Response->Array[i].fans_count); CtrlAddItemToCoolBarList_Lable(this, pListItem, 65, (nItemHeight + nHeight + 10), 0, FONT_SMALL, pszString, RGB_COLOR_GRAY); nItemHeight = nItemHeight + nHeight + 25 + FONT_SMALL; pListItem->SetHeight(nItemHeight); #endif pListItem->SetTagValue(i); gItemData[i].id = Response->Array[i].page_id; } } pRowList->EndUpdate(); } } if( Response ) { delete Response; } return TRUE; }
// 窗口初始化 Boolean TMessageGetsForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { int iRet = eFailed; tResponseMessageGets* Response = NULL; if(nMessageBoxType == MESSAGE_TYPE_INBOX ) { SetAppTilte(this, APP_RE_ID_STRING_MessagesInBox); //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_OutBox,TITLE_BUTTON_LEFT); m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over); } else { SetAppTilte(this, APP_RE_ID_STRING_MessagesOutBox); //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_InBox,TITLE_BUTTON_LEFT); m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over); } m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); //从对应Json中获取数据,用于更新UI iRet = RenRenAPI_JsonParse(RR_MessageGets, (void **)&Response); //:TODO: //Panel -> CoolBarList->pRowList->pBarRow->pListItem TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if(pCoolBarList) { TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); pRowList = pCoolBarList->Rows(); if (pRowList) { pRowList->BeginUpdate(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); if(pBarRow) { //数量统计 { TBarListItem* lpItem = NULL; TUChar pszTitle[64] = {0}; lpItem = pBarRow->AppendItem(); if (lpItem) { Int32 StringWidth = 0; TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_MessageCount), Response->count); StringWidth = GetShowAllStringWidth(pszTitle, FONT_MIDDLE) + 8; //多预留一些 CtrlAddItemToCoolBarList_Lable(this, lpItem, (COOLBARLIST_WIDTH-StringWidth)/2, NAME_Y, 0, FONT_MIDDLE, pszTitle); lpItem->SetHeight(NAME_Y*2+FONT_MIDDLE); lpItem->SetEnabled(FALSE); } } //以下为增加列表项自定义项 for (int i = 0; i < Response->nSize_messages; i++) { TUChar pszString[4096] = {0}; pListItem = pBarRow->AppendItem(); if (pListItem) { //属性设置 pListItem->SetHeight(COOLBARLIST_HEIGHT); pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itNone); //头像,先读取磁盘cache, 无文件再下载 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(Response->messages[i].head_url); if( pDownLoadBitmap != NULL) { gItemData[i].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmp, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default), (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); RenRenAPICommon_DownloadPhoto(Response->messages[i].head_url, this->GetWindowHwndId(), i ); } //姓名 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].name); CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, 0, FONT_MIDDLE, pszString); //时间 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].time); CtrlAddItemToCoolBarList_Lable(this, pListItem, TIME_X, TIME_Y, 0, FONT_SMALL, pszString, RGB_COLOR_LIGHTBLUE); //标题,新消息显示为红色 //一个小技巧,一个消息显示为两种(已读和未读), 然后根据情况隐藏一个 TUChar pszStringTemp[4096] = {0}; TUString::StrUtf8ToStrUnicode(pszStringTemp , (const Char *)Response->messages[i].title); gItemData[i].TitleIDRead = CtrlAddItemToCoolBarList_Lable(this, pListItem, TITLE_X, TITLE_Y, TITLE_W, FONT_NORMAL, pszStringTemp); TUString::StrCopy(pszString, TResource::LoadConstString(APP_RE_ID_STRING_NewMessageFlag)); TUString::StrCat(pszString, pszStringTemp); gItemData[i].TitleIDUnread = CtrlAddItemToCoolBarList_Lable(this, pListItem, TITLE_X, TITLE_Y, TITLE_W, FONT_NORMAL, pszString, RGB_COLOR_RED); if(Response->messages[i].is_read == 0) { this->HideControl(gItemData[i].TitleIDRead); } else { this->HideControl(gItemData[i].TitleIDUnread); } //内容 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->messages[i].content); CtrlAddItemToCoolBarList_Lable(this, pListItem, CONTENT_X, CONTENT_Y, CONTENT_W, FONT_MIDDLE, pszString, RGB_COLOR_GRAY); pListItem->SetTagValue(i); gItemData[i].id = Response->messages[i].id; } } } pRowList->EndUpdate(); } } if( Response ) { delete Response; } return TRUE; }
/** * 设置专辑列表显示 * * \param pApp * * \return */ Int32 TPhotosGetAlbumsForm::_SetAlbumCoolBarList(TApplication* pApp) { //获取CoolBarList 控件指针 TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if (Response) { //动态添加控件处理 if (pCoolBarList) { //大行类,它管理 N个TBarRow对象 TBarRowList* pRowList = NULL; //小行类,管理N个TBarListItem 对象 TBarRow* pBarRow = NULL; //TCoolBarList中的项,为行所包含,一行可以包含多个项 TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); //获取行列表指针,通过行列表指针插入一行 pRowList = pCoolBarList->Rows(); if (pRowList) { //开始更新数据 pRowList->BeginUpdate(); //清除所有行 pRowList->Clear(); //在行列表尾追加一行 pBarRow = pRowList->AppendRow(); //数量统计 { TBarListItem* lpItem = NULL; TUChar pszTitle[64] = {0}; TUString::StrPrintF(pszTitle, TResource::LoadConstString(APP_RE_ID_STRING_AlbumCount), Response->nArraySize); lpItem = pBarRow->AppendItem(); lpItem->SetCaption(pszTitle); lpItem->SetEnabled(FALSE); } for(int i=0; i<Response->nArraySize; i++) { TUChar pnString[128] = {0};//相册名称 TUChar pctString[64] = {0};//相册创建时间 TUChar psString[64] = {0}; //相册大小 //添加列表项 pListItem = pBarRow->AppendItem(); if (pListItem) { //设定item属性 pListItem->SetHeight(COOLBAR_ITEM_HEIGHT); pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itDefault); //磁盘cache无文件,再下载 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(Response->Array[i].url); // 1、获取相册封面,图片头像,需要做缩放 if( pDownLoadBitmap != NULL) { gItemData[i].pBmp= pDownLoadBitmap->Create(IMAGE_W, IMAGE_H, 32); gItemData[i].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); gItemData[i].nImageID = CtrlAddItemToCoolBarList_Image(this, pListItem, IMAGE_X, IMAGE_Y, IMAGE_W, IMAGE_H, gItemData[i].pBmp); //pListItem->SetIcon( gItemData[i].pBmpZoom ); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } else { //因为第一项为数据统计, 所以参数需要+1 RenRenAPICommon_DownloadPhoto(Response->Array[i].url, this->GetWindowHwndId(), i ); gItemData[i].nImageID = CtrlAddItemToCoolBarList_Image(this, pListItem, IMAGE_X, IMAGE_Y, IMAGE_W, IMAGE_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default)); //pListItem->SetIcon(TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default)); } // 2、获取相册名称 TUString::StrUtf8ToStrUnicode(pnString , (const Char *)Response->Array[i].name); //是否加密 if(Response->Array[i].visable == 4) { CtrlAddItemToCoolBarList_Image(this, pListItem, NAME_X, NAME_Y + (NAME_H - LOCK_H)/2, LOCK_W, LOCK_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_locked)); CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X+LOCK_W, NAME_Y, NAME_W-LOCK_W, NAME_FONT, pnString, RGB_COLOR_BLACK); } else { CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, NAME_W, NAME_FONT, pnString, RGB_COLOR_BLACK); } // 3、获取相册大小 //按照格式串填写目的串 TUString::StrPrintF(psString, TResource::LoadConstString(APP_RE_ID_STRING_PhotosCountFormat), Response->Array[i].size); CtrlAddItemToCoolBarList_Lable(this, pListItem, SIZE_X, SIZE_Y, 0, SIZE_FONT, psString, RGB_COLOR_BLACK); // 4、获取创建相册日期 TUString::StrUtf8ToStrUnicode(pctString , (const Char *)Response->Array[i].create_time); CtrlAddItemToCoolBarList_Lable(this, pListItem, DATE_X, DATE_Y, 0, DATE_FONT, pctString, RGB_COLOR_GRAY); pListItem->SetTagValue(i); } gItemData[i].uid = Response->Array[i].uid; gItemData[i].aid = Response->Array[i].aid; gItemData[i].visable = Response->Array[i].visable; } pRowList->EndUpdate(); } } } return TRUE; }
// 窗口初始化 Boolean TPhotosGetAlbumsForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { int nErrorCode = eFailed; Int32 Height_Panel = 0; //Panel高度 //m_TitleBtnLeft = SetAppTitleButton(this, APP_RE_ID_STRING_Comment,TITLE_BUTTON_LEFT); //显示不同的title if(m_FormMode == FORM_MODE_NORMAL) { SetAppTilte(this, APP_RE_ID_STRING_Album); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); char* uid = NULL; uid = Get_Url_Params(RR_PhotosGetAlbums, "uid"); if( strcmp(uid, RenRenUserInfo.szuid) == 0) { m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_take_photo, APP_RE_ID_BITMAP_take_photo); } } else if(m_FormMode == FORM_MODE_MYHOME) { tResponseProfile* ResponseProfile; nErrorCode = RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile != NULL) { if(ResponseProfile->uid == RenRenUserInfo.uid) { SetAppTilte(this, APP_RE_ID_STRING_MyNews); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Home, TITLE_BUTTON_RIGHT); m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_take_photo, APP_RE_ID_BITMAP_take_photo); } else { //姓名 TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); SetAppTilte(this, 0, pszFName); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); } delete ResponseProfile; ResponseProfile = NULL; } } //设置panel高度 TPanel* pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel)); TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if(pTPanel) { TRectangle rect; Height_Panel = SCR_H - STATUSBAR_H - TITLEBAR_H; if(m_FormMode == FORM_MODE_MYHOME) Height_Panel -= BOTTOM_TAB_H; pTPanel->GetBounds(&rect); rect.SetHeight(Height_Panel); pTPanel->SetBounds(&rect); } if(m_FormMode == FORM_MODE_MYHOME) CreateProfileBottomTab(this, &BottomTabCtrID, 2); //显示个人信息 if(m_FormMode == FORM_MODE_MYHOME) { Int32 Height_Top = 0; //CoolBarList上面信息的高度 Int32 Height_CoolBarList = 0; //CoolBarList高度 tResponseProfile* ResponseProfile; nErrorCode = RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile != NULL) { //头像 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(ResponseProfile->headurl); //pProfileImage = LoadImgByUrl(ResponseProfile->headurl); const TBitmap * pImageDeault = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_DefaultLarge); const TBitmap * pBackImage = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_headmask_large); if(pDownLoadBitmap == NULL) { //RenRenAPICommon_DownloadPhoto(ResponseProfile->headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pImageDeault, (TBitmap*)pImageDeault, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); } else { //需要做放大 pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pProfileImage, (TBitmap*)pProfileImage, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } //下载大头像 tResponseUsersGetInfo* ResponseUserInfoPhoto = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&ResponseUserInfoPhoto); if(ResponseUserInfoPhoto) { if( (ResponseUserInfoPhoto->nArraySize > 0) && (ResponseUserInfoPhoto->Array[0].uid == ResponseProfile->uid) ) { _UpdateProfilePhoto(pApp, ResponseUserInfoPhoto); } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } delete ResponseUserInfoPhoto; ResponseUserInfoPhoto = NULL; } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } //姓名 TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); CtrlAddItemToPanel_Label(this, pTPanel, RR_NAME_X, RR_NAME_Y, 0, FONT_NORMAL, pszFName, RGB_COLOR_BLACK); Height_Top += (RR_NAME_Y+RR_NAME_H); //状态 TUChar pszStatus[1024] = {0}; Coord nHeight_RichView = 0; if(ResponseProfile->nSize_status>0) { TUString::StrUtf8ToStrUnicode(pszStatus, (const Char *)ResponseProfile->status[0].content); CtrlAddItemToPanel_RichView(this, pTPanel, RR_STATUS_X, RR_STATUS_Y, RR_STATUS_W, &nHeight_RichView, FONT_MIDDLE, pszStatus, RGB_COLOR_BLACK); } //位置容错调整 if(nHeight_RichView > (RR_HEAD_H-RR_NAME_H) ) Height_Top += nHeight_RichView; else Height_Top += (RR_HEAD_H- RR_NAME_H); //调整间隔 Height_Top += 4; //设置CoolBarList高度 if(pCoolBarList) { TRectangle rect; Int32 nY = Height_Top; pCoolBarList->GetBounds(&rect); rect.SetY(nY); pCoolBarList->SetBounds(&rect); } delete ResponseProfile; ResponseProfile = NULL; } } //从对应Json中获取数据,用于更新UI nErrorCode = RenRenAPI_JsonParse(RR_PhotosGetAlbums, (void **)&Response); if (Response ) { _SetAlbumCoolBarList(pApp); delete Response; Response = NULL; } else { //显示无权限操作的情况(用户设置了阅读权限) if(nErrorCode == 200) { TUChar ErrorInfo[ERROR_INFO_LEN] = {0}; if(RenRenAPI_JsonParse_bSuccess(RR_PhotosGetAlbums, ErrorInfo) != 0) { if(TUString::StrLen(ErrorInfo) > 0) { //动态添加列表数据 TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; pRowList = pCoolBarList->Rows(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); //显示错误提示 TBarListItem* lpItem = NULL; lpItem = pBarRow->AppendItem(); if (lpItem) { CtrlAddItemToCoolBarList_Lable(this, lpItem, RR_INFO_X, RR_INFO_Y, RR_INFO_W, FONT_NORMAL, (TUChar*)ErrorInfo); lpItem->SetHeight(RR_INFO_H); lpItem->SetEnabled(FALSE); } } } } } return TRUE; }
// 窗口事件处理 Boolean TPhotosGetAlbumsForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); if(m_FormMode == FORM_MODE_MYHOME) dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_Bottom_btn_bg), 0, BOTTOM_TAB_Y, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_PhotoDownload: { if(notifyData.nParam == FEED_PROFILE_IMAGE_INDEX) { //下载完后更新对应的图片 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap) { TMaskButton* pLogo = NULL; pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID)); if(pLogo) { TRectangle rc; pLogo->GetBounds(&rc); if( pProfileImage != NULL) { pProfileImage->Destroy(); pProfileImage = NULL; } pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pLogo->SetCaption(TUSTR_Re_NULL,0,0); pLogo->SetImage(pProfileImage, (rc.Width()-pProfileImage->GetWidth())/2, (rc.Height()-pProfileImage->GetHeight())/2); pLogo->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } break; } TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap= LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap != NULL) { TImage* pImage = static_cast<TImage*>(GetControlPtr(gItemData[notifyData.nParam].nImageID)); if(pImage != NULL) { if( gItemData[notifyData.nParam].pBmp != NULL) { gItemData[notifyData.nParam].pBmp->Destroy(); gItemData[notifyData.nParam].pBmp = NULL; } gItemData[notifyData.nParam].pBmp = pDownLoadBitmap->Create(IMAGE_W, IMAGE_H, 32); gItemData[notifyData.nParam].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); //pImage->SetImage(gItemData[notifyData.nParam].pBmp, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmp->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmp->GetHeight())/2 ); pImage->SetBitmap(gItemData[notifyData.nParam].pBmp); pImage->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } } break; case RR_PhotosUpload: { if(pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadContinue),TResource::LoadConstString(APP_RE_ID_STRING_PhotoUploadSuccess),WMB_YESNO) ==0 ) { HitControl(m_TitleBtnLeft); } else { RenRenAPICommon_Download(RR_PhotosGetAlbums, this->GetWindowHwndId(), 0, m_FormMode); } break; } case RR_UsersGetInfoPhoto: { tResponseUsersGetInfo* Response = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&Response); if(Response) { _UpdateProfilePhoto(pApp, Response); delete Response; Response = NULL; } } break; default: break; } } break; case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); if(notifyData.nParam == EDIT_PARAM_PASSWORD) { Set_Url_Params(RR_PhotosGet, "password", (char*)notifyData.pszEditContent); RenRenAPICommon_Download(RR_PhotosGet, this->GetWindowHwndId(), 0, 0); } else if(notifyData.nParam == RR_PhotosUpload) { Set_Url_Params(RR_PhotosUpload, "caption", (char*)notifyData.pszEditContent); RenRenAPICommon_Download(RR_PhotosUpload, this->GetWindowHwndId(), 0, 0); } bHandled = TRUE; break; } default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口初始化 Boolean TGuestbookGetForm::_OnWinInitEvent(TApplication * pApp, EventType * pEvent) { m_TitleBtnLeft = SetAppBitmapButton(this, APP_RE_ID_BITMAP_write_but, APP_RE_ID_BITMAP_write_but_over); //m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); //SetAppTilte(this, APP_RE_ID_STRING_Guestbook); //显示不同的title if(m_FormMode == FORM_MODE_NORMAL) { SetAppTilte(this, APP_RE_ID_STRING_Guestbook); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); } else if(m_FormMode == FORM_MODE_MYHOME) { tResponseProfile* ResponseProfile; RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile) { if(ResponseProfile->uid == RenRenUserInfo.uid) { SetAppTilte(this, APP_RE_ID_STRING_MyNews); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Home,TITLE_BUTTON_RIGHT); } else { TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); SetAppTilte(this, 0, pszFName); m_TitleBtnRight = SetAppTitleButton(this, APP_RE_ID_STRING_Back,TITLE_BUTTON_RIGHT); } delete ResponseProfile; ResponseProfile = NULL; } } //设置panel高度 TPanel* pTPanel = static_cast<TPanel*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonPanel)); TCoolBarList* pCoolBarList = static_cast<TCoolBarList*>(GetControlPtr(APP_RE_ID_CommonListForm_CommonCoolBarList)); if( (pTPanel == NULL) || (pCoolBarList == NULL) ) return FALSE; //调整Panel高度 { TRectangle rect; Int32 Height_Panel = 0; //Panel高度 Height_Panel = SCR_H - STATUSBAR_H - TITLEBAR_H; if(m_FormMode == FORM_MODE_MYHOME) Height_Panel -= BOTTOM_TAB_H; pTPanel->GetBounds(&rect); rect.SetHeight(Height_Panel); pTPanel->SetBounds(&rect); } if(m_FormMode == FORM_MODE_MYHOME) CreateProfileBottomTab(this, &BottomTabCtrID, 4); //:TODO: //显示个人信息 if(m_FormMode == FORM_MODE_MYHOME) { Int32 Height_Top = 0; //CoolBarList上面信息的高度 tResponseProfile* ResponseProfile; RenRenAPI_JsonParse(RR_ProfileGetInfo, (void **)&ResponseProfile); if(ResponseProfile != NULL) { //头像 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByUrl(ResponseProfile->headurl); //pProfileImage = LoadImgByUrl(ResponseProfile->headurl); const TBitmap * pImageDeault = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_DefaultLarge); const TBitmap * pBackImage = TResource::LoadConstBitmap(APP_RE_ID_BITMAP_headmask_large); if(pDownLoadBitmap == NULL) { //RenRenAPICommon_DownloadPhoto(ResponseProfile->headurl, this->GetWindowHwndId(), FEED_PROFILE_IMAGE_INDEX); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pImageDeault, (TBitmap*)pImageDeault, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); } else { //需要做放大 pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); m_ProfileImageID = CtrlAddItemToPanel_MaskButton(this, pTPanel, RR_HEAD_X, RR_HEAD_Y, RR_HEAD_W, RR_HEAD_H, (TBitmap*)pProfileImage, (TBitmap*)pProfileImage, (TBitmap*)pBackImage ); this->DisableControl(m_ProfileImageID); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } //下载大头像 tResponseUsersGetInfo* ResponseUserInfoPhoto = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&ResponseUserInfoPhoto); if(ResponseUserInfoPhoto) { if( (ResponseUserInfoPhoto->nArraySize > 0) && (ResponseUserInfoPhoto->Array[0].uid == ResponseProfile->uid) ) { _UpdateProfilePhoto(pApp, ResponseUserInfoPhoto); } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } delete ResponseUserInfoPhoto; ResponseUserInfoPhoto = NULL; } else { Set_Url_Params(RR_UsersGetInfoPhoto, "uids", m_uid); RenRenAPICommon_Download(RR_UsersGetInfoPhoto, this->GetWindowHwndId(), 0, 0); } //姓名 TUChar pszFName[64] = {0}; TUString::StrUtf8ToStrUnicode(pszFName , (const Char *)ResponseProfile->name); CtrlAddItemToPanel_Label(this, pTPanel, RR_NAME_X, RR_NAME_Y, 0, FONT_NORMAL, pszFName, RGB_COLOR_BLACK); Height_Top += (RR_NAME_Y+RR_NAME_H); //状态 TUChar pszStatus[1024] = {0}; Coord nHeight_RichView = 0; if(ResponseProfile->nSize_status>0) { TUString::StrUtf8ToStrUnicode(pszStatus, (const Char *)ResponseProfile->status[0].content); CtrlAddItemToPanel_RichView(this, pTPanel, RR_STATUS_X, RR_STATUS_Y, RR_STATUS_W, &nHeight_RichView, FONT_MIDDLE, pszStatus, RGB_COLOR_BLACK); } //位置容错调整 if(nHeight_RichView > (RR_HEAD_H-RR_NAME_H) ) Height_Top += nHeight_RichView; else Height_Top += (RR_HEAD_H- RR_NAME_H); //调整间隔 Height_Top += 4; //设置CoolBarList高度 if(pCoolBarList) { TRectangle rect; Int32 nY = Height_Top; pCoolBarList->GetBounds(&rect); rect.SetY(nY); pCoolBarList->SetBounds(&rect); } delete ResponseProfile; ResponseProfile = NULL; } } //从对应Json中获取数据,用于更新UI int nErrorCode = eFailed; tResponseGuestbookGet* Response = NULL; nErrorCode = RenRenAPI_JsonParse(RR_GuestbookGet, (void **)&Response); //动态添加列表数据 TBarRowList* pRowList = NULL; TBarRow* pBarRow = NULL; pRowList = pCoolBarList->Rows(); pRowList->Clear(); pBarRow = pRowList->AppendRow(); if(Response != NULL) { TBarListItem* pListItem = NULL; //背景设置为白色底色 pCoolBarList->SetColor(CTL_COLOR_TYPE_FOCUS_BACK, RGB_COLOR_WHITE); pRowList->BeginUpdate(); if(Response->nArraySize == 0) { TUChar pszCount[64] = {0}; TUString::StrPrintF(pszCount, TResource::LoadConstString(APP_RE_ID_STRING_GuestbookCount), Response->nArraySize); TBarListItem* lpItem = NULL; lpItem = pBarRow->AppendItem(); lpItem->SetCaption(pszCount); lpItem->SetEnabled(FALSE); } //以下为增加列表项 for (int i = 0; i < Response->nArraySize; i++) { TUChar pszString[4096] = {0}; Coord nHeigh = 0; pListItem = pBarRow->AppendItem(); if (pListItem) { //属性设置 pListItem->SetTitle(NULL); pListItem->SetCaption(NULL); pListItem->SetIndicatorType(itNone); //先读取磁盘cache, 无文件再下载 gItemData[i].pBmp = LoadImgByUrl(Response->Array[i].headurl); if( gItemData[i].pBmp != NULL) { //头像,需要做缩放 gItemData[i].pBmpZoom = gItemData[i].pBmp->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[i].pBmpZoom->QuickSpecialZoom(gItemData[i].pBmp, 0, 0); gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, gItemData[i].pBmpZoom, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); } else { gItemData[i].HeadMaskButtonID = CtrlAddItemToCoolBarList_MaskButton(this, pListItem, HEADMASK_X, HEADMASK_Y, HEADMASKBUTTON_W, HEADMASKBUTTON_H, (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_Default), (TBitmap*)TBitmap::LoadResBitmap(APP_RE_ID_BITMAP_head1)); RenRenAPICommon_DownloadPhoto(Response->Array[i].headurl, this->GetWindowHwndId(), i ); } //姓名 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].name); CtrlAddItemToCoolBarList_Lable(this, pListItem, NAME_X, NAME_Y, 0, NAME_FONT, pszString, RGB_COLOR_LIGHTBLUE); //悄悄话 if(Response->Array[i].is_whisper != 0) { gItemData[i].bWhisper = TRUE; CtrlAddItemToCoolBarList_Image(this, pListItem, WHISPER_X, WHISPER_Y , 49, 15, (TBitmap*)TResource::LoadConstBitmap(APP_RE_ID_BITMAP_whisper)); } //内容,去掉html格式化内容 StrRemoveAtoB(Response->Array[i].content, strlen(Response->Array[i].content), "<", ">"); TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].content); CtrlAddItemToCoolBarList_RichView(this, pListItem, CONTENT_X, CONTENT_Y, CONTENT_W, &nHeigh, CONTENT_FONT, pszString); //时间 TUString::StrUtf8ToStrUnicode(pszString , (const Char *)Response->Array[i].time); CtrlAddItemToCoolBarList_Lable(this, pListItem, TIME_X, CONTENT_Y+nHeigh, 0, TIME_FONT, pszString, RGB_COLOR_GRAY); //回复 if(Response->Array[i].uid != RenRenUserInfo.uid) { TUString::StrCopy(pszString,TResource::LoadConstString(APP_RE_ID_STRING_Reply)); gItemData[i].TButtonReplyID = CtrlAddItemToCoolBarList_Button(this, pListItem, BUTTON_REPLY_X, BUTTON_REPLY_Y, BUTTON_REPLY_W, BUTTON_REPLY_H, pszString); } //设置CoolBarList Item的高度 pListItem->SetHeight(60 + nHeigh); //保存id gItemData[i].id = Response->Array[i].id; gItemData[i].uid = Response->Array[i].uid; } } pRowList->EndUpdate(); delete Response; Response = NULL; } else { //显示无权限操作的情况(用户设置了阅读权限) if(nErrorCode == 200) { TUChar ErrorInfo[ERROR_INFO_LEN] = {0}; int iResult = RenRenAPI_JsonParse_bSuccess(RR_GuestbookGet, ErrorInfo); if(iResult != 0) { if(TUString::StrLen(ErrorInfo) > 0) { //显示错误提示 TBarListItem* lpItem = NULL; lpItem = pBarRow->AppendItem(); if (lpItem) { CtrlAddItemToCoolBarList_Lable(this, lpItem, RR_INFO_X, RR_INFO_Y, RR_INFO_W, FONT_NORMAL, (TUChar*)ErrorInfo); lpItem->SetHeight(RR_INFO_H); lpItem->SetEnabled(FALSE); } } } } } return TRUE; }
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); pStateTime->SetTransparent(TRUE); //pStateTime->SetCaption(pszStateTime, FALSE); pStateTime->SetEnabled(TRUE); if(strcmp(Response->friends[0].state,"")==0) { TUString::StrCat(pszStateTime, TUSTR_Kx_Left_Parenthesis); TUString::StrCat(pszStateTime, TResource::LoadConstString(APP_KA_ID_STRING_NoState)); TUString::StrCat(pszStateTime, TUSTR_Kx_Right_Parenthesis); pStateTime->SetCaption(pszStateTime, FALSE); } else { TUChar* pszDateTime = NULL; cUnixTime_ConvertUnixTimeToFormatString( Response->friends[0].statetime, KX_TIME_FORMAT_YY_MM_DD, &pszDateTime ); if(pszDateTime != NULL) { TUString::StrCat(pszStateTime, TUSTR_Kx_Left_Parenthesis); TUString::StrCat(pszStateTime, pszDateTime); TUString::StrCat(pszStateTime, TUSTR_Kx_Right_Parenthesis); } pStateTime->SetCaption(pszStateTime, FALSE); if(pszDateTime != NULL) { delete pszDateTime; pszDateTime = NULL; } } } //Set InfoCoolBar Ctrls data //基本信息 objFontType.Create(14, 14); /*"性别"*/ TLabel* pGenderLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_GenderLbl)); TLabel* pGenderValueLble = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_GenderValueLbl)); if(pGenderLbl) { pGenderLbl->SetFont(objFontType); pGenderLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pGenderValueLble) { pGenderValueLble->SetFont(objFontType); if(Response->friends[0].gender == 1) { pGenderValueLble->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_Female),FALSE); } else { pGenderValueLble->SetCaption(TResource::LoadConstString(APP_KA_ID_STRING_Male),FALSE); } } /*"出生日期"*/ TUChar pszBirthdayValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszBirthdayValue , (const Char *)Response->friends[0].birthday); TLabel* pBirthdayLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_BirthdayLbl)); TLabel* pBirthdayValueLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_BirthdayValueLbl)); if(pBirthdayLbl) { pBirthdayLbl->SetFont(objFontType); pBirthdayLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pBirthdayValueLbl) { pBirthdayValueLbl->SetFont(objFontType); pBirthdayValueLbl->SetCaption(pszBirthdayValue,FALSE); } /*"现居住地"*/ TUChar pszCityValue[64] = {0}; TUString::StrUtf8ToStrUnicode(pszCityValue , (const Char *)Response->friends[0].city); TLabel* pCityLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CityLbl)); TRichView* pCityValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CityValueView)); if(pCityLbl) { pCityLbl->SetFont(objFontType); pCityLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pCityValueView) { pCityValueView->SetCaption(pszCityValue,FALSE); pCityValueView->SetFont(objFontType); pCityValueView->SetWordWrapAttr(TRUE); pCityValueView->SetTransparent(TRUE); pCityValueView->SetEnabled(FALSE); pCityValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pCityValueView->SetMaxVisibleLines(pCityValueView->GetLinesCount(), TRUE); pCityValueView->GetBounds(&Rc_Temp); } /*" 家乡"*/ TUChar pszHomeTownValue[256*3] = {0}; TUString::StrUtf8ToStrUnicode(pszHomeTownValue , (const Char *)Response->friends[0].hometown); TLabel* pHomeTownLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_HomeTownLbl)); TRichView* pHomeTownValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_HomeTownValueView)); if(pHomeTownLbl) { pHomeTownLbl->SetFont(objFontType); pHomeTownLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pHomeTownValueView) { pHomeTownValueView->SetCaption(pszHomeTownValue,FALSE); pHomeTownValueView->SetFont(objFontType); pHomeTownValueView->SetWordWrapAttr(TRUE); pHomeTownValueView->SetTransparent(TRUE); pHomeTownValueView->SetEnabled(FALSE); pHomeTownValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pHomeTownValueView->SetMaxVisibleLines(pHomeTownValueView->GetLinesCount(), TRUE); pHomeTownValueView->GetBounds(&Rc_Temp); } /*"兴趣爱好"*/ TUChar pszInterestValue[1024*3] = {0}; TUString::StrUtf8ToStrUnicode(pszInterestValue , (const Char *)Response->friends[0].interest); TLabel* pInterestLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_InterestLbl)); TRichView* pInterestValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_InterestValueView)); if(pInterestLbl) { pInterestLbl->SetFont(objFontType); pInterestLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pInterestValueView) { pInterestValueView->SetCaption(pszInterestValue,FALSE); pInterestValueView->SetFont(objFontType); pInterestValueView->SetWordWrapAttr(TRUE); pInterestValueView->SetTransparent(TRUE); pInterestValueView->SetEnabled(FALSE); pInterestValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pInterestValueView->SetMaxVisibleLines(pInterestValueView->GetLinesCount(), TRUE); pInterestValueView->GetBounds(&Rc_Temp); } //其他信息 /*"手机"*/ TUChar pszMobileValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszMobileValue , (const Char *)Response->friends[0].mobile); TLabel* pMobileLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MobileLbl)); TRichView* pMobileValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MobileValueView)); if(pMobileLbl) { pMobileLbl->SetFont(objFontType); pMobileLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pMobileValueView) { pMobileValueView->SetCaption(pszMobileValue,FALSE); pMobileValueView->SetFont(objFontType); pMobileValueView->SetWordWrapAttr(TRUE); pMobileValueView->SetTransparent(TRUE); pMobileValueView->SetEnabled(FALSE); pMobileValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pMobileValueView->SetMaxVisibleLines(pMobileValueView->GetLinesCount(), TRUE); pMobileValueView->GetBounds(&Rc_Temp); } /*"电话"*/ TUChar pszTelValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszTelValue , (const Char *)Response->friends[0].tel); TLabel* pTelLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_TelLbl)); TRichView* pTelValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_TelValueView)); if(pTelLbl) { pTelLbl->SetFont(objFontType); pTelLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pTelValueView) { pTelValueView->SetCaption(pszTelValue,FALSE); pTelValueView->SetFont(objFontType); pTelValueView->SetWordWrapAttr(TRUE); pTelValueView->SetTransparent(TRUE); pTelValueView->SetEnabled(FALSE); pTelValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pTelValueView->SetMaxVisibleLines(pTelValueView->GetLinesCount(), TRUE); pTelValueView->GetBounds(&Rc_Temp); } /*"QQ号"*/ TUChar pszQQValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszQQValue , (const Char *)Response->friends[0].qq); TLabel* pQQLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_QQLbl)); TRichView* pQQValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_QQValueView)); if(pQQLbl) { pQQLbl->SetFont(objFontType); pQQLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pQQValueView) { pQQValueView->SetCaption(pszQQValue,FALSE); pQQValueView->SetFont(objFontType); pQQValueView->SetWordWrapAttr(TRUE); pQQValueView->SetTransparent(TRUE); pQQValueView->SetEnabled(FALSE); pQQValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pQQValueView->SetMaxVisibleLines(pQQValueView->GetLinesCount(), TRUE); pQQValueView->GetBounds(&Rc_Temp); } /*"MSN账号"*/ TUChar pszMSNValue[128] = {0}; TUString::StrUtf8ToStrUnicode(pszMSNValue , (const Char *)Response->friends[0].msn); TLabel* pMSNLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MSNLbl)); TRichView* pMSNValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_MSNValueView)); if(pMSNLbl) { pMSNLbl->SetFont(objFontType); pMSNLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pMSNValueView) { pMSNValueView->SetCaption(pszMSNValue,FALSE); pMSNValueView->SetFont(objFontType); pMSNValueView->SetWordWrapAttr(TRUE); pMSNValueView->SetTransparent(TRUE); pMSNValueView->SetEnabled(FALSE); pMSNValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pMSNValueView->SetMaxVisibleLines(pMSNValueView->GetLinesCount(), TRUE); } /*"地址"*/ TUChar pszAddressValue[1024] = {0}; TUString::StrUtf8ToStrUnicode(pszAddressValue , (const Char *)Response->friends[0].address); TLabel* pAddressLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_AddressLbl)); TRichView* pAddressValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_AddressValueView)); if(pAddressLbl) { pAddressLbl->SetFont(objFontType); pAddressLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pAddressValueView) { pAddressValueView->SetCaption(pszAddressValue,FALSE); pAddressValueView->SetFont(objFontType); pAddressValueView->SetWordWrapAttr(TRUE); pAddressValueView->SetTransparent(TRUE); pAddressValueView->SetEnabled(FALSE); pAddressValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pAddressValueView->SetMaxVisibleLines(pAddressValueView->GetLinesCount(), TRUE); pAddressValueView->GetBounds(&Rc_Temp); } /*"邮编"*/ TUChar pszZipValue[32] = {0}; TUString::StrUtf8ToStrUnicode(pszZipValue , (const Char *)Response->friends[0].zip); TLabel* pZipLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_ZipLbl)); TRichView* pZipValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_ZipValueView)); if(pZipLbl) { pZipLbl->SetFont(objFontType); pZipLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pZipValueView) { pZipValueView->SetCaption(pszZipValue,FALSE); pZipValueView->SetFont(objFontType); pZipValueView->SetWordWrapAttr(TRUE); pZipValueView->SetTransparent(TRUE); pZipValueView->SetEnabled(FALSE); pZipValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pZipValueView->SetMaxVisibleLines(pZipValueView->GetLinesCount(), TRUE); pZipValueView->GetBounds(&Rc_Temp); } /*"电子邮件"*/ TUChar pszEmailValue[128] = {0}; TUString::StrUtf8ToStrUnicode(pszEmailValue , (const Char *)Response->friends[0].email); TLabel* pEmailLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EmailLbl)); TRichView* pEmailValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EmailValueView)); if(pEmailLbl) { pEmailLbl->SetFont(objFontType); pEmailLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pEmailValueView) { pEmailValueView->SetCaption(pszEmailValue,FALSE); pEmailValueView->SetFont(objFontType); pEmailValueView->SetWordWrapAttr(TRUE); pEmailValueView->SetTransparent(TRUE); pEmailValueView->SetEnabled(FALSE); pEmailValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pEmailValueView->SetMaxVisibleLines(pEmailValueView->GetLinesCount(), TRUE); pEmailValueView->GetBounds(&Rc_Temp); } /*"教育背景"*/ TUChar pszEduValue[1024] = {0}; for(int i=0; i<Response->friends[0].nSize_education; i++) { TUChar pszTemp[128*3] = {0}; TUChar pszYear[32] = {0}; //院校名 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].education[i].school); TUString::StrCat(pszEduValue,pszTemp); TUString::StrCat(pszEduValue, TUSTR_Kx_Empty_Cell); //班级 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].education[i].classEx); TUString::StrCat(pszEduValue,pszTemp); TUString::StrCat(pszEduValue, TUSTR_Kx_Ellipsis); //届 TUString::StrUtf8ToStrUnicode(pszYear , (const Char *)Response->friends[0].education[i].year); TUString::StrCat(pszEduValue,pszYear); TUString::StrCat(pszEduValue, (const TUChar*)TUSTR_Kx_Newline_Character); } TLabel* pEduLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EduLbl)); TRichView* pEduValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_EduValueView)); if(pEduLbl) { pEduLbl->SetFont(objFontType); pEduLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pEduValueView) { pEduValueView->SetCaption(pszEduValue,FALSE); pEduValueView->SetFont(objFontType); pEduValueView->SetWordWrapAttr(TRUE); pEduValueView->SetTransparent(TRUE); pEduValueView->SetEnabled(FALSE); pEduValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pEduValueView->SetMaxVisibleLines(pEduValueView->GetLinesCount(), TRUE); pEduValueView->GetBounds(&Rc_Temp); } /*"工作经历"*/ TUChar pszCareerValue[1024] = {0}; for(int i=0; i<Response->friends[0].nSize_career; i++) { TUChar pszTemp[128*3] = {0}; TUChar pszYear[8] = {0}; TUChar pszMonth[8] = {0}; //公司名 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].career[i].company); TUString::StrCat(pszCareerValue,pszTemp); TUString::StrCat(pszCareerValue, TUSTR_Kx_Empty_Cell); //部门名 TUString::StrUtf8ToStrUnicode(pszTemp , (const Char *)Response->friends[0].career[i].dept); TUString::StrCat(pszCareerValue,pszTemp); TUString::StrCat(pszCareerValue, TUSTR_Kx_Empty_Cell); //开始年月 TUString::StrUtf8ToStrUnicode(pszYear , (const Char *)Response->friends[0].career[i].beginyear); TUString::StrCat(pszCareerValue,pszYear); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Year)); TUString::StrUtf8ToStrUnicode(pszMonth , (const Char *)Response->friends[0].career[i].beginmonth); TUString::StrCat(pszCareerValue,pszMonth); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Month)); //分隔符- TUString::StrCat(pszCareerValue, TUSTR_Kx_Separator); //结束年月 TUString::StrUtf8ToStrUnicode(pszYear , (const Char *)Response->friends[0].career[i].endyear); if(TUString::StrLen(pszYear)==0) { TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Now)); } else { TUString::StrCat(pszCareerValue,pszYear); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Year)); TUString::StrUtf8ToStrUnicode(pszMonth , (const Char *)Response->friends[0].career[i].endmonth); TUString::StrCat(pszCareerValue,pszMonth); TUString::StrCat(pszCareerValue, TResource::LoadConstString(APP_KA_ID_STRING_Month)); } TUString::StrCat(pszCareerValue, (const TUChar*)TUSTR_Kx_Newline_Character); } TLabel* pCareerLbl = static_cast<TLabel*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CareerLbl)); TRichView* pCareerValueView = static_cast<TRichView*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_CareerValueView)); if(pCareerLbl) { pCareerLbl->SetFont(objFontType); pCareerLbl->SetColor(CTL_COLOR_TYPE_FORE, GRAY); } if(pCareerValueView) { pCareerValueView->SetCaption(pszCareerValue,FALSE); pCareerValueView->SetFont(objFontType); pCareerValueView->SetWordWrapAttr(TRUE); pCareerValueView->SetTransparent(TRUE); pCareerValueView->SetEnabled(FALSE); pCareerValueView->SetScrollBarMode(CTL_SCL_MODE_NONE); pCareerValueView->SetMaxVisibleLines(pCareerValueView->GetLinesCount(), TRUE); pCareerValueView->GetBounds(&Rc_Temp); } } }
bool CCImage::initWithString( const char * pText, int nWidth/* = 0*/, int nHeight/* = 0*/, ETextAlign eAlignMask/* = kAlignCenter*/, const char * pFontName/* = nil*/, int nSize/* = 0*/) { bool bRet = false; TUChar* pWText = NULL; do { CC_BREAK_IF(! pText); int nLen = strlen(pText) + 1; CC_BREAK_IF(! (pWText = new TUChar[nLen])); TUString::StrGBToUnicode(pWText, (Char*)pText); BitmapDC& dc = sharedBitmapDC(); dc.setFont(pFontName, nSize); TSize size(nWidth, nHeight); dc.getTextExtentPoint(pWText, nLen, size); CC_BREAK_IF(! size.Width() || ! size.Height()); // set style UInt32 styles = GUI_API_STYLE_SPECIFY_FORE_COLOR | GUI_API_STYLE_ROP_MODE_TRANSPARENT | GUI_API_STYLE_CLIP_WORDWRAP | GUI_API_STYLE_SPECIFY_BACK_COLOR | GUI_API_STYLE_SPECIFY_FONT; switch (eAlignMask) { case kAlignCenter: styles |= GUI_API_STYLE_ALIGNMENT_CENTER | GUI_API_STYLE_ALIGNMENT_MIDDLE; break; case kAlignTop: styles |= GUI_API_STYLE_ALIGNMENT_CENTER | GUI_API_STYLE_ALIGNMENT_TOP; break; case kAlignTopRight: styles |= GUI_API_STYLE_ALIGNMENT_RIGHT | GUI_API_STYLE_ALIGNMENT_TOP; break; case kAlignRight: styles |= GUI_API_STYLE_ALIGNMENT_RIGHT | GUI_API_STYLE_ALIGNMENT_MIDDLE; break; case kAlignBottomRight: styles |= GUI_API_STYLE_ALIGNMENT_RIGHT | GUI_API_STYLE_ALIGNMENT_BOTTOM; break; case kAlignBottom: styles |= GUI_API_STYLE_ALIGNMENT_CENTER | GUI_API_STYLE_ALIGNMENT_BOTTOM; break; case kAlignBottomLeft: styles |= GUI_API_STYLE_ALIGNMENT_LEFT | GUI_API_STYLE_ALIGNMENT_BOTTOM; break; case kAlignLeft: styles |= GUI_API_STYLE_ALIGNMENT_LEFT | GUI_API_STYLE_ALIGNMENT_MIDDLE; break; case kAlignTopLeft: styles |= GUI_API_STYLE_ALIGNMENT_LEFT | GUI_API_STYLE_ALIGNMENT_TOP; } CC_BREAK_IF(! dc.drawText(pWText, nLen, size, styles)); // init image information TBitmap * pBitmap = dc.getBitmap(); CC_BREAK_IF(! pBitmap); INT32 nWidth = pBitmap->GetWidth(); INT32 nHeight = pBitmap->GetHeight(); CC_BREAK_IF(nWidth <= 0 || nHeight <= 0); INT32 nDataLen = pBitmap->GetRowBytes() * nHeight; m_pData.reset(new ccxByte[nDataLen]); CC_BREAK_IF(! m_pData.get()); memcpy((void*) m_pData.get(), pBitmap->GetDataPtr(), nDataLen); m_nWidth = (ccxInt16)nWidth; m_nHeight = (ccxInt16)nHeight; m_bHasAlpha = true; m_bPreMulti = true; m_nBitsPerComponent = pBitmap->GetDepth() / 4; bRet = true; } while (0); if (pWText) { delete [] pWText; pWText = NULL; } return bRet; }
template<typename I, typename O> int denoiseModifiedNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, bool dump = true) { ModifiedNLMeansDenoiser<I, O> *denoiser = new ModifiedNLMeansDenoiser<I, O>(r, f, k, sigma, dump); TBitmap<I> *inputA = new TBitmap<I>; //BitmapI *inputsppA = new BitmapI; TBitmap<I> *inputsppA = new TBitmap<I>; TBitmap<I> *inputvarA = new TBitmap<I>; TBitmap<I> *inputvarsA = new TBitmap<I>; TBitmap<I> *inputB = new TBitmap<I>; //BitmapI *inputsppB = new BitmapI; TBitmap<I> *inputsppB = new TBitmap<I>; TBitmap<I> *inputvarB = new TBitmap<I>; TBitmap<I> *inputvarsB = new TBitmap<I>; Assert(inputA->loadBitmap(inputfile + "_A", inputtype), "Input bitmap A failed to load!"); Assert(inputsppA->loadBitmap(inputfile + "_spp_A", inputtype), "Input spp bitmap A failed to load!"); Assert(inputvarA->loadBitmap(inputfile + "_variance_A", inputtype), "Input variance bitmap A failed to load!"); Assert(inputvarsA->loadBitmap(inputfile + "_variance_square_A", inputtype), "Input variance square bitmap A failed to load!"); Assert(inputB->loadBitmap(inputfile + "_B", inputtype), "Input bitmap B failed to load!"); Assert(inputsppB->loadBitmap(inputfile + "_spp_B", inputtype), "Input spp bitmap B failed to load!"); Assert(inputvarsB->loadBitmap(inputfile + "_variance_square_B", inputtype), "Input variance square bitmap B failed to load!"); Assert(inputvarB->loadBitmap(inputfile + "_variance_B", inputtype), "Input variance bitmap B failed to load!"); DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), inputA->getSize(), 1, false, inputA, inputsppA, inputvarA, inputvarsA)); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), inputB->getSize(), 1, false, inputB, inputsppB, inputvarB, inputvarsB)); DenoiserOutput<O> *dOutput = denoiser->denoise(dInput); LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration()); dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype); inputA->unloadBitmap(); inputsppA->unloadBitmap(); inputvarA->unloadBitmap(); inputvarsA->unloadBitmap(); inputB->unloadBitmap(); inputsppB->unloadBitmap(); inputvarB->unloadBitmap(); inputvarsB->unloadBitmap(); std::cin.get(); _CrtDumpMemoryLeaks(); // prints mem leaks return 0; }
// 窗口事件处理 Boolean TPagesGetListForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_PhotoDownload: { TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap != NULL) { TMaskButton* pMyHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(gItemData[notifyData.nParam].MaskButtonID)); if(pMyHeadMBtn != NULL) { if( gItemData[notifyData.nParam].pBmp != NULL) { gItemData[notifyData.nParam].pBmp->Destroy(); gItemData[notifyData.nParam].pBmp = NULL; } gItemData[notifyData.nParam].pBmp = pDownLoadBitmap->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[notifyData.nParam].pBmp->QuickSpecialZoom(pDownLoadBitmap, 0, 0); pMyHeadMBtn->SetImage(gItemData[notifyData.nParam].pBmp, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmp->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmp->GetHeight())/2 ); pMyHeadMBtn->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } } break; default: break; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TUserInfoDetailForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; break; } case EVENT_WinClose: { _OnWinClose(pApp, pEvent); break; } case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); TRectangle rcBack(5, 142, 310, 314); GetBounds(&rcBack); // 擦除 dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_title_bg), 0, 0, SCR_W, GUI_API_STYLE_ALIGNMENT_LEFT); //dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_KA_ID_BITMAP_bottom_bg), 0, rcBack.Bottom()-44, //320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); pEraseEvent->result = 1; bHandled = TRUE; } break; case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); break; } //下载完成消息 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); switch(notifyData.nAccessType) { case KX_PhotoDownload: { if(pPhotoBmp != NULL) { pPhotoBmp->Destroy(); pPhotoBmp = NULL; } TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); TMaskButton* pHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(APP_KA_ID_UserInfoDetailForm_UserDetailHeadMaskButton)); if(pDownLoadBitmap) { TRectangle rc; pHeadMBtn->GetBounds(&rc); pPhotoBmp = TBitmap::Create(PHOTO_W, PHOTO_H, pDownLoadBitmap->GetDepth()); pPhotoBmp->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pHeadMBtn->SetImage(pPhotoBmp,(rc.Width()-pPhotoBmp->GetWidth())/2, (rc.Height()-pPhotoBmp->GetHeight())/2); pHeadMBtn->Draw(); //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } break; } default: break; } bHandled = TRUE; break; } case EVENT_KeyCommand: { // 抓取右软键事件 if (pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG) { // 模拟退出按钮选中消息 HitControl(m_BackBtn); bHandled = TRUE; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
// 窗口事件处理 Boolean TGuestbookGetForm::EventHandler(TApplication * pApp, EventType * pEvent) { Boolean bHandled = FALSE; switch (pEvent->eType) { //窗口创建 case EVENT_WinInit: { _OnWinInitEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口关闭 case EVENT_WinClose: { _OnWinClose(pApp, pEvent); } break; //点击控件 case EVENT_CtrlSelect: { bHandled = _OnCtrlSelectEvent(pApp, pEvent); } break; //控件获取焦点 case EVENT_CtrlSetFocus: { bHandled = _OnCtrlSetFocusEvent(pApp, pEvent); } break; //控件丢失焦点 case EVENT_CtrlKillFocus : { bHandled = _OnCtrlKillFocusEvent(pApp, pEvent); } break; //输入框内容变化 case EVENT_FieldChanged: { _OnFldChangedEvent(pApp, pEvent); bHandled = TRUE; } break; //窗口的背景 case EVENT_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); dc.SetBackColor(RGB_COLOR_FORM_BACKGROUND); dc.EraseRectangle(&rc, 0); dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_title_bg), 0, 0, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); if(m_FormMode == FORM_MODE_MYHOME) dc.DrawBitmapsH(TResource::LoadConstBitmap(APP_RE_ID_BITMAP_Bottom_btn_bg), 0, BOTTOM_TAB_Y, SCR_W,GUI_API_STYLE_ALIGNMENT_LEFT); pEraseEvent->result = 1; bHandled = TRUE; } break; // 右软键事件 case EVENT_KeyCommand: { if( pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_UP || pEvent->sParam1 == SYS_KEY_SOFTKEY_RIGHT_LONG ) { // 模拟标题栏右按钮选中消息 HitControl(m_TitleBtnRight); bHandled = TRUE; } } break; //下载完成事件 case MSG_DL_THREAD_NOTIFY: { NotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(NotifyMsgDataType)); bHandled = TRUE; switch(notifyData.nAccessType) { case RR_PhotoDownload: { if(notifyData.nParam == FEED_PROFILE_IMAGE_INDEX) { //下载完后更新对应的图片 TBitmap* pDownLoadBitmap = NULL; pDownLoadBitmap = LoadImgByPath(notifyData.pszFilePath); if(pDownLoadBitmap) { TMaskButton* pLogo = NULL; pLogo = static_cast<TMaskButton*>(GetControlPtr(m_ProfileImageID)); if(pLogo) { TRectangle rc; pLogo->GetBounds(&rc); if( pProfileImage != NULL) { pProfileImage->Destroy(); pProfileImage = NULL; } pProfileImage = TBitmap::Create(RR_HEAD_W, RR_HEAD_W, pDownLoadBitmap->GetDepth()); pProfileImage->QuickZoom(pDownLoadBitmap, TRUE, TRUE,RGBA(0,0,0,255)); pLogo->SetCaption(TUSTR_Re_NULL,0,0); pLogo->SetImage(pProfileImage, (rc.Width()-pProfileImage->GetWidth())/2, (rc.Height()-pProfileImage->GetHeight())/2); pLogo->Draw(); } //释放图片 pDownLoadBitmap->Destroy(); pDownLoadBitmap = NULL; } break; } if( gItemData[notifyData.nParam].pBmp != NULL) { gItemData[notifyData.nParam].pBmp->Destroy(); gItemData[notifyData.nParam].pBmp = NULL; } if( gItemData[notifyData.nParam].pBmpZoom!= NULL) { gItemData[notifyData.nParam].pBmpZoom->Destroy(); gItemData[notifyData.nParam].pBmpZoom = NULL; } gItemData[notifyData.nParam].pBmp= LoadImgByPath(notifyData.pszFilePath); if(gItemData[notifyData.nParam].pBmp != NULL) { TMaskButton* pMyHeadMBtn = static_cast<TMaskButton*>(GetControlPtr(gItemData[notifyData.nParam].HeadMaskButtonID)); if(pMyHeadMBtn != NULL) { gItemData[notifyData.nParam].pBmpZoom = gItemData[notifyData.nParam].pBmp->Create(HEADPHOTO_W, HEADPHOTO_H, 32); gItemData[notifyData.nParam].pBmpZoom->QuickSpecialZoom(gItemData[notifyData.nParam].pBmp, 0, 0); pMyHeadMBtn->SetImage(gItemData[notifyData.nParam].pBmpZoom, (HEADMASKBUTTON_W - gItemData[notifyData.nParam].pBmpZoom->GetWidth())/2, (HEADMASKBUTTON_H - gItemData[notifyData.nParam].pBmpZoom->GetHeight())/2 ); pMyHeadMBtn->Draw(); } } break; } case RR_GuestbookPost: { pApp->MessageBox(TResource::LoadConstString(APP_RE_ID_STRING_Success), TResource::LoadConstString(APP_RE_ID_STRING_SendComment), WMB_OK); RenRenAPICommon_Download(RR_GuestbookGet, this->GetWindowHwndId(), 0, m_FormMode); break; } case RR_UsersGetInfoPhoto: { tResponseUsersGetInfo* Response = NULL; RenRenAPI_JsonParse(RR_UsersGetInfoPhoto, (void **)&Response); if(Response) { _UpdateProfilePhoto(pApp, Response); delete Response; Response = NULL; } } break; default: break; } } break; case MSG_POST_THREAD_NOTIFY: { PostNotifyMsgDataType notifyData; Sys_GetMessageBody((MESSAGE_t *)pEvent, ¬ifyData, sizeof(PostNotifyMsgDataType)); //if(notifyData.nEditType == NewBlogEdit) { char* uid = Get_Url_Params(RR_GuestbookGet, "uid"); Set_Url_Params(RR_GuestbookPost, "uid", uid); Set_Url_Params(RR_GuestbookPost, "content", (char*)notifyData.pszEditContent); //留言是否为悄悄话,1表示是,0表示否,缺省值为0 if(notifyData.bPrivacy == TRUE) Set_Url_Params(RR_GuestbookPost, "type", "1"); else Set_Url_Params(RR_GuestbookPost, "type", "0"); //回复他人的留言需要传rid if(bReply) { char rid[64] = {0}; sprintf(rid, "%d", gItemData[m_SelectReplyItem].uid); Set_Url_Params(RR_GuestbookPost, "rid", rid); } else { Set_Url_Params(RR_GuestbookPost, "rid", ""); } //当回复公共主页的留言时需要传reply_gossip_id //TUChar sID[64]={0}; //Char id[64]={0}; //TUString::StrI64ToA(sID,(Int64)gItemData[m_SelectReplyItem].id); //TUString::StrUnicodeToStrUtf8(id,sID); char id[64] = {0}; DoubleToChar(gItemData[m_SelectReplyItem].id, id); Set_Url_Params(RR_GuestbookPost, "reply_gossip_id", (char*)id); RenRenAPICommon_Download(RR_GuestbookPost, this->GetWindowHwndId(), 0, 0); } bHandled = TRUE; break; } default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
void ButtonControl::OnPaint(DibBitmap *pbm) { Rect rcForm; m_pfrm->GetRect(&rcForm); bool fSelected = m_pfrm->IsControlInside(this); if (m_ptbmDown != NULL && m_ptbmUp != NULL) { // Draw up / down image (if present) TBitmap *ptbm; if (m_wf & kfCtlDisabled) ptbm = m_ptbmDisabled; else ptbm = fSelected ? m_ptbmDown : m_ptbmUp; ptbm->BltTo(pbm, m_rc.left + rcForm.left, m_rc.top + rcForm.top, m_wf & kfCtlUseSide1Colors ? kside1 : ksideNeutral); // Center the text (if present) if (m_szLabel[0] != 0) { Font *pfnt = gapfnt[m_nfnt]; int cx = pfnt->GetTextExtent(m_szLabel); int cy = pfnt->GetHeight(); int x = m_rc.left + (m_rc.Width() - cx + 1) / 2; int y = m_rc.top + (m_rc.Height() - cy + gcxyBorder) / 2; if (fSelected) { x++; y++; } gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top); } } else { #if 0 // old-style filled-rect buttons Rect rcT = m_rc; rcT.Offset(rcForm.left, rcForm.top); int cxyBorder2x = gcxyBorder * 2; pbm->Fill(rcT.left + gcxyBorder, rcT.top + gcxyBorder, rcT.Width() - cxyBorder2x, rcT.Height() - cxyBorder2x, GetColor(fSelected ? kiclrButtonFillHighlight : kiclrButtonFill)); int iclr = GetColor(fSelected ? kiclrWhite : kiclrButtonBorder); pbm->Fill(rcT.left + gcxyBorder, rcT.top, rcT.Width() - cxyBorder2x, gcxyBorder, iclr); pbm->Fill(rcT.left, rcT.top + gcxyBorder, gcxyBorder, rcT.Height() - cxyBorder2x, iclr); pbm->Fill(rcT.right - gcxyBorder, rcT.top + gcxyBorder, gcxyBorder, rcT.Height() - cxyBorder2x, iclr); pbm->Fill(rcT.left + gcxyBorder, rcT.bottom - gcxyBorder, rcT.Width() - cxyBorder2x, gcxyBorder, iclr); if (m_szLabel[0] != 0) { Font *pfnt = gapfnt[m_nfnt]; int cx = pfnt->GetTextExtent(m_szLabel); int cy = pfnt->GetHeight(); int x = m_rc.left + (m_rc.Width() - cx + 1) / 2; int y = m_rc.top + (m_rc.Height() - cy + gcxyBorder) / 2; gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top); } #else Rect rcT = m_rc; rcT.Offset(rcForm.left, rcForm.top); TBitmap *ptbmLeft, *ptbmMid, *ptbmRight; if (!fSelected) { ptbmLeft = s_ptbmLeftUp; ptbmMid = s_ptbmMidUp; ptbmRight = s_ptbmRightUp; } else { ptbmLeft = s_ptbmLeftDown; ptbmMid = s_ptbmMidDown; ptbmRight = s_ptbmRightDown; } Size sizLeft, sizMid, sizRight; ptbmLeft->GetSize(&sizLeft); ptbmMid->GetSize(&sizMid); ptbmRight->GetSize(&sizRight); int x = rcT.left; int xRight = rcT.right - sizRight.cx; ptbmLeft->BltTo(pbm, x, rcT.top); x += sizLeft.cx; #if 0 while (x < xRight) { ptbmMid->BltTo(pbm, x, rcT.top); x += sizMid.cx; } #else ptbmMid->FillTo(0, pbm, x, rcT.top, xRight - x, rcT.Height()); x = xRight; #endif ptbmRight->BltTo(pbm, xRight, rcT.top); if (m_szLabel[0] != 0) { Font *pfnt = gapfnt[m_nfnt]; int cx = pfnt->GetTextExtent(m_szLabel); int cy = pfnt->GetHeight(); int x = m_rc.left + (m_rc.Width() - cx + 1) / 2; int y = m_rc.top + ((sizMid.cy - gapfnt[m_nfnt]->GetHeight() + 1) / 2); gapfnt[m_nfnt]->DrawText(pbm, m_szLabel, x + rcForm.left, y + rcForm.top); } #endif } }