Esempio n. 1
0
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);
	}
}
/* 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)) ;
}
Esempio n. 3
0
//-------------------------------------------------------------------------
//  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;
    }
}
Esempio n. 4
0
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;
	}
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
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);
        }
    }
}
Esempio n. 7
0
static void
_termBufferPrintLine
(
    const TermBuffer tb,
    const short row
)
{
    TermLine    line;
    wchar_t   *pChar;
    short       j;

    printf("Line: %d\n", row);

    line = LINE_OF_TBUF(tb, row);
    printf("    length: %3d\n", WIDTH(line));
    if (WIDTH(line) > 0)
    {
        printf("    buffer: <");
        pChar = BUFFER(line);
        for (j = 0; j < WIDTH(line); j++)
        {
            printf("%X", *pChar++);
        }
        printf(">\n");
    }
}
Esempio n. 8
0
void CToolsPanelContainer::SetWindowsPos(const RECT& rect)
{
	if (!pTopToolsPanel || !pBotToolsPanel)
		return;

	// position top toolbar
	pTopToolsPanel->SetWindowPos(NULL, rect.left, rect.top, WIDTH(rect), HEIGHT(rect), SWP_NOZORDER | SWP_NOACTIVATE);
	// position bottom toolbar
	pBotToolsPanel->SetWindowPos(NULL, rect.left, rect.bottom, WIDTH(rect), HEIGHT(rect), SWP_NOZORDER | SWP_NOACTIVATE);
}
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;
}
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;
}
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;
}
Esempio n. 12
0
/*
** Pad the requested row from the current width to 'newWidth' with spaces...
*/
void
_DtTermPrimBufferPadLineWc
(
    const TermBuffer  tb,
    const short       row,
    const short       width
)
{
    short       i;
    short       widthInc;
    TermLine    line;
    wchar_t    *pwc;
    
    line = LINE_OF_TBUF(tb, row);

    if (isDebugFSet('i', 1)) {
#ifdef	BBA
#pragma BBA_IGNORE
#endif	/*BBA*/
	(void) _termBufferValidateLineWc(tb, row);
    }

    /*
    ** if this line is part of the selection, disown the selection...
    */
    if (IS_IN_SELECTION(line, MIN(width, WIDTH(line)),
			MAX(width, WIDTH(line))))
    {
	(void) _DtTermPrimSelectDisown(WIDGET(tb));
    }

    widthInc = MIN(COLS(tb), width) - WIDTH(line);

    for (i = 0, pwc = (wchar_t *)BUFFER(line) + MAX(0, LENGTH(line));
         i < widthInc;
         i++, pwc++)
    {
        *pwc = L' ';
	LENGTH(line)++;
    }
    if (CLEAR_ENH(tb))
    {
        (*CLEAR_ENH(tb))(tb, row, WIDTH(line), widthInc);
    }
    _DtTermPrimBufferSetLineWidth(tb, row, WIDTH(line) + widthInc);
    if (isDebugFSet('i', 1)) {
#ifdef	BBA
#pragma BBA_IGNORE
#endif	/*BBA*/
	_termBufferValidateLineWc(tb, row);
    }
}
Esempio n. 13
0
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));
}
Esempio n. 14
0
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);
	}
}
Esempio n. 15
0
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;
}
Esempio n. 16
0
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);
		}
	}
}
Esempio n. 17
0
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)
	);
}
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;
}
static int random_bubble(struct player_state* p)
{
  int i, j, result;
  int tried = 0;

  if(level < sizeof(levels) / sizeof(levels[0]) && levels[level].has_joker)
  {
    if((rng() % 10) == 0)
      return 8;
  }

  while(tried != 0xFF)
  {
    result = rng() % 8;

    tried |= (1 << result);

    for(i = 0; i < field_height; ++i)
    {
      for(j = 0; j < WIDTH(i); ++j)
      {
        if(p->field[i][j] == result + 1)
          return result;
      }
    }
  }

  return rng() % 8;
}
Esempio n. 20
0
LRESULT CLabel::OnCtlColor(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	HDC hDC = (HDC)wParam;
	if (hDC)
	{
		::SelectObject(hDC, m_hFont);
		::SetTextColor(hDC, m_clrText);
		::SetBkMode(hDC, TRANSPARENT);

		if (m_iAngle)
		{
			int nAlign = ::SetTextAlign(hDC, TA_BASELINE);
			RECT rc;
			GetClientRect(&rc);
			POINT pt;
			::GetViewportOrgEx(hDC, &pt);
			::SetViewportOrgEx(hDC, WIDTH(rc)/2, HEIGHT(rc)/2, NULL);
		//j To restore
		//j	::SetViewportOrgEx(hDC, pt.x/2, pt.y/2, NULL);
		//j	::SetTextAlign(hDC, nAlign);
		}
	}

	if (m_FlashType == Background && !m_bFlashState)
		return (LRESULT)m_hFlashBrush;
	else
		return (LRESULT)m_hBackgroundBrush;
}
Esempio n. 21
0
static bool matrix_determinant(CMATRIX *m, COMPLEX_VALUE *det) 
{
  int sign = 0; 
	int size = WIDTH(m);
	
	if (size != HEIGHT(m))
		return TRUE;
	
  gsl_permutation *p = gsl_permutation_calloc(size);
	
	if (COMPLEX(m))
	{
		gsl_matrix_complex *tmp = gsl_matrix_complex_alloc(size, size);
		gsl_matrix_complex_memcpy(tmp, CMAT(m));
		gsl_linalg_complex_LU_decomp(tmp, p, &sign);
		det->z = gsl_linalg_complex_LU_det(tmp, sign);
		gsl_matrix_complex_free(tmp);
	}
	else
	{
		gsl_matrix *tmp = gsl_matrix_alloc(size, size);
		gsl_matrix_memcpy(tmp, MAT(m));
		gsl_linalg_LU_decomp(tmp, p, &sign);
		det->x = gsl_linalg_LU_det(tmp, sign);
		det->z.dat[1] = 0;
		gsl_matrix_free(tmp);
	}
	
  gsl_permutation_free(p);
  return FALSE;
}
Esempio n. 22
0
void CECardDialog::PositionWindow()
{
	HWND hParent = GetParent();
	POINT ptCursor;
	::GetCursorPos(&ptCursor);
	
	RECT rParent;
	::GetWindowRect(hParent, &rParent);
	ClientToScreen(&rParent);

	RECT rRect;
	GetWindowRect(&rRect);
	ClientToScreen(&rRect);

	POINT ptNew;
	if (ptCursor.x < (rParent.left + rParent.right)/2)
		ptNew.x = ptCursor.x;
	else
		ptNew.x = ptCursor.x - WIDTH(rRect);

	if (ptCursor.y < (rParent.top + rParent.bottom)/2)
		ptNew.y = ptCursor.y + 10;
	else
		ptNew.y = ptCursor.y - HEIGHT(rRect) - 10;
	
	SetWindowPos(HWND_TOPMOST, ptNew.x, ptNew.y, 0, 0, SWP_NOSIZE | SWP_SHOWWINDOW);
}
Esempio n. 23
0
void CTrack::Init(CAGDC* pDC, RECT& SymbolRect, RECT& BoundRect, RECT& PageRect, CAGMatrix& ViewToDeviceMatrix, CAGMatrix& SymbolMatrix, CGrid& Grid)
{
	ZeroData();

	m_pAGDC = pDC;
	m_ViewToDeviceMatrix = ViewToDeviceMatrix;
	m_OrigMatrix = SymbolMatrix;
	m_Matrix = m_OrigMatrix;
	m_Grid = Grid;

	m_PageRect = PageRect;
	m_BoundRectScreen = m_PageRect;

	// Setup the bounding rectangle
	m_Distort.Rect = SymbolRect;

	// Don't let the rect be empty in either dimension
	::InflateRect(&m_Distort.Rect, !WIDTH(m_Distort.Rect), !HEIGHT(m_Distort.Rect));

	m_Distort.RectOrig = m_Distort.Rect;
	m_Distort.p[0].x = m_Distort.Rect.left;
	m_Distort.p[0].y = m_Distort.Rect.top;
	m_Distort.p[1].x = m_Distort.Rect.right;
	m_Distort.p[1].y = m_Distort.Rect.top;
	m_Distort.p[2].x = m_Distort.Rect.right;
	m_Distort.p[2].y = m_Distort.Rect.bottom;
	m_Distort.p[3].x = m_Distort.Rect.left;
	m_Distort.p[3].y = m_Distort.Rect.bottom;
	m_ptCenter.x = (m_Distort.Rect.left + m_Distort.Rect.right)/2;
	m_ptCenter.y = (m_Distort.Rect.top  + m_Distort.Rect.bottom)/2;
	m_ptRotate.x = m_ptCenter.x;
	m_ptRotate.y = (m_Distort.Rect.top  + m_ptCenter.y)/2;
}
Esempio n. 24
0
static void
bstack(Monitor *m) {
	int x, y, h, w, mh;
	unsigned int i, n;
	Client *c;

	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
	if(n == 0)
		return;
	/* master */
	c = nexttiled(m->clients);
	mh = m->mfact * m->wh;
	resize(c, m->wx, m->wy, m->ww - 2 * c->bw, (n == 1 ? m->wh : mh) - 2 * c->bw, False);
	if(--n == 0)
		return;
	/* tile stack */
	x = m->wx;
	y = (m->wy + mh > c->y + c->h) ? c->y + c->h + 2 * c->bw : m->wy + mh;
	w = m->ww / n;
	h = (m->wy + mh > c->y + c->h) ? m->wy + m->wh - y : m->wh - mh;
	if(w < bh)
		w = m->ww;
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
		resize(c, x, y, /* remainder */ ((i + 1 == n)
		       ? m->wx + m->ww - x - 2 * c->bw : w - 2 * c->bw), h - 2 * c->bw, False);
		if(w != m->ww)
			x = c->x + WIDTH(c);
	}
}
static void rgz_src2blend_prep(
    struct rgz_blt_entry* e, hwc_layer_1_t *l, blit_rect_t *rect)
{
    IMG_native_handle_t *handle = (IMG_native_handle_t *)l->handle;

