void TraceWidget::updateMargins(int width)
{
  if (isLeftToRight())
    setViewportMargins(width + cbar_->width(), 0, 0, 0);
  else
    setViewportMargins(0, 0, width + cbar_->width(), 0);
}
Esempio n. 2
0
void QScriptEdit::updateExtraAreaWidth()
{
    if (isLeftToRight())
        setViewportMargins(extraAreaWidth(), 0, 0, 0);
    else
        setViewportMargins(0, 0, extraAreaWidth(), 0);
}
Esempio n. 3
0
void TextEdit::updateLineNumberAreaWidth(int /* newBlockCount */)
{
    if (lineNumberArea->isVisiblePrivate())
        setViewportMargins(lineNumberAreaWidth() + 12, 0, 0, 0);
    else
        setViewportMargins(0, 0, 0, 0);
}
Esempio n. 4
0
void TextEditLineNumbers::setLineAreaVisble(bool visible)
{
	m_lineAreaVisble = visible;
	if (m_lineAreaVisble) {
		setViewportMargins(getAreaWidth(),0,0,0);
	}
	else {
		setViewportMargins(0,0,0,0);
	}
}
void FilterTableHeader::updateGeometries()
{
    // If there are any input widgets add a viewport margin to the header to generate some empty space for them which is not affected by scrolling
    if(filterWidgets.size())
        setViewportMargins(0, 0, 0, filterWidgets.at(0)->sizeHint().height());
    else
        setViewportMargins(0, 0, 0, 0);

    // Now just call the parent implementation and reposition the input widgets
    QHeaderView::updateGeometries();
    adjustPositions();
}
Esempio n. 6
0
void SourceViewerWidget::optionChanged(int identifier, const QVariant &value)
{
	if (identifier == SettingsManager::Interface_ShowScrollBarsOption)
	{
		setHorizontalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
		setVerticalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
	}
	else if (identifier == SettingsManager::SourceViewer_ShowLineNumbersOption)
	{
		if (value.toBool() && !m_marginWidget)
		{
			m_marginWidget = new MarginWidget(this);
			m_marginWidget->show();
			m_marginWidget->setGeometry(QRect(contentsRect().left(), contentsRect().top(), m_marginWidget->width(), contentsRect().height()));
		}
		else if (!value.toBool() && m_marginWidget)
		{
			m_marginWidget->deleteLater();
			m_marginWidget = nullptr;

			setViewportMargins(0, 0, 0, 0);
		}
	}
	else if (identifier == SettingsManager::SourceViewer_WrapLinesOption)
	{
		setLineWrapMode(value.toBool() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
	}
}
void SourceViewerWidget::optionChanged(const QString &option, const QVariant &value)
{
	if (option == QLatin1String("Interface/ShowScrollBars"))
	{
		setHorizontalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
		setVerticalScrollBarPolicy(value.toBool() ? Qt::ScrollBarAsNeeded : Qt::ScrollBarAlwaysOff);
	}
	else if (option == QLatin1String("SourceViewer/ShowLineNumbers"))
	{
		if (value.toBool() && !m_marginWidget)
		{
			m_marginWidget = new MarginWidget(this);
			m_marginWidget->show();
			m_marginWidget->setGeometry(QRect(contentsRect().left(), contentsRect().top(), m_marginWidget->width(), contentsRect().height()));
		}
		else if (!value.toBool() && m_marginWidget)
		{
			m_marginWidget->deleteLater();
			m_marginWidget = NULL;

			setViewportMargins(0, 0, 0, 0);
		}
	}
	else if (option == QLatin1String("SourceViewer/WrapLines"))
	{
		setLineWrapMode(value.toBool() ? QPlainTextEdit::WidgetWidth : QPlainTextEdit::NoWrap);
	}
}
Esempio n. 8
0
SourceWindow::SourceWindow(const QString& fileName, QWidget* parent) :
	QPlainTextEdit(parent),
	m_fileName(fileName),
	m_highlighter(0),
	m_widthItems(16),
	m_widthPlus(12),
	m_widthLineNo(30),
	m_lineInfoArea(new LineInfoArea(this))
{
    // load pixmaps
    m_pcinner = UserIcon("pcinner");
    m_pcup = UserIcon("pcup");
    m_brkena = UserIcon("brkena");
    m_brkdis = UserIcon("brkdis");
    m_brktmp = UserIcon("brktmp");
    m_brkcond = UserIcon("brkcond");
    m_brkorph = UserIcon("brkorph");
    setFont(KGlobalSettings::fixedFont());
    setReadOnly(true);
    setViewportMargins(lineInfoAreaWidth(), 0, 0 ,0);
    setWordWrapMode(QTextOption::NoWrap);
    connect(this, SIGNAL(updateRequest(const QRect&, int)),
	    m_lineInfoArea, SLOT(update()));
    connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(cursorChanged()));

    // add a syntax highlighter
    if (QRegExp("\\.(c(pp|c|\\+\\+)?|CC?|h(\\+\\+|h|pp)?|HH?)$").indexIn(m_fileName) >= 0)
    {
	m_highlighter = new HighlightCpp(this);
    }
}
Esempio n. 9
0
void MarkdownEditor::setupPaperMargins(int width)
{
    if (EditorWidthFull == editorWidth)
    {
        preferredLayout->setContentsMargins(0, 0, 0, 0);
        setViewportMargins(0, 0, 0, 0);

        return;
    }

    int screenWidth = QApplication::desktop()->screenGeometry().width();
    int proposedEditorWidth = width;
    int margin = 0;

    switch (editorWidth)
    {
        case EditorWidthNarrow:
            proposedEditorWidth = screenWidth / 3;
            break;
        case EditorWidthMedium:
            proposedEditorWidth = screenWidth / 2;
            break;
        case EditorWidthWide:
            proposedEditorWidth = 2 * (screenWidth / 3);
            break;
        default:
            break;
    }

    if (proposedEditorWidth <= width)
    {
        margin = (width - proposedEditorWidth) / 2;
    }

    if (EditorAspectStretch == aspect)
    {
        preferredLayout->setContentsMargins(0, 0, 0, 0);
        setViewportMargins(margin, 20, margin, 0);
    }
    else
    {
        preferredLayout->setContentsMargins(margin, 20, margin, 20);
        setViewportMargins(10, 10, 10, 10);
    }
}
Esempio n. 10
0
void HeaderedWidget::setHeaderLabels(const QStringList& headerLabels, const char* aligns)
{
  headerItemModel->setHorizontalHeaderLabels(headerLabels);
  int headerHeight = headerView->sizeHint().height();
  headerView->setFixedHeight(headerHeight);
  setViewportMargins(0, headerHeight, 0, 0);
  for(int i = headerLabels.count() - 1; i >= 0; i--)
    headerItemModel->horizontalHeaderItem(i)->setTextAlignment((aligns == 0 || aligns[i] == 'l') ? Qt::AlignLeft : (aligns[i] == 'r' ? Qt::AlignRight : Qt::AlignCenter));
}
Esempio n. 11
0
void TextEditLineNumbers::resizeEvent(QResizeEvent *e)
{
	QTextEdit::resizeEvent(e);
	if (m_lineAreaVisble) {
		setViewportMargins(getAreaWidth(),0,0,0); // since font might have changed
		QRect cr = contentsRect();
		lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), getAreaWidth(), cr.height()));
	}
}
Esempio n. 12
0
void RosegardenScrollView::setBottomFixedWidget(QWidget* w)
{
    m_bottomWidget = w;
    if (m_bottomWidget) {
        m_bottomWidget->setParent(this);
        m_bottomWidget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
        setViewportMargins( 0, 0, 0, m_bottomWidget->sizeHint().height() );
        RG_DEBUG << "RosegardenScrollView::setBottomFixedWidget" << endl;
    }
}
Esempio n. 13
0
XMLTextEdit::XMLTextEdit(QWidget *parent)
  : QTextEdit(parent)
{
  setViewportMargins(50, 0, 0, 0);
  highlight = new XmlHighlighter(document());
  setLineWrapMode ( QTextEdit::NoWrap );
  setAcceptRichText ( false );
  connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(update()));
  connect(this, SIGNAL(textChanged()), this, SLOT(update()));
}
Esempio n. 14
0
/*******************************************************************************
    show/hide bottom panel
*******************************************************************************/
void BrowserView::show_bottom_panel(QWidget* w)
{
    //Debug::debug() << "  [BrowserView] show_bottom_panel";

    m_bottomWidget->setContent( w );
   
    if(!w) 
    {
      m_bottomWidget->hide();
      setViewportMargins(0,0,0,0);
    }
    else
    {
      m_bottomWidget->show();  

      m_bottomWidget->resize(m_bottomWidget->width(),w->sizeHint().height() + 4);
      setViewportMargins(0,0,0,w->sizeHint().height() + 4);
    }
}
Esempio n. 15
0
EvScrollTabBar::EvScrollTabBar(Qt::Orientation orientation,QWidget *parent) :
    QScrollArea(parent)
{
    m_tabBar = new EvTabBar(orientation,this);
    setWidget(m_tabBar);
    setWidgetResizable(true);
    setViewportMargins(0,0,-3,-3);
    setFrameShape(QFrame::NoFrame);
    connect(m_tabBar,SIGNAL(currentIndexChanged(bool)),this,SLOT(updateScrollPosition(bool)));
}
Esempio n. 16
0
/* ==== JBEAM TEXT EDIT ==== */
JBEAM_TextBox::JBEAM_TextBox(QWidget *parent, NodeBeam *nb) : QPlainTextEdit(parent)
{
    LineNumbersA = new LineNumbers(this);
    setViewportMargins(26,0,0,0);

    //Connect linenumbers update request
    connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumbers(QRect,int)));
    connect(this, SIGNAL(textChanged()), this, SLOT(textchanged()));

    synhigh = new Highlighter(this->document());

    JBEAM_NodeCursor = -1;
    JBEAM_BeamCursor = -1;
    CurrentNodeBeam = nb;

    this->setLineWrapMode(QPlainTextEdit::NoWrap); //No automatic line change
    this->setTabStopWidth(15); //Set smaller TAB width

    EmptyJbeamTextTemplate = "{\n"
                   "    \"Vehicle\":{\n"
                   "        \"information\":{\n"
                   "            \"authors\":\"Your name\"      \n"
                   "        },\n"
                   "        \"nodes\":[\n"
                   "            [\"id\", \"posX\", \"posY\", \"posZ\"],\n\n"
                   "            //BNEnodes\n"
                   "   \n"
                   "        ],\n"
                   "        \"beams\":[\n"
                   "            [\"id1:\", \"id2:\"],\n\n"
                   "            //BNEbeams\n"
                   "   \n"
                   "   \n"
                   "        ],\n"
                   "        \"triangles\":[\n"
                   "            [\"id1:\", \"id2:\", \"id3:\"],\n\n"
                   "            //BNEtriangles\n"
                   "   \n"
                   "   \n"
                   "        ],\n"
                   "   }\n"
                   "}\n";

    ResetContents();

    QFont fontti;
    fontti.setFamily(tr("Verdana"));
    this->setFont(fontti);

    for(int i=0; i<CurrentNodeBeam->ListTypes.size();i++)
    {
        this->JBEAM_curorNames.append(CurrentNodeBeam->ListTypes.at(i).keyword);
    }
}
Esempio n. 17
0
void AdjustingScrollArea::resizeEvent(QResizeEvent* ev)
{
    int scrollBarWidth =
        verticalScrollBar()->isVisible() ? verticalScrollBar()->sizeHint().width() : 0;

    if (layoutDirection() == Qt::RightToLeft)
        setViewportMargins(-scrollBarWidth, 0, 0, 0);

    updateGeometry();
    QScrollArea::resizeEvent(ev);
}
Esempio n. 18
0
void CodeEditor::resizeEvent(QResizeEvent* event)
{
    QPlainTextEdit::resizeEvent(event);

    lineNumWidth = FONTWIDTH * lineNumDigits;

    int width = lineNumWidth + foldBoxWidth + 2 * foldBoxIndent;

    setViewportMargins(width, 0, 0, 0);

    extraArea->setGeometry(contentsRect().x(), contentsRect().y(), width, contentsRect().height());
}
Esempio n. 19
0
void ToolBarList::updateGeometries()
{
	// Resize viewport margins
	QSize hint = m_toolbar->isHidden() ? QSize(0,0) : m_toolbar->sizeHint();
	setViewportMargins(0, 0, 0, hint.height());

	// Resize toolbar
	QRect rect = viewport()->geometry();
	QRect geometry(rect.left(), rect.top() + rect.height(), rect.width(), hint.height());
	m_toolbar->setGeometry(geometry);

	QListWidget::updateGeometries();
}
Esempio n. 20
0
void VariableTableView::showEvent(QShowEvent *event)
{
    setViewportMargins(m_header->sizeHint().width(), this->rowHeight(0) + 6, 0, 0);
    m_header->setGeometry(0,
                          static_cast<int>(this->rowHeight(0) / 2.0),
                          m_header->sizeHint().width() + 10,
                          this->rowHeight(0) * m_header->sectionCount());
    horizontalHeader()->setMinimumWidth(horizontalHeader()->count() * horizontalHeader()->sectionSize(1));
    horizontalScrollBar()->setMaximum((horizontalHeader()->count() - 1) * horizontalHeader()->sectionSize(1));
    horizontalScrollBar()->updateGeometry();
    viewport()->update();
    QWidget::showEvent(event);
}
Esempio n. 21
0
void IrgaTableView::resizeEvent(QResizeEvent *event)
{
    setViewportMargins(m_header->sizeHint().width() - 2, rowHeight(0) + 2, 0, 0);
    m_header->setGeometry(0,
                          static_cast<int>(rowHeight(0) / 2.0) + 2,
                          m_header->sizeHint().width() + 10,
                          rowHeight(0) * m_header->sectionCount());
    horizontalHeader()->setMinimumWidth(horizontalHeader()->count() * horizontalHeader()->sectionSize(1));
    horizontalScrollBar()->setMaximum((horizontalHeader()->count() - 1) * horizontalHeader()->sectionSize(1));
    horizontalScrollBar()->updateGeometry();
    viewport()->update();
    QWidget::resizeEvent(event);
}
DWIDGET_USE_NAMESPACE

