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


C++ WIDTH函数代码示例

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


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

示例1: readjust_columns

static void
readjust_columns(GntTree *tree)
{
	int i, col, total;
	int width;
#define WIDTH(i) (tree->columns[i].width_ratio ? tree->columns[i].width_ratio : tree->columns[i].width)
	gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL);
	if (!GNT_WIDGET_IS_FLAG_SET(GNT_WIDGET(tree), GNT_WIDGET_NO_BORDER))
		width -= 2;
	width -= 1;  /* Exclude the scrollbar from the calculation */
	for (i = 0, total = 0; i < tree->ncol ; i++) {
		if (tree->columns[i].flags & GNT_TREE_COLUMN_INVISIBLE)
			continue;
		if (tree->columns[i].flags & GNT_TREE_COLUMN_FIXED_SIZE)
			width -= WIDTH(i) + (tree->priv->lastvisible != i);
		else
			total += WIDTH(i) + (tree->priv->lastvisible != i);
	}

	if (total == 0)
		return;

	for (i = 0; i < tree->ncol; i++) {
		if (tree->columns[i].flags & GNT_TREE_COLUMN_INVISIBLE)
			continue;
		if (tree->columns[i].flags & GNT_TREE_COLUMN_FIXED_SIZE)
			col = WIDTH(i);
		else
			col = (WIDTH(i) * width) / total;
		gnt_tree_set_col_width(GNT_TREE(tree), i, col);
	}
}
开发者ID:crodjer,项目名称:pidgin_whiteboard,代码行数:32,代码来源:gnttree.c

示例2: utility_sntoull

/* Converts a substring to its unsigned long long integer representation
 * Returns -1 on error setting errno
 * Returns number of unconverted chars on success with numeric value stored in pdest
 * EINVAL: invalid args passed
 * Function may fail and set errno for same reasons as
 * utility_strndup(), strtoull() */
int
utility_sntoull(
        uint64_t *pdest,
        const char *s,
        size_t len
        )
{
char buf[WIDTH(*pdest)+1] = {0};
char *pend;
unsigned long long val;
int neg=0;
int zero=0;
const int radix = 10;

     errno = EINVAL;
    if(!s  || !len || !pdest || len >= WIDTH(*pdest))
        return util_eError;

    /* skip leading space */
    for(pend = (char*)s; (len && isspace(*pend)); ++pend)
        --len;

    /* leading positive sign is meaningless but valid */
    errno = ERANGE;
    if(!len)
        return util_eError;

    /* skip leading zeros and sign, we rely on side effects nasty */
    if( ('+' == *pend) || (neg=('-' == *pend)) || (zero=('0' == *pend)))
        for( ++pend, --len; (len && '0' == *pend); --len)
            ++pend;

    /* only zeros found so we discard any sign  */
    if(!len && !zero)
        return util_eError;

    else if(!len)
    {
        *pdest = 0;
        return util_eOk;
    }


    memcpy(buf,pend,len);
    buf[len] = '\0';

    /* need this to tell the difference
     * between error and conversion of zero, which we handle above */
    errno = 0;
    val = strtoull(buf,&pend,radix);
    /* different from succesful conversion of zero, or no digits converted*/
    if( (errno && !val) || (pend == buf)  ||
            ((ERANGE == errno) && (ULLONG_MAX == val) ))
        return util_eError;

    /* store result and return number of unconverted chars remaining */
    *pdest = val;
    return (((intptr_t)(pend - buf)) > INT_MAX) ?  INT_MAX :
        ((int)(pend - buf)) ;
}
开发者ID:jamal-fuma,项目名称:epic-food-frequency,代码行数:66,代码来源:Utility_lib.c

示例3: GetClientRect

