Ejemplo n.º 1
0
void W32VBox::setPosition(int x, int y, Size size) {
	int elementCounter = visibleElementsNumber();
	if (elementCounter == 0) {
		return;
	}

	x += leftMargin();
	y += topMargin();
	if (homogeneous()) {
		const Size elementSize(
			size.Width - leftMargin() - rightMargin(),
			(size.Height - topMargin() - bottomMargin() - spacing() * (elementCounter - 1)) / elementCounter
		);
		const short deltaY = elementSize.Height + spacing();
		for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
			if ((*it)->isVisible()) {
				(*it)->setPosition(x, y, elementSize);
				y += deltaY;
			}
		}
	} else {
		const short elementWidth = size.Width - leftMargin() - rightMargin();
		for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
			if ((*it)->isVisible()) {
				Size elementSize = (*it)->minimumSize();
				elementSize.Width = elementWidth;
				(*it)->setPosition(x, y, elementSize);
				y += elementSize.Height + spacing();
			}
		}
	}
}
Ejemplo n.º 2
0
void W32HBox::setPosition(int x, int y, Size size) {
	int elementCounter = visibleElementsNumber();
	if (elementCounter == 0) {
		return;
	}

	x += leftMargin();
	y += topMargin();
	if (homogeneous()) {
		Size elementSize(0, size.Height - topMargin() - bottomMargin());
		for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
			if ((*it)->isVisible()) {
				Size currentSize = (*it)->minimumSize();
				elementSize.Width = std::max(currentSize.Width, elementSize.Width);
			}
		}
		if (myAlignment != LEFT) {
			const short extraWidth = size.Width - leftMargin() - rightMargin() - elementSize.Width * elementCounter - spacing() * (elementCounter - 1);
			if (myAlignment == CENTER) {
				x += extraWidth / 2;
			} else if (myAlignment == RIGHT) {
				x += extraWidth;
			} else if (myAlignment == FILL) {
				elementSize.Width += extraWidth / elementCounter;
			}
		}
		const short deltaX = elementSize.Width + spacing();
		for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
			if ((*it)->isVisible()) {
				(*it)->setPosition(x, y, elementSize);
				x += deltaX;
			}
		}
	} else {
		if (myAlignment != LEFT) {
			short extraWidth = size.Width - leftMargin() - rightMargin() - spacing() * (elementCounter - 1);
			for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
				if ((*it)->isVisible()) {
					Size currentSize = (*it)->minimumSize();
					extraWidth -= currentSize.Width;
				}
			}
			if (myAlignment == CENTER) {
				x += extraWidth / 2;
			} else if (myAlignment == RIGHT) {
				x += extraWidth;
			}
		}
		const int elementHeight = size.Height - topMargin() - bottomMargin();
		Size elementSize;
		for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
			if ((*it)->isVisible()) {
				Size elementSize = (*it)->minimumSize();
				elementSize.Height = elementHeight;
				(*it)->setPosition(x, y, elementSize);
				x += elementSize.Width + spacing();
			}
		}
	}
}
Ejemplo n.º 3
0
W32Widget::Size W32HBox::minimumSize() const {
	if (myElements.empty()) {
		return Size(leftMargin() + rightMargin(), topMargin() + bottomMargin());
	}

	Size size;
	int elementCounter = 0;
	for (W32WidgetList::const_iterator it = myElements.begin(); it != myElements.end(); ++it) {
		if ((*it)->isVisible()) {
			Size elementSize = (*it)->minimumSize();
			if (homogeneous()) {
				size.Width = std::max(size.Width, elementSize.Width);
			} else {
				size.Width += elementSize.Width;
			}
			size.Height = std::max(size.Height, elementSize.Height);
			++elementCounter;
		}
	}
	if (homogeneous()) {
		size.Width *= elementCounter;
	}
	size.Width += leftMargin() + rightMargin() + spacing() * (elementCounter - 1);
	size.Height += topMargin() + bottomMargin();
	return size;
}
Ejemplo n.º 4
0
void QVistaHelper::drawTitleBar(QPainter *painter)
{
    Q_ASSERT(backButton_);
    QPoint origin;
    const bool isWindow = wizard->isWindow();
    const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin);

    if (vistaState() == VistaAero && isWindow)
        drawBlackRect(QRect(0, 0, wizard->width(),
                            titleBarSize() + topOffset()), hdc);
    // The button is positioned in QWizardPrivate::handleAeroStyleChange(),
    // all calculation is relative to it.
    const int btnTop = backButton_->mapToParent(QPoint()).y();
    const int btnHeight = backButton_->size().height();
    const int verticalCenter = (btnTop + btnHeight / 2) - 1;

    const QString text = wizard->window()->windowTitle();
    QFont font;
    if (!isWindow || !getCaptionQFont(wizard->logicalDpiY() * wizard->devicePixelRatio(), &font))
        font = QApplication::font("QMdiSubWindowTitleBar");
    const QFontMetrics fontMetrics(font);
    const QRect brect = fontMetrics.boundingRect(text);
    int textHeight = brect.height();
    int textWidth = brect.width();
    int glowOffset = 0;

    if (vistaState() == VistaAero) {
        textHeight += 2 * glowSize();
        textWidth += 2 * glowSize();
        glowOffset = glowSize();
    }

    const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight
                           ? titleOffset() - glowOffset
                           : wizard->width() - titleOffset() - textWidth + glowOffset);

    const QRect textRectangle(titleLeft, verticalCenter - textHeight / 2, textWidth, textHeight);
    if (isWindow) {
        drawTitleText(painter, text, textRectangle, hdc);
    } else {
        painter->save();
        painter->setFont(font);
        painter->drawText(textRectangle, Qt::AlignVCenter | Qt::AlignHCenter, text);
        painter->restore();
    }

    const QIcon windowIcon = wizard->windowIcon();
    if (!windowIcon.isNull()) {
        const int size = QVistaHelper::iconSize();
        const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight
                              ? leftMargin()
                              : wizard->width() - leftMargin() - size);

        const QPoint pos(origin.x() + iconLeft, origin.y() + verticalCenter - size / 2);
        const QPoint posDp = pos * QVistaHelper::m_devicePixelRatio;
        const HICON hIcon = qt_pixmapToWinHICON(windowIcon.pixmap(size * QVistaHelper::m_devicePixelRatio));
        DrawIconEx(hdc, posDp.x(), posDp.y(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
        DestroyIcon(hIcon);
    }
}
void QVistaHelper::drawTitleBar(QPainter *painter)
{
    Q_ASSERT(backButton_);
    QPoint origin;
    const bool isWindow = wizard->isWindow();
    const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin);

    if (vistaState() == VistaAero && isWindow)
        drawBlackRect(QRect(0, 0, wizard->width(),
                            titleBarSize() + topOffset()), hdc);
    const int btnTop = backButton_->mapToParent(QPoint()).y();
    const int btnHeight = backButton_->size().height();
    const int verticalCenter = (btnTop + btnHeight / 2) - 1;

    const QString text = wizard->window()->windowTitle();
    const QFont font = QApplication::font("QMdiSubWindowTitleBar");
    const QFontMetrics fontMetrics(font);
    const QRect brect = fontMetrics.boundingRect(text);
    int textHeight = brect.height();
    int textWidth = brect.width();
    int glowOffset = 0;

    if (vistaState() == VistaAero) {
        textHeight += 2 * glowSize();
        textWidth += 2 * glowSize();
        glowOffset = glowSize();
    }

    const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight
                           ? titleOffset() - glowOffset
                           : wizard->width() - titleOffset() - textWidth + glowOffset);

    const QRect textRectangle(titleLeft, verticalCenter - textHeight / 2, textWidth, textHeight);
    if (isWindow) {
        drawTitleText(painter, text, textRectangle, hdc);
    } else {
        painter->save();
        painter->setFont(font);
        painter->drawText(textRectangle, Qt::AlignVCenter | Qt::AlignHCenter, text);
        painter->restore();
    }

    const QIcon windowIcon = wizard->windowIcon();
    if (!windowIcon.isNull()) {
        const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight
                              ? leftMargin()
                              : wizard->width() - leftMargin() - iconSize());

        const QRect rect(origin.x() + iconLeft,
                         origin.y() + verticalCenter - iconSize() / 2, iconSize(), iconSize());
        const HICON hIcon = qt_pixmapToWinHICON(windowIcon.pixmap(iconSize()));
        DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
        DestroyIcon(hIcon);
    }
}
Ejemplo n.º 6
0
W32Widget::Size W32VBorderBox::minimumSize() const {
	Size size;
	int counter = 0;

	if (!myTopElement.isNull() && myTopElement->isVisible()) {
		++counter;
		Size elementSize = myTopElement->minimumSize();
		size.Height += elementSize.Height;
		size.Width = std::max(size.Width, elementSize.Width);
	}
	if (!myCenterElement.isNull() && myCenterElement->isVisible()) {
		++counter;
		Size elementSize = myCenterElement->minimumSize();
		size.Height += elementSize.Height;
		size.Width = std::max(size.Width, elementSize.Width);
	}
	if (!myBottomElement.isNull() && myBottomElement->isVisible()) {
		++counter;
		Size elementSize = myBottomElement->minimumSize();
		size.Height += elementSize.Height;
		size.Width = std::max(size.Width, elementSize.Width);
	}

	if (counter > 0) {
		size.Height += (counter - 1) * mySpacing;
	}

	size.Width += leftMargin() + rightMargin();
	size.Height += topMargin() + bottomMargin();
	return size;
}
Ejemplo n.º 7
0
void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), 0);
      _text->layout();

      qreal h = _text->height();
      if (_text->empty()) {
            QFontMetricsF fm = QFontMetricsF(_text->font(), MScore::paintDevice());
            h = fm.ascent();
            }
      else
            h = _text->height();
      qreal y = topMargin() * DPMM;
