当前位置: 首页>>代码示例>>C++>>正文


C++ CompString类代码示例

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


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

示例1: fileNameWithExtension

bool
PngScreen::fileToImage (CompString &name,
			CompSize   &size,
			int        &stride,
			void       *&data)
{
    bool          status = false;
    std::ifstream file;
    CompString    fileName = fileNameWithExtension (name);

    file.open (fileName.c_str ());
    if (file.is_open ())
    {
	status = readPng (file, size, data);
	file.close ();
    }

    if (status)
    {
	stride = size.width () * 4;
	return true;
    }

    return screen->fileToImage (name, size, stride, data);
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:25,代码来源:imgpng.cpp

示例2: readSvgToImage

bool
SvgScreen::fileToImage (CompString &path,
			CompSize   &size,
			int        &stride,
			void       *&data)
{
    CompString fileName = path;
    bool       status = false;
    int        len = fileName.length ();

    if (len < 4 || fileName.substr (len - 4, 4) != ".svg")
	fileName += ".svg";

    status = readSvgToImage (fileName.c_str (), size, data);

    if (status)
    {
	stride = size.width () * 4;
	return true;
    }

    status = screen->fileToImage (path, size, stride, data);

    return status;
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:25,代码来源:imgsvg.cpp

示例3: finiTexture

void
SvgWindow::setSvg (CompString    &data,
		   decor_point_t p[2])
{
    RsvgHandle *svg = NULL;
    GError     *error = NULL;

    if (!gWindow)
	return;

    svg = rsvg_handle_new_from_data ((guint8 *) data.c_str (),
				     data.length (), &error);

    if (source)
    {
	rsvg_handle_free (source->svg);
	source->svg = svg;
    }
    else
    {
	source = new SvgSource;
	if (source)
	    source->svg = svg;
    }

    if (source && source->svg)
    {
	source->p1 = p[0];
	source->p2 = p[1];

	source->svg = svg;

	gWindow->glDrawSetEnabled (this, true);
	rsvg_handle_get_dimensions (svg, &source->dimension);

	updateSvgContext ();
    }
    else
    {
	if (svg)
	    rsvg_handle_free (svg);

	if (source)
	{
	    delete source;
	    source = NULL;
	}

	if (context)
	{
	    finiTexture (context->texture[0]);
	    delete context;
	    context = NULL;
	}

	gWindow->glDrawSetEnabled (this, false);
    }
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:58,代码来源:imgsvg.cpp

示例4:

CompString
PngScreen::fileNameWithExtension (CompString &path)
{
    unsigned int len = path.length ();

    if (len > 4 && path.substr (len - 4, 4) == ".png")
	return path;

    return path + ".png";
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:10,代码来源:imgpng.cpp

示例5: while

/*
 * Left trimming function
 */
CompString
FragmentParser::ltrim (const CompString &string)
{
    size_t pos = 0;
    while (!(pos >= string.size ()))
    {
	if (isspace (string.at (pos)))
	    pos++;
	else
	    break;
    }

    return string.substr (pos);
}
开发者ID:hedmo,项目名称:compiz-plugins-main,代码行数:17,代码来源:parser.cpp

示例6: TEXT_SCREEN

bool
CompText::renderWindowTitle (Window               window,
		             bool                 withViewportNumber,
		             const CompText::Attrib &attrib)
{
    CompString text;

    TEXT_SCREEN (screen);

    if (!ts)
	return false;

    if (withViewportNumber)
    {
	CompString title;
    	CompPoint  winViewport;
	CompSize   viewportSize;

	title = ts->getWindowName (window);
	if (!title.empty ())
	{
	    CompWindow *w;

	    w = screen->findWindow (window);
	    if (w)
	    {
		int viewport;

		winViewport  = w->defaultViewport ();
		viewportSize = screen->vpSize ();
		viewport = winViewport.y () * viewportSize.width () +
		           winViewport.x () + 1;
		text = compPrintf ("%s -[%d]-", title.c_str (), viewport);
	    }
	    else
	    {
		text = title;
	    }
	}
    }
    else
    {
	text = ts->getWindowName (window);
    }

    if (text.empty ())
	return false;

    return renderText (text, attrib);
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:50,代码来源:text.cpp

示例7: getTextProperty

CompString
PrivateTextScreen::getWindowName (Window id)
{
    CompString name;

    name = getUtf8Property (id, visibleNameAtom);

    if (name.empty ())
	name = getUtf8Property (id, wmNameAtom);

    if (name.empty ())
	name = getTextProperty (id, XA_WM_NAME);

    return name;
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:15,代码来源:text.cpp

示例8: get_format

CompString get_format (const CompString &fmt, Value::Ptr v)
{
    if (fmt == "%i" || fmt == "%d")
	return compPrintf(fmt.c_str(),
		(boost::shared_static_cast<TValue<int> >(v))->value());
    if (fmt == "%f")
	return compPrintf(fmt.c_str(),
		(boost::shared_static_cast<TValue<float> >(v))->value());
    if (fmt == "%s")
	return compPrintf(
		fmt.c_str(),
		(boost::shared_static_cast<TValue<std::string> >(v))->value().c_str());
    if (fmt == "%x")
	return compPrintf(fmt.c_str(),
		(boost::shared_static_cast<TValue<int> >(v))->value());

    return "not_reached";
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:18,代码来源:test-string-printf.cpp

示例9: CompString

/*
 * File reader function
 */
CompString
FragmentParser::programReadSource (const CompString &fname)
{
    std::ifstream fp;
    int length;
    char *buffer;
    CompString data, path, home = CompString (getenv ("HOME"));

    /* Try to open file fname as is */
    fp.open (fname.c_str ());

    /* If failed, try as user filter file (in ~/.compiz/data/filters) */
    if (!fp.is_open () && !home.empty ())
    {
	path = home + "/.compiz/data/filters/" + fname;
	fp.open (path.c_str ());
    }

    /* If failed again, try as system wide data file
     * (in PREFIX/share/compiz/filters) */
    if (!fp.is_open ())
    {
	path = CompString (DATADIR) + "/data/filters/" + fname;
	fp.open (path.c_str ());
    }

    /* If failed again & again, abort */
    if (!fp.is_open ())
    {
	return CompString ("");
    }

    /* get length of file: */
    fp.seekg (0, std::ios::end);
    length = fp.tellg ();
    length++;
    fp.seekg (0, std::ios::beg);

    /* allocate memory */
    buffer = new char [length];

    /* read data as a block: */
    fp.read (buffer, length - 1);
    buffer[length - 1] = '\0';
    fp.close ();

    data = buffer;

    delete[] buffer;

    return data;
}
开发者ID:hedmo,项目名称:compiz-plugins-main,代码行数:55,代码来源:parser.cpp

示例10: getCurrentWSName

void
WSNamesScreen::renderNameText ()
{
    CompText::Attrib attrib;
    CompString	     name;

    textData.clear ();

    name = getCurrentWSName ();

    if (name.empty ())
        return;

    /* 75% of the output device as maximum width */
    attrib.maxWidth  = screen->getCurrentOutputExtents ().width () * 3 / 4;
    attrib.maxHeight = 100;

    attrib.family = "Sans";
    attrib.size = optionGetTextFontSize ();

    attrib.color[0] = optionGetFontColorRed ();
    attrib.color[1] = optionGetFontColorGreen ();
    attrib.color[2] = optionGetFontColorBlue ();
    attrib.color[3] = optionGetFontColorAlpha ();

    attrib.flags = CompText::WithBackground | CompText::Ellipsized;
    if (optionGetBoldText ())
        attrib.flags |= CompText::StyleBold;

    attrib.bgHMargin = 15;
    attrib.bgVMargin = 15;
    attrib.bgColor[0] = optionGetBackColorRed ();
    attrib.bgColor[1] = optionGetBackColorGreen ();
    attrib.bgColor[2] = optionGetBackColorBlue ();
    attrib.bgColor[3] = optionGetBackColorAlpha ();

    textData.renderText (name, attrib);
}
开发者ID:pfreris,项目名称:compiz,代码行数:38,代码来源:workspacenames.cpp

示例11: compileShader

static bool compileShader (GLuint *shader, GLenum type, CompString &source)
{
    const GLchar *data;
    GLint         status;

    data = (GLchar *)source.c_str ();

    *shader = (*GL::createShader) (type);
    (*GL::shaderSource) (*shader, 1, &data, NULL);
    (*GL::compileShader) (*shader);

    (*GL::getShaderiv) (*shader, GL::COMPILE_STATUS, &status);
    return (status == GL_TRUE);
}
开发者ID:CannedFish,项目名称:deepin-compiz,代码行数:14,代码来源:program.cpp

示例12: programCleanName

/*
 * Load a source file and build a Compiz Fragment Function from it
 */
GLFragment::FunctionId
FragmentParser::loadFragmentProgram (const CompString &file,
				     CompString &name,
				     int target)
{
    CompString source;
    GLFragment::FunctionId handle;

    /* Clean fragment program name */
    programCleanName (name);
    /* Read the source file */
    source = programReadSource (file);
    if (source.empty ())
    {
	return 0;
    }

    /* Build the Compiz Fragment Program */
    handle = buildFragmentProgram (source,
				   name, target);

    return handle;
}
开发者ID:hedmo,项目名称:compiz-plugins-main,代码行数:26,代码来源:parser.cpp

示例13: getFirstArgument

/*
 * Add a new fragment offset to the offsets stack from an ADD op string
 */
FragmentParser::FragmentOffset *
FragmentParser::programAddOffsetFromAddOp (const CompString &source)
{
    FragmentOffset  offset;
    CompString  op;
    size_t	    pos = 0;
    CompString	    name;
    CompString	    offsetString;
    CompString	    temp;
    std::list <FragmentOffset>::iterator it = offsets.begin ();

    if (source.size () < 5)
	return NULL;

    op = source;
    pos += 3;
    name = getFirstArgument (op, pos);
    if (name.empty ())
	return NULL;

    temp = getFirstArgument (op, pos);

    /* If an offset with the same name is
     * already registered, skip this one */
    if ((!offsets.empty () &&
	 !programFindOffset (it, name).empty ()) ||
	 temp.empty ())
	return &(*it);

    /* Just use the end of the op as the offset */
    pos += 1;
    offsetString = ltrim (op.substr (pos));
    if (offsetString.empty ())
	return NULL;

    offset.name =  name;
    offset.offset = offsetString;

    offsets.push_back (offset);

    return &(offsets.back ());
}
开发者ID:hedmo,项目名称:compiz-plugins-main,代码行数:45,代码来源:parser.cpp

示例14: programParseSource

/*
 * Build a Compiz Fragment Function from a source string
 */
GLFragment::FunctionId
FragmentParser::buildFragmentProgram (CompString &source,
				      const CompString &name,
				      int target)
{
    GLFragment::FunctionData *data;
    int handle;
    /* Create the function data */
    data = new GLFragment::FunctionData ();
    if (!data)
	return 0;
    /* Parse the source and fill the function data */
    programParseSource (data, target, source);
    /* Create the function */
    handle = data->createFragmentFunction (name.c_str ());
    delete data;
    return handle;
}
开发者ID:hedmo,项目名称:compiz-plugins-main,代码行数:21,代码来源:parser.cpp

示例15:

bool
CompOption::stringToColor (CompString     color,
			   unsigned short *rgba)
{
    int c[4];

    if (sscanf (color.c_str (), "#%2x%2x%2x%2x",
		&c[0], &c[1], &c[2], &c[3]) == 4)
    {
	rgba[0] = c[0] << 8 | c[0];
	rgba[1] = c[1] << 8 | c[1];
	rgba[2] = c[2] << 8 | c[2];
	rgba[3] = c[3] << 8 | c[3];

	return true;
    }

    return false;
}
开发者ID:squarehimself,项目名称:XMoniz,代码行数:19,代码来源:option.cpp


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