Example #1
0
/**
 * Sets the page increment (equivalent to slider size)
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setPageIncrement
(JNIEnv *env, jobject obj, jint inc)
{
  QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
  assert( bar );

  bar->setPageStep( inc );
}
Example #2
0
void TailView::updateScrollBars(int newMax)
{
    if(verticalScrollBar()->maximum() != newMax) {
        QScrollBar * vsb = verticalScrollBar();
        vsb->setRange(0, newMax);
        vsb->setPageStep(numLinesOnScreen() - PAGE_STEP_OVERLAP);
        vsb->setSingleStep(1);
    }
}
Example #3
0
/*
 * Setvalues.
 */
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setValues
(JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max)
{
  QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
  assert( bar );

  bar->setValue(value);
  bar->setPageStep( visible ); // page step and slider size are the same in Qt
  bar->setRange( min , max );
}
Example #4
0
///Generates renderObjectCollections when required, i.e.
///when re-sized, molecule altered; adjusts the vertical scrollbar,
///and paints all visible renderOjbectCollections
void RenderArea::paintEvent(QPaintEvent *)
{
  //First, let's see how big the window is and how many bases we can spanIdRole
    QFont font("Courier", 14, QFont::Normal);						//need fixed width font
    QPainter painter(viewport());
    painter.setFont(font);
    QFontMetrics fm(font);
    int charWidth   = fm.width("cagtnrlpyt") / 10;	//width of each cha
    int lineHeight  = charWidth*3;            //fm.height("cagtnrlpyt");
    int numberWidth = round(log10(pMol->sequence.length())) * charWidth + charWidth ;
    int basePerLine = (width()-numberWidth-32)/charWidth;

    int currentBase = 0;
    QString number = QString();
    QScrollBar* scrollbar = verticalScrollBar();

    //we go here and re-virtual-render everything if the window has been re-sized 
    //as well as adjusting the vertical scroll bar
    if (reSized)
    {
       float r = ((float) scrollbar->sliderPosition())/((float) totalHeight);           //get relative position of where we are
       while (!renderObjects.isEmpty()) delete renderObjects.takeFirst();		//clean up previous render Elements

       totalHeight = 0;									//clear cumulative height
       do {
         qDebug() << "---------Line----------" << currentBase;
         RenderObjectContainer* container = pMol->renderSequenceDump(NULL, currentBase,currentBase+basePerLine, charWidth);
         renderObjects.append(container);
         currentBase += basePerLine;
         totalHeight+=container->rect.height();						//measure total height of render
       } while ((currentBase + basePerLine)<(pMol->sequence.length()));

       scrollbar->setMinimum(1);							//re-set the scrollbar
       scrollbar->setMaximum(totalHeight-height()+100);					//leave a bit of room at the bottom	
       scrollbar->setPageStep(height());						//adjust the page step to the view port's size
       scrollbar->setSliderPosition(round(r*totalHeight));				//set the slider position correctly from the relative value we had stored
       scrollbar->setSingleStep(charWidth);

       reSized = false;								//label as reSized!
    } 

    //This bit paints only the renderObjectContainers above that are visible on this viewport

    int y = 1; //renderObjects.at(1)->rect.height();
    int virtualy = scrollbar->sliderPosition();

    for (int i = 0; i < renderObjects.size(); ++i)					//ok let's paint what is visible in the view-port
    {
      y+= renderObjects.at(i)->rect.height();
      if (y>=virtualy) renderObjects.at(i)->Render(&painter, numberWidth, y-virtualy); //only if visible
      if (y>(virtualy + height())) break;						//if over the edge of the view port, stop looping
    }
}
Example #5
0
void EigenGraspDlg::setSlaveLayout( int nGrasps )
{
	mainLayout = new QVBoxLayout(mSlave, 5);

	QLabel *valueLabel = new QLabel(QString("Value:"), mSlave);
	QLabel *amplLabel = new QLabel(QString("Amplitude:"), mSlave);
	QLabel *fixedLabel = new QLabel(QString("Fixed"), mSlave);

	QHBoxLayout *fakeRow = new QHBoxLayout(mainLayout,-1);
	fakeRow->addSpacing(400);

	QHBoxLayout *labelRow = new QHBoxLayout(mainLayout,-1);
	labelRow->addSpacing(5);
	labelRow->addWidget(valueLabel,0);
	labelRow->addWidget(amplLabel,1,Qt::AlignHCenter);
	labelRow->addWidget(fixedLabel,0);
	labelRow->addSpacing(5);
	mainLayout->addLayout(labelRow);

	for (int i=0; i<nGrasps; i++) {
		QHBoxLayout *graspRow = new QHBoxLayout(mainLayout,10);
	
		QLabel *eigenValue = new QLabel(QString("0.0"), mSlave);
		QScrollBar *bar = new QScrollBar(Qt::Horizontal, mSlave);
		bar->setRange( -SLIDER_STEPS, SLIDER_STEPS );
		bar->setPageStep(5000);
		bar->setLineStep(1000);
		bar->setValue(0);
		QCheckBox *box = new QCheckBox(mSlave);

		graspRow->addSpacing(15);
		graspRow->addWidget(eigenValue,0);
		graspRow->addWidget(bar,1);
		graspRow->addWidget(box,0);
		graspRow->addSpacing(15);

		mValueList.push_back(eigenValue);
		mBarList.push_back(bar);
		mCheckList.push_back(box);

		connect(bar,SIGNAL(sliderMoved(int)), this, SLOT(eigenGraspChanged()) );
		//comment this one out
		//connect(bar,SIGNAL(valueChanged(int)), this, SLOT(eigenGraspChanged()) );
		connect(bar,SIGNAL(nextLine()), this, SLOT(eigenGraspChanged()) );
		connect(bar,SIGNAL(prevLine()), this, SLOT(eigenGraspChanged()) );
		connect(bar,SIGNAL(nextPage()), this, SLOT(eigenGraspChanged()) );
		connect(bar,SIGNAL(prevPage()), this, SLOT(eigenGraspChanged()) );
		connect(bar,SIGNAL(sliderReleased()), this, SLOT(eigenGraspChanged()) );
		connect(box,SIGNAL(clicked()), this, SLOT(fixBoxChanged()) );
	}	
	mainLayout->addSpacing(20);
}
Example #6
0
// Set the extent of the vertical and horizontal scrollbars and return true if
// the view needs re-drawing.
bool QsciScintillaQt::ModifyScrollBars(int nMax,int nPage)
{
    bool modified = false;
    QScrollBar *sb;

    int vNewPage = nPage;
    int vNewMax = nMax - vNewPage + 1;

    if (vMax != vNewMax || vPage != vNewPage)
    {
        vMax = vNewMax;
        vPage = vNewPage;
        modified = true;

        sb = qsb->verticalScrollBar();
        sb->setMaximum(vMax);
        sb->setPageStep(vPage);
    }

    int hNewPage = GetTextRectangle().Width();
    int hNewMax = (scrollWidth > hNewPage) ? scrollWidth - hNewPage : 0;
    int charWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;

    sb = qsb->horizontalScrollBar();

    if (hMax != hNewMax || hPage != hNewPage || sb->singleStep() != charWidth)
    {
        hMax = hNewMax;
        hPage = hNewPage;
        modified = true;

        sb->setMaximum(hMax);
        sb->setPageStep(hPage);
        sb->setSingleStep(charWidth);
    }

    return modified;
}
void QConsolePrivate::updateScrollBar (void)
{
  m_scrollBar->setMinimum (0);
  if (m_bufferSize.height () > m_consoleRect.height ())
    m_scrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ());
  else
    m_scrollBar->setMaximum (0);
  m_scrollBar->setSingleStep (1);
  m_scrollBar->setPageStep (m_consoleRect.height ());
  m_scrollBar->setValue (m_consoleRect.top ());

  log ("Scrollbar parameters updated: %d/%d/%d/%d\n",
       m_scrollBar->minimum (), m_scrollBar->maximum (),
       m_scrollBar->singleStep (), m_scrollBar->pageStep ());
}
Example #8
0
void MainWindow::updateScrollBar( bool blockSignals )
{
    QScrollBar* sb = ui->horizontalScrollBar;

    if ( PlotsArea==NULL || !PlotsArea->isZoomed() )
    {
        sb->hide();
    }
    else
    {
        const FrameInterval intv = PlotsArea->visibleFrames();

        sb->blockSignals( blockSignals );

        sb->setRange( 0, PlotsArea->numFrames() - intv.count() + 1 );
        sb->setValue( intv.from );
        sb->setPageStep( intv.count() );
        sb->setSingleStep( intv.count() );

        sb->blockSignals( false );

        sb->show();
    }
}
Example #9
0
void AvatarEditor::RebuildEditView()
{
    if (!avatar_widget_)
        return;

    // Activate/deactivate export button based on whether export currently supported
    QPushButton *button = avatar_widget_->findChild<QPushButton *>("but_export");
    if (button)
        button->setEnabled(rexlogicmodule_->GetAvatarHandler()->AvatarExportSupported());

    QWidget* mat_panel = avatar_widget_->findChild<QWidget *>("panel_materials");
    QWidget* attachment_panel = avatar_widget_->findChild<QWidget *>("panel_attachments");
    if (!mat_panel || !attachment_panel)
        return;

    Scene::EntityPtr entity = rexlogicmodule_->GetAvatarHandler()->GetUserAvatar();
    if (!entity)
        return;
    EC_AvatarAppearance* appearance = entity->GetComponent<EC_AvatarAppearance>().get();
    if (!appearance)
        return;

    int width = 308-10;
    int tab_width = 302-10;
    int itemheight = 20;

    // Materials
    ClearPanel(mat_panel);
    const AvatarMaterialVector& materials = appearance->GetMaterials();
    mat_panel->resize(width, itemheight * (materials.size() + 1));

    for (uint y = 0; y < materials.size(); ++y)
    {
        QPushButton* button = new QPushButton("Change", mat_panel);
        button->setObjectName(QString::fromStdString(ToString<int>(y))); // Material index
        button->resize(50, 20);
        button->move(width - 50, y*itemheight);
        button->show();

        QObject::connect(button, SIGNAL(clicked()), this, SLOT(ChangeTexture()));
        // If there's a texture name, use it, because it is probably more understandable than material name
        std::string texname = materials[y].asset_.name_;
        if (materials[y].textures_.size())
            texname = materials[y].textures_[0].name_;

        QLabel* label = new QLabel(QString::fromStdString(texname), mat_panel);
        label->resize(200,20);
        label->move(0, y*itemheight);
        label->show();
    }

    // Attachments
    ClearPanel(attachment_panel);
    const AvatarAttachmentVector& attachments = appearance->GetAttachments();
    attachment_panel->resize(width, itemheight * (attachments.size() + 1));

    for (uint y = 0; y < attachments.size(); ++y)
    {
        QPushButton* button = new QPushButton("Remove", attachment_panel);
        button->setObjectName(QString::fromStdString(ToString<int>(y))); // Attachment index
        button->resize(50, 20);
        button->move(width - 50, y*itemheight);
        button->show();

        QObject::connect(button, SIGNAL(clicked()), this, SLOT(RemoveAttachment()));

        std::string attachment_name = attachments[y].name_;
        // Strip away .xml from the attachment name for slightly nicer display
        std::size_t pos = attachment_name.find(".xml");
        if (pos != std::string::npos)
            attachment_name = attachment_name.substr(0, pos);

        QLabel* label = new QLabel(QString::fromStdString(attachment_name), attachment_panel);
        label->resize(200,20);
        label->move(0, y*itemheight);
        label->show();
    }

    // Modifiers
    QTabWidget* tabs = avatar_widget_->findChild<QTabWidget *>("tab_appearance");
    if (!tabs)
        return;
    for (;;)
    {
        QWidget* tab = tabs->widget(0);
        if (!tab)
            break;
        tabs->removeTab(0);
        delete tab;
    }

    const MasterModifierVector& master_modifiers = appearance->GetMasterModifiers();
    // If no master modifiers, show the individual morph/bone controls
    if (!master_modifiers.size())
    {
        QWidget* morph_panel = GetOrCreateTabScrollArea(tabs, "Morphs");
        QWidget* bone_panel = GetOrCreateTabScrollArea(tabs, "Bones");
        if (!morph_panel || !bone_panel)
            return;

        const BoneModifierSetVector& bone_modifiers = appearance->GetBoneModifiers();
        const MorphModifierVector& morph_modifiers = appearance->GetMorphModifiers();
        morph_panel->resize(tab_width, itemheight * (morph_modifiers.size() + 1));
        bone_panel->resize(tab_width, itemheight * (bone_modifiers.size() + 1));

        for (uint i = 0; i < bone_modifiers.size(); ++i)
        {
            QScrollBar* slider = new QScrollBar(Qt::Horizontal, bone_panel);
            slider->setObjectName(QString::fromStdString(bone_modifiers[i].name_));
            slider->setMinimum(0);
            slider->setMaximum(100);
            slider->setPageStep(10);
            slider->setValue(bone_modifiers[i].value_ * 100.0f);
            slider->resize(150, 20);
            slider->move(tab_width - 150, i * itemheight);
            slider->show();

            QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(BoneModifierValueChanged(int)));

            QLabel* label = new QLabel(QString::fromStdString(bone_modifiers[i].name_), bone_panel);
            label->resize(100,20);
            label->move(0, i * itemheight);
            label->show();
        }

        for (uint i = 0; i < morph_modifiers.size(); ++i)
        {
            QScrollBar* slider = new QScrollBar(Qt::Horizontal, morph_panel);
            slider->setObjectName(QString::fromStdString(morph_modifiers[i].name_));
            slider->setMinimum(0);
            slider->setMaximum(100);
            slider->setPageStep(10);
            slider->setValue(morph_modifiers[i].value_ * 100.0f);
            slider->resize(150, 20);
            slider->move(tab_width - 150, i * itemheight);
            slider->show();

            QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(MorphModifierValueChanged(int)));

            QLabel* label = new QLabel(QString::fromStdString(morph_modifiers[i].name_), morph_panel);
            label->resize(100,20);
            label->move(0, i * itemheight);
            label->show();
        }
    }