//-------------------------------------------------------------------------
//  CmdProcessDoubleClick
//  processes command "change selection" from the playback window
//-------------------------------------------------------------------------
void CMultiSAP::CmdProcessDoubleClick( int xPos, int yPos)
{
    if( !m_pEffect || eEffectStagePlaying != m_pEffect->GetStage() )
    {
        return;
    }

    RECT rect;
    GetClientRect( m_hwndApp, &rect );

    RECT rectRT = m_movieList.GetDefaultTarget();

    // given xPos, yPos are in client coordinates of the window;
    // transform then to client coordinates of the render target and find the movie

    float xPosRT = (float)xPos / (float)(WIDTH(&rect)) * (float)(WIDTH(&rectRT));
    float yPosRT = (float)yPos / (float)(HEIGHT(&rect)) * (float)(HEIGHT(&rectRT));

    CMovie *pmovie = NULL;
    pmovie = m_movieList.GetMovieFromRTPoint( xPosRT, yPosRT);

    if( pmovie && pmovie->m_dwUserID != m_movieList.GetSelectedMovieID() )
    {
        m_pdwNextSelectedMovie = pmovie->m_dwUserID;
        if( m_pEffect )
        {
            m_pEffect->Finish();
        }

        CmdAddEffect(eEffectFountain, 10, 10, 10, TRUE);

        return;
    }
}
开发者ID:hgl888,项目名称:nashtest,代码行数:38,代码来源:CMultiSAP.cpp

示例4: Draw

static void
Draw(void *obj)
{
	AG_Slider *sl = obj;
	int x;

	if (GetPosition(sl, &x) == -1) {
		return;
	}
	switch (sl->type) {
	case AG_SLIDER_VERT:
		AG_DrawBox(sl, AG_RECT(0,0,WIDTH(sl),HEIGHT(sl)), -1, WCOLOR(sl,0));
		AG_DrawBox(sl,
		    AG_RECT(0, x, WIDTH(sl), sl->wControl),
		    sl->ctlPressed ? -1 : 1,
		    WCOLOR(sl,0));
		break;
	case AG_SLIDER_HORIZ:
		AG_DrawBox(sl, AG_RECT(0,0,WIDTH(sl),HEIGHT(sl)), -1, WCOLOR(sl,0));
		AG_DrawBox(sl,
		    AG_RECT(x, 0, sl->wControl, HEIGHT(sl)),
		    sl->ctlPressed ? -1 : 1,
		    WCOLOR(sl,0));
		break;
	}
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:26,代码来源:slider.c

示例5: _equalf

static int _equalf(CMATRIX *a, double f)
{
	bool result;
	
	if (COMPLEX(a))
	{
		if (f == 0.0)
			return gsl_matrix_complex_isnull(CMAT(a));
		
		gsl_matrix_complex *m = gsl_matrix_complex_alloc(WIDTH(a), HEIGHT(a));
		gsl_matrix_complex_set_identity(m);
		gsl_matrix_complex_scale(m, gsl_complex_rect(f, 0));
		result = gsl_matrix_complex_equal(CMAT(a), m);
		gsl_matrix_complex_free(m);
	}
	else
	{
		if (f == 0.0)
			return gsl_matrix_isnull(MAT(a));
		
		gsl_matrix *m = gsl_matrix_alloc(WIDTH(a), HEIGHT(a));
		gsl_matrix_set_identity(m);
		gsl_matrix_scale(m, f);
		result = gsl_matrix_equal(MAT(a), m);
		gsl_matrix_free(m);
	}
	
	return result;
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:29,代码来源:c_matrix.c

示例6: bstack

static void
bstack(Monitor *m) {
    int w, h, mh, mx, tx, ty, tw;
    unsigned int i, n;
    Client *c;

    for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
    if(n == 0)
        return;
    if(n > m->nmaster) {
        mh = m->nmaster ? m->mfact * m->wh : 0;
        tw = m->ww / (n - m->nmaster);
        ty = m->wy + mh;
    } 
    else {
        mh = m->wh;
        tw = m->ww;
        ty = m->wy;
    }
    for(i = mx = 0, tx = m->wx, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
        if(i < m->nmaster) {
            w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
            resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), False);
            mx += WIDTH(c);
        } 
        else {
            h = m->wh - mh;
            resize(c, tx, ty, tw - (2 * c->bw), h - (2 * c->bw), False);
            if(tw != m->ww)
                tx += WIDTH(c);
        }
    }
}
开发者ID:foxiepaws,项目名称:dwm-fox,代码行数:33,代码来源:bstack.c

