MHEG5  18.9.0
MHEG5 Documentation
mh5button.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  *******************************************************************************/
32 /*---includes for this file--------------------------------------------------*/
33 #include "mh5profile.h"
34 #include "mh5button.h"
35 #include "mh5object.h" /* for actions */
36 #include "mh5variable.h" /* for actions */
37 #include "mh5display.h" /* for actions */
38 #include "mh5application.h" /* Default Colour */
39 #include "mh5queue.h" /* Events */
40 #include "mh5debug.h"
41 
42 #ifndef MHEG5PROFILE_UK1_06
43 
44 #ifdef MH5PRINTOUT
45 #include <string.h>
46 #endif /* #ifdef MH5PRINTOUT */
47 
48 /*---constant definitions for this file--------------------------------------*/
49 
50 
51 /*---local typedef structs for this file-------------------------------------*/
52 
53 /*---local (static) variable declarations for this file----------------------*/
54 
55 /*---local function definitions----------------------------------------------*/
56 
57 /*---global function definitions---------------------------------------------*/
58 
64 /*
65  Debug
66  */
67 #ifdef MH5PRINTOUT
68 
69 void MHEG5buttonPrint(MHEG5Button *button, char *out)
70 {
71  MHEG5visiblePrint(&button->visible, out);
72  MHEG5interactiblePrint(&button->interactible, out);
73  MHEG5indent(out);
74  MHEG_PRINT(out, ":RefColour ");
75  MHEG5colourPrint(button->buttonColour, out);
76  MHEG5newLine(out);
77  MHEG5indent(out);
78  MHEG_PRINT(out, "// SelectionStatus:\t");
79  MHEG5boolPrint(button->selectionStatus, out);
80  MHEG5newLine(out);
81  MHEG5indent(out);
82  MHEG_PRINT(out, "// CursorHere:\t");
83  MHEG5boolPrint(button->cursorHere, out);
84  MHEG5newLine(out);
85 }
86 
87 #endif
88 
95 {
96  assert(button);
97 
98  MHEG5visibleInit(&button->visible);
100 }
101 
110 {
111  assert(button);
112 
113  MHEG5visibleFree(&button->visible);
115 
117 }
118 
129 {
130  assert(button);
131  MHEG5interactibleInitInternal(&button->interactible);
132  button->selectionStatus = MHEG5FALSE;
133 
134  MHEG5visiblePrepare(&button->visible);
135 }
136 
146 {
147  assert(button);
149  {
150  MHEG5buttonPrepare( button );
151  }
152  MHEG5visibleActivate(&button->visible);
153 }
154 
164 {
165  assert(button);
166 
168 
169  /* Apply deactivation behaviour inherrited from Interactible class */
171 }
172 
180 {
181  assert(button);
182 
183  MHEG5visibleDestruct(&button->visible);
185 }
186 
193 static void MHEG5buttonSelection(MHEG5Button *item)
194 {
195  assert(item);
196 
197  item->selectionStatus = MHEG5TRUE;
198 
200 
202 }
203 
210 static void MHEG5buttonDeselection(MHEG5Button *item)
211 {
212  assert(item);
213  item->selectionStatus = MHEG5FALSE;
214 
216 
218 }
219 
220 /*
221  Actions
222  */
233 {
234  assert(target);
235 
236  switch (target->clazz)
237  {
238  case MHEG5HOTSPOT:
239  case MHEG5PUSHBUTTON:
240  /* Execute the following sequence of actions:
241  * 1. Apply the Selection behaviour as defined in the base class.
242  */
243  MHEG5buttonSelection((MHEG5Button *)target);
244 
245  /* 2. Apply the Deselection behaviour as defined in the base class. */
246  MHEG5buttonDeselection((MHEG5Button *)target);
247  break;
248 
249  case MHEG5SWITCHBUTTON:
250  /* If the SelectionStatus attribute is True, disregard this action.
251  * Otherwise, invoke the Selection behaviour.
252  */
253  if (((MHEG5Button *)target)->selectionStatus)
254  {
255  return MHEG5ERR_NOERROR;
256  }
257  MHEG5buttonSelection((MHEG5Button *)target);
258  break;
259 
260  default:
261  return MHEG5ERR_WRONGTARGET;
262  }
263  return MHEG5ERR_NOERROR;
264 }
265 
276 {
277  assert( target );
278 
279  switch (target->clazz)
280  {
281  case MHEG5HOTSPOT:
282  case MHEG5PUSHBUTTON:
283  case MHEG5SWITCHBUTTON:
284  /* If the SelectionStatus attribute is False, disregard this action.
285  * Otherwise, invoke the Deselection behaviour.
286  */
287  if (!((MHEG5Button *)target)->selectionStatus)
288  {
289  return MHEG5ERR_NOERROR;
290  }
291  MHEG5buttonDeselection((MHEG5Button *)target);
292  break;
293 
294  default:
295  return MHEG5ERR_WRONGTARGET;
296  }
297  return MHEG5ERR_NOERROR;
298 }
299 
300 #endif
MHEG5Bool availabilityStatus
Definition: mh5root.h:52
Implement the MHEG5 Button Class Description Defines functionality associated with the rendering and ...
void MHEG5buttonFree(MHEG5Button *button)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5button.c:109
void MHEG5visibleActivate(MHEG5Visible *visible)
Apply the activation behaviour of the visible class. Apply the activation behaviour off the visible c...
Definition: mh5visible.c:306
MHEG5Bool cursorHere
Definition: mh5button.h:58
MHEG5Final clazz
Definition: mh5root.h:55
void MHEG5interactibleDestruct(MHEG5Interactible *interactible)
MHEG5Colour buttonColour
Definition: mh5button.h:54
void MHEG5visibleFree(MHEG5Visible *visible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5visible.c:186
void MHEG5buttonActivate(MHEG5Button *button)
Apply the activation behaviour of the button class. As this class has no own activation behaviour thi...
Definition: mh5button.c:145
void MHEG5visiblePrepare(MHEG5Visible *visible)
Apply the preparation behaviour off the visible class Apply the preparation behaviour of the visible ...
Definition: mh5visible.c:239
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5visibleDestruct(MHEG5Visible *visible)
Destruct a visible object.
Definition: mh5visible.c:282
void MHEG5interactibleDeactivate(MHEG5Interactible *interactible)
Implementation of the deactivation behaviour of the interactible class. This behaviour was introduced...
MHEG5ErrorCode MHEG5select(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to select a button. Implementation of the Select action of the button cl...
Definition: mh5button.c:232
MHEG5ErrorCode MHEG5deselect(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to deselect the button. Implementation of the Deselect action of the but...
Definition: mh5button.c:275
This file defines the profile for the MHEG engine.
#define MHEG5displayRedraw(v)
Definition: mh5display.h:47
MHEG5ErrorCode
Definition: mh5base.h:222
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
void MHEG5buttonDeactivate(MHEG5Button *button)
Apply the deactivation behaviour of the button class. As this class has no own deactivation behaviour...
Definition: mh5button.c:163
void MHEG5buttonInit(MHEG5Button *button)
<Function description>="">
Definition: mh5button.c:94
void MHEG5buttonPrepare(MHEG5Button *button)
Apply the preparation behaviour of the button class Apply the preparation behaviour of the button cla...
Definition: mh5button.c:128
#define MHEG5TRUE
Definition: mh5base.h:49
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.
Mheg5 logging and debug printing.
MHEG5Interactible interactible
Definition: mh5button.h:51
void MHEG5buttonDestruct(MHEG5Button *button)
Destruct a button object.
Definition: mh5button.c:179
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
void MHEG5interactibleInit(MHEG5Interactible *interactible)
<Function description>="">
MHEG5Bool selectionStatus
Definition: mh5button.h:57
void MHEG5interactibleFree(MHEG5Interactible *interactible)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
MHEG5Visible visible
Definition: mh5button.h:50
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
void MHEG5visibleDeactivate(MHEG5Visible *visible)
Apply the deactivation behaviour of the visible class. As this class has no own deactivation behaviou...
Definition: mh5visible.c:338
#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
void MHEG5visibleInit(MHEG5Visible *visible)
Initialise a visible object with default values.
Definition: mh5visible.c:172