Ejemplo n.º 1
0
void Boid::draw()
{
    gl::pushMatrices();
    gl::translate(mPos);
    gl::color(mColor);
    drawWidget(1);
    gl::color(mColor.r, mColor.g, mColor.b, 0.3);
    drawWidget(mRadius);
    gl::popMatrices();
}
Ejemplo n.º 2
0
void Widget::paintEvent(QPaintEvent *e) {

    QPainter qp(this);
    drawWidget(qp);

    QFrame::paintEvent(e);
}
Ejemplo n.º 3
0
void QWidgetPrivate::repaint_sys(const QRegion &rgn)
{
    if (data.in_destructor)
        return;

    Q_Q(QWidget);
    if (q->testAttribute(Qt::WA_StaticContents)) {
        if (!extra)
            createExtra();
        extra->staticContentsSize = data.crect.size();
    }

    QRegion toBePainted(rgn);

    toBePainted &= clipRect();
    clipToEffectiveMask(toBePainted);
    if (toBePainted.isEmpty())
        return; // Nothing to repaint.

#ifndef QT_NO_PAINT_DEBUG
    bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted);
#endif

    drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, 0);

#ifndef QT_NO_PAINT_DEBUG
    if (flushed)
        QWidgetBackingStore::unflushPaint(q, toBePainted);
#endif

    if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive())
        qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
}
QImage TrafficGraph::getSnapshotImage(uint w, uint height)
{
  uint horizontalStep = (uint)((1.0*w/width())+0.5); //get the closest integer horizontal step
  uint newWidth = horizontalStep * width();
  QImage image = QImage(newWidth, height, QImage::Format_RGB32);
  QPainter p(&image);
  drawWidget(&p, newWidth, height, newWidth);
  return image;
}
Ejemplo n.º 5
0
void drawOKMenu()
{
	int i;

	drawImage(menu.background, menu.x, menu.y, FALSE, 196);

	for (i=0;i<menu.widgetCount;i++)
	{
		drawWidget(menu.widgets[i], &menu, menu.index == i);
	}
}
void TrafficGraph::paintEvent( QPaintEvent* )
{
  uint w = width();
  uint h = height();

  /* Do not do repaints when the widget is not yet setup properly. */
  if ( w <= 2 )
    return;
  QPainter p(this);
  drawWidget(&p, w, h, mHorizontalScale);
}
Ejemplo n.º 7
0
	void Widget::draw(bool forceDraw) {
		if(!mEnabled && !forceDraw)
			return;
	
		//Engine &engine = Engine::getSingleton();

		//bool res = engine.pushClipRectIntersect(mBounds.x, mBounds.y,
		//	mBounds.width, mBounds.height);
		
		Gfx_pushMatrix();
		Gfx_translate(mRelX, mRelY);
		BOOL res = Gfx_intersectClipRect(0, 0, mBounds.width, mBounds.height);

		if(res) 
		{
			if(isDirty() || forceDraw) 
			{
				drawBackground();
			}
			//MAUI_LOG("Widget::draw, paddingLeft= %d, paddingTop = %d", mPaddingLeft, mPaddingTop);
			Gfx_translate(mPaddingLeft, mPaddingTop);
			BOOL res = Gfx_intersectClipRect(0, 0, mPaddedBounds.width, mPaddedBounds.height);

#if 0	// debug drawings
			if(mFocused) {
				maSetColor(0x00ff00);
				Gfx_line(0, 0, mBounds.width-1, 0);
				Gfx_line(mPaddedBounds.width-1, 0, mPaddedBounds.width-1, mPaddedBounds.height-1);
				Gfx_line(0, mPaddedBounds.height-1, mPaddedBounds.width-1, mPaddedBounds.height-1);
				Gfx_line(0, 0, 0, mPaddedBounds.height-1);
			}
#endif

			Gfx_translate(getTranslationX(), getTranslationY());

			if(res) {
				if(isDirty() || forceDraw) {
					drawWidget();
				}

				Vector_each(Widget*, it, mChildren)
					(*it)->draw();

			}
			// This commented out to match removal of above intersectClipRect() call.
			Gfx_popClipRect();
			setDirty(false);
		}
		Gfx_popMatrix();
		//engine.popClipRect();
		Gfx_popClipRect();
	}
