Control
From Pointui
Properties
Controls (ControlCollection)
Contains the child controls of this control. Child controls can be added or removed from this collection. Generally control hierarchy is configured in the Load() method of a control.
Attributes (NameValueCollection)
Provides a generic bin for storing key/value pairs. This is particularly useful for Applet descendents because they can store their settings in their Attributes collection which supports simple loading and saving to the file system. See NameValueCollection and File.Write() for more information.
Events
void OnClick(Control sender, int x, int y)
Triggered when the user clicks on the control. The OnClick event will only occur if the control and all parent controls leading back to the screen are visible, and each of those controls contain the point x, y.
void OnClickHold(Control sender, int x, int y)
Triggered when the user clicks and holds for a period of time on the control. The event will only occur if the control and all parent controls leading back to the screen are visible, and each of those controls contain the point x, y, and the user does not move their stylus while the click-hold gesture is being recognized.
Methods
void SetBounds(int x, int y)
Moves a control to the specified x, y coordinate which is relative to the parent bounds.
void SetBounds(int x, int y, int w)
Moves a control to the specified x, y coordinate which is relative to the parent bounds, and sets the width of the control.
void SetBounds(int x, int y, int w, int h)
Moves a control to the specified x, y coordinate which is relative to the parent bounds, and sets the width and height of the control.
void SetHeight(int height)
AVAILABLE SINCE: 2.1 Sets only the height of the control.
void SetWidthHeight(int width, int height)
AVAILABLE SINCE: 2.1 Sets only the width and height of the control.
int GetLeft()
Returns the left bounds of the control as an integer relative to the parent bounds.
int GetTop()
Returns the top bounds of the control as an integer relative to the parent bounds.
int GetWidth()
Returns the width of the control.
int GetHeight()
Returns the height of the control.
void SetClipping(int x, int y, int w, int h)
Specifies the area that is to be applied as the clipping region. Descendents of the Control class usually take note of this when rendering their contents and will not draw outside the specified region.
void SetOpacity(int opacity)
Sets the opacity of the control which is applied when the control is drawn. It’s up to each control to interpret this value. For instance an Image control will use this value directly when rendering it’s image to the screen and blend the image based on the opacity supplied.
PARAMETERS
- opacity – value between 0 (completely transparent) and 100 (completely opaque)
void SetSelected(bool selected)
Sets whether the control is selected or not. It’s up to each control to interpret this value. For instance, a Button control will use this to know whether to display the Image or ImageSelected graphic.
void SetVisible(bool visible)
Sets whether the control is visible or not. By setting a control to be hidden (visible = false) it will automatically hide all child controls, and by setting a control to visible it will automatically restore to visible any child controls which were previously visible.
void AnimateClear()
Clears all animations that were existing for the control. It is recommended that this is called before applying animations to controls that regularly have their animations set. This ensures that parallel animations do not run that contradict each other. For instance, if you specified two AnimateMove() animations in quick succession so that they both ran at the same time then they would each by trying to move the control to their respective destinations and the control would end up at an unexpected location.
void AnimateMove(int destX, int destY, float maxSpeed)
void AnimateMove(int destX, int destY, float maxSpeed, float startEasing)
void AnimateMove(int destX, int destY, float maxSpeed, float startEasing, float endEasing)
void AnimateMove(int destX, int destY, float maxSpeed, float startEasing, float endEasing, int startDelay)
Moves the control from it’s current location to the specified destination destX, destY position which are coordinates relative to the parent bounds.
PARAMETERS
- destX, destY – destination point to move the control to.
- maxSpeed – number of pixels to move each frame when moving at it’s maximum speed.
- startEasing – number of pixels to accelerate by each frame until reaching maxSpeed.
- endEasing – value between 0.0 (take effect immediately as soon as animation begins) and 1.0 (take effect when control has travelled 100% of the distance to it’s destX, destY coordinates – so in other words don’t take effect at all). For instance, 0.5 would have the end easing take effect when the control was halfway to it’s destX, destY. End easing will slow the control as it approaches it’s destination.
- startDelay – number of frames to pause the animation before it begins.
void AnimateFade(int startOpacity, int targetOpacity, float speed)
void AnimateFade(int startOpacity, int targetOpacity, float speed, int startDelay)
Fades a control in or out.
PARAMETERS
- startOpacity – value between 0 (completely transparent) and 100 (completely opaque). If the control does not have this opacity when the animation begins it will automatically be set. Additionally, the value -1 can be used if the current opacity of the control is not to be altered.
- targetOpacity – value between 0 (completely transparent) and 100 (completely opaque).
- startDelay – number of frames to pause the animation before it begins.
void AnimateAscend()
void SetTabStop(bool tabStopEnabled)
Sets if the control can be focused by navigating around with the dpad.
void SetPadding(int allSides)
void SetPadding(int topAndBottom, int leftAndRight)
void SetPadding(int top, int right, int bottom, int left)
Sets the padding for the control. The impact it will have on each control depends on how the control interprets this value. For instance, a Label control will adjust the text position based on the padding specified.
PARAMETERS
- allSides – padding in pixels to apply to all sides of the control.
- topAndBottom – padding to apply to the top and bottom edges of the control.
- leftAndRight – padding to apply to the left and right edges of the control.
- top, right, bottom, left – padding to apply to the specific edge of the control.
void AlignTo(Control control, String horizontalAlign, String verticalAlign)
Positions this control relative to the control specified, and according to the supplied horizontal and vertical alignment.
PARAMETERS
- control – the control to position this one relative to.
- horizontalAlign – must be one of the following values:
- “Left”
- “Center”
- “Right”
- verticalAlign – must be one of the following values:
- “Top”
- “Center”
- “Bottom”
void BringToFront()
Brings the control to the top of the z-order in relation to it’s sibling controls (all other controls that are a direct child of the parent of this control).
void SendToBack()
Sends the control to the bottom of the z-order.
void SetID(String id)
Sets the id of the control which can be used to uniquely identify the control.
void Load()
The Load() method is called once by the system as a control is being initialized. This method is typically overridden and contains code to set up the control hierarchy, and initialize any values.
void SetHotKey(String hotKey)
AVAILABLE SINCE: 2.0.28b Assigns a hot key to the control. Only the first character in the string is used as the hot key. NOTE: this should only be called once the control has been added to a Controls collection (using Controls.Add), otherwise the hot key won't work.
void SetFocus()
AVAILABLE SINCE: 2.1 Sets the focus to this control.
bool IsFocused()
AVAILABLE SINCE: 2.1 Returns true if the control currently has focus.
void GotFocus()
AVAILABLE SINCE: 2.1 This method is called when the control receives focus, so if you define a method named GotFocus() in your class that inherits from Control then you can respond to this event.
void LostFocus()
AVAILABLE SINCE: 2.1 This method is called when the control loses focus, so if you define a method named LostFocus() in your class that inherits from Control then you can respond to this event.
void FlagLayoutRequired()
AVAILABLE SINCE: 2.1 Flags that this control needs to have it's Layout method called. NOTE: Layout() is not called immediately, as the control may not even be visible or Home may not be the focused application, so to avoid unnecessary code from being executed the Layout() method is called the next time the control is about to be drawn.
void MouseUp(int x, int y)
AVAILABLE SINCE: 2.1 This method is called every time a mouse up event occurs. You can respond to these events by providing a MouseUp method in a custom class that inherits from Control (or any of it's descendants).
void MouseDown(int x, int y)
AVAILABLE SINCE: 2.1 This method is called every time a mouse up event occurs. You can respond to these events by providing a MouseUp method in a custom class that inherits from Control (or any of it's descendants).