示例7: rgz_hwc_scaled

static int rgz_hwc_scaled(hwc_layer_1_t *layer)
{
    int w = WIDTH(layer->sourceCrop);
    int h = HEIGHT(layer->sourceCrop);

    if (layer->transform & HWC_TRANSFORM_ROT_90)
        swap(w, h);

    return WIDTH(layer->displayFrame) != w || HEIGHT(layer->displayFrame) != h;
}
开发者ID:LG-P769-DEVELOPERS,项目名称:aokp_device_lge_p769,代码行数:10,代码来源:rgz_2d.c

示例8: getscalew

static float getscalew(hwc_layer_1_t *layer)
{
    int w = WIDTH(layer->sourceCrop);
    int h = HEIGHT(layer->sourceCrop);

    if (layer->transform & HWC_TRANSFORM_ROT_90)
        swap(w, h);

    return ((float)WIDTH(layer->displayFrame)) / (float)w;
}
开发者ID:LG-P769-DEVELOPERS,项目名称:aokp_device_lge_p769,代码行数:10,代码来源:rgz_2d.c

示例9: rgz_src1_prep

static void rgz_src1_prep(
    struct rgz_blt_entry* e, hwc_layer_1_t *l,
    blit_rect_t *rect,
    struct bvbuffdesc *scrdesc, struct bvsurfgeom *scrgeom)
{
    if (!l)
        return;

    IMG_native_handle_t *handle = (IMG_native_handle_t *)l->handle;

    struct bvbuffdesc *src1desc = &e->src1desc;
    src1desc->structsize = sizeof(struct bvbuffdesc);
    src1desc->length = handle->iHeight * HANDLE_TO_STRIDE(handle);
    /*
     * The virtaddr isn't going to be used in the final 2D h/w integration
     * because we will be handling buffers differently
     */
    src1desc->virtaddr = HANDLE_TO_BUFFER(handle);

    struct bvsurfgeom *src1geom = &e->src1geom;
    src1geom->structsize = sizeof(struct bvsurfgeom);
    src1geom->format = hal_to_ocd(handle->iFormat);
    src1geom->width = handle->iWidth;
    src1geom->height = handle->iHeight;
    src1geom->orientation = l->transform & HWC_TRANSFORM_ROT_90 ? 90 :
            l->transform & HWC_TRANSFORM_ROT_180 ? 180 :
            l->transform & HWC_TRANSFORM_ROT_270 ? 270 : 0;
    src1geom->virtstride = HANDLE_TO_STRIDE(handle);

    struct bvsurfgeom *dstgeom = &e->dstgeom;
    dstgeom->structsize = sizeof(struct bvsurfgeom);
    dstgeom->format = scrgeom->format;
    dstgeom->width = scrgeom->width;
    dstgeom->height = scrgeom->height;
    dstgeom->orientation = 0;
    dstgeom->virtstride = DSTSTRIDE(scrgeom);

    struct bvbltparams *bp = &e->bp;
    bp->structsize = sizeof(struct bvbltparams);
    bp->dstdesc = scrdesc;
    bp->dstgeom = dstgeom;
    bp->dstrect.left = rect->left;
    bp->dstrect.top = rect->top;
    bp->dstrect.width = WIDTH(*rect);
    bp->dstrect.height = HEIGHT(*rect);
    bp->src1.desc = src1desc;
    bp->src1geom = src1geom;
    bp->src1rect.left = effective_srcleft(l, rect);
    bp->src1rect.top = effective_srctop(l, rect);
    bp->src1rect.width = WIDTH(*rect); // XXX fixme - effective width/height?
    bp->src1rect.height = HEIGHT(*rect);
    bp->cliprect.left = bp->cliprect.top = 0;
    bp->cliprect.width = scrgeom->width;
    bp->cliprect.height = scrgeom->height;
}
开发者ID:LG-P769-DEVELOPERS,项目名称:aokp_device_lge_p769,代码行数:55,代码来源:rgz_2d.c

