Exemplo n.º 1
0
bool NodeInstance::hasAnchors() const
{
    return hasAnchor("anchors.fill")
            || hasAnchor("anchors.centerIn")
            || hasAnchor("anchors.top")
            || hasAnchor("anchors.left")
            || hasAnchor("anchors.right")
            || hasAnchor("anchors.bottom")
            || hasAnchor("anchors.horizontalCenter")
            || hasAnchor("anchors.verticalCenter")
            || hasAnchor("anchors.baseline");
}
Exemplo n.º 2
0
QPair<QString, ServerNodeInstance> QmlGraphicsItemNodeInstance::anchor(const QString &name) const
{
    if (!isValidAnchorName(name) || !hasAnchor(name))
        return GraphicsObjectNodeInstance::anchor(name);

    QObject *targetObject = 0;
    QString targetName;

    if (name == "anchors.fill") {
        targetObject = anchors()->fill();
    } else if (name == "anchors.centerIn") {
        targetObject = anchors()->centerIn();
    } else {
        QDeclarativeProperty metaProperty(object(), name, context());
        if (!metaProperty.isValid())
            return GraphicsObjectNodeInstance::anchor(name);

        QDeclarativeAnchorLine anchorLine = metaProperty.read().value<QDeclarativeAnchorLine>();
        if (anchorLine.anchorLine != QDeclarativeAnchorLine::Invalid) {
            targetObject = anchorLine.item;
            targetName = propertyNameForAnchorLine(anchorLine.anchorLine);
        }

    }

    if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) {
        return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject));
    } else {
        return GraphicsObjectNodeInstance::anchor(name);
    }
}
Exemplo n.º 3
0
bool CHexViewView::isNewSelection() {
  if(m_keepSelection) {
    return false;
  }
  if(m_shift) {
    if(!hasAnchor()) {
      dropAnchor(m_lastCurrentAddr);
      return true;
    }
  } else { // !m_shift
    if(hasAnchor()) {
      resetAnchor();
      return true;
    }
  }
  return getSelection() != m_lastSelection;
}
Exemplo n.º 4
0
void CHexViewView::OnMouseMove(UINT nFlags, CPoint point) {
  if((nFlags & MK_LBUTTON) && hasAnchor()) {
    const __int64 addr = getFileAddrFromPoint(point);
    if(addr >= 0) {
      setCurrentAddr(addr);
    }
  }
  CView::OnMouseMove(nFlags, point);
}
Exemplo n.º 5
0
__int64 CHexViewView::getBestTopLine(__int64 addr) const {
  const __int64 line1  = GETLINENO(addr);
  const __int64 addr2  = hasAnchor() ? getAnchor() : addr;
  const __int64 line2  = GETLINENO(addr2);

  if(ISVISIBLELINE(line1) && ISVISIBLELINE(line2)) {
    return m_topLine; // no need to do vertical scroll
  }
  const __int64 selectedLineCount = (addr == addr2) ? 0 : (abs(line1 - line2) + 1);
  if(selectedLineCount <= m_pageSize.cy) {
    return min(line1, line2) - (m_pageSize.cy - selectedLineCount)/2;
  } else {
    return min(line1, line2);
  }
}
Exemplo n.º 6
0
void CHexViewView::setCurrentAddr(unsigned __int64 addr, bool invalidate) {
  if(addr > m_docSize) {
    return;
  }

  keepSelection();
  if(addr != getCurrentAddr() && hasAnchor()) {
    invalidate = true;
  }
  const __int64 newTopLine = getBestTopLine(   addr);
  const int     newOffset  = getBestLineOffset(addr);
  if((newTopLine != m_topLine) || (newOffset != m_lineOffset)) {
    setTopLine(newTopLine, false).setLineOffset(newOffset, false);
    invalidate = true;
  }
  setCaret(GETLINEOFFSET(addr) - m_lineOffset, (int)(GETLINENO(addr) - m_topLine), invalidate);
}
Exemplo n.º 7
0
int CHexViewView::getBestLineOffset(__int64 addr) const {
  const __int64 offset1 = GETLINEOFFSET(addr);
  const __int64 addr2   = hasAnchor() ? getAnchor() : addr;
  const __int64 offset2 = GETLINEOFFSET(addr2);

  if(ISVISIBLEOFFSET(offset1) && ISVISIBLEOFFSET(offset2)) {
    return m_lineOffset; // no need to do horizontal scroll
  }
  const __int64 line1 = GETLINENO(addr );
  const __int64 line2 = GETLINENO(addr2);
  if(line1 == line2) {
    const int length = (int)abs(addr - addr2);
    if(length <= m_pageSize.cx) {
      return (int)(min(offset1, offset2) - (m_pageSize.cx - length)/2);
    } else {
      return (int)min(offset1, offset2);
    }
  } else {
    return (int)min(offset1, offset2);
  }
}
Exemplo n.º 8
0
AddrRange CHexViewView::getSelection() const {
  return hasAnchor() ? AddrRange(m_anchor, getCurrentAddr()) : AddrRange();
}
Exemplo n.º 9
0
unsigned __int64 CHexViewView::getAnchor() const {
  return hasAnchor() ? m_anchor : getCurrentAddr();
}
Exemplo n.º 10
0
bool CHexViewView::resetAnchor() {
  const bool ret = hasAnchor();
  m_anchor = -1;
  return ret;
}