Example #10
0
void CtrlRegisterList::paintEvent(QPaintEvent *)
{

	int numRowsTotal = cpu->GetNumRegsInCategory(category);
	int maxRowsDisplay =rect().bottom()/rowHeight - 1;

	selection = std::min(std::max(selection,0),numRowsTotal);
	curVertOffset = std::max(std::min(curVertOffset,numRowsTotal - maxRowsDisplay),0);

	QScrollBar *bar = findChild<QScrollBar*>("RegListScroll");
	if(bar)
	{
		bar->setMinimum(0);
		bar->setMaximum(numRowsTotal - maxRowsDisplay);
		bar->setPageStep(1);
		bar->setValue(curVertOffset);
	}


	QPainter painter(this);
	painter.setBrush(Qt::white);
	painter.setPen(Qt::white);
	painter.drawRect(rect());

	if (!cpu)
		return;

	QFont normalFont = QFont("Arial", 10);
	painter.setFont(normalFont);

	int width = rect().width();

	QColor bgColor(0xffffff);
	QPen nullPen(bgColor);
	QPen currentPen(QColor(0xFF000000));
	QPen selPen(0x808080);
	QPen textPen;

	QBrush lbr;
	lbr.setColor(bgColor);
	QBrush nullBrush(bgColor);
	QBrush currentBrush(0xFFEfE8);
	QBrush pcBrush(0x70FF70);

	int nc = cpu->GetNumCategories();
	for (int i=0; i<nc; i++)
	{
		painter.setPen(i==category?currentPen:nullPen);
		painter.setBrush(i==category?pcBrush:nullBrush);
		painter.drawRect(width*i/nc,0,width*(i+1)/nc - width*i/nc -1,rowHeight-1);
		QString name = cpu->GetCategoryName(i);
		painter.setPen(currentPen);
		painter.drawText(width*i/nc+1,-3+rowHeight,name);
	}

	int numRows=rect().bottom()/rowHeight;

	for (int i=curVertOffset; i<curVertOffset+numRows; i++)
	{
		int rowY1 = rowHeight*(i-curVertOffset+1);
		int rowY2 = rowHeight*(i-curVertOffset+2)-1;

		lbr.setColor(i==selection?0xffeee0:0xffffff);

		painter.setBrush(currentBrush);
		painter.setPen(nullPen);
		painter.drawRect(0,rowY1,16-1,rowY2-rowY1);

		if (selecting && i == selection)
			painter.setPen(selPen);
		else
			painter.setPen(nullPen);

		QBrush mojsBrush(lbr.color());
		painter.setBrush(mojsBrush);

		painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);

		// Check for any changes in the registers.
		if (lastPC != cpu->GetPC())
		{
			for (int i = 0, n = cpu->GetNumRegsInCategory(0); i < n; ++i)
			{
				u32 v = cpu->GetRegValue(0, i);
				changedCat0Regs[i] = v != lastCat0Values[i];
				lastCat0Values[i] = v;
			}
			lastPC = cpu->GetPC();
		}

		painter.setBrush(currentBrush);
		if (i<cpu->GetNumRegsInCategory(category))
		{
			QString regName = cpu->GetRegName(category,i);
			textPen.setColor(0x600000);
			painter.setPen(textPen);
			painter.drawText(17,rowY1-3+rowHeight,regName);
			textPen.setColor(0xFF000000);
			painter.setPen(textPen);

			char temp[256];
			cpu->PrintRegValue(category,i,temp);
			if (category == 0 && changedCat0Regs[i])
			{
				textPen.setColor(0x0000FF);
				painter.setPen(textPen);
			}
			else
			{
				textPen.setColor(0x004000);
				painter.setPen(textPen);
			}
			painter.drawText(77,rowY1-3+rowHeight,temp);
		}
	}
}