summaryrefslogtreecommitdiff
path: root/cubedbusStd.c.in
blob: 2cadaeff8d74970325bc7bd218d966e8b39e9c12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
static bool
cubedbusAddStdObject (CompOption *option, int nOption, CubedbusObject *head, CompScreen *s, char *name)
{


	CubedbusObj *data=head->data; 
  	
	CubedbusObject *objptr=data->firstChild;
	
	if (objptr == NULL)
		{
		
		data->firstChild = malloc (sizeof(CubedbusObject));
		
		if(data->firstChild == NULL) 
			{
			compLogMessage (NULL, "cubedbus", CompLogLevelError, "Out of memory. Could not add object");
			return FALSE;	
			}
			
		objptr=data->firstChild;			
		objptr->prev = NULL;
		
		}
	else
		{
		while(1)
			{
			if(objptr->next == NULL )
				{
				objptr->next = malloc (sizeof(CubedbusObject));
				if(objptr->next == NULL) 
					{
					compLogMessage (NULL, "cubedbus", CompLogLevelError, "Out of memory. Could not add object");
					return FALSE;	
					}
				objptr->next->prev=objptr;
				objptr=objptr->next; /* objptr now points to newly created object */	
				
				break;		
				}
			else objptr=objptr->next;
			}
		}
				
	/* have now created CubedbusObject */
	
	objptr->next=NULL;
	objptr->type=getIntOptionNamed (option,nOption, "type", 0);
		if(objptr->type == 0) return FALSE;
	objptr->s=s;
		
	strcpy(objptr->name,name); /* set name */
	
	switch (objptr->type)
		{
		case CUBEDBUS_OBJECT:
			{
			objptr->func   =&cubedbusDrawObj;   /* function called when drawing */
			objptr->delfunc=&cubedbusDeleteObj; /* function called when deleting */
			objptr->modfunc=&cubedbusModifyObj; /* function called when modifying */
			objptr->addfunc=&cubedbusAddObj;	/* function called when adding */		
			
			return (objptr->addfunc) (objptr, option, nOption);				
			}
		case CUBEDBUS_COLOUR_OBJECT:
			{
				
			objptr->func   =&cubedbusDrawColourObject;   /* function called when drawing */
			objptr->delfunc=&cubedbusDeleteColourObject; /* function called when deleting */
			objptr->modfunc=&cubedbusModifyColourObject; /* function called when modifying */
			objptr->addfunc=&cubedbusAddColourObject;	 /* function called when adding */

			return (objptr->addfunc) (objptr, option, nOption);
			}	
				
		case CUBEDBUS_TEXTURE_OBJECT:
			{		
			objptr->func   =&cubedbusDrawTextureObject;   /* function called when drawing */
			objptr->delfunc=&cubedbusDeleteTextureObject; /* function called when deleting */
			objptr->modfunc=&cubedbusModifyTextureObject; /* function called when modifying */
			objptr->addfunc=&cubedbusAddTextureObject;	  /* function called when adding */

			return (objptr->addfunc) (objptr, option, nOption);
			}
			
		case CUBEDBUS_WINDOW_OBJECT:
			{		
			objptr->func   =&cubedbusDrawWindowObject;   /* function called when drawing */
			objptr->delfunc=&cubedbusDeleteWindowObject; /* function called when deleting */
			objptr->modfunc=&cubedbusModifyWindowObject; /* function called when modifying */
			objptr->addfunc=&cubedbusAddWindowObject;	  /* function called when adding */

			return (objptr->addfunc) (objptr, option, nOption);		
			}	

		case CUBEDBUS_MODEL_OBJECT:
			{		
			objptr->func   =&cubedbusDrawModelObject;   /* function called when drawing */
			objptr->delfunc=&cubedbusDeleteModelObject; /* function called when deleting */
			objptr->modfunc=&cubedbusModifyModelObject; /* function called when modifying */
			objptr->addfunc=&cubedbusAddModelObject;	  /* function called when adding */

			return (objptr->addfunc) (objptr, option, nOption);		
			}
		case CUBEDBUS_PARTICLE_OBJECT:
			{		
			objptr->func   =&cubedbusDrawParticleObject;   /* function called when drawing */
			objptr->delfunc=&cubedbusDeleteParticleObject; /* function called when deleting */
			objptr->modfunc=&cubedbusModifyParticleObject; /* function called when modifying */
			objptr->addfunc=&cubedbusAddParticleObject;	  /* function called when adding */

			return (objptr->addfunc) (objptr, option, nOption);		
			}			
		default: 
			return FALSE;			
		}
}