Previous 199869 Revisions Next

r26390 Sunday 24th November, 2013 at 10:17:13 UTC by Jürgen Buchmüller
Use QPainter::drawStaticText() to render strings with the same attribute.
[src/osd/sdl]debugqtview.c

trunk/src/osd/sdl/debugqtview.c
r26389r26390
7272
7373   size_t viewDataOffset = 0;
7474   const debug_view_xy& visibleCharDims = m_view->visible_size();
75   const debug_view_char* viewdata = m_view->viewdata();
7576   for (int y = 0; y < visibleCharDims.y; y++)
7677   {
77      for (int x = 0; x < visibleCharDims.x; x++)
78      int width = 1;
79      for (int x = 0; x < visibleCharDims.x; viewDataOffset += width, x += width)
7880      {
79         const unsigned char textAttr = m_view->viewdata()[viewDataOffset].attrib;
81         const unsigned char textAttr = viewdata[viewDataOffset].attrib;
8082
81         if (x == 0 || textAttr != m_view->viewdata()[viewDataOffset-1].attrib)
83         // Text color handling
84         QColor fgColor(0,0,0);
85         QColor bgColor(255,255,255);
86
87         if(textAttr & DCA_VISITED)
8288         {
83            // Text color handling
84            QColor fgColor(0,0,0);
85            QColor bgColor(255,255,255);
89            bgColor.setRgb(0xc6, 0xe2, 0xff);
90         }
91         if(textAttr & DCA_ANCILLARY)
92         {
93            bgColor.setRgb(0xe0, 0xe0, 0xe0);
94         }
95         if(textAttr & DCA_SELECTED)
96         {
97            bgColor.setRgb(0xff, 0x80, 0x80);
98         }
99         if(textAttr & DCA_CURRENT)
100         {
101            bgColor.setRgb(0xff, 0xff, 0x00);
102         }
103         if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT))
104         {
105            bgColor.setRgb(0xff,0xc0,0x80);
106         }
107         if(textAttr & DCA_CHANGED)
108         {
109            fgColor.setRgb(0xff, 0x00, 0x00);
110         }
111         if(textAttr & DCA_INVALID)
112         {
113            fgColor.setRgb(0x00, 0x00, 0xff);
114         }
115         if(textAttr & DCA_DISABLED)
116         {
117            fgColor.setRgb((fgColor.red()   + bgColor.red())   >> 1,
118                        (fgColor.green() + bgColor.green()) >> 1,
119                        (fgColor.blue()  + bgColor.blue())  >> 1);
120         }
121         if(textAttr & DCA_COMMENT)
122         {
123            fgColor.setRgb(0x00, 0x80, 0x00);
124         }
86125
87            if(textAttr & DCA_VISITED)
88            {
89               bgColor.setRgb(0xc6, 0xe2, 0xff);
90            }
91            if(textAttr & DCA_ANCILLARY)
92            {
93               bgColor.setRgb(0xe0, 0xe0, 0xe0);
94            }
95            if(textAttr & DCA_SELECTED)
96            {
97               bgColor.setRgb(0xff, 0x80, 0x80);
98            }
99            if(textAttr & DCA_CURRENT)
100            {
101               bgColor.setRgb(0xff, 0xff, 0x00);
102            }
103            if ((textAttr & DCA_SELECTED) && (textAttr & DCA_CURRENT))
104            {
105               bgColor.setRgb(0xff,0xc0,0x80);
106            }
107            if(textAttr & DCA_CHANGED)
108            {
109               fgColor.setRgb(0xff, 0x00, 0x00);
110            }
111            if(textAttr & DCA_INVALID)
112            {
113               fgColor.setRgb(0x00, 0x00, 0xff);
114            }
115            if(textAttr & DCA_DISABLED)
116            {
117               fgColor.setRgb((fgColor.red()   + bgColor.red())   >> 1,
118                           (fgColor.green() + bgColor.green()) >> 1,
119                           (fgColor.blue()  + bgColor.blue())  >> 1);
120            }
121            if(textAttr & DCA_COMMENT)
122            {
123               fgColor.setRgb(0x00, 0x80, 0x00);
124            }
126         bgBrush.setColor(bgColor);
127         painter.setBackground(bgBrush);
128         painter.setPen(QPen(fgColor));
125129
126            bgBrush.setColor(bgColor);
127            painter.setBackground(bgBrush);
128            painter.setPen(QPen(fgColor));
130         QString text(QChar(viewdata[viewDataOffset].byte));
131         for (width = 1; x + width < visibleCharDims.x; width++)
132         {
133            if (textAttr != viewdata[viewDataOffset + width].attrib)
134               break;
135            text.append(QChar(viewdata[viewDataOffset + width].byte));
129136         }
130
131         // Your character is not guaranteed to take up the entire fontWidth x fontHeight, so fill before.
132         painter.fillRect(x*fontWidth, y*fontHeight, fontWidth, fontHeight, bgBrush);
133
134         // There is a touchy interplay between font height, drawing difference, visible position, etc
135         // Fonts don't get drawn "down and to the left" like boxes, so some wiggling is needed.
136         painter.drawText(x*fontWidth,
137                        (y*fontHeight + (fontHeight*0.80)),
138                        QString(m_view->viewdata()[viewDataOffset].byte));
139         viewDataOffset++;
137         // Your characters are not guaranteed to take up the entire length x fontWidth x fontHeight, so fill before.
138         painter.fillRect(x*fontWidth, y*fontHeight, width*fontWidth, fontHeight, bgBrush);
139         // Static text object
140         QStaticText staticText(text);
141         painter.drawStaticText(x*fontWidth, y*fontHeight, staticText);
140142      }
141143   }
142144}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team