Пример #1
0
HDC SWELL_CreateGfxContext(void *c)
{
  HDC__ *ctx=SWELL_GDP_CTX_NEW();

  
  return ctx;
}
Пример #2
0
HDC SWELL_CreateMemContext(HDC hdc, int w, int h)
{
  // we could use CGLayer here, but it's 10.4+ and seems to be slower than this
//  if (w&1) w++;
  void *buf=calloc(w*4,h);
  if (!buf) return 0;

  HDC__ *ctx=SWELL_GDP_CTX_NEW();
  ctx->ownedData=buf;
  
  SetTextColor(ctx,0);
  return ctx;
}
Пример #3
0
HDC SWELL_CreateMemContext(HDC hdc, int w, int h)
{
  LICE_MemBitmap * bm = new LICE_MemBitmap(w,h);
  if (!bm) return 0;

  HDC__ *ctx=SWELL_GDP_CTX_NEW();
  ctx->surface = bm;
  ctx->surface_offs.x=0;
  ctx->surface_offs.y=0;
  ctx->dirty_rect_valid=false;

  SetTextColor(ctx,0);
  return ctx;
}
Пример #4
0
HDC SWELL_internalGetWindowDC(HWND h, bool calcsize_on_first)
{
  if (!h || !IsWindowVisible(h)) return NULL;

  int xoffs=0,yoffs=0;
  int wndw = h->m_position.right-h->m_position.left;
  int wndh = h->m_position.bottom-h->m_position.top;

  HWND starth = h;
  while (h)
  {
    if ((calcsize_on_first || h!=starth)  && h->m_wndproc)
    {
      RECT r;
      GetWindowContentViewRect(h,&r);
      NCCALCSIZE_PARAMS p={{r,},};
      h->m_wndproc(h,WM_NCCALCSIZE,FALSE,(LPARAM)&p);
      RECT r2=r;
      r=p.rgrc[0];

      // todo: handle left edges and adjust postions/etc accordingly
      if (h==starth)  // if initial window, adjust rects to client area (this implies calcsize_on_first being false)
      {
        wndw=r.right-r.left;
        wndh=r.bottom-r.top;
      }
      yoffs += r.top-r2.top;
      xoffs += r.left-r2.left;
    } 
    if (h->m_backingstore) break; // found our target window

    xoffs += h->m_position.left;
    yoffs += h->m_position.top;
    h = h->m_parent;
  }
  if (!h) return NULL;

  swell_gdpLocalContext *p = (swell_gdpLocalContext*)SWELL_GDP_CTX_NEW();
  // todo: GDI defaults?
  p->ctx.surface=new LICE_SubBitmap(h->m_backingstore,xoffs,yoffs,wndw,wndh);
  if (xoffs<0) p->ctx.surface_offs.x = xoffs;
  if (yoffs<0) p->ctx.surface_offs.y = yoffs;
  p->clipr.left=xoffs;
  p->clipr.top=yoffs;
  p->clipr.right=xoffs + p->ctx.surface->getWidth();
  p->clipr.bottom=yoffs + p->ctx.surface->getHeight();

  return (HDC)p;
}