Beispiel #1
0
// set the callbacks up in the constructor
Engine::Engine()
{
	glictGlobals.paintrectCallback = Engine::draw_rectangle;
	glictGlobals.paintrectlinesCallback = Engine::draw_rectangle_lines;
	glictGlobals.enableGlTranslate = false;
	glictGlobals.windowTitleColor.r = glictGlobals.windowTitleColor.g = glictGlobals.windowTitleColor.b = 0.6;

	doResize(options.w, options.h);

	m_video_bpp = options.bpp;

	m_screen = NULL;

	initFont(&m_sysfont, "system");
	initFont(&m_minifont, "minifont");
	initFont(&m_aafont, "aafont");
	initFont(&m_gamefont, "gamefont");

	m_fps = 0.;
    m_ui = NULL;
	m_light = NULL;
    m_cursorBasic = m_cursorUse = NULL;

    // remember default cursor
    resetDefaultCursor();

    g_frames = 0;

	m_lastfpsupdate = SDL_GetTicks();
}
Beispiel #2
0
void MainWindow::initCells()
{

  if (centralWidget() != 0) {
    delete centralWidget();
  }
  QWidget *grid = new QWidget();
  QPalette pal;
  pal.setBrush(QPalette::Active, QPalette::Window,QBrush(QColor("#b2b5c7")));
  grid->setPalette(pal);
  grid->setAutoFillBackground(true);
  grid->setBackgroundRole(QPalette::Window);

  QGridLayout* layout = new QGridLayout;
  layout->setHorizontalSpacing(0);
  layout->setVerticalSpacing(0);
  layout->setSizeConstraint(QLayout::SetNoConstraint);
  //layout->setContentsMargins(1,1,1,1);
  layout->setContentsMargins(0,0,0,0);
  for(int i = 0; i < BoardSize; i++)
  {
    for(int j = 0; j < BoardSize; j++)
    {
      int ii = i * BoardSize + j;
      board[ii] = new Cell(grid, ii);
      connect(board[ii], SIGNAL(cellClicked(int)), SLOT(cellClicked(int)));
      layout->addWidget(board[ii], i, j);
    }
  }
  
  grid->setLayout(layout); 
  setCentralWidget(grid);
  QApplication::processEvents();
  doResize();
}
Beispiel #3
0
EngineGL::EngineGL()
{
	DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "Starting OpenGL engine\n");
	m_screen = NULL;

    SDL_ShowCursor(0);
	doResize(m_width, m_height);

	if(!m_screen)
		// looks like GL is not supported -- dont attempt anything else
		return;

	glictGlobals.drawPartialOut = true;
	glictGlobals.clippingMode = GLICT_SCISSORTEST;

    Sprite*a,*b;

	m_sysfont->SetFontParam(new YATCFont("Tibia.pic", 2, a=createSprite("Tibia.pic", 2)));
	m_minifont->SetFontParam(new YATCFont("Tibia.pic", 5, createSprite("Tibia.pic", 5)));
	m_aafont->SetFontParam(new YATCFont("Tibia.pic", 7, b=createSprite("Tibia.pic", 7)));
	m_gamefont->SetFontParam(new YATCFont("Tibia.pic", 4, createSprite("Tibia.pic", 4)));

	a->addColor(.75,.75,.75);
	b->addColor(.75,.75,.75);

    m_ui = createSprite("Tibia.pic", 3);
	m_light = createSprite("Tibia.pic", 6);
    m_cursorBasic = m_ui->createCursor(290,12,11,19, 1, 1);
    m_cursorUse = m_ui->createCursor(310,12,19,19, 9, 9);
    SDL_ShowCursor(1);
    SDL_SetCursor(m_cursorBasic);

	initEngine();
}
Beispiel #4
0
void QSplitterPrivate::setSizes_helper(const QList<int> &sizes, bool clampNegativeSize)
{
    int j = 0;

    for (int i = 0; i < list.size(); ++i) {
        QSplitterLayoutStruct *s = list.at(i);

        s->collapsed = false;
        s->sizer = sizes.value(j++);
        if (clampNegativeSize && s->sizer < 0)
            s->sizer = 0;
        int smartMinSize = pick(qSmartMinSize(s->widget));

        // Make sure that we reset the collapsed state.
        if (s->sizer == 0) {
            if (collapsible(s) && smartMinSize > 0) {
                s->collapsed = true;
            } else {
                s->sizer = smartMinSize;
            }
        } else {
            if (s->sizer < smartMinSize)
                s->sizer = smartMinSize;
        }
    }
    doResize();
}
Beispiel #5
0
void MachineSplash::setPreview(const QString previewLocation)
{
    if(!previewLocation.isEmpty())
        previewLoc = previewLocation;
    QPixmap preview = QPixmap(previewLoc);
    preview.setAlphaChannel(alpha.scaled(preview.width(),preview.height()));
    previewImage->setPixmap(preview);
    doResize();
}
void testSimple() {
  describePlatform();

  auto sizes = {0, 1, 10, 14, 15, 16, 17, 22, 23, 24, 32, 95, 100, 10000};
  for (auto i : sizes) {
    for (auto j : sizes) {
      {
        T target;
        std::vector<bool> valid;
        doResize(target, valid, i);
        doResizeWithoutInit(target, valid, j);
        check(target);
      }

      {
        T target;
        std::vector<bool> valid;
        doResize(target, valid, i);
        doResizeWithoutInit(target, valid, j);
        doOverwrite(target, valid, i, j);
        check(target);
      }

      {
        T target;
        std::vector<bool> valid;
        doResizeWithoutInit(target, valid, i);
        doResize(target, valid, j);
        doOverwrite(target, valid, i / 2, i / 2);
        check(target);
      }

      {
        T target;
        std::vector<bool> valid;
        doResizeWithoutInit(target, valid, i);
        doResize(target, valid, j);
        doOverwrite(target, valid, i, j);
        check(target);
      }
    }
  }
}
Beispiel #7
0
ChatbarTextEdit::ChatbarTextEdit(QWidget *p) : QTextEdit(p), iHistoryIndex(-1) {
	setWordWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setMinimumHeight(0);
	connect(this, SIGNAL(textChanged()), SLOT(doResize()));

	bDefaultVisible = true;
	setDefaultText(tr("<center>Type chat message here</center>"));
}
 HighlightScrollBarOverlay(HighlightScrollBarController *scrollBarController)
     : QWidget(scrollBarController->scrollArea())
     , m_scrollBar(scrollBarController->scrollBar())
     , m_highlightController(scrollBarController)
 {
     setAttribute(Qt::WA_TransparentForMouseEvents);
     m_scrollBar->parentWidget()->installEventFilter(this);
     doResize();
     doMove();
     show();
 }