    struct bvbuffdesc *src2desc = &e->src2desc;
    src2desc->structsize = sizeof(struct bvbuffdesc);
    src2desc->length = handle->iHeight * HANDLE_TO_STRIDE(handle);
    src2desc->virtaddr = HANDLE_TO_BUFFER(handle); /* XXX caution virtaddr */

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

    /*
     * This looks a little odd but what we need to do here is take the
     * rectangle which has coordinates in terms of the display dimensions
     * and find the offset of the source buffer for the layer
     */
    blit_rect_t src2rect = *rect;
    src2rect.top = effective_srctop(l, rect);
    src2rect.left = effective_srcleft(l, rect);
    src2rect.bottom = src2rect.top + HEIGHT(*rect);
    src2rect.right = src2rect.left + WIDTH(*rect);
    rgz_src2blend_prep2(e, l->transform, &src2rect, src2desc, src2geom);
}
Esempio n. 26
0
void CTrack::Init(CAGDC* pDC, int iWhatCanDo, DRAWPROC lpDrawProc, void* pData, RECT& SymbolRect, RECT& BoundRect, RECT& PageRect, CAGMatrix& ViewToDeviceMatrix, CAGMatrix& SymbolMatrix, CGrid& Grid)
{
	ZeroData();

	m_iWhatCanDo = 	iWhatCanDo;
	Mode(m_iWhatCanDo, false/*fDisplay*/);

	RotateConstrain(false/*bConstrainX*/, false/*bConstrainY*/);

	m_pAGDC = pDC;
	m_pDrawProc = lpDrawProc;
	m_pData = pData;

	m_ViewToDeviceMatrix = ViewToDeviceMatrix;
	m_OrigMatrix = SymbolMatrix;
	m_Matrix = m_OrigMatrix;
	m_Grid = Grid;

	m_PageRect = PageRect;
	if (m_iWhatCanDo & TR_BOUNDTOSYMBOL)
	{
		m_BoundRect = BoundRect;
		m_Matrix.Transform(m_BoundRect);
		m_BoundRectScreen = m_BoundRect;
		m_ViewToDeviceMatrix.Transform(m_BoundRectScreen);
	}
	else
		m_BoundRectScreen = m_PageRect;

	// Setup the bounding rectangle
	m_Distort.Rect = SymbolRect;

	// Don't let the rect be empty in either dimension
	::InflateRect(&m_Distort.Rect, !WIDTH(m_Distort.Rect), !HEIGHT(m_Distort.Rect));

	m_Distort.RectOrig = m_Distort.Rect;
	m_Distort.p[0].x = m_Distort.Rect.left;
	m_Distort.p[0].y = m_Distort.Rect.top;
	m_Distort.p[1].x = m_Distort.Rect.right;
	m_Distort.p[1].y = m_Distort.Rect.top;
	m_Distort.p[2].x = m_Distort.Rect.right;
	m_Distort.p[2].y = m_Distort.Rect.bottom;
	m_Distort.p[3].x = m_Distort.Rect.left;
	m_Distort.p[3].y = m_Distort.Rect.bottom;
	m_ptCenter.x = (m_Distort.Rect.left + m_Distort.Rect.right)/2;
	m_ptCenter.y = (m_Distort.Rect.top  + m_Distort.Rect.bottom)/2;
	m_ptRotate.x = m_ptCenter.x;
	m_ptRotate.y = (m_Distort.Rect.top  + m_ptCenter.y)/2;

	// init to no handles grabbed and no transforming done
	m_iHandleGrabbed = 0;

	m_bMoveOnly = true;

#ifdef READOUT
	m_fReadoutAngleX = m_fReadoutAngleY = 0;
	m_fReadoutScaleX = m_fReadoutScaleY = 1.0;
#endif READOUT
}
Esempio n. 27
0
//////////////////////////////////////////////////////////////////////
// Adjust the matrix to stretch the source within the destination rectangle
void CAGMatrix::StretchToFit(const RECT& DestRect, const RECT& SrcRect)
{
    double scx = (double)(SrcRect.left + SrcRect.right) / 2;
    double scy = (double)(SrcRect.top + SrcRect.bottom) / 2;

    double dcx = (double)(DestRect.left + DestRect.right) / 2;
    double dcy = (double)(DestRect.top + DestRect.bottom) / 2;

    int sw = WIDTH(SrcRect);
    int sh = HEIGHT(SrcRect);

    Translate(-scx, -scy);
    double fxScale = (!sw ? 1.0 : (double)WIDTH(DestRect) / sw);
    double fyScale = (!sh ? 1.0 : (double)HEIGHT(DestRect) / sh);
    Scale(fxScale, fyScale);
    Translate(dcx, dcy);
}
Esempio n. 28
0
static void
nbstack(Monitor *m) {
	int x, y, h, w, mh, nm, nmax;
	unsigned int i, n;
	Client *c;

	/* override layout symbol */
	snprintf(m->ltsymbol, sizeof m->ltsymbol, "T%dT", LT(m)->nmaster);
	for(n = 0, c = nexttiled(cl->clients, m); c; c = nexttiled(c->next, m), n++);
	c = nexttiled(cl->clients, m);
	nmax = LT(m)->nmaster;
	nm = nmax == 1 ? 1 : MIN(n / 2, nmax);
	if(nm > n)
		nm = n;
	/* master */
	if(nm > 0) {
		mh = LT(m)->mfact * m->wh;
		w = m->ww / nm;
		if(w < bh)
			w = m->ww;
		x = m->wx;
		for(i = 0; i < nm; i++, c = nexttiled(c->next, m)) {
			resize(c, x, m->wy, ((i + 1 == nm) ? m->wx + m->ww - x : w) - 2 * c->bw,
			       (n == nm ? m->wh : mh) - 2 * c->bw, False);
			if(w != m->ww)
				x = c->x + WIDTH(c);
		}
		n -= nm;
	} else
		mh = 0;
	if(n == 0)
		return;
	/* tile stack */
	x = m->wx;
	y = m->wy + mh;
	w = m->ww / n;
	h = m->wh - mh;
	if(w < bh)
		w = m->ww;
	for(i = 0; c; c = nexttiled(c->next, m), i++) {
		resize(c, x, y, ((i + 1 == n) ? m->wx + m->ww - x : w) - 2 * c->bw,
		       h - 2 * c->bw, False);
		if(w != m->ww)
			x = c->x + WIDTH(c);
	}
}
static void init_field()
{
  int i, j, k, color;

  if(level < sizeof(levels) / sizeof(levels[0]))
  {
    for(i = 0, k = 0; i < field_height; ++i)
    {
      for(j = 0; j < WIDTH(i); ++j, ++k)
      {
        p.field[i][j] = levels[level].colors[k];
      }
    }

    rng_seed = levels[level].seed;
    bonus = 0;
  }
  else
  {
    for(i = 0; i < field_height / 2; ++i)
    {
      for(j = 0; j < WIDTH(i); ++j)
      {
        color = (rng() % 8) + 1;

        p.field[i][j] = color;
      }
    }
  }

  for(; i < field_height; ++i)
  {
    for(j = 0; j < WIDTH(i); ++j)
    {
      p.field[i][j] = 0;
    }
  }

  p.bubble = random_bubble(&p);
  p.next_bubble = random_bubble(&p);

  init_player(&p);

  state = GS_NEUTRAL;
}
Esempio n. 30
0
//////////////////////////////////////////////////////////////////////
// Adjust the matrix to stretch the source within the destination rectangle
void CAGMatrix::ScaleToFit(const RECT& DestRect, const RECT& SrcRect, bool bUseSmallerFactor)
{
    double scx = (double)(SrcRect.left + SrcRect.right) / 2;
    double scy = (double)(SrcRect.top + SrcRect.bottom) / 2;

    double dcx = (double)(DestRect.left + DestRect.right) / 2;
    double dcy = (double)(DestRect.top + DestRect.bottom) / 2;

    int sw = WIDTH(SrcRect);
    int sh = HEIGHT(SrcRect);

    Translate(-scx, -scy);
    double fxScale = (!sw ? 1.0 : (double)WIDTH(DestRect) / sw);
    double fyScale = (!sh ? 1.0 : (double)HEIGHT(DestRect) / sh);
    double fScale = (bUseSmallerFactor ? min(fxScale, fyScale) : max(fxScale, fyScale));
    Scale(fScale, fScale);
    Translate(dcx, dcy);
}