playtile.cpp
来自「Siemens 的SIMpad是一个多媒体设备」· C++ 代码 · 共 79 行
CPP
79 行
/* * Copyright (C) 2002 Robert Ernst <robert.ernst@linux-solutions.at> * * This file may be distributed and/or modified under the terms of the * GNU General Public License version 2 as published by the Free Software * Foundation and appearing in the file LICENSE.GPL included in the * packaging of this file. * * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * See COPYING for GPL licensing information. * */#include <qpe/qpeapplication.h>#include <qwidget.h>#include <qpainter.h>#include "PlayTile.h"#include "SpriteCollection.h"PlayTile::PlayTile(QWidget *parent, SpriteCollection *sprites, int id, int state, const char *name, WFlags f) : QWidget(parent, name, f){ m_sprites = sprites; m_id = id; m_state = state;}void PlayTile::paintEvent(QPaintEvent *event){ if (m_id == -1) { return; } QPainter painter(this); QColor white(255, 255, 255); QColor darkgray(64, 64, 64); int x2 = width() - 1; int y2 = height() - 1; painter.setPen(white); painter.drawLine(0, 0, x2, 0); painter.drawLine(0, 0, 0, y2); painter.setPen(darkgray); painter.drawLine(0, y2, x2, y2); painter.drawLine(x2, 0, x2, y2); m_sprites->drawChip(painter, 1, 1, m_state);}void PlayTile::mousePressEvent(QMouseEvent *event){ if (m_id != -1) { emit tileClicked(m_id); }}void PlayTile::setState(int state){ m_state = state;}void PlayTile::setId(int id){ m_id = id;}int PlayTile::state(void){ return m_state;}int PlayTile::id(void){ return m_id;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?