Ejemplo n.º 8
0
void Widget::draw() {
	if (!isVisible() || !_boss->isVisible())
		return;

	if (_needsRedraw) {
		int oldX = _x, oldY = _y;

		// Account for our relative position in the dialog
		_x = getAbsX();
		_y = getAbsY();

		Common::Rect oldClip = g_gui.theme()->swapClipRect(_boss->getClipRect());

		// Draw border
		if (_flags & WIDGET_BORDER) {
			g_gui.theme()->drawWidgetBackground(Common::Rect(_x, _y, _x + _w, _y + _h), 0,
			                                    ThemeEngine::kWidgetBackgroundBorder);
			_x += 4;
			_y += 4;
			_w -= 8;
			_h -= 8;
		}

		// Now perform the actual widget draw
		drawWidget();

		g_gui.theme()->swapClipRect(oldClip);

		// Restore x/y
		if (_flags & WIDGET_BORDER) {
			_x -= 4;
			_y -= 4;
			_w += 8;
			_h += 8;
		}

		_x = oldX;
		_y = oldY;

		_needsRedraw = false;
	}

	// Draw all children
	Widget *w = _firstWidget;
	while (w) {
		w->draw();
		w = w->_next;
	}
}
googleweatherWidget::googleweatherWidget (const QRectF &rect, QWidget *widget):
DesktopWidget(rect,widget)
{
  shade = 0;
  moveY = 0;
  setPath(applicationDirPath() +"/theme/skins/default/widget/default/googleweather/");
  setDockImage(QPixmap(prefix + "icon.png"));
  drawWidget();

  clip = QRectF(10, 10, rect.width()-40, rect.height()-20);
  view = QRectF(0, 0, rect.width()-80, 0);
  initD = 0;
  DS_EXTF = 0;
  initTimer = 1;
  weather = new SocialQDBusPluginData();

}
Ejemplo n.º 10
0
int main(int argc, char **argv) {
    QApplication app(argc, argv);

    QMainWindow window;
    QWidget mainWidget;
    QVBoxLayout layout;
    DrawWidget drawWidget(QSize(128, 128));

    layout.addWidget(&drawWidget, 0, Qt::AlignCenter);

    mainWidget.setLayout(&layout);

    QAction fillArrayAction("Fill array", &window);
    QAction smoothAction("Smooth", &window);

    QObject::connect(&fillArrayAction, &QAction::triggered, [&]() {
        drawWidget.setEnabled(false);
        fillArrayAction.setEnabled(false);
        drawWidget.fillArray();
        smoothAction.setEnabled(true);
        drawWidget.setEnabled(true);
    });

    smoothAction.setEnabled(false);
    QObject::connect(&smoothAction, &QAction::triggered, [&]() {
        smoothAction.setEnabled(false);
        drawWidget.smooth();
        fillArrayAction.setEnabled(true);
    });

    QToolBar toolBar;
    toolBar.addAction(&fillArrayAction);
    toolBar.addAction(&smoothAction);

    window.addToolBar(&toolBar);
    window.setCentralWidget(&mainWidget);
    window.resize(320, 240);
    window.show();

    return app.exec();
}
Ejemplo n.º 11
0
void drawMedalsMenu()
{
	int i;
	SDL_Rect rect;

	drawImage(menu.background, menu.x, menu.y, FALSE, 196);

	rect.x = menu.x + 5;
	rect.y = menu.y + 5;
	rect.w = menu.w;
	rect.h = menu.h;

	SDL_RenderSetClipRect(game.renderer, &rect);

	for (i=0;i<menu.widgetCount;i++)
	{
		drawWidget(menu.widgets[i], &menu, -1);
	}

	SDL_RenderSetClipRect(game.renderer, NULL);
}
Ejemplo n.º 12
0
void chooseSkillStart(GUI* gui, Model* initData, SDL_Surface* windowSurface) {
	if (gui->stateId == CAT_CHOOSE_SKILL) {
		currAnimal = CAT;
	}
	else {
		currAnimal = MOUSE;
	}


	char buffer[3];
	gui->viewState = initializeChooseSkillWindow(windowSurface);
	gui->model = guis[gui->stateId]->model;


	if (initData != NULL && initData->world != NULL && initData->stateIdModel != CHOOSE_MOUSE && initData->stateIdModel != CHOOSE_CAT) { // coming from "reconfigure cat/mouse"
		gui->model->gameConfig = initData->gameConfig;
		gui->model->world = initData->world;

		Widget* skillButton = getWidgetFromId(BUTTON_SKILL_LEVEL, gui->viewState);

		if (gui->model->stateIdModel == CAT_CHOOSE_SKILL) {
			currSkill = gui->model->gameConfig->catSkill;
		}
		else {
			currSkill = gui->model->gameConfig->mouseSkill;
		}
		sprintf(buffer, "%d", currSkill);

		markButtonStart(gui->model, BUTTON_SKILL_LEVEL, BUTTON_SKILL_LEVEL, gui->viewState);
		setText(skillButton, buffer);
	}
	else if (initData != NULL && initData->prevModel != NULL && gui->stateId == initData->prevModel->stateIdModel) { // coming from "back" button
		Widget* skillButton = getWidgetFromId(BUTTON_SKILL_LEVEL, gui->viewState);
		
		
		gui->model = initData->prevModel;

		if (gui->model->stateIdModel == CAT_CHOOSE_SKILL) {
			currSkill = gui->model->gameConfig->catSkill;
		}
		else {
			currSkill = gui->model->gameConfig->mouseSkill;
		}
		sprintf(buffer, "%d", currSkill);
		
		markButtonStart(gui->model, gui->model->markedButton, BUTTON_SKILL_LEVEL, gui->viewState);
		setText(skillButton, buffer);
	}
	

	else { // coming from "choose type"
		if (gui->model == NULL) { // if we come to this screen for the first time, we need to allocate the model
			gui->model = createModel(gui->stateId, initData, BUTTON_SKILL_LEVEL);
		}
		else { // if this is not the first time, we don't allocate, just update the relevant fields
			gui->model->stateIdModel = gui->stateId;
			gui->model->prevModel = initData;
			gui->model->markedButton = BUTTON_SKILL_LEVEL;
		}


		gui->model->gameConfig = initData->gameConfig;

		

		gui->model->world = initData->world;
		Widget* skillButton = getWidgetFromId(BUTTON_SKILL_LEVEL, gui->viewState);
		if (gui->model->stateIdModel == CAT_CHOOSE_SKILL && gui->model->gameConfig->catSkill != 0) {
			currSkill = gui->model->gameConfig->catSkill;
		}
		else if (gui->model->stateIdModel == MOUSE_CHOOSE_SKILL && gui->model->gameConfig->mouseSkill != 0) {
			currSkill = gui->model->gameConfig->mouseSkill;
		}
		else {
			currSkill = DEFAULT_SKILL;
		}
		sprintf(buffer, "%d", currSkill);
		setText(skillButton, buffer);
		
	}

	drawWidget(gui->viewState);
}
Ejemplo n.º 13
0
StateId chooseSkillHandleEvent(Model* model, Widget* viewState, LogicEvent* logicalEvent) {
	Widget* exMarkedButton = NULL;
	Widget* newMarkedButton = NULL;
	Widget* selectedButton = NULL;
	StateId stateid;

	switch (logicalEvent->type) {

	case QUIT_EVENT:
		stateid = QUIT;
		free(logicalEvent);
		return stateid;
		break;

	case MARK_BUTTON:
		markButton(model, logicalEvent, exMarkedButton, viewState, newMarkedButton);
		stateid = model->stateIdModel;
		break;

	case SELECT_BUTTON:
		markButton(model, logicalEvent, exMarkedButton, viewState, newMarkedButton);
		selectedButton = getWidgetFromId(logicalEvent->buttonId, viewState);

		// return the appropriate StateId
		switch (selectedButton->id) {
		

		case BUTTON_SKILL_DONE:
			if (currAnimal == CAT) {
				model->gameConfig->catSkill = currSkill;
				if (model->world == NULL) {
					stateid = CHOOSE_MOUSE;
				}
				else {
					stateid = PLAY_GAME;
				}
			}
			else {
				model->gameConfig->mouseSkill = currSkill;
				stateid = PLAY_GAME;
			}

			break;
		case BUTTON_SKILL_INCREASE:
			markButtonStart(model, BUTTON_SKILL_LEVEL, BUTTON_SKILL_LEVEL, viewState);
			if (currSkill < MAX_SKILL) {
				currSkill++;
				changeSkillButton(viewState);
			}
			stateid = model->stateIdModel;

			break;

		case BUTTON_SKILL_DECREASE:
			markButtonStart(model, BUTTON_SKILL_LEVEL, BUTTON_SKILL_LEVEL, viewState);
			if (currSkill > MIN_SKILL) {
				currSkill--;
				changeSkillButton(viewState);
			}
			stateid = model->stateIdModel;

			break;

		case BUTTON_SKILL_BACK:
			stateid = model->prevModel->stateIdModel;
			if (model->world == NULL) { // if the game hasn't started, we want to "forget" the skill when clicking back
				if (currAnimal == CAT) {
					model->gameConfig->catSkill = DEFAULT_SKILL;
				}
				else {
					model->gameConfig->mouseSkill = DEFAULT_SKILL;
				}
			}
			break;
		default:
			stateid = model->stateIdModel;
			break;
		}
		break;

		
	default:
		stateid = model->stateIdModel;
		free(logicalEvent);
		return stateid;
		break;
	}

	drawWidget(viewState);

	free(logicalEvent);
	return stateid;
}
Ejemplo n.º 14
0
void selectWorldStart(GUI* gui, Model* initData, SDL_Surface* windowSurface) {
	if (gui->stateId == EDIT_GAME) {
		currSelectionWindow = EDIT;
	}
	else if (gui->stateId == SAVE_GAME) {
		currSelectionWindow = SAVE;
	}
	else {
		currSelectionWindow = LOAD;
	}


	char stringBuffer[SELECT_WORLD_STRING_LENGTH];
	char digitBuffer[2];
	strcpy(stringBuffer, SELECT_WORLD_COOSE_TEXT);

	gui->viewState = initializeChooseWorldWindow(windowSurface);
	gui->model = guis[gui->stateId]->model;
	if (initData != NULL && initData->prevModel != NULL && gui->stateId == initData->prevModel->stateIdModel && currSelectionWindow != SAVE) {// coming from "back" button
		Widget* worldButton = getWidgetFromId(BUTTON_SELECT_WORLD, gui->viewState);


		gui->model = initData->prevModel;

		currWorld = gui->model->gameConfig->worldIndex;

		sprintf(digitBuffer, "%d", currWorld);
		strcat(stringBuffer, digitBuffer);

		markButtonStart(gui->model, gui->model->markedButton, BUTTON_SELECT_WORLD, gui->viewState);
		setText(worldButton, stringBuffer);
	}

	else if (initData != NULL && initData->gameConfig != NULL) { // coming from "world builder"
		if (gui->model == NULL) {
			gui->model = createModel(gui->stateId, initData, BUTTON_SELECT_WORLD);
		}
		gui -> model->world = initData->world;
		gui->model->gameConfig = initData->gameConfig;

		gui->model->prevModel = initData;

		currWorld = gui->model->gameConfig->worldIndex;

		sprintf(digitBuffer, "%d", currWorld);
		strcat(stringBuffer, digitBuffer);

		Widget* worldButton = getWidgetFromId(BUTTON_SELECT_WORLD, gui->viewState);
		markButtonStart(gui->model, BUTTON_SELECT_WORLD, BUTTON_SELECT_WORLD, gui->viewState);
		setText(worldButton, stringBuffer);
	}
	else { // coming from main menu
		if (gui->model == NULL) { // if we come to this screen for the first time, we need to allocate the model
			gui->model = createModel(gui->stateId, initData, BUTTON_SELECT_WORLD);
		}
		else { // if this is not the first time, we don't allocate, just update the relevant fields
			gui->model->stateIdModel = gui->stateId;
			gui->model->prevModel = initData;
			gui->model->markedButton = BUTTON_SELECT_WORLD;
		}


		if (gui->model->gameConfig == NULL) { // if we come to this screen for the first time, we need to allocate the game config
			gui->model->gameConfig = createGameConfig(0, 0, DEFAULT_WORLD);
		}
		else { // if this is not the first time, we don't allocate, just update the relevant fields to the default values
			gui->model->gameConfig->catSkill = 0;
			gui->model->gameConfig->mouseSkill = 0;
			gui->model->gameConfig->worldIndex = DEFAULT_WORLD;
		}

		Widget* worldButton = getWidgetFromId(BUTTON_SELECT_WORLD, gui->viewState);
		currWorld = DEFAULT_WORLD;

		sprintf(digitBuffer, "%d", currWorld);
		strcat(stringBuffer, digitBuffer);
		setText(worldButton, stringBuffer);

		markButtonStart(gui->model, BUTTON_SELECT_WORLD, BUTTON_SELECT_WORLD, gui->viewState);
	}

	if (currSelectionWindow == SAVE) {
		markButtonStart(gui->model, BUTTON_SELECT_WORLD, BUTTON_SELECT_WORLD_DONE, gui->viewState);
	}

	drawWidget(gui->viewState);
}
Ejemplo n.º 15
0
StateId selectWorldHandleEvent(Model* model, Widget* viewState, LogicEvent* logicalEvent) {
	Widget* exMarkedButton = NULL;
	Widget* newMarkedButton = NULL;
	Widget* selectedButton = NULL;
	StateId stateid;

	switch (logicalEvent->type) {
	case QUIT_EVENT:
		stateid = QUIT;
		free(logicalEvent);
		return stateid;
		break;

	case MARK_BUTTON:
		markButton(model, logicalEvent, exMarkedButton, viewState, newMarkedButton);
		stateid = model->stateIdModel;
		break;

	case SELECT_BUTTON:
		markButton(model, logicalEvent, exMarkedButton, viewState, newMarkedButton);
		selectedButton = getWidgetFromId(logicalEvent->buttonId, viewState);

		// return the appropriate StateId
		switch (selectedButton->id) {
		case BUTTON_SELECT_WORLD_DONE:
			model->gameConfig->worldIndex = currWorld;
			if (currSelectionWindow == LOAD) {
				stateid = CHOOSE_CAT;
			}
			else if (currSelectionWindow == EDIT) {
				stateid = EDIT_WORLD_BUILDER;
			}
			else {
				saveWorldToFile(model->gameConfig->worldIndex, model->world);
				stateid = EDIT_WORLD_BUILDER;
			}

			break;
		case BUTTON_SELECT_WORLD_INCREASE:
			markButtonStart(model, BUTTON_SELECT_WORLD, BUTTON_SELECT_WORLD, viewState);
			if (currWorld < MAX_WORLD) {
				currWorld++;
				changeWorldButton(viewState);
			}
			stateid = model->stateIdModel;

			break;

		case BUTTON_SELECT_WORLD_DECREASE:
			markButtonStart(model, BUTTON_SELECT_WORLD, BUTTON_SELECT_WORLD, viewState);
			if (currWorld > MIN_WORLD) {
				currWorld--;
				changeWorldButton(viewState);
			}
			stateid = model->stateIdModel;

			break;

		case BUTTON_SELECT_WORLD_BACK:
			stateid = model->prevModel->stateIdModel;
			break;
		default:
			stateid = model->stateIdModel;
			break;
		}
		break;

	default:
		stateid = model->stateIdModel;
		free(logicalEvent);
		return stateid;
		break;
	}

	drawWidget(viewState);


	free(logicalEvent);
	return stateid;
}
Ejemplo n.º 16
0
CentralWidget::CentralWidget(QWidget* parent): QWidget(parent) {
    drawWidget();
    setValidator();
    lock();
}