A control displaying some text

For a text-only control, see Label.

Introduced properties

fun align=(align: nullable Float)

app :: TextView :: align=

Align the text horizontally
init defaultinit(parent: nullable CompositeControl, enabled: nullable Bool, text: nullable Text, size: nullable Float, align: nullable Float)

app :: TextView :: defaultinit

fun size=(size: nullable Float)

app :: TextView :: size=

Set the relative size of the text
abstract fun text: nullable Text

app :: TextView :: text

Main Text of this control
abstract fun text=(text: nullable Text)

app :: TextView :: text=

Main Text of this control

Redefined properties

redef type NATIVE: NativeTextView

android :: ui $ TextView :: NATIVE

Type of native
redef type SELF: TextView

app $ TextView :: SELF

Type of this instance, automatically specialized in every class
redef fun align=(align: nullable Float)

android :: ui $ TextView :: align=

Align the text horizontally
redef fun size=(size: nullable Float)

android :: ui $ TextView :: size=

Set the relative size of the text
redef fun text: nullable Text

android :: ui $ TextView :: text

Main Text of this control
redef fun text=(value: nullable Text)

android :: ui $ TextView :: text=

Main Text of this control

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type NATIVE: NSObject

app :: Control :: NATIVE

Type of the native implementation of this control
type NATIVE: JavaObject

app :: Control :: NATIVE

Type of native
type NATIVE: GtkWidget

app :: Control :: NATIVE

Type of native
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun align=(align: nullable Float)

app :: TextView :: align=

Align the text horizontally
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
init defaultinit(parent: nullable CompositeControl, enabled: nullable Bool)

app :: View :: defaultinit

init defaultinit(parent: nullable CompositeControl)

app :: Control :: defaultinit

init defaultinit(parent: nullable CompositeControl, enabled: nullable Bool, text: nullable Text, size: nullable Float, align: nullable Float)

app :: TextView :: defaultinit

abstract fun enabled: nullable Bool

app :: View :: enabled

Is this control enabled so the user can interact with it?
abstract fun enabled=(enabled: nullable Bool)

app :: View :: enabled=

Is this control enabled so the user can interact with it?
fun finalize

core :: Finalizable :: finalize

Liberate any resources held by self before the memory holding self is freed
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
abstract fun native: NATIVE

app :: Control :: native

The GTK element used to implement self
abstract fun native: NATIVE

app :: Control :: native

Native implementation of this control
abstract fun native: NATIVE

app :: Control :: native

The Android element used to implement self
fun notify_observers(event: AppEvent)

app :: AppComponent :: notify_observers

Propagate event to all observers by calling AppObserver::on_event
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun observers: HashSet[AppObserver]

app :: AppComponent :: observers

All AppObserver notified of events raised by self
protected fun observers=(observers: HashSet[AppObserver])

app :: AppComponent :: observers=

All AppObserver notified of events raised by self
fun on_create

app :: AppComponent :: on_create

The application is being created
fun on_destroy

app :: AppComponent :: on_destroy

The application is being destroyed
fun on_event(event: AppEvent)

app :: AppObserver :: on_event

Notification of event raised by sender
fun on_pause

app :: AppComponent :: on_pause

The application leaves the active state but is still partially visible
fun on_restart

app :: AppComponent :: on_restart

The application returns to a visible state from a previous on_stop
fun on_restore_state

app :: AppComponent :: on_restore_state

The application is launching, restore its state from a previous on_save_state
fun on_resume

app :: AppComponent :: on_resume

The application enters the active state, it is in the foreground and interactive
fun on_save_state

app :: AppComponent :: on_save_state

The application may be destroyed soon, save its state for a future on_restore_state
fun on_start

app :: AppComponent :: on_start

The application is starting or restarting, it is visible to the user
fun on_stop

app :: AppComponent :: on_stop

The application is completely hidden from the user
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun parent: nullable CompositeControl

app :: Control :: parent

Direct parent Control in the control tree
fun parent=(parent: nullable CompositeControl)

app :: Control :: parent=

Direct parent Control in the control tree
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
abstract fun signal(sender: GtkWidget, user_data: nullable Object)

gtk :: GtkCallable :: signal

return true to stop event processing, false to let it propagate
fun size=(size: nullable Float)

app :: TextView :: size=

