Hi aal,
I am trying to draw different shapes in BREW MP. it’s a mob OS by Qualcomm. The programming is in C.
The operation is I’ve to draw different shapes on screen based on the selected button. But before drawing the next shape I need to store the values of old shapes which I had drew. So I need to maintain data structure for each shapes. When I press particular button(say circle) after drawing that circle values need to be stored in linked list before drawing next shape.
I’ve taken a linked list after drawing each shape add it as a node to linked list then before calling new shape traverse this list n draw all available shapes.
for that i've bulit union inside a structure with type_def
now i want to dump after each operation(each shape ) that structure into the linked list so that when next time before drawing any new shape i can call all the previous shapes i had drew using linked list .
for this i've declared a liked list
I am Trying to create nodes of structure
create_record function
createline function
Is It Right way to store the things into structures????? ??????
n also i wantt to retrieve the things how it can be done....??????
I am trying to draw different shapes in BREW MP. it’s a mob OS by Qualcomm. The programming is in C.
The operation is I’ve to draw different shapes on screen based on the selected button. But before drawing the next shape I need to store the values of old shapes which I had drew. So I need to maintain data structure for each shapes. When I press particular button(say circle) after drawing that circle values need to be stored in linked list before drawing next shape.
I’ve taken a linked list after drawing each shape add it as a node to linked list then before calling new shape traverse this list n draw all available shapes.
for that i've bulit union inside a structure with type_def
Code:
struct shapes{
int type_in_union;
union draw{
struct line lines;
struct ellipse ellipses;
struct rect rects;
struct polygon polygons;
}draw;
}shapes1;
struct line{
int sx,sy;
int ex,ey;
}line;
struct ellipse{
int cx,cy;
int wx;
int wy;
}ellipse;
struct rect{
int x,y;
int dx,dy;
}rect;
struct polygon{
int len;
struct point *points;
}poly;
struct point{
int x,y;
}points;
now i want to dump after each operation(each shape ) that structure into the linked list so that when next time before drawing any new shape i can call all the previous shapes i had drew using linked list .
for this i've declared a liked list
Code:
struct Node{
struct shapes *shape;
struct Node *pNext;
struct Node *pPrev;
int type;
};
I am Trying to create nodes of structure
Code:
insert_node(create_node(&shape_type,&a,&b,&x,&y));
void insert_node(struct Node *pNode)
{
struct Node *t;
struct Node *pTemp = NULL;
if(pStart == NULL)
{
pStart = pNode; /* Store address of the node as the start node */
return;
}
else
{
t=pStart;
while(t->pNext!=NULL)
{
t=t->pNext;
}
t->pNext=pNode;
pNode->pPrev=t;
}
}
struct Node* create_node(int *shape_type,int *a,int *b,int *x,int *y)
{
struct Node *pNode = NULL; // Pointer to the new node
pNode = (struct Node*)malloc(sizeof(struct Node)); // Allocate memory for node
pNode->pNext = NULL; // No next node yet
pNode->pPrev = NULL; // No previous node
pNode->type=*shape_type;
pNode->shape = create_record(&shape_type,&a,&b,&x,&y); // Create record and store address in node
return pNode;
}
create_record function
Code:
struct shapes* create_record(int *shape_type,int *a,int *b,int *x,int *y)
{
struct shapes *shape=NULL;
if(*shape_type==LINE)
{
//struct shapes *shape=NULL;
shape = (struct shapes*)malloc(sizeof(struct shapes));
shape->draw.lines=createline(&shape_type,&a,&b,&x,&y);
}
return shape;
}
Code:
struct line* createline(int *shape_type,int *a,int *b,int *x,int *y)
{
struct line *line1=NULL;
line1 = (struct line*)malloc(sizeof(struct line));
line1->start_x=*a;
line1->start_y=*b;
line1->end_x=*x;
line1->end_y=*y;
return line1;
}
n also i wantt to retrieve the things how it can be done....??????
Comment