Qt 4.8
Functions
qdeclarativeanchors.cpp File Reference
#include "private/qdeclarativeanchors_p_p.h"
#include "qdeclarativeitem.h"
#include "private/qdeclarativeitem_p.h"
#include <qdeclarativeinfo.h>
#include <QDebug>
#include <moc_qdeclarativeanchors_p.cpp>

Go to the source code of this file.

Functions

static qreal adjustedPosition (QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
 
static qreal hcenter (QGraphicsItem *i)
 
static qreal position (QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
 
QDeclarativeAnchorLine::AnchorLine reverseAnchorLine (QDeclarativeAnchorLine::AnchorLine anchorLine)
 
static qreal vcenter (QGraphicsItem *i)
 

Function Documentation

◆ adjustedPosition()

static qreal adjustedPosition ( QGraphicsObject item,
QDeclarativeAnchorLine::AnchorLine  anchorLine 
)
static

Definition at line 117 of file qdeclarativeanchors.cpp.

Referenced by QDeclarativeAnchorsPrivate::updateHorizontalAnchors(), and QDeclarativeAnchorsPrivate::updateVerticalAnchors().

118 {
119  qreal ret = 0.0;
121  switch(anchorLine) {
123  ret = 0.0;
124  break;
126  ret = d->width();
127  break;
129  ret = 0.0;
130  break;
132  ret = d->height();
133  break;
135  ret = hcenter(item);
136  break;
138  ret = vcenter(item);
139  break;
141  if (d->isDeclarativeItem)
142  ret = static_cast<QDeclarativeItem*>(item)->baselineOffset();
143  break;
144  default:
145  break;
146  }
147 
148  return ret;
149 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
virtual qreal height() const
static qreal vcenter(QGraphicsItem *i)
The QDeclarativeItem class provides the most basic of all visual items in QML.
virtual qreal width() const
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
static qreal hcenter(QGraphicsItem *i)

◆ hcenter()

static qreal hcenter ( QGraphicsItem i)
static

Definition at line 56 of file qdeclarativeanchors.cpp.

Referenced by adjustedPosition(), QDeclarativeAnchorsPrivate::centerInChanged(), position(), and QDeclarativeAnchorsPrivate::updateHorizontalAnchors().

57 {
59 
60  qreal width = item->width();
61  int iw = width;
62  if (iw % 2)
63  return (width + 1) / 2;
64  else
65  return width / 2;
66 }
double qreal
Definition: qglobal.h:1193
virtual qreal width() const
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)

◆ position()

static qreal position ( QGraphicsObject item,
QDeclarativeAnchorLine::AnchorLine  anchorLine 
)
static

Definition at line 82 of file qdeclarativeanchors.cpp.

Referenced by QAbstractScrollArea::addScrollBarWidget(), QTextBlock::begin(), QTextDocumentPrivate::block(), QDeclarativeAnchorsPrivate::calcStretch(), QPlainTextEdit::centerCursor(), QAccessibleStackedWidget::childAt(), QTextFragment::contains(), QOCICols::create(), QUrlPrivate::createErrorString(), QOCICols::createLobLocator(), QTextLine::cursorToX(), QTextLayout::draw(), QTextLayout::drawCursor(), QTreeView::drawRow(), QAbstractItemViewPrivate::dropOn(), QtMultimediaInternal::QAudioPacketFeeder::empty(), QTextBlock::end(), QDeclarativeListViewPrivate::endPositionAt(), QPatternist::InsertBeforeFN::evaluateSequence(), QtMultimediaInternal::QAudioPacketFeeder::feed(), QWingedEdge::findInsertStatus(), firstFramePosLessThanCursorPos(), QDeclarativeListViewPrivate::firstVisibleItem(), QDeclarativeGridViewPrivate::firstVisibleItem(), QDeclarativeGridViewPrivate::fixup(), QDeclarativeListViewPrivate::fixup(), flowPosition(), QTextTablePrivate::fragmentAdded(), QTextDocumentLayoutPrivate::frameIteratorForYPosition(), QTextFragment::glyphRuns(), QTextDocumentLayout::hitTest(), QTextDocumentLayoutPrivate::hitTest(), QTextTable::insertColumns(), QGlyphLayout::instance(), QTreeViewPrivate::itemDecorationRect(), QDeclarativeListView::itemsInserted(), QGlyphLayout::mid(), QString::mid(), QString::midRef(), QTextLineItemIterator::next(), QTextDocumentPrivate::nextCursorPosition(), QSqlRecord::operator!=(), QTextBlock::operator<(), QTextFragment::operator<(), QTextOption::Tab::operator==(), QSettingsKey::originalKeyPosition(), QDeclarativeListViewPrivate::originPosition(), CloseButton::paintEvent(), QNetworkCookiePrivate::parseSetCookieHeaderLine(), QRawFont::pathForGlyph(), QDeclarativeListViewPrivate::positionAt(), QDeclarativeGridViewPrivate::positionViewAtIndex(), QDeclarativeListViewPrivate::positionViewAtIndex(), QTextDocumentPrivate::previousCursorPosition(), QtMultimediaInternal::QAudioPacketFeeder::QAudioPacketFeeder(), QScript::qobjectProtoFuncFindChildren(), QStringRef::QStringRef(), QConfFileSettingsPrivate::readIniFile(), QConfFileSettingsPrivate::readIniSection(), QDeclarativeListViewPrivate::refill(), QTextControlPrivate::repaintSelection(), QExpandingLineEdit::resizeToContents(), QPatternist::XPath10CoreFunctions::retrieveExpression(), QDeclarativeRewrite::RewriteBinding::rewrite(), QAbstractSliderPrivate::scrollByDelta(), QHeaderView::sectionViewportPosition(), QListViewPrivate::selectionAllowed(), QAbstractItemViewPrivate::selectionBehaviorFlags(), QTextControl::selectionRect(), QWSCalibratedMouseHandler::sendFiltered(), QGlyphLayout::setInstance(), QDeclarativeRewrite::RewriteBinding::setName(), QHeaderView::setOffsetToLastSection(), QHeaderView::setOffsetToSectionPosition(), setPenAndDrawBackground(), QDeclarativeGradientStop::setPosition(), QTextLayout::setPreeditArea(), QListModeViewBase::setRowCount(), QAbstractSlider::setSliderPosition(), QMdiArea::setTabPosition(), QSlider::setTickPosition(), QPatternist::AccelTree::sourceLocation(), QTextBlock::text(), QTextBlock::textDirection(), QTextEdit::toHtml(), QFileDialogPrivate::toInternal(), QTextBoundaryFinder::type(), QDeclarativeListViewPrivate::updateCurrentSection(), QDeclarativeGridViewPrivate::updateFooter(), QDeclarativeListViewPrivate::updateFooter(), QDeclarativeGridViewPrivate::updateHeader(), QDeclarativeListViewPrivate::updateHeader(), QDeclarativeAnchorsPrivate::updateHorizontalAnchors(), QDeclarativeListViewPrivate::updateUnrequestedPositions(), QDeclarativeAnchorsPrivate::updateVerticalAnchors(), QSidebar::urls(), QCommonStylePrivate::viewItemDrawText(), QHeaderView::visualIndexAt(), QAccessibleTextInterface::~QAccessibleTextInterface(), and QTestEvent::~QTestEvent().

83 {
84  qreal ret = 0.0;
86  switch(anchorLine) {
88  ret = item->x();
89  break;
91  ret = item->x() + d->width();
92  break;
94  ret = item->y();
95  break;
97  ret = item->y() + d->height();
98  break;
100  ret = item->x() + hcenter(item);
101  break;
103  ret = item->y() + vcenter(item);
104  break;
106  if (d->isDeclarativeItem)
107  ret = item->y() + static_cast<QDeclarativeItem*>(item)->baselineOffset();
108  break;
109  default:
110  break;
111  }
112 
113  return ret;
114 }
double d
Definition: qnumeric_p.h:62
double qreal
Definition: qglobal.h:1193
qreal y
the y position of the item
virtual qreal height() const
static qreal vcenter(QGraphicsItem *i)
The QDeclarativeItem class provides the most basic of all visual items in QML.
virtual qreal width() const
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)
static qreal hcenter(QGraphicsItem *i)
qreal x
the x position of the item

◆ reverseAnchorLine()

Definition at line 586 of file qdeclarativeanchors.cpp.

Referenced by QDeclarativeAnchorsPrivate::updateHorizontalAnchors().

586  {
587  if (anchorLine == QDeclarativeAnchorLine::Left) {
589  } else if (anchorLine == QDeclarativeAnchorLine::Right) {
591  } else {
592  return anchorLine;
593  }
594 }

◆ vcenter()

static qreal vcenter ( QGraphicsItem i)
static

Definition at line 68 of file qdeclarativeanchors.cpp.

Referenced by adjustedPosition(), QDeclarativeAnchorsPrivate::centerInChanged(), position(), and QDeclarativeAnchorsPrivate::updateVerticalAnchors().

69 {
71 
72  qreal height = item->height();
73  int ih = height;
74  if (ih % 2)
75  return (height + 1) / 2;
76  else
77  return height / 2;
78 }
double qreal
Definition: qglobal.h:1193
virtual qreal height() const
static const QGraphicsItemPrivate * get(const QGraphicsItem *item)