| 484 | } |
| 485 | |
| 486 | void NetHackQtMenuWindow::SetTwiAttr(QTableWidgetItem *twi, int color, int attr) |
| 487 | { |
| 488 | if (color != NO_COLOR) { |
| 489 | const QPen qp = NetHackQtBind::nhcolor_to_pen(color); |
| 490 | twi->setForeground(qp.color()); |
| 491 | } |
| 492 | |
| 493 | if (attr != ATR_NONE) { |
| 494 | QFont itemfont(table->font()); |
| 495 | switch (attr) { |
| 496 | case ATR_BOLD: |
| 497 | itemfont.setWeight(QFont::Bold); |
| 498 | twi->setFont(itemfont); |
| 499 | break; |
| 500 | case ATR_ITALIC: |
| 501 | itemfont.setItalic(true); |
| 502 | twi->setFont(itemfont); |
| 503 | break; |
| 504 | case ATR_DIM: |
| 505 | twi->setFlags(Qt::NoItemFlags); |
| 506 | break; |
| 507 | case ATR_ULINE: |
| 508 | itemfont.setUnderline(true); |
| 509 | twi->setFont(itemfont); |
| 510 | break; |
| 511 | case ATR_INVERSE: { |
| 512 | QBrush fg = twi->foreground(); |
| 513 | QBrush bg = twi->background(); |
| 514 | if (fg.color() == bg.color()) { |
| 515 | // default foreground and background come up the same for |
| 516 | // some unknown reason |
| 517 | //[pr: both are set to 'Qt::color1' which has same RGB |
| 518 | // value as 'Qt::black'; X11 on OSX behaves similarly] |
| 519 | if (fg.color() == Qt::color1) { |
| 520 | fg = Qt::black; |
| 521 | bg = Qt::white; |
| 522 | } else { |
| 523 | fg = (bg.color() == Qt::white) ? Qt::black : Qt::white; |
| 524 | } |
| 525 | } |
| 526 | twi->setForeground(bg); |
| 527 | twi->setBackground(fg); |
| 528 | break; |
| 529 | } |
| 530 | case ATR_BLINK: |
| 531 | // not supported |
| 532 | break; |
| 533 | } /* switch */ |
| 534 | } /* if attr != ATR_NONE */ |
| 535 | } |
| 536 | |
| 537 | void NetHackQtMenuWindow::AddRow(int row, const MenuItem& mi) |
| 538 | { |