MHEG5  18.9.0
MHEG5 Documentation
mh5switchbutton.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 <stdlib.h>
33 #include <string.h>
34 
35 #include "mh5profile.h"
36 #include "mh5switchbutton.h"
37 #include "mh5object.h"
38 #include "mh5variable.h"
39 
40 #ifndef MHEG5PROFILE_UK1_06
41 
42 /*
43  Debug
44  */
45 #ifdef MH5PRINTOUT
46 
53 void MHEG5switchbuttonPrint(MHEG5Switchbutton *switchbutton, char *out)
54 {
55  MHEG5pushbuttonPrint(&switchbutton->pushbutton, out);
56  MHEG5indent(out);
57  /* Exchanged Attribute */
58  MHEG_PRINT(out, ":Style: ");
59  switch (switchbutton->style)
60  {
61  case MHEG5PUSHBUTTONS:
62  MHEG_PRINT(out, "PUSHBUTTONS");
63  break;
64  case MHEG5RADIOBUTTON:
65  MHEG_PRINT(out, "RADIOBUTTON");
66  break;
67  case MHEG5CHECKBOX:
68  MHEG_PRINT(out, "CHECKBOX");
69  break;
70  default:
71  MHEG_PRINT(out, "<Internal Error>");
72  break;
73  }
74  MHEG5newLine(out);
75 }
76 
77 #endif
78 
79 /*
80  Constructor
81  */
82 
89 {
90  assert(switchbutton);
91 
92  MHEG5pushbuttonInit(&switchbutton->pushbutton);
93 
94  switchbutton->style = MHEG5PUSHBUTTONS;
95 }
96 
105 {
106  assert(switchbutton);
107 
108  MHEG5pushbuttonFree(&switchbutton->pushbutton);
109 }
110 
111 /*
112  Internal behaviours
113  */
114 /*
115  32.3 Internal behaviours
116  this class has the same behaviours as its base class, with identical semantics.
117  */
118 
129 {
130  assert(switchbutton);
131  MHEG5pushbuttonPrepare(&switchbutton->pushbutton);
132 }
133 
143 {
144  assert(switchbutton);
145  MHEG5pushbuttonActivate(&switchbutton->pushbutton);
146 }
147 
157 {
158  assert(switchbutton);
159  MHEG5pushbuttonDeactivate(&switchbutton->pushbutton);
160 }
161 
169 {
170  assert(switchbutton);
171 
172  MHEG5pushbuttonDestruct(&switchbutton->pushbutton);
173 }
174 
175 /*
176  Actions
177  */
185 {
186  MHEG5Root *tVar = 0;
187 
188  assert(target);
189 
190  if (!params)
191  {
193  }
194  if (target->clazz != MHEG5SWITCHBUTTON)
195  {
196  return MHEG5ERR_WRONGTARGET;
197  }
198 
199  MHEG5resolveORef(params, &tVar);
200 
201  if (!tVar)
202  {
204  }
205  if (!tVar->runningStatus)
206  {
208  }
209 
210  if (tVar->clazz != MHEG5BOOLEANVARIABLE)
211  {
212  return MHEG5ERR_WRONGPARAM;
213  }
214 
215  ((MHEG5BooleanVariable *) tVar)->value = ((MHEG5Switchbutton *)target)->pushbutton.button.selectionStatus;
216 
217  return MHEG5ERR_NOERROR;
218 }
219 
231 {
232  assert(target);
233 
234  if (target->clazz != MHEG5SWITCHBUTTON)
235  {
236  return MHEG5ERR_WRONGTARGET;
237  }
238 
239  if ((((MHEG5Button *)target)->selectionStatus == MHEG5FALSE))
240  {
241  return MHEG5select(target, params);
242  }
243 
244  return MHEG5deselect(target, params);
245 }
246 
247 #endif
void MHEG5pushbuttonActivate(MHEG5Pushbutton *pushbutton)
MHEG5Final clazz
Definition: mh5root.h:55
MHEG5Pushbutton pushbutton
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
MHEG5PushbuttonStyle style
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
MHEG5ErrorCode MHEG5getSelectionStatus(MHEG5Root *target, MHEG5GList *params)
Implementation of the GetSelectionStatus action.
void MHEG5switchbuttonActivate(MHEG5Switchbutton *switchbutton)
Apply the activation behaviour of the switchbutton class. As this class has no own activation behavio...
MHEG5ErrorCode MHEG5toggle(MHEG5Root *target, MHEG5GList *params)
The effect of this action is to toggle the selection state of the switchbutton. Implementation of the...
This file defines the profile for the MHEG engine.
void MHEG5switchbuttonInit(MHEG5Switchbutton *switchbutton)
Initialise a switchbutton object with default values.
MHEG5ErrorCode
Definition: mh5base.h:222
void MHEG5switchbuttonDeactivate(MHEG5Switchbutton *switchbutton)
Apply the deactivation behaviour of the switchbutton class. As this class has no own deactivation beh...
Implement functions to retrieve MHEG5objects by GroupID and ID.
MHEG5Bool runningStatus
Definition: mh5root.h:51
void MHEG5switchbuttonDestruct(MHEG5Switchbutton *switchbutton)
Destruct a switchbutton object.
void MHEG5pushbuttonPrepare(MHEG5Pushbutton *pushbutton)
Implement the MHEG5 SwitchButton Class. Defines the behaviour of pressable buttons. Base class: PushButton. Subclasses: None. Status: Concrete class.
void MHEG5switchbuttonFree(MHEG5Switchbutton *switchbutton)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
void MHEG5pushbuttonDeactivate(MHEG5Pushbutton *pushbutton)
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
void MHEG5switchbuttonPrepare(MHEG5Switchbutton *switchbutton)
Apply the preparation behaviour of the switchbutton class Apply the preparation behaviour of the swit...
void MHEG5pushbuttonInit(MHEG5Pushbutton *pushbutton)
<Function description>="">
Definition: mh5pushbutton.c:83
void MHEG5pushbuttonFree(MHEG5Pushbutton *pushbutton)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5pushbutton.c:97
#define MHEG5FALSE
Definition: mh5base.h:48
void MHEG5pushbuttonDestruct(MHEG5Pushbutton *pushbutton)