Ejemplo n.º 1
0
Archivo: c.c Proyecto: wenfahu/toy_c2js
void ChangeToBehind(char* ch)
{
    int len = strlen(ch);
    int num = 0;
    int l = 0;
    int i;
    int j;
    int heaptop = 0;
    char heap[2000];
    chnew[0] = 0;
    heap[0] = '#';
    for (i = 0; i <= len; i++)
    {
        if (ch[i] >= '0' && ch[i] <= '9')
        {
            num++;
        }
        else
        {
            for (j = 0; j < num; j++)
            {
                chnew[l + j] = ch[i - num + j];
            }
            chnew[l + num] = ' ';
            l = l + num + 1;
            num = 0;
            while (checkl(ch[i]) <= checkr(heap[heaptop]))
            {
                if (heaptop == 0)
                {
                    break;
                }
                if (heap[heaptop] != '('){
                    chnew[l] = heap[heaptop];
                    l = l + 1;
                }
                else
                {
                    if (ch[i] == ')')
                    {
                    heaptop--;
                    break;
                    }
                }
                heaptop--;
            }
            heap[++heaptop] = ch[i];
        }
    }
}
Ejemplo n.º 2
0
void PlayerWidget::paintEvent(QPaintEvent *e) {
	Painter p(this);

	QRect r(e->rect()), checkr(myrtlrect(r));
	p.fillRect(r, st::playerBg->b);

	if (!_playbackRect.contains(checkr)) {
		if (_fullAvailable && checkr.intersects(_prevRect)) {
			if (_prevAvailable) {
				float64 o = _stateHovers[OverPrev];
				p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
			} else {
				p.setOpacity(st::playerUnavailableOpacity);
			}
			p.drawSpriteCenterLeft(_prevRect, width(), st::playerPrev);
		}
		if (checkr.intersects(_playRect)) {
			float64 o = _stateHovers[OverPlay];
			p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
			p.drawSpriteCenterLeft(_playRect, width(), (_showPause || _down == OverPlayback) ? st::playerPause : st::playerPlay);
		}
		if (_fullAvailable && checkr.intersects(_nextRect)) {
			if (_nextAvailable) {
				float64 o = _stateHovers[OverNext];
				p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
			} else {
				p.setOpacity(st::playerUnavailableOpacity);
			}
			p.drawSpriteCenterLeft(_nextRect, width(), st::playerNext);
		}
		if (checkr.intersects(_closeRect)) {
			float64 o = _stateHovers[OverClose];
			p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
			p.drawSpriteCenterLeft(_closeRect, width(), st::playerClose);
		}
		if (checkr.intersects(_volumeRect)) {
			float64 o = _stateHovers[OverVolume];
			p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
			int32 top = _volumeRect.y() + (_volumeRect.height() - st::playerVolume.pxHeight()) / 2;
			int32 left = _volumeRect.x() + (_volumeRect.width() - st::playerVolume.pxWidth()) / 2;
			int32 mid = left + qRound(st::playerVolume.pxWidth() * cSongVolume());
			int32 right = left + st::playerVolume.pxWidth();
			if (rtl()) {
				left = width() - left;
				mid = width() - mid;
				right = width() - right;
				if (mid < left) {
					p.drawPixmap(QRect(mid, top, left - mid, st::playerVolume.pxHeight()), App::sprite(), QRect(st::playerVolume.x() + (mid - right) * cIntRetinaFactor(), st::playerVolume.y(), (left - mid) * cIntRetinaFactor(), st::playerVolume.pxHeight() * cIntRetinaFactor()));
				}
				if (right < mid) {
					p.setOpacity(st::playerUnavailableOpacity);
					p.drawPixmap(QRect(right, top, mid - right, st::playerVolume.pxHeight()), App::sprite(), QRect(st::playerVolume.x(), st::playerVolume.y(), (mid - right) * cIntRetinaFactor(), st::playerVolume.pxHeight() * cIntRetinaFactor()));
				}
			} else {
				if (mid > left) {
					p.drawPixmap(QRect(left, top, mid - left, st::playerVolume.pxHeight()), App::sprite(), QRect(st::playerVolume.x(), st::playerVolume.y(), (mid - left) * cIntRetinaFactor(), st::playerVolume.pxHeight() * cIntRetinaFactor()));
				}
				if (right > mid) {
					p.setOpacity(st::playerUnavailableOpacity);
					p.drawPixmap(QRect(mid, top, right - mid, st::playerVolume.pxHeight()), App::sprite(), QRect(st::playerVolume.x() + (mid - left) * cIntRetinaFactor(), st::playerVolume.y(), (right - mid) * cIntRetinaFactor(), st::playerVolume.pxHeight() * cIntRetinaFactor()));
				}
			}
		}
		if (_fullAvailable && checkr.intersects(_fullRect)) {
			float64 o = _stateHovers[OverFull];
			p.setOpacity(o * 1. + (1. - o) * st::playerInactiveOpacity);
			p.drawSpriteCenterLeft(_fullRect, width(), st::playerFull);
		}
		if (checkr.intersects(_repeatRect)) {
			float64 o = _stateHovers[OverRepeat];
			p.setOpacity(_repeat ? 1. : (o * st::playerInactiveOpacity + (1. - o) * st::playerUnavailableOpacity));
			p.drawSpriteCenterLeft(_repeatRect, width(), st::playerRepeat);
		}
		p.setOpacity(1.);

		p.setPen(st::playerTimeFg->p);
		p.setFont(st::linkFont->f);
		p.drawTextLeft(_infoRect.x() + _infoRect.width() - _timeWidth, _infoRect.y() + (_infoRect.height() - st::linkFont->height) / 2, width(), _time, _timeWidth);

		textstyleSet(&st::playerNameStyle);
		p.setPen(st::playerFg->p);
		_name.drawElided(p, _infoRect.x() + (rtl() ? (_timeWidth + st::playerSkip) : 0), _infoRect.y() + (_infoRect.height() - st::linkFont->height) / 2, _infoRect.width() - _timeWidth - st::playerSkip);
		textstyleRestore();
	}

	if (_duration) {
		float64 prg = (_down == OverPlayback) ? _downProgress : a_progress.current();
		int32 from = _playbackRect.x(), mid = qRound(_playbackRect.x() + prg * _playbackRect.width()), end = _playbackRect.x() + _playbackRect.width();
		if (mid > from) {
			p.fillRect(rtl() ? (width() - mid) : from, height() - st::playerLineHeight, mid - from, _playbackRect.height(), st::playerLineActive->b);
		}
		if (end > mid) {
			p.fillRect(rtl() ? (width() - end) : mid, height() - st::playerLineHeight, end - mid, st::playerLineHeight, st::playerLineInactive->b);
		}
		if (_stateHovers[OverPlayback] > 0) {
			p.setOpacity(_stateHovers[OverPlayback]);

			int32 x = mid - (st::playerMoverSize.width() / 2);
			p.fillRect(rtl() ? (width() - x - st::playerMoverSize.width()) : x, height() - st::playerMoverSize.height(), st::playerMoverSize.width(), st::playerMoverSize.height(), st::playerLineActive->b);
		}
	} else if (a_loadProgress.current() > 0) {
		int32 from = _playbackRect.x(), mid = qRound(_playbackRect.x() + a_loadProgress.current() * _playbackRect.width());
		if (mid > from) {
			p.fillRect(rtl() ? (width() - mid) : from, height() - st::playerLineHeight, mid - from, _playbackRect.height(), st::playerLineInactive->b);
		}
	}
}