DFM_BEGIN_NAMESPACE

DCompleterListView::DCompleterListView(QWidget *parent)
    : QListView(parent)
{
    setFocusPolicy(Qt::NoFocus);
    overrideWindowFlags(Qt::Tool | Qt::WindowDoesNotAcceptFocus);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setViewportMargins(0, 0, -verticalScrollBar()->sizeHint().width(), 0);
    setMouseTracking(true);
}
Esempio n. 23
0
void QsCompletionBox::updateGeometries()
{
    KCompletionBox::updateGeometries();
    int statusHeight = m_status->geometry().height();

//         setGeometry(calculateGeometry());

    setViewportMargins(0,0,0,statusHeight);

    QRect vg = viewport()->geometry();
    int statusTop = vg.bottom();

    m_status->setGeometry(vg.left(), statusTop, vg.width(), statusHeight);
}
Esempio n. 24
0
ResultDisplay::ResultDisplay(QWidget* parent)
    : QPlainTextEdit(parent)
    , m_count(0)
    , m_highlighter(new SyntaxHighlighter(this))
    , m_scrolledLines(0)
    , m_scrollDirection(0)
    , m_isScrollingPageOnly(false)
{
    setViewportMargins(0, 0, 0, 0);
    setBackgroundRole(QPalette::Base);
    setLayoutDirection(Qt::LeftToRight);
    setMinimumWidth(150);
    setReadOnly(true);
    setFocusPolicy(Qt::NoFocus);
    setWordWrapMode(QTextOption::WrapAnywhere);
}
Esempio n. 25
0
void SparqlTextEdit::paintLineNumbers(QPaintEvent *e)
{
    QFontMetrics metrics(currentCharFormat().font());

    int digits = 0;
    int blocks = blockCount();
    do {
        blocks /= 10;
        ++digits;
    } while (blocks);

    int maxCharWidth = 0;
    for (char c = '0'; c <= '9'; c++) {
        maxCharWidth = qMax(maxCharWidth, metrics.width(c));
    }

    int newLeftMargin = frameWidth() + maxCharWidth * digits;
    if (leftMargin != newLeftMargin) {
        leftMargin = newLeftMargin;
        setViewportMargins(leftMargin, 0, 0, 0);
    }

    QPainter painter(this);
    painter.setClipRect(lineNumbersRect(), Qt::IntersectClip);
    painter.fillRect(e->rect(), palette().window());
    painter.setPen(palette().windowText().color());
    painter.setFont(currentCharFormat().font());

    QTextBlock block = firstVisibleBlock();

    int blockNumber = block.blockNumber();
    int top = (int) blockBoundingGeometry(block)
            .translated(contentOffset()).top() + lineNumbersRect().top();
    int bottom = top + (int) blockBoundingRect(block).height();
    while (block.isValid() && top <= e->rect().bottom()) {
        if (block.isVisible() && bottom >= e->rect().top()) {
            QString number = QString::number(blockNumber + 1);
            painter.drawText(0, top, leftMargin, metrics.height(),
                             Qt::AlignRight, number);
        }

        block = block.next();
        top = bottom;
        bottom = top + (int) blockBoundingRect(block).height();
        ++blockNumber;
    }
}
Esempio n. 26
0
ImageView::ImageView(QWidget* parent)
  : QGraphicsView(parent)
  , m_autoZoomFit(false)
  , m_scaleFactor(1.0)
  , m_proxy(0)
  , m_item(0)
  , m_cacheTimer(0)
{
  m_scene = new QGraphicsScene(this);

  setViewportMargins(0, 0, 0, 0);
  setContentsMargins(0, 0, 0, 0);
  setLineWidth(0);
  setDragMode(ScrollHandDrag);
  setFrameStyle(Plain | NoFrame);

  setScene(m_scene);
}
Esempio n. 27
0
void CCodeEditor::updateLineNumberAreaWidth(int newBlockCount){
	setViewportMargins(lineNumberAreaWidth()+m_foldArea->foldAreaWidth(), 0, 0, 0);

        // CHECK FOR PREVIUOS BLOCK INDENT

        if( newBlockCount == 0 ){
            return;
        }

        // the block count has increased?
        if( (newBlockCount-1) == m_oldBlockCount ){

            if( !textCursor().block().isValid() ){
                m_oldBlockCount = newBlockCount;
                return;
            }

            if( textCursor().block().previous().isValid() ){

                // Pick the previous block text and his
                // indent manually
                QString     prevText = textCursor().block().previous().text();
                QString     oldIndent;
                int         cc = 0;

                while( cc < prevText.length() ){
                    if( prevText[cc] == ' ' || prevText[cc] == '\t' )
                        oldIndent += prevText[cc];
                    else
                        break;

                    cc++;
                }

                // and apply on current cursor position
                if( oldIndent.length() > 0 && textCursor().atBlockStart() ){
                    textCursor().insertText( oldIndent );
                }
            }
        }

        m_oldBlockCount = newBlockCount;

}
Esempio n. 28
0
ImageView::ImageView(QWidget* parent):
  QGraphicsView(parent),
  scene_(new QGraphicsScene(this)),
  imageItem_(new QGraphicsRectItem()),
  gifMovie_(nullptr),
  cacheTimer_(nullptr),
  cursorTimer_(nullptr),
  scaleFactor_(1.0),
  autoZoomFit_(false),
  isSVG(false) {

  setViewportMargins(0, 0, 0, 0);
  setContentsMargins(0, 0, 0, 0);
  setLineWidth(0);

  setScene(scene_);
  imageItem_->hide();
  imageItem_->setPen(QPen(Qt::NoPen)); // remove the border
  scene_->addItem(imageItem_);
}
    RoboScintilla::RoboScintilla(QWidget *parent) : QsciScintilla(parent),
        _ignoreEnterKey(false),
        _ignoreTabKey(false),
        _lineNumberDigitWidth(0),
        _lineNumberMarginWidth(0)
    {
        setAutoIndent(true);
        setIndentationsUseTabs(false);
        setIndentationWidth(indentationWidth);
        setUtf8(true);
        setMarginWidth(1, 0);
        setCaretForegroundColor(caretForegroundColor);
        setMatchedBraceForegroundColor(matchedBraceForegroundColor); //1AB0A6
        setMatchedBraceBackgroundColor(marginsBackgroundColor);
        setContentsMargins(0, 0, 0, 0);
        setViewportMargins(3, 3, 3, 3);
        QFont ourFont = GuiRegistry::instance().font();
        setMarginsFont(ourFont);
        setMarginLineNumbers(0, true);
        setMarginsBackgroundColor(QColor(53, 56, 58));
        setMarginsForegroundColor(QColor(173, 176, 178));

        SendScintilla(QsciScintilla::SCI_STYLESETFONT, 1, ourFont.family().data());
        SendScintilla(QsciScintilla::SCI_SETHSCROLLBAR, 0);

        setWrapMode((QsciScintilla::WrapMode)QsciScintilla::SC_WRAP_NONE);
        setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); 
        setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); 

        // Cache width of one digit