#if 0
      if (_text->align() & Align::BOTTOM)
            y += h;
      else if (_text->align() & Align::VCENTER)
            y +=  h * .5;
      else
            ; // y = 0;
#endif
      _text->setPos(leftMargin() * DPMM, y);
      h += topMargin() * DPMM + bottomMargin() * DPMM;
      bbox().setRect(0.0, 0.0, system()->width(), h);

      MeasureBase::layout();  // layout LayoutBreak's
      }
Ejemplo n.º 8
0
void QVistaHelper::drawTitleBar(QPainter *painter)
{
    if (vistaState() == VistaAero)
        drawBlackRect(
            QRect(0, 0, wizard->width(), titleBarSize() + topOffset()),
            painter->paintEngine()->getDC());

    Q_ASSERT(backButton_);
    const int btnTop = backButton_->mapToParent(QPoint()).y();
    const int btnHeight = backButton_->size().height();
    const int verticalCenter = (btnTop + btnHeight / 2);

    wizard->windowIcon().paint(
        painter, QRect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize()));

    const QString text = wizard->window()->windowTitle();
    const QFont font = QApplication::font("QWorkspaceTitleBar");
    const QFontMetrics fontMetrics(font);
    const QRect brect = fontMetrics.boundingRect(text);
    int textHeight = brect.height();
    int textWidth = brect.width();
    if (vistaState() == VistaAero) {
        textHeight += 2 * glowSize();
        textWidth += 2 * glowSize();
    }
    drawTitleText(
        painter, text,
        QRect(titleOffset(), verticalCenter - textHeight / 2, textWidth, textHeight),
        painter->paintEngine()->getDC());
}
Ejemplo n.º 9
0
void PageTemplate::write(QXmlStreamWriter *xml)
{
    QLocale locale;
    QString thisLanguage = locale.name().split('_').at(0);

    xml->writeStartElement("page-template");
    xml->writeAttribute("name",name());
    if( !isHalfOf().isEmpty() )
        xml->writeAttribute("is-half-of",isHalfOf());

    xml->writeStartElement("long-name");
    xml->writeAttribute("lang",thisLanguage);
    xml->writeCharacters(longName());
    xml->writeEndElement(); // long-name
    for(int i=0; i<aOtherLongNames.count(); i++)
    {
        xml->writeStartElement("long-name");
        xml->writeAttribute("lang",aOtherLongNames.at(i).lang);
        xml->writeCharacters(aOtherLongNames.at(i).string);
        xml->writeEndElement(); // long-name
    }

    xml->writeTextElement("width",QString::number(width()));
    xml->writeTextElement("height",QString::number(height()));
    xml->writeTextElement("header",QString::number(header()));
    xml->writeTextElement("footer",QString::number(footer()));

    xml->writeStartElement("margins");
    xml->writeAttribute("side","right");
    xml->writeTextElement("left-margin",QString::number(leftMargin(Book::Right)));
    xml->writeTextElement("right-margin",QString::number(rightMargin(Book::Right)));
    xml->writeTextElement("top-margin",QString::number(topMargin(Book::Right)));
    xml->writeTextElement("bottom-margin",QString::number(bottomMargin(Book::Right)));
    xml->writeEndElement(); // margins

    xml->writeStartElement("margins");
    xml->writeAttribute("side","left");
    xml->writeTextElement("left-margin",QString::number(leftMargin(Book::Left)));
    xml->writeTextElement("right-margin",QString::number(rightMargin(Book::Left)));
    xml->writeTextElement("top-margin",QString::number(topMargin(Book::Left)));
    xml->writeTextElement("bottom-margin",QString::number(bottomMargin(Book::Left)));
    xml->writeEndElement(); // margins

    xml->writeEndElement(); // page-template
}
Ejemplo n.º 10
0
void GtkPaintContext::drawString(int x, int y, const char *str, int len) {
	if (!g_utf8_validate(str, len, 0)) {
		return;
	}

	x += leftMargin();
	y += topMargin();
	pango_shape(str, len, &myAnalysis, myString);
	gdk_draw_glyphs(myPixmap, myTextGC, myAnalysis.font, x, y, myString);
}
Ejemplo n.º 11
0
void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
      _text->layout();
      _text->setPos(leftMargin() * MScore::DPMM, topMargin() * MScore::DPMM);
      qreal h = _text->isEmpty() ? _text->lineSpacing() : _text->height();
      bbox().setRect(0.0, 0.0, system()->width(), h);
      MeasureBase::layout();  // layout LayoutBreak's
      }
