コード例 #1
0
ファイル: MinimalString.hpp プロジェクト: hxdnshx/SolfiskMod
__inline
bool ToUTF8(MinimalStringT<char> &dest, LPCSTR source)
{
	MinimalStringT<wchar_t> unistr(dest.GetAllocator());
	if (!ToUCS2(unistr, source)) return false;

	int outLen = ::WideCharToMultiByte(
		CP_UTF8, 0,
		unistr, unistr.GetSize(),
		NULL, 0, NULL, NULL); 
	if (outLen == 0) return false;
	dest.Grow(outLen + 1);
	int convLen = ::WideCharToMultiByte(
		CP_UTF8, 0,
		unistr, unistr.GetSize(),
		dest, outLen, NULL, NULL); 
	if (outLen != convLen) return false;
	dest.GetRaw()[outLen] = 0;
	dest.Repair();
	return true;
}
コード例 #2
0
ファイル: c_locale.c プロジェクト: 3runo5ouza/rhodes
wchar_t *wcsstr( const wchar_t *_wc1, const wchar_t *_wc2 )
{ return (wchar_t *)unistr( (const unicode *)_wc1, (const unicode *)_wc2 ); }
コード例 #3
0
ファイル: string.hpp プロジェクト: akivajp/seraf
 unistr &append_utf8(const std::string &str) { return append(unistr(str)); }
コード例 #4
0
ファイル: TEWidget.cpp プロジェクト: descent/qtermwidget
void TEWidget::paintEvent( QPaintEvent* pe )
{
//{ static int cnt = 0; printf("paint %d\n",cnt++); }
  const QPixmap* pm = backgroundPixmap();
  QPainter paint;
  setUpdatesEnabled(FALSE);
  paint.begin( this );
  paint.setBackgroundMode( TransparentMode );
HCNT("paintEvent");
  qDebug("in TEWidget::paintEvent()");
  //sleep(2);

  // Note that the actual widget size can be slightly larger
  // than the image (the size is truncated towards the smaller
  // number of characters in `resizeEvent'. The paint rectangle
  // can thus be larger than the image, but less then the size
  // of one character.

  QRect rect = pe->rect().intersect(contentsRect());

  QPoint tL  = contentsRect().topLeft();
  int    tLx = tL.x();
  int    tLy = tL.y();

  int lux = min(columns-1, max(0,(rect.left()   - tLx - blX ) / font_w));
  int luy = min(lines-1,   max(0,(rect.top()    - tLy - bY  ) / font_h));
  int rlx = min(columns-1, max(0,(rect.right()  - tLx - blX ) / font_w));
  int rly = min(lines-1,   max(0,(rect.bottom() - tLy - bY  ) / font_h));

  /*
 printf("paintEvent: %d..%d, %d..%d (%d..%d, %d..%d)\n",lux,rlx,luy,rly,
  rect.left(), rect.right(), rect.top(), rect.bottom());
  */

  //  if (pm != NULL && color_table[image->b].transparent)
  //  erase(rect);
  // BL: I have no idea why we need this, and it breaks the refresh.

  QChar *disstrU = new QChar[columns];
  QFontMetrics fm(font());

  for (int y = luy; y <= rly; y++)
  {
    int draw_font_w=0;
  for (int x = lux; x <= rlx; x++)
  {
    int len = 1;
    disstrU[0] = fontMap(image[loc(x,y)].c);
    int cf = image[loc(x,y)].f;
    int cb = image[loc(x,y)].b;
    int cr = image[loc(x,y)].r;
    while (x+len <= rlx &&
           image[loc(x+len,y)].f == cf &&
           image[loc(x+len,y)].b == cb &&
           image[loc(x+len,y)].r == cr )
    {
      disstrU[len] = fontMap(image[loc(x+len,y)].c);
      len += 1;
    }
    QString unistr(disstrU,len);
/*
    qDebug("blX+tLx+font_w*x: %d", blX+tLx+font_w*x);
    qDebug("bY+tLy+font_h*y: %d", bY+tLy+font_h*y);
    qDebug("font_w*len: %d", font_w*len);
    qDebug("font_h: %d", font_h);
    qDebug("font_w: %d", font_w);
    qDebug("x: %d", x);
*/
    //drawAttrStr(paint, QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), unistr, image[loc(x,y)], pm != NULL, false);
    drawAttrStr(paint, QRect(blX+tLx+draw_font_w,bY+tLy+font_h*y,font_w*len/2,font_h), unistr, image[loc(x,y)], pm != NULL, false);
    draw_font_w+=fm.width(unistr);
    //sleep(2);
    x += len - 1;
  }
  }
  delete [] disstrU;
  drawFrame( &paint );
  paint.end();
  setUpdatesEnabled(TRUE);
}