#ifdef Q_OS_WIN
        _lineNumberDigitWidth = rowNumberWidth;
#else
        _lineNumberDigitWidth = textWidth(STYLE_LINENUMBER, "0");
#endif
        updateLineNumbersMarginWidth();

        setLineNumbers(AppRegistry::instance().settingsManager()->lineNumbers());
        setUtf8(true);
        VERIFY(connect(this, SIGNAL(linesChanged()), this, SLOT(updateLineNumbersMarginWidth())));
    }
Esempio n. 30
0
FastoScintilla::FastoScintilla(QWidget* parent)
    : QsciScintilla(parent), lineNumberMarginWidth_(0), showAutoCompletion_(false) {
  setAutoIndent(true);
  setIndentationsUseTabs(false);
  setIndentationWidth(indentationWidth);
  setUtf8(true);
  setMarginWidth(1, 0);

  setCaretForegroundColor(caretForegroundColor);

  setMatchedBraceForegroundColor(matchedBraceForegroundColor);
  setMatchedBraceBackgroundColor(matchedBraceBackgroundColor);

  setSelectionBackgroundColor(selectionBackgroundColor);
  setSelectionForegroundColor(selectionForegroundColor);

  setContentsMargins(0, 0, 0, 0);
  setViewportMargins(3, 3, 3, 3);
  setMarginLineNumbers(0, true);

  // Margins colors
  // line numbers margin
  setMarginsBackgroundColor(marginsBackgroundColor);
  setMarginsForegroundColor(marginsForegroundColor);

  SendScintilla(QsciScintilla::SCI_SETHSCROLLBAR, 0);

  setWrapMode(QsciScintilla::WrapNone);
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);

  VERIFY(connect(this, &FastoScintilla::linesChanged, this,
                 &FastoScintilla::updateLineNumbersMarginWidth));

  setAutoCompletionThreshold(1);
  setAutoCompletionCaseSensitivity(false);
  setAutoCompletionSource(QsciScintilla::AcsNone);
}