branches/alto2/src/osd/sdl/debugqtview.c
| r26377 | r26378 | |
| 70 | 70 | bgBrush.setStyle(Qt::SolidPattern); |
| 71 | 71 | painter.setPen(QPen(QColor(0,0,0))); |
| 72 | 72 | |
| 73 | QTextOption opt(Qt::AlignLeft); |
| 74 | QStaticText stext; |
| 75 | stext.prepare(); |
| 76 | stext.setTextFormat(Qt::PlainText); |
| 77 | stext.setTextOption(opt); |
| 78 | |
| 73 | 79 | size_t viewDataOffset = 0; |
| 74 | 80 | const debug_view_xy& visibleCharDims = m_view->visible_size(); |
| 75 | 81 | const debug_view_char* viewdata = m_view->viewdata(); |
| 76 | 82 | for (int y = 0; y < visibleCharDims.y; y++) |
| 77 | 83 | { |
| 78 | | for (int x = 0; x < visibleCharDims.x; x++) |
| 84 | for (int x = 0; x < visibleCharDims.x; /* */) |
| 79 | 85 | { |
| 86 | int width = 0; |
| 87 | QString text; |
| 80 | 88 | const unsigned char textAttr = viewdata[viewDataOffset].attrib; |
| 81 | 89 | |
| 82 | 90 | if (x == 0 || textAttr != viewdata[viewDataOffset-1].attrib) |
| r26377 | r26378 | |
| 127 | 135 | bgBrush.setColor(bgColor); |
| 128 | 136 | painter.setBackground(bgBrush); |
| 129 | 137 | // Scan for the width of identical attributes |
| 130 | | int width; |
| 131 | | for (width = 0; x + width < visibleCharDims.x; width++) |
| 138 | text.clear(); |
| 139 | for (width = 0; x + width < visibleCharDims.x; width++) { |
| 132 | 140 | if (textAttr != viewdata[viewDataOffset + width].attrib) |
| 133 | 141 | break; |
| 134 | | // Fill the of width times fontWidth x fontHeight. |
| 142 | text.append(QChar(viewdata[viewDataOffset + width].uchar)); |
| 143 | } |
| 144 | // Fill width times fontWidth x fontHeight. |
| 135 | 145 | painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush); |
| 136 | 146 | painter.setPen(QPen(fgColor)); |
| 137 | 147 | } |
| 138 | | |
| 139 | | // There is a touchy interplay between font height, drawing difference, visible position, etc |
| 140 | | // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed. |
| 141 | | painter.drawText(x*fontWidth, |
| 142 | | (y*fontHeight + (fontHeight*0.80)), |
| 143 | | QString(QChar(viewdata[viewDataOffset].uchar))); |
| 144 | | viewDataOffset++; |
| 148 | // Use QPainter::drawStaticText() for the string of characters |
| 149 | // sharing the same attributes |
| 150 | stext.setText(text); |
| 151 | painter.drawStaticText(QPoint(x*fontWidth,y*fontHeight), stext); |
| 152 | viewDataOffset += width; |
| 153 | x += width; |
| 145 | 154 | } |
| 146 | 155 | } |
| 147 | 156 | } |