Ejemplo n.º 12
0
void hist_impl::render(const void* pWnd, int pX, int pY, int pVPW, int pVPH)
{
    float w = float(pVPW - (leftMargin()+rightMargin()+tickSize()));
    float h = float(pVPH - (bottomMargin()+topMargin()+tickSize()));
    float offset_x = (2.0f * (leftMargin()+tickSize()) + (w - pVPW)) / pVPW;
    float offset_y = (2.0f * (bottomMargin()+tickSize()) + (h - pVPH)) / pVPH;
    float scale_x = w / pVPW;
    float scale_y = h / pVPH;

    CheckGL("Begin Histogram::render");
    /* Enavle scissor test to discard anything drawn beyond viewport.
     * Set scissor rectangle to clip fragments outside of viewport */
    glScissor(pX+leftMargin()+tickSize(), pY+bottomMargin()+tickSize(),
            pVPW - (leftMargin()+rightMargin()+tickSize()),
            pVPH - (bottomMargin()+topMargin()+tickSize()));
    glEnable(GL_SCISSOR_TEST);

    glm::mat4 trans = glm::translate(glm::scale(glm::mat4(1),
                                                glm::vec3(scale_x, scale_y, 1)),
                                     glm::vec3(offset_x, offset_y, 0));

    glUseProgram(mHistBarProgram);
    glUniformMatrix4fv(mHistBarMatIndex, 1, GL_FALSE, glm::value_ptr(trans));
    glUniform4fv(mHistBarColorIndex, 1, mBarColor);
    glUniform1f(mHistBarNBinsIndex, (GLfloat)mNBins);
    glUniform1f(mHistBarYMaxIndex, ymax());

    /* render a rectangle for each bin. Same
     * rectangle is scaled and translated accordingly
     * for each bin. This is done by OpenGL feature of
     * instanced rendering */
    bindResources(pWnd);
    glDrawArraysInstanced(GL_TRIANGLE_FAN, 0, 4, mNBins);
    unbindResources();

    glUseProgram(0);
    /* Stop clipping */
    glDisable(GL_SCISSOR_TEST);

    renderChart(pWnd, pX, pY, pVPW, pVPH);
    CheckGL("End Histogram::render");
}
Ejemplo n.º 13
0
void QPaintContext::drawString(int x, int y, const char *str, int len) {
	QString qStr = QString::fromUtf8(str, len);
	for (unsigned int i=0; i<qStr.length(); i++) {
	    if (qStr[i] == QChar(0x14,0x20) ||
		qStr[i] == QChar(0x13,0x20))
		qStr[i] = QChar('-', 0);
	}
//	myPainter->drawText(x + leftMargin(), y + topMargin(),0,-1,-1, qStr);
	myPainter->drawText(x + leftMargin(), y + topMargin(),stringWidth(str,len),stringHeight()+3,0, qStr);
//	myPainter->drawText(x + leftMargin(), y + topMargin(), qStr);
}
Ejemplo n.º 14
0
void W32VBorderBox::setPosition(int x, int y, Size size) {
	const short elementX = x + leftMargin();
	const short elementWidth = size.Width - leftMargin() - rightMargin();

	short centerElementX = elementX;
	short centerElementY = y + topMargin();
	short centerElementHeight = size.Height - topMargin() - bottomMargin();

	if (!myTopElement.isNull() && myTopElement->isVisible()) {
		Size topElementSize = myTopElement->minimumSize();
		myTopElement->setPosition(elementX, centerElementY, Size(elementWidth, topElementSize.Height));
		centerElementY += topElementSize.Height + mySpacing;
		centerElementHeight -= topElementSize.Height + mySpacing;
	}
	if (!myBottomElement.isNull() && myBottomElement->isVisible()) {
		Size bottomElementSize = myBottomElement->minimumSize();
		myBottomElement->setPosition(elementX, y + size.Height - bottomMargin() - bottomElementSize.Height, Size(elementWidth, bottomElementSize.Height));
		centerElementHeight -= bottomElementSize.Height + mySpacing;
	}
	if (!myCenterElement.isNull() && myCenterElement->isVisible()) {
		myCenterElement->setPosition(centerElementX, centerElementY, Size(elementWidth, centerElementHeight));
	}
}
Ejemplo n.º 15
0
void QPaintContext::fillRectangle(int x0, int y0, int x1, int y1) {
	if (x1 < x0) {
		int tmp = x1;
		x1 = x0;
		x0 = tmp;
	}
	if (y1 < y0) {
		int tmp = y1;
		y1 = y0;
		y0 = tmp;
	}
	myPainter->fillRect(x0 + leftMargin(), y0 + topMargin(),
			    x1 - x0 + 1, y1 - y0 + 1,
			    myPainter->brush());
}
Ejemplo n.º 16
0
void GtkPaintContext::fillRectangle(int x0, int y0, int x1, int y1) {
	if (x1 < x0) {
		int tmp = x1;
		x1 = x0;
		x0 = tmp;
	}
	if (y1 < y0) {
		int tmp = y1;
		y1 = y0;
		y0 = tmp;
	}
	gdk_draw_rectangle(myPixmap, myFillGC, true,
										 x0 + leftMargin(), y0 + topMargin(),
										 x1 - x0 + 1, y1 - y0 + 1);
}
Ejemplo n.º 17
0
void ZLTextView::paint() {
	context().clear(backgroundColor());

	myTextAreaController.area().setOffsets(
		textArea().isRtl() ? rightMargin() : leftMargin(), topMargin() + headerHeight()
	);

	preparePaintInfo();

	if (textArea().isEmpty()) {
		return;
	}

	myTextAreaController.area().paint();

	shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo();
	if (!indicatorInfo.isNull()) {
		switch (indicatorInfo->type()) {
			default:
				break;
			case ZLTextPositionIndicatorInfo::PAGE_FOOTER:
				positionIndicator()->draw();
				break;
			case ZLTextPositionIndicatorInfo::PAGE_HEADER:
				paintHeader();
				break;
		}
	}

	if (myDoUpdateScrollbar && !indicatorInfo.isNull()) {
		myDoUpdateScrollbar = false;
		const std::size_t full = sizeOfTextBeforeParagraph(endTextIndex());
		const std::size_t from = sizeOfTextBeforeCursor(textArea().startCursor());
		const std::size_t to = sizeOfTextBeforeCursor(textArea().endCursor());

		bool showScrollbar =
			(indicatorInfo->type() == ZLTextPositionIndicatorInfo::OS_SCROLLBAR) &&
			(to - from < full);
		if (showScrollbar) {
			setScrollbarEnabled(VERTICAL, true);
			setScrollbarParameters(VERTICAL, full, from, to);
		} else {
			setScrollbarEnabled(VERTICAL, false);
		}
	}

	ZLTextParagraphCursorCache::cleanup();
}
int LineEditExtension::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = leftMargin(); break;
        case 1: *reinterpret_cast< int*>(_v) = rightMargin(); break;
        case 2: *reinterpret_cast< int*>(_v) = topMargin(); break;
        case 3: *reinterpret_cast< int*>(_v) = bottomMargin(); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setLeftMargin(*reinterpret_cast< int*>(_v)); break;
        case 1: setRightMargin(*reinterpret_cast< int*>(_v)); break;
        case 2: setTopMargin(*reinterpret_cast< int*>(_v)); break;
        case 3: setBottomMargin(*reinterpret_cast< int*>(_v)); break;
        }
        _id -= 4;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 4;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 4;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 19
