Exemplo n.º 1
0
//
/// Resize the CelArray by re-allocating the bitmap(s) to the new size and copying
/// over.
//
bool
TCelArray::Resize(int newCount)
{
  // Can't resize--the bitmap is not ours
  //
  if (!ShouldDelete)
    return false;

  TBitmap* bitmap = new TBitmap(TScreenDC(), CSize.cx*newCount, CSize.cy*NRows);

  // Copy old bitmap if there is one
  //
  if (Bitmap) {
    TMemoryDC srcDC(*Bitmap);
    TMemoryDC dstDC(*bitmap);
    dstDC.BitBlt(TRect(0, 0, CSize.cx*NCels, CSize.cy*NRows), srcDC, TPoint(0));

    // Cleanup old bitmap
    //
    srcDC.RestoreBitmap();
    delete Bitmap;
  }

  // Update bitmap data member
  //
  Bitmap = bitmap;

  // Update total number of Cels
  //
  NCels = newCount;
  return true;
}
Exemplo n.º 2
0
//
/// Draws the cel at index onto the DC at position x and y.
//
bool
TCelArray::BitBlt(int index, TDC& dstDC, int x, int y, uint32 rop)
{
  TMemoryDC srcDC(*Bitmap);
  TRect cr = CelRect(index,-1);
  dstDC.BitBlt(x, y, cr.Width(), cr.Height(), srcDC, cr.left, cr.top, rop);
  return true;
}
Exemplo n.º 3
0
//
/// Draws the image of the cel onto the DC.
//
bool
TCelArray::StretchBlt(int index, TDC& dstDC, const TRect& dstRect, uint32 rop)
{
  TMemoryDC srcDC(*Bitmap);
  TRect cr = CelRect(index,-1);
  dstDC.StretchBlt(dstRect.left,dstRect.top, dstRect.Width(),dstRect.Height(),
                   srcDC, cr.left, cr.top, cr.Width(), cr.Height(), rop);
  return true;
}
Exemplo n.º 4
0
//
/// Draws the image of the cel onto the DC.
//
bool
TCelArray::BitBlt(int index, TDC& dstDC, int x, int y, int /*dx*/, int /*dy*/,
                  const TColor& /*bgClr*/, const TColor& /*fgClr*/)
{
  TMemoryDC srcDC(*Bitmap);
  TRect cr = CelRect(index,-1);
  dstDC.BitBlt(x, y, cr.Width(), cr.Height(), srcDC, cr.left, cr.top);
  return true;
}
Exemplo n.º 5
0
void CSimpleGUIPanel::SetBackgroundBitmap() {
    wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::SetBackgroundBitmap - Function Start"));

    CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple();

    wxASSERT(pSkinSimple);
    wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple));

    wxColour bgColor(*pSkinSimple->GetBackgroundImage()->GetBackgroundColor());
    SetBackgroundColour(bgColor);
    wxRect panelRect = GetRect();
    m_bmpBg = wxBitmap(panelRect.width, panelRect.height);
    wxMemoryDC dc(m_bmpBg);
    wxBrush bgBrush(bgColor);
    dc.SetBackground(bgBrush);
    dc.Clear();
#ifdef __WXMAC__
    // Work around an apparent bug in wxMemoryDC::Clear() in wxCarbon 2.9.4
    // TODO: remove this when the wxCarbon bug is fixed
    dc.SetBrush(bgBrush);
    wxPen bgPen(bgColor);
    dc.SetPen(bgPen);
    dc.DrawRectangle(panelRect);
#endif

    int srcX, srcY, destX, destY, h, w;
    wxBitmap* srcBmp = pSkinSimple->GetBackgroundImage()->GetBitmap();
    wxSize srcSize = srcBmp->GetSize();
    switch(pSkinSimple->GetBackgroundImage()->GetHorizontalAnchor()) {
    case BKGD_ANCHOR_HORIZ_LEFT:
    default:
        srcX = 0;
        destX = 0;
        break;
    case BKGD_ANCHOR_HORIZ_CENTER:
        if (panelRect.width < srcSize.GetWidth()) {
            srcX = (srcSize.GetWidth() - panelRect.width) / 2;
            destX = 0;
        } else {
            srcX = 0;
            destX = (panelRect.width - srcSize.GetWidth()) / 2;
        }
        break;
    case BKGD_ANCHOR_HORIZ_RIGHT:
        if (panelRect.width < srcSize.GetWidth()) {
            srcX = (srcSize.GetWidth() - panelRect.width);
            destX = 0;
        } else {
            srcX = 0;
            destX = (panelRect.width - srcSize.GetWidth());
        }
        break;
    }
    w = wxMin(panelRect.width, srcSize.GetWidth());

    switch(pSkinSimple->GetBackgroundImage()->GetVerticalAnchor()) {
    case BKGD_ANCHOR_VERT_TOP:
    default:
        srcY = 0;
        destY = 0;
        break;
    case BKGD_ANCHOR_VERT_CENTER:
        if (panelRect.height < srcSize.GetHeight()) {
            srcY = (srcSize.GetHeight() - panelRect.height) / 2;
            destY = 0;
        } else {
            srcY = 0;
            destY = (panelRect.height - srcSize.GetHeight()) / 2;
        }
        break;
    case BKGD_ANCHOR_VERT_BOTTOM:
        if (panelRect.height < srcSize.GetHeight()) {
            srcY = (srcSize.GetHeight() - panelRect.height);
            destY = 0;
        } else {
            srcY = 0;
            destY = (panelRect.height - srcSize.GetHeight());
        }
        break;
    }
    h = wxMin(panelRect.height, srcSize.GetHeight());

    wxMemoryDC srcDC(*srcBmp);
    dc.Blit(destX, destY, w, h, &srcDC, srcX, srcY, wxCOPY);

//    dc.DrawBitmap(*pSkinSimple->GetBackgroundImage()->GetBitmap(), 0, 0, false);

    wxLogTrace(wxT("Function Start/End"), wxT("CSimpleGUIPanel::SetBackgroundBitmap - Function End"));
}