示例10: _equal

static int _equal(CMATRIX *a, CMATRIX *b)
{
	if (WIDTH(a) != WIDTH(b) || HEIGHT(a) != HEIGHT(b))
		return FALSE;
	
	if (COMPLEX(a) || COMPLEX(b))
	{
		MATRIX_ensure_complex(a);
		MATRIX_ensure_complex(b);
		return gsl_matrix_complex_equal(CMAT(a), CMAT(b));
	}
	else
		return gsl_matrix_equal(MAT(a), MAT(b));
}
开发者ID:ramonelalto,项目名称:gambas,代码行数:14,代码来源:c_matrix.c

示例11: Draw

static void
Draw(void *p)
{
	AG_Button *bu = p;
	AG_Variable *binding;
	void *pState;
	int pressed;
	
	binding = AG_GetVariable(bu, "state", &pState);
	pressed = GetState(bu, binding, pState);
	AG_UnlockVariable(binding);

	if (AG_WidgetEnabled(bu)) {
		AG_DrawBox(bu,
		    AG_RECT(0, 0, WIDTH(bu), HEIGHT(bu)),
		    pressed ? -1 : 1,
		    WCOLOR(bu,0));
	} else {
		AG_DrawBoxDisabled(bu,
		    AG_RECT(0, 0, WIDTH(bu), HEIGHT(bu)),
		    pressed ? -1 : 1,
		    WCOLOR_DEF(bu,0),
		    WCOLOR_DIS(bu,0));
	}

	if (bu->lbl != NULL) {
		AG_WidgetDraw(bu->lbl);
	} else if (bu->surface != -1) {
		int w = WSURFACE(bu,bu->surface)->w;
		int h = WSURFACE(bu,bu->surface)->h;
		int x = 0, y = 0;

		switch (bu->justify) {
		case AG_TEXT_LEFT:	x = bu->lPad;			break;
		case AG_TEXT_CENTER:	x = WIDTH(bu)/2 - w/2;		break;
		case AG_TEXT_RIGHT:	x = WIDTH(bu) - w - bu->rPad;	break;
		}
		switch (bu->valign) {
		case AG_TEXT_TOP:	y = bu->tPad;			break;
		case AG_TEXT_MIDDLE:	y = HEIGHT(bu)/2 - h/2;		break;
		case AG_TEXT_BOTTOM:	y = HEIGHT(bu) - h - bu->bPad;	break;
		}
		if (pressed) {
			x++;
			y++;
		}
		AG_WidgetBlitSurface(bu, bu->surface, x, y);
	}
}
开发者ID:varialus,项目名称:agar,代码行数:49,代码来源:button.c

示例12: draw_number

int draw_number(const char *num, int x, int y)
{
    int len = strlen(num);
    int i;
    int written = 0;

    int valid_length = digitlen(num);

    if (x < 0)
        x = (COLS - WIDTH(valid_length)) / 2;

    if (y < 0)
        y = (LINES - HEIGHT) / 2;


    for (i = 0; i < len; ++i)
    {
        char glyph = map_glyph(num[i]);

        if (glyph < 0)
            continue;

        draw_digit(glyph, x, y);
        x += DIGIT_SPACING + DIGIT_WIDTH;

        ++written;
    }

    return written;
}
开发者ID:FliPPeh,项目名称:NClock,代码行数:30,代码来源:nclock.c

示例13: bstackhoriz