0
void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), point(boxHeight()));
      foreach(Element* e, _el) {
            if (e->isText()) {
                  Text* text = static_cast<Text*>(e);
                  text->layout();
                  qreal h;
                  if (text->isEmpty())
                        h = text->lineSpacing();
                  else
                        h = text->height();
                  text->setPos(leftMargin() * MScore::DPMM, topMargin() * MScore::DPMM);
                  bbox().setRect(0.0, 0.0, system()->width(), h);
                  }
            }
      MeasureBase::layout();  // layout LayoutBreak's
      }
Ejemplo n.º 20
0
void ZLTextView::preparePaintInfo() {
	size_t newWidth = 
		std::max(context().width() - leftMargin() - rightMargin(), 1);
	int viewHeight = context().height() - topMargin() - bottomMargin();
	shared_ptr<ZLTextPositionIndicatorInfo> indicatorInfo = this->indicatorInfo();
	if (!indicatorInfo.isNull() && (indicatorInfo->type() == ZLTextPositionIndicatorInfo::FB_INDICATOR)) {
		viewHeight -= indicatorInfo->height() + indicatorInfo->offset();
	}
	size_t newHeight = std::max(viewHeight, 1);
	AppLog("newWidth %d newHeight=%d",newWidth,newHeight);
	if (newWidth != myTextAreaController.area().width() || newHeight != myTextAreaController.area().height()) {
		myTextAreaController.area().setSize(newWidth, newHeight);
		myTextAreaController.rebuildPaintInfo(false);
	}

	if (myTextAreaController.preparePaintInfo()) {
		myDoUpdateScrollbar = true;
	}
}
Ejemplo n.º 21
0
void BookTextView::paintHeader() const {
	const int unit = baseStyle()->fontSize() / 4;
	const int left = leftMargin();
	const int right = context().width() - rightMargin() - 1;
	const int bottom = topMargin() + unit * 4;
	context().setColor(color(ZLTextStyle::REGULAR_TEXT));
	context().setFont(baseStyle()->fontFamily(), unit * 3, false, true);
	context().drawLine(left, bottom, right, bottom);

	// TODO: use chapter name instead
	const std::string leftText = myBook->title();
	context().drawString(left, bottom - unit, leftText.c_str(), leftText.length(), false);

	std::string rightText;
	ZLStringUtil::appendNumber(rightText, 1 + sizeOfTextBeforeCursor(textArea().endCursor()) / 2048);
	rightText += '/';
	ZLStringUtil::appendNumber(rightText, 1 + sizeOfTextBeforeParagraph(endTextIndex()) / 2048);
	const std::size_t rightTextWidth = context().stringWidth(rightText.c_str(), rightText.length(), false);
	context().drawString(right - rightTextWidth, bottom - unit, rightText.c_str(), rightText.length(), false);
}
Ejemplo n.º 22
0
void KVocTrainTable::menuTriggerTimeout()
{
  delayTimer->stop();
  if (triggerSect == -1)
    return;

  int mt = triggerSect;
  triggerSect = -1;

  QHeader *header = horizontalHeader();
  int x = leftMargin();
  for (int i = 0; i < mt; ++i)
    x += header->sectionSize(i);
  QPoint mpos = mapToGlobal(QPoint(x, topMargin()));

  if (mt != KV_COL_MARK)
    emit rightButtonClicked(mt, mpos.x(), mpos.y());

  QMouseEvent me(QEvent::MouseButtonRelease, QPoint(0, 0), QMouseEvent::LeftButton, QMouseEvent::LeftButton);
  QApplication::sendEvent(header, &me);
}
Ejemplo n.º 23
0
void KoSectionStyle::saveOdf(KoGenStyle &style)
{
    // only custom style have a displayname. automatic styles don't have a name set.
    if (!d->name.isEmpty() && !style.isDefaultStyle()) {
        style.addAttribute("style:display-name", d->name);
    }

    QList<int> keys = d->stylesPrivate.keys();
    foreach(int key, keys) {
        if (key == KoSectionStyle::TextProgressionDirection) {
            int directionValue = 0;
            bool ok = false;
            directionValue = d->stylesPrivate.value(key).toInt(&ok);
            if (ok) {
                QString direction;
                if (directionValue == KoText::LeftRightTopBottom)
                    direction = "lr-tb";
                else if (directionValue == KoText::RightLeftTopBottom)
                    direction = "rl-tb";
                else if (directionValue == KoText::TopBottomRightLeft)
                    direction = "tb-lr";
                else if (directionValue == KoText::InheritDirection)
                    direction = "page";
                if (!direction.isEmpty())
                    style.addProperty("style:writing-mode", direction, KoGenStyle::DefaultType);
            }
        } else if (key == QTextFormat::BackgroundBrush) {
            QBrush backBrush = background();
            if (backBrush.style() != Qt::NoBrush)
                style.addProperty("fo:background-color", backBrush.color().name(), KoGenStyle::ParagraphType);
            else
                style.addProperty("fo:background-color", "transparent", KoGenStyle::DefaultType);
        } else if (key == QTextFormat::BlockLeftMargin) {
            style.addPropertyPt("fo:margin-left", leftMargin(), KoGenStyle::DefaultType);
        } else if (key == QTextFormat::BlockRightMargin) {
            style.addPropertyPt("fo:margin-right", rightMargin(), KoGenStyle::DefaultType);
      }
    }
}
Ejemplo n.º 24
0
void TBox::layout()
      {
      setPos(QPointF());      // !?
      bbox().setRect(0.0, 0.0, system()->width(), 0);
      _text->layout();

      qreal h = _text->height();
      qreal y = topMargin() * DPMM;
#if 0
      if (_text->align() & Align::BOTTOM)
            y += h;
      else if (_text->align() & Align::VCENTER)
            y +=  h * .5;
      else
            ; // y = 0;
#endif
      _text->setPos(leftMargin() * DPMM, y);
      h += topMargin() * DPMM + bottomMargin() * DPMM;
      bbox().setRect(0.0, 0.0, system()->width(), h);

      MeasureBase::layout();  // layout LayoutBreak's
      }
