Esempio n. 1
1
/* sizeArray:
 * Set column and row sizes. Optimize for minimum width and
 * height. Where there is slack, try to distribute evenly.
 * We do this by encoding cells as edges with min length is
 * a dag on a chain. We then run network simplex, using
 * LR_balance.
 */
void sizeArray(htmltbl_t * tbl)
{
    graph_t *rowg;
    graph_t *colg;

    /* Do the 1D cases by hand */
    if ((tbl->rc == 1) || (tbl->cc == 1)) {
	sizeLinearArray(tbl);
	return;
    }

    tbl->heights = N_NEW(tbl->rc + 1, int);
    tbl->widths = N_NEW(tbl->cc + 1, int);

#ifdef WITH_CGRAPH
    rowg = agopen("rowg", Agdirected,NIL(Agdisc_t *));
    colg = agopen("colg", Agdirected,NIL(Agdisc_t *));
    /* Only need GD_nlist */
    agbindrec(rowg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE);    // graph custom data
    agbindrec(colg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE);    // graph custom data
#else
    rowg = agopen("rowg", AGDIGRAPH);
    colg = agopen("colg", AGDIGRAPH);
#endif
    makeGraphs(tbl, rowg, colg);
    rank(rowg, 2, INT_MAX);
    rank(colg, 2, INT_MAX);
    setSizes(tbl, rowg, colg);
    closeGraphs(rowg, colg);
}
Esempio n. 2
0
void KNoteBook::setDirectionsReflectsPage(bool state)
{
  pnote->directionsreflectspage = state;
  for(int i = 0; i < pnote->numtabs; i++)
    sections->at(i)->setDirectionsReflectsPage(state);
  setSizes();
}
Esempio n. 3
0
void HTMLLinkElement::parseAttribute(Attribute* attr)
{
    if (attr->name() == relAttr) {
        m_relAttribute = LinkRelAttribute(attr->value());
        process();
    } else if (attr->name() == hrefAttr) {
        String url = stripLeadingAndTrailingHTMLSpaces(attr->value());
        m_url = url.isEmpty() ? KURL() : document()->completeURL(url);
        process();
    } else if (attr->name() == typeAttr) {
        m_type = attr->value();
        process();
    } else if (attr->name() == sizesAttr) {
        setSizes(attr->value());
        process();
    } else if (attr->name() == mediaAttr) {
        m_media = attr->value().string().lower();
        process();
    } else if (attr->name() == disabledAttr)
        setDisabledState(!attr->isNull());
    else if (attr->name() == onbeforeloadAttr)
        setAttributeEventListener(eventNames().beforeloadEvent, createAttributeEventListener(this, attr));
    else if (attr->name() == onloadAttr)
        setAttributeEventListener(eventNames().loadEvent, createAttributeEventListener(this, attr));
    else if (attr->name() == onerrorAttr)
        setAttributeEventListener(eventNames().errorEvent, createAttributeEventListener(this, attr));
    else {
        if (attr->name() == titleAttr && m_sheet)
            m_sheet->setTitle(attr->value());
        HTMLElement::parseAttribute(attr);
    }
}
Esempio n. 4
0
void
AnimatedSplitter::onAnimationStep( int frame )
{
    QList< int > sizes;

    for ( int i = 0; i < count(); i ++ )
    {
        int j = 0;

        if ( i == m_greedyIndex )
        {
            j = height() - frame; // FIXME
        }
        else if ( i == m_animateIndex )
        {
            j = frame;
        }
        else
        {
            j = widget( i )->height();
        }

        sizes << j;
    }

    setSizes( sizes );
}
Esempio n. 5
0
void BranchAcceptor::load(istream &is)
{
  double cutoff;
  Strand strand;
  SignalType signalType;
  BOOM::String p;
  int consensusOffset;
  is >> signalType;
  is >> p; 
  cutoff=p.asDouble();
  is >> strand;
  is >> consensusOffset;
  setSignalType(signalType);
  setStrand(strand);
  setCutoff(cutoff);

  BOOM::String dummy;
  is>>dummy; // will always be "WWAM"
  branchPoint=new WWAM(getGC(),is);
  is>>dummy; // will always be "WAM"
  acceptor=new WAM(getGC(),is);

  int contextWindowLength=branchPoint->getContextWindowLength()+
    acceptor->getContextWindowLength();
  setSizes(2,consensusOffset,contextWindowLength);
}
Esempio n. 6
0
void KTabBar::resizeEvent(QResizeEvent *)
{
  //debug("KTabBar, resizing");

  setSizes();

  if(ptab->leftscroll)
  {
    ptab->left->setGeometry( 0, 0, ptab->tw_height, ptab->tw_height);
    ptab->left->show();
  }
  else
    ptab->left->hide();

  if(ptab->rightscroll)
  {
    ptab->right->setGeometry( width()-ptab->tw_height, 0,
                              ptab->tw_height, ptab->tw_height);
    ptab->right->show();
  }
  else
    ptab->right->hide();

  ptab->tabw->setGeometry( ptab->tw_start, 0,
                           ptab->tw_width, ptab->tw_height);
  ptab->qtab->setGeometry( ptab->tpos, 0,
                           ptab->qtab->sizeHint().width(), ptab->tw_height);
  //debug("KTabBar\ntabw: %dx%d\nqtab: %dx%d", tw_width, tw_height,
  //                          qtab->sizeHint().width(), tw_height);

  QPaintEvent pe(geometry());
  paintEvent( &pe );

  //debug("KTabBar, resize - done");
}
Esempio n. 7
0
void
Splitter::setSizes_mt_safe(const QList<int> & list)
{
    QMutexLocker l(&_lock);

    setSizes(list);
}
Esempio n. 8
0
ObjectPanel::ObjectPanel(QWidget *parent)
	: QSplitter(Qt::Vertical, parent)
{
	m_Hierarchy = new HierarchyView(this);
	
	addWidget(m_Hierarchy);

	m_PropertyView = new PropertyView(this);
	
	addWidget(m_PropertyView);

	QList<int> initSize;
	//
	initSize.push_back(m_Hierarchy->minimumSizeHint().height());
	initSize.push_back(m_PropertyView->minimumSizeHint().height());
	//
	setSizes(initSize);
	
	//
	m_PropertyModel = new PropertyModel("PropertyModel", this);
	
	m_PropertyView->setModel(m_PropertyModel);
	
	//
	connect(m_Hierarchy, SIGNAL(clicked(const QModelIndex&)), this,
		SLOT(slotHierarchyItemClicked(const QModelIndex&)));
}
Esempio n. 9
0
void
AnimatedSplitter::changeSize( QWidget* child, const QSize& size )
{
    int wi = indexOf( child );

    QList< int > sizes;
    for ( int i = 0; i < count(); i ++ )
    {
        int j = 0;

        if ( i == m_greedyIndex )
        {
            j = height() - size.height();
            for ( int x = 0; x < count(); x++ )
            {
                if ( x != i && x != wi )
                    j -= widget( x )->height();
            }
        }
        else if ( i == wi )
        {
            j = size.height();
        }
        else
        {
            j = widget( i )->height();
        }

        sizes << j;
    }

    setSizes( sizes );
}
Esempio n. 10
0
TransferFunctionEditorWidget::TransferFunctionEditorWidget(QWidget *parent) :  
  QSplitter(Qt::Vertical, parent)
{
  m_parent = parent;

  m_splineEditorWidget = new SplineEditorWidget(this);
  m_gradientEditorWidget = new GradientEditorWidget(this);

  addWidget(m_splineEditorWidget);
  addWidget(m_gradientEditorWidget);

  QList<int> ssz;
  ssz << 150 << 75;
  setSizes(ssz);

  setChildrenCollapsible(false);

  QObject::connect(m_splineEditorWidget, SIGNAL(giveHistogram(int)),
		   this, SLOT(changeHistogram(int)));

  QObject::connect(m_gradientEditorWidget, SIGNAL(gradientChanged(QGradientStops)),
		   m_splineEditorWidget, SLOT(setGradientStops(QGradientStops)));

  QObject::connect(m_splineEditorWidget, SIGNAL(selectEvent(QGradientStops)),
		   m_gradientEditorWidget, SLOT(setColorGradient(QGradientStops)));

  QObject::connect(m_splineEditorWidget, SIGNAL(deselectEvent()),
		   m_gradientEditorWidget, SLOT(resetColorGradient()));

  QObject::connect(m_splineEditorWidget, SIGNAL(transferFunctionChanged(QImage)),
		   this, SLOT(transferFunctionChanged(QImage)));
}
/*!
 * Begins execution of this kernel object's OpenCL kernel using the given OpenCL 
 * command queue and kernel arguments, returning the OpenCL event associated with 
 * the kernel execution. 
 *
 * @param queue The OpenCL command queue this kernel is executed on. 
 *
 * @param buffer The OpenCL memory buffer where a row is stored and will 
 *               be transformed by this kernel execution. 
 *
 * @param type The mathematical operation type that will be used for the transform. 
 *
 * @param amount The amount that will be used for the mathematical transform. 
 *
 * @return OpenCL event associated with this kernel's execution. 
 */