Set the relative size of the text
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun text: nullable Text

app :: TextView :: text

Main Text of this control
abstract fun text=(text: nullable Text)

app :: TextView :: text=

Main Text of this control
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
package_diagram app::TextView TextView app::View View app::TextView->app::View app::Control Control app::View->app::Control ...app::Control ... ...app::Control->app::Control app::TextInput TextInput app::TextInput->app::TextView app::Button Button app::Button->app::TextView app::Label Label app::Label->app::TextView app::CheckBox CheckBox app::CheckBox->app::TextView linux::BackButton BackButton linux::BackButton->app::Button linux::BackButton... ... linux::BackButton...->linux::BackButton

Ancestors

abstract class AppComponent

app :: AppComponent

An element of an application that is notified of the application life cycle
interface AppObserver

app :: AppObserver

Observer of AppEvents raised by AppComponents
class Control

app :: Control

A control implementing the UI
class Finalizable

core :: Finalizable

An object needing finalization
interface GtkCallable

gtk :: GtkCallable

interface Object

core :: Object

The root of the class hierarchy.

Parents

abstract class View

app :: View

A visible Control

Children

class Button

app :: Button

A pressable button, raises ButtonPressEvent
class CheckBox

app :: CheckBox

Toggle control between two states, also displays a label
class Label

app :: Label

A simple text label
class TextInput

app :: TextInput

A control for the user to enter custom text

Descendants

class BackButton

linux :: BackButton

Button to go back between windows

Class definitions

app $ TextView
# A control displaying some `text`
#
# For a text-only control, see `Label`.
abstract class TextView
	super View

	# Main `Text` of this control
	#
	# By default, or if set to `null`, no text is shown.
	var text: nullable Text is writable, abstract, autoinit

	# Set the relative size of the text
	#
	# A value of 1.0, the default, use the platform default text size.
	# Values under 1.0 set a smaller text size, and over 1.0 a larger size.
	#
	# Implementation varies per platform, and some controls may be unaffected
	# depending on the customization options of each platform.
	# For consistent results, it is recommended to use only on instances
	# of `Label` and `size` should be either 0.5, 1.0 or 1.5.
	fun size=(size: nullable Float) is autoinit do end

	# Align the text horizontally
	#
	# Use 0.0 to align left (the default), 0.5 to align in the center and
	# 1.0 to align on the right.
	#
	# Implementation varies per platform, and some controls may be unaffected
	# depending on the customization options of each platform.
	# For consistent results, it is recommended to use only on instances
	# of `Label` and `size` should be either 0.0, 0.5 or 1.0.
	fun align=(align: nullable Float) is autoinit do end
end
lib/app/ui.nit:226,1--258,3

ios :: ui $ TextView
redef class TextView
	# Convert `size` from app.nit relative size to iOS font points
	private fun ios_points(size: nullable Float): Float
	do
		size = size or else 1.0
		return 8.0 + size * 5.0
	end
end
lib/ios/ui/ui.nit:266,1--273,3

android :: ui $ TextView
redef class TextView
	redef type NATIVE: NativeTextView

	redef fun text do return native.text.to_s
	redef fun text=(value) do
		if value == null then value = ""
		native.text = value.to_java_string
	end

	redef fun size=(size) do set_size_native(app.native_activity, native, size or else 1.0)

	private fun set_size_native(context: NativeContext, view: NativeTextView, size: Float)
	in "Java" `{
		int s;
		if (size == 1.0d)
			s = android.R.style.TextAppearance_Medium;
		else if (size < 1.0d)
			s = android.R.style.TextAppearance_Small;
		else // if (size > 1.0d)
			s = android.R.style.TextAppearance_Large;

		view.setTextAppearance(context, s);
	`}

	redef fun align=(align) do set_align_native(native, align or else 0.0)

	private fun set_align_native(view: NativeTextView, align: Float)
	in "Java" `{
		int g;
		if (align == 0.5d)
			g = android.view.Gravity.CENTER_HORIZONTAL;
		else if (align < 0.5d)
			g = android.view.Gravity.LEFT;
		else // if (align > 0.5d)
			g = android.view.Gravity.RIGHT;

		view.setGravity(g | android.view.Gravity.CENTER_VERTICAL);
	`}
end
lib/android/ui/ui.nit:222,1--260,3