• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WString的典型用法代码示例。如果您正苦于以下问题:C++ WString类的具体用法?C++ WString怎么用?C++ WString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: createEditor

WWidget *WItemDelegate::update(WWidget *widget, const WModelIndex& index,
			       WFlags<ViewItemRenderFlag> flags)
{
  bool editing = widget && widget->find("t") == 0;

  if (flags & RenderEditing) {
    if (!editing) {
      widget = createEditor(index, flags);
      WInteractWidget *iw = dynamic_cast<WInteractWidget *>(widget);
      if (iw) {
	// Disable drag & drop and selection behaviour
	iw->mouseWentDown().preventPropagation();
	iw->clicked().preventPropagation();
      }
    }
  } else {
    if (editing)
      widget = 0;
  }

  WidgetRef widgetRef(widget);

  bool isNew = false;

  if (!(flags & RenderEditing)) {
    if (!widgetRef.w) {
      isNew = true;
      IndexText *t = new IndexText(index);
      t->setObjectName("t");
      if (index.isValid() && !(index.flags() & ItemIsXHTMLText))
	t->setTextFormat(PlainText);
      t->setWordWrap(true);
      widgetRef.w = t;
    }

    if (!index.isValid())
      return widgetRef.w;

    bool haveCheckBox = false;

    boost::any checkedData = index.data(CheckStateRole);
    if (!checkedData.empty()) {
      haveCheckBox = true;
      CheckState state =
	(checkedData.type() == typeid(bool) ?
	   (boost::any_cast<bool>(checkedData) ? Checked : Unchecked)
	   : (checkedData.type() == typeid(CheckState) ?
	      boost::any_cast<CheckState>(checkedData) : Unchecked));
      IndexCheckBox *icb =
        checkBox(widgetRef, index, true, index.flags() & ItemIsTristate);
      icb->setCheckState(state);
      icb->setEnabled(index.flags() & ItemIsUserCheckable);
    } else if (!isNew)
      delete checkBox(widgetRef, index, false);

    boost::any linkData = index.data(LinkRole);
    if (!linkData.empty()) {
      WLink link = boost::any_cast<WLink>(linkData);
      IndexAnchor *a = anchorWidget(widgetRef, index);
      a->setLink(link);
      if (link.type() == WLink::Resource)
	a->setTarget(TargetNewWindow);
    }

    IndexText *t = textWidget(widgetRef, index);

    WString label = asString(index.data(), textFormat_);
    if (label.empty() && haveCheckBox)
      label = WString::fromUTF8(" ");
    t->setText(label);

    std::string iconUrl = asString(index.data(DecorationRole)).toUTF8();
    if (!iconUrl.empty()) {
      iconWidget(widgetRef, index, true)->setImageLink(WLink(iconUrl));
    } else if (!isNew)
      delete iconWidget(widgetRef, index, false);
  }

  if (index.flags() & ItemHasDeferredTooltip){
    widgetRef.w->setDeferredToolTip(true, (index.flags() & ItemIsXHTMLText) ?
                                      XHTMLText : PlainText);
  } else {
  WString tooltip = asString(index.data(ToolTipRole));
  if (!tooltip.empty() || !isNew)
    widgetRef.w->setToolTip(tooltip,
			    (index.flags() & ItemIsXHTMLText) ? 
			    XHTMLText : PlainText);
  }

  WT_USTRING sc = asString(index.data(StyleClassRole));

  if (flags & RenderSelected)
    sc += WT_USTRING::fromUTF8
      (" " + WApplication::instance()->theme()->activeClass());

  if (flags & RenderEditing)
    sc += WT_USTRING::fromUTF8(" Wt-delegate-edit");

  widgetRef.w->setStyleClass(sc);

//.........这里部分代码省略.........
开发者ID:Brasil,项目名称:wt,代码行数:101,代码来源:WItemDelegate.C


示例2: dbload

void dbload()
{
    // If the file doesn't exist, there is no DB to load
    if(!FileExists(dbpath))
        return;

    dprintf("Loading database...");
    DWORD ticks = GetTickCount();

    // Multi-byte (UTF8) file path converted to UTF16
    WString databasePathW = StringUtils::Utf8ToUtf16(dbpath);

    // Decompress the file if compression was enabled
    bool useCompression = !settingboolget("Engine", "DisableCompression");
    LZ4_STATUS lzmaStatus = LZ4_INVALID_ARCHIVE;
    {
        lzmaStatus = LZ4_decompress_fileW(databasePathW.c_str(), databasePathW.c_str());

        // Check return code
        if(useCompression && lzmaStatus != LZ4_SUCCESS && lzmaStatus != LZ4_INVALID_ARCHIVE)
        {
            dputs("\nInvalid database file!");
            return;
        }
    }

    // Open the file for reading by the JSON parser
    FILE* jsonFile = nullptr;
    long jsonFileSize = 0;

    if(_wfopen_s(&jsonFile, databasePathW.c_str(), L"rb"))
    {
        dputs("\nFailed to open database file!");
        return;
    }

    // Get the current file size
    fseek(jsonFile, 0, SEEK_END);
    jsonFileSize = ftell(jsonFile);
    fseek(jsonFile, 0, SEEK_SET);

    // Verify that the file size is greater than 0.
    // This corrects a bug when a file exists, but there is no data inside.
    JSON root = nullptr;

    if(jsonFileSize > 0)
        root = json_loadf(jsonFile, 0, 0);

    // Release the file handle and re-compress
    fclose(jsonFile);

    if(lzmaStatus != LZ4_INVALID_ARCHIVE && useCompression)
        LZ4_compress_fileW(databasePathW.c_str(), databasePathW.c_str());

    // Validate JSON load status
    if(!root)
    {
        dputs("\nInvalid database file (JSON)!");
        return;
    }

    // Finally load all structures
    CommentCacheLoad(root);
    LabelCacheLoad(root);
    BookmarkCacheLoad(root);
    FunctionCacheLoad(root);
    LoopCacheLoad(root);
    BpCacheLoad(root);

    // Free root
    json_decref(root);
    dprintf("%ums\n", GetTickCount() - ticks);
}
开发者ID:SamirMahmudzade,项目名称:x64dbg,代码行数:73,代码来源:addrinfo.cpp


示例3: EncodeHttpHeaderField

std::string EncodeHttpHeaderField(const std::string &fieldname,
                                  const WString &fieldValue)
{
  // This implements RFC 5987
  return fieldname + "*=UTF-8''" + urlEncode(fieldValue.toUTF8());
}
开发者ID:NovaWova,项目名称:wt,代码行数:6,代码来源:WebUtils.C


示例4: getFullPath

    //-----------------------------------------------------------------------
	Ogre::DataStreamPtr UnicodeFileSystemArchive::open(const String& _filename, bool _readOnly) const
    {
		WString wfullpath = getFullPath(_filename);

		// Use filesystem to determine size 
		// (quicker than streaming to the end and back)
		struct _stat tagStat;
		int ret = _wstat(wfullpath.c_str(), &tagStat);
		if(ret != 0)
		{
			GOTHOGRE_EXCEPT(_filename << " - Problem getting file size"
				<< " (archive " << getName() << ").");
		}

		// Always open in binary mode
		// Also, always include reading
		std::ios::openmode mode = std::ios::in | std::ios::binary;
		std::istream* baseStream = 0;
		std::ifstream* roStream = 0;
		std::fstream* rwStream = 0;

		if (_readOnly)
		{
			roStream = OGRE_NEW_T(std::ifstream, MEMCATEGORY_GENERAL)();
			roStream->open(wfullpath.c_str(), mode);
			baseStream = roStream;
		}
		else
		{
			if (isReadOnly())
			{
				GOTHOGRE_EXCEPT(_filename << " - Cannot open a file for writing in"
					<< " read-only archive " << getName() << ".");
			}
			mode |= std::ios::out;
			rwStream = OGRE_NEW_T(std::fstream, MEMCATEGORY_GENERAL)();
			rwStream->open(wfullpath.c_str(), mode);
			baseStream = rwStream;
		}

		// Should check ensure open succeeded, in case fail for some reason.
		if (baseStream->fail())
		{
			OGRE_DELETE_T(roStream, basic_ifstream, MEMCATEGORY_GENERAL);
			OGRE_DELETE_T(rwStream, basic_fstream, MEMCATEGORY_GENERAL);
			GOTHOGRE_EXCEPT(_filename << " - Cannot open file in"
				<< " archive " << getName() << ".");
		}

		GOTHOGRE_INFO(_filename << " - " << (_readOnly ? "Loading from" : "Saving to")
			<< " archive " << getName() << ".");

		/// Construct return stream, tell it to delete on destroy
		FileStreamDataStream* stream = 0;
		if (rwStream)
		{
			// use the writeable stream 
			stream = OGRE_NEW FileStreamDataStream(_filename,
				rwStream, tagStat.st_size, true);
		}
		else
		{
			// read-only stream
			stream = OGRE_NEW FileStreamDataStream(_filename,
				roStream, tagStat.st_size, true);
		}
		return DataStreamPtr(stream);
    }
开发者ID:raduetsya,项目名称:GothOgre,代码行数:69,代码来源:WinUnicodeFileSystem.cpp


示例5: Write

	void Console::Write(const WString& string)
	{
		DWORD count = 0;
		WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), string.Buffer(), (int)string.Length(), &count, 0);
	}
