/********************************************************************* * * _Paint */ static void _Paint(PROGBAR_Handle hObj) { PROGBAR_Obj* pObj; GUI_RECT r, rInside, rClient, rText; const char* pText; char ac[5]; int tm, xPos; pObj = PROGBAR_H2P(hObj); WM_GetClientRect(&rClient); GUI__ReduceRect(&rInside, &rClient, pObj->Widget.pEffect->EffectSize); xPos = _Value2X(pObj, pObj->v); pText = _GetText(pObj, ac); GUI_SetFont(pObj->pFont); _GetTextRect(pObj, &rText, pText); tm = GUI_SetTextMode(GUI_TM_TRANS); /* Draw left bar */ r = rInside; r.x1 = xPos - 1; WM_SetUserClipArea(&r); _DrawPart(pObj, 0, rText.x0, rText.y0, pText); /* Draw right bar */ r = rInside; r.x0 = xPos; WM_SetUserClipArea(&r); _DrawPart(pObj, 1, rText.x0, rText.y0, pText); WM_SetUserClipArea(NULL); GUI_SetTextMode(tm); WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &rClient); }
/********************************************************************* * * PROGBAR_SetValue */ void PROGBAR_SetValue(PROGBAR_Handle hObj, int v) { if (hObj) { PROGBAR_Obj* pObj; WM_LOCK(); pObj= PROGBAR_H2P(hObj); /* Put v into legal range */ if (v < pObj->Min) { v = pObj->Min; } if (v > pObj->Max) { v = pObj->Max; } if (pObj->v != v) { GUI_RECT r; /* Get x values */ if (v < pObj->v) { r.x0 = _Value2X(pObj, v); r.x1 = _Value2X(pObj, pObj->v); } else { r.x0 = _Value2X(pObj, pObj->v); r.x1 = _Value2X(pObj, v); } r.y0 = 0; r.y1 = 4095; if (pObj->hpText == 0) { const GUI_FONT GUI_UNI_PTR * pOldFont; char acBuffer[5]; GUI_RECT rText; pOldFont = GUI_SetFont(pObj->pFont); _GetTextRect(pObj, &rText, _GetText(pObj, acBuffer)); GUI_MergeRect(&r, &r, &rText); pObj->v = v; _GetTextRect(pObj, &rText, _GetText(pObj, acBuffer)); GUI_MergeRect(&r, &r, &rText); GUI_SetFont(pOldFont); } else { pObj->v = v; } WM_InvalidateRect(hObj, &r); } WM_UNLOCK(); } }
/********************************************************************* * * PROGBAR_SetText */ void PROGBAR_SetText(PROGBAR_Handle hObj, const char* s) { if (hObj) { PROGBAR_Obj* pObj; const GUI_FONT GUI_UNI_PTR * pOldFont; GUI_RECT r1; char acBuffer[5]; WM_LOCK(); pObj = PROGBAR_H2P(hObj); pOldFont = GUI_SetFont(pObj->pFont); _GetTextRect(pObj, &r1, _GetText(pObj, acBuffer)); if (GUI__SetText(&pObj->hpText, s)) { GUI_RECT r2; _GetTextRect(pObj, &r2, _GetText(pObj, acBuffer)); GUI_MergeRect(&r1, &r1, &r2); WM_InvalidateRect(hObj, &r1); } GUI_SetFont(pOldFont); WM_UNLOCK(); } }
STDMETHODIMP touchmind::control::DWriteEditControlTextStoreACP::GetText( IN LONG acpStart, IN LONG acpEnd, OUT WCHAR *pchPlain, IN ULONG cchPlainReq, OUT ULONG *pcchPlainRet, OUT TS_RUNINFO *prgRunInfo, IN ULONG ulRunInfoReq, OUT ULONG *pulRunInfoOut, OUT LONG *pacpNext) { if (!_IsLocked(TS_LF_READ)) { return TS_E_NOLOCK; } BOOL fDoText = cchPlainReq > 0; BOOL fDoRunInfo = ulRunInfoReq > 0; LONG cchTotal; HRESULT hr = E_FAIL; if (pcchPlainRet) { *pcchPlainRet = 0; } if (fDoRunInfo) { *pulRunInfoOut = 0; } if (pacpNext) { *pacpNext = acpStart; } std::wstring text; _GetText(text, &cchTotal); if ((acpStart < 0) || (acpStart > cchTotal)) { hr = TS_E_INVALIDPOS; } else { if (acpStart == cchTotal) { hr = S_OK; } else { ULONG cchReq; if (acpEnd >= acpStart) { cchReq = acpEnd - acpStart; } else { cchReq = cchTotal - acpStart; } if (fDoText) { if (cchReq > cchPlainReq) { cchReq = cchPlainReq; } std::wstring substr = text.substr(acpStart, cchReq); if (pchPlain && cchPlainReq) { CopyMemory(pchPlain, substr.c_str(), cchReq * sizeof(WCHAR)); } } if (pcchPlainRet) { *pcchPlainRet = cchReq; } if (fDoRunInfo) { *pulRunInfoOut = 1; prgRunInfo[0].type = TS_RT_PLAIN; prgRunInfo[0].uCount = cchReq; } if (pacpNext) { *pacpNext = acpStart + cchReq; } hr = S_OK; } } return hr; }
void CTSFEditWnd::_Save(IStream *pStream) { if(pStream) { HRESULT hr; //write the plain UNICODE text into the stream LPWSTR pwsz; LONG cch; ULONG uWritten; LARGE_INTEGER li; ULONG uSize; //set the stream pointer to the start of the stream li.QuadPart = 0; pStream->Seek(li, STREAM_SEEK_SET, NULL); //get the text if(SUCCEEDED(_GetText(&pwsz, &cch))) { TF_PERSISTENT_PROPERTY_HEADER_ACP PropHeader; //write the size, in BYTES, of the text uSize = cch * sizeof(WCHAR); hr = pStream->Write(&uSize, sizeof(ULONG), &uWritten); //write the text, including the NULL_terminator, into the stream hr = pStream->Write(pwsz, uSize, &uWritten); //free the memory allocated by _GetText GlobalFree(pwsz); //enumerate the properties in the context IEnumTfProperties *pEnumProps; hr = m_pContext->EnumProperties(&pEnumProps); if(SUCCEEDED(hr)) { ITfProperty *pProp; ULONG uFetched; while(SUCCEEDED(pEnumProps->Next(1, &pProp, &uFetched)) && uFetched) { //enumerate all the ranges that contain the property IEnumTfRanges *pEnumRanges; hr = pProp->EnumRanges(m_EditCookie, &pEnumRanges, NULL); if(SUCCEEDED(hr)) { IStream *pTempStream; //create a temporary stream to write the property data to hr = CreateStreamOnHGlobal(NULL, TRUE, &pTempStream); if(SUCCEEDED(hr)) { ITfRange *pRange; while(SUCCEEDED(pEnumRanges->Next(1, &pRange, &uFetched)) && uFetched) { //reset the temporary stream's pointer li.QuadPart = 0; pTempStream->Seek(li, STREAM_SEEK_SET, NULL); //get the property header and data for the range hr = m_pServices->Serialize(pProp, pRange, &PropHeader, pTempStream); /* Write the property header into the primary stream. The header also contains the size of the property data. */ hr = pStream->Write(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP), &uWritten); //reset the temporary stream's pointer li.QuadPart = 0; pTempStream->Seek(li, STREAM_SEEK_SET, NULL); //copy the property data from the temporary stream into the primary stream ULARGE_INTEGER uli; uli.QuadPart = PropHeader.cb; hr = pTempStream->CopyTo(pStream, uli, NULL, NULL); pRange->Release(); } pTempStream->Release(); } pEnumRanges->Release(); } pProp->Release(); } pEnumProps->Release(); } //write a property header with zero size and guid into the stream as a terminator ZeroMemory(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP)); hr = pStream->Write(&PropHeader, sizeof(TF_PERSISTENT_PROPERTY_HEADER_ACP), &uWritten); } } }