::OpenCL::Event MathTransform::OpenCL::Kernel::execute(::OpenCL::CommandQueue* queue, ::OpenCL::Buffer<cl_float>* buffer, Operation type, int amount)
{
   // Lock this kernel's underlying kernel class so arguments can be set. 
   Locker locker {lock()};

   // Set the arguments this OpenCL kernel requires. This includes the global memory 
   // buffer where the row is held, the local memory buffer, the operation type, 
   // and the amount. 
   setBuffer(GlobalBuffer,buffer);
   setArgument(GlobalSize,buffer->size());
   setLocalMemory<cl_float>(LocalValue,1);
   setArgument(Type,static_cast<int>(type));
   setArgument(Amount,amount);

   // Set the work sizes. The global work size is determined by the row size, but
   // it must also be a multiple of the local work size, so it is rounded up
   // accordingly.
   int localWorkSize = 1;
   int workgroupSize = (buffer->size() + localWorkSize - 1) / localWorkSize;

   setSizes(0, workgroupSize * localWorkSize, localWorkSize);

   // Execute this object's OpenCL kernel with the given command queue, returning its 
   // generated OpenCL event. 
   return ::OpenCL::Kernel::execute(queue);
}
int TableContendor::readFileIntoContendor (QString ifilename)
{
bool res;

QFile infile(ifilename);

if (!infile.open(QIODevice::ReadOnly | QIODevice::Text))
{
    qDebug()<<"Error while opening file";
    return 1;
}





QTextStream str (&infile);
QStringList listOfLines = str.readAll().split("\n");
QStringList namesLst = listOfLines.at(0).trimmed().split("\t");
int gnumberOfColumns  = namesLst.count();
int gnumberOfRows = listOfLines.count();

setSizes(gnumberOfColumns,gnumberOfRows-1);





int i=0;
foreach (QString name, namesLst)
{
    setColumnName(i, name);
    i++;
}
Esempio n. 13
0
Skin::Skin (const QString &url)
{
	setSizes ();
	setPositions ();

	m_valid = setSkin (url);
}
Esempio n. 14
0
int KNoteBook::addTab(QTab *tab, KWizardPage *p)
{
  //debug("addTab");
  int id = 0;
  KWizard *wiz = new KWizard(this, 0, false); // non-modal wizard
  wiz->setDirectionsReflectsPage(pnote->directionsreflectspage);
  wiz->setEnableArrowButtons(pnote->enablearrowbuttons);
  wiz->hide();
  //debug("KWizard created");
  sections->append(wiz);
  if(!pnote->numtabs) // the first tab
  {
    pnote->current = 0;
    pnote->currentwiz = wiz;
  }
  pnote->numtabs++;
  connect( wiz, SIGNAL(popup(QPoint)), SLOT(popupMenu(QPoint)) );
  connect( wiz, SIGNAL(nomorepages(bool, bool)), SLOT(directionButton(bool, bool)) );

  //tab->id = pnote->numtabs;
  //debug("Before adding to tabbar");
  id = pnote->tabbar->addTab(tab);
  pnote->menu->insertItem(tab->label, wiz->getMenu(), id);
  pnote->menu->setItemEnabled(id, tab->enabled);
  //debug("After adding to tabbar");

  if(p)
    wiz->addPage(p);

  setSizes();

  //debug("addTab - done");

  return id;
}
Esempio n. 15
0
void
AnimatedSplitter::onSizeChanged( const QSize& size )
{
    AnimatedWidget* w = (AnimatedWidget*)(sender());
    int wi = indexOf( w );

    QList< int > sizes;
    for ( int i = 0; i < count(); i ++ )
    {
        int j = 0;

        if ( i == m_greedyIndex )
        {
            j = height() - size.height();
            for ( int x = 0; x < count(); x++ )
            {
                if ( x != i && x != wi )
                    j -= widget( x )->height();
            }
        }
        else if ( i == wi )
        {
            j = size.height();
        }
        else
        {
            j = widget( i )->height();
        }

        sizes << j;
    }

    setSizes( sizes );
}
int addWindowMenu(int x,int y,int grav,bool fromleft)
{
	const char	*icon=NULL;
	int			xpos=x;
	int			ypos=y;
	int			width=0;
	int			height=0;
	int			thisgrav=grav;
	int			iconsize=16;

	if(windowMenu!=NULL)
		{
			printError("Duplicate window selector");
			return(0);
		}

	setSizes(&xpos,&ypos,&width,&height,&iconsize,&thisgrav,fromleft);

	windowMenu=new LFSTK_menuButtonClass(mainwind,"",xpos,ypos,width,height,thisgrav);
	icon=mainwind->globalLib->LFSTK_findThemedIcon(desktopTheme,"computer","");
	if(icon!=NULL)
		windowMenu->LFSTK_setIconFromPath(icon,iconsize);
	else
		windowMenu->LFSTK_setIconFromPath(DATADIR "/pixmaps/windows.png",iconsize);
	windowMenu->LFSTK_setCallBack(NULL,windowMenuCB,NULL);

	windowDeskListCnt=-1;
	windowListCnt=-1;
	updateWindowCnt=WINDOWREFRESH;
	updateWindowMenu();
	useAlarm=true;
	return(width);
}
Esempio n. 17
0
void KGridView::setShowRulers(bool mode)
{
  pprops->showrulers = mode;
  setSizes();
  QResizeEvent e(size(), size());
  resizeEvent(&e);
}
Esempio n. 18
0
void NTNDArrayRecord::update()
{
    lock();
    try
    {
        beginGroupPut();
        PVUByteArray::svector bytes;
        imageGen->fillSharedVector(bytes,angle);
        setValue(freeze(bytes));
        if (firstTime)
        {
            int dims[] = { imageGen->getWidth(), imageGen->getHeight() };
            setDimension(dims, 2);
            setAttributes();
            setSizes(static_cast<int64_t>(imageGen->getSize()));
            firstTime = false;
        }
        setDataTimeStamp();
        setUniqueId(count++);
        process();
        endGroupPut();
    }
    catch(...)
    {
        unlock();
        throw;
    }
    angle += 1;
    unlock();
}
void WTextSourceViewerLine::setDocument(int n,const QTextDocument *doc)
{
  text_document_p=doc;
  number_of_lines=n;
  setSizes();
  update();
}
Esempio n. 20
0
void AnimatedSplitter::setActiveWidgetWidth(int width)
{
	if (mActiveIndex >=0 && mActiveIndex < count()) {
		qDebug() << "w" << width;
		// We have to explicitly redistribute the sizes, otherwise
		// any additional/missing space is distributed amongst the widgets
		// according to the relative weight of the sizes. see. setSizes() documentation
		QList<int> sz(sizes());
		int delta = width - sz.at(mActiveIndex);  // < 0 for shrinking
		if (mActiveIndex < count()-1 && sz.at(mActiveIndex+1) > delta) {
			// take place from right
			sz.replace(mActiveIndex, width);
			sz.replace(mActiveIndex+1, sz.at(mActiveIndex+1) - delta);
		} else if (mActiveIndex > 0 && sz.at(mActiveIndex-1) > delta) {
			// take place from left
			sz.replace(mActiveIndex, width);
			sz.replace(mActiveIndex-1, sz.at(mActiveIndex-1) - delta);
		} else {
			// fallback:
			// TODO: the widget likely will not have the final width "width", because of space redistribution
			sz.replace(mActiveIndex, width);
			qDebug() << "AnimatedSplitter fallback: no cannot take space from adjacent widgets";
		}
		setSizes(sz);
	}
}
Esempio n. 21
0
void KTabCtl::setFont(const QFont & font)
{
    QFont f(font);
    f.setWeight(QFont::Light);
    QWidget::setFont(f);

    setSizes();
}
Esempio n. 22
0
void KTabCtl::setTabFont(const QFont & font)
{
    QFont f(font);
//    f.setWeight(QFont::Light);
    tabs->setFont(f);

    setSizes();
}
Esempio n. 23
0
KGridView::KGridView(QImage *image, QWidget *parent, const char *name) : QFrame(parent, name)
{
  pprops = 0L;
  _corner = 0L;
  _hruler = _vruler = 0L;
  _grid = 0L;

  acceptdrop = false;
  
  pprops = props(this);

  viewport = new QScrollView(this);
  CHECK_PTR(viewport);

  _grid = new KIconEditGrid(image, viewport->viewport());
  CHECK_PTR(_grid);
  viewport->addChild(_grid);

  if(pprops->backgroundmode == FixedPixmap)
  {
    QPixmap pix(pprops->backgroundpixmap.data());
    if(pix.isNull())
    {
      QPixmap pmlogo((const char**)logo);
      pix = pmlogo;
    }
    viewport->viewport()->setBackgroundPixmap(pix);
    _grid->setBackgroundPixmap(pix);
  }
  else
  {
    viewport->viewport()->setBackgroundColor(pprops->backgroundcolor);
  }

  _corner = new QFrame(this);
  _corner->setFrameStyle(QFrame::WinPanel | QFrame::Raised);

  _hruler = new KRuler(KRuler::horizontal, this);
  _hruler->setEndLabel(i18n("width"));
  _hruler->setOffset( 0 );
  _hruler->setRange(0, 1000);

  _vruler = new KRuler(KRuler::vertical, this);
  _vruler->setEndLabel(i18n("height"));
  _vruler->setOffset( 0 );
  _vruler->setRange(0, 1000);

  connect(_grid, SIGNAL(scalingchanged(int, bool)), SLOT(scalingChange(int, bool)));
  connect(_grid, SIGNAL(sizechanged(int, int)), SLOT(sizeChange(int, int)));
  connect(_grid, SIGNAL(needPainting()), SLOT(paintGrid()));
  connect( _grid, SIGNAL(xposchanged(int)), _hruler, SLOT(slotNewValue(int)) );
  connect( _grid, SIGNAL(yposchanged(int)), _vruler, SLOT(slotNewValue(int)) );
  connect(viewport, SIGNAL(contentsMoving(int, int)), SLOT(moving(int, int)));

  setSizes();
  QResizeEvent e(size(), size());
  resizeEvent(&e);
}
Esempio n. 24
0
ListViews::ListViews( QWidget *parent, const char *name )
    : QSplitter( Qt::Horizontal, parent, name )
{
    lstFolders.setAutoDelete( TRUE );

    folders = new QListView( this );
    folders->header()->setClickEnabled( FALSE );
    folders->addColumn( "Folder" );

    initFolders();
    setupFolders();

    folders->setRootIsDecorated( TRUE );
    setResizeMode( folders, QSplitter::KeepSize );

    QSplitter *vsplitter = new QSplitter( Qt::Vertical, this );

    messages = new QListView( vsplitter );
    messages->addColumn( "Sender" );
    messages->addColumn( "Subject" );
    messages->addColumn( "Date" );
    messages->setColumnAlignment( 1, Qt::AlignRight );
    messages->setAllColumnsShowFocus( TRUE );
    messages->setShowSortIndicator( TRUE );
    menu = new QPopupMenu( messages );
    for( int i = 1; i <= 10; i++ )
	menu->insertItem( QString( "Context Item %1" ).arg( i ) );
    connect(messages, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint& , int ) ),
	    this, SLOT( slotRMB( QListViewItem *, const QPoint &, int ) ) );
    vsplitter->setResizeMode( messages, QSplitter::KeepSize );

    message = new QLabel( vsplitter );
    message->setAlignment( Qt::AlignTop );
    message->setBackgroundMode( PaletteBase );

    connect( folders, SIGNAL( selectionChanged( QListViewItem* ) ),
	     this, SLOT( slotFolderChanged( QListViewItem* ) ) );
    connect( messages, SIGNAL( selectionChanged() ),
	     this, SLOT( slotMessageChanged() ) );
    connect( messages, SIGNAL( currentChanged( QListViewItem * ) ),
	     this, SLOT( slotMessageChanged() ) );

    messages->setSelectionMode( QListView::Extended );
    // some preparations
    folders->firstChild()->setOpen( TRUE );
    folders->firstChild()->firstChild()->setOpen( TRUE );
    folders->setCurrentItem( folders->firstChild()->firstChild()->firstChild() );
    folders->setSelected( folders->firstChild()->firstChild()->firstChild(), TRUE );

    messages->setSelected( messages->firstChild(), TRUE );
    messages->setCurrentItem( messages->firstChild() );
    message->setMargin( 5 );

    QValueList<int> lst;
    lst.append( 170 );
    setSizes( lst );
}
Esempio n. 25
0
void KNoteBook::setCancelButton(const char *name)
{
  if(!pnote->cancel)
  {
    pnote->cancel = new QPushButton(name, this);
    pnote->cancel->show();
    connect( pnote->cancel, SIGNAL(clicked()), SLOT(cancelClicked()));
  }
  else
    pnote->cancel->setText(name);
  setSizes();
}
Esempio n. 26
0
void KNoteBook::setDefaultButton(const char *name)
{
  if(!pnote->def)
  {
    pnote->def = new QPushButton(name, this);
    pnote->def->show();
    connect( pnote->def, SIGNAL(clicked()), SLOT(defaultClicked()));
  }
  else
    pnote->def->setText(name);
  setSizes();
}
Esempio n. 27
0
void KNoteBook::setHelpButton(const char *name)
{
  if(!pnote->help)
  {
    pnote->help = new QPushButton(name, this);
    pnote->help->show();
    connect( pnote->help, SIGNAL(clicked()), SLOT(helpClicked()));
  }
  else
    pnote->help->setText(name);
  setSizes();
}
Esempio n. 28
0
void KNoteBook::setOkButton(const char *name)
{
  if(!pnote->ok)
  {
    pnote->ok = new QPushButton(name, this);
    pnote->ok->show();
    connect( pnote->ok, SIGNAL(clicked()), SLOT(okClicked()));
  }
  else
    pnote->ok->setText(name);
  setSizes();
}
Esempio n. 29
0
void KTabCtl::addTab(QWidget *w, const char *name)
{
    QTab *t = new QTab();
    t->label = name;
    t->enabled = TRUE;
    int id = tabs->addTab(t);   /* add the tab itself to the tabbar */
    if (id == (int)pages.size()) {
	pages.resize(id + 1);
        pages[id] = w;          /* remember the widget to manage by this tab */
    }
    // BL: compute sizes
    setSizes();
}
SingleCellSimulationViewGraphPanelWidget * SingleCellSimulationViewGraphPanelsWidget::addGraphPanel()
{
    // Keep track of the graph panels' original size

    QList<int> origSizes = sizes();

    // Create a new graph panel

    SingleCellSimulationViewGraphPanelWidget *res = new SingleCellSimulationViewGraphPanelWidget(this);

    // Add the graph panel to ourselves

    addWidget(res);

    // Resize the graph panels, thus making sure that their size is what it
    // should be (see issue #58)

    double scalingFactor = double(count()-1)/count();

    for (int i = 0, iMax = origSizes.count(); i < iMax; ++i)
        origSizes[i] *= scalingFactor;

    setSizes(origSizes << height()/count());

    // Create a connection to keep track of whenever the graph panel gets
    // activated

    connect(res, SIGNAL(activated(SingleCellSimulationViewGraphPanelWidget *)),
            this, SLOT(graphPanelActivated(SingleCellSimulationViewGraphPanelWidget *)));

    // Activate the graph panel

    res->setActive(true);

    // Keep track of our new sizes

    splitterMoved();

    // Let people know that we have added a graph panel

    emit grapPanelAdded(res);

    // Let people know whether graph panels can be removed

    emit removeGraphPanelsEnabled(count() > 1);

    // Return our newly created graph panel

    return res;
}