1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.runtime
.lcdui
.mle
;
12 import cc
.squirreljme
.jvm
.mle
.UIFormShelf
;
13 import cc
.squirreljme
.jvm
.mle
.brackets
.UIDisplayBracket
;
14 import cc
.squirreljme
.jvm
.mle
.brackets
.UIDrawableBracket
;
15 import cc
.squirreljme
.jvm
.mle
.brackets
.UIFormBracket
;
16 import cc
.squirreljme
.jvm
.mle
.brackets
.UIItemBracket
;
17 import cc
.squirreljme
.jvm
.mle
.brackets
.UIWidgetBracket
;
18 import cc
.squirreljme
.jvm
.mle
.callbacks
.UIDisplayCallback
;
19 import cc
.squirreljme
.jvm
.mle
.callbacks
.UIFormCallback
;
20 import cc
.squirreljme
.jvm
.mle
.constants
.UIItemPosition
;
21 import cc
.squirreljme
.jvm
.mle
.constants
.UIItemType
;
22 import cc
.squirreljme
.jvm
.mle
.constants
.UIMetricType
;
23 import cc
.squirreljme
.jvm
.mle
.constants
.UIWidgetProperty
;
24 import cc
.squirreljme
.jvm
.mle
.exceptions
.MLECallError
;
25 import cc
.squirreljme
.runtime
.cldc
.annotation
.Exported
;
28 * This interface is used as a wrapper around {@link UIFormShelf}, it is
29 * implemented by a class and essentially is used to forward calls to the
30 * true backing implementation. This is here so that in the event that
31 * {@link UIFormShelf} is not supported, that there is a fall-back.
36 public interface UIBackend
39 * Registers a callback for a display when it needs to be drawn or the
40 * display state changes.
42 * @param __display The display that the callback will act under.
43 * @param __callback The callback to register.
44 * @throws MLECallError If {@code __display} is {@code null}.
45 * @see UIDisplayCallback
49 void callback(UIDisplayBracket __display
,
50 UIDisplayCallback __callback
)
54 * This is used to register the callback which is called with the user
55 * interface events and otherwise.
57 * @param __form The form that the callback will act under.
58 * @param __callback The callback to register.
59 * @throws MLECallError If {@code __form} is {@code null}.
63 void callback(UIFormBracket __form
, UIFormCallback __callback
)
67 * Returns the displays which are attached to the system.
69 * @return The display heads which are attached to a system, these objects
70 * here represent physical displays.
71 * @throws MLECallError If there are no displays.
75 UIDisplayBracket
[] displays()
79 * Returns the form that is currently being shown on the display.
81 * @param __display The display to query.
82 * @return The form that is currently shown or {@code null}.
83 * @throws MLECallError On null arguments.
87 UIFormBracket
displayCurrent(UIDisplayBracket __display
)
91 * Shows the given display without having a form be displayed on the
92 * display, this can be used for raw graphics operations such as canvases
95 * @param __display The display to show.
96 * @param __show Should the display be shown or hidden?
97 * @throws MLECallError If {@code __display} is {@code null} or there was
98 * an error showing the display.
102 void displayShow(UIDisplayBracket __display
,
107 * Show the given form on the display.
109 * @param __display The form to display on screen.
110 * @param __form The form to display, if {@code null} then no item is
111 * shown on the display.
112 * @throws MLECallError On {@code __display} is {@code null}.
116 void displayShow(UIDisplayBracket __display
, UIFormBracket __form
)
120 * Checks if the two displays represent the same {@link UIDisplayBracket}.
122 * @param __a The first.
123 * @param __b The second.
124 * @return If these are the same display.
125 * @throws MLECallError If either is {@code null}.
129 boolean equals(UIDisplayBracket __a
, UIDisplayBracket __b
)
133 * Checks if the two drawables represent the same
134 * {@link UIDrawableBracket}.
136 * @param __a The first.
137 * @param __b The second.
138 * @return If these are the same drawable.
139 * @throws MLECallError If either is {@code null}.
143 boolean equals(UIDrawableBracket __a
, UIDrawableBracket __b
)
147 * Checks if the two displays represent the same {@link UIFormBracket}.
149 * @param __a The first.
150 * @param __b The second.
151 * @return If these are the same form.
152 * @throws MLECallError If either is {@code null}.
156 boolean equals(UIFormBracket __a
, UIFormBracket __b
)
160 * Checks if the two displays represent the same {@link UIItemBracket}.
162 * @param __a The first.
163 * @param __b The second.
164 * @return If these are the same item.
165 * @throws MLECallError If either is {@code null}.
169 boolean equals(UIItemBracket __a
, UIItemBracket __b
)
173 * Checks if the two displays represent the same {@link UIWidgetBracket}.
175 * @param __a The first.
176 * @param __b The second.
177 * @return If these are the same item.
178 * @throws MLECallError If either is {@code null}.
182 boolean equals(UIWidgetBracket __a
, UIWidgetBracket __b
)
186 * Flushes all of the events and forces them to be processed.
188 * @throws MLECallError If events could not be flushed.
196 * Deletes the given form.
198 * @param __form The form to delete.
199 * @throws MLECallError On null arguments or the form could not be deleted.
203 void formDelete(UIFormBracket __form
)
207 * Returns the item at the given location.
209 * @param __form The form to check.
210 * @param __pos The position to check, may be {@link UIItemPosition}.
211 * @return The item at the given position or {@code null} if it is not
213 * @throws MLECallError If the form is not valid or if the position is
218 UIItemBracket
formItemAtPosition(UIFormBracket __form
, int __pos
)
222 * Returns the number of items on the form.
224 * @param __form The form to get the count from.
225 * @return The number of normal items on the form.
226 * @throws MLECallError If the form is null or not valid.
230 int formItemCount(UIFormBracket __form
)
234 * Returns the position of the item on the given form, or if it is not
237 * @param __form The form to get from.
238 * @param __item The item being queried.
239 * @return The position of the item, may be one of
240 * {@link UIItemPosition} or
241 * {@link UIItemPosition#NOT_ON_FORM} if not on the form.
242 * @throws MLECallError If the form and item are null.
246 int formItemPosition(UIFormBracket __form
, UIItemBracket __item
)
250 * Sets the position of a form's item.
252 * @param __form The form to set on.
253 * @param __item The item to set.
254 * @param __pos The position to set the item at, may be one of
255 * {@link UIItemPosition}.
256 * @throws MLECallError If the form or item are null, or the position
261 void formItemPosition(UIFormBracket __form
, UIItemBracket __item
,
266 * Removes the item at the given position on the form.
268 * @param __form The form to remove from.
269 * @param __pos The item to be removed.
270 * @return The item that was removed.
271 * @throws MLECallError If the form or item are null, the position is
272 * not valid, or there was no item at the position.
276 UIItemBracket
formItemRemove(UIFormBracket __form
, int __pos
)
280 * Creates a new form.
282 * @return The newly created form.
283 * @throws MLECallError If the form could not be created.
287 UIFormBracket
formNew()
291 * Forces a form to be refreshed.
293 * @param __form The form to refresh
294 * @throws MLECallError On null arguments or the form is not valid.
298 void formRefresh(UIFormBracket __form
)
302 * Returns the injector for forms, which is used for testing purposes.
304 * @return The injector for the shelf.
305 * @throws MLECallError If injecting is not supported.
309 UIFormCallback
injector()
313 * Deletes the specified item.
315 * @param __item The item to delete.
316 * @throws MLECallError On null arguments, if the item could not be
317 * deleted, if the item was already deleted, or if the item is currently
318 * active within a form.
322 void itemDelete(UIItemBracket __item
)
326 * Returns the form the item is on.
328 * @param __item The item to get.
329 * @return The form the item is on.
330 * @throws MLECallError If {@code __item} is {@code null}.
334 UIFormBracket
itemForm(UIItemBracket __item
)
338 * Creates a new item.
340 * @param __type The {@link UIItemType} to create.
341 * @return The newly created item.
342 * @throws MLECallError If the item could not be created or the type was
347 UIItemBracket
itemNew(int __type
)
351 * Calls the given method serially within the main event handler.
353 * @param __display The display identifier.
354 * @param __serialId The serial identifier.
355 * @throws MLECallError If the call is not valid.
359 void later(UIDisplayBracket __display
, int __serialId
)
363 * Returns a metric which describes something about the user interface
364 * forms implementation or other details about the system.
366 * @param __display The display to get the metric of.
367 * @param __metric One of {@link UIMetricType}. The metric
368 * {@link UIMetricType#UIFORMS_SUPPORTED} is always a valid metric and
369 * must be supported, even if the implementation lacks forms.
370 * @return The value of the metric.
371 * @throws MLECallError If the metric is out of range or forms are not
372 * supported and the metric is not {@link UIMetricType#UIFORMS_SUPPORTED}.
376 int metric(UIDisplayBracket __display
, int __metric
)
380 * Sets the given item property.
382 * @param __item The item to set.
383 * @param __intProp The {@link UIWidgetProperty}.
384 * @param __sub The sub-index.
385 * @param __newValue The new value to set.
386 * @throws MLECallError If the item is not valid or the property is not
387 * valid or not an integer property.
391 void widgetProperty(UIWidgetBracket __item
, int __intProp
, int __sub
,
395 * Sets the given item property.
397 * @param __item The item to set.
398 * @param __strProp The {@link UIWidgetProperty}.
399 * @param __sub The sub-index.
400 * @param __newValue The new value to set.
401 * @throws MLECallError If the item is not valid or the property is not
402 * valid or not a string property.
406 void widgetProperty(UIWidgetBracket __item
, int __strProp
, int __sub
,
410 * Gets a property of the given widget.
412 * @param __widget The widget to get from.
413 * @param __intProp The {@link UIWidgetProperty}.
414 * @param __sub The sub-index.
415 * @return The value of the property.
416 * @throws MLECallError If the widget or property is not valid.
420 int widgetPropertyInt(UIWidgetBracket __widget
, int __intProp
, int __sub
)
424 * Gets a property of the given widget.
426 * @param __widget The widget to get from.
427 * @param __strProp The {@link UIWidgetProperty}.
428 * @param __sub The sub-index.
429 * @return The value of the property.
430 * @throws MLECallError If the widget or property is not valid.
434 String
widgetPropertyStr(UIWidgetBracket __widget
, int __strProp
,