MHEG5  18.9.0
MHEG5 Documentation
mh5pushbutton.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 "mh5profile.h"
33 #include "mh5pushbutton.h"
34 #include "mh5application.h"
35 #include "mh5memory.h" /*for constructor/destructor */
36 #include "mh5object.h"
37 #include "mh5display.h" /* API to real display */
38 #include "mh5variable.h"
39 #include <stdlib.h>
40 #include <string.h>
41 
42 #ifndef MHEG5PROFILE_UK1_06
43 
44 /*
45  Debug
46  */
47 #ifdef MH5PRINTOUT
48 
55 void MHEG5pushbuttonPrint(MHEG5Pushbutton *pushbutton, char *out)
56 {
57  MHEG5buttonPrint(&pushbutton->button, out);
58 
59  /* exchanged attributes */
60  MHEG5indent(out);
61  MHEG_PRINT(out, ":OriginalLabel ");
62  MHEG5stringPrint(pushbutton->originalLabel, out);
63  MHEG5newLine(out);
64 
65  MHEG5indent(out);
66  MHEG_PRINT(out, ":CharacterSet ");
67  MHEG5intPrint(pushbutton->characterSet, out);
68  MHEG5newLine(out);
69 }
70 
71 #endif
72 
73 
74 /*
75  Constructor
76  */
77 
84 {
85  assert(pushbutton);
86 
87  MHEG5buttonInit(&pushbutton->button);
88 }
89 
98 {
99  assert(pushbutton);
100 
101  MHEG5buttonFree(&pushbutton->button);
102 
103  MHEG5stringDestruct(&pushbutton->originalLabel);
104 }
105 
106 /*
107  Internal behaviours
108  */
109 /*
110  32.3 Internal behaviours
111  this class has the same behaviours as its base class, with identical semantics.
112  */
114 {
115  assert(pushbutton);
116 
117  if (!(MHEG5Root *)pushbutton->availabilityStatus)
118  {
119  pushbutton->label = MHEG5stringCopy(pushbutton->originalLabel);
120  }
121 
122  MHEG5buttonPrepare(&pushbutton->button);
123 }
124 
126 {
127  assert(pushbutton);
128  MHEG5buttonActivate(&pushbutton->button);
129 }
130 
132 {
133  assert(pushbutton);
134  MHEG5buttonDeactivate(&pushbutton->button);
135 }
136 
138 {
139  assert(pushbutton);
140 
141  MHEG5buttonDestruct(&pushbutton->button);
142 
143  MHEG5stringDestruct(&pushbutton->label);
144 }
145 
147 {
148  MHEG5String newLabel;
149  MHEG5Pushbutton *pushbutton;
150  MHEG5Bool invalidString;
151 
152  assert(target);
153 
154  if ((target->clazz != MHEG5PUSHBUTTON) &&
155  (target->clazz != MHEG5SWITCHBUTTON))
156  {
157  return MHEG5ERR_WRONGTARGET;
158  }
159  if (!params)
160  {
162  }
163 
164  MHEG5resolveGenericOctetString(params, &newLabel, &invalidString);
165  if (invalidString)
166  {
167  /* Parameter was not an octet string */
168  return MHEG5ERR_WRONGPARAM;
169  }
170 
171  pushbutton = (MHEG5Pushbutton *)target;
172  MHEG5stringDestruct(&pushbutton->label);
173 
174  pushbutton->label = MHEG5stringCopy(newLabel);
175 
176  MHEG5displayRedraw((MHEG5Visible *) target);
177 
178  return MHEG5ERR_NOERROR;
179 }
180 
182 {
183  MHEG5Root *var = 0;
184  MHEG5Pushbutton *pushbutton;
185  MHEG5OctetStringVariable *oc_var;
186 
187  assert(target);
188 
189  if ((target->clazz != MHEG5PUSHBUTTON) &&
190  (target->clazz != MHEG5SWITCHBUTTON))
191  {
192  return MHEG5ERR_WRONGTARGET;
193  }
194 
195  if (!params)
196  {
198  }
199  MHEG5resolveORef(params, &var);
200  if (!var)
201  {
203  }
204  if (var->clazz != MHEG5OCTETSTRINGVARIABLE)
205  {
206  return MHEG5ERR_WRONGPARAM;
207  }
208 
209  oc_var = (MHEG5OctetStringVariable *)var;
210  pushbutton = (MHEG5Pushbutton *)target;
211  MHEG5stringDestruct(&oc_var->value);
212  oc_var->value = MHEG5stringCopy(pushbutton->label);
213 
214  return MHEG5ERR_NOERROR;
215 }
216 
217 #endif
MHEG5ErrorCode MHEG5setLabel(MHEG5Root *target, MHEG5GList *params)
void MHEG5pushbuttonFree(MHEG5Pushbutton *pushbutton)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5pushbutton.c:97
void MHEG5pushbuttonDestruct(MHEG5Pushbutton *pushbutton)
void MHEG5pushbuttonActivate(MHEG5Pushbutton *pushbutton)
void MHEG5pushbuttonInit(MHEG5Pushbutton *pushbutton)
Initialise a pushbutton object with default values.
Definition: mh5pushbutton.c:83
MHEG5Button button
Definition: mh5pushbutton.h:39
MHEG5Final clazz
Definition: mh5root.h:55
MHEG5ErrorCode MHEG5getLabel(MHEG5Root *target, MHEG5GList *params)
MHEG5String label
Definition: mh5pushbutton.h:46
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
MHEG5String MHEG5stringCopy(MHEG5String source)
<Function description>="">
Definition: mh5base.c:574
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5stringDestruct(MHEG5String *item)
Destruct a MHEG5String.
Definition: mh5base.c:686
void MHEG5buttonInit(MHEG5Button *button)
<Function description>="">
Definition: mh5button.c:94
This file defines the profile for the MHEG engine.
MHEG5GList * MHEG5resolveGenericOctetString(MHEG5GList *params, MHEG5String *value, MHEG5Bool *invalidString)
Resolve a parameter reference to a generic octet string. The reference can be either direct or indire...
Definition: mh5object.c:478
#define MHEG5displayRedraw(v)
Definition: mh5display.h:47
MHEG5Int characterSet
Definition: mh5pushbutton.h:43
short MHEG5Bool
Definition: mh5base.h:71
MHEG5ErrorCode
Definition: mh5base.h:222
MHEG5String originalLabel
Definition: mh5pushbutton.h:42
void MHEG5buttonFree(MHEG5Button *button)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5button.c:109
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.
void MHEG5pushbuttonDeactivate(MHEG5Pushbutton *pushbutton)
Implement the MHEG5 PushButton Class. Defines labelled, largely rectangular areas on the screen...
redirection include
void MHEG5buttonDestruct(MHEG5Button *button)
Destruct a button object.
Definition: mh5button.c:179
void MHEG5buttonPrepare(MHEG5Button *button)
Apply the preparation behaviour of the button class Apply the preparation behaviour of the button cla...
Definition: mh5button.c:128
void MHEG5buttonDeactivate(MHEG5Button *button)
Apply the deactivation behaviour of the button class. As this class has no own deactivation behaviour...
Definition: mh5button.c:163
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
void MHEG5pushbuttonPrepare(MHEG5Pushbutton *pushbutton)