开发者ID:Vonng,项目名称:Algorithm,代码行数:5,代码来源:Console.cpp


示例6: TextUnicode

void Draw::DrawText(int x, int y, const String& text, Font font, Color ink, const int *dx)
{
	WString h = TextUnicode(text, text.GetLength(), CHARSET_DEFAULT, font);
	DrawText(x, y, h, font, ink, h.GetLength(), dx);
}
开发者ID:koz4k,项目名称:soccer,代码行数:5,代码来源:DrawText.cpp


示例7: GetSelection

void   LineEdit::Paint0(Draw& w) {
	int sell, selh;
	GetSelection(sell, selh);
	if(!IsEnabled())
		sell = selh = 0;
	Size sz = GetSize();
	Size fsz = GetFontSize();
	Point sc = sb;
	int ll = min(line.GetCount(), sz.cy / fsz.cy + sc.y + 1);
	int  y = 0;
	cpos = GetPos(sc.y);
	cline = sc.y;
	sell -= cpos;
	selh -= cpos;
	int pos = cpos;
	Vector<int> dx, dx2;
	int fascent = font.Info().GetAscent();
	for(int i = sc.y; i < ll; i++) {
		WString tx = line[i];
		int len = tx.GetLength();
		if(w.IsPainting(0, y, sz.cx, fsz.cy)) {
			Highlight ih;
			ih.ink = color[IsShowEnabled() ? INK_NORMAL : INK_DISABLED];
			ih.paper = color[IsReadOnly() || !IsShowEnabled() ? PAPER_READONLY : PAPER_NORMAL];
			if(nobg)
				ih.paper = Null;
			ih.font = font;
			ih.chr = 0;
			Vector<Highlight> hl;
			hl.SetCount(len + 1, ih);
			for(int q = 0; q < tx.GetCount(); q++)
				hl[q].chr = tx[q];
			HighlightLine(i, hl, pos);
			int ln = hl.GetCount() - 1;
			int l = max(sell, 0);
			int h = selh > len ? len : selh;
			if(l < h)
				for(int i = l; i < h; i++) {
					hl[i].paper = color[PAPER_SELECTED];
					hl[i].ink = color[INK_SELECTED];
				}
			if(sell <= len && selh > len)
				for(int i = len; i < hl.GetCount(); i++) {
					hl[i].paper = color[PAPER_SELECTED];
					hl[i].ink = color[INK_SELECTED];
				}
			Buffer<wchar> txt(ln);
			for(int i = 0; i < ln; i++)
				txt[i] = hl[i].chr;
			for(int pass = 0; pass < 2; pass++) {
				int gp = 0;
				int scx = fsz.cx * sc.x;
				if(ln >= 0) {
					int q = 0;
					while(q < ln) {
						Highlight& h = hl[q];
						if(txt[q] == '\t') {
							int ngp = (gp + tabsize) / tabsize * tabsize;
							int l = ngp - gp;
							LLOG("Highlight -> tab[" << q << "] paper = " << h.paper);
							if(pass == 0) {
								w.DrawRect(gp * fsz.cx - scx, y, fsz.cx * l, fsz.cy, h.paper);
								if(showtabs && h.paper != SColorHighlight && q < tx.GetLength()) {
									Color c = Blend(SColorLight, SColorHighlight);
									w.DrawRect(gp * fsz.cx - scx + 2, y + fsz.cy / 2,
									           l * fsz.cx - 4, 1, c);
									w.DrawRect(ngp * fsz.cx - scx - 3, y + 3,
									           1, fsz.cy - 6, c);
								}
								if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + l)
									w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor);
							}
							q++;
							gp = ngp;
						}
						else
						if(txt[q] == ' ') {
						    LLOG("Highlight -> space[" << q << "] paper = " << h.paper);
						    if(pass == 0) {
						        w.DrawRect(gp * fsz.cx - scx, y, fsz.cx, fsz.cy, h.paper);
						        if(showspaces && h.paper != SColorHighlight && q < tx.GetLength()) {
						            Color c = Blend(SColorLight, SColorHighlight);
						            w.DrawRect(gp * fsz.cx - scx + fsz.cx / 2, y + fsz.cy / 2,
						                       2, 2, c);
						        }
						        if(bordercolumn > 0 && bordercolumn >= gp && bordercolumn < gp + 1)
						            w.DrawRect((bordercolumn - sc.x) * fsz.cx, y, 1, fsz.cy, bordercolor);
						    }
						    q++;
						    gp++;
						}
						else {
							bool cjk = IsCJKIdeograph(txt[q]);
							int p = q + 1;
							while(p < len && h == hl[p] && txt[p] != '\t' && txt[p] != ' ' && IsCJKIdeograph(txt[p]) == cjk && p - q < 128)
								p++;
							int l = p - q;
							int ll = cjk ? 2 * l : l;
							LLOG("Highlight -> paper[" << q << "] = " << h.paper);
							int x = gp * fsz.cx - scx;
//.........这里部分代码省略.........
开发者ID:pedia,项目名称:raidget,代码行数:101,代码来源:LineEdit.cpp


示例8: layoutText

void FontSupport::drawText(const WFont& font, const WRectF& rect,
			   WFlags<AlignmentFlag> flags, const WString& text)
{
  PANGO_LOCK;

  enabledFontFormats = enabledFontFormats_;

  std::string utf8 = text.toUTF8();

  std::vector<PangoGlyphString *> glyphs;
  int width;

  GList *items = layoutText(font, utf8, glyphs, width);

  AlignmentFlag hAlign = flags & AlignHorizontalMask;
  AlignmentFlag vAlign = flags & AlignVerticalMask;

  /* FIXME handle bidi ! */

  double x;
  switch (hAlign) {
  case AlignmentFlag::Left:
    x = rect.left();
    break;
  case AlignmentFlag::Right:
    x = rect.right() - pangoUnitsToDouble(width);
    break;
  case AlignmentFlag::Center:
    x = rect.center().x() - pangoUnitsToDouble(width/2);
    break;
  default:
    x = 0;
  }

  unsigned i = 0;
  for (GList *elem = items; elem; elem = elem->next) {
    PangoItem *item = (PangoItem *)elem->data;
    PangoAnalysis *analysis = &item->analysis;

    PangoGlyphString *gl = glyphs[i++];

    currentFont_ = analysis->font;

    /*
     * Note, we are actually ignoring the selected glyphs here, which
     * is a pitty and possibly wrong if the device does not make the
     * same selection !
     */
    WString s = WString::fromUTF8(utf8.substr(item->offset,
                                              item->length));

    device_->drawText(WRectF(x, rect.y(),
			     1000, rect.height()),
		      AlignmentFlag::Left | vAlign, TextFlag::SingleLine,
		      s, nullptr);

    WTextItem textItem = device_->measureText(s, -1, false);

    x += textItem.width();

    pango_item_free(item);
    pango_glyph_string_free(gl);
  }

  g_list_free(items);

  currentFont_ = nullptr;
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:68,代码来源:FontSupportPango.C


示例9: g_utf8_strlen

WTextItem FontSupport::measureText(const WFont& font, const WString& text,
				   double maxWidth, bool wordWrap)
{
  PANGO_LOCK;

  enabledFontFormats = enabledFontFormats_;

  /*
   * Note: accurate measuring on a bitmap requires that the transformation
   * is applied, because hinting may push chars to boundaries e.g. when
   * rotated (or scaled too?)
   */
  std::string utf8 = text.toUTF8();
  const char *s = utf8.c_str();

  if (wordWrap) {
    int utflen = g_utf8_strlen(s, -1);
    PangoLogAttr *attrs = new PangoLogAttr[utflen + 1];
    PangoLanguage *language = pango_language_from_string("en-US");

    pango_get_log_attrs(s, utf8.length(), -1, language, attrs, utflen + 1);

    double w = 0, nextW = -1;

    int current = 0;
    int measured = 0;
    int end = 0;

    bool maxWidthReached = false;

    for (int i = 0; i < utflen + 1; ++i) {
      if (i == utflen || attrs[i].is_line_break) {
	int cend = g_utf8_offset_to_pointer(s, end) - s;

	WTextItem ti
	  = measureText(font, WString::fromUTF8(utf8.substr(measured,
							    cend - measured)),
			-1, false);

	if (isEpsilonMore(w + ti.width(), maxWidth)) {
	  nextW = ti.width();
	  maxWidthReached = true;
	  break;
	} else {
	  measured = cend;
	  current = g_utf8_offset_to_pointer(s, i) - s;
	  w += ti.width();

	  if (i == utflen) {
	    w += measureText(font, WString::fromUTF8(utf8.substr(measured)),
			     -1, false).width();
	    measured = utf8.length();
	  }
	}
      }

      if (!attrs[i].is_white)
	end = i + 1;
    }

    delete[] attrs;

    if (maxWidthReached) {
      return WTextItem(WString::fromUTF8(utf8.substr(0, current)), w, nextW);
    } else {
      /*
       * For some reason, the sum of the individual widths is a bit less
       * (for longer stretches of text), so we re-measure it !
       */
      w = measureText(font, WString::fromUTF8(utf8.substr(0, measured)),
		      -1, false).width();
      return WTextItem(text, w);
    }
  } else {
    std::vector<PangoGlyphString *> glyphs;
    int width;

    GList *items = layoutText(font, utf8, glyphs, width);

    double w = pangoUnitsToDouble(width);

    for (unsigned i = 0; i < glyphs.size(); ++i)
      pango_glyph_string_free(glyphs[i]);

    g_list_foreach(items, (GFunc) pango_item_free, nullptr);
    g_list_free(items);

    return WTextItem(text, w);
  }
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:90,代码来源:FontSupportPango.C


示例10: drawText

void WPdfImage::drawText(const WRectF& rect, 
			 WFlags<AlignmentFlag> flags,
			 TextFlag textFlag,
			 const WString& text,
			 const WPointF *clipPoint)
{
  // FIXME: textFlag
  
  if (clipPoint && painter() && !painter()->clipPath().isEmpty()) {
    if (!painter()->clipPathTransform().map(painter()->clipPath())
	  .isPointInPath(painter()->worldTransform().map(*clipPoint)))
      return;
  }

  if (trueTypeFont_ && !trueTypeFonts_->busy())
    trueTypeFonts_->drawText(painter()->font(), rect, flags, text);
  else {
    HPDF_REAL left, top, right, bottom;
    HPDF_TextAlignment alignment = HPDF_TALIGN_LEFT;

    AlignmentFlag horizontalAlign = flags & AlignHorizontalMask;
    AlignmentFlag verticalAlign = flags & AlignVerticalMask;

    switch (horizontalAlign) {
    default:
      // should never happen
    case AlignmentFlag::Left:
      left = rect.left();
      right = left + 10000;
      alignment = HPDF_TALIGN_LEFT;
      break;
    case AlignmentFlag::Right:
      right = rect.right();
      left = right - 10000;
      alignment = HPDF_TALIGN_RIGHT;
      break;
    case AlignmentFlag::Center:
      {
	float center = rect.center().x();
	left = center - 5000;
	right = center + 5000;
	alignment = HPDF_TALIGN_CENTER;
	break;
      }
    }

    switch (verticalAlign) {
    default:
      // fall-through ; should never happen
    case AlignmentFlag::Top:
      top = rect.top(); break;
    case AlignmentFlag::Middle:
      // FIXME: use font metrics to center middle of ascent !
      top = rect.center().y() - 0.60 * fontSize_; break;
    case AlignmentFlag::Bottom:
      top = rect.bottom() - fontSize_; break;
    }

    bottom = top + fontSize_;

    if (trueTypeFonts_->busy())
      setChanged(PainterChangeFlag::Font);

    HPDF_Page_GSave(page_);

    // Undo the global inversion
    HPDF_Page_Concat(page_, 1, 0, 0, -1, 0, bottom);

    HPDF_Page_BeginText(page_);

    // Need to fill text using pen color
    const WColor& penColor = painter()->pen().color();
    HPDF_Page_SetRGBFill(page_,
			 penColor.red() / 255.,
			 penColor.green() / 255.,
			 penColor.blue() / 255.);

    std::string s = trueTypeFont_ ? text.toUTF8() : text.narrow();

    HPDF_Page_TextRect(page_, left, fontSize_, right, 0, s.c_str(),
		       alignment, nullptr);

    HPDF_Page_EndText(page_);

    HPDF_Page_GRestore(page_);
  }
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:87,代码来源:WPdfImage.C


示例11: UTF8ToWide

FILE *OpenRead(const char *inUtf8Name)
{
   WString wide = UTF8ToWide(inUtf8Name);
   return OpenRead( wide.c_str() );
}
开发者ID:madrazo,项目名称:nme,代码行数:5,代码来源:Utils.cpp


示例12: emitJobClickedOrSelected

///
/// Handle emitting result clicked or selected (they do the same thing except
/// for the signal so combined into one function)
///
void ResultsTable::emitJobClickedOrSelected(const WModelIndex& item, bool clicked)
{

    int modelRow = item.row();

    boost::any d = mSortFilterProxyModel->data(modelRow, 0, UserRole);
    boost::any d1 = mSortFilterProxyModel->data(modelRow, 0, UserRole + 1);
    boost::any d2 = mSortFilterProxyModel->data(modelRow, 0, UserRole + 2);
    boost::any d3 = mSortFilterProxyModel->data(modelRow, 0, UserRole + 3);
    boost::any d4 = mSortFilterProxyModel->data(modelRow, 1, DisplayRole);
    boost::any d5 = mSortFilterProxyModel->data(modelRow, 0, UserRole + 4);

    if (!d.empty() && !d1.empty() && !d2.empty())
    {
        WString clusterCommand = boost::any_cast<WString>(d);
        WString metaScript = boost::any_cast<WString>(d1);
        WString arguments = boost::any_cast<WString>(d2);

        WString jobID;
        if (!d3.empty())
        {
            jobID = boost::any_cast<WString>(d3);
        }

        WString user;
        if (!d4.empty())
        {
            user = boost::any_cast<WString>(d4);
        }

        WString project;
        if (!d5.empty())
        {
            project = boost::any_cast<WString>(d5);
        }

        if (clicked)
        {
            mResultClicked.emit(clusterCommand.toUTF8(), metaScript.toUTF8(), arguments.toUTF8(),
                                jobID.toUTF8(), user.toUTF8(), project.toUTF8());
        }
        else
        {
            mResultSelected.emit(clusterCommand.toUTF8(), metaScript.toUTF8(), arguments.toUTF8(),
                                jobID.toUTF8(), user.toUTF8(), project.toUTF8());
        }
    }

}
开发者ID:FNNDSC,项目名称:web,代码行数:53,代码来源:ResultsTable.cpp


示例13: debugInfo

void TreeNode::debugInfo( TreeRoot * root )
//-----------------------------------------
{
    WString boundLine;
    WString descendLine;
    char *  enabled;
    char *  placed;
    WString statLine;
    WString refLine;
    WString rootLine;

    TreeCoord   ox, oy;
    TreeRect rootRect;

    ox = _parent->getXOff();
    oy = _parent->getYOff();

    root->getBound( rootRect );

    rootLine.printf( "_rootNode = %s, bounding(%ld,%ld,%ld,%ld) ",
                     root->node()->name(), rootRect.x(), rootRect.y(),
                     rootRect.w(), rootRect.h() );
    boundLine.printf( "_bounding [%s] = (%ld,%ld,%ld,%ld), offset = (%ld,%ld) ",
                        (_flags.boundSet) ? "set" : "unset",
                        _bounding.x(), _bounding.y(),
                        _bounding.w(), _bounding.h(),
                        ox, oy );
    descendLine.printf( "_sibWidth = %ld, _descend = (%ld,%ld,%ld,%ld) ",
                        _sibWidth, _descend.x(), _descend.y(),
                        _descend.w(), _descend.h() );

    switch( _flags.enabled ) {
    case Hidden:
        enabled = "Hidden";
        break;
    default:
        enabled = "Visible";
        break;
    }

    switch( _flags.placed ) {
    case NotPlaced:
        placed = "NotPlaced";
        break;
    case PartiallyPlaced:
        placed = "PartiallyPlaced";
        break;
    case Arranging:
        placed = "Arranging";
        break;
    default:
        placed = "Placed";
    }
    statLine.printf( " enabled = %s, placed = %s, selected = %s, _level = %d\n",
                        enabled, placed, (_flags.selected) ? "true" : "false",
                        getLevel() );

    refLine.printf( "hasReference() = %s, isReference() = %s",
                    hasReference() ? "true" : "false",
                    isReference() ? "true" : "false" );

    WMessageDialog::messagef( _parent, MsgPlain, MsgOk, name(), "%s%s%s%s%s",
                            (const char *)rootLine, (const char *)boundLine,
                            (const char *)descendLine, (const char *)statLine,
                            (const char *)refLine );
}
开发者ID:ArmstrongJ,项目名称:open-watcom-v2,代码行数:66,代码来源:gtbase.cpp


示例14: wupper

	WString wupper(const WString& string)
	{
		WString result = string.Buffer();
		_wcsupr_s((wchar_t*)result.Buffer(), result.Length() + 1);
		return result;
	}
开发者ID:FlyingSwan999,项目名称:Vlpp,代码行数:6,代码来源:String.cpp


示例15: Rename

	bool Folder::Rename(const WString& newName)const
	{
		WString oldFileName = filePath_.GetFullPath();
		WString newFileName = (filePath_.GetFolder() / newName).GetFullPath();
		return MoveFile(oldFileName.Buffer(), newFileName.Buffer()) != 0;
	}
开发者ID:mazip1990,项目名称:FaceUI,代码行数:6,代码来源:FileSystem.cpp


示例16: drawText

void FontSupport::drawText(const WFont& font, const WRectF& rect,
			   const WTransform& transform, Bitmap& bitmap,
			   WFlags<AlignmentFlag> flags,
			   const WString& text)
{
  PANGO_LOCK;

  enabledFontFormats = enabledFontFormats_;

  PangoMatrix matrix;
  matrix.xx = transform.m11();
  matrix.xy = transform.m21();
  matrix.yx = transform.m12();
  matrix.yy = transform.m22();
  matrix.x0 = transform.dx();
  matrix.y0 = transform.dy();

  std::string utf8 = text.toUTF8();

  std::vector<PangoGlyphString *> glyphs;
  int width;

  pango_context_set_matrix(context_, &matrix);

  /*
   * Oh my god, somebody explain me why we need to do this...
   */
  WFont f = font;
  f.setSize(font.sizeLength().toPixels()
	    / pango_matrix_get_font_scale_factor(&matrix));

  GList *items = layoutText(f, utf8, glyphs, width);
  pango_context_set_matrix(context_, nullptr);

  AlignmentFlag hAlign = flags & AlignHorizontalMask;

  /* FIXME handle bidi ! */

  double x;
  switch (hAlign) {
  case AlignmentFlag::Left:
    x = rect.left();
    break;
  case AlignmentFlag::Right:
    x = rect.right() - pangoUnitsToDouble(width);
    break;
  case AlignmentFlag::Center:
    x = rect.center().x() - pangoUnitsToDouble(width/2);
    break;
  default:
    x = 0;
  }

  AlignmentFlag vAlign = flags & AlignVerticalMask;

  PangoFont *pangoFont = matchFont(font).pangoFont();
  PangoFontMetrics *metrics = pango_font_get_metrics(pangoFont, nullptr);

  double ascent
    = pangoUnitsToDouble(pango_font_metrics_get_ascent(metrics));
  double descent 
    = pangoUnitsToDouble(pango_font_metrics_get_descent(metrics));

  pango_font_metrics_unref(metrics);

  double baseline = ascent;
  double height = ascent + descent;

  double y;
  switch (vAlign) {
  case AlignmentFlag::Top:
    y = rect.top() + baseline;
    break;
  case AlignmentFlag::Middle:
    y = rect.center().y() - height / 2 + baseline;
    break;
  case AlignmentFlag::Bottom:
    y = rect.bottom() - height + baseline;
    break;
  default:
    y = 0;
  }

  FT_Bitmap bmp;
  bmp.buffer = bitmap.buffer();
  bmp.width = bitmap.width();
  bmp.rows = bitmap.height();
  bmp.pitch = bitmap.pitch();
  bmp.pixel_mode = FT_PIXEL_MODE_GRAY;
  bmp.num_grays = 16; // ???

  GList *elem;
  unsigned i = 0;

  for (elem = items; elem; elem = elem->next) {
    PangoItem *item = (PangoItem *)elem->data;
    PangoAnalysis *analysis = &item->analysis;

    PangoGlyphString *gl = glyphs[i++];

//.........这里部分代码省略.........
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:101,代码来源:FontSupportPango.C


示例17: DrawText

void Draw::DrawText(int x, int y, int angle, const WString& text, Font font,
                    Color ink, const int *dx)
{
	DrawText(x, y, angle, ~text, font, ink, text.GetLength(), dx);
}
开发者ID:koz4k,项目名称:soccer,代码行数:5,代码来源:DrawText.cpp


示例18: setWindowTitle

void WDialog::setWindowTitle(const WString& windowTitle)
{
  caption_->setText(WString::fromUTF8("<h3>" + windowTitle.toUTF8()
				      + "</h3>"));
}
开发者ID:NeilNienaber,项目名称:wt,代码行数:5,代码来源:WDialog.C


示例19: GetTextSize

Size GetTextSize(const WString& text, Font font)
{
	return GetTextSize(text, font, text.GetLength());
}
开发者ID:koz4k,项目名称:soccer,代码行数:4,代码来源:DrawText.cpp


示例20: encode

bool WTemplate::renderTemplateText(std::ostream& result, const WString& templateText)
{
  errorText_ = "";

  std::string text;
  if (encodeTemplateText_)
    text = encode(templateText.toUTF8());
  else
    text = templateText.toUTF8();

  std::size_t lastPos = 0;
  std::vector<WString> args;
  std::vector<std::string> conditions;
  int suppressing = 0;

  for (std::size_t pos = text.find('$'); pos != std::string::npos;
       pos = text.find('$', pos)) {

    if (!suppressing)
      result << text.substr(lastPos, pos - lastPos);

    lastPos = pos;

    if (pos + 1 < text.length()) {
      if (text[pos + 1] == '$') { // $$ -> $
	if (!suppressing)
	  result << '$';

	lastPos += 2;
      } else if (text[pos + 1] == '{') {
	std::size_t startName = pos + 2;
	std::size_t endName = text.find_first_of(" \r\n\t}", startName);

        args.clear();
        std::size_t endVar = parseArgs(text, endName, args);

        if (endVar == std::string::npos) {
          std::stringstream errorStream;
          errorStream << "variable syntax error near \"" << text.substr(pos)
                      << "\"";
          errorText_ = errorStream.str();
          LOG_ERROR(errorText_);
          return false;
        }

        std::string name = text.substr(startName, endName - startName);
	std::size_t nl = name.length();

	if (nl > 2 && name[0] == '<' && name[nl - 1] == '>') {
	  if (name[1] != '/') {
	    std::string cond = name.substr(1, nl - 2);
	    conditions.push_back(cond);
	    if (suppressing || !conditionValue(cond))
	      ++suppressing;
	  } else {
	    std::string cond = name.substr(2, nl - 3);
	    if (conditions.empty() || conditions.back() != cond) {
              std::stringstream errorStream;
              errorStream << "mismatching condition block end: " << cond;
              errorText_ = errorStream.str();
              LOG_ERROR(errorText_);
              return false;
	    }
	    conditions.pop_back();

	    if (suppressing)
	      --suppressing;
	  }
	} else {
	  if (!suppressing) {
	    std::size_t colonPos = name.find(':');

	    bool handled = false;
	    if (colonPos != std::string::npos) {
	      std::string fname = name.substr(0, colonPos);
	      std::string arg0 = name.substr(colonPos + 1);
	      args.insert(args.begin(), WString::fromUTF8(arg0));
	      if (resolveFunction(fname, args, result))
		handled = true;
	      else
		args.erase(args.begin());
	    }

	    if (!handled)
	      resolveString(name, args, result);
	  }
	}

	lastPos = endVar + 1;
      } else {
	if (!suppressing)
	  result << '$'; // $. -> $.
	lastPos += 1;
      }
    } else {
      if (!suppressing)
	result << '$'; // $ at end of template -> $
      lastPos += 1;
    }

//.........这里部分代码省略.........
开发者ID:dreamsxin,项目名称:WebWidgets,代码行数:101,代码来源:WTemplate.C



注:本文中的WString类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WStringAutoPtr类代码示例发布时间:2022-05-31
下一篇:
C++ WStrVec类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap