CrossingWidget.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * Copyright (c) 2012 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. * Contributors:
  8. * m.muehlbrandt - initial API and implementation
  9. *
  10. */
  11. #include "CrossingWidget.h"
  12. CrossingWidget::CrossingWidget(QWidget *parent) :
  13. QWidget(parent) {
  14. parentWidget()->setFixedSize(WIDTH, HEIGHT);
  15. }
  16. void CrossingWidget::paintEvent(QPaintEvent *event) {
  17. QWidget::paintEvent(event);
  18. setFixedSize(parentWidget()->width(), parentWidget()->height());
  19. QPainter painter(this);
  20. painter.setBrush(Qt::darkGreen);
  21. painter.drawRect(0, 0, parentWidget()->width(), parentWidget()->height());
  22. painter.setBrush(QColor(192, 192, 192));
  23. painter.drawRect(WIDTH / 3, 0, WIDTH / 3, HEIGHT);
  24. painter.setBrush(Qt::white);
  25. for (int i = 0; i <= 10; i += 2) {
  26. painter.drawRect(WIDTH / 3 + i * WIDTH / 33, HEIGHT / 11, WIDTH / 30,
  27. HEIGHT / 10);
  28. }
  29. }
  30. CrossingWidget::~CrossingWidget() {
  31. }