Exemple #1
0
void CScrollerView::draw(CDrawContext *dstcon)
{
  CPoint cp;
  CRect  cr;
  int x,y,w,h;
  int bar = 0;
  
	setDirty(false);
  if(mParam) bar += mParam->IsBipolar() ? 0: 1;

  w = mLedbmp->getWidth();
  h = mLedbmp->getHeight();

  switch(mType)
  {
  case kScTpVS:
    x = size.left + mHmLeft;
    y = size.top + mHmTop;
    cr = CRect(x,y, x+LEDBAR_WIDTH, y+LEDBAR_HEIGHT);
    cp = CPoint(bar*LEDBAR_WIDTH, (mLedbarValue/2)*LEDBAR_HEIGHT);
    mLedbmp->draw(dstcon, cr, cp);
    break;

  case kScTpHB:
    x = size.left + 1 + mHmLeft;
    y = size.top - 1 + mHmTop;
    cr = CRect(x,y, x+w, y+h);
    int v,b;

    if(bar)
    {
      v = 63-mLedbarValue;;
      for(int l=0; l<10; l++)
      {
        if(mFrame) 
			mFrame->getBackground()->draw(dstcon, cr, CPoint(x,y));
        b = v>7 ? v>16 ? 78-(v/12) : 7 : v<=0 ? 0 : v;
        b *= 36;
        mLedbmp->drawAlphaBlend(dstcon, cr, CPoint(0,0), b);
        cr.offset(w+1,0);
        v -= 6;
      }
    }
    else
    {
      if(mLedbarValue < 33)
      {
        v = 68-mLedbarValue;
        for(int l=0; l<10; l++)
        {
          if(mFrame) 
			  mFrame->getBackground()->draw(dstcon, cr, CPoint(x,y));
          b = l<4 ? 0 : v>7 ? v>16 ? 80-(v/6) : 7 : v<=0 ? 0 : v;
          b *= 36;
          mLedbmp->drawAlphaBlend(dstcon, cr, CPoint(0,0), b);
          cr.offset(w+1,0);
          v -= 6;
        }
      }
      else
      {
        v = mLedbarValue+3;
        cr.offset(9*(w+1),0);
        for(int l=0; l<10; l++)
        {
          if(mFrame) 
			  mFrame->getBackground()->draw(dstcon, cr, CPoint(x,y));
          b = l<4 ? 0 : v>7 ? v>16 ? 80-(v/6) : 7 : v<=0 ? 0 : v;
          b *= 36;
          mLedbmp->drawAlphaBlend(dstcon, cr, CPoint(0,0), b);
          cr.offset(-(w+1),0);
          v -= 6;
        }
      }
    }
    break;
  }

#if 0
  mHitmap->drawAlphaBlend(dstcon, size, cp(0,0));
#endif
}
Exemple #2
0
void CDisplayView::drawofl(void)
{
  CFrame *parentframe = getParent();
  if(!parentframe) return;

  CDrawContext *srccon;
  long dsplw,dsplh;

#if 1     // quantise near-grey to grey for transparent-draw
          // could be removed if q'ed bitmap is compiled to resource
  if(stConverted==false)
  {
    stConverted = true;

    srccon = new CDrawContext(parentframe,0);
    COffscreenContext *charcon;
    CColor pcl;
    int w,h;

    for(int nf=0; nf<kNumFtTypes; nf++)
    {
      dsplw = stFonts[nf].font->getWidth();
      dsplh = stFonts[nf].font->getHeight();
      charcon = new COffscreenContext(srccon,stFonts[nf].font,true);
      CPoint cp = CPoint(0,0);
      CRect  cr = CRect(0,0, dsplw,dsplh);
      stFonts[nf].font->draw(charcon, cr, cp );
      for(w=0; w<dsplw; w++)
      {
        for(h=0; h<dsplh; h++)
        {
          #define RNG 14

          pcl = charcon->getPoint(CPoint(w,h));
          if( pcl.red==128 && pcl.green==128 && pcl.blue==128 ) continue;
          if(pcl.red<(128-RNG)   || pcl.red>128+RNG)   continue;
          if(pcl.green<(128-RNG) || pcl.green>128+RNG) continue;
          if(pcl.blue<(128-RNG)  || pcl.blue>128+RNG)  continue;
          pcl.red=pcl.green=pcl.blue = 128;
          charcon->drawPoint(CPoint(w,h), pcl);
        }
      }
      delete charcon;
    }
    delete srccon;
  }
#endif

#if 0   // 0=PixelDrawing, else transparent drawing

  COffscreenContext *charcon;
  CPoint cp;
  CRect  cr;
  char c;
  dsplw = mDsplBmp->getWidth();
  dsplh = mDsplBmp->getHeight();
  CBitmap *bgnd = parentframe->getBackground();
  
  // get fresh background image
  cp = CPoint(size.left+mXAlign,size.top+mYAlign);
  cr = CRect(0,0,dsplw,dsplh);
  srccon = new CDrawContext(parentframe,0);
  COffscreenContext *dspcon = new COffscreenContext(srccon,mDsplBmp,true);
  bgnd->draw(dspcon, cr, cp);

  // get fresh font image
  cp = CPoint(0,0);
  cr = CRect(0,0, mFontBmp->getWidth(),mFontBmp->getHeight());
  charcon = new COffscreenContext(parentframe,mFontBmp->getWidth(),mFontBmp->getHeight());

  CColor scl,dcl;
  mFontBmp->draw(charcon, cr, cp );

  for(int i=0; i<mCharsfit && (c = mText[i]); i++)
  {
    int h,w,wd = i*mPaintWidth;
    int ws = (c - 33) * mCharWidth; // left position in font

    if(ws < 0)
    {
      continue;
    }

    for(w=0,ws+=mCharOfs; w<(mCharWidth-mCharOfs); w++,ws++,wd++)
    {
      for(h=0; h<dsplh; h++)
      {
        scl = charcon->getPoint(CPoint(ws,h));
        if( scl.red==128 && scl.green==128 && scl.blue==128 ) continue;
        dcl = dspcon->getPoint(CPoint(wd,h));
        dcl.red   = stClip[scl.red + (scl.red>>1) + dcl.red];
        dcl.green = stClip[scl.green + (scl.green>>1) + dcl.green];
        dcl.blue  = stClip[scl.blue + (scl.blue>>1) + dcl.blue];
        dspcon->drawPoint(CPoint(wd,h), dcl);
      }
    }
  }

  delete srccon;
  delete dspcon;
  delete charcon;

#else

  CPoint cp;
  CRect  cr;
  char c;
  dsplw = mDsplBmp->getWidth();
  dsplh = mDsplBmp->getHeight();

  // get fresh background image
  CBitmap *bgnd = parentframe->getBackground();
  cp = CPoint(size.left+mXAlign,size.top+mYAlign);
  cr = CRect(0,0,dsplw,dsplh);
  srccon = new CDrawContext(parentframe,0);
  COffscreenContext *dspcon = new COffscreenContext(srccon,mDsplBmp,true);
  bgnd->draw(dspcon, cr, cp);

  for(int i=0; i<mCharsfit && (c = mText[i]); i++)
  {
    int ws = (c - 33) * mCharWidth; // left position in font

    if(ws < 0)
    {
      continue;
    }

    CPoint dp = CPoint(ws+mCharOfs,0);
    CRect  dr = CRect(i*mPaintWidth,0, i*mPaintWidth+mCharWidth,dsplh);
    mFontBmp->drawTransparent(dspcon, dr, dp);
  }

  delete srccon;
  delete dspcon;

#endif

  m1stSight = false;
  setDirty(true);
}