static void
bstackhoriz(Monitor *m) {
	int w, mh, mx, tx, ty, th;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->cl->clients,m); c; c = nexttiled(c->next,m), n++);
	if(n == 0)
		return;
	if(n > m->nmaster) {
		mh = m->nmaster ? m->mfact * m->wh : 0;
		th = (m->wh - mh) / (n - m->nmaster);
		ty = m->wy + mh;
	} 
	else {
		th = mh = m->wh;
		ty = m->wy;
	}
	for(i = mx = 0, tx = m->wx, c = nexttiled(m->cl->clients,m); c; c = nexttiled(c->next,m), i++) {
		if(i < m->nmaster) {
			w = (m->ww - mx) / (MIN(n, m->nmaster) - i);
			resize(c, m->wx + mx, m->wy, w - (2 * c->bw), mh - (2 * c->bw), False);
			mx += WIDTH(c);
		} 
		else {
			resize(c, tx, ty, m->ww - (2 * c->bw), th - (2 * c->bw), False);
			if(th != m->wh)
				ty += HEIGHT(c);
		}
	}
}
开发者ID:towarischtsch,项目名称:dwm,代码行数:31,代码来源:bstackhoriz.c

示例14: infoTile

static inline void infoTile(const QString & message, Tile * tile)
{
	if (tile == NULL) {
		DebugDialog::debug("infoTile: tile is NULL");
		return;
	}

	DebugDialog::debug(QString("tile:%1 lb:%2 bl:%3 tr:%4 rt%5")
		.arg((long) tile, 0, 16)
		.arg((long) tile->ti_lb, 0, 16)
		.arg((long) tile->ti_bl, 0, 16)
		.arg((long) tile->ti_tr, 0, 16)
		.arg((long) tile->ti_rt, 0, 16));

	DebugDialog::debug(QString("%1 tile:%2 l:%3 t:%4 w:%5 h:%6 type:%7 body:%8")
		.arg(message)
		.arg((long) tile, 0, 16)
		.arg(LEFT(tile))
		.arg(YMIN(tile))
		.arg(WIDTH(tile))
		.arg(HEIGHT(tile))
		.arg(TiGetType(tile))
		.arg((long) TiGetBody(tile), 0, 16)
	);
}
开发者ID:bacchante95,项目名称:fritzing,代码行数:25,代码来源:cmrouter.cpp

示例15: ALIGN

void ExynosMPP::setupSource(exynos_mpp_img &src_img, hwc_layer_1_t &layer)
{
    private_handle_t *src_handle = private_handle_t::dynamicCast(layer.handle);
    src_img.x = ALIGN((unsigned int)layer.sourceCropf.left, srcXOffsetAlign(layer));
    src_img.y = ALIGN((unsigned int)layer.sourceCropf.top, srcYOffsetAlign(layer));
    src_img.w = WIDTH(layer.sourceCropf);
    src_img.fw = src_handle->stride;
    src_img.h = HEIGHT(layer.sourceCropf);
    src_img.fh = src_handle->vstride;
    src_img.yaddr = src_handle->fd;
    if (mS3DMode == S3D_SBS)
        src_img.w /= 2;
    if (mS3DMode == S3D_TB)
        src_img.h /= 2;
    if (isFormatYCrCb(src_handle->format)) {
        src_img.uaddr = src_handle->fd2;
        src_img.vaddr = src_handle->fd1;
    } else {
        src_img.uaddr = src_handle->fd1;
        src_img.vaddr = src_handle->fd2;
    }
    if (src_handle->format != HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M_FULL)
        src_img.format = src_handle->format;
    else
        src_img.format = HAL_PIXEL_FORMAT_EXYNOS_YCrCb_420_SP_M;
    src_img.drmMode = !!(getDrmMode(src_handle->flags) == SECURE_DRM);
    src_img.acquireFenceFd = layer.acquireFenceFd;
}
开发者ID:TeamEOS,项目名称:hardware_samsung_slsi_exynos,代码行数:28,代码来源:ExynosMPP.cpp


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