| 3028 | |
| 3029 | |
| 3030 | void NetHackQtMenuWindow::paintCell(QPainter* painter, int row, int col) |
| 3031 | { |
| 3032 | // [pick-count] [accel] [glyph] [string] |
| 3033 | |
| 3034 | MenuItem& i = item[row]; |
| 3035 | |
| 3036 | painter->setPen(black); |
| 3037 | painter->setFont(font()); |
| 3038 | |
| 3039 | if (i.selected) { |
| 3040 | painter->setPen(darkGreen); |
| 3041 | } |
| 3042 | |
| 3043 | switch (col) { |
| 3044 | case 0: |
| 3045 | if ( i.ch || i.attr!=ATR_INVERSE ) { |
| 3046 | QString text; |
| 3047 | if ( i.selected && i.count == -1 ) { |
| 3048 | if ( i.str[0]>='0' && i.str[0]<='9' ) |
| 3049 | text = "All"; |
| 3050 | else |
| 3051 | text = "*"; |
| 3052 | } else if ( i.count<0 ) { |
| 3053 | text = "-"; |
| 3054 | } else { |
| 3055 | text.sprintf("%d",i.count); |
| 3056 | } |
| 3057 | painter->drawText(0,0,cellWidth(col),cellHeight(), |
| 3058 | AlignHCenter|AlignVCenter,text); |
| 3059 | } |
| 3060 | break; case 1: |
| 3061 | if ((signed char)i.ch >= 0) { |
| 3062 | char text[2]={i.ch,0}; |
| 3063 | painter->drawText(0,0,cellWidth(col),cellHeight(), |
| 3064 | AlignHCenter|AlignVCenter,text); |
| 3065 | } |
| 3066 | break; case 2: |
| 3067 | if (i.glyph!=NO_GLYPH) { |
| 3068 | // Centered in height |
| 3069 | int y=(cellHeight()-qt_settings->glyphs().height())/2; |
| 3070 | if (y<0) y=0; |
| 3071 | qt_settings->glyphs().drawGlyph(*painter, i.glyph, 0, y); |
| 3072 | } |
| 3073 | break; case 3: |
| 3074 | // XXX should qt_settings have ALL the various fonts |
| 3075 | QFont newfont=font(); |
| 3076 | |
| 3077 | if (i.attr) { |
| 3078 | switch(i.attr) { |
| 3079 | case ATR_ULINE: |
| 3080 | newfont.setUnderline(TRUE); |
| 3081 | break; case ATR_BOLD: |
| 3082 | painter->setPen(red); |
| 3083 | break; case ATR_BLINK: |
| 3084 | newfont.setItalic(TRUE); |
| 3085 | break; case ATR_INVERSE: |
| 3086 | newfont=qt_settings->largeFont(); |
| 3087 | newfont.setWeight(QFont::Bold); |