Previous 199869 Revisions Next

r26378 Saturday 23rd November, 2013 at 14:44:18 UTC by Jürgen Buchmüller
Use QPainter::drawStaticText() for a try - looks good to me.
[/branches/alto2/src/osd/sdl]debugqtview.c debugqtview.h

branches/alto2/src/osd/sdl/debugqtview.c
r26377r26378
7070   bgBrush.setStyle(Qt::SolidPattern);
7171   painter.setPen(QPen(QColor(0,0,0)));
7272
73   QTextOption opt(Qt::AlignLeft);
74   QStaticText stext;
75   stext.prepare();
76   stext.setTextFormat(Qt::PlainText);
77   stext.setTextOption(opt);
78
7379   size_t viewDataOffset = 0;
7480   const debug_view_xy& visibleCharDims = m_view->visible_size();
7581   const debug_view_char* viewdata = m_view->viewdata();
7682   for (int y = 0; y < visibleCharDims.y; y++)
7783   {
78      for (int x = 0; x < visibleCharDims.x; x++)
84      for (int x = 0; x < visibleCharDims.x; /* */)
7985      {
86         int width = 0;
87         QString text;
8088         const unsigned char textAttr = viewdata[viewDataOffset].attrib;
8189
8290         if (x == 0 || textAttr != viewdata[viewDataOffset-1].attrib)
r26377r26378
127135            bgBrush.setColor(bgColor);
128136            painter.setBackground(bgBrush);
129137            // 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++) {
132140               if (textAttr != viewdata[viewDataOffset + width].attrib)
133141                  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.
135145            painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush);
136146            painter.setPen(QPen(fgColor));
137147         }
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;
145154      }
146155   }
147156}
branches/alto2/src/osd/sdl/debugqtview.h
r26377r26378
22#define __DEBUG_QT_VIEW_H__
33
44#include <QtGui/QtGui>
5#include <QPainter>
56
67#include "debug/debugvw.h"
78

Previous 199869 Revisions Next


© 1997-2024 The MAME Team