Example #1
0
TInt AVisWidget::GetParData(ParentSizeProv::TData aData)
{
    TInt res = 0;
    // Update parent of widget. It is requied because there is no notification of parent change or
    // connection to parent change. In fact the observation via HandleCompChanged give us only
    // info of local connection change, but not the whole connection chain change. Ref grayb uc_010
    Container* parent = iWidget->get_parent();
    if (parent == NULL) {
	Elem* eprntcp = GetNode("../../ConnPoint:Child");
	if (eprntcp != NULL) {
	    MVisContainer* mcont = (MVisContainer*) eprntcp->GetSIfiC(MVisContainer::Type(), this);
	    if (mcont != NULL) {
		if (iWidget->get_parent() == NULL) {
		    Container& cont = mcont->GetContainer();
		    cont.add(*iWidget);
		    parent = iWidget->get_parent();
		}
	    }
	}
    }
    if (parent != NULL) {
	Allocation palc = parent->get_allocation();
	res = aData == ParentSizeProv::ED_W ? palc.get_width() : palc.get_height();
    }
    return res;
}
Example #2
0
void ScrollCtrl::pageView(KeyEvent & e, const Allocation& a )
{
	PPM delta = 0;
	Dimension dim = 0;
	if( e.isPageUp() && e.isPlainKey() )
	{
		dim = DimY;
		delta = -PPM( a.getHeight() ) * g_page / d_area->getTwipPerPpm( dim );
	}else if( e.isPageDown() && e.isPlainKey() )
	{
		dim = DimY;
		delta = PPM( a.getHeight() ) * g_page / d_area->getTwipPerPpm( dim );
	}else if( e.isPageUp() && e.isCtrl() )
	{
		dim = DimX;
		delta = -PPM( a.getWidth() ) * g_page / d_area->getTwipPerPpm( dim );
	}else if( e.isPageDown() && e.isCtrl() )
	{
		dim = DimX;
		delta = PPM( a.getWidth() ) * g_page / d_area->getTwipPerPpm( dim );
	}
	if( d_do[ dim ] && d_area->inUse( dim ) )
	{
		PpmRange r = d_area->getRange( dim );
		r.move( delta * r.getSign() );
		d_area->setRange( dim, r );
		getViewport()->damageAll();
	}
}
Example #3
0
void View::transform(
    Transformer& t, const Allocation& a, const Allocation&
) const {
    scene2view(a);
    const Allotment& ax = a.x_allotment();
    const Allotment& ay = a.y_allotment();
    csize(ax.begin(), ax.span(), ay.begin(), ay.span());
    float sx = ax.span()/XYView::width();
    float sy = ay.span()/XYView::height();
//	if (sx > sy) sx = sy;
    t.translate( -x(), -y());
    t.scale(sx, sx);
    View* v = (View*)this;
    v->x_pick_epsilon_ = pick_epsilon/sx;
    v->y_pick_epsilon_ = pick_epsilon/sx;
    t.translate((ax.begin() + ax.end())/2,(ay.begin() + ay.end())/2);
//printf("\nx origin=%g span=%g alignment=%g begin=%g end=%g\n", ax.origin(), ax.span(), ax.alignment(), ax.begin(), ax.end());
//printf("\ny origin=%g span=%g alignment=%g begin=%g end=%g\n", ay.origin(), ay.span(), ay.alignment(), ay.begin(), ay.end());
    Coord x1,y1;
    t.transform(x() - x_span_/2, y() - y_span_/2, x1, y1);
    if (!Math::equal(ax.begin(), x1, 1) || !Math::equal(ay.begin(), y1, 1)) {
        t.inverse_transform(ax.begin(), ay.begin(), x1, y1);
        v->x_span_ = 2*(x() - x1);
        v->y_span_ = 2*(y() - y1);
        v->size(x1,y1,x1+v->x_span_, y1+v->y_span_);
    }

}
void rsi_Allocation3DRead(Context *rsc, RsAllocation va,
                          uint32_t xoff, uint32_t yoff, uint32_t zoff,
                          uint32_t lod, uint32_t w, uint32_t h, uint32_t d,
                          void *data, size_t sizeBytes, size_t stride) {
    Allocation *a = static_cast<Allocation *>(va);
    a->read(rsc, xoff, yoff, zoff, lod, w, h, d, data, sizeBytes, stride);
}
Example #5
0
void XYView::damage(Glyph* g, const Allocation& a, bool fixed, bool vf) {
    if (canvas_) {
        Extension e;
        canvas_->push_transform();
        canvas_->transformer(((XYView_helper*)body())->t_);
        if (fixed) {
            Coord x, y;
            canvas_->transform(s2o());
            if (vf) {
                view_ratio(a.x(), a.y(), x, y);
            } else {
                s2o().inverse_transform(a.x(), a.y(), x, y);
            }
            Allocation a_fix = a;
            a_fix.x_allotment().origin(x);
            a_fix.y_allotment().origin(y);
            g->allocate(canvas_, a_fix, e);
        } else {
            g->allocate(canvas_, a, e);
        }
//printf("damage extension %g %g %g %g\n", e.left(), e.bottom(), e.right(), e.top());
//print_t("XYView::damage", canvas_->transformer());
        canvas_->pop_transform();
        canvas_->damage(e);
    }
}
Example #6
0
void XYView_helper::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (MyMath::inside(h.left(), h.bottom(), v_->left(), v_->bottom(),
                       v_->right(), v_->top())) {
        if (h.event()->grabber()) { // fixes a bug but I dont know why
#if 1
//The above fix broke the handling of keystrokes for crosshairs and Rotate3D
//It was needed so that buttons would appear normal when moving quickly from
// a button through a box to a scene. Now we put in the right handler in
//case event was a keystroke.
            if (h.event()->type() == Event::key) {
                h.target(depth, this, 0, h.event()->grabber());
            }
#endif
            return;
        }
        current_pick_view_ = v_;
        MonoGlyph::pick(c, a, depth, h);
        if (h.event()->type() == Event::down) {
#if 0
            printf("XYView_helper hit (%g, %g)  event (%g, %g)\n", h.left(), h.bottom(),
                   h.event()->pointer_x(), h.event()->pointer_y());
            printf(" allocation lb=(%g, %g), rt=(%g,%g)\n", a.left(), a.bottom(), a.right(), a.top());
#endif
        }
    }
}
Example #7
0
void BevelFrame::allocate_body(Glyph* g, Coord t, Allocation& a) const {
    Requisition req;
    g->request(req);
    Coord h = hmargin_ ? t : 0, v = vmargin_ ? t : 0;
    Allotment& ax = a.x_allotment();
    Coord x_span = ax.span() - h - h;
    Coord x_offset = h;
    Coord x_align = ax.alignment();
    const Requirement& rx = req.x_requirement();
    if (rx.defined()) {
	Coord x_usable = rx.natural() + rx.stretch();
	if (x_span > x_usable) {
	    x_offset += xalign_ * (x_span - x_usable);
	    x_span = x_usable;
	}
    }
    ax.span(x_span);
    ax.offset(x_offset * (1 - x_align - x_align));

    Allotment& ay = a.y_allotment();
    Coord y_span = ay.span() - v - v;
    Coord y_offset = v;
    Coord y_align = ay.alignment();
    const Requirement& ry = req.y_requirement();
    if (ry.defined()) {
	Coord y_usable = ry.natural() + ry.stretch();
	if (y_span > y_usable) {
	    y_offset += yalign_ * (y_span - y_usable);
	    y_span = y_usable;
	}
    }
    ay.span(y_span);
    ay.offset(y_offset * (1 - y_align - y_align));
}
Example #8
0
bool CursorCtrl::handleMousePress( MouseEvent& e ) 
{ 
	if( e.isLeft() && ( e.isNoKey() || e.isAlt() ) ||
		e.isRight() && e.isShift() )
	{
		Allocation a;
		allocation( a );
		ViewAreaMdl* area = d_view->getArea();
		if( d_do[ DimX ] && d_do[ DimY ] && area->getDimCount() == 2 )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, 
				d_view->getDim( DimY ), y, d_mouseVeto );
		}else if( d_do[ DimX ] && area->inUse( DimX ) )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, d_mouseVeto );
		}else if( d_do[ DimY ] && area->inUse( DimY ) )
		{
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimY ), y, d_mouseVeto );
		}
		return d_swallow;	// Der Click soll nicht immer gefressen werden.
	}else
		return false;
}
Example #9
0
void Character::allocate(Canvas* c, const Allocation& a, Extension& ext) {
    Coord x = a.x();
    Coord y = a.y();
    ext.set_xy(
	c, x - left_bearing_, y - descent_, x + right_bearing_, y + ascent_
    );
}
Example #10
0
void Space::pick(Canvas*, const Allocation& a, int depth, Hit& h) {
    Coord x = h.left();
    Coord left = a.left();
    Coord right = a.right();
    if (x >= left && x < right) {
        h.target(depth, this, (x > (left+right)/2) ? 1 : 0);
    }
}
void *rsi_AllocationGetPointer(Context *rsc, RsAllocation valloc,
                          uint32_t lod, RsAllocationCubemapFace face,
                          uint32_t z, uint32_t array, size_t *stride, size_t strideLen) {
    Allocation *alloc = static_cast<Allocation *>(valloc);
    rsAssert(strideLen == sizeof(size_t));

    return alloc->getPointer(rsc, lod, face, z, array, stride);
}
Example #12
0
void Background::draw(Canvas* c, const Allocation& a) const {
    Extension ext;
    ext.set(c, a);
    if (c->damaged(ext)) {
        c->fill_rect(a.left(), a.bottom(), a.right(), a.top(), color_);
    }
    MonoGlyph::draw(c, a);
}
Example #13
0
void MonoKitFrame::draw(Canvas* c, const Allocation& a) const {
    BevelFrame::draw(c, a);
    if (!state_->test(TelltaleState::is_enabled)) {
        c->fill_rect(
            a.left(), a.bottom(), a.right(), a.top(), info_->gray_out()
        );
    }
}
Example #14
0
void AVisDrawing::OnUpdated_H(int aData)
{
    Allocation alc = iWidget->get_allocation();
    Container* parent = iWidget->get_parent();
    VisDrwArea* drw = GetDrawing();
    drw->set_size_request(iW, iH);
    drw->queue_draw_area(alc.get_x(), alc.get_y(), iW, iH);
}
Example #15
0
bool VisDrwArea::on_expose_event(GdkEventExpose* aEvent)
{
    DrawingArea::on_expose_event(aEvent);
    Glib::RefPtr<Gdk::Window> drw = get_window();
    Glib::RefPtr<Gtk::Style> style = get_style(); 	
    Glib::RefPtr<Gdk::GC> gc = style->get_fg_gc(get_state());
    Allocation alc = get_allocation();
    drw->draw_rectangle(gc, false, 0, 0, alc.get_width() - 1, alc.get_height() - 1);
}
Example #16
0
void DebugGlyph::allocate(Canvas* c, const Allocation& a, Extension& ext) {
    if ((flags_ & trace_allocate) != 0) {
	heading("allocate ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::allocate(c, a, ext);
}
Example #17
0
void Slider::draw(Canvas* c, const Allocation& a) const {
    SliderImpl& s = *impl_;
    c->push_clipping();
    c->clip_rect(a.left(), a.bottom(), a.right(), a.top());
    if (s.showing_old_thumb_) {
        s.old_thumb_->draw(c, s.old_thumb_->allocation());
    }
    s.thumb_patch_->draw(c, s.thumb_patch_->allocation());
    c->pop_clipping();
}
Example #18
0
void FieldStringEditor::pick(
    Canvas*, const Allocation& a, int depth, Hit& h
) {
    const Event* ep = h.event();
    if (ep != nil && h.left() < a.right() && h.right() >= a.left() &&
	h.bottom() < a.top() && h.top() >= a.bottom()
    ) {
	h.target(depth, this, 0);
    }
}
Example #19
0
	void update( const Allocation& a, Lexi::Twips w, Lexi::Twips h, bool all, bool shift )
	{
		if( d_dim == DimX || d_dim == DimUndefined )
			d_phi = double( w ) * 360.0 * ( (shift)?3.0:1.0 ) / 
				double( a.getWidth() ) + d_phi;
		if( d_dim == DimY || d_dim == DimUndefined )
			d_psi = double( h ) * 360.0 * ( (shift)?3.0:1.0 ) / 
				double( a.getHeight() ) + d_psi;
		d_agent->setPhiPsi( d_phi, d_psi, all );
	}
Example #20
0
void DebugGlyph::print(Printer* p, const Allocation& a) const {
    if ((flags_ & trace_print) != 0) {
	heading("print ");
	print_allotment(a.allotment(Dimension_X));
	printf(", ");
	print_allotment(a.allotment(Dimension_Y));
	printf("\n");
    }
    MonoGlyph::print(p, a);
}
RsAllocation rsi_AllocationCreateTyped(Context *rsc, RsType vtype,
                                       RsAllocationMipmapControl mipmaps,
                                       uint32_t usages, uintptr_t ptr) {
    Allocation * alloc = Allocation::createAllocation(rsc, static_cast<Type *>(vtype), usages, mipmaps, (void*)ptr);
    if (!alloc) {
        return nullptr;
    }
    alloc->incUserRef();
    return alloc;
}
Example #22
0
void Graphic31::allocate(Canvas* c, const Allocation& a, Extension& ext) {
    if (_ctrlpts > 0) {
        Coord w = _brush == nil ? 0 : _brush->width();
        Coord x = a.x();
        Coord y = a.y();
        ext.merge_xy(
            c, x + _xmin - w, x + _xmax + w,
            y + _ymin - w, y + _ymax + w
        );
    }
}
Example #23
0
void MonoKitFrame::pick(Canvas* c, const Allocation& a, int depth, Hit& h) {
    if (target_) {
        Coord x = h.left();
        Coord y = h.bottom();
        if (x >= a.left() && x < a.right() && y >= a.bottom() && y < a.top()) {
            h.target(depth, this, 0);
        }
    } else {
        BevelFrame::pick(c, a, depth, h);
    }
}
Example #24
0
void Space::draw(Canvas* c, const Allocation& a) const {
    if (count_ > 0) {
        Coord x = a.x();
        Coord y = a.y();
        Coord each = (a.right() - a.left()) / count_;
        for (int i = 0; i < count_; ++i) {
            c->character(font_, ' ', each, color_, x, y);
            x += each;
        }
    }
}
RsAllocation rsi_AllocationAdapterCreate(Context *rsc, RsType vwindow, RsAllocation vbase) {


    Allocation * alloc = Allocation::createAdapter(rsc,
            static_cast<Allocation *>(vbase), static_cast<Type *>(vwindow));
    if (!alloc) {
        return nullptr;
    }
    alloc->incUserRef();
    return alloc;
}
void rsi_AllocationRead(Context *rsc, RsAllocation va, void *data, size_t sizeBytes) {
    Allocation *a = static_cast<Allocation *>(va);
    const Type * t = a->getType();
    if(t->getDimY()) {
        a->read(rsc, 0, 0, 0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
                t->getDimX(), t->getDimY(), data, sizeBytes, 0);
    } else {
        a->read(rsc, 0, 0, t->getDimX(), data, sizeBytes);
    }

}
Example #27
0
void PaletteHint::setText(const ustring &name, const ustring &info) {
	if(is_visible()) return;

	caption.set_markup("<b>" + name + "</b>");
	this->info.set_text(" " + info + " ");
	Allocation a = get_allocation();
	a.set_width(100);
	a.set_height(20);
	set_allocation(a);
	show();
}
Example #28
0
void SpecRuler2D::allocateBody( Glyph* body, Allocation& interior ) 
{
	// Dies funktioniert minimal, d.h. wenn Request nicht vorhanden.
    Allotment& x = interior.getAllotment( DimensionX );
	x.setSpan( x.getSpan() - d_width );
	x.setOrigin( x.getOrigin() );
    Allotment& y = interior.getAllotment( DimensionY );
	y.setSpan( y.getSpan() - d_height );
	y.setOrigin( y.getOrigin() );
	return;

}
void rsi_AllocationCopyToBitmap(Context *rsc, RsAllocation va, void *data, size_t dataLen) {
    Allocation *texAlloc = static_cast<Allocation *>(va);
    const Type * t = texAlloc->getType();

    size_t s = t->getDimX() * t->getDimY() * t->getElementSizeBytes();
    if (s != dataLen) {
        rsc->setError(RS_ERROR_BAD_VALUE, "Bitmap size didn't match allocation size");
        return;
    }

    memcpy(data, texAlloc->getPtr(), s);
}
Example #30
0
void memoryLeak()
{
   do
   {
      // no leak
      Allocation A;
      Allocation Acopy(A);
      Allocation Anew = A.clone();
      // leak
      //Allocation* B = new Allocation();
   } while (1);
}