VisiblePosition RenderReplaced::positionForCoordinates(int x, int y)
{
    InlineBox* box = inlineBoxWrapper();
    if (!box)
        return VisiblePosition(element(), 0, DOWNSTREAM);

    // FIXME: This code is buggy if the replaced element is relative positioned.

    RootInlineBox* root = box->root();

    int top = root->topOverflow();
    int bottom = root->nextRootBox() ? root->nextRootBox()->topOverflow() : root->bottomOverflow();

    if (y + yPos() < top)
        return VisiblePosition(element(), caretMinOffset(), DOWNSTREAM); // coordinates are above

    if (y + yPos() >= bottom)
        return VisiblePosition(element(), caretMaxOffset(), DOWNSTREAM); // coordinates are below

    if (element()) {
        if (x <= width() / 2)
            return VisiblePosition(element(), 0, DOWNSTREAM);
        return VisiblePosition(element(), 1, DOWNSTREAM);
    }

    return RenderBox::positionForCoordinates(x, y);
}
示例#2
0
bool RenderFrameSet::userResize(MouseEvent* evt)
{
    if (!m_isResizing) {
        if (needsLayout())
            return false;
        if (evt->type() == eventNames().mousedownEvent && evt->button() == LeftButton) {
            startResizing(m_cols, evt->pageX() - xPos());
            startResizing(m_rows, evt->pageY() - yPos());
            if (m_cols.m_splitBeingResized != noSplit || m_rows.m_splitBeingResized != noSplit) {
                setIsResizing(true);
                return true;
            }
        }
    } else {
        if (evt->type() == eventNames().mousemoveEvent || (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton)) {
            continueResizing(m_cols, evt->pageX() - xPos());
            continueResizing(m_rows, evt->pageY() - yPos());
            if (evt->type() == eventNames().mouseupEvent && evt->button() == LeftButton) {
                setIsResizing(false);
                return true;
            }
        }
    }

    return false;
}
void GameplayScreen::onEntry() {
    b2Vec2 gravity(0.0f, -25.0);
    m_world = std::make_unique<b2World>(gravity);

    m_debugRenderer.init();

    // Make the ground
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set(0.0f, -20.0f);
    b2Body* groundBody = m_world->CreateBody(&groundBodyDef);
    // Make the ground fixture
    b2PolygonShape groundBox;
    groundBox.SetAsBox(50.0f, 10.0f);
    groundBody->CreateFixture(&groundBox, 0.0f);

    // Load the texture
    m_texture = Bengine::ResourceManager::getTexture("Assets/bricks_top.png");

    // Make a bunch of boxes
    std::mt19937 randGenerator;
    std::uniform_real_distribution<float> xPos(-10.0, 10.0f);
    std::uniform_real_distribution<float> yPos(-10.0, 25.0f);
    std::uniform_real_distribution<float> size(0.5, 2.5f);
    std::uniform_int_distribution<int> color(50, 255);
    const int NUM_BOXES = 100;

    for (int i = 0; i < NUM_BOXES; i++) {
        Bengine::ColorRGBA8 randColor;
        randColor.r = color(randGenerator);
        randColor.g = color(randGenerator);
        randColor.b = color(randGenerator);
        randColor.a = 255;
        Box newBox;
        newBox.init(m_world.get(), glm::vec2(xPos(randGenerator), yPos(randGenerator)), glm::vec2(size(randGenerator), size(randGenerator)), m_texture, randColor, false);
        m_boxes.push_back(newBox);
    }

    // Initialize spritebatch
    m_spriteBatch.init();

    // Shader init
    // Compile our color shader
    m_textureProgram.compileShaders("Shaders/textureShading.vert", "Shaders/textureShading.frag");
    m_textureProgram.addAttribute("vertexPosition");
    m_textureProgram.addAttribute("vertexColor");
    m_textureProgram.addAttribute("vertexUV");
    m_textureProgram.linkShaders();

    // Init camera
    m_camera.init(m_window->getScreenWidth(), m_window->getScreenHeight());
    m_camera.setScale(32.0f);

    // Init player
    m_player.init(m_world.get(), glm::vec2(0.0f, 30.0f), glm::vec2(1.0f, 2.0f), Bengine::ColorRGBA8(255, 255, 255, 255));
}
示例#4
0
void RootInlineBox::placeEllipsis(const AtomicString& ellipsisStr,  bool ltr, int blockEdge, int ellipsisWidth,
                                  InlineBox* markupBox)
{
    // Create an ellipsis box.
    EllipsisBox* ellipsisBox = new (m_object->renderArena()) EllipsisBox(m_object, ellipsisStr, this,
                                                              ellipsisWidth - (markupBox ? markupBox->width() : 0),
                                                              yPos(), height(), baseline(), !prevRootBox(),
                                                              markupBox);
    
    if (!gEllipsisBoxMap)
        gEllipsisBoxMap = new EllipsisBoxMap();
    gEllipsisBoxMap->add(this, ellipsisBox);
    m_hasEllipsisBox = true;

    if (ltr && (xPos() + width() + ellipsisWidth) <= blockEdge) {
        ellipsisBox->m_x = xPos() + width();
        return;
    }

    // Now attempt to find the nearest glyph horizontally and place just to the right (or left in RTL)
    // of that glyph.  Mark all of the objects that intersect the ellipsis box as not painting (as being
    // truncated).
    bool foundBox = false;
    ellipsisBox->m_x = placeEllipsisBox(ltr, blockEdge, ellipsisWidth, foundBox);
}
示例#5
0
FloatRect RenderSVGText::relativeBBox(bool includeStroke) const
{
    FloatRect repaintRect;

    for (InlineRunBox* runBox = firstLineBox(); runBox; runBox = runBox->nextLineBox()) {
        ASSERT(runBox->isInlineFlowBox());

        InlineFlowBox* flowBox = static_cast<InlineFlowBox*>(runBox);
        for (InlineBox* box = flowBox->firstChild(); box; box = box->nextOnLine())
            repaintRect.unite(FloatRect(box->xPos(), box->yPos(), box->width(), box->height()));
    }

    // SVG needs to include the strokeWidth(), not the textStrokeWidth().
    if (includeStroke && style()->svgStyle()->hasStroke()) {
        float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(this, style()->svgStyle()->strokeWidth(), 0.0f);

#if ENABLE(SVG_FONTS)
        const Font& font = style()->font();
        if (font.primaryFont()->isSVGFont()) {
            float scale = font.unitsPerEm() > 0 ? font.size() / font.unitsPerEm() : 0.0f;

            if (scale != 0.0f)
                strokeWidth /= scale;
        }
#endif

        repaintRect.inflate(strokeWidth);
    }

    repaintRect.move(xPos(), yPos());
    return repaintRect;
}
示例#6
0
static	void	rectControl(FILE *fp, object ctl)
{
	CTLTYPE_RECT_t	v;
	char	*cp, name[81];
	static	int	id = 1;

	return;

	gGetControlParameters(ctl, &v);

	if (!strcmp(v.name, "STATIC"))
		sprintf(name, "staticText%d", id++);
	else
		strcpy(name, v.name);
	fprintf(fp, "createClassObject(mx.controls.Label, \"%s\", getNextHighestDepth(), {});\n", name);
	fprintf(fp, "%s.move(%d * ScalingFactor, %d * ScalingFactor);\n", name, xPos(v.xPos), yPos(v.yPos));
	fprintf(fp, "%s.setSize(%d * ScalingFactor, %d * ScalingFactor);\n", name, width(v.width), height(v.height));
	fprintf(fp, "box(%d, %d, %d, %d);\n", yPos(v.yPos), xPos(v.xPos), width(v.width), height(v.height));
	setFont(fp, ctl, name);

	if (v.DT_Format & DT_CENTER)
		fprintf(fp, "%s.setStyle(\"textAlign\", \"%s\");\n", name, "center");
	else if (v.DT_Format & DT_RIGHT)
		fprintf(fp, "%s.setStyle(\"textAlign\", \"%s\");\n", name, "right");
	if (v.hidden == 'Y')
		fprintf(fp, "%s.visible = false;\n", name);
/*
	if (v.disabled == 'Y')
		fprintf(fp, "%s.enabled = false;\n", name);
*/
	cp = gStringValue(ctl);
	fprintf(fp, "%s.text = \"%s\";\n", name, cp?cp:"");
	fprintf(fp, "\n");
}
//--------------------------------------------------------------------------------------------------
/// Draw the axis labels
//--------------------------------------------------------------------------------------------------
void OverlayNavigationCube::renderAxisLabels(OpenGLContext* oglContext, bool software, const MatrixState& matrixState)
{
    // Multiply with 1.08 will slightly pull the labels away from the corresponding arrow head
    Vec3f xPos(1.08f, 0, 0);
    Vec3f yPos(0, 1.08f, 0);
    Vec3f zPos(0, 0, 1.08f);

    DrawableText drawableText;
    drawableText.setFont(m_font.p());
    drawableText.setCheckPosVisible(false);
    drawableText.setDrawBorder(false);
    drawableText.setDrawBackground(false);
    drawableText.setVerticalAlignment(TextDrawer::CENTER);
    drawableText.setTextColor(m_textColor);

    if (!m_xLabel.isEmpty()) drawableText.addText(m_xLabel, xPos);
    if (!m_yLabel.isEmpty()) drawableText.addText(m_yLabel, yPos);
    if (!m_zLabel.isEmpty()) drawableText.addText(m_zLabel, zPos);


    // Do the actual rendering
    // -----------------------------------------------
    if (software)
    {
        drawableText.renderSoftware(oglContext, matrixState);
    }
    else
    {
        ref<ShaderProgram> textShader = oglContext->resourceManager()->getLinkedTextShaderProgram(oglContext);
        drawableText.render(oglContext, textShader.p(), matrixState);
    }
}
IntRect RenderReplaced::selectionRect(bool clipToVisibleContent)
{
    ASSERT(!needsLayout());

    if (!isSelected())
        return IntRect();
    if (!m_inlineBoxWrapper)
        // We're a block-level replaced element.  Just return our own dimensions.
        return absoluteBoundingBoxRect();

    RenderBlock* cb =  containingBlock();
    if (!cb)
        return IntRect();

    RootInlineBox* root = m_inlineBoxWrapper->root();
    IntRect rect(0, root->selectionTop() - yPos(), width(), root->selectionHeight());

    if (clipToVisibleContent)
        computeAbsoluteRepaintRect(rect);
    else {
        int absx, absy;
        absolutePositionForContent(absx, absy);
        rect.move(absx, absy);
    }

    return rect;
}
示例#9
0
void PrimitiveMeshHelper::WireAxis(float size) {
  DrawCmdData<Vertex> cmd;
  cmd.draw_mode = kDrawLines;
  VertexList &vert_list = cmd.vertex_list;

  //vertex list 생성
  vec3 xPos(size, 0, 0);
  vec3 yPos(0, size, 0);
  vec3 zPos(0, 0, size);
  vec3 zero(0, 0, 0);

  sora::vec4ub red(255, 0, 0, 255);
  sora::vec4ub green(0, 255, 0, 255);
  sora::vec4ub blue(0, 0, 255, 255);
  
  {
    // x axis - r
    Vertex x_zero_vert;
    x_zero_vert.color = red;
    x_zero_vert.pos = zero;
    vert_list.push_back(x_zero_vert);

    Vertex x_one_vert;
    x_one_vert.color = red;
    x_one_vert.pos = xPos;
    vert_list.push_back(x_one_vert);
  }
  {
    //y axis - g
    Vertex zero_vert;
    zero_vert.color = green;
    zero_vert.pos = zero;
    vert_list.push_back(zero_vert);

    Vertex y_vert;
    y_vert.color = green;
    y_vert.pos = yPos;
    vert_list.push_back(y_vert);
  }
  {
    //z axis - b
    Vertex zero_vert;
    zero_vert.color = blue;
    zero_vert.pos = zero;
    vert_list.push_back(zero_vert);

    Vertex z_vert;
    z_vert.color = blue;
    z_vert.pos = zPos;
    vert_list.push_back(z_vert);
  }
  this->cmd_list_->push_back(cmd);
}
示例#10
0
IntRect RenderReplaced::localSelectionRect(bool checkWhetherSelected) const
{
    if (checkWhetherSelected && !isSelected())
        return IntRect();

    if (!m_inlineBoxWrapper)
        // We're a block-level replaced element.  Just return our own dimensions.
        return IntRect(0, 0, width(), height() + borderTopExtra() + borderBottomExtra());

    RenderBlock* cb =  containingBlock();
    if (!cb)
        return IntRect();
    
    RootInlineBox* root = m_inlineBoxWrapper->root();
    return IntRect(0, root->selectionTop() - yPos(), width(), root->selectionHeight());
}
示例#11
0
void RenderSVGTSpan::absoluteRects(Vector<IntRect>& rects, int, int, bool)
{
    InlineRunBox* firstBox = firstLineBox();

    SVGRootInlineBox* rootBox = firstBox ? static_cast<SVGInlineTextBox*>(firstBox)->svgRootInlineBox() : 0;
    RenderObject* object = rootBox ? rootBox->object() : 0;

    if (!object)
        return;

    int xRef = object->xPos() + xPos();
    int yRef = object->yPos() + yPos();
 
    for (InlineRunBox* curr = firstBox; curr; curr = curr->nextLineBox()) {
        FloatRect rect(xRef + curr->xPos(), yRef + curr->yPos(), curr->width(), curr->height());
        rects.append(enclosingIntRect(absoluteTransform().mapRect(rect)));
    }
}
示例#12
0
FloatRect RenderSVGText::relativeBBox(bool includeStroke) const
{
    FloatRect repaintRect;

    for (InlineRunBox* runBox = firstLineBox(); runBox; runBox = runBox->nextLineBox()) {
        ASSERT(runBox->isInlineFlowBox());

        InlineFlowBox* flowBox = static_cast<InlineFlowBox*>(runBox);
        for (InlineBox* box = flowBox->firstChild(); box; box = box->nextOnLine())
            repaintRect.unite(FloatRect(box->xPos(), box->yPos(), box->width(), box->height()));
    }

    // SVG needs to include the strokeWidth(), not the textStrokeWidth().
    if (includeStroke && style()->svgStyle()->hasStroke())
        repaintRect.inflate(narrowPrecisionToFloat(KSVGPainterFactory::cssPrimitiveToLength(this, style()->svgStyle()->strokeWidth(), 0.0)));

    repaintRect.move(xPos(), yPos());
    return repaintRect;
}
示例#13
0
void RenderSVGTextPath::absoluteQuads(Vector<FloatQuad>& quads, bool)
{
    InlineRunBox* firstBox = firstLineBox();

    SVGRootInlineBox* rootBox = firstBox ? static_cast<SVGInlineTextBox*>(firstBox)->svgRootInlineBox() : 0;
    RenderObject* object = rootBox ? rootBox->object() : 0;

    if (!object)
        return;

    int xRef = object->xPos() + xPos();
    int yRef = object->yPos() + yPos();

    for (InlineRunBox* curr = firstBox; curr; curr = curr->nextLineBox()) {
        FloatRect rect(xRef + curr->xPos(), yRef + curr->yPos(), curr->width(), curr->height());
        // FIXME: broken with CSS transforms
        quads.append(absoluteTransform().mapRect(rect));
    }
}
示例#14
0
IntRect RenderListMarker::selectionRect(bool clipToVisibleContent)
{
    ASSERT(!needsLayout());

    if (selectionState() == SelectionNone || !inlineBoxWrapper())
        return IntRect();

    RootInlineBox* root = inlineBoxWrapper()->root();
    IntRect rect(0, root->selectionTop() - yPos(), width(), root->selectionHeight());
            
    if (clipToVisibleContent)
        computeAbsoluteRepaintRect(rect);
    else {
        int absx, absy;
        absolutePosition(absx, absy);
        rect.move(absx, absy);
    }
    
    return rect;
}
示例#15
0
//------------------------------ PUBLIC SLOTS ----------------------------------
void ViewPort::showPage(int p_number)
{
    curPixmapNumber = p_number;
    scene->clear();
    qreal xPos(5);
    qreal yPos(5);
    if (m_thumb){
        // Режим наготков :) рисуем все а стр с номером p_number выделяем
        for (int i=0;i<m_pixmap_list.size();i++){
            if (i == curPixmapNumber){
                yPos = addPairItem(xPos,yPos,i,true);
            }else{
                yPos = addPairItem(xPos,yPos,i,false);
            }
        }
    }else{
        // Рисуем одну страницу на весь экран
        if (m_pixmap_list.contains(curPixmapNumber)){
            yPos = addPairItem(xPos,yPos,curPixmapNumber,false);
        }
    }
}
示例#16
0
void eParentalSetup::init_eParentalSetup()
{
	loadSettings();

	parentallock=new eCheckbox(this, parentalpin_enabled, 1);
	parentallock->setText(_("Parental lock"));
	parentallock->move(ePoint(10, yPos()));
	parentallock->resize(eSize(200, widgetHeight()));
	parentallock->setHelpText(_("enable/disable parental lock"));
	CONNECT(parentallock->checked, eParentalSetup::plockChecked );

	changeParentalPin = new eButton(this);
	changeParentalPin->setText(_("change PIN"));
	changeParentalPin->move(ePoint(230, yPos()));
	changeParentalPin->resize(eSize(160, widgetHeight()));
	changeParentalPin->setHelpText(_("change Parental PIN (ok)"));
	changeParentalPin->loadDeco();
	CONNECT(changeParentalPin->selected_id, eParentalSetup::changePin );
	if ( !parentalpin_enabled )
	{
		changeParentalPin->hide();
	}

	nextYPos(35);  
	setuplock=new eCheckbox(this, setuppin_enabled, 1);
	setuplock->setText(_("Setup lock"));
	setuplock->move(ePoint(10, yPos()));
	setuplock->resize(eSize(200, widgetHeight()));
	setuplock->setHelpText(_("enable/disable setup lock"));
	CONNECT(setuplock->checked, eParentalSetup::slockChecked );

	changeSetupPin = new eButton(this);
	changeSetupPin->setText(_("change PIN"));
	changeSetupPin->move( ePoint( 230, yPos()));
	changeSetupPin->resize( eSize(160, widgetHeight()));
	changeSetupPin->setHelpText(_("change Setup PIN (ok)"));
	changeSetupPin->loadDeco();
	CONNECT(changeSetupPin->selected_id, eParentalSetup::changePin );
	if ( !setuppin_enabled )
	{
		changeSetupPin->hide();
	}

	nextYPos(35);  
	pin_timeout_label = new eLabel (this);
	pin_timeout_label->setText (_("Pin timeout"));
	pin_timeout_label->move (ePoint (10, yPos()));
	pin_timeout_label->resize (eSize (370, widgetHeight()));

	pin_timeout = new eNumber (this, 1, 0, 999, 4, &pintimeout, 0, pin_timeout_label);
	pin_timeout->move (ePoint (230, yPos()));
	pin_timeout->resize (eSize (50, widgetHeight()));
	pin_timeout->setHelpText (_("Number of minutes the entered pin is valid. After this timeout you need to re-enter the pin when zapping to protected service (0 to disable)"));
	pin_timeout->loadDeco();

	nextYPos(35);  
	maxpin_errors_label = new eLabel (this);
	maxpin_errors_label->setText (_("Max Pin errors"));
	maxpin_errors_label->move (ePoint (10, yPos()));
	maxpin_errors_label->resize (eSize (370, widgetHeight()));

	maxpin_errors = new eNumber (this, 1, 0, 999, 4, &maxpinerrors, 0, maxpin_errors_label);
	maxpin_errors->move (ePoint (230, yPos()));
	maxpin_errors->resize (eSize (50, widgetHeight()));
	maxpin_errors->setHelpText (_("Maximum number of chances to enter correct pin. When pin is entered wrong for x times the pin validation will be blocked temporarily (0 to disable)"));
	maxpin_errors->loadDeco();

	nextYPos(35);  
	pinerror_block_time_label = new eLabel (this);
	pinerror_block_time_label->setText (_("Pin block timeout"));
	pinerror_block_time_label->move (ePoint (10, yPos()));
	pinerror_block_time_label->resize (eSize (370, widgetHeight()));

	pinerror_block_time = new eNumber (this, 1, 1, 999, 4, &pinerrorblocktime, 0, pinerror_block_time_label);
	pinerror_block_time->move (ePoint (230, yPos()));
	pinerror_block_time->resize (eSize (50, widgetHeight()));
	pinerror_block_time->setHelpText (_("Number of minutes pincode check is disabled when pin validation has failed maximum times."));
	pinerror_block_time->loadDeco();

	nextYPos(35);  
	hidelocked=new eCheckbox(this, shidelocked, 1);
	hidelocked->setText(_("Hide locked services"));
	hidelocked->move(ePoint(10, yPos()));
	hidelocked->resize(eSize(380, widgetHeight()));
	hidelocked->setHelpText(_("don't show locked services in any list"));
	hidelocked->loadDeco();
	CONNECT(hidelocked->checked, eParentalSetup::hidelockChecked );
	if ( !parentalpin_enabled )
	{
		hidelocked->hide();
	}

	/* help text for parental setup */
	setHelpText(_("\tParental Lock\n\n>>> [MENU] >>> [6] Setup >>> [5] Parental Lock\n. . . . . . . . . .\n\n" \
								"Here you can enable and setup Parental Lock. After reboot locked channels will not be available unless unlocked with your PIN code\n" \
								". . . . . . . . . .\n\nUsage:\n\n[UP]/[DOWN]\tSelect Inputfield or Button\n\nParental lock\tToggle Channel access on/off\n\n" \
								"Setup lock\tToggle setup access on/off\n\nChange PIN\tEnter a new PIN code\n\n[GREEN]\tSave Settings and Close Window\n\n" \
								"[EXIT]\tClose window without saving changes"));
								

	buildWindow();

	CONNECT(bOK->selected, eParentalSetup::okPressed);
}
示例#17
0
VisiblePosition RenderContainer::positionForCoordinates(int x, int y)
{
    // no children...return this render object's element, if there is one, and offset 0
    if (!m_firstChild)
        return VisiblePosition(element(), 0, DOWNSTREAM);

    if (isTable() && element()) {
        int right = contentWidth() + borderRight() + paddingRight() + borderLeft() + paddingLeft();
        int bottom = contentHeight() + borderTop() + paddingTop() + borderBottom() + paddingBottom();

        if (x < 0 || x > right || y < 0 || y > bottom) {
            if (x <= right / 2)
                return VisiblePosition(Position(element(), 0));
            else
                return VisiblePosition(Position(element(), maxDeepOffset(element())));
        }
    }

    // Pass off to the closest child.
    int minDist = INT_MAX;
    RenderObject* closestRenderer = 0;
    int newX = x;
    int newY = y;
    if (isTableRow()) {
        newX += xPos();
        newY += yPos();
    }
    for (RenderObject* renderer = m_firstChild; renderer; renderer = renderer->nextSibling()) {
        if (!renderer->firstChild() && !renderer->isInline() && !renderer->isBlockFlow()
                || renderer->style()->visibility() != VISIBLE)
            continue;

        int top = borderTop() + paddingTop() + (isTableRow() ? 0 : renderer->yPos());
        int bottom = top + renderer->contentHeight();
        int left = borderLeft() + paddingLeft() + (isTableRow() ? 0 : renderer->xPos());
        int right = left + renderer->contentWidth();

        if (x <= right && x >= left && y <= top && y >= bottom) {
            if (renderer->isTableRow())
                return renderer->positionForCoordinates(x + newX - renderer->xPos(), y + newY - renderer->yPos());
            return renderer->positionForCoordinates(x - renderer->xPos(), y - renderer->yPos());
        }

        // Find the distance from (x, y) to the box.  Split the space around the box into 8 pieces
        // and use a different compare depending on which piece (x, y) is in.
        IntPoint cmp;
        if (x > right) {
            if (y < top)
                cmp = IntPoint(right, top);
            else if (y > bottom)
                cmp = IntPoint(right, bottom);
            else
                cmp = IntPoint(right, y);
        } else if (x < left) {
            if (y < top)
                cmp = IntPoint(left, top);
            else if (y > bottom)
                cmp = IntPoint(left, bottom);
            else
                cmp = IntPoint(left, y);
        } else {
            if (y < top)
                cmp = IntPoint(x, top);
            else
                cmp = IntPoint(x, bottom);
        }

        int x1minusx2 = cmp.x() - x;
        int y1minusy2 = cmp.y() - y;

        int dist = x1minusx2 * x1minusx2 + y1minusy2 * y1minusy2;
        if (dist < minDist) {
            closestRenderer = renderer;
            minDist = dist;
        }
    }

    if (closestRenderer)
        return closestRenderer->positionForCoordinates(newX - closestRenderer->xPos(), newY - closestRenderer->yPos());

    return VisiblePosition(element(), 0, DOWNSTREAM);
}
示例#18
0
void VisibilityLayout::layout(GraphAttributes &GA, const UpwardPlanRep &UPROrig)
{
	UpwardPlanRep UPR = UPROrig;

	//clear some data
	for(edge e : GA.constGraph().edges) {
		GA.bends(e).clear();
	}

	int minGridDist = 1;
	for(node v : GA.constGraph().nodes) {
		if (minGridDist < max(GA.height(v), GA.width(v)))
			minGridDist = (int) max(GA.height(v), GA.width(v));
	}
	minGridDist = max(minGridDist*2+1, m_grid_dist);

	CombinatorialEmbedding &gamma = UPR.getEmbedding();
	//add edge (s,t)
	adjEntry adjSrc = nullptr;
	for(adjEntry adj : UPR.getSuperSource()->adjEntries) {
		if (gamma.rightFace(adj) == gamma.externalFace())
			adjSrc = adj;
			break;
	}

	OGDF_ASSERT(adjSrc != nullptr);

	edge e_st = UPR.newEdge(adjSrc, UPR.getSuperSink()); // on the right
	gamma.computeFaces();
	gamma.setExternalFace(gamma.rightFace(e_st->adjSource()));

	constructVisibilityRepresentation(UPR);

	// the preliminary postion
	NodeArray<int> xPos(UPR);
	NodeArray<int> yPos(UPR);

	// node Position
	for(node v : UPR.nodes) {
		NodeSegment vVis = nodeToVis[v];
		int x = (int) (vVis.x_l + vVis.x_r)/2 ; // median positioning
		xPos[v] = x;
		yPos[v] = vVis.y;

		if (UPR.original(v) != nullptr) {
			node vOrig = UPR.original(v);
			//final position
			GA.x(vOrig) = x * minGridDist;
			GA.y(vOrig)	= vVis.y * minGridDist;
		}
	}

	//compute bendpoints
	for(edge e : GA.constGraph().edges) {
		const List<edge> &chain = UPR.chain(e);
		for(edge eUPR : chain) {
			EdgeSegment eVis = edgeToVis[eUPR];
			if (chain.size() == 1) {
				if ((yPos[eUPR->target()] - yPos[eUPR->source()]) > 1) {
					DPoint p1(eVis.x*minGridDist, (yPos[eUPR->source()]+1)*minGridDist);
					DPoint p2(eVis.x*minGridDist, (yPos[eUPR->target()]-1)*minGridDist);
					GA.bends(e).pushBack(p1);
					if (yPos[eUPR->source()]+1 != yPos[eUPR->target()]-1)
						GA.bends(e).pushBack(p2);
				}
			}
			else {
				//short edge
				if ((yPos[eUPR->target()] - yPos[eUPR->source()]) == 1) {
					if (UPR.original(eUPR->target()) == nullptr) {
						node tgtUPR = eUPR->target();
						DPoint p(xPos[tgtUPR]*minGridDist, yPos[tgtUPR]*minGridDist);
						GA.bends(e).pushBack(p);
					}
				}
				//long edge
				else {
					DPoint p1(eVis.x*minGridDist, (yPos[eUPR->source()]+1)*minGridDist);
					DPoint p2(eVis.x*minGridDist, (yPos[eUPR->target()]-1)*minGridDist);
					GA.bends(e).pushBack(p1);
					if (yPos[eUPR->source()]+1 != yPos[eUPR->target()]-1)
						GA.bends(e).pushBack(p2);
					if (UPR.original(eUPR->target()) == nullptr) {
						node tgtUPR = eUPR->target();
						DPoint p(xPos[tgtUPR]*minGridDist, yPos[tgtUPR]*minGridDist);
						GA.bends(e).pushBack(p);
					}
				}
			}
		}

		DPolyline &poly = GA.bends(e);
		DPoint pSrc(GA.x(e->source()), GA.y(e->source()));
		DPoint pTgt(GA.x(e->target()), GA.y(e->target()));
		poly.normalize(pSrc, pTgt);
	}
}
示例#19
0
IntRect RenderSVGInlineText::computeAbsoluteRectForRange(int startPos, int endPos)
{
    IntRect rect;

    RenderBlock* cb = containingBlock();
    if (!cb || !cb->container())
        return rect;

    RenderSVGRoot* root = findSVGRootObject(parent());
    if (!root)
        return rect;

    for (InlineTextBox* box = firstTextBox(); box; box = box->nextTextBox())
        rect.unite(box->selectionRect(0, 0, startPos, endPos));

    // Mimic RenderBox::computeAbsoluteRepaintRect() functionality. But only the subset needed for SVG and respecting SVG transformations.
    int x, y;
    cb->container()->absolutePosition(x, y);

    // Remove HTML parent translation offsets here! These need to be retrieved from the RenderSVGRoot object.
    // But do take the containingBlocks's container position into account, ie. SVG text in scrollable <div>.
    AffineTransform htmlParentCtm = root->RenderContainer::absoluteTransform();

    FloatRect fixedRect(narrowPrecisionToFloat(rect.x() + x - xPos() - htmlParentCtm.e()), narrowPrecisionToFloat(rect.y() + y - yPos() - htmlParentCtm.f()), rect.width(), rect.height());
    return enclosingIntRect(absoluteTransform().mapRect(fixedRect));
}
示例#20
0
void GameplayScreen::onEntry() {

    b2Vec2 gravity(0.0f, -25.0);
    m_world = std::make_unique<b2World>(gravity);

    m_debugRenderer.init();

    // Make the ground
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set(0.0f, -20.0f);
    b2Body* groundBody = m_world->CreateBody(&groundBodyDef);
    // Make the ground fixture
    b2PolygonShape groundBox;
    groundBox.SetAsBox(50.0f, 10.0f);
    groundBody->CreateFixture(&groundBox, 0.0f);

    // Load the texture
    m_texture = Bengine::ResourceManager::getTexture("Assets/bricks_top.png");

    // Make a bunch of boxes
    std::mt19937 randGenerator;
    std::uniform_real_distribution<float> xPos(-10.0, 10.0f);
    std::uniform_real_distribution<float> yPos(-10.0, 25.0f);
    std::uniform_real_distribution<float> size(0.5, 2.5f);
    std::uniform_int_distribution<int> color(50, 255);
    const int NUM_BOXES = 10;

    for (int i = 0; i < NUM_BOXES; i++) {
        Bengine::ColorRGBA8 randColor;
        randColor.r = color(randGenerator);
        randColor.g = color(randGenerator);
        randColor.b = color(randGenerator);
        randColor.a = 255;
        Box newBox;
        newBox.init(m_world.get(), glm::vec2(xPos(randGenerator), yPos(randGenerator)), glm::vec2(size(randGenerator), size(randGenerator)), m_texture, randColor, false);
        m_boxes.push_back(newBox);
    }

    // Initialize spritebatch
    m_spriteBatch.init();

    // Shader init
    // Compile our texture
    m_textureProgram.compileShaders("Shaders/textureShading.vert", "Shaders/textureShading.frag");
    m_textureProgram.addAttribute("vertexPosition");
    m_textureProgram.addAttribute("vertexColor");
    m_textureProgram.addAttribute("vertexUV");
    m_textureProgram.linkShaders();
    // Compile our light shader
    m_lightProgram.compileShaders("Shaders/lightShading.vert", "Shaders/lightShading.frag");
    m_lightProgram.addAttribute("vertexPosition");
    m_lightProgram.addAttribute("vertexColor");
    m_lightProgram.addAttribute("vertexUV");
    m_lightProgram.linkShaders();

    // Init camera
    m_camera.init(m_window->getScreenWidth(), m_window->getScreenHeight());
    m_camera.setScale(32.0f);

    // Init player
    m_player.init(m_world.get(), glm::vec2(0.0f, 30.0f), glm::vec2(2.0f), glm::vec2(1.0f, 1.8f), Bengine::ColorRGBA8(255, 255, 255, 255));

    // Init the UI
    m_gui.init("GUI");
    m_gui.loadScheme("TaharezLook.scheme");
    m_gui.setFont("DejaVuSans-10");
    CEGUI::PushButton* testButton = static_cast<CEGUI::PushButton*>(m_gui.createWidget("TaharezLook/Button", glm::vec4(0.5f, 0.5f, 0.1f, 0.05f), glm::vec4(0.0f), "TestButton"));
    testButton->setText("Hello World!");

    CEGUI::Combobox* TestCombobox = static_cast<CEGUI::Combobox*>(m_gui.createWidget("TaharezLook/Combobox", glm::vec4(0.2f, 0.2f, 0.1f, 0.05f), glm::vec4(0.0f), "TestCombobox"));

    m_gui.setMouseCursor("TaharezLook/MouseArrow");
    m_gui.showMouseCursor();
    SDL_ShowCursor(0);
}
void GameplayScreen::init()
{
	b2Vec2 gravity(0.0f, -50.0f);
	//create up world
	mWorld = std::make_unique<b2World>(gravity);

	//Add Ground body
	b2BodyDef groundBodyDef;
	groundBodyDef.position.Set(0.0f, -20.0f); // units of meters
	b2Body* groundBody = mWorld->CreateBody(&groundBodyDef);
	//Shape is a polygon, fixture keeps them together
	b2PolygonShape groundBox;
	groundBox.SetAsBox(50.0f, 10.0f);
	groundBody->CreateFixture(&groundBox, 0.0f);

	//Load texture
	mTexture = WebEngine::ResourceManager::getTexture("Assets/bricks_top.png");

	WebEngine::ColorRGBA8 color(255, 0, 0, 255);

	//Add a bunch of boxes
	std::mt19937 randGenerator(time(nullptr));
	std::uniform_real_distribution<float> xPos(-10.0f, 10.0f);
	std::uniform_real_distribution<float> yPos(-15.0f, 15.0f);
	std::uniform_real_distribution<float> size(0.5f, 2.5f);
	std::uniform_int_distribution<unsigned int> randColor(0, 255);
	const int numBoxes = 20;

	for (int i = 0; i < numBoxes; i++)
	{
		WebEngine::ColorRGBA8 color(randColor(randGenerator), randColor(randGenerator), randColor(randGenerator), 255);
		Box newBox;
		newBox.init(mWorld.get(), glm::vec2(xPos(randGenerator), yPos(randGenerator)), glm::vec2(size(randGenerator), size(randGenerator)), mTexture, color);
		//Box memory can be discraded because the important bits are stored in the world
		mBoxes.push_back(newBox);
	}

	//Initialize shaders
	//Compile texture shader
	mTextureProgram.compileShaders("Shaders/textureShading.vert", "Shaders/textureShading.frag");
	mTextureProgram.addAttribute("vertexPosition");
	mTextureProgram.addAttribute("vertexColor");
	mTextureProgram.addAttribute("vertexUV");
	mTextureProgram.linkShaders();
	//Compile light shader
	mLightProgram.compileShaders("Shaders/lightShading.vert", "Shaders/lightShading.frag");
	mLightProgram.addAttribute("vertexPosition");
	mLightProgram.addAttribute("vertexColor");
	mLightProgram.addAttribute("vertexUV");
	mLightProgram.linkShaders();

	mDebugRenderer.init();
	m_CameraController.init(&mCamera, mTime);
	//Initialize spritebatch
	mSpriteBatch.init();

	//Init camera
	mCamera.init(mWindow->getScreenWidth(), mWindow->getScreenHeight());
	mCamera.setScale(32.0f); //32 pixels per meter, good scale

	mPlayer.init(mWorld.get(), glm::vec2(0.0f, 30.0f), glm::vec2(1.0f), glm::vec2(0.5f, 1.0f), WebEngine::ColorRGBA8(255, 255, 255, 255));
}
示例#22
0
// initialize screen coordinates for tree
void TreeModel::SetTreeCoord(long degrees) {
    double bufferX, bufferY;
    if (BufferWi < 1) return;
    if (BufferHt < 1) return; // June 27,2013. added check to not divide by zero
    double RenderHt, RenderWi;
    if (degrees > 0) {
        double angle;
        RenderHt=BufferHt * 3;
        RenderWi=((double)RenderHt)/1.8;
        
        double radians=toRadians(degrees);
        double radius=RenderWi/2.0;
        double topradius=radius/botTopRatio;
        
        double StartAngle=-radians/2.0;
        double AngleIncr=radians/double(BufferWi);
        if (degrees < 350 && BufferWi > 1) {
            AngleIncr=radians/double(BufferWi - 1);
        }
        
        //shift a tiny bit to make the strands in back not line up exactly with the strands in front
        StartAngle += toRadians(rotation);
        
        std::vector<float> yPos(BufferHt);
        std::vector<float> xInc(BufferHt);
        for (int x = 0; x < BufferHt; x ++) {
            yPos[x] = x;
            xInc[x] = 0;
        }
        if (spiralRotations != 0.0f) {
            std::vector<float> lengths(10);
            float rgap = (radius - topradius)/ 10.0;
            float total = 0;
            for (int x = 0; x < 10; x++) {
                lengths[x] = 2.0*M_PI*(radius - rgap*x) - rgap/2.0;
                lengths[x] *= spiralRotations / 10.0;
                lengths[x] = sqrt(lengths[x]*lengths[x]+(float)BufferHt/10.0*(float)BufferHt/10.0);
                total += lengths[x];
            }
            int lights = 0;
            for (int x = 0; x < 10; x++) {
                lengths[x] /= total;
                lights += (int)std::round(lengths[x]*BufferHt);
            }
            int curSeg = 0;
            float lightsInSeg = std::round(lengths[0]*BufferHt);
            int curLightInSeg = 0;
            for (int x = 1; x < BufferHt; x++) {
                if (curLightInSeg >= lightsInSeg) {
                    curSeg++;
                    curLightInSeg = 0;
                    lightsInSeg = std::round(lengths[curSeg]*BufferHt);
                }
                float ang = spiralRotations * 2.0 * M_PI / 10.0;
                ang /= (float)lightsInSeg;
                yPos[x] = yPos[x-1] + (BufferHt/10.0/lightsInSeg);
                xInc[x] = xInc[x-1] + ang;
                curLightInSeg++;
            }
        }
        
        
        double topYoffset = std::abs(perspective * topradius * cos(M_PI));
        double ytop = RenderHt - topYoffset;
        double ybot = std::abs(perspective * radius * cos(M_PI));
        
        size_t NodeCount=GetNodeCount();
        for(size_t n=0; n<NodeCount; n++) {
            size_t CoordCount=GetCoordCount(n);
            for(size_t c=0; c < CoordCount; c++) {
                bufferX=Nodes[n]->Coords[c].bufX;
                bufferY=Nodes[n]->Coords[c].bufY;
                angle=StartAngle + double(bufferX) * AngleIncr + xInc[bufferY];
                double xb=radius * sin(angle);
                double xt=topradius * sin(angle);
                double yb = ybot - perspective * radius * cos(angle);
                double yt = ytop - perspective * topradius * cos(angle);
                double posOnString = 0.5;
                if (BufferHt > 1) {
                    posOnString = yPos[bufferY]/(double)(BufferHt-1.0);
                }

                Nodes[n]->Coords[c].screenX = xb + (xt - xb) * posOnString;
                Nodes[n]->Coords[c].screenY = yb + (yt - yb) * posOnString - ((double)RenderHt)/2.0;
            }
        }
    } else {
        double treeScale = degrees == -1 ? 5.0 : 4.0;
        double botWid = BufferWi * treeScale;
        RenderHt=BufferHt * 2.0;
        RenderWi=(botWid + 2);
        
        double offset = 0.5;
        size_t NodeCount=GetNodeCount();
        for(size_t n=0; n<NodeCount; n++) {
            size_t CoordCount=GetCoordCount(n);
            if (degrees == -1) {
                for(size_t c=0; c < CoordCount; c++) {
                    bufferX=Nodes[n]->Coords[c].bufX;
                    bufferY=Nodes[n]->Coords[c].bufY;
                    
                    double xt = (bufferX + offset - BufferWi/2.0) * 0.9;
                    double xb = (bufferX + offset - BufferWi/2.0) * treeScale;
                    double h = std::sqrt(RenderHt * RenderHt + (xt - xb)*(xt - xb));
                    
                    double posOnString = 0.5;
                    if (BufferHt > 1) {
                        posOnString = (bufferY/(double)(BufferHt-1.0));
                    }
                    
                    double newh = RenderHt * posOnString;
                    Nodes[n]->Coords[c].screenX = xb + (xt - xb) * posOnString;
                    Nodes[n]->Coords[c].screenY = RenderHt * newh / h - ((double)RenderHt)/2.0;
                    
                    posOnString = 0;
                    if (BufferHt > 1) {
                        posOnString = ((bufferY - 0.33)/(double)(BufferHt-1.0));
                    }

                    newh = RenderHt * posOnString;
                    Nodes[n]->Coords.push_back(Nodes[n]->Coords[c]);
                    Nodes[n]->Coords.back().screenX = xb + (xt - xb) * posOnString;
                    Nodes[n]->Coords.back().screenY = RenderHt * newh / h - ((double)RenderHt)/2.0;
                    
                    posOnString = 1;
                    if (BufferHt > 1) {
                        posOnString = ((bufferY + 0.33)/(double)(BufferHt-1.0));
                    }
                    newh = RenderHt * posOnString;
                    Nodes[n]->Coords.push_back(Nodes[n]->Coords[c]);
                    Nodes[n]->Coords.back().screenX = xb + (xt - xb) * posOnString;
                    Nodes[n]->Coords.back().screenY = RenderHt * newh / h - ((double)RenderHt)/2.0;
                }
                
            } else {
                for(size_t c=0; c < CoordCount; c++) {
                    bufferX=Nodes[n]->Coords[c].bufX;
                    bufferY=Nodes[n]->Coords[c].bufY;
                    
                    double xt = (bufferX + offset - BufferWi/2.0) * 0.9;
                    double xb = (bufferX + offset - BufferWi/2.0) * treeScale;
                    double posOnString = 0.5;
                    if (BufferHt > 1) {
                        posOnString = (bufferY/(double)(BufferHt-1.0));
                    }
                    Nodes[n]->Coords[c].screenX = xb + (xt - xb) * posOnString;
                    Nodes[n]->Coords[c].screenY = RenderHt * posOnString - ((double)RenderHt)/2.0;
                }
            }
        }
    }
    screenLocation.SetRenderSize(RenderWi, RenderHt);
}
示例#23
0
void LevelOneScreen::initLevel(){
	std::mt19937 randomEngine((unsigned int)time(NULL));
	std::uniform_int_distribution<int> randMonster(0, MONSTER_KIND-1);
	std::uniform_int_distribution<int> randomMovement(0,1000);
	std::uniform_int_distribution<int> randomItemNum(1, 10);
	std::uniform_int_distribution<int> randomItemKind(0, ITEM_KIND - 1);
	glm::vec4 playerArea;

	_level = std::make_unique<LevelManager>("Levels/Version1/level1.txt");
	

	// Objects Creation code goes here.

	

	std::uniform_int_distribution<int> yPos(3, _level->getHeight() - 3);
	std::uniform_int_distribution<int> xPos(3, _level->getWidth() - 3);

	//Monsters
	int i = 0;
	int count = 2;
	int numMonster = _level->getNumMonsters();
	_monsters.reserve(numMonster);
	while(i < numMonster){
		int temp = randMonster(randomEngine);
		int x = xPos(randomEngine);
		int y = yPos(randomEngine);
		int movement = ((randomMovement(randomEngine) * count) % MAX_MOVEMENT + count/2);
			if (_level->getSymbol(x, y) == '.'){
				glm::vec2 pos = glm::vec2(x * TILE_WIDTH, y * TILE_WIDTH);
				if (temp == 0){
					_monsters.push_back(new Werewolf);
					_monsters.back()->init(4, 2, pos, 10);
				}
				else if (temp == 1){
					_monsters.push_back(new Orga);
					_monsters.back()->init(3, 3, pos, 30);
				}
				else{
					_monsters.push_back(new Wolf);
					_monsters.back()->init(2, 2, pos, movement);
					//std::cout << "Movement : " <<  movement << std::endl;
				}

				i++;
			}
		count++;
	}

	//Testing
	/*_monsters.push_back(new Wolf);
	_monsters.back()->init(3, 3, glm::vec2(500, 1000));*/

	int numItem = randomItemNum(randomEngine);
	int j = 0;
	while (j < numItem) {
		int temp = randomItemKind(randomEngine);
		int x = xPos(randomEngine);
		int y = yPos(randomEngine);
		if (_level->getSymbol(x, y) == '.') {
			glm::vec2 pos = glm::vec2(x * TILE_WIDTH, y * TILE_WIDTH);
	
			switch (temp) {
				case 0:
					_items.push_back(new BigPotion);
					break;
				case 1:
					_items.push_back(new SmallPotion);
					break;
				case 2:
					_items.push_back(new GoodMeat);
					break;
				case 3:
					_items.push_back(new BadMeat);
					break;
				case 4:
					_items.push_back(new GoodFish);
					break;
				case 5:
					_items.push_back(new BadFish);
			}

			_items.back()->init(pos);
			j++;
		}
	}

	//Initialize player.
	_player = Player::getInstance();
	_player->init(_level->getStartPlayerPosition(), PLAYER_SPEED);


	//Testing for weapon.
	_items.push_back(new Sword);
	_items.back()->init(glm::vec2(200, 1000));


}
示例#24
0
文件: Mirror.cpp 项目: EQ4/JamomaMax
void Mirror::printPos() const
{
    post("/MirrorPos: %f, %f, %f", xPos(), yPos(), zPos());
}
示例#25
0
void Obstacle::DrawObstacle(int x, int y, SDL_Rect camera, float deltaTime, Player &player, SDL_Renderer* renderer)
{
    m_xPos = x;
    m_yPos = y;

    // Setting the collision box around the obstacle
    SDL_Rect collideRect = m_collisionRect;
    collideRect.x = m_collisionRect.x + x + camera.x;
    collideRect.y = m_collisionRect.y + y;

    // Setting the rect to draw the image
    SDL_Rect drawRect = {x-camera.x, y-camera.y, m_imgRect.w, m_imgRect.h};

    // Drawing the image
    // Only draw it if it's present on the screen
    if (m_xPos + m_imgRect.w > camera.x && m_xPos < SCREEN_WIDTH+camera.x && m_yPos + m_imgRect.h > camera.y && m_yPos < SCREEN_HEIGHT + camera.y)
        SDL_RenderCopy(renderer, m_obstaclesSheet, &m_imgRect, &drawRect);

    // Finding the sides of the player
    int playerLeftSide = player.xPos();
    int playerRightSide = player.xPos() + player.WIDTH;
    int playerTop = player.yPos();
    int playerBottom = player.yPos() + player.HEIGHT;

    // Finding the sides of the obstacle
    int obstLeftSide = collideRect.x;
    int obstRightSide = collideRect.x + collideRect.w;
    int obstTop = collideRect.y;
    int obstBottom = collideRect.y + collideRect.h;

    // If the player collided, check where he will respawn
    int playerYRespawn =  y+m_imgRect.h;

    if (m_name == "cliff" && player.yPos()+32 > y+20 && playerLeftSide < obstRightSide-3 &&
        playerRightSide > obstLeftSide+3 && playerTop < y+114)
    {
       if (player.yVel()<= player.SPEED/3)
            player.forceAirborne(0.05, player.SPEED/2.5f);
        else
            player.forceAirborne(0.05, player.SPEED*1.5);
    }

    //Checking for collision (Checking if the player and the obstacle overlap)
    if (!player.collided() && (playerBottom-20 < obstBottom) && m_canCollide && playerRightSide > obstLeftSide && 
        playerLeftSide < obstRightSide && playerTop < obstBottom && playerBottom > obstTop && 
        ((m_jumpable && !player.IsInAir()) || !m_jumpable))
    {
        player.obstCollidedWith(yPos(), m_imgRect.h);
        player.setCollision(true);
    }
    else if ((!player.collided() && (playerBottom-20 < obstBottom) && m_canCollide && playerRightSide > obstLeftSide &&
            playerLeftSide < obstRightSide && playerTop < obstBottom && playerBottom > obstTop && ((m_jumpable && player.IsInAir()))))
    {
        player.adjustMultiplier(m_pointsToGive);

    }
    // Make sure if the player is trying to respawn he doesn't respawn on another object
    else if (player.collided() && m_canCollide && playerRightSide > obstLeftSide && playerLeftSide < obstRightSide &&
             playerYRespawn < obstBottom && playerYRespawn+32 > obstTop)
    {
        player.obstCollidedWith(yPos(), m_imgRect.w);
    }
}
示例#26
0
EpgConfigDialog::EpgConfigDialog():
	ePLiWindow("EPG Configuration", 400),
	configPath(CONFIGDIR "/dbepg"),
	currentCfg(0)
{
	getConfig();
	/* abort if no valid configurations were found */
	if (configItems.size() == 0)
	{
		eMessageBox("No valid packages found. Please check your configuration.", "Error");
	}

	/* Selector for configuration */
	makeNewLabel(this, "Package", 10, yPos(), 130, widgetHeight());
	eComboBox *cb = new eComboBox(this);
	setWidgetGeom( cb, 190, yPos(), 200, widgetHeight());
	cb->setHelpText("Select the EPG provider");
	cb->loadDeco();
	cb->show();

	eListBoxEntryText *first = 0;
	for (std::map<eString, Config>::const_iterator it=configItems.begin(); it!=configItems.end(); ++it)
	{
		eListBoxEntryText *le= new eListBoxEntryText(*cb, it->second.getName());       //weird syntax....
		if (!first)
		{
			first = le;
		}
	}
	CONNECT(cb->selchanged, EpgConfigDialog::OnItemSelected);

	nextYPos(35);
	makeNewLabel(this, "Time offset", 10, yPos(), 130, widgetHeight());

	cTimeOffset = new eComboBox(this);
	setWidgetGeom( cTimeOffset, 190, yPos(), 200, widgetHeight());
	cTimeOffset->setHelpText("Select the time offset between EPG provider and your time zone");
	cTimeOffset->loadDeco();
	cTimeOffset->show();

	for (int i=-12; i<=12; i++)
	{
		char buf[30];
		sprintf(buf, "%2d hours", i);
		new eListBoxEntryText(*cTimeOffset, buf, (void*) i);       //weird syntax....
	}

	cTimeOffset->setCurrent((void*) 0); //will this work...

//     cTimeOffset = new eNumber(this, 1, -12, 12, 3, 0);
//     setWidgetGeom(cTimeOffset, 130+10+10, yPos(), 100, widgetHeight());
//     cTimeOffset->loadDeco();
//     cTimeOffset->setFlags(eNumber::flagPosNeg);
//     cTimeOffset->show();

	nextYPos(35);
	makeNewLabel(this, "Number of days", 10, yPos(), 130, widgetHeight());
	cNumOfDays = new eNumber( this, 1, 0, 365, 1, 0);
	setWidgetGeom( cNumOfDays, 190, yPos(), 200, widgetHeight() );
	cNumOfDays->setHelpText("Select number of EPG days to retrieve");
	cNumOfDays->loadDeco();
	cNumOfDays->show();

	nextYPos(35);
	makeNewLabel(this, "Cron options:", 10, yPos(), 130, widgetHeight());

//     makeNewLabel(this, "Interval", 10, yPos(), 130, widgetHeight());
//     cInterval =  new eNumber( this, 1, 1, 6, 1, 0);
//     //makeNewNumber(this, 0, 130+10+10, yPos(), 100, widgetHeight(), 6, 1, 7);
//     cInterval->setNumber(interval);
//     setWidgetGeom( cInterval, 150, yPos(), 100, widgetHeight() );
//     cInterval->loadDeco();
//     cInterval->show();

	nextYPos();
	cUseCron = makeNewCheckbox(this, "Use cron", 10, yPos(), 170, widgetHeight());
	cUseCron->setHelpText("Enable cron to retrieve EPG each day automatically");

	makeNewLabel(this, "Update at", 190, yPos(), 130, widgetHeight());
	cStartTime = new eNumber( this, 2, 0, 59, 2, 0, 0);
	setWidgetGeom( cStartTime , 310, yPos(), 80, widgetHeight() );
	cStartTime->setHelpText("Time EPG will be retrieved");
	cStartTime->loadDeco();
	cStartTime->setFlags( eNumber::flagDrawPoints|eNumber::flagFillWithZeros|eNumber::flagTime );
	cStartTime->show();

	nextYPos(40);
	eButton *bt_channels = makeNewButton(this, "Channels",
		10, yPos(), 120, 40, "blue");
	bt_channels->setHelpText("Map channels");
	CONNECT(bt_channels->selected, EpgConfigDialog::OnChannelManagerClicked);

	eButton *bt_retrieve = makeNewButton(this, "Retrieve",
		270, yPos(), 120, 40, "yellow");
	bt_retrieve->setHelpText("Retrieve EPG data");
	CONNECT(bt_retrieve->selected, EpgConfigDialog::OnRetrieveClicked);

	/* Don't send the signal until gui is fully build....*/
	if (first)
	{
		cb->setCurrent(first, true);    //do send a selected message, will update view..
	}

	buildWindow();
	CONNECT(bOK->selected, EpgConfigDialog::OnOkClicked);
}