Example #1
0
PageTab::PageTab(const QRectF& pageTabGeometry,const QString& label,
				 PageTabBar * p_belongsTo,Page * p_refersToPage)
: ThingPaintable(pageTabGeometry)
, m_qp_currentTabBarOwner(p_belongsTo)
, m_qp_relatedToPage(p_refersToPage)
, m_qp_backgroundShadow(0)
, m_currentMode(PageTabDisplayMode::INVALID)
, m_savedMode(PageTabDisplayMode::INVALID)
, m_interactionsBlocked(false)
, m_currentBackgroundPmo(0)
, m_showLeftDivider(false)
, m_showRightDivider(false)
, m_leftDividerPmo(0)
, m_rightDividerPmo(0)
, m_tabLabel(label)
{
	m_textFont = PageTabBar::staticLabelFontForTabs();
	m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
	m_unselectedColor = LayoutSettings::settings()->tabBarUnSelectedTabFontColor;
	recalculateLabelBoundsForCurrentGeom();
	redoLabelTextLayout();
	recalculateLabelPosition();

	if (m_qp_currentTabBarOwner)
		this->setParentItem(m_qp_currentTabBarOwner);

	grabGesture(Qt::TapGesture);
	initSignalSlotConnections();

	m_backgroundGeom = m_geom;
	m_backgroundShadowGeom = m_backgroundGeom.adjusted(0.0,0.0,		//(left,up,right,down)
											0.0,2.0);
	ThingPaintable::recomputeBoundingRect(m_backgroundShadowGeom);
}
//virtual
void PixButton::setLabelVerticalAdjust(qint32 adjustPx)
{
	m_labelVerticalAdjust = adjustPx;
	m_textFont = PixButton::staticLabelFontForButtons();
	m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
	m_unselectedColor = LayoutSettings::settings()->doneButtonFontColor;
	recalculateLabelBoundsForCurrentGeom();
	redoLabelTextLayout();
	recalculateLabelPosition();
	update();
}
//virtual
void PixButton::setLabel(const QString& v)
{
	m_label = v;
	m_textFont = PixButton::staticLabelFontForButtons();
	m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
	m_unselectedColor = LayoutSettings::settings()->doneButtonFontColor;
	recalculateLabelBoundsForCurrentGeom();
	redoLabelTextLayout();
	recalculateLabelPosition();
	update();
}
//virtual
void PixButton::setLabel(const QString& v,quint32 fontSizePx)
{
	m_label = v;
	m_textFont = PixButton::staticLabelFontForButtons();
	quint32 fontSize = qBound((quint32)2,fontSizePx,(quint32)100);
	s_standardButtonFont.setPixelSize(fontSize);
	m_selectedColor = LayoutSettings::settings()->tabBarSelectedTabFontColor;
	m_unselectedColor = LayoutSettings::settings()->doneButtonFontColor;
	recalculateLabelBoundsForCurrentGeom();
	redoLabelTextLayout();
	recalculateLabelPosition();
	update();
}
Example #5
0
//virtual
bool PageTab::resize(const QSize& s)
{
	m_geom = DimensionsGlobal::realRectAroundRealPoint(QSizeF(s));
	m_backgroundGeom = m_geom;
	m_backgroundShadowGeom = m_backgroundGeom.adjusted(0.0,0.0,		//(left,up,right,down)
												0.0,2.0);
	recalculateLabelBoundsForCurrentGeom();
	redoLabelTextLayout();
	recalculateLabelPosition();
	QSize bgSize = m_backgroundGeom.size().toSize();
	for (QMap<qint32,QPointer<PixmapObject> >::iterator it = m_modeBackgrounds.begin();
			it != m_modeBackgrounds.end();++it)
	{
		if (it.value())
		{
			it.value()->resize(bgSize);
		}
	}
	if (m_qp_backgroundShadow)
	{
		m_qp_backgroundShadow->resize(m_backgroundShadowGeom.size().toSize());
	}

	if (m_leftDividerPmo)
	{
		m_leftDividerPmo->resize(s);
		//reposition it
		m_leftDividerPosPntCS = m_geom.topLeft();
	}
	if (m_rightDividerPmo)
	{
		m_rightDividerPmo->resize(s);
		//reposition it
		m_rightDividerPosPntCS = m_geom.topRight()-QPointF((qreal)(m_rightDividerPmo->size().width()),0);
	}

	//WARN: this should be the greatest of m_geom, m_backgroundShadowGeom, and m_backgroundGeom
	ThingPaintable::recomputeBoundingRect(m_backgroundShadowGeom);
	update();
	return true;
}