bool ColorListBox::event(QEvent *event) { if (event->type() == QEvent::ToolTip) { if (cList != NULL) { QHelpEvent *helpEvent = static_cast<QHelpEvent *>(event); QListWidgetItem* it = itemAt(helpEvent->pos()); if (it != 0) { event->accept(); QString tipText = ""; if (cList->contains(it->text())) { ScColor col = (*cList)[it->text()]; if (col.getColorModel() == colorModelCMYK) { int c, m, y, k; col.getCMYK(&c, &m, &y, &k); tipText = QString("C:%1% M:%2% Y:%3% K:%4%").arg(qRound(c / 2.55)).arg(qRound(m / 2.55)).arg(qRound(y / 2.55)).arg(qRound(k / 2.55)); } else { int r, g, b; col.getRawRGBColor(&r, &g, &b); tipText = QString("R:%1 G:%2 B:%3").arg(r).arg(g).arg(b); } } QToolTip::showText(helpEvent->globalPos(), tipText, this); return true; } } } return QListWidget::event(event); }
static quint64 code64(const ScColor & col) { int C, M, Y, K, R, G, B; quint64 result=0; if (col.getColorModel() == colorModelRGB) { col.getRGB( &R, &G, &B ); QColor color = QColor(R, G, B); color.getCmyk(&C, &M, &Y, &K); } else { col.getCMYK( &C, &M, &Y, &K ); R = 255-qMin(255, C + K); G = 255-qMin(255, M + K); B = 255-qMin(255, Y + K); } result |= col.getColorModel() == colorModelRGB ? 1 : 0; result |= col.isSpotColor() ? 64 : 0; result |= col.isRegistrationColor() ? 32 : 0; result <<= 8; result |= C; result <<= 8; result |= M; result <<= 8; result |= Y; result <<= 8; result |= K; result <<= 8; result |= R; result <<= 8; result |= G; result <<= 8; result |= B; return result; }
static quint64 code64(const ScColor & col) { int C = 0; int M = 0; int Y = 0; int K = 0; int R = 0; int G = 0; int B = 0; quint64 result = 0; if (col.getColorModel() == colorModelRGB) { col.getRGB( &R, &G, &B ); QColor color = QColor(R, G, B); color.getCmyk(&C, &M, &Y, &K); } else if (col.getColorModel() == colorModelCMYK) { col.getCMYK( &C, &M, &Y, &K ); R = 255-qMin(255, C + K); G = 255-qMin(255, M + K); B = 255-qMin(255, Y + K); } else { double L, a, b; col.getLab(&L, &a, &b); R = qRound(L); G = qRound(a); B = qRound(b); } result |= col.getColorModel() == colorModelRGB ? 1 : 0; result |= col.isSpotColor() ? 64 : 0; result |= col.isRegistrationColor() ? 32 : 0; result <<= 8; result |= C; result <<= 8; result |= M; result <<= 8; result |= Y; result <<= 8; result |= K; result <<= 8; result |= R; result <<= 8; result |= G; result <<= 8; result |= B; return result; }
static quint64 code64(const ScColor & col) { int C, M, Y, K, R, G, B; quint64 result=0; col.getRGB( &R, &G, &B ); col.getCMYK( &C, &M, &Y, &K ); result |= col.getColorModel() == colorModelRGB ? 1 : 0; result |= col.isSpotColor() ? 64 : 0; result |= col.isRegistrationColor() ? 32 : 0; result <<= 8; result |= C; result <<= 8; result |= M; result <<= 8; result |= Y; result <<= 8; result |= K; result <<= 8; result |= R; result <<= 8; result |= G; result <<= 8; result |= B; return result; }