MHEG5  18.9.0
MHEG5 Documentation
mh5interactible.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
31 /*---includes for this file--------------------------------------------------*/
32 #include "mh5variable.h" /* for actions */
33 #include "mh5object.h" /* for actions */
34 #include "mh5queue.h" /* Events */
35 #include "mh5interactible.h"
36 #include "mh5application.h"
37 #include "mh5button.h"
38 #include "mh5slider.h"
39 #include "mh5display.h"
40 #include "mh5entryfield.h"
41 #include "mh5hypertext.h"
42 #include "mh5scene.h"
43 #include "mh5memory.h"
44 
45 #include "mh5profile.h"
46 
47 #include "mh5debug.h"
48 #include "mh5drawtext.h"
49 
50 #ifdef MH5PRINTOUT
51 #include <string.h>
52 #endif /* #ifdef MH5PRINTOUT */
53 
54 /*---constant definitions for this file--------------------------------------*/
55 
56 
57 /*---local typedef structs for this file-------------------------------------*/
58 
59 /*---local (static) variable declarations for this file----------------------*/
60 
61 /*---local function definitions----------------------------------------------*/
62 
63 /*---global function definitions---------------------------------------------*/
64 
69 /*
70  Debug
71  */
72 #ifdef MH5PRINTOUT
73 
74 void MHEG5interactiblePrint(MHEG5Interactible *interactible, char *out)
75 {
76  MHEG5indent(out);
77  MHEG_PRINT(out, ":EngineResp ");
78  MHEG5boolPrint(interactible->engineResp, out);
79  MHEG5newLine(out);
80  MHEG5indent(out);
81  MHEG_PRINT(out, ":HighlightRefColour ");
82  MHEG5colourPrint(interactible->highlightRefColour, out);
83  MHEG5newLine(out);
84  MHEG5indent(out);
85  MHEG_PRINT(out, "// HighlightStatus:\t");
86  MHEG5boolPrint(interactible->highlightStatus, out);
87  MHEG5newLine(out);
88  MHEG5indent(out);
89  MHEG_PRINT(out, "// InteractionStatus:\t");
90  MHEG5boolPrint(interactible->interactionStatus, out);
91  MHEG5newLine(out);
92 }
93 
94 #endif /* #ifdef MH5PRINTOUT */
95 
96 
103 {
104  assert(interactible);
105 
106  interactible->engineResp = MHEG5TRUE;
107 }
108 
116 {
117  assert(interactible);
118 
119  interactible->highlightStatus = MHEG5FALSE;
120  interactible->interactionStatus = MHEG5FALSE;
121 }
122 
131 {
132  assert(interactible);
133 
135 }
136 
137 /*
138  Internal behaviours
139  */
141 {
142  assert(interactible);
143 }
144 
152 {
153  assert(interactible);
154 
155  interactible->interactionStatus = MHEG5FALSE;
156 }
157 
158 /*
159  Internal functions
160  */
161 
162 static void MHEG5interactibleHighlightOn(MHEG5Interactible *interactible, MHEG5Root *item)
163 {
164  assert(interactible);
165  assert(item);
166 
167  if (interactible->highlightStatus)
168  {
169  return;
170  }
171 
172  interactible->highlightStatus = MHEG5TRUE;
174 
175  if (interactible->engineResp)
176  {
178  }
179 }
180 
181 static void MHEG5interactibleHighlightOff(MHEG5Interactible *interactible, MHEG5Root *item)
182 {
183  assert(interactible);
184  assert(item);
185 
186  if (!interactible->highlightStatus)
187  {
188  return;
189  }
190 
191  interactible->highlightStatus = MHEG5FALSE;
193 
194  if (interactible->engineResp)
195  {
197  }
198 }
199 
200 #ifdef _MOVINGCURSOR_
201 
202 void MHEG5interactibleCursorEnter(MHEG5Interactible *interactible, MHEG5Root *item)
203 {
205 }
206 
207 void MHEG5interactibleCursorLeave(MHEG5Interactible *interactible, MHEG5Root *item)
208 {
210 }
211 
212 #endif /* #ifdef _MOVINGCURSOR_ */
213 
214 
216 {
218 }
219 
220 /*
221  Actions
222  */
224 {
225  MHEG5Bool interactionStatus = MHEG5FALSE;
226  MHEG5Bool interactionCompleted = MHEG5FALSE;
227  MHEG5Interactible *interactible = 0;
228  MHEG5Scene *scene = MHEG5getCurrentScene();
229 
230  assert(target);
231 
232  if (!params)
233  {
235  }
236  if (!scene)
237  {
238  return MHEG5ERR_NOSCENE;
239  }
240 
241  MHEG5resolveGenericBoolean(params, &interactionStatus);
242 
243  switch (target->clazz)
244  {
245  case MHEG5HOTSPOT:
246  case MHEG5PUSHBUTTON:
247  case MHEG5SWITCHBUTTON:
248  interactible = &((MHEG5Button *)target)->interactible;
249  break;
250  case MHEG5SLIDER:
251  interactible = &((MHEG5Slider *)target)->interactible;
252  break;
253  case MHEG5ENTRYFIELD:
254  interactible = &((MHEG5Entryfield *)target)->interactible;
255  break;
256  case MHEG5HYPERTEXT:
257  interactible = &((MHEG5Hypertext *)target)->interactible;
258  break;
259  default:
260  return MHEG5ERR_WRONGTARGET;
261  }
262 
263  if (interactible)
264  {
265  if ((scene->currentInteractible) && interactionStatus)
266  {
267  return MHEG5ERR_NOERROR;
268  }
269 
270  if (interactible->interactionStatus && !interactionStatus)
271  {
272  interactionCompleted = MHEG5TRUE;
273  }
274 
275  interactible->interactionStatus = interactionStatus;
276 
277  if (target->clazz == MHEG5ENTRYFIELD)
278  {
280  }
281  else if (target->clazz == MHEG5HYPERTEXT)
282  {
284  }
285  MHEG5displayRedraw((MHEG5Visible *) target);
286 
287  if ((scene->currentInteractible == target) && (!interactionStatus))
288  {
289  scene->currentInteractible = 0;
290  }
291 
292  if ((!scene->currentInteractible) && (interactionStatus))
293  {
294  scene->currentInteractible = target;
295  }
296 
297  if (interactionCompleted)
298  {
300  }
301  }
302 
303  return MHEG5ERR_NOERROR;
304 }
305 
307 {
308  MHEG5Root *rcVar = 0;
309  MHEG5Interactible *interactible = 0;
310 
311  assert(target);
312 
313  if (!params)
315  MHEG5resolveORef(params, &rcVar);
316  switch (target->clazz)
317  {
318  case MHEG5HOTSPOT:
319  case MHEG5PUSHBUTTON:
320  case MHEG5SWITCHBUTTON:
321  interactible = &((MHEG5Button *)target)->interactible;
322  break;
323  case MHEG5SLIDER:
324  interactible = &((MHEG5Slider *)target)->interactible;
325  break;
326  case MHEG5ENTRYFIELD:
327  interactible = &((MHEG5Entryfield *)target)->interactible;
328  break;
329  case MHEG5HYPERTEXT:
330  interactible = &((MHEG5Hypertext *)target)->interactible;
331  break;
332  default:
333  return MHEG5ERR_WRONGTARGET;
334  }
335  if (!rcVar)
337  if (rcVar->clazz != MHEG5BOOLEANVARIABLE)
338  return MHEG5ERR_WRONGPARAM;
339  if (!rcVar->runningStatus)
341  if (interactible)
342  ((MHEG5BooleanVariable *) rcVar)->value = interactible->interactionStatus;
343  return MHEG5ERR_NOERROR;
344 }
345 
347 {
348  MHEG5Bool highlightStatus = MHEG5FALSE;
349  MHEG5Interactible *interactible = 0;
350 
351  assert(target);
352 
353  if (!params)
355  MHEG5resolveGenericBoolean(params, &highlightStatus);
356  switch (target->clazz)
357  {
358  case MHEG5HOTSPOT:
359  case MHEG5PUSHBUTTON:
360  case MHEG5SWITCHBUTTON:
361  interactible = &((MHEG5Button *)target)->interactible;
362  break;
363  case MHEG5SLIDER:
364  interactible = &((MHEG5Slider *)target)->interactible;
365  break;
366  case MHEG5ENTRYFIELD:
367  interactible = &((MHEG5Entryfield *)target)->interactible;
368  break;
369  case MHEG5HYPERTEXT:
370  interactible = &((MHEG5Hypertext *)target)->interactible;
371  break;
372  default:
373  return MHEG5ERR_WRONGTARGET;
374  }
375  if (interactible)
376  {
377  if (highlightStatus)
378  MHEG5interactibleHighlightOn(interactible, target);
379  else
380  MHEG5interactibleHighlightOff(interactible, target);
381  }
382  return MHEG5ERR_NOERROR;
383 }
384 
386 {
387  MHEG5Root *rcVar = 0;
388  MHEG5Interactible *interactible = 0;
389 
390  if (!params)
392  MHEG5resolveORef(params, &rcVar);
393  switch (target->clazz)
394  {
395  case MHEG5HOTSPOT:
396  case MHEG5PUSHBUTTON:
397  case MHEG5SWITCHBUTTON:
398  interactible = &((MHEG5Button *)target)->interactible;
399  break;
400  case MHEG5SLIDER:
401  interactible = &((MHEG5Slider *)target)->interactible;
402  break;
403  case MHEG5ENTRYFIELD:
404  interactible = &((MHEG5Entryfield *)target)->interactible;
405  break;
406  case MHEG5HYPERTEXT:
407  interactible = &((MHEG5Hypertext *)target)->interactible;
408  break;
409  default:
410  return MHEG5ERR_WRONGTARGET;
411  }
412  if (!rcVar)
414  if (rcVar->clazz != MHEG5BOOLEANVARIABLE)
415  return MHEG5ERR_WRONGPARAM;
416  if (!rcVar->runningStatus)
418  if (interactible)
419  ((MHEG5BooleanVariable *) rcVar)->value = interactible->highlightStatus;
420  return MHEG5ERR_NOERROR;
421 }
422 
Implement the MHEG5 Button Class Description Defines functionality associated with the rendering and ...
Implement the MHEG5 Hypertext Class. The HyperText class is a subclass of the Text class...
void MHEG5interactibleFree(MHEG5Interactible *interactible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
void MHEG5drawHypertext(MHEG5Hypertext *hypertxt)
Definition: mh5drawtext.c:578
void MHEG5interactibleInit(MHEG5Interactible *interactible)
<Function description>="">
Implement the MHEG5 Interactible Class. Defines functionality associated with an interaction behaviou...
MHEG5Final clazz
Definition: mh5root.h:55
MHEG5ErrorCode MHEG5setHighlightStatus(MHEG5Root *target, MHEG5GList *params)
MHEG5Bool highlightStatus
void MHEG5drawEntry(MHEG5Entryfield *entry, entryfieldCursor_t cursor)
Definition: mh5drawtext.c:502
Implement the MHEG5 Slider Class. Slider Class. Defines the behaviour of sliders. Base class: Visible...
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5interactibleInteractionCompleted(MHEG5Interactible *interactible, MHEG5Root *item)
This file defines the profile for the MHEG engine.
#define MHEG5displayRedraw(v)
Definition: mh5display.h:47
short MHEG5Bool
Definition: mh5base.h:71
MHEG5ErrorCode
Definition: mh5base.h:222
MHEG5ErrorCode MHEG5getInteractionStatus(MHEG5Root *target, MHEG5GList *params)
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
void MHEG5interactibleDeactivate(MHEG5Interactible *interactible)
Implementation of the deactivation behaviour of the interactible class. This behaviour was introduced...
MHEG5Bool interactionStatus
#define MHEG5TRUE
Definition: mh5base.h:49
void MHEG5interactibleDestruct(MHEG5Interactible *interactible)
void MHEG5genericDestruct(MHEG5Generic *item)
Destruct a MHEG5Generic.
Definition: mh5base.c:834
Implement functions to retrieve MHEG5objects by GroupID and ID.
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
Implementation of the MHEG5 Scene Class Scene Class Defines a set of Ingredient objects to be activat...
Mheg5 logging and debug printing.
void MHEG5interactiblePrepare(MHEG5Interactible *interactible)
Sets all internal attributes for the specified object to their default values.
MHEG class interface to graphics text render.
MHEG5Bool runningStatus
Definition: mh5root.h:51
redirection include
MHEG5Scene * MHEG5getCurrentScene(void)
<Function description>="">
Definition: mh5scene.c:207
void MHEG5sendEvent(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the asynchronous event queue.
Definition: mh5queue.c:1540
MHEG5Root * currentInteractible
Definition: mh5scene.h:56
MHEG5GList * MHEG5resolveGenericBoolean(MHEG5GList *params, MHEG5Bool *value)
Definition: mh5object.c:454
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
MHEG5ErrorCode MHEG5getHighlightStatus(MHEG5Root *target, MHEG5GList *params)
#define MHEG5FALSE
Definition: mh5base.h:48
void MHEG5sendSync(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the synchronous event queue.
Definition: mh5queue.c:1651
MHEG5Colour highlightRefColour
MHEG5ErrorCode MHEG5setInteractionStatus(MHEG5Root *target, MHEG5GList *params)
Implement the MHEG5 EntryField Class. Defines an interaction widget used by the final user to edit an...