/* ================ SV_Status_f ================ */ static void SV_Status_f(void) { int i, j, l; client_t *cl; playerState_t *ps; const char *s; int ping; // make sure server is running if (!com_sv_running->integer) { Com_Printf("Server is not running.\n"); return; } Com_Printf("cpu server utilization: %i %%\n" "avg response time : %i ms\n" "server time : %i\n" "internal time : %i\n" "map : %s\n\n" "num score ping name lastmsg address qport rate\n" "--- ----- ---- --------------- ------- --------------------- ----- -----\n", ( int ) svs.stats.cpu, ( int ) svs.stats.avg, svs.time, Sys_Milliseconds(), sv_mapname->string); // FIXME: extend player name length (>16 chars) ? - they are printed! // FIXME: do a Com_Printf per line! ... create the row at first for (i = 0, cl = svs.clients ; i < sv_maxclients->integer ; i++, cl++) { if (!cl->state && !cl->demoClient) { continue; } Com_Printf("%3i ", i); ps = SV_GameClientNum(i); Com_Printf("%5i ", ps->persistant[PERS_SCORE]); if (cl->demoClient) // if it's a democlient, we show DEMO instead of the ping (which would be 999 anyway - which is not the case in the scoreboard which show the real ping that had the player because commands are replayed!) { Com_Printf("DEMO "); } else if (cl->state == CS_CONNECTED) { Com_Printf("CNCT "); } else if (cl->state == CS_ZOMBIE) { Com_Printf("ZMBI "); } else { ping = cl->ping < 9999 ? cl->ping : 9999; Com_Printf("%4i ", ping); } Com_Printf("%s", rc(cl->name)); l = 16 - strlen(cl->name); for (j = 0 ; j < l ; j++) { Com_Printf(" "); } Com_Printf("%7i ", svs.time - cl->lastPacketTime); s = NET_AdrToString(cl->netchan.remoteAddress); Com_Printf("%s", s); l = 22 - strlen(s); for (j = 0 ; j < l ; j++) { Com_Printf(" "); } Com_Printf("%5i", cl->netchan.qport); Com_Printf(" %5i\n", cl->rate); } Com_Printf("\n"); }
BOOL CEdRptDoc::GetDataFromDB() { CDatabase db; BOOL bRet = FALSE; try { if (m_szODBCLink.IsEmpty()) { ShowMessage(m_hWnd, "没有给定数据库指针,也没有指定链接字!"); return FALSE; } if (!db.OpenEx(m_szODBCLink, CDatabase::openReadOnly | CDatabase::noOdbcDialog)) { ShowMessage(m_hWnd, "无法打开数据库连接 %s", m_szODBCLink); return FALSE; } m_nRecCount = GetRecordCount(db); CRecordset rc(&db); CString szSQL = m_szSQL; CString csHeadRight = m_szHeadRight; if (m_nRecCount > (int)m_nMaxRecordNum) { CString str; str.Format(_T("共有 %d 条记录,但模版设计最大记录数为 %d,\n是否只 %d 条记录?\n" "注意:如何选否,会给数据库很大压力,甚至取消操作!"), m_nRecCount, m_nMaxRecordNum, m_nMaxRecordNum); UINT ulSelect = IDNO; if (m_hWnd) ulSelect = MessageBox(m_hWnd, str, _T("BSRpter"), MB_YESNOCANCEL); if (ulSelect == IDNO) ; else if (ulSelect == IDCANCEL) return FALSE; else // IDYES { csHeadRight.Format(_T(" %d条记录未打印"), m_nRecCount - m_nMaxRecordNum); m_nRecCount = m_nMaxRecordNum; CString csDBDrv = getDBDriver(m_szODBCLink); csDBDrv.MakeLower(); if (csDBDrv.Find("oracle") >= 0) { CString szTmp = szSQL; szTmp.MakeLower(); int nFind = szTmp.Find(" where "); if (nFind > 0) { szTmp.Format("ROWNUM <= %d AND ", m_nMaxRecordNum); szSQL.Insert(nFind + (int)_tcslen(" where "), (LPCSTR)szTmp); } else { szTmp.Format(" WHERE ROWNUM <= %d ", m_nMaxRecordNum); szSQL += szTmp; } } else if (csDBDrv.Find("mysql") >= 0) { CString szTmp; szTmp.Format(" Limit 0, %d ", m_nMaxRecordNum); szSQL += szTmp; } else { CString str; str.Format(_T("[ %s ] 数据库无法使用修改SQL的方法限制记录个数," "而打开大数据集可能会出现异常\n,是否先修改查询条件,再进行打印?") , csDBDrv); if (m_hWnd != NULL && MessageBox(m_hWnd, str,_T("EdFc"), MB_YESNO) == IDYES) return FALSE; } } } rc.Open(CRecordset::forwardOnly, szSQL); m_nFieldCount = rc.GetODBCFieldCount(); while (m_ColFmt.GetSize() > m_nFieldCount && m_nFieldCount > 1) m_ColFmt.RemoveAt(m_ColFmt.GetSize() - 1); COLFMT cf; while (m_ColFmt.GetSize() < m_nFieldCount) m_ColFmt.Add(cf); m_Grid.DeleteAllItems(); int nRowCount = m_nRecCount + (m_bFootSum ? 2 : 1); m_Grid.SetRowCount(nRowCount); m_Grid.SetColumnCount(m_nFieldCount); // set ColumName; GV_ITEM Item; Item.mask = GVIF_TEXT|GVIF_FORMAT; Item.row = 0; Item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX; for (Item.col = 0; Item.col < m_nFieldCount; Item.col++) { m_Grid.SetColumnWidth(Item.col, m_ColFmt[Item.col].width); Item.szText = m_ColFmt[Item.col].name; if (m_ColFmt[Item.col].name.IsEmpty()) { CODBCFieldInfo fi; rc.GetODBCFieldInfo(Item.col, fi); Item.szText = fi.m_strName; } m_Grid.SetItem(&Item); } if (m_hWnd != NULL && m_nRecCount > 0) ::SendMessage(m_hWnd, WM_CREATEPROGRESS, m_nRecCount, 0); CDBVariant varValue; Item.mask = GVIF_TEXT|GVIF_FORMAT; Item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS|DT_NOPREFIX; for(int row = 0; row < m_nRecCount; row ++) { for (int col = 0; col < m_nFieldCount; col ++) { rc.GetFieldValue(col, varValue); Item.row = row + 1; Item.col = col; Item.szText = GetVarStr(&varValue, m_ColFmt[col].format); m_Grid.SetItem(&Item); varValue.Clear(); } if (m_hWnd != NULL) ::SendMessage(m_hWnd, WM_STEPPROGRESS, m_nRecCount, row); rc.MoveNext(); } if (m_bFootSum) GetStaticData(rc); rc.Close(); if (m_hWnd != NULL) ::SendMessage(m_hWnd, WM_DESTROYPROGRESS, 0, 0); bRet = TRUE; } catch(CException *edb) { static TCHAR lpszError[MAX_PATH]; CString csError; if (edb->GetErrorMessage(lpszError, MAX_PATH)) csError = lpszError; if (csError.GetLength() <= 0) csError = _T("无法获得数据!"); ShowMessage(m_hWnd, csError); edb->Delete(); } catch(...) { ShowMessage(m_hWnd, _T("无法获得数据!")); } return bRet; }
// 窗口事件处理 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; }
void eListboxPythonMultiContent::paint(gPainter &painter, eWindowStyle &style, const ePoint &offset, int selected) { gRegion itemregion(eRect(offset, m_itemsize)); eListboxStyle *local_style = 0; eRect sel_clip(m_selection_clip); bool cursorValid = this->cursorValid(); if (sel_clip.valid()) sel_clip.moveBy(offset); /* get local listbox style, if present */ if (m_listbox) local_style = m_listbox->getLocalStyle(); painter.clip(itemregion); clearRegion(painter, style, local_style, ePyObject(), ePyObject(), ePyObject(), ePyObject(), selected, itemregion, sel_clip, offset, cursorValid); ePyObject items, buildfunc_ret; if (m_list && cursorValid) { /* a multicontent list can be used in two ways: either each item is a list of (TYPE,...)-tuples, or there is a template defined, which is a list of (TYPE,...)-tuples, and the list is an unformatted tuple. The template then references items from the list. */ items = PyList_GET_ITEM(m_list, m_cursor); // borrowed reference! if (m_buildFunc) { if (PyCallable_Check(m_buildFunc)) // when we have a buildFunc then call it { if (PyTuple_Check(items)) buildfunc_ret = items = PyObject_CallObject(m_buildFunc, items); else eDebug("items is no tuple"); } else eDebug("buildfunc is not callable"); } if (!items) { eDebug("eListboxPythonMultiContent: error getting item %d", m_cursor); goto error_out; } if (!m_template) { if (!PyList_Check(items)) { eDebug("eListboxPythonMultiContent: list entry %d is not a list (non-templated)", m_cursor); goto error_out; } } else { if (!PyTuple_Check(items)) { eDebug("eListboxPythonMultiContent: list entry %d is not a tuple (templated)", m_cursor); goto error_out; } } ePyObject data; /* if we have a template, use the template for the actual formatting. we will later detect that "data" is present, and refer to that, instead of the immediate value. */ int start = 1; if (m_template) { data = items; items = m_template; start = 0; } int size = PyList_Size(items); for (int i = start; i < size; ++i) { ePyObject item = PyList_GET_ITEM(items, i); // borrowed reference! if (!item) { eDebug("eListboxPythonMultiContent: ?"); goto error_out; } if (!PyTuple_Check(item)) { eDebug("eListboxPythonMultiContent did not receive a tuple."); goto error_out; } int size = PyTuple_Size(item); if (!size) { eDebug("eListboxPythonMultiContent receive empty tuple."); goto error_out; } int type = PyInt_AsLong(PyTuple_GET_ITEM(item, 0)); switch (type) { case TYPE_TEXT: // text { /* (0, x, y, width, height, fnt, flags, "bla" [, color, colorSelected, backColor, backColorSelected, borderWidth, borderColor] ) */ ePyObject px = PyTuple_GET_ITEM(item, 1), py = PyTuple_GET_ITEM(item, 2), pwidth = PyTuple_GET_ITEM(item, 3), pheight = PyTuple_GET_ITEM(item, 4), pfnt = PyTuple_GET_ITEM(item, 5), pflags = PyTuple_GET_ITEM(item, 6), pstring = PyTuple_GET_ITEM(item, 7), pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, pborderWidth, pborderColor; if (!(px && py && pwidth && pheight && pfnt && pflags && pstring)) { eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_TEXT, x, y, width, height, fnt, flags, string [, color, backColor, backColorSelected, borderWidth, borderColor])"); goto error_out; } if (size > 8) pforeColor = lookupColor(PyTuple_GET_ITEM(item, 8), data); if (size > 9) pforeColorSelected = lookupColor(PyTuple_GET_ITEM(item, 9), data); if (size > 10) pbackColor = lookupColor(PyTuple_GET_ITEM(item, 10), data); if (size > 11) pbackColorSelected = lookupColor(PyTuple_GET_ITEM(item, 11), data); if (size > 12) { pborderWidth = PyTuple_GET_ITEM(item, 12); if (pborderWidth == Py_None) pborderWidth=ePyObject(); } if (size > 13) pborderColor = lookupColor(PyTuple_GET_ITEM(item, 13), data); if (PyInt_Check(pstring) && data) /* if the string is in fact a number, it refers to the 'data' list. */ pstring = PyTuple_GetItem(data, PyInt_AsLong(pstring)); /* don't do anything if we have 'None' as string */ if (pstring == Py_None) continue; const char *string = (PyString_Check(pstring)) ? PyString_AsString(pstring) : "<not-a-string>"; int x = PyInt_AsLong(px) + offset.x(); int y = PyInt_AsLong(py) + offset.y(); int width = PyInt_AsLong(pwidth); int height = PyInt_AsLong(pheight); int flags = PyInt_AsLong(pflags); int fnt = PyInt_AsLong(pfnt); int bwidth = pborderWidth ? PyInt_AsLong(pborderWidth) : 0; if (m_font.find(fnt) == m_font.end()) { eDebug("eListboxPythonMultiContent: specified font %d was not found!", fnt); goto error_out; } eRect rect(x+bwidth, y+bwidth, width-bwidth*2, height-bwidth*2); painter.clip(rect); { gRegion rc(rect); bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor); clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear); } painter.setFont(m_font[fnt]); painter.renderText(rect, string, flags); painter.clippop(); // draw border if (bwidth) { eRect rect(eRect(x, y, width, height)); painter.clip(rect); if (pborderColor) { unsigned int color = PyInt_AsUnsignedLongMask(pborderColor); painter.setForegroundColor(gRGB(color)); } rect.setRect(x, y, width, bwidth); painter.fill(rect); rect.setRect(x, y+bwidth, bwidth, height-bwidth); painter.fill(rect); rect.setRect(x+bwidth, y+height-bwidth, width-bwidth, bwidth); painter.fill(rect); rect.setRect(x+width-bwidth, y+bwidth, bwidth, height-bwidth); painter.fill(rect); painter.clippop(); } break; } case TYPE_PROGRESS_PIXMAP: // Progress /* (1, x, y, width, height, filled_percent, pixmap [, borderWidth, foreColor, foreColorSelected, backColor, backColorSelected] ) */ case TYPE_PROGRESS: // Progress { /* (1, x, y, width, height, filled_percent [, borderWidth, foreColor, foreColorSelected, backColor, backColorSelected] ) */ ePyObject px = PyTuple_GET_ITEM(item, 1), py = PyTuple_GET_ITEM(item, 2), pwidth = PyTuple_GET_ITEM(item, 3), pheight = PyTuple_GET_ITEM(item, 4), pfilled_perc = PyTuple_GET_ITEM(item, 5), ppixmap, pborderWidth, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected; int idx = 6; if (type == TYPE_PROGRESS) { if (!(px && py && pwidth && pheight && pfilled_perc)) { eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_PROGRESS, x, y, width, height, filled percent [,border width, foreColor, backColor, backColorSelected]))"); goto error_out; } } else { ppixmap = PyTuple_GET_ITEM(item, idx++); if (ppixmap == Py_None) continue; if (!(px && py && pwidth && pheight && pfilled_perc, ppixmap)) { eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_PROGRESS_PIXMAP, x, y, width, height, filled percent, pixmap, [,border width, foreColor, backColor, backColorSelected]))"); goto error_out; } } if (size > idx) { pborderWidth = PyTuple_GET_ITEM(item, idx++); if (pborderWidth == Py_None) pborderWidth = ePyObject(); } if (size > idx) { pforeColor = PyTuple_GET_ITEM(item, idx++); if (pforeColor == Py_None) pforeColor = ePyObject(); } if (size > idx) { pforeColorSelected = PyTuple_GET_ITEM(item, idx++); if (pforeColorSelected == Py_None) pforeColorSelected=ePyObject(); } if (size > idx) { pbackColor = PyTuple_GET_ITEM(item, idx++); if (pbackColor == Py_None) pbackColor=ePyObject(); } if (size > idx) { pbackColorSelected = PyTuple_GET_ITEM(item, idx++); if (pbackColorSelected == Py_None) pbackColorSelected=ePyObject(); } int x = PyInt_AsLong(px) + offset.x(); int y = PyInt_AsLong(py) + offset.y(); int width = PyInt_AsLong(pwidth); int height = PyInt_AsLong(pheight); int filled = PyInt_AsLong(pfilled_perc); if ((filled < 0) && data) /* if the string is in a negative number, it refers to the 'data' list. */ filled = PyInt_AsLong(PyTuple_GetItem(data, -filled)); /* don't do anything if percent out of range */ if ((filled < 0) || (filled > 100)) continue; int bwidth = pborderWidth ? PyInt_AsLong(pborderWidth) : 2; eRect rect(x, y, width, height); painter.clip(rect); { gRegion rc(rect); bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor); clearRegion(painter, style, local_style, pforeColor, pforeColorSelected, pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear); } // border if (bwidth) { rect.setRect(x, y, width, bwidth); painter.fill(rect); rect.setRect(x, y+bwidth, bwidth, height-bwidth); painter.fill(rect); rect.setRect(x+bwidth, y+height-bwidth, width-bwidth, bwidth); painter.fill(rect); rect.setRect(x+width-bwidth, y+bwidth, bwidth, height-bwidth); painter.fill(rect); } rect.setRect(x+bwidth, y+bwidth, (width-bwidth*2) * filled / 100, height-bwidth*2); // progress if (ppixmap) { ePtr<gPixmap> pixmap; if (PyInt_Check(ppixmap) && data) /* if the pixmap is in fact a number, it refers to the data list */ ppixmap = PyTuple_GetItem(data, PyInt_AsLong(ppixmap)); if (SwigFromPython(pixmap, ppixmap)) { eDebug("eListboxPythonMultiContent (Pixmap) get pixmap failed"); painter.clippop(); continue; } painter.blit(pixmap, rect.topLeft(), rect, 0); } else painter.fill(rect); painter.clippop(); break; } case TYPE_PIXMAP_ALPHABLEND: case TYPE_PIXMAP_ALPHATEST: case TYPE_PIXMAP: // pixmap { /* (2, x, y, width, height, pixmap [, backColor, backColorSelected] ) */ ePyObject px = PyTuple_GET_ITEM(item, 1), py = PyTuple_GET_ITEM(item, 2), pwidth = PyTuple_GET_ITEM(item, 3), pheight = PyTuple_GET_ITEM(item, 4), ppixmap = PyTuple_GET_ITEM(item, 5), pbackColor, pbackColorSelected; if (!(px && py && pwidth && pheight && ppixmap)) { eDebug("eListboxPythonMultiContent received too small tuple (must be (TYPE_PIXMAP, x, y, width, height, pixmap [, backColor, backColorSelected] ))"); goto error_out; } if (PyInt_Check(ppixmap) && data) /* if the pixemap is in fact a number, it refers to the 'data' list. */ ppixmap = PyTuple_GetItem(data, PyInt_AsLong(ppixmap)); /* don't do anything if we have 'None' as pixmap */ if (ppixmap == Py_None) continue; int x = PyInt_AsLong(px) + offset.x(); int y = PyInt_AsLong(py) + offset.y(); int width = PyInt_AsLong(pwidth); int height = PyInt_AsLong(pheight); ePtr<gPixmap> pixmap; if (SwigFromPython(pixmap, ppixmap)) { eDebug("eListboxPythonMultiContent (Pixmap) get pixmap failed"); goto error_out; } if (size > 6) pbackColor = lookupColor(PyTuple_GET_ITEM(item, 6), data); if (size > 7) pbackColorSelected = lookupColor(PyTuple_GET_ITEM(item, 7), data); eRect rect(x, y, width, height); painter.clip(rect); { gRegion rc(rect); bool mustClear = (selected && pbackColorSelected) || (!selected && pbackColor); clearRegion(painter, style, local_style, ePyObject(), ePyObject(), pbackColor, pbackColorSelected, selected, rc, sel_clip, offset, cursorValid, mustClear); } painter.blit(pixmap, rect.topLeft(), rect, (type == TYPE_PIXMAP_ALPHATEST) ? gPainter::BT_ALPHATEST : (type == TYPE_PIXMAP_ALPHABLEND) ? gPainter::BT_ALPHABLEND : 0); painter.clippop(); break; } default: eWarning("eListboxPythonMultiContent received unknown type (%d)", type); goto error_out; } } } if (selected && !sel_clip.valid() && (!local_style || !local_style->m_selection)) style.drawFrame(painter, eRect(offset, m_itemsize), eWindowStyle::frameListboxEntry); error_out: if (buildfunc_ret) Py_DECREF(buildfunc_ret); painter.clippop(); }
void CXTPSkinObjectTrackBar::OnDraw(CDC* pDC) { CXTPClientRect rc(this); CXTPBufferDC dcMem(*pDC, rc); NMCUSTOMDRAW nm; ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_PREPAINT; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); LRESULT lrCdrf = GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); FillBackground(&dcMem, rc); if (::GetFocus() == m_hWnd && ((SendMessage(WM_QUERYUISTATE) & UISF_HIDEFOCUS) == 0)) { dcMem.SetBkColor(GetColor(COLOR_BTNHIGHLIGHT)); DrawFocusRect(dcMem, &rc); } FillDrawRect(); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPREPAINT; nm.dwItemSpec = TBCD_TICS; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } DrawTics(&dcMem); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPOSTPAINT; nm.dwItemSpec = TBCD_TICS; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPREPAINT; nm.dwItemSpec = TBCD_CHANNEL; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } DrawChannel(&dcMem); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPOSTPAINT; nm.dwItemSpec = TBCD_CHANNEL; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPREPAINT; nm.dwItemSpec = TBCD_THUMB; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } DrawThumb(&dcMem); if (lrCdrf & CDRF_NOTIFYITEMDRAW) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_ITEMPOSTPAINT; nm.dwItemSpec = TBCD_THUMB; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } if (lrCdrf & CDRF_NOTIFYPOSTPAINT) { ZeroMemory(&nm, sizeof(NMCUSTOMDRAW)); nm.hdc = dcMem.GetSafeHdc(); nm.dwDrawStage = CDDS_POSTPAINT; nm.hdr.code = NM_CUSTOMDRAW; nm.hdr.hwndFrom = GetSafeHwnd(); nm.hdr.idFrom = GetDlgCtrlID(); GetParent()->SendMessage(WM_NOTIFY, (WPARAM)GetDlgCtrlID(), (LPARAM)&nm); } }
void LegendItem::paint(QPainter *painter) { if (!isVisible()) { return; } RelationList legendItems; if (_auto) { legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList(); } else { legendItems = _relations; } int count = legendItems.count(); if (count <= 0) { // no legend or box if there are no legend items return; } QFont font(_font); font.setPointSizeF(view()->scaledFontSize(_fontScale, *painter->device())); painter->setFont(font); // generate string list of relation names QStringList names; //bool allAuto = true; bool sameX = true; bool sameYUnits = true; LabelInfo label_info = legendItems.at(0)->xLabelInfo(); QString yUnits = legendItems.at(0)->yLabelInfo().units; for (int i = 0; i<count; i++) { RelationPtr relation = legendItems.at(i); if (relation->descriptiveNameIsManual()) { //allAuto = false; } if (relation->xLabelInfo() != label_info) { sameX = false; } // sameYUnits is false if any non empty units are defined differently. if (yUnits.isEmpty()) { yUnits = relation->yLabelInfo().units; } else if (relation->yLabelInfo().units != yUnits) { if (!relation->yLabelInfo().units.isEmpty()) { sameYUnits = false; } } } // if (!allAuto) { // for (int i = 0; i<count; i++) { // names.append(legendItems.at(i)->descriptiveName()); // } // } else { // FIXME: move most of this into a new function, relation->legend_name // then create separate [legend_name] and Auto in the relation dialog. // show relation->legend_name in dialog when [x] Auto for (int i = 0; i<count; i++) { RelationPtr relation = legendItems.at(i); QString label = relation->legendName(sameX, sameYUnits); int i_dup = names.indexOf(label); if (i_dup<0) { names.append(label); } else { RelationPtr dup_relation = legendItems.at(i_dup); if (!dup_relation->yLabelInfo().file.isEmpty()) { names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().escapedFile() + ')'); } if (!relation->yLabelInfo().file.isEmpty()) { names.append(label + " (" + relation->yLabelInfo().escapedFile() + ')'); } } } QSize legendSize(0, 0); QSize titleSize(0,0); Label::Parsed *parsed = Label::parse(_title, _color); int pad = painter->fontMetrics().ascent()/4; Label::RenderContext rc(painter->font(), painter); Label::renderLabel(rc, parsed->chunk, false, false); if (!_title.isEmpty()) { titleSize.setWidth(rc.x+3*pad); titleSize.setHeight(painter->fontMetrics().height()+pad); } QList<QSize> sizes; int max_w = 0; int max_h = 0; for (int i = 0; i<count; i++) { RelationPtr relation = legendItems.at(i); QSize size; painter->save(); size = paintRelation(names.at(i), relation, painter, false); painter->restore(); sizes.append(size); max_w = qMax(max_w, size.width()); max_h = qMax(max_h, size.height()); } // determine number of rows and number of columns int n_rows = 0; int n_cols = 0; if (_verticalDisplay) { int h=titleSize.height(); for (int i = 0; i<count; i++) { h+=sizes.at(i).height(); } int max_legend_height = _plotItem->plotRect().height()*0.6+1; n_cols = qMin(count, h / max_legend_height + 1); n_rows = count / n_cols; while (n_rows*n_cols<count) { n_rows++; } } else { int w = 0; for (int i = 0; i<count; i++) { w+=sizes.at(i).width(); } int max_legend_width = _plotItem->plotRect().width()*0.8+1; n_rows = qMin(count, w / max_legend_width+1); n_cols = count/n_rows; while (n_rows*n_cols<count) { n_cols++; } } // determine the dimensions of each column QList<QSize> col_sizes; for (int i=0; i<n_cols; i++) { col_sizes.append(QSize(0,0)); } for (int i = 0; i<count; i++) { int col = i/n_rows; col_sizes[col].rheight()+= sizes.at(i).height(); col_sizes[col].setWidth(qMax(sizes.at(i).width(), col_sizes.at(col).width())); } // determine the dimensions of the legend int w = 0; int h = 0; for (int col = 0; col < n_cols; col++) { w += col_sizes.at(col).width(); h = qMax(h, col_sizes.at(col).height()); } legendSize.setHeight(h + titleSize.height()); legendSize.setWidth(qMax(titleSize.width(), w)); setViewRect(rect().x(), rect().y(), legendSize.width()+pad, legendSize.height()+pad); // Now paint everything painter->drawRect(rect()); int x=rect().x(); int y=rect().y(); if (!_title.isEmpty()) { rc.y = rect().y() + titleSize.height()-pad; rc.x = qMax(rect().x()+pad, rect().x() + legendSize.width()/2 - titleSize.width()/2); Label::renderLabel(rc, parsed->chunk, false, true); y+= titleSize.height(); } legendSize.setWidth(0); legendSize.setHeight(0); for (int i = 0; i<count; i++) { RelationPtr relation = legendItems.at(i); painter->save(); painter->translate(x,y); paintRelation(names.at(i), relation, painter, true); painter->restore(); int col = i/n_rows; int row = i%n_rows; if (row == n_rows-1) { // end of a column x += col_sizes.at(col).width(); y = rect().y() + titleSize.height(); } else { y += sizes.at(i).height(); } } delete parsed; }
void inline update(int t) { sum[t] = sum[lc(t)] + sum[rc(t)]; }
static TInt cipher_decrypt_doProcessL (sc_cipher_hd_t c, byte *outbuf, const byte *inbuf, unsigned int nbytes, int* outputLen, int last) { TInt rc(KErrNone); switch( c->mode ) { case SC_CIPHER_MODE_ECB: case SC_CIPHER_MODE_CBC: { TUint blockSize = c->iDecryptor->BlockSize(); if ((c->mode == SC_CIPHER_MODE_CBC) && nbytes%blockSize && !(nbytes > blockSize && (c->flags & SC_CIPHER_CBC_CTS))) { rc = KErrArgument; } else if ((c->mode == SC_CIPHER_MODE_ECB) && nbytes%blockSize) { rc = KErrArgument; } else { TInt outlen; if (last) outlen = c->iDecryptor->MaxFinalOutputLength(nbytes); else outlen = c->iDecryptor->MaxOutputLength(nbytes); HBufC8 *result = HBufC8::NewLC(outlen); TPtr8 resultActual= result->Des(); resultActual.FillZ(resultActual.MaxLength()); resultActual.SetLength(0); // could improve memory usage later by allocating a smaller buffer HBufC8* input = HBufC8::NewLC(nbytes); TPtrC8 inbufPtr(inbuf, nbytes); *input = inbufPtr; TInt j=0; for(; j+blockSize<nbytes; j+=blockSize) { // decryption in blocks of size blocksize c->iDecryptor->Process(input->Mid(j,blockSize), resultActual); } if (last) { c->iDecryptor->ProcessFinalL(input->Mid(j), resultActual); *outputLen = result->Size(); // we delete iDecryptor once the decryption finishes // so that the next decryption can use a different key or iv delete c->iDecryptor; c->iDecryptor = NULL; } else c->iDecryptor->Process(input->Mid(j,blockSize), resultActual); memcpy(outbuf, result->Ptr(), result->Size()); CleanupStack::PopAndDestroy(input); CleanupStack::PopAndDestroy(result); } } break; /* case SC_CIPHER_MODE_CFB: do_cfb_decrypt(c, outbuf, inbuf, nbytes ); break; case SC_CIPHER_MODE_CTR: do_ctr_decrypt(c, outbuf, inbuf, nbytes ); break; case SC_CIPHER_MODE_STREAM: c->cipher->stdecrypt ( &c->context.c, outbuf, (byte*) inbuf, nbytes ); break; case SC_CIPHER_MODE_NONE: if( inbuf != outbuf ) memmove( outbuf, inbuf, nbytes ); break; */ default: rc = KErrNotSupported; break; } return rc; }
void StupidG1RemSet::oops_into_collection_set_do(OopsInHeapRegionClosure* oc, int worker_i) { IntoCSRegionClosure rc(_g1, oc); _g1->heap_region_iterate(&rc); }
void CSortHeaderCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct ) { // attath to the device context. CDC dc; VERIFY( dc.Attach( lpDrawItemStruct->hDC ) ); // save the device context. const int iSavedDC = dc.SaveDC(); // get the column rect. CRect rc( lpDrawItemStruct->rcItem ); // set the clipping region to limit drawing within the column. CRgn rgn; VERIFY( rgn.CreateRectRgnIndirect( &rc ) ); (void)dc.SelectObject( &rgn ); VERIFY( rgn.DeleteObject() ); // draw the background, CBrush brush( GetSysColor( COLOR_3DFACE ) ); dc.FillRect( rc, &brush ); // get the column text and format. TCHAR szText[ 256 ]; HD_ITEM hditem; hditem.mask = HDI_TEXT | HDI_FORMAT; hditem.pszText = szText; hditem.cchTextMax = 255; VERIFY( GetItem( lpDrawItemStruct->itemID, &hditem ) ); // determine the format for drawing the column label. UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS ; if( hditem.fmt & HDF_CENTER) uFormat |= DT_CENTER; else if( hditem.fmt & HDF_RIGHT) uFormat |= DT_RIGHT; else uFormat |= DT_LEFT; // adjust the rect if the mouse button is pressed on it. if( lpDrawItemStruct->itemState == ODS_SELECTED ) { rc.left++; rc.top += 2; rc.right++; } CRect rcIcon( lpDrawItemStruct->rcItem ); const int iOffset = ( rcIcon.bottom - rcIcon.top ) / 4; // adjust the rect further if the sort arrow is to be displayed. if( lpDrawItemStruct->itemID == (UINT)m_iSortColumn ) rc.right -= 3 * iOffset; rc.left += iOffset; rc.right -= iOffset; // draw the column label. if( rc.left < rc.right ) (void)dc.DrawText( szText, -1, rc, uFormat ); // draw the sort arrow. if( lpDrawItemStruct->itemID == (UINT)m_iSortColumn ) { // set up the pens to use for drawing the arrow. CPen penLight( PS_SOLID, 1, GetSysColor( COLOR_3DHILIGHT ) ); CPen penShadow( PS_SOLID, 1, GetSysColor( COLOR_3DSHADOW ) ); CPen* pOldPen = dc.SelectObject( &penLight ); if( m_bSortAscending ) { // draw the arrow pointing upwards. dc.MoveTo( rcIcon.right - 2 * iOffset, iOffset); dc.LineTo( rcIcon.right - iOffset, rcIcon.bottom - iOffset - 1 ); dc.LineTo( rcIcon.right - 3 * iOffset - 2, rcIcon.bottom - iOffset - 1 ); (void)dc.SelectObject( &penShadow ); dc.MoveTo( rcIcon.right - 3 * iOffset - 1, rcIcon.bottom - iOffset - 1 ); dc.LineTo( rcIcon.right - 2 * iOffset, iOffset - 1); } else { // draw the arrow pointing downwards. dc.MoveTo( rcIcon.right - iOffset - 1, iOffset ); dc.LineTo( rcIcon.right - 2 * iOffset - 1, rcIcon.bottom - iOffset ); (void)dc.SelectObject( &penShadow ); dc.MoveTo( rcIcon.right - 2 * iOffset - 2, rcIcon.bottom - iOffset ); dc.LineTo( rcIcon.right - 3 * iOffset - 1, iOffset ); dc.LineTo( rcIcon.right - iOffset - 1, iOffset ); } // restore the pen. (void)dc.SelectObject( pOldPen ); } // restore the previous device context. VERIFY( dc.RestoreDC( iSavedDC ) ); // detach the device context before returning. (void)dc.Detach(); }
void CPDObjectFrameSelected::DrawThreadRects(Gdiplus::Graphics* pGraphics, Gdiplus::Color& color, IPDMatrix* matrix) { Gdiplus::Pen pen(color); Gdiplus::SolidBrush brush(color); CComQIPtr<IPDObjectFrame> frame = m_object; if (frame) { CComPtr<IPDObject> content; frame->get_content(&content); CComQIPtr<IPDContentText> contentText = content; if (contentText) { PointD m_threadPtLeft; PointD m_threadPtRight; contentText->get_threadPtIn(&m_threadPtLeft); contentText->get_threadPtOut(&m_threadPtRight); double rotation; matrix->getRotation(&rotation); CComPtr<IPDObjectText> previousContentText; contentText->get_previousTextThread(&previousContentText); CComPtr<IPDObjectText> nextContentText; contentText->get_nextTextThread(&nextContentText); Gdiplus::SolidBrush whiteBrush(Gdiplus::Color(255, 255, 255)); { PointD xpt; matrix->transformPoint(&m_threadPtLeft, &xpt); Gdiplus::Rect rc(xpt.x-4, xpt.y-4, 9, 9); pGraphics->FillRectangle(&whiteBrush, rc); pGraphics->DrawRectangle(&pen, rc); if (previousContentText != NULL) { DrawThreadRectArrow(pGraphics, &brush, rc, rotation); } } { PointD xpt; matrix->transformPoint(&m_threadPtRight, &xpt); Gdiplus::Rect rc(xpt.x-4, xpt.y-4, 9, 9); pGraphics->FillRectangle(&whiteBrush, rc); VARIANT_BOOL overflow; contentText->get_overflow(&overflow); if (nextContentText != NULL) { pGraphics->DrawRectangle(&pen, rc); DrawThreadRectArrow(pGraphics, &brush, rc, rotation); } else { if (overflow) { Gdiplus::Pen redPen(Gdiplus::Color(255, 0, 0), 1); pGraphics->DrawRectangle(&redPen, rc); pGraphics->DrawLine(&redPen, rc.X+rc.Width/2, rc.Y+2, rc.X+rc.Width/2, rc.GetBottom()-1); pGraphics->DrawLine(&redPen, rc.X+2, rc.Y+rc.Height/2, rc.GetRight()-1, rc.Y+rc.Height/2); } else { pGraphics->DrawRectangle(&pen, rc); } } } } CComPtr<IPDPathText> pathText; frame->get_pathText(&pathText); if (pathText) { CComPtr<IPDMatrix> mat0; mat0.CoCreateInstance(CLSID_PDMatrix); CComPtr<IPDMatrix> mat1; mat0->translate(-m_pthreadPtLeft.x, -m_pthreadPtLeft.y, &mat1); CComPtr<IPDMatrix> mat2; mat1->rotate(m_pthreadRotationLeft, &mat2); CComPtr<IPDMatrix> mat3; mat2->translate(m_pthreadPtLeft.x, m_pthreadPtLeft.y, &mat3); CComPtr<IPDMatrix> mat; mat3->multiply(matrix, &mat); double x = m_pthreadPtLeft.x; double y = m_pthreadPtLeft.y; // { PointD xpt1; mat->transformPoint((PointD*)&CDblPoint(x, y), &xpt1); PointD xpt2; mat->transformPoint((PointD*)&CDblPoint(x, y+20), &xpt2); pGraphics->DrawLine(&pen, (float)xpt1.x, (float)xpt1.y, (float)xpt2.x, (float)xpt2.y); } { PointD pts[4] = { x, y, x-12, y, x-12, y+12, x, y+12 }; PointD xpts[4]; for (int i = 0; i < 4; i++) { mat->transformPoint(&pts[i], &xpts[i]); } pGraphics->DrawLine(&pen, (float)xpts[0].x, (float)xpts[0].y, (float)xpts[1].x, (float)xpts[1].y); pGraphics->DrawLine(&pen, (float)xpts[1].x, (float)xpts[1].y, (float)xpts[2].x, (float)xpts[2].y); pGraphics->DrawLine(&pen, (float)xpts[2].x, (float)xpts[2].y, (float)xpts[3].x, (float)xpts[3].y); pGraphics->DrawLine(&pen, (float)xpts[3].x, (float)xpts[3].y, (float)xpts[0].x, (float)xpts[0].y); } } } }
void CProgressCtrlEx::OnPaint() { CPaintDC paintDC(this); int nMin = 0; int nMax = 0; GetRange(nMin, nMax); ASSERT(nMin <= nMax); int nPos = GetPos(); ASSERT(nPos >= nMin && nPos <= nMax); DWORD dwStyle = GetStyle(); BOOL bVertical = FALSE; if (dwStyle & PBS_VERTICAL) { bVertical = TRUE; } CDC dc; dc.CreateCompatibleDC(&paintDC); ASSERT(dc.GetSafeHdc()); CRect rect; GetClientRect(&rect); CBitmap bmp; bmp.CreateCompatibleBitmap(&paintDC, rect.Width(), rect.Height()); ASSERT(bmp.GetSafeHandle()); CBitmap* pOldBitmap = (CBitmap*)dc.SelectObject(&bmp); CFont* pOldFont = NULL; CWnd* pParent = GetParent(); ASSERT(pParent); CFont* pFont = pParent->GetFont(); ASSERT(pFont); if (bVertical) { if (NULL == m_font.GetSafeHandle()) { LOGFONT lf = { 0 }; pFont->GetLogFont(&lf); lf.lfEscapement = 900; m_font.CreateFontIndirect(&lf); } ASSERT(m_font.GetSafeHandle()); pOldFont = (CFont*)dc.SelectObject(&m_font); } else { pOldFont = (CFont*)dc.SelectObject(pFont); } double dPercent = (double)(nPos - nMin) / ((double)(nMax - nMin)); dc.DrawEdge(rect, EDGE_SUNKEN, BF_RECT | BF_FLAT); CRect rc(rect); rc.DeflateRect(CSize(2, 2)); dc.FillSolidRect(&rc, m_clrBarBkColor); CString strText(_T("")); GetWindowText(strText); if (m_bShowPercent) { strText.AppendFormat(_T("%d%% "), static_cast<int>((dPercent * 100.0) + 0.5)); } dc.SetBkMode(TRANSPARENT); dc.SetTextColor(m_clrTextColor); CPoint pt(0, 0); CSize size = dc.GetOutputTextExtent(strText); if (!bVertical) { switch (m_AlignText) { case ALIGN_LEFT: pt.x = rc.left; break; case ALIGN_RIGHT: pt.x = rc.right - size.cx; break; case ALIGN_CENTER: default: pt.x = rc.left + (rc.Width() - size.cx) / 2; break; } pt.y = rc.top + (rc.Height() - size.cy) / 2; CRect rcPos(rc); rcPos.right = rcPos.left + (int)(dPercent * rcPos.Width()); dc.FillSolidRect(rcPos, m_clrBarColor); dc.SetTextColor(m_clrTextColor); dc.ExtTextOut(pt.x, pt.y, ETO_OPAQUE, rcPos, strText, NULL); dc.SetTextColor(m_clrTextBkColor); dc.ExtTextOut(pt.x, pt.y, ETO_CLIPPED, &rcPos, strText, NULL); } else { switch (m_AlignText) { case ALIGN_LEFT: pt.y = rc.bottom; break; case ALIGN_RIGHT: pt.y = rc.top + size.cx; break; case ALIGN_CENTER: default: pt.y = rc.bottom - (rc.Height() - size.cx) / 2; break; } pt.x = rc.left + (rc.Width() - size.cy) / 2; CRect rcPos(rc); rcPos.top = rcPos.bottom - (int)(dPercent * rcPos.Height()); dc.FillSolidRect(rcPos, m_clrBarColor); dc.SetTextColor(m_clrTextColor); dc.ExtTextOut(pt.x, pt.y, ETO_OPAQUE, rcPos, strText, NULL); dc.SetTextColor(m_clrTextBkColor); dc.ExtTextOut(pt.x, pt.y, ETO_CLIPPED, &rcPos, strText, NULL); } paintDC.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), &dc, 0, 0, SRCCOPY); dc.SelectObject(pOldFont); dc.SelectObject(pOldBitmap); bmp.DeleteObject(); dc.DeleteDC(); }
bool IrisBitmap::StretchBlt(const IIrisRect *destIrisRect, const IIrisBitmap *srcIrisBitmap, const IIrisRect *srcIrisRect, int opacity){ this->needRefreshTexture = true; Rect rc(((IrisRect*)srcIrisRect)->x, ((IrisRect*)srcIrisRect)->y, ((IrisRect*)srcIrisRect)->width, ((IrisRect*)srcIrisRect)->height); Rect drc(((IrisRect*)destIrisRect)->x, ((IrisRect*)destIrisRect)->y, ((IrisRect*)destIrisRect)->width, ((IrisRect*)destIrisRect)->height); return IrisBitmapStretchBlt(&drc, this->bitmap, &rc, ((IrisBitmap*)srcIrisBitmap)->bitmap, opacity); }
bool IrisBitmap::Blt(int x, int y, const IIrisBitmap *srcIrisBitmap, const IIrisRect *srcIrisRect, int opacity = 255){ this->needRefreshTexture = true; Rect rc(((IrisRect*)srcIrisRect)->x, ((IrisRect*)srcIrisRect)->y, ((IrisRect*)srcIrisRect)->width, ((IrisRect*)srcIrisRect)->height); return IrisBitmapBitBlt(x, y, this->bitmap, ((IrisBitmap*)srcIrisBitmap)->bitmap, &rc, opacity); }
void CMonitorBarCtrl::PaintHistory(CDC* pDC, CRect* prc) { CRect rc( prc ); pDC->Draw3dRect( &rc, CoolInterface.m_crSys3DShadow, CoolInterface.m_crSys3DHighlight ); rc.DeflateRect( 1, 1 ); pDC->FillSolidRect( &rc, Settings.Live.BandwidthScale > 100 ? CoolInterface.m_crMonitorHistoryBackMax : CoolInterface.m_crMonitorHistoryBack ); if ( m_bTab ) { CString str; if ( Settings.Live.BandwidthScale > 100 ) { str = _T("MAX"); } else { DWORD nRate = max( Settings.Connection.InSpeed, Settings.Connection.OutSpeed ); nRate = nRate * Settings.Live.BandwidthScale / 100; str.Format( _T("%s (%u%%)"), (LPCTSTR)Settings.SmartSpeed( nRate, Kilobits ), Settings.Live.BandwidthScale ); } CFont* pfOld = (CFont*)pDC->SelectObject( &CoolInterface.m_fntNormal ); pDC->SetBkMode( TRANSPARENT ); pDC->SetTextColor( CoolInterface.m_crMonitorHistoryText ); pDC->DrawText( str, &rc, DT_CENTER|DT_VCENTER|DT_SINGLELINE ); pDC->SelectObject( pfOld ); return; } if ( m_nMaximum == 0 ) return; DWORD nMax = min( m_pTxItem->m_nLength, (DWORD)rc.Width() ); int nX = rc.right - 1; for ( DWORD nPos = 0 ; nPos < nMax ; nPos++, nX-- ) { DWORD nTxValue = m_pTxItem->GetValueAt( nPos ); DWORD nRxValue = m_pRxItem->GetValueAt( nPos ); nTxValue = rc.bottom - nTxValue * rc.Height() / m_nMaximum; nRxValue = rc.bottom - nRxValue * rc.Height() / m_nMaximum; if ( nTxValue < nRxValue ) { if ( nTxValue < (DWORD)rc.bottom ) { pDC->FillSolidRect( nX, nTxValue + 1, 1, rc.bottom - nTxValue - 1, CoolInterface.m_crMonitorUploadBar ); pDC->SetPixel( nX, nTxValue, CoolInterface.m_crMonitorUploadLine ); } if ( nRxValue < (DWORD)rc.bottom ) { pDC->FillSolidRect( nX, nRxValue + 1, 1, rc.bottom - nRxValue - 1, CoolInterface.m_crMonitorDownloadBar ); pDC->SetPixel( nX, nRxValue, CoolInterface.m_crMonitorDownloadLine ); } } else { if ( nRxValue < (DWORD)rc.bottom ) { pDC->FillSolidRect( nX, nRxValue + 1, 1, rc.bottom - nRxValue - 1, CoolInterface.m_crMonitorDownloadBar ); pDC->SetPixel( nX, nRxValue, CoolInterface.m_crMonitorDownloadLine ); } if ( nTxValue < (DWORD)rc.bottom ) { pDC->FillSolidRect( nX, nTxValue + 1, 1, rc.bottom - nTxValue - 1, CoolInterface.m_crMonitorUploadBar ); pDC->SetPixel( nX, nTxValue, CoolInterface.m_crMonitorUploadLine ); } } } }
// 窗口事件处理 Boolean TGardenListForm::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_WinEraseClient: { TDC dc(this); WinEraseClientEventType *pEraseEvent = reinterpret_cast< WinEraseClientEventType* >( pEvent ); TRectangle rc(pEraseEvent->rc); TRectangle rcBack(5, 142, 310, 314); this->GetBounds(&rcBack); // 刷主窗口背景色 dc.SetBackColor(RGB_COLOR_WHITE); // 擦除 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()-68, //320, GUI_API_STYLE_ALIGNMENT_LEFT|GUI_API_STYLE_ALIGNMENT_TOP); 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_BackBtn); bHandled = TRUE; } } break; default: break; } if (!bHandled) { bHandled = TWindow::EventHandler(pApp, pEvent); } return bHandled; }
BOOL CMonitorBarCtrl::Create(CWnd* pParentWnd, DWORD dwStyle, UINT nID) { CRect rc( 0, 0, 0, 0 ); dwStyle |= WS_CHILD|WS_CLIPCHILDREN; return CWnd::Create( NULL, NULL, dwStyle, rc, pParentWnd, nID, NULL ); }
ExecutableModel* LLVMModelGenerator::createModel(const std::string& sbml, uint options) { bool forceReCompile = options & LoadSBMLOptions::RECOMPILE; string md5; if (!forceReCompile) { // check for a chached copy md5 = rr::getMD5(sbml); if (options & LoadSBMLOptions::CONSERVED_MOIETIES) { md5 += "_conserved"; } ModelPtrMap::const_iterator i; SharedModelPtr sp; cachedModelsMutex.lock(); if ((i = cachedModels.find(md5)) != cachedModels.end()) { sp = i->second.lock(); } cachedModelsMutex.unlock(); // we could have recieved a bad ptr, a model could have been deleted, // in which case, we should have a bad ptr. if (sp) { Log(Logger::LOG_DEBUG) << "found a cached model for " << md5; return new LLVMExecutableModel(sp, createModelData(*sp->symbols, sp->random)); } else { Log(Logger::LOG_TRACE) << "no cached model found for " << md5 << ", creating new one"; } } SharedModelPtr rc(new ModelResources()); ModelGeneratorContext context(sbml, options); rc->evalInitialConditionsPtr = EvalInitialConditionsCodeGen(context).createFunction(); rc->evalReactionRatesPtr = EvalReactionRatesCodeGen(context).createFunction(); rc->getBoundarySpeciesAmountPtr = GetBoundarySpeciesAmountCodeGen(context).createFunction(); rc->getFloatingSpeciesAmountPtr = GetFloatingSpeciesAmountCodeGen(context).createFunction(); rc->getBoundarySpeciesConcentrationPtr = GetBoundarySpeciesConcentrationCodeGen(context).createFunction(); rc->getFloatingSpeciesConcentrationPtr = GetFloatingSpeciesConcentrationCodeGen(context).createFunction(); rc->getCompartmentVolumePtr = GetCompartmentVolumeCodeGen(context).createFunction(); rc->getGlobalParameterPtr = GetGlobalParameterCodeGen(context).createFunction(); rc->evalRateRuleRatesPtr = EvalRateRuleRatesCodeGen(context).createFunction(); rc->getEventTriggerPtr = GetEventTriggerCodeGen(context).createFunction(); rc->getEventPriorityPtr = GetEventPriorityCodeGen(context).createFunction(); rc->getEventDelayPtr = GetEventDelayCodeGen(context).createFunction(); rc->eventTriggerPtr = EventTriggerCodeGen(context).createFunction(); rc->eventAssignPtr = EventAssignCodeGen(context).createFunction(); rc->evalVolatileStoichPtr = EvalVolatileStoichCodeGen(context).createFunction(); rc->evalConversionFactorPtr = EvalConversionFactorCodeGen(context).createFunction(); if (options & LoadSBMLOptions::READ_ONLY) { rc->setBoundarySpeciesAmountPtr = 0; rc->setBoundarySpeciesConcentrationPtr = 0; rc->setFloatingSpeciesConcentrationPtr = 0; rc->setCompartmentVolumePtr = 0; rc->setFloatingSpeciesAmountPtr = 0; rc->setGlobalParameterPtr = 0; } else { rc->setBoundarySpeciesAmountPtr = SetBoundarySpeciesAmountCodeGen( context).createFunction(); rc->setBoundarySpeciesConcentrationPtr = SetBoundarySpeciesConcentrationCodeGen(context).createFunction(); rc->setFloatingSpeciesConcentrationPtr = SetFloatingSpeciesConcentrationCodeGen(context).createFunction(); rc->setCompartmentVolumePtr = SetCompartmentVolumeCodeGen(context).createFunction(); rc->setFloatingSpeciesAmountPtr = SetFloatingSpeciesAmountCodeGen( context).createFunction(); rc->setGlobalParameterPtr = SetGlobalParameterCodeGen(context).createFunction(); } if (options & LoadSBMLOptions::MUTABLE_INITIAL_CONDITIONS) { rc->getFloatingSpeciesInitConcentrationsPtr = GetFloatingSpeciesInitConcentrationCodeGen(context).createFunction(); rc->setFloatingSpeciesInitConcentrationsPtr = SetFloatingSpeciesInitConcentrationCodeGen(context).createFunction(); rc->getFloatingSpeciesInitAmountsPtr = GetFloatingSpeciesInitAmountCodeGen(context).createFunction(); rc->setFloatingSpeciesInitAmountsPtr = SetFloatingSpeciesInitAmountCodeGen(context).createFunction(); rc->getCompartmentInitVolumesPtr = GetCompartmentInitVolumeCodeGen(context).createFunction(); rc->setCompartmentInitVolumesPtr = SetCompartmentInitVolumeCodeGen(context).createFunction(); rc->getGlobalParameterInitValuePtr = GetGlobalParameterInitValueCodeGen(context).createFunction(); rc->setGlobalParameterInitValuePtr = SetGlobalParameterInitValueCodeGen(context).createFunction(); } else { rc->getFloatingSpeciesInitConcentrationsPtr = 0; rc->setFloatingSpeciesInitConcentrationsPtr = 0; rc->getFloatingSpeciesInitAmountsPtr = 0; rc->setFloatingSpeciesInitAmountsPtr = 0; rc->getCompartmentInitVolumesPtr = 0; rc->setCompartmentInitVolumesPtr = 0; rc->getGlobalParameterInitValuePtr = 0; rc->setGlobalParameterInitValuePtr = 0; } // if anything up to this point throws an exception, thats OK, because // we have not allocated any memory yet that is not taken care of by // something else. // Now that everything that could have thrown would have thrown, we // can now create the model and set its fields. LLVMModelData *modelData = createModelData(context.getModelDataSymbols(), context.getRandom()); uint llvmsize = ModelDataIRBuilder::getModelDataSize(context.getModule(), &context.getExecutionEngine()); if (llvmsize != modelData->size) { std::stringstream s; s << "LLVM Model Data size " << llvmsize << " is different from " << "C++ size of LLVM ModelData, " << modelData->size; LLVMModelData_free(modelData); Log(Logger::LOG_FATAL) << s.str(); throw_llvm_exception(s.str()); } // * MOVE * the bits over from the context to the exe model. context.stealThePeach(&rc->symbols, &rc->context, &rc->executionEngine, &rc->random, &rc->errStr); if (!forceReCompile) { // check for a chached copy, another thread could have // created one while we were making ours... ModelPtrMap::const_iterator i; SharedModelPtr sp; cachedModelsMutex.lock(); // whilst we have it locked, clear any expired ptrs for (ModelPtrMap::const_iterator j = cachedModels.begin(); j != cachedModels.end();) { if (j->second.expired()) { Log(Logger::LOG_DEBUG) << "removing expired model resource for hash " << md5; j = cachedModels.erase(j); } else { ++j; } } if ((i = cachedModels.find(md5)) == cachedModels.end()) { Log(Logger::LOG_DEBUG) << "could not find existing cached resource " "resources, for hash " << md5 << ", inserting new resources into cache"; cachedModels[md5] = rc; } cachedModelsMutex.unlock(); } return new LLVMExecutableModel(rc, modelData); }
ConvivData:: ConvivData( const char *application_path ) : schoenflies(32,as_capacity), htmlManual(), js() { ios::resources rc( application_path ); //========================================================================== // // get schoenflies notation // //========================================================================== { //---------------------------------------------------------------------- // load and parse the resource //---------------------------------------------------------------------- auto_ptr<ios::istream> fp( rc.load_stream( "schoenflies.js" ) ); //lingua::input fp( rc.load_stream( "schoenflies.js" ) ); JSON::Value &jv = js( *fp ); if( jv.type != JSON::IsObject ) throw exception("invalid schoenflies.js"); //---------------------------------------------------------------------- // convert into a Schoenflies object //---------------------------------------------------------------------- const JSON::Object &s = jv.as<JSON::Object>(); const size_t ns = s.length(); schoenflies.reserve(ns); for( JSON::Object::const_iterator p = s.begin();p!=s.end();++p) { const JSON::Pair &P = *p; const string &symbol = P.name; const JSON::Object &data = P.value.as<JSON::Object>(); const JSON::String &info = data["info"].as<JSON::String>(); const JSON::Value &abelian = data["abelian"]; bool isAbelian = false; switch ( abelian.type ) { case JSON::IsTrue: isAbelian= true; break; case JSON::IsFalse: isAbelian= false; break; default: throw exception("Schoenflies '%s': bad abelian field", symbol.c_str() ); } Schoenflies sym(symbol,info,isAbelian); vector<string> &ch = (vector<string>&) sym.characters; const JSON::Array &arr = data["char"].as<JSON::Array>(); const size_t nc = arr.length(); ch.reserve(nc); for( size_t i=0; i < nc; ++i ) ch.push_back( arr[i].as<JSON::String>() ); if( !schoenflies.insert(sym) ) throw exception("unexpected multiple Schoenflies '%s'", symbol.c_str() ); } //---------------------------------------------------------------------- // free resources //---------------------------------------------------------------------- jv.nullify(); } //========================================================================== // // get document // //========================================================================== { rc.load_chars(htmlManual, "doc.html", 1); } //========================================================================== // // get basis info // //========================================================================== { //---------------------------------------------------------------------- // load and parse the resource //---------------------------------------------------------------------- auto_ptr<ios::istream> fp( rc.load_stream( "basis.js" ) ); //lingua::input fp( rc.load_stream( "basis.js" ) ); JSON::Value &jv = js( *fp ); if( jv.type != JSON::IsObject ) throw exception("invalid basis.js"); const JSON::Object &db = jv.as<JSON::Object>(); basisDB.reserve( db.length() ); for( JSON::Object::const_iterator p = db.begin();p!=db.end();++p) { const JSON::Pair &P = *p; BasisInfo bi(P.name); if( P.value.type != JSON::IsArray ) throw exception("invalid value for '%s'", P.name.c_str()); const JSON::Array &arr = P.value.as<JSON::Array>(); for( size_t i=0; i < arr.length(); ++i ) { const JSON::Value &jstr = arr[i]; if( jstr.type != JSON::IsString ) throw exception("'%s'[%d]: not a string", P.name.c_str(), int(i)); bi.param.push_back( jstr.as<JSON::String>() ); } if( !basisDB.insert(bi) ) throw exception("Multiple BasisInfo '%s'", bi.name.c_str()); } } }
BOOL CDuiMenu::Create(CWnd *pParent, CPoint point, UINT uMessageID, CString strImage, int nFrameSize/* = 4*/, int nMinWidth/* = 112*/, enumBackMode enBackMode/* = enBMFrame*/) { CRect rc(point.x - nMinWidth / 2, point.y, point.x + nMinWidth / 2, point.y + nMinWidth); return CDlgPopup::Create(pParent, rc, uMessageID, strImage, enBackMode, nFrameSize); }
ColorsPreflet::ColorsPreflet(PrefsWindow *parent) : Preflet(parent) { // clear colors listview BRect lvrc(Bounds()); lvrc.InsetBy(20, 50); lvrc.OffsetBy(0, -5); lvrc.right--; lvrc.top += 12; // make room for cut/paste instructions lvrc.bottom -= 2; // looks nicer lvrc.OffsetBy(0, 1); // create list lvrc.InsetBy(2, 2); lvrc.right -= B_V_SCROLL_BAR_WIDTH; fColorsList = new ColorView(lvrc, parent); // create scrollview fScrollView = new BScrollView("sv", fColorsList, B_FOLLOW_ALL, 0, false, true); AddChild(fScrollView); lvrc.right += B_V_SCROLL_BAR_WIDTH; // the real TargetedByScrollView is for some reason called BEFORE the scrollbars // are created, so it doesn't work properly, fix up... fColorsList->TargetedByScrollView(fScrollView); // cut/paste instructions BStringView *paste; BRect rc(lvrc); rc.bottom = rc.top - 1; rc.top -= 18; //rc.bottom = rc.top + 15; rc.right = rc.left + (WIDTHOF(rc) / 2); AddChild(new BStringView(rc, "", "Right-click: pick up color", 0)); rc.left = rc.right + 1; rc.right = lvrc.right; paste = new BStringView(rc, "", "Ctrl-click: paste color", 0); paste->SetAlignment(B_ALIGN_RIGHT); AddChild(paste); // font selector area fFontMenu = new BPopUpMenu("fontsel"); fFontMenu->AddItem(new BMenuItem("System Fixed Font ", NULL)); int x = 10; int y = 273; rc.Set(x, y, x+20, y+20); fFontField = new BMenuField(rc, "fontfld", "", fFontMenu); fFontMenu->ItemAt(0)->SetMarked(true); AddChild(fFontField); rc.Set(200, 270, 353, 290); fFontSize = new Spinner(rc, "fontsz", "Point size", new BMessage(M_POINTSIZE_CHANGED)); fFontSize->SetRange(4, 24); fFontSize->SetValue(editor.settings.font_size); fFontSize->SetTarget(Looper()); AddChild(fFontSize); // scheme selector area fSchemeMenu = new BPopUpMenu("schemesel"); UpdateSchemesMenu(); x = 10; y = 10; rc.Set(x, y, x+20, y+20); fSchemeField = new BMenuField(rc, "schemefld", "", fSchemeMenu); AddChild(fSchemeField); rc.right = lvrc.right; rc.left = rc.right - 48; rc.OffsetBy(-80, 0); BButton *delbtn = new BButton(rc, "", "Del", new BMessage(M_SCHEME_DELETE)); rc.OffsetBy(-58, 0); BButton *newbtn = new BButton(rc, "", "New", new BMessage(M_SCHEME_NEW)); rc.OffsetBy(115, 0); rc.right = lvrc.right + 1; BButton *defaultsbtn = new BButton(rc, "", "Defaults", new BMessage(M_SCHEME_DEFAULTS)); newbtn->SetTarget(Looper()); delbtn->SetTarget(Looper()); defaultsbtn->SetTarget(Looper()); AddChild(newbtn); AddChild(delbtn); AddChild(defaultsbtn); }
BOOL CDuiMenu::Create(CWnd *pParent, CPoint point, UINT uMessageID) { int nMinWidth = m_nWidth; CRect rc(point.x - nMinWidth / 2, point.y, point.x + nMinWidth / 2, point.y + nMinWidth); return CDlgPopup::Create(pParent, rc, uMessageID); }
void CLibraryTileItem::Paint(CDC* pDC, const CRect& rcBlock, CDC* /*pMemDC*/, BOOL bFocus ) { CRect rc( &rcBlock ); CPoint pt( rc.left + 5, rc.top + 4 ); if ( m_nIcon48 >= 0 ) { ShellIcons.Draw( pDC, m_nIcon48, 48, pt.x, pt.y, CLR_NONE, m_bSelected ); } else if ( m_nIcon32 >= 0 ) { pt.x += 8; pt.y += 8; ShellIcons.Draw( pDC, m_nIcon32, 32, pt.x, pt.y, CLR_NONE, m_bSelected ); } else { CoolInterface.Draw( pDC, IDI_FOLDER_OPEN, 48, pt.x, pt.y, CLR_NONE, m_bSelected ); } if ( m_bCollection ) CoolInterface.Draw( pDC, IDI_COLLECTION_MASK, 16, pt.x, pt.y, CLR_NONE, m_bSelected ); rc.left += 48 + 5; rc.DeflateRect( 10, 5 ); const BOOL bSelectmark = m_bSelected && Images.m_bmSelected.m_hObject != NULL; if ( m_bSelected ) { pDC->SetTextColor( Colors.m_crHiText ); pDC->SetBkColor( bSelectmark ? CLR_NONE : Colors.m_crHighlight ); pDC->SetBkMode( bSelectmark ? TRANSPARENT : OPAQUE ); } else { pDC->SetTextColor( Colors.m_crText ); pDC->SetBkColor( Colors.m_crWindow ); pDC->SetBkMode( TRANSPARENT ); } int nX = rc.left + 1; int nY = ( rc.top + rc.bottom ) / 2; int nH = pDC->GetTextExtent( L"Xy" ).cy; CRect rcUnion( nX, nY, nX, nY ); if ( ! m_sSubtitle1.IsEmpty() ) { if ( ! m_sSubtitle2.IsEmpty() ) { nY -= ( nH * 3 ) / 2; if ( m_bCollection ) pDC->SelectObject( &CoolInterface.m_fntBold ); DrawText( pDC, &rc, nX, nY, m_sTitle, &rcUnion, bSelectmark ); if ( m_bCollection ) pDC->SelectObject( &CoolInterface.m_fntNormal ); if ( ! m_bSelected ) pDC->SetTextColor( Colors.m_crDisabled ); DrawText( pDC, &rc, nX, nY + nH, m_sSubtitle1, &rcUnion, bSelectmark ); DrawText( pDC, &rc, nX, nY + nH + nH, m_sSubtitle2, &rcUnion, bSelectmark ); } else { if ( m_bCollection ) pDC->SelectObject( &CoolInterface.m_fntBold ); DrawText( pDC, &rc, nX, nY - nH, m_sTitle, &rcUnion, bSelectmark ); if ( m_bCollection ) pDC->SelectObject( &CoolInterface.m_fntNormal ); if ( ! m_bSelected ) pDC->SetTextColor( Colors.m_crDisabled ); DrawText( pDC, &rc, nX, nY, m_sSubtitle1, &rcUnion, bSelectmark ); } if ( bSelectmark ) // ToDo: Is this aesthetic right? When are subtitles shown with highlight? { rcUnion.top--; rcUnion.left -= 4; rcUnion.right += 4; rcUnion.bottom += 2; CoolInterface.DrawWatermark( pDC, &rcUnion, &Images.m_bmSelected, FALSE ); // No overdraw DrawText( pDC, &rc, nX, nY, m_sTitle, NULL, bSelectmark ); // Duplicate Workaround } else { rcUnion.InflateRect( 1, 1 ); if ( bFocus && Images.m_bmSelected.m_hObject ) { rcUnion.left -= 3; rcUnion.right += 3; rcUnion.bottom++; } pDC->FillSolidRect( &rcUnion, pDC->GetBkColor() ); } } else // Draw Name { nY -= nH / 2; if ( m_bCollection ) pDC->SelectObject( &CoolInterface.m_fntBold ); DrawText( pDC, &rc, nX, nY, m_sTitle, &rcUnion, bSelectmark ); if ( bSelectmark ) { rcUnion.top--; rcUnion.left -= 4; rcUnion.right += 4; rcUnion.bottom += 2; CoolInterface.DrawWatermark( pDC, &rcUnion, &Images.m_bmSelected, FALSE ); // No overdraw DrawText( pDC, &rc, nX, nY, m_sTitle, NULL, bSelectmark ); // Duplicate Workaround } else if ( bFocus ) { rcUnion.InflateRect( 1, 1 ); if ( Images.m_bmSelected.m_hObject ) { rcUnion.left -= 3; rcUnion.right += 3; rcUnion.bottom++; } } if ( m_bCollection ) pDC->SelectObject( &CoolInterface.m_fntNormal ); } if ( bFocus ) { pDC->Draw3dRect( &rcUnion, Colors.m_crHiBorder, Colors.m_crHiBorder ); if ( Settings.Skin.RoundedSelect ) { pDC->SetPixel( rcUnion.left, rcUnion.top, Colors.m_crWindow ); pDC->SetPixel( rcUnion.left, rcUnion.bottom - 1, Colors.m_crWindow ); pDC->SetPixel( rcUnion.right - 1, rcUnion.top, Colors.m_crWindow ); pDC->SetPixel( rcUnion.right - 1, rcUnion.bottom - 1, Colors.m_crWindow ); } if ( Colors.m_crHiBorderIn ) { rcUnion.DeflateRect( 1, 1 ); pDC->Draw3dRect( &rcUnion, Colors.m_crHiBorderIn, Colors.m_crHiBorderIn ); } } pDC->SelectClipRgn( NULL ); }
void CAllNodesDiaolg::ClickMsflexgrid1() { long lRow,lCol; lRow = m_FlexGrid.get_RowSel();//获取点击的行号 lCol = m_FlexGrid.get_ColSel(); //获取点击的列号 if(lRow==0) return; CRect rect; m_FlexGrid.GetWindowRect(rect); //获取表格控件的窗口矩形 ScreenToClient(rect); //转换为客户区矩形 // MSFlexGrid控件的函数的长度单位是"缇(twips)", //需要将其转化为像素,1440缇= 1英寸 CDC* pDC =GetDC(); //计算象素点和缇的转换比例 int nTwipsPerDotX = 1440 / pDC->GetDeviceCaps(LOGPIXELSX) ; int nTwipsPerDotY = 1440 / pDC->GetDeviceCaps(LOGPIXELSY) ; //计算选中格的左上角的坐标(象素为单位) long y = m_FlexGrid.get_RowPos(lRow)/nTwipsPerDotY; long x = m_FlexGrid.get_ColPos(lCol)/nTwipsPerDotX; //计算选中格的尺寸(象素为单位)。加1是实际调试中,发现加1后效果更好 long width = m_FlexGrid.get_ColWidth(lCol)/nTwipsPerDotX+1; long height = m_FlexGrid.get_RowHeight(lRow)/nTwipsPerDotY+1; //形成选中个所在的矩形区域 CRect rc(x,y,x+width,y+height); //转换成相对对话框的坐标 rc.OffsetRect(rect.left+1,rect.top+1); //获取选中格的文本信息 CString strValue = m_FlexGrid.get_TextMatrix(lRow,lCol); m_nCurRow=lRow; m_nCurCol=lCol; if(m_nCurCol==1) { if(m_nCurRow<m_FlexGrid.get_Rows()-1) return; } // if(m_nCurCol==AN_PRODUCTTYPE) // { // if(m_nCurRow<m_FlexGrid.get_Rows()-1) // return; // m_productCombox.ResetContent(); // m_productCombox.AddString(_T("Tstat")); // m_productCombox.AddString(_T("NC")); // m_productCombox.ShowWindow(SW_SHOW);//显示控件 // m_productCombox.SetWindowText(strValue); //显示文本 // m_productCombox.SelectString(-1,strValue); //内容全选。方便直接修改 this line must before setfocus // m_productCombox.SetFocus(); //获取焦点 // m_productCombox.MoveWindow(rc); //移动到选中格的位置,覆盖 // } // if(m_nCurCol==AN_PRUDUCTNAME||m_nCurCol==AN_ROOMNAME||m_nCurCol==AN_FLOORNAME) if(m_nCurCol > 0 && m_nCurCol != AN_GRAPHICID && m_nCurCol != AN_MAINNAME) { m_InputTextEdt.ShowWindow(SW_SHOW); m_InputTextEdt.SetWindowText(strValue); //显示文本 // m_InputTextEdt(-1,strValue); //内容全选。方便直接修改 this line must before setfocus m_InputTextEdt.SetFocus(); int nLenth=strValue.GetLength(); m_InputTextEdt.SetSel(0,nLenth); m_InputTextEdt.SetFocus(); //获取焦点 m_InputTextEdt.MoveWindow(rc); //移动到选中格的位置,覆盖 } if(m_nCurCol==AN_GRAPHICID) { CString strFilter = _T("bmp file|*.bmp|jpg file|*.jpg|png file|*.png|tif file|*.tif|all file|*.*||"); CFileDialog dlg(true,_T("Open image file"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,strFilter); if(IDOK==dlg.DoModal()) { //=program_path+"image\\"+short_name; CString strImgFilePathName=dlg.GetPathName(); CString strImgFileName=dlg.GetFileName(); CString strDestFileName=g_strImgeFolder+strImgFileName; CopyFile(strImgFilePathName,strDestFileName,FALSE); m_FlexGrid.put_TextMatrix(m_nCurRow,m_nCurCol,strImgFileName); //update recorder; if(m_nCurRow<m_FlexGrid.get_Rows()) { CString strSerial=m_FlexGrid.get_TextMatrix(m_nCurRow,AN_SerialID); if(strSerial.IsEmpty()) return; try { CString strSql; strSql.Format(_T("update ALL_NODE set Background_imgID ='%s' where Serial_ID = '%s' "/*and Building_Name = '%s'*/),strImgFileName,strSerial/*,m_strSubNetName*/); m_pCon->Execute(strSql.GetString(),NULL,adCmdText); m_bChanged=TRUE; g_strImagePathName=strImgFileName; } catch(_com_error *e) { AfxMessageBox(e->ErrorMessage()); } } } } }
void CPHTMLIFrameElement::PlaceControls(HWND hWndParent, CHTMFlowBlockContext* /*pC*/) { ASSERT(0); #if 0 CLHTMLIFrameElement* pElement = static_cast<CLHTMLIFrameElement*>(m_pNode); if (m_pBox) { Gdiplus::RectF rcf = m_pBox->GetAbsInnerRect(); CRect rc((int)rcf.X, (int)rcf.Y, (int)rcf.GetRight(), (int)rcf.GetBottom()); if (pElement->m_pFrameContent == NULL) { CComObject<CLHTMLFrameContent>::CreateInstance(&pElement->m_pFrameContent); pElement->m_pFrameContent->AddRef(); // TODO CPElement* pParent = this; while (pParent) { CComQIPtr<IOleInPlaceFrame> frame = static_cast<ILViewNode*>(pParent); if (frame) { pElement->m_pFrameContent->m_pInPlaceFrame = frame; break; } pParent = pParent->m_parent; } pElement->m_pFrameContent->m_hWnd = hWndParent; pElement->Load(); } if (pElement->m_pFrameContent) { if (pElement->m_pFrameContent->m_spOleObject) { if (pElement->m_pFrameContent->m_pViewSite == NULL) { #if 0 pElement->m_pFrameContent->m_spOleObject->DoVerb(OLEIVERB_SHOW, NULL, pElement->m_pFrameContent, 0, hWndParent, &rc); #endif } else { pElement->m_pFrameContent->m_pViewSite->SetRect(rc); } } } } if (pElement->m_pFrameContent) { if (pElement->m_pFrameContent->m_pViewSite) { ASSERT(pElement->m_pFrameContent->m_pViewSite->m_pIOleDocView); BOOL bShow = m_pBox != NULL; pElement->m_pFrameContent->m_pViewSite->m_pIOleDocView->Show(bShow); } } #endif }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // // if (!m_wndToolBar.Create(this) || // !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) // { // TRACE0("Failed to create toolbar\n"); // return -1; // fail to create // } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } //pCLog = NULL; // TODO: Remove this if you don't want tool tips or a resizeable toolbar // m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | // CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // if (!m_buttonbar.Create(this,IDD_DIALOGBAR1, CBRS_TOP, IDD_DIALOGBAR1)) // { // return -1; // } if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); // EnableDocking(CBRS_ALIGN_ANY); // DockControlBar(&m_wndToolBar); if (!m_wndMyBar1.Create(_T("控制条"), this, CSize(280,100),TRUE,123)) { TRACE0("Failed to create mybar\n"); return -1; } if (!m_wndMyBar2.Create(_T("我的控制条2"), this,CSize(200,30),TRUE,124)) { TRACE0("Failed to create mybar\n"); return -1; } if (!m_wndLogBar3.Create(_T("输出窗口"), this,CSize(100,250),TRUE,124)) { TRACE0("Failed to create mybar\n"); return -1; } // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.SetButtonText(0," Optim "); m_wndToolBar.SetButtonText(1," Exit "); /////////////调整工具条///////////////// CRect rc(0, 0, 0, 0); CSize sizeMax(0, 0); CToolBarCtrl& bar = m_wndToolBar.GetToolBarCtrl(); for (int nIndex = bar.GetButtonCount() - 1; nIndex >= 0; nIndex--) { bar.GetItemRect(nIndex, rc); rc.NormalizeRect(); sizeMax.cx = __max(rc.Size().cx, sizeMax.cx); sizeMax.cy = __max(rc.Size().cy, sizeMax.cy); } //sizeMax.cx += 10; m_wndToolBar.SetSizes(sizeMax, CSize(16,15)); ////////////创建TAB Control,并把它加入到ControlBar中 /// 需要注意的是:同一个ControlBar只能加入一个"一级子窗口" // m_TabCtrl.Create(TCS_DOWN|WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),&m_wndMyBar1,125); /////////////这一段代码创建树型控件//////////// // if (!m_wndTree.Create(WS_CHILD|WS_VISIBLE| // TVS_HASLINES|TVS_HASBUTTONS|TVS_LINESATROOT, // CRect(0, 0, 0, 0), &m_TabCtrl, IDC_MYTREECTRL)) // { // TRACE0("Failed to create instant bar child\n"); // return -1; // } // m_wndTree.ModifyStyleEx(0, WS_EX_CLIENTEDGE); ///往树型控件添加内容 // HTREEITEM hti = m_wndTree.InsertItem(_T("函数名")); // m_wndTree.InsertItem(_T("2")); // m_wndTree.InsertItem(_T("main()"), hti); // m_wndTree.InsertItem(_T("aaa"), hti); ///将树型控件加入到TabCtrl中 // m_TabCtrl.AddPage(&m_wndTree,"函数",IDI_ICON1); // m_TabCtrl.AddPage(RUNTIME_CLASS(CViewFunDlg),IDD_DIALOGBAR2,"第1页",IDI_ICON1); // m_TabCtrl.AddPage(RUNTIME_CLASS(CViewDlg),IDD_DIALOG2,"第三页",IDI_ICON1); // m_TabCtrl.UpdateWindow(); ////////对话框/////////// if(!dlg.Create(IDD_DIALOGBAR2,&m_wndMyBar1)) return -1; dlg.ShowWindow(SW_SHOW); if(!m_commandDlg.Create(IDD_COMMAND,&m_wndMyBar2)) return -1; m_commandDlg.ShowWindow(SW_SHOW); if(!m_log.Create(IDD_DIALOGBAR3,&m_wndLogBar3)) return -1; m_log.ShowWindow(SW_SHOW); // m_listFun.Create( // WS_CHILD|WS_VISIBLE|WS_BORDER|LVS_REPORT, // CRect(10,10,400,200), pParentWnd, 1); ////////编辑控件/////////// // if(!m_wndEdit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_MULTILINE|ES_WANTRETURN,CRect(0,0,0,0),&m_wndMyBar2,101)) // return -1; // m_wndEdit.ModifyStyleEx(0,WS_EX_CLIENTEDGE); ///////////////停靠控制/////////////////// m_wndMyBar1.SetBarStyle(m_wndMyBar1.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_wndMyBar2.SetBarStyle(m_wndMyBar2.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_wndLogBar3.SetBarStyle(m_wndLogBar3.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndMyBar1.EnableDocking(CBRS_ALIGN_ANY); m_wndMyBar2.EnableDocking(CBRS_ALIGN_ANY); m_wndLogBar3.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); DockControlBar(&m_wndMyBar1, AFX_IDW_DOCKBAR_RIGHT); RecalcLayout(); CRect rect; m_wndMyBar1.GetWindowRect(rect); rect.OffsetRect(0,1);//偏移一个位置 DockControlBar(&m_wndLogBar3, AFX_IDW_DOCKBAR_RIGHT,rect);///也停靠在底部 DockControlBar(&m_wndMyBar2, AFX_IDW_DOCKBAR_BOTTOM); /////////使浮动与停靠显示相同的头部//// #ifdef _SCB_REPLACE_MINIFRAME m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd); #endif //_SCB_REPLACE_MINIFRAME // m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); // EnableDocking(CBRS_ALIGN_ANY); // DockControlBar(&m_wndToolBar); //::SendMessage(m_log.GetSafeHwnd(),WM_LBUTTONDOWN,0x1,0x31FFF8); //::SendMessage(m_log.GetSafeHwnd(),WM_MOUSEMOVE,0x1,0xD6003F); //::SendMessage(m_log.GetSafeHwnd(),WM_LBUTTONUP,0x0,0xD6003F); return 0; }
bool SceneIO::processSceneRobot(rapidxml::xml_node<char>* sceneXMLNode, ScenePtr scene, const std::string& basePath ) { THROW_VR_EXCEPTION_IF(!sceneXMLNode, "NULL data in processSceneRobot"); // get name std::string robotName = processNameAttribute(sceneXMLNode,true); if (robotName.empty()) { THROW_VR_EXCEPTION("Please specify the name of the robot..."); return false; } std::string initStr("initconfig"); std::string initConfigName = processStringAttribute(initStr,sceneXMLNode,true); std::vector< RobotConfigPtr > configs; std::vector< std::vector< RobotConfig::Configuration > > configDefinitions; std::vector< std::string > configNames; Eigen::Matrix4f globalPose = Eigen::Matrix4f::Identity(); std::string fileName; rapidxml::xml_node<>* node = sceneXMLNode->first_node(); std::vector< rapidxml::xml_node<>* > rnsNodes; while (node) { std::string nodeName = getLowerCase(node->name()); if (nodeName == "file") { THROW_VR_EXCEPTION_IF(!fileName.empty(), "Multiple files defined in scene's robot tag '" << robotName << "'." << endl); fileName = processFileNode(node,basePath); } else if (nodeName == "configuration") { bool c*K = processConfigurationNodeList(node, configDefinitions, configNames); THROW_VR_EXCEPTION_IF(!c*K, "Invalid configuration defined in scene's robot tag '" << robotName << "'." << endl); } else if (nodeName == "globalpose") { processTransformNode(node, robotName, globalPose); } else if (nodeName == "robotnodeset") { rnsNodes.push_back(node); } else { THROW_VR_EXCEPTION("XML definition <" << nodeName << "> not supported in scene's Robot definition <" << robotName << ">." << endl); } node = node->next_sibling(); } // create & register robot THROW_VR_EXCEPTION_IF(fileName.empty(), "Missing file definition in scene's robot tag '" << robotName << "'." << endl); RobotPtr robot = RobotIO::loadRobot(fileName); THROW_VR_EXCEPTION_IF(!robot, "Invalid robot file in scene's robot tag '" << robotName << "'." << endl); robot->setGlobalPose(globalPose); scene->registerRobot(robot); // create & register node sets int rnsNr = 0; for (size_t i=0;i<rnsNodes.size();i++) { // registers rns to robot RobotNodeSetPtr r = processRobotNodeSet(rnsNodes[i], robot, robot->getRootNode()->getName(), rnsNr); THROW_VR_EXCEPTION_IF(!r, "Invalid RobotNodeSet definition " << endl); } // create & register configs THROW_VR_EXCEPTION_IF(configDefinitions.size()!=configNames.size(), "Invalid RobotConfig definitions " << endl); for (size_t i=0;i<configDefinitions.size();i++) { RobotConfigPtr rc(new RobotConfig(robot,configNames[i],configDefinitions[i])); scene->registerRobotConfig(robot,rc); } // process init config if (!initConfigName.empty()) { THROW_VR_EXCEPTION_IF(!scene->hasRobotConfig(robot,initConfigName), "Scene's robot tag '" << robotName << "' does not have the initConfig '" << initConfigName << "'." << endl); robot->setJointValues(scene->getRobotConfig(robot,initConfigName)); } return true; }
// 窗口事件处理 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 CXTPDockingPaneSplitterWnd::OnLButtonDown(UINT /*nFlags*/, CPoint point) { if (m_pContainer == 0) return; CXTPDockingPaneManager* pManager = GetDockingPaneManager(); if (pManager->IsSplittersLocked()) return; CXTPWindowRect rc(this); CRect rcAvail, rcUnion; if (!GetAvailableRect(rcAvail, rcUnion)) return; if (m_pContainer->OnAction(xtpPaneActionSplitterResizing)) return; m_pContainer->NormalizeDockingSize(); BOOL bHoriz = m_pContainer->m_bHoriz; //point = rc.TopLeft(); ClientToScreen(&point); if (pManager->IsSplitterTrackerUsed()) { CXTPSplitterTracker tracker; BOOL bAccept = tracker.Track(this, rcAvail, rc, point, bHoriz); if (bAccept) { Reposition(rc, rcUnion); pManager->RecalcFrameLayout(m_pContainer, TRUE); } } else { CPoint ptOffset = bHoriz ? CPoint(rc.left - point.x, 0) : CPoint(0, rc.top - point.y); SetCapture(); while (::GetCapture() == m_hWnd) { MSG msg; while (::PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_REMOVE | PM_NOYIELD)) { DispatchMessage(&msg); } if (!GetMessage(&msg, NULL, 0, 0)) break; if (msg.message == WM_MOUSEMOVE) { point = CPoint(msg.lParam); ClientToScreen(&point); point += ptOffset; point.x = max(min(point.x, rcAvail.right), rcAvail.left); point.y = max(min(point.y, rcAvail.bottom), rcAvail.top); if (bHoriz) { if (rc.left == point.x) continue; rc.OffsetRect(point.x - rc.left, 0); } else { if (rc.top == point.y) continue; rc.OffsetRect(0, point.y - rc.top); } Reposition(rc, rcUnion); pManager->RecalcFrameLayout(m_pContainer); } else if (msg.message == WM_KEYDOWN && msg.wParam == VK_ESCAPE) break; else if (msg.message == WM_LBUTTONUP) break; else ::DispatchMessage(&msg); } if (CWnd::GetCapture() == this) ReleaseCapture(); } m_pContainer->OnAction(xtpPaneActionSplitterResized); }
Z void showx(K x){ O("[%lld,%lld,%lld] ",xt,xn,rc(x));show(x);if(6==xt)O("\n");}