qtewin.cpp.org

来自「远程桌面登陆软件 用rdesktop 但不基于Xwindows 可基于(nano」· ORG 代码 · 共 2,378 行 · 第 1/5 页

ORG
2,378
字号
  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 repaintvoid 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);    }    else if (g_server_bpp == 24)    {      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,                      *(((uint32*)the_bitmap->data) + ((i + srcy) * the_bitmap->w + (j + srcx))),                      opcode);    }  }  redraw(x, y, cx, cy);}/******************************************************************************/// not usedvoid ui_triblt(uint8 opcode, int x, int y, int cx, int cy,               HBITMAP src, int srcx, int srcy, BRUSH * brush,               int bgcolour, int fgcolour){}/******************************************************************************//* Bresenham's line drawing algorithm */void ui_line(uint8 opcode, int startx, int starty, int endx,             int endy, PEN * pen){  int dx, dy, incx, incy, dpr, dpru, p, left, top, right, bottom;  if (startx > endx)  {    dx = startx - endx;    incx = -1;    left = endx;    right = startx;  }  else  {    dx = endx - startx;    incx = 1;    left = startx;    right = endx;  }  if (starty > endy)  {    dy = starty - endy;    incy = -1;    top = endy;    bottom = starty;  }  else  {    dy = endy - starty;    incy = 1;    top = starty;    bottom = endy;  }  if (dx >= dy)  {    dpr = dy << 1;    dpru = dpr - (dx << 1);    p = dpr - dx;    for (; dx >= 0; dx--)    {      set_pixel(startx, starty, pen->colour, opcode);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?