in GUI Development by


Is it possible to change (x,y) position of Views during runtime ?

I could able to get all views (Core::View) using CountViews() and GetViewAtIndex()

I also could able to get the x1,y1,x2,y2 using viewItem.GetExtent().

Is there a way to change x1,y1,x2,y2 during runtime ?




1 Answer

0 votes
Best answer

Hi Maha,

there are two possibilities to do this:

Approach 1. Using the method MoveView() you can specify an offset to translate the view relative to its actual position. Please use the value false for the parameter aFastMove. This ensures, that the view correctly updates its internal state and the affected screen areas are redrawn during the next screen update. Specifying true in this parameter suppreses these steps. This is used only in special optimized cases when many views are moved simultanously. 

Approach 2: Depending on its type every view descends from one of the following three primitive basic view classes:

Core::LineView - Views with 2 end points. Usually straight line segments. Every end position can be configured individually via the property Point1 and Point2.

Core::RectView - Views with rectangular shape. Here the class provides the property Bounds you can use to configure the position and the size of the view.

Core::QuadView - Views with 4 corners. Every corner can be moved individually. For this purpose this class exposes the properties Point1, Point2, Point3 and Point4.

Now the difficulty: the method GetViewAtIndex() returns the generic Core::View type. This can be a text view, image view, line view, etc. Before you can modify the position of the view you need to typecast it in one of the above three classes and test whether the cast was successful. For example:

var Core::View     view = GetViewAtIndex(...);

// Try to cast the returned view to one of the three basic
// view classes
var Core::LineView lineView = (Core::LineView)view;
var Core::RectView rectView = (Core::RectView)view;
var Core::QuadView quadView = (Core::QuadView)view;

// Is the view a line view with two end points? Then modify its
// end points
if ( lineView != null )
  lineView.Point1 = ...
  lineView.Point2 = ...

// ... or is it a rectangular view?
else if ( rectView != null )
  rectView.Bounds = ...

// ... or a quad with 4 individual corners?
else if ( quadView != null )
  quadView.Point1 = ...
  quadView.Point2 = ...
  quadView.Point3 = ...
  quadView.Point4 = ...

Hope, it helps you.

Best regards

Paul Banach


It helped a lot,

Thanks !

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint