QIcon SCgAlphabet::createNodeIcon(const QSize &size, const SCgConstType &type_const, const SCgNodeStructType &type_struct) { QIcon icon; // for (int mode = QIcon::Normal; mode <= QIcon::Selected; mode++) // for (int state = QIcon::On; state <= QIcon::Off; state++) { QPixmap pixmap(size); QPainter painter; pixmap.fill(Qt::transparent); painter.begin(&pixmap); painter.setRenderHint(QPainter::Antialiasing, true); QColor color; painter.translate(size.width() / 2.f, size.height() / 2.f); painter.scale(0.8f, 0.8f); paintNode(&painter, QColor(0, 0, 0, 255),//(state == QIcon::On) ? 255 : 128), QRectF(-size.width() / 2.f, - size.height() / 2.f, size.width(), size.height()), type_const, type_struct); painter.end(); for (int mode = QIcon::Normal; mode <= QIcon::Selected; mode++) for (int state = QIcon::On; state <= QIcon::Off; state++) icon.addPixmap(pixmap, (QIcon::Mode)mode, (QIcon::State)state); } return icon; }
//////////////////////////////////////////////////////////////////////////////// /// CPuzzleNodeArtist::paintModel /// /// @description This function paints all the nodes to the screen. /// @pre None /// @post All the nodes are drawn to the screen. /// /// @limitations None /// //////////////////////////////////////////////////////////////////////////////// void CPuzzleNodeArtist::paintModel() { if (m_model != NULL) { QPainter painter( m_canvas ); for (int i = 0; i < m_model->getNodeCount(); i++) { paintNode( m_model->getNodeAt(i), &painter ); } } }
//////////////////////////////////////////////////////////////////////////////// /// CPuzzleNodeArtist::paintModel /// /// @description This function paints all the nodes to the screen. /// @pre None /// @post All the nodes are drawn to the screen. /// /// @param painter: This is a pointer to the painter to use. If no value is /// passed, create a painter to use. /// /// @limitations None /// //////////////////////////////////////////////////////////////////////////////// void CPuzzleNodeArtist::paintModel( QPainter *painter ) { if (m_model != NULL) { //This variable is used for painting to the canvas if no painter was //specified. QPainter localPainter( m_canvas ); //Check if the calling function did not pass a painter and use //the local one in that case. if ( painter == NULL ) painter = &localPainter; for (int i = 0; i < m_model->getNodeCount(); i++) { paintNode( m_model->getNodeAt(i), painter ); } } }