ContainerGetx

int ContainerGetx(int cn);

 

Returns the x coordinate of a container within its owning container or the screen.

 

Return Value

 

Returns the x coordinate of the container.

 

Parameters

 

cn

Handle to a container where the container was added.  Container zero is defined as the screen.

 

Remarks

 

The ContainerGetx() function returns the x coordinate of a container on the screen or within another container.

 

Availability

 

Available in DragonFireSDK 2.0 and later.

 

Example

 

The sample code below puts a deck of cards on the screen and when the user touches a card, it is brought to the foreground and can be dragged around in front of the other cards until the user picks another card.

 

#include "DragonFireSDK.h"

 

int Cards[52];

int Containers[52];

int i;

 

int OnTouch(int id, int event, int x, int y)

{

  if (event==1)

   {

      // Bring the selected card to the fore.

       ContainerOrderFront(0, Containers[id]);

   }

  else

  if (event==2)

   {

      // Take half off the card's width and height from the x and y

      // to "grab" the card in the center while we drag it around.

       ContainerSetxy(Containers[id], x-(ViewGetWidth(Cards[id])/2), y-ViewGetHeight(Cards[id])/2);

   }

  else

  if (event==3)

   {

       printf("Container %d position is %d,%d\n",id,ContainerGetx(Containers[id]),ContainerGety(Containers[id]));

   }

   return(id);

}

 

void AppMain()

{

  int x=0;

  int y=20;

  char buffer[50];

 

  for (i=0;i<52;i++)

   {

      // Start each card 17 pixels right of the last one.

      x+=17;

      // When we hit the 13th card (King), start a new row

      if (i>0 && i % 13==0)

      {

          x=17;

          y+=110;

      }

      // Create a container and put a view with the next card into it.

      Containers[i]=ContainerAdd(0, x, y);

      sprintf(buffer,"Cards/Card%02d.png",i+1);

      Cards[i]=ViewAdd(Containers[i],buffer,0,0,OnTouch,i);

   }

}

 

void AppExit()

{

 

}

 

void OnTimer()

{

 

}