Ejemplo n.º 25
0
void TrackView::paintLeftMargin(QStylePainter &painter, const QRegion &region)
{
	const QRect &rect = region.boundingRect();
	const SyncDocument *doc = getDocument();

	int firstRow = qBound(0, getRowFromPhysicalY(qMax(rect.top(), topMarginHeight)), getRows() - 1);
	int lastRow = qBound(0, getRowFromPhysicalY(qMax(rect.bottom(), topMarginHeight)), getRows() - 1);

	painter.setClipRect(QRectF(QPointF(0.0f, topMarginHeight - 0.5f),
	                           QPointF(leftMarginWidth - 0.5f, rect.bottom() + 1.0f)));

	QRectF padding(QPointF(rect.left(), topMarginHeight - 0.5f),
	               QPointF(leftMarginWidth - 0.5f, rect.bottom() + 1.0f));
	painter.fillRect(padding, palette().dark());

	for (int row = firstRow; row <= lastRow; ++row) {
		QRect leftMargin(0, getPhysicalY(row), leftMarginWidth, rowHeight);
		if (!region.intersects(leftMargin))
			continue;

		QBrush fillBrush;
		if (row == editRow)
			fillBrush = editBrush;
		else if (doc->isRowBookmark(row))
			fillBrush = bookmarkBrush;
		else
			fillBrush = palette().button();

		painter.fillRect(leftMargin.adjusted(1, 1, -1, -1), fillBrush);
		qDrawWinButton(&painter, leftMargin, QPalette(fillBrush.color()));

		if ((row % 8) == 0)      painter.setPen(QColor(0, 0, 0));
		else if ((row % 4) == 0) painter.setPen(QColor(64, 64, 64));
		else                     painter.setPen(QColor(128, 128, 128));

		painter.drawText(leftMargin, QString("%1").arg(row, 5, 16, QChar('0')).toUpper() + "h");
	}
}
Ejemplo n.º 26
0
void QVistaHelper::drawTitleBar(QPainter *painter)
{
    HDC hdc = painter->paintEngine()->getDC();

    if (vistaState() == VistaAero)
        drawBlackRect(QRect(0, 0, wizard->width(),
                            titleBarSize() + topOffset()), hdc);
    Q_ASSERT(backButton_);
    const int btnTop = backButton_->mapToParent(QPoint()).y();
    const int btnHeight = backButton_->size().height();
    const int verticalCenter = (btnTop + btnHeight / 2) - 1;

    const QString text = wizard->window()->windowTitle();
    const QFont font = QApplication::font("QWorkspaceTitleBar");
    const QFontMetrics fontMetrics(font);
    const QRect brect = fontMetrics.boundingRect(text);
    int textHeight = brect.height();
    int textWidth = brect.width();
    int glowOffset = 0;

    if (vistaState() == VistaAero) {
        textHeight += 2 * glowSize();
        textWidth += 2 * glowSize();
        glowOffset = glowSize();
    }

    drawTitleText(
        painter, text,
        QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight),
        hdc);

    if (!wizard->windowIcon().isNull()) {
        QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize());
        HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON();
        DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
        DestroyIcon(hIcon);
    }
}
Ejemplo n.º 27
0
void GtkPaintContext::drawImage(int x, int y, const ZLImageData &image) {
	GdkPixbuf *imageRef = ((GtkImageData&)image).pixbuf();
	if (imageRef != 0) {
		gdk_pixbuf_render_to_drawable(
			imageRef, myPixmap,
			0, 0, 0,
			x + leftMargin(), y + topMargin() - gdk_pixbuf_get_height(imageRef),
			-1, -1, GDK_RGB_DITHER_NONE, 0, 0
		);
	}
	// for gtk+ v2.2
	// 		gdk_draw_pixbuf(
	// 			myPixmap, 0, imageRef, 0, 0,
	// 			x + leftMargin(), y + topMargin() - gdk_pixbuf_get_height(imageRef),
	// 			-1, -1, GDK_RGB_DITHER_NONE, 0, 0
	// 		);
	//
	// COMMENTS:
	// 0			-- we have no clipping (do we need it?)
	// 0, 0			-- offset in the image
	// -1, -1		-- use the whole
	// GDK_RGB_DITHER_NONE -- no dithering, hopefully, (0, 0) after it does not harm
}
Ejemplo n.º 28
0
W32Widget::Size W32Table::minimumSize() const {
	std::vector<short> widths, heights;
	calculateSizes(widths, heights);

	Size size(
		leftMargin() + rightMargin() + myHorizontalSpacing * (widths.size() - 1),
		topMargin() + bottomMargin()
	);
	for (std::vector<short>::const_iterator it = widths.begin(); it != widths.end(); ++it) {
		size.Width += *it;
	}
	int hCount = 0;
	for (std::vector<short>::const_iterator it = heights.begin(); it != heights.end(); ++it) {
		if (*it > 0) {
			size.Height += *it;
			++hCount;
		}
	}
	if (hCount > 1) {
		size.Height += myVerticalSpacing * (hCount - 1);
	}

	return size;
}
Ejemplo n.º 29
0
int QCommandLinkButtonPrivate::textOffset() const
{
    Q_Q(const QCommandLinkButton);
    return q->icon().actualSize(q->iconSize()).width() + leftMargin() + 6;
}
Ejemplo n.º 30
0
int GtkPaintContext::width() const {
	if (myPixmap == NULL) {
		return 0;
	}
	return myWidth - leftMargin() - rightMargin();
}