void KSlider::mousePressEvent(QGraphicsSceneMouseEvent * event) { Q_D(KSlider); QRectF thumbRect = d->m_thumb->geometry(); if ( thumbRect.contains(event->pos()) ) { d->m_isDragging = true; d->m_pointInThumb = event->pos() - thumbRect.topLeft(); d->m_thumb->setDown(); } else { d->m_thumb->setNormal(); if(d->m_orientation == Qt::Vertical) { qreal val = event->pos().y() - d->m_thumbSize.height() / 2; qreal ratio = val / (height() - d->m_thumbSize.height()); _setValue(ratio); } else { qreal val = event->pos().x() - d->m_thumbSize.width() / 2; qreal ratio = val / (width() - d->m_thumbSize.width()); _setValue(ratio); } } }
bool fp_FieldTOCHeadingRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; // // First get owning TOC. // UT_ASSERT(getLength() == 0); fl_TOCLayout * pTOCL = static_cast<fl_TOCLayout *>(getBlock()->myContainingLayout()); UT_ASSERT(pTOCL->getContainerType() == FL_CONTAINER_TOC); UT_UCS4String str = pTOCL->getTOCHeading().ucs4_str(); if(str.size() == 0) { sz_ucs_FieldValue[0] = 0; return _setValue(sz_ucs_FieldValue); } UT_sint32 i = 0; bool bStop = false; for(i=0; (i<FPFIELD_MAX_LENGTH) && !bStop; i++) { sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(str[i]); if(str[i] == 0) { bStop = true; } } return _setValue(sz_ucs_FieldValue); }
bool fp_FieldTOCNumRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; // // First Find page number. // PL_StruxDocHandle sdh = getBlock()->getStruxDocHandle(); PD_Document * pDoc = getBlock()->getDocument(); PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1; FL_DocLayout * pLayout = getBlock()->getDocLayout(); fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos); if(pBlockInDoc == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Line * pLine = static_cast<fp_Line *>(pBlockInDoc->getFirstContainer()); if(pLine == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Page * pPage = pLine->getPage(); UT_sint32 iPage = pLayout->findPage(pPage); if( iPage < 0) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } iPage++; // Start from Page 1. UT_String sVal(""); FootnoteType iType = getBlock()->getTOCNumType(); pLayout->getStringFromFootnoteVal(sVal,iPage,iType); const char * psz = sVal.c_str(); bool bStop = false; UT_sint32 i = 0; sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); for(i=1; (i<FPFIELD_MAX_LENGTH) && !bStop; i++) { sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(*psz); if(*psz == 0) { bStop = true; } else { psz++; } } return _setValue(sz_ucs_FieldValue); }
bool fp_FieldListLabelRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; UT_uint32 i = 0; UT_UCSChar * listlabel = NULL; if(getBlock()->isContainedByTOC()) { xxx_UT_DEBUGMSG(("!!!!!!------!!!! ListLabel in TOC!!!! \n")); // // First Find the block in the document. // pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle(); PD_Document * pDoc = getBlock()->getDocument(); PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1; FL_DocLayout * pLayout = getBlock()->getDocLayout(); fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos); if(pBlockInDoc == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } i = 0; listlabel = pBlockInDoc->getListLabel(); } else { i = 0; listlabel = getBlock()->getListLabel(); } if(listlabel == NULL) { sz_ucs_FieldValue[0] = 0; } else { // // This code is here because UT_UCS_copy_char is broken // i = 0; UT_uint32 len = UT_MIN( UT_UCS4_strlen(listlabel),FPFIELD_MAX_LENGTH + 1) ; for(i=0; i<=len;i++) { sz_ucs_FieldValue[i] = *listlabel++; } // sz_ucs_FieldValue[len] = 0; // m_sFieldValue[0] = 0; // Force an update!!! } return _setValue(sz_ucs_FieldValue); }
bool BLECharacteristicImp::writeValue(const byte value[], int length, int offset) { int status; bool retVal = false; _setValue(value, length, offset); // Address same is GATT server. Send notification if CCCD enabled // Different is GATT client. Send write request if (true == BLEUtils::isLocalBLE(_ble_device) && NULL != _attr_chrc_value) { // Notify for peripheral. status = bt_gatt_notify(NULL, _attr_chrc_value, value, length, NULL); // Sid. KW found status is always 0. // if (!status) // { retVal = true; // } } //Not schedule write request for central // The write request may failed. // If user want to get latest set value. Call read and get the real value return retVal; }
void KSlider::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { Q_D(KSlider); if (d->m_isDragging) { if(d->m_orientation == Qt::Vertical) { qreal yValue = event->pos().y() - d->m_pointInThumb.y(); _setValue( yValue / (height() - d->m_thumbSize.height())); } else { qreal xValue = event->pos().x() - d->m_pointInThumb.x(); _setValue( xValue / (width() - d->m_thumbSize.width())); } } }
bool KSlider::setValue(qreal value) { Q_D(KSlider); if(value > d->m_maximum) value = d->m_maximum; if(value < d->m_minimum) value = d->m_minimum; qreal val = (value - d->m_minimum) / (d->m_maximum - d->m_minimum); return _setValue(val); }
void BLECharacteristic::setValue(BLEHelper& blehelper, const unsigned char* value, unsigned short length) { //BLEHelper *bledevice = ¢ral; _setValue(value, length); _written = true; _reading = false; if (_event_handlers[BLEWritten]) { _event_handlers[BLEWritten](blehelper, *this); } }
UT_sint32 fp_AnnotationRun::calcWidth(void) { UT_sint32 iNewWidth = 0; _setValue(); getGraphics()->setFont(_getFont()); if(m_sValue.size() > 0) { iNewWidth = getGraphics()->measureString(m_sValue.ucs4_str().ucs4_str(), 0, m_sValue.ucs4_str().size(), NULL); } UT_ASSERT(iNewWidth > 0); return iNewWidth; }
bool BLECharacteristicImp::setValue(const unsigned char value[], uint16_t length) { _setValue(value, length, 0); if (BLEUtils::isLocalBLE(_ble_device) == true) { // GATT server // Write request for GATT server if (_event_handlers[BLEWritten]) { BLECharacteristic chrcTmp(this, &_ble_device); _event_handlers[BLEWritten](_ble_device, chrcTmp); } if (_oldevent_handlers[BLEWritten]) { BLECharacteristic chrcTmp(this, &_ble_device); BLECentral central(_ble_device); _oldevent_handlers[BLEWritten](central, chrcTmp); } } else { // GATT client // Discovered attribute // Read response/Notification/Indication for GATT client if (_reading) { // Read response received. Not block the other reading. _reading = false; } if (_event_handlers[BLEValueUpdated]) { BLECharacteristic chrcTmp(this, &_ble_device); _event_handlers[BLEValueUpdated](_ble_device, chrcTmp); } if (_oldevent_handlers[BLEValueUpdated]) { BLECharacteristic chrcTmp(this, &_ble_device); BLECentral central(_ble_device); _oldevent_handlers[BLEValueUpdated](central, chrcTmp); } } return true; }
bool BLECharacteristic::setValue(const unsigned char value[], uint16_t length) { int status; _setValue(value, length); if (_attr_chrc_value) { // TODO: Notify for peripheral. // Write request for central. status = bt_gatt_notify(NULL, _attr_chrc_value, value, length, NULL); if (0 != status) { return false; } } return true; }
void RGB::setValue(uint8_t r, uint8_t g, uint8_t b) { mode = MANUAL; _setValue(r, g, b); }
bool fp_FieldTableSumCols::calculateValue(void) { FV_View * pView = _getView(); pf_Frag_Strux* tableSDH= NULL; UT_sint32 numRows =0; UT_sint32 numCols = 0; bUseCurrency = false; cCurrency = '$'; pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle(); PD_Document * pDoc = getBlock()->getDocument(); if(pDoc->isPieceTableChanging()) { return false; } if(getLine() == NULL) { return false; } fp_Container * pCol = getLine()->getColumn(); if(pCol == NULL) { return false; } fp_ShadowContainer * pShad =NULL; fl_HdrFtrShadow * pShadL = NULL; if(pCol->getContainerType() == FP_CONTAINER_COLUMN_SHADOW) { pShad = static_cast<fp_ShadowContainer *>(pCol); pShadL = pShad->getShadow(); } PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1; pDoc->getStruxOfTypeFromPosition(pos,PTX_SectionTable,&tableSDH); pDoc-> getRowsColsFromTableSDH(tableSDH, pView->isShowRevisions(), pView->getRevisionLevel(), &numRows, &numCols); UT_UTF8String sValF; if(!pView->isInTable(pos)) { sValF = "???"; return _setValue(sValF.ucs4_str().ucs4_str()); } fl_CellLayout * pCell = NULL; UT_sint32 myLeft,myRight,myTop,myBot; pView->getCellParams(pos,&myLeft,&myRight,&myTop,&myBot); UT_sint32 col = 0; UT_sint32 row = myTop; UT_sint32 lastCol = -1; double dSum = 0.0; for(col = 0; col < numCols; col++) { pf_Frag_Strux* sdhCell = pDoc->getCellSDHFromRowCol(tableSDH,true,99999,row,col); UT_sint32 i = getBlock()->getDocLayout()->getLID(); fl_ContainerLayout* fmtCell = pDoc->getNthFmtHandle(sdhCell,i); pCell = static_cast<fl_CellLayout *>(fmtCell); if(pCell->getLeftAttach() == lastCol) { continue; } if((pCell->getTopAttach() == myTop) && (pCell->getLeftAttach() == myLeft)) { continue; } UT_GrowBuf grText; pCell->appendTextToBuf(grText); if(grText.getLength() == 0) { fl_ContainerLayout * pC = pCell->getFirstLayout(); while(pC) { if(pC->getContainerType() == FL_CONTAINER_BLOCK) { fl_BlockLayout * pBL = static_cast<fl_BlockLayout *>(pC); if(pShadL) { pBL = static_cast<fl_BlockLayout *>(pShadL->findMatchingContainer(pBL)); } if(pBL == NULL) { continue; } fp_Run * pRun = pBL->getFirstRun(); while(pRun) { if(pRun->getType() == FPRUN_FIELD) { fp_FieldRun * pFRun = static_cast<fp_FieldRun *>(pRun); const UT_UCS4Char * szVal = pFRun->getValue(); sValF.clear(); sValF.appendUCS4(szVal); dSum += dGetVal(sValF.utf8_str()); pRun = NULL; pC = NULL; break; } pRun = pRun->getNextRun(); } } if(pC) { pC = pC->getNext(); } } } else { sValF.clear(); sValF.appendUCS4(reinterpret_cast<const UT_UCS4Char *>(grText.getPointer(0)),grText.getLength()); dSum += dGetVal(sValF.utf8_str()); } lastCol = col; } sFormatDouble(sValF,dSum); return _setValue(sValF.ucs4_str().ucs4_str()); }
bool fp_FieldTOCNumRun::calculateValue(void) { UT_UCSChar sz_ucs_FieldValue[FPFIELD_MAX_LENGTH + 1]; // // First Find page number. // pf_Frag_Strux* sdh = getBlock()->getStruxDocHandle(); PD_Document * pDoc = getBlock()->getDocument(); PT_DocPosition pos = pDoc->getStruxPosition(sdh)+1; FL_DocLayout * pLayout = getBlock()->getDocLayout(); fl_BlockLayout * pBlockInDoc = pLayout->findBlockAtPosition(pos); if(pBlockInDoc == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Line * pLine = static_cast<fp_Line *>(pBlockInDoc->getFirstContainer()); UT_sint32 kk = 0; bool b_goodLine = false; while (pLine && !b_goodLine) { for (kk = 0; kk < pLine->getNumRunsInLine(); kk++) { if(pLine->getRunFromIndex(kk)->getType() == FPRUN_TEXT) { b_goodLine = true; break; } } if (!b_goodLine) { pLine = static_cast<fp_Line *>(pLine->getNext()); } } if(pLine == NULL) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } fp_Page * pPage = pLine->getPage(); UT_sint32 iPage = pPage->getFieldPageNumber(); bool b_hasSetFieldPageNumber = false; if(iPage < 0) { pPage->resetFieldPageNumber(); iPage = pPage->getFieldPageNumber(); b_hasSetFieldPageNumber = true; if (iPage < 0) { sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); sz_ucs_FieldValue[1] = 0; return _setValue(sz_ucs_FieldValue); } } UT_String sVal(""); FootnoteType iType = getBlock()->getTOCNumType(); pLayout->getStringFromFootnoteVal(sVal,iPage,iType); const char * psz = sVal.c_str(); if (b_hasSetFieldPageNumber) { // We need to set the field page number value to -1 so that we // recalculate the page number next time we enter this function pPage->setFieldPageNumber(-1); } bool bStop = false; UT_sint32 i = 0; sz_ucs_FieldValue[0] = static_cast<UT_UCSChar>(' '); for(i=1; (i<FPFIELD_MAX_LENGTH) && !bStop; i++) { sz_ucs_FieldValue[i] = static_cast<UT_UCSChar>(*psz); if(*psz == 0) { bStop = true; } else { psz++; } } return _setValue(sz_ucs_FieldValue); }
void Playstring::setValue(const char *newval) { _setValue(newval, 0); }