📄 qtwin.cpp
字号:
SetColorx(&g_Color1, fgcolour);
SetColorx(&g_Color2, bgcolour);
g_P2->setBackgroundColor(g_Color2);
g_P2->setPen(g_Color1);
if (boxcx > 1)
{
g_P2->fillRect(boxx, boxy, boxcx, boxcy, QBrush(g_Color2));
}
else if (mixmode == MIX_OPAQUE)
{
g_P2->fillRect(clipx, clipy, clipcx, clipcy, QBrush(g_Color2));
}
/* Paint text, character by character */
for (i = 0; i < length;)
{
switch (text[i])
{
case 0xff:
if (i + 2 < length)
{
cache_put_text(text[i + 1], text, text[i + 2]);
}
else
{
error("this shouldn't be happening\n");
exit(1);
}
/* this will move pointer from start to first character after FF
command */
length -= i + 3;
text = &(text[i + 3]);
i = 0;
break;
case 0xfe:
entry = cache_get_text(text[i + 1]);
if (entry != NULL)
{
if ((((uint8 *) (entry->data))[1] == 0) &&
(!(flags & TEXT2_IMPLICIT_X)))
{
if (flags & TEXT2_VERTICAL)
{
y += text[i + 2];
}
else
{
x += text[i + 2];
}
}
for (j = 0; j < entry->size; j++)
{
DO_GLYPH(((uint8 *) (entry->data)), j);
}
}
if (i + 2 < length)
{
i += 3;
}
else
{
i += 2;
}
length -= i;
/* this will move pointer from start to first character after FE
command */
text = &(text[i]);
i = 0;
break;
default:
DO_GLYPH(text, i);
i++;
break;
}
}
if (boxcx > 1)
{
bitBltClip(g_MW, NULL, boxx, boxy, g_BS, boxx, boxy, boxcx, boxcy,
Qt::CopyROP, true);
}
else
{
bitBltClip(g_MW, NULL, clipx, clipy, g_BS, clipx, clipy, clipcx,
clipcy, Qt::CopyROP, true);
}
}
/*****************************************************************************/
void ui_line(uint8 opcode, int startx, int starty, int endx, int endy,
PEN * pen)
{
SetColorx(&g_Color1, pen->colour);
SetOpCode(opcode);
g_P1->setPen(g_Color1);
g_P1->moveTo(startx, starty);
g_P1->lineTo(endx, endy);
g_P2->setPen(g_Color1);
g_P2->moveTo(startx, starty);
g_P2->lineTo(endx, endy);
ResetOpCode(opcode);
}
/*****************************************************************************/
// not used
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
HBITMAP src, int srcx, int srcy,
BRUSH* brush, int bgcolour, int fgcolour)
{
}
/*****************************************************************************/
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
HBITMAP src, int srcx, int srcy)
{
QPixmap* Pixmap;
Pixmap = (QPixmap*)src;
if (Pixmap != NULL)
{
SetOpCode(opcode);
g_P1->drawPixmap(x, y, *Pixmap, srcx, srcy, cx, cy);
g_P2->drawPixmap(x, y, *Pixmap, srcx, srcy, cx, cy);
ResetOpCode(opcode);
}
}
//******************************************************************************
void CommonDeskSave(QPixmap* Pixmap1, QPixmap* Pixmap2, int Offset, int x,
int y, int cx, int cy, int dir)
{
int lx;
int ly;
int x1;
int y1;
int width;
int lcx;
int right;
int bottom;
lx = Offset % 480;
ly = Offset / 480;
y1 = y;
right = x + cx;
bottom = y + cy;
while (y1 < bottom)
{
x1 = x;
lcx = cx;
while (x1 < right)
{
width = 480 - lx;
if (width > lcx)
width = lcx;
if (dir == 0)
bitBlt(Pixmap1, lx, ly, Pixmap2, x1, y1, width, 1, Qt::CopyROP, true);
else
bitBlt(Pixmap2, x1, y1, Pixmap1, lx, ly, width, 1, Qt::CopyROP, true);
lx = lx + width;
if (lx >= 480)
{
lx = 0;
ly++;
if (ly >= 480)
ly = 0;
}
lcx = lcx - width;
x1 = x1 + width;
}
y1++;
}
}
/*****************************************************************************/
void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
{
QPixmap * Pixmap;
Pixmap = new QPixmap(cx, cy);
CommonDeskSave(g_DS, Pixmap, offset, 0, 0, cx, cy, 1);
bitBltClip(g_MW, g_BS, x, y, Pixmap, 0, 0, cx, cy, Qt::CopyROP, true);
delete Pixmap;
}
/*****************************************************************************/
void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
{
CommonDeskSave(g_DS, g_BS, offset, x, y, cx, cy, 0);
}
/*****************************************************************************/
void ui_rect(int x, int y, int cx, int cy, int colour)
{
SetColorx(&g_Color1, colour);
g_P1->fillRect(x, y, cx, cy, QBrush(g_Color1));
g_P2->fillRect(x, y, cx, cy, QBrush(g_Color1));
}
/*****************************************************************************/
void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
int srcx, int srcy)
{
SetOpCode(opcode);
bitBltClip(g_MW, g_BS, x, y, NULL, srcx, srcy, cx, cy, Qt::CopyROP, true);
ResetOpCode(opcode);
}
/*****************************************************************************/
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
BRUSH* brush, int bgcolour, int fgcolour)
{
QBitmap* Bitmap;
QBrush* Brush;
uint8 ipattern[8], i;
SetOpCode(opcode);
switch (brush->style)
{
case 0:
SetColorx(&g_Color1, fgcolour);
g_P2->fillRect(x, y, cx, cy, QBrush(g_Color1));
break;
case 3:
SetColorx(&g_Color1, fgcolour);
SetColorx(&g_Color2, bgcolour);
for (i = 0; i != 8; i++)
{
ipattern[7 - i] = ~brush->pattern[i];
}
Bitmap = new QBitmap(8, 8, ipattern);
Brush = new QBrush(g_Color1, *Bitmap);
g_P2->setBackgroundMode(Qt::OpaqueMode);
g_P2->setBrushOrigin(brush->xorigin, brush->yorigin);
g_P2->setBackgroundColor(g_Color2);
g_P2->fillRect(x, y, cx, cy, *Brush);
delete Brush;
delete Bitmap;
g_P2->setBackgroundMode(Qt::TransparentMode);
g_P2->setBrushOrigin(0, 0);
break;
}
ResetOpCode(opcode);
bitBltClip(g_MW, NULL, x, y, g_BS, x, y, cx, cy, Qt::CopyROP, true);
}
/*****************************************************************************/
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
{
SetOpCode(opcode);
g_P1->fillRect(x, y, cx, cy, QBrush(QColor("black")));
g_P2->fillRect(x, y, cx, cy, QBrush(QColor("black")));
ResetOpCode(opcode);
}
/*****************************************************************************/
void ui_move_pointer(int x, int y)
{
}
/*****************************************************************************/
void ui_set_null_cursor(void)
{
g_MW->setCursor(10); // Qt::BlankCursor
}
/*****************************************************************************/
void ui_paint_bitmap(int x, int y, int cx, int cy,
int width, int height, uint8* data)
{
QImage * Image = NULL;
QPixmap * Pixmap;
uint32 * d = NULL;
uint16 * s;
int i;
switch (g_server_depth)
{
case 8:
Image = new QImage(data, width, height, 8, (QRgb*)&g_CM->RGBColors,
g_CM->NumColors, QImage::IgnoreEndian);
break;
case 15:
d = (uint32*)malloc(width * height * 4);
s = (uint16*)data;
for (i = 0; i < width * height; i++)
{
d[i] = Color15to32(s[i]);
}
Image = new QImage((uint8*)d, width, height, 32, NULL,
0, QImage::IgnoreEndian);
break;
case 16:
d = (uint32*)malloc(width * height * 4);
s = (uint16*)data;
for (i = 0; i < width * height; i++)
{
d[i] = Color16to32(s[i]);
}
Image = new QImage((uint8*)d, width, height, 32, NULL,
0, QImage::IgnoreEndian);
break;
case 24:
d = (uint32*)malloc(width * height * 4);
memset(d, 0, width * height * 4);
for (i = 0; i < width * height; i++)
{
memcpy(d + i, data + i * 3, 3);
}
Image = new QImage((uint8*)d, width, height, 32, NULL,
0, QImage::IgnoreEndian);
break;
}
if (Image == NULL)
{
return;
}
Pixmap = new QPixmap();
Pixmap->convertFromImage(*Image);
g_P1->drawPixmap(x, y, *Pixmap, 0, 0, cx, cy);
g_P2->drawPixmap(x, y, *Pixmap, 0, 0, cx, cy);
delete Image;
delete Pixmap;
if (d != NULL)
{
free(d);
}
}
//******************************************************************************
int Is24On(uint8* Data, int X, int Y)
{
uint8 R, G, B;
int Start;
Start = Y * 32 * 3 + X * 3;
R = Data[Start];
G = Data[Start + 1];
B = Data[Start + 2];
return !((R == 0) && (G == 0) && (B == 0));
}
//******************************************************************************
int Is1On(uint8* Data, int X, int Y)
{
int Start;
int Shift;
Start = (Y * 32) / 8 + X / 8;
Shift = X % 8;
return (Data[Start] & (0x80 >> Shift)) == 0;
}
//******************************************************************************
void Set1(uint8* Data, int X, int Y)
{
int Start;
int Shift;
Start = (Y * 32) / 8 + X / 8;
Shift = X % 8;
Data[Start] = Data[Start] | (0x80 >> Shift);
}
//******************************************************************************
void FlipOver(uint8* Data)
{
uint8 AData[128];
int Index;
memcpy(AData, Data, 128);
for (Index = 0; Index <= 31; Index++)
{
Data[127 - (Index * 4 + 3)] = AData[Index * 4];
Data[127 - (Index * 4 + 2)] = AData[Index * 4 + 1];
Data[127 - (Index * 4 + 1)] = AData[Index * 4 + 2];
Data[127 - Index * 4] = AData[Index * 4 + 3];
}
}
/*****************************************************************************/
void ui_set_cursor(HCURSOR cursor)
{
QCursor* Cursor;
Cursor = (QCursor*)cursor;
if (Cursor != NULL)
g_MW->setCursor(*Cursor);
}
/*****************************************************************************/
HCURSOR ui_create_cursor(unsigned int x, unsigned int y,
int width, int height,
uint8* andmask, uint8* xormask)
{
uint8 AData[128];
uint8 AMask[128];
QBitmap* DataBitmap;
QBitmap* MaskBitmap;
QCursor* Cursor;
int I1, I2, BOn, MOn;
if (width != 32 || height != 32)
{
return 0;
}
memset(AData, 0, 128);
memset(AMask, 0, 128);
for (I1 = 0; I1 <= 31; I1++)
{
for (I2 = 0; I2 <= 31; I2++)
{
MOn = Is24On(xormask, I1, I2);
BOn = Is1On(andmask, I1, I2);
if (BOn ^ MOn) // xor
{
Set1(AData, I1, I2);
if (!MOn)
{
Set1(AMask, I1, I2);
}
}
if (MOn)
{
Set1(AMask, I1, I2);
}
}
}
FlipOver(AData);
FlipOver(AMask);
DataBitmap = new QBitmap(32, 32, AData);
MaskBitmap = new QBitmap(32, 32, AMask);
Cursor = new QCursor(*DataBitmap, *MaskBitmap, x, y);
delete DataBitmap;
delete MaskBitmap;
return Cursor;
}
/*****************************************************************************/
uint16 ui_get_numlock_state(uint32 state)
{
return 0;
}
/*****************************************************************************/
uint32 read_keyboard_state(void)
{
return 0;
}
/*****************************************************************************/
void ui_resize_window(void)
{
}
/*****************************************************************************/
void ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints,
BRUSH * brush, int bgcolour, int fgcolour)
{
}
/*****************************************************************************/
/* todo, use qt function for this (QPainter::drawPolyline) */
void ui_polyline(uint8 opcode, POINT * points, int npoints, PEN * pen)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -