-
Notifications
You must be signed in to change notification settings - Fork 1
/
htmlmenuitem.mata
274 lines (174 loc) · 8.3 KB
/
htmlmenuitem.mata
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
// Switch to Mata interpreter/compiler
mata:
// Drops class object if it already exists
// mata drop menuitem()
// Definition of HTML Tag menuitem Mata Class
// Defines a command/menu item that the user can invoke from a popup menu// Information retrieved from http://www.w3schools.com/tags/tag_menuitem.asp
class menuitem extends htmlglobal {
// Define private member variables
private:
// Static/final variables
static string scalar opens, opene, close
// String scalar attributes
string scalar htmlchecked, htmlcommand, htmldefault, htmldisabled, htmlicon, htmllabel, htmlradiogroup, htmltype
// Make class args non-static to prevent assignment of class args to all instances of class
string scalar classargs
// Define public members/methods
public:
// Class constructor method
void new()
// Setter methods
class menuitem scalar setClassArgs(), setChecked(), setCommand(), setDefault(), setDisabled(), setIcon(), setLabel(), setRadiogroup(), setType()
// Getter methods
string scalar getOpens(), getOpene(), getClose(), print(), getClassArgs(), getChecked(), getCommand(), getDefault(), getDisabled(), getIcon(), getLabel(), getRadiogroup(), getType()
} // End of class declaration
// Class constructor method declaration
void menuitem::new() {
// Defines the start of the opening tag for the class
this.opens = "<menuitem"
// Defines the end of the opening tag for the class
this.opene = ">"
// Defines the closing tag for the class
this.close = "</menuitem>"
} // End of class constructor method definition
// Setter method for class arguments (appear between HTML tags)
class menuitem scalar menuitem::setClassArgs(| string scalar classarguments) {
// Defines arguments that appear between HTML tags
this.classargs = classarguments
// Return a copy of the object
return(this)
} // End of setter method for class arguments
// Specifies that the command/menu item should be checked when the page loads. Only for type="radio" or type="checkbox"
class menuitem scalar menuitem::setChecked(| string scalar methodarg) {
// Set the attribute checked for this class
this.htmlchecked = `" checked=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method checked declaration for class menuitem
//
class menuitem scalar menuitem::setCommand(| string scalar methodarg) {
// Set the attribute command for this class
this.htmlcommand = `" command=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method command declaration for class menuitem
// Marks the command/menu item as being a default command
class menuitem scalar menuitem::setDefault(| string scalar methodarg) {
// Set the attribute default for this class
this.htmldefault = `" default=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method default declaration for class menuitem
// Specifies that the command/menu item should be disabled
class menuitem scalar menuitem::setDisabled(| string scalar methodarg) {
// Set the attribute disabled for this class
this.htmldisabled = `" disabled=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method disabled declaration for class menuitem
// Specifies an icon for the command/menu item
class menuitem scalar menuitem::setIcon(| string scalar methodarg) {
// Set the attribute icon for this class
this.htmlicon = `" icon=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method icon declaration for class menuitem
// Required. Specifies the name of the command/menu item, as shown to the user
class menuitem scalar menuitem::setLabel(| string scalar methodarg) {
// Set the attribute label for this class
this.htmllabel = `" label=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method label declaration for class menuitem
// Specifies the name of the group of commands that will be toggled when the command/menu item itself is toggled. Only for type="radio"
class menuitem scalar menuitem::setRadiogroup(| string scalar methodarg) {
// Set the attribute radiogroup for this class
this.htmlradiogroup = `" radiogroup=""' + methodarg + `"""'
// Return a copy of the object
return(this)
} // End of Method radiogroup declaration for class menuitem
// Specifies the type of command/menu item. Default is "command"
class menuitem scalar menuitem::setType(| string scalar methodarg) {
// Validate argument
if (methodarg == "checkbox" | methodarg == "command" | methodarg == "radio") {
// Set the attribute value
this.htmltype = `" type=""' + methodarg + `"""'
} // End IF Block for validated argument value
// Return a copy of the object
return(this)
} // End of Method type declaration for class menuitem
// Getter method for opening bracket
string scalar menuitem::getOpens() {
// Returns the opening bracket/tag w/o > character to allow attributes
return(this.opens)
} // End of getter method for opens member of class menuitem
// Getter method for opening bracket closing character
string scalar menuitem::getOpene() {
// Returns the closing character for the opening bracket
return(this.opene)
} // End of getter method for opene member of class menuitem
// Getter method for closing bracket
string scalar menuitem::getClose() {
// Returns the closing bracket/tag
return(this.close)
} // End of getter method for close member of class menuitem
// Getter method for class arguments
string scalar menuitem::getClassArgs() {
// Returns the class arguments that appear between the HTML tags
return(this.classargs)
} // End of getter method for class arguments member of class menuitem
// Getter method for checked member variable
string scalar menuitem::getChecked() {
// Returns the checked variable
return(this.htmlchecked)
} // End of getter method for checked member of class menuitem
// Getter method for command member variable
string scalar menuitem::getCommand() {
// Returns the command variable
return(this.htmlcommand)
} // End of getter method for command member of class menuitem
// Getter method for default member variable
string scalar menuitem::getDefault() {
// Returns the default variable
return(this.htmldefault)
} // End of getter method for default member of class menuitem
// Getter method for disabled member variable
string scalar menuitem::getDisabled() {
// Returns the disabled variable
return(this.htmldisabled)
} // End of getter method for disabled member of class menuitem
// Getter method for icon member variable
string scalar menuitem::getIcon() {
// Returns the icon variable
return(this.htmlicon)
} // End of getter method for icon member of class menuitem
// Getter method for label member variable
string scalar menuitem::getLabel() {
// Returns the label variable
return(this.htmllabel)
} // End of getter method for label member of class menuitem
// Getter method for radiogroup member variable
string scalar menuitem::getRadiogroup() {
// Returns the radiogroup variable
return(this.htmlradiogroup)
} // End of getter method for radiogroup member of class menuitem
// Getter method for type member variable
string scalar menuitem::getType() {
// Returns the type variable
return(this.htmltype)
} // End of getter method for type member of class menuitem
// Get the HTML tag w/attributes and arguments
string scalar menuitem::print() {
// Create local variables to piece together return string
string scalar open, args, close
// Create opening string
open = getOpens() + getChecked() + getCommand() + getDefault() + getDisabled() + getIcon() + getLabel() + getRadiogroup() + getType() + globalAttrs() + getOpene()
// Get class arguments
args = getClassArgs()
// Get closing tag
close = getClose()
// Return the complete HTML string
return(char((10)) + subinstr(open, " >", ">") + args + close + char((10)))
} // End of print method for class menuitem
// End of Mata session
end