Beispiel #9
0
void QSplitter::styleChange( QStyle& old )
{
    int sw = style().splitterWidth();
    QSplitterLayoutStruct *s = data->list.first();
    while ( s ) {
	if ( s->isSplitter )
	    s->sizer = sw;
	s = data->list.next();
    }
    doResize();
    QFrame::styleChange( old );
}
Beispiel #10
0
void KoToolDockMoveManager::doYResize( QWidget* w, bool mirror )
{
    if (working)
        return;

    mirrorX = false;
    mirrorY = mirror;

    yOnly = true;
    xOnly = false;

    doResize(w);
}
Beispiel #11
0
void QWaylandWindow::requestResize()
{
    QMutexLocker lock(&mResizeLock);

    if (mCanResize) {
        doResize();
    }

    mRequestResizeSent = false;
    lock.unlock();
    QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
    QWindowSystemInterface::flushWindowSystemEvents();
}
Beispiel #12
0
void KoToolDockMoveManager::doXYResize( QWidget* w, bool _mirrorX, bool _mirrorY )
{
    if (working)
        return;

    mirrorX = _mirrorX;
    mirrorY = _mirrorY;

    yOnly = false;
    xOnly = false;

    doResize(w);
}
Beispiel #13
0
void QSplitter::setSizes( QValueList<int> list )
{
    processChildEvents();
    QValueList<int>::Iterator it = list.begin();
    QSplitterLayoutStruct *s = data->list.first();
    while ( s && it != list.end() ) {
	if ( !s->isSplitter ) {
	    s->sizer = *it;
	    ++it;
	}
	s = data->list.next();
    }
    doResize();
}
void LineMove::mouseMoveEvent(QMouseEvent *m)
{
	adjustBounds(m);
	if (m_haveLineItem)
	{
		doResize();
		double angle = rotation();
		if (angle > 0)
			angle = 360 - angle;
		m_canvas->displaySizeHUD(m->globalPos(), length(), fabs(angle), true);
	}
	m->accept();
	m_canvas->repaint();
}
Beispiel #15
0
int Window::resize(const yguipp::Point& p) {
    WindowManager* windowManager = m_guiServer->getWindowManager();

    if (m_visible) {
        windowManager->lock();
    }

    doResize(p);

    if (m_visible) {
        windowManager->unLock();
    }

    return 0;
}
Beispiel #16
0
TopLevel::TopLevel (ConfigList *cl)
  : KTopLevelWidget(), ID_GENERAL(1)
{
  configList = cl;
  current = 0;

  setupMenuBar();
  setupStatusBar();

  splitter = new MySplitter(this);
  connect(splitter, SIGNAL(resized()), this, SLOT(doResize()));

  treelist = new KTreeList(splitter);
  configList->fillTreeList(treelist);
  treelist->setMinimumWidth(200);
  splitter->setResizeMode(treelist,QSplitter::KeepSize);

  mwidget = new mainWidget(splitter);
  connect(mwidget, SIGNAL(resized()), this, SLOT(doResize()));

  connect(treelist, SIGNAL(selected(int)), this, SLOT(item_selected(int)));
  connect(treelist, SIGNAL(singleSelected(int)), this, SLOT(item_singleSelected(int)));

  setView(splitter);
  setMinimumSize(450,200);

  resize(700,600);

  show();
  resizeEvent(NULL);

  KConfig *config = kapp->getConfig();
  config->setGroup("Options");
  KModuleListEntry::swallowingEnabled = config->readNumEntry("SwallowEnabled", TRUE);
  options->setItemChecked(swallowID, KModuleListEntry::swallowingEnabled);
}
void LineMove::mouseReleaseEvent(QMouseEvent *m)
{
	adjustBounds(m);
	if (m_haveLineItem)
	{
		doResize();
		m_doc->setRedrawBounding(m_line);
		m_view->resetMousePressed();
		m_line->checkChanges();
		m_line->update();
	}
	m->accept();
	m_canvas->update();
//	qDebug() << "LineMove::mouseRelease" << m_line->xPos() << "," << m_line->yPos() << "@" << m_line->rotation() << m_line->width() << "x" << m_line->height();
	m_view->stopGesture();
}
Beispiel #18
0
MachineSplash::MachineSplash(QWidget *parent)
 : QWidget(parent)
{
    //set up splash background from splash.svg
    QSettings settings("QtEmu", "QtEmu");
    splashImage = new QSvgWidget(":/images/" + settings.value("iconTheme", "oxygen").toString() + "/splash.svg", this);
    getPreviewRect();
    previewImage = new QLabel(this);
    alpha = QPixmap(":/images/" + settings.value("iconTheme", "oxygen").toString() + "/alpha.svg");
    previewImage->setScaledContents(true);
    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->addWidget(splashImage);

    setLayout(layout);
    doResize();
    
}
bool HighlightScrollBarOverlay::eventFilter(QObject *object, QEvent *event)
{
    switch (event->type()) {
    case QEvent::Move:
        doMove();
        break;
    case QEvent::Resize:
        doResize();
        break;
    case QEvent::ZOrderChange:
        raise();
        break;
    default:
        break;
    }
    return QWidget::eventFilter(object, event);
}
Beispiel #20
0
void QWaylandWindow::setCanResize(bool canResize)
{
    QMutexLocker lock(&mResizeLock);
    mCanResize = canResize;

    if (canResize) {
        if (mResizeDirty) {
            QWindowSystemInterface::handleGeometryChange(window(), geometry());
        }
        if (!mConfigure.isEmpty()) {
            doResize();
            QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
        } else if (mResizeDirty) {
            QWindowSystemInterface::handleExposeEvent(window(), QRect(QPoint(), geometry().size()));
            mResizeDirty = false;
        }
    }
}
void ResizeGesture::mouseMoveEvent(QMouseEvent *m)
{
	adjustBounds(m);
	FPoint where = m_canvas->globalToCanvas(m->globalPos());
	if (// directly after a create the shape of an item isnt really usable, so we fix here
		m_origBounds.width() < 20 || m_origBounds.height() < 20 ||
		// and if we resize outside of the current canvas dimensions, we need to enlarge it
		where.x() < m_doc->minCanvasCoordinate.x() || where.y() < m_doc->minCanvasCoordinate.y() ||
		where.x() > m_doc->maxCanvasCoordinate.x() || where.y() > m_doc->maxCanvasCoordinate.y())
	{
		doResize(m->modifiers() & Qt::AltModifier);
	}
	m->accept();
	QPoint point = m->globalPos() - (m_canvas->mapToParent(QPoint(0, 0)) + m_canvas->parentWidget()->mapToGlobal(QPoint(0, 0)));
	m_view->ensureVisible(point.x(), point.y(), 20, 20);
	m_canvas->repaint();
	QRectF newBounds = m_bounds.normalized();
	m_canvas->displaySizeHUD(m->globalPos(), newBounds.width() - m_extraWidth, newBounds.height() - m_extraHeight);
}
Beispiel #22
0
void QSplitter::childEvent( QChildEvent *c )
{
    if ( c->type() == QEvent::ChildInserted ) {
	if ( !c->child()->isWidgetType() )
	    return;

	if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
	    return;

	QSplitterLayoutStruct *s = data->list.first();
	while ( s ) {
	    if ( s->wid == c->child() )
		return;
	    s = data->list.next();
	}
	addWidget( (QWidget*)c->child() );
	recalc( isVisible() );

    } else if ( c->type() == QEvent::ChildRemoved ) {
	QSplitterLayoutStruct *p = 0;
	if ( data->list.count() > 1 )
	    p = data->list.at(1); //remove handle _after_ first widget.
	QSplitterLayoutStruct *s = data->list.first();
	while ( s ) {
	    if ( s->wid == c->child() ) {
		data->list.removeRef( s );
		delete s;
		if ( p && p->isSplitter ) {
		    data->list.removeRef( p );
		    delete p->wid; //will call childEvent
		    delete p;
		}
		recalcId();
		doResize();
		return;
	    }
	    p = s;
	    s = data->list.next();
	}
    }
}
Beispiel #23
0
int omxResize(ILCLIENT_T *client, IMAGE *inImage, IMAGE *outImage){
	OMX_RESIZER resizer;
	resizer.client=client;
	resizer.pInputBufferHeader=NULL;
	int ret = prepareResizer(&resizer);
	if (ret != OMX_IMAGE_OK){
		return ret;
	}
	ret = startupResizer(&resizer, inImage);
	if (ret != OMX_IMAGE_OK){
		return ret;
	}
	ret = doResize(&resizer, inImage, outImage);
	if (ret != OMX_IMAGE_OK){
		return ret;
	}
	
	COMPONENT_T *list[2];
	list[0]=resizer.component;
	list[1]=NULL;
	ilclient_cleanup_components(list);
	return ret;
}
void ResizeGesture::mouseReleaseEvent(QMouseEvent *m)
{
	adjustBounds(m);
	if (m_doc->m_Selection->count() != 0)
	{
		PageItem* currItem = m_doc->m_Selection->itemAt(0);
//		qDebug() << "ResizeGesture::release: new bounds" << m_bounds;
		if (m_bounds != m_mousePressBounds)
		{
			doResize(m->modifiers() & Qt::AltModifier);
			m_doc->setRedrawBounding(currItem);
			if (currItem->asImageFrame())
				currItem->AdjustPictScale();
		}
		m_view->resetMousePressed();
		// necessary since mousebutton is still recorded pressed, and otherwise checkchanges() will do nothing
		// we must check changes on whole selection otherwise resize operation won't undo correctly on groups
		if (m_bounds != m_mousePressBounds)
		{
			for (int i = 0; i < m_doc->m_Selection->count(); ++i)
				m_doc->m_Selection->itemAt(i)->checkChanges();
			m_doc->invalidateRegion(m_mousePressBounds.unite(m_bounds));
			m_doc->regionsChanged()->update(m_mousePressBounds.unite(m_bounds));
			m_doc->changed();
		}
	}
//	qDebug() << "ResizeGesture::release: transaction" << m_transactionStarted;
	if (m_transactionStarted)
	{
		m_transactionStarted->commit();
		delete m_transactionStarted;
		m_transactionStarted = NULL;
	}
	m->accept();
	m_canvas->update();
	m_view->stopGesture();
}
Beispiel #25
0
void QSplitterPrivate::recalc(bool update)
{
    Q_Q(QSplitter);
    int n = list.count();
    /*
      Splitter handles before the first visible widget or right
      before a hidden widget must be hidden.
    */
    bool first = true;
    for (int i = 0; i < n ; ++i) {
        QSplitterLayoutStruct *s = list.at(i);
        s->handle->setHidden(first || s->widget->isHidden());
        if (!s->widget->isHidden())
            first = false;
    }

    int fi = 2 * q->frameWidth();
    int maxl = fi;
    int minl = fi;
    int maxt = QWIDGETSIZE_MAX;
    int mint = fi;
    /*
      calculate min/max sizes for the whole splitter
    */
    bool empty = true;
    for (int j = 0; j < n; j++) {
        QSplitterLayoutStruct *s = list.at(j);

        if (!s->widget->isHidden()) {
            empty = false;
            if (!s->handle->isHidden()) {
                minl += s->getHandleSize(orient);
                maxl += s->getHandleSize(orient);
            }

            QSize minS = qSmartMinSize(s->widget);
            minl += pick(minS);
            maxl += pick(s->widget->maximumSize());
            mint = qMax(mint, trans(minS));
            int tm = trans(s->widget->maximumSize());
            if (tm > 0)
                maxt = qMin(maxt, tm);
        }
    }

    if (empty) {
        if (qobject_cast<QSplitter *>(q->parentWidget())) {
            // nested splitters; be nice
            maxl = maxt = 0;
        } else {
            // QSplitter with no children yet
            maxl = QWIDGETSIZE_MAX;
        }
    } else {
        maxl = qMin<int>(maxl, QWIDGETSIZE_MAX);
    }
    if (maxt < mint)
        maxt = mint;

    if (update) {
        if (orient == Qt::Horizontal) {
            q->setMaximumSize(maxl, maxt);
            if (q->isWindow())
                q->setMinimumSize(minl,mint);
        } else {
            q->setMaximumSize(maxt, maxl);
            if (q->isWindow())
                q->setMinimumSize(mint,minl);
        }
        doResize();
        q->updateGeometry();
    } else {
        firstShow = true;
    }
}
void testRandom(size_t numSteps = 10000) {
  describePlatform();

  auto target = folly::make_unique<T>();
  std::vector<bool> valid;

  for (size_t step = 0; step < numSteps; ++step) {
    auto pct = folly::Random::rand32(100);
    auto v = folly::Random::rand32(uint32_t{3} << folly::Random::rand32(14));

    if (pct < 5) {
      doClear(*target, valid);
    } else if (pct < 30) {
      T copy;
      folly::resizeWithoutInitialization(copy, target->size());
      for (size_t i = 0; i < copy.size(); ++i) {
        if (valid[i]) {
          copy[i] = target->at(i);
        }
      }
      if (pct < 10) {
        std::swap(copy, *target);
      } else if (pct < 15) {
        *target = std::move(copy);
      } else if (pct < 20) {
        *target = copy;
      } else if (pct < 25) {
        target = folly::make_unique<T>(std::move(copy));
      } else {
        target = folly::make_unique<T>(copy);
      }
    } else if (pct < 35) {
      target->reserve(v);
    } else if (pct < 40) {
      target->shrink_to_fit();
    } else if (pct < 45) {
      doResize(*target, valid, v);
    } else if (pct < 50) {
      doInsert(*target, valid, v % (target->size() + 1));
    } else if (pct < 55) {
      if (!target->empty()) {
        doErase(*target, valid, v % target->size());
      }
    } else if (pct < 60) {
      doPushBack(*target, valid);
    } else if (pct < 65) {
      target = folly::make_unique<T>();
      valid.clear();
    } else if (pct < 80) {
      auto v2 = folly::Random::rand32(uint32_t{3} << folly::Random::rand32(14));
      doOverwrite(*target, valid, std::min(v, v2), std::max(v, v2));
    } else {
      doResizeWithoutInit(*target, valid, v);
    }

    // don't check every time in implementation does lazy work
    if (folly::Random::rand32(100) < 50) {
      check(*target);
    }
  }
}
Beispiel #27
0
void MainWindow::resizeEvent(QResizeEvent *)
{
  if (centralWidget()==0) return;

  doResize();
}
Beispiel #28
0
void QSplitter::recalc( bool update )
{
    int fi = 2*frameWidth();
    int maxl = fi;
    int minl = fi;
    int maxt = QWIDGETSIZE_MAX;
    int mint = fi;
    int n = data->list.count();
    bool first = TRUE;
    /*
      The splitter before a hidden widget is always hidden.
      The splitter before the first visible widget is hidden.
      The splitter before any other visible widget is visible.
    */
    for ( int i = 0; i< n; i++ ) {
	QSplitterLayoutStruct *s = data->list.at(i);
	if ( !s->isSplitter ) {
	    QSplitterLayoutStruct *p = (i > 0) ? data->list.at( i-1 ) : 0;
	    if ( p && p->isSplitter )
		if ( first || s->wid->isHidden() )
		    p->wid->hide(); //may trigger new recalc
		else
		    p->wid->show(); //may trigger new recalc
	    if ( !s->wid->isHidden() )
		first = FALSE;
	}
    }

    bool empty=TRUE;
    for ( int j = 0; j< n; j++ ) {
	QSplitterLayoutStruct *s = data->list.at(j);
	if ( !s->wid->isHidden() ) {
	    empty = FALSE;
	    if ( s->isSplitter ) {
		minl += s->sizer;
		maxl += s->sizer;
	    } else {
		QSize minS = minSize(s->wid);
		minl += pick( minS );
		maxl += pick( s->wid->maximumSize() );
		mint = QMAX( mint, trans( minS ));
		int tm = trans( s->wid->maximumSize() );
		if ( tm > 0 )
		    maxt = QMIN( maxt, tm );
	    }
	}
    }
    if ( empty )
	maxl = maxt = 0;
    else
	maxl = QMIN( maxl, QWIDGETSIZE_MAX );
    if ( maxt < mint )
	maxt = mint;

    if ( orient == Horizontal ) {
	setMaximumSize( maxl, maxt );
	setMinimumSize( minl, mint );
    } else {
	setMaximumSize( maxt, maxl );
	setMinimumSize( mint, minl );
    }
    if ( update )
	doResize();
}
Beispiel #29
0
void Picdok::resizeEvent(QResizeEvent *e)   // Trap the form resize event to allow the picture to be resized to match.
{
    QMainWindow::resizeEvent(e);
    doResize();
}
Beispiel #30
0
/*!
  \reimp
*/
void QSplitter::resizeEvent( QResizeEvent * )
{
    doResize();
}