📄 qtewin.cpp
字号:
int start, shift;
if (bpp == 1)
{
width = (width + 7) / 8;
start = (y * width) + x / 8;
shift = x % 8;
return (data[start] & (0x80 >> shift)) != 0;
}
else if (bpp == 8)
return data[y * width + x] != 0;
else
return false;
}
/******************************************************************************/
void set_pixel_on(uint8 * data, int x, int y, int width, int bpp, uint8 pixel)
{
if (bpp == 8)
data[y * width + x] = pixel;
}
/******************************************************************************/
HGLYPH ui_create_glyph(int width, int height, uint8 * data)
{
int i, j;
uint8* glyph_data;
struct bitmap* the_glyph;
glyph_data = (uint8*)xmalloc(width * height);
the_glyph = (struct bitmap*)xmalloc(sizeof(struct bitmap));
the_glyph->w = width;
the_glyph->h = height;
the_glyph->data = glyph_data;
memset(glyph_data, 0, width * height);
for (i = 0; i < height; i++)
for (j = 0; j < width; j++)
if (is_pixel_on(data, j, i, width, 1))
set_pixel_on(glyph_data, j, i, width, 8, 255);
return the_glyph;
}
/******************************************************************************/
void ui_destroy_glyph(HGLYPH glyph)
{
struct bitmap* the_glyph;
the_glyph = (struct bitmap*)glyph;
if (the_glyph != NULL)
{
if (the_glyph->data != NULL)
xfree(the_glyph->data);
xfree(the_glyph);
}
}
/******************************************************************************/
HCURSOR ui_create_cursor(uint32 x, uint32 y,
int width, int height,
uint8 * andmask, uint8 * xormask)
{
return (void*)1;
}
/******************************************************************************/
void ui_set_cursor(HCURSOR /*cursor*/)
{
}
/*****************************************************************************/
uint16 ui_get_numlock_state(uint32 state)
{
return 0;
}
/*****************************************************************************/
unsigned int 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)
{
int i, x, y, dx, dy;
if (npoints > 0)
{
x = points[0].x;
y = points[0].y;
for (i = 1; i < npoints; i++)
{
dx = points[i].x;
dy = points[i].y;
ui_line(opcode, x, y, x + dx, y + dy, pen);
x = x + dx;
y = y + dy;
}
}
}
/*****************************************************************************/
void ui_ellipse(uint8 opcode, uint8 fillmode,
int x, int y, int cx, int cy,
BRUSH * brush, int bgcolour, int fgcolour)
{
}
/******************************************************************************/
void ui_destroy_cursor(HCURSOR /*cursor*/)
{
}
/******************************************************************************/
HCOLOURMAP ui_create_colourmap(COLOURMAP * colours)
{
int i;
int x;
uint8 r, g, b;
i = 0;
while (i < colours->ncolours && i < 256)
{
r = colours->colours[i].red;
g = colours->colours[i].green;
b = colours->colours[i].blue;
x = (r << 16) | (g << 8) | b;
g_CM->RGBColors[i] = x;
i++;
}
g_CM->NumColors = colours->ncolours;
return g_CM;
}
/******************************************************************************/
void ui_set_colourmap(HCOLOURMAP map)
{
}
/******************************************************************************/
void ui_destroy_colourmap(HCOLOURMAP map)
{
}
/******************************************************************************/
void ui_begin_update(void)
{
}
/******************************************************************************/
void ui_end_update(void)
{
}
/******************************************************************************/
void ui_set_clip(int x, int y, int cx, int cy)
{
g_clipx = x;
g_clipy = y;
g_clipcx = cx;
g_clipcy = cy;
}
/******************************************************************************/
void ui_reset_clip(void)
{
g_clipx = 0;
g_clipy = 0;
g_clipcx = g_width;
g_clipcy = g_height;
}
/******************************************************************************/
void ui_bell(void)
{
g_App->beep();
}
/******************************************************************************/
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
{
int i, j;
if (opcode == 0x0) /* black */
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
set_pixel(x + j, y + i, 0, 0xc);
}
else if (opcode == 0xf) /* white */
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
set_pixel(x + j, y + i, 0xffffff, 0xc);
}
else
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode);
}
redraw(x, y, cx, cy);
}
/******************************************************************************/
// does not repaint
void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc)
{
int i, j;
if (x + cx > g_width)
cx = g_width - x;
if (y + cy > g_height)
cy = g_height - y;
#ifdef QT_OPTI
if (opcode == 0xc) /* optimize */
{
if (WarpCoords(&x, &y, &cx, &cy, 0, 0))
{
if (g_server_bpp == 8)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
SETPIXEL8(g_BS, x + j, y + i, g_width, colour);
}
else if (g_server_bpp == 16)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
SETPIXEL16(g_BS, x + j, y + i, g_width, colour);
}
else if (g_server_bpp == 24)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
SETPIXEL32(g_BS, x + j, y + i, g_width, colour);
}
}
}
else
#endif
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
set_pixel(x + j, y + i, colour, opcode);
}
}
/******************************************************************************/
void ui_rect(int x, int y, int cx, int cy, int colour)
{
fill_rect(x, y, cx, cy, colour);
redraw(x, y, cx, cy);
}
/******************************************************************************/
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
BRUSH * brush, int bgcolour, int fgcolour)
{
int i, j;
uint8 ipattern[8];
switch (brush->style)
{
case 0:
fill_rect(x, y, cx, cy, fgcolour, opcode);
break;
case 3:
for (i = 0; i < 8; i++)
ipattern[i] = ~brush->pattern[7 - i];
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8,
(y + i + brush->yorigin) % 8, 8, 1))
set_pixel(x + j, y + i, fgcolour, opcode);
else
set_pixel(x + j, y + i, bgcolour, opcode);
break;
}
redraw(x, y, cx, cy);
}
/******************************************************************************/
void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
int srcx, int srcy)
{
int i, j, pixel;
uint8 * temp;
temp = (uint8*)xmalloc(cx * cy * 4);
#ifdef QT_OPTI
if (opcode == 0xc)
{
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy))
{
if (g_server_bpp == 8)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL8(g_BS, srcx + j, srcy + i, g_width);
SETPIXEL8(temp, j, i, cx, pixel);
}
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL8(temp, j, i, cx);
SETPIXEL8(g_BS, x + j, y + i, g_width, pixel);
}
}
else if (g_server_bpp == 16)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL16(g_BS, srcx + j, srcy + i, g_width);
SETPIXEL16(temp, j, i, cx, pixel);
}
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL16(temp, j, i, cx);
SETPIXEL16(g_BS, x + j, y + i, g_width, pixel);
}
}
else if (g_server_bpp == 24)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL32(g_BS, srcx + j, srcy + i, g_width);
SETPIXEL32(temp, j, i, cx, pixel);
}
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL32(temp, j, i, cx);
SETPIXEL32(g_BS, x + j, y + i, g_width, pixel);
}
}
}
}
else
#endif
{
if (g_server_bpp == 8)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
temp[i * cx + j] = get_pixel(srcx + j, srcy + i);
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
set_pixel(x + j, y + i, temp[i * cx + j], opcode);
}
else if (g_server_bpp == 16)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = get_pixel(srcx + j, srcy + i);
SETPIXEL16(temp, j, i, cx, pixel);
}
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
pixel = GETPIXEL16(temp, j, i, cx);
set_pixel(x + j, y + i, pixel, opcode);
}
}
else if (g_server_bpp == 24)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
*(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i);
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode);
}
}
xfree(temp);
redraw(x, y, cx, cy);
}
/******************************************************************************/
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
HBITMAP src, int srcx, int srcy)
{
int i, j, p;
struct bitmap * the_bitmap;
the_bitmap = (struct bitmap*)src;
if (the_bitmap == NULL)
return;
#ifdef QT_OPTI
if (opcode == 0xc) /* optimize */
{
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy))
{
if (g_server_bpp == 8)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
p = GETPIXEL8(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
SETPIXEL8(g_BS, x + j, y + i, g_width, p);
}
}
else if (g_server_bpp == 16)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
p = GETPIXEL16(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
SETPIXEL16(g_BS, x + j, y + i, g_width, p);
}
}
else if (g_server_bpp == 24)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
{
p = GETPIXEL32(the_bitmap->data, srcx + j, srcy + i, the_bitmap->w);
SETPIXEL32(g_BS, x + j, y + i, g_width, p);
}
}
}
}
else
#endif
{
if (g_server_bpp == 8)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
set_pixel(x + j, y + i,
the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)],
opcode);
}
else if (g_server_bpp == 16)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
set_pixel(x + j, y + i,
*(((uint16*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),
opcode);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -