A window, root of the Control tree

Each window should hold a single control, usually a CompositeControl, which in turn holds all the displayed controls.

Introduced properties

fun act_notif

app :: Window :: act_notif

Action when pressing but_notif
fun act_toast

app :: Window :: act_toast

Action when pressing but_toast
init defaultinit(parent: nullable CompositeControl)

app :: Window :: defaultinit

fun enable_back_button: Bool

app :: Window :: enable_back_button

Should the back button be shown and used to go back to a previous window?
protected fun native=(native: NATIVE)

app :: Window :: native=

protected fun native=(native: NATIVE)

app :: Window :: native=

fun on_back_button

app :: Window :: on_back_button

The back button has been pressed, usually to open the previous window
fun title: String

app :: Window :: title

Title of this window
fun title=(title: String)

app :: Window :: title=

Set the title of this window
fun view: nullable View

app :: Window :: view

Root high-level view of this window
fun view: nullable View

app :: Window :: view

Root view of this window
protected fun view=(view: nullable View)

app :: Window :: view=

Root high-level view of this window
protected fun view=(view: nullable View)

app :: Window :: view=

Root view of this window

Redefined properties

redef type NATIVE: Android_app_Fragment

android :: ui $ Window :: NATIVE

Type of native
redef type NATIVE: NitViewController

ios :: ui $ Window :: NATIVE

Type of the native implementation of this control
redef type SELF: Window

app $ Window :: SELF

Type of this instance, automatically specialized in every class
redef fun add(view: Control)

ios :: ui $ Window :: add

Add item as a child of self
redef fun add(view: Control)

linux :: ui $ Window :: add

Add item as a child of self
redef fun add(item: Control)

android :: ui $ Window :: add

Add item as a child of self
redef init init

android :: ui_test $ Window :: init

redef fun native: NATIVE

android :: ui $ Window :: native

The Android element used to implement self
redef fun native: NATIVE

ios :: ui $ Window :: native

Native implementation of this control
redef fun on_event(event: AppEvent)

android :: ui_test $ Window :: on_event

Notification of event raised by sender

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: GtkWidget

app :: Control :: NATIVE

Type of native
type NATIVE: JavaObject

app :: Control :: NATIVE

Type of native
type NATIVE: NSObject

app :: Control :: NATIVE

Type of the native implementation of this control
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun act_notif

app :: Window :: act_notif

Action when pressing but_notif
fun act_toast

app :: Window :: act_toast

Action when pressing but_toast
protected fun add(item: Control)

app :: CompositeControl :: add

Add item as a child of self
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.
fun clear

app :: CompositeControl :: clear

Remove all items from self
init defaultinit(parent: nullable CompositeControl)

app :: Window :: defaultinit

init defaultinit(parent: nullable CompositeControl)

app :: Control :: defaultinit

fun enable_back_button: Bool

app :: Window :: enable_back_button

Should the back button be shown and used to go back to a previous window?
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 has(item: Control): Bool

app :: CompositeControl :: has

Is item in 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.
protected fun items: Array[Control]

app :: CompositeControl :: items

Child controls composing this control
protected fun items=(items: Array[Control])

app :: CompositeControl :: items=

Child controls composing this control
abstract fun native: NATIVE

app :: Control :: native

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

app :: Control :: native

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

app :: Control :: native

Native implementation of this control
protected fun native=(native: NATIVE)

app :: Window :: native=

protected fun native=(native: NATIVE)

app :: Window :: native=

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_back_button

app :: Window :: on_back_button

The back button has been pressed, usually to open the previous window
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 remove(item: Control)

app :: CompositeControl :: remove

Remove item from self
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
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun title: String

app :: Window :: title

Title of this window
fun title=(title: String)

app :: Window :: title=

Set the title of this window
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun view: nullable View

app :: Window :: view

Root high-level view of this window
fun view: nullable View

app :: Window :: view

Root view of this window
protected fun view=(view: nullable View)

app :: Window :: view=

Root high-level view of this window
protected fun view=(view: nullable View)

app :: Window :: view=

Root view of this window
package_diagram app::Window Window app::CompositeControl CompositeControl app::Window->app::CompositeControl app::Control Control app::CompositeControl->app::Control ...app::Control ... ...app::Control->app::Control app::HttpRequestClientWindow HttpRequestClientWindow app::HttpRequestClientWindow->app::Window app::UiExampleWindow UiExampleWindow app::UiExampleWindow->app::Window app::SecondWindow SecondWindow app::SecondWindow->app::Window

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

class CompositeControl

app :: CompositeControl

A Control grouping other controls

Children

class HttpRequestClientWindow

app :: HttpRequestClientWindow

Simple window with a label and a button
class SecondWindow

app :: SecondWindow

Another window with a small VerticalLayout
class UiExampleWindow

app :: UiExampleWindow

Window showing off some the available controls

Class definitions

app $ Window
# A window, root of the `Control` tree
#
# Each window should hold a single control, usually a `CompositeControl`,
# which in turn holds all the displayed controls.
class Window
	super CompositeControl

	# Should the back button be shown and used to go back to a previous window?
	fun enable_back_button: Bool do return app.window_stack.length > 1

	# The back button has been pressed, usually to open the previous window
	fun on_back_button do app.pop_window
end
lib/app/ui.nit:202,1--214,3

ios :: ui $ Window
redef class Window

	redef type NATIVE: NitViewController
	redef var native = new NitViewController

	# Title of this window
	fun title: String do return native.title.to_s

	# Set the title of this window
	fun title=(title: String) do native.title = title.to_nsstring

	redef fun add(view)
	do
		super

		var native_view = view.native
		assert native_view isa UIView

		if view isa ListLayout then
			native.view.add_subview native_view
		else native.view = native_view
	end
end
lib/ios/ui/ui.nit:206,1--228,3

linux :: ui $ Window
# On GNU/Linux, a window is implemented by placing the `view` in a `GtkStack` in the single GTK window
redef class Window

	# Root view of this window
	var view: nullable View = null

	redef fun add(view)
	do
		if view isa View then
			self.view = view
			view.native.valign = new GtkAlign.start
			view.native.set_size_request(gtk_window_width_request, 0)
		end

		super
	end
end
lib/linux/ui.nit:121,1--137,3

android :: ui $ Window
# On Android, a window is implemented with the fragment `native`
redef class Window
	redef var native = (new Android_app_Fragment(self)).new_global_ref

	redef type NATIVE: Android_app_Fragment

	# Root high-level view of this window
	var view: nullable View = null

	redef fun add(item)
	do
		if item isa View then view = item
		super
	end

	private fun on_create_fragment: NativeView
	do
		on_create

		var view = view
		assert view != null else print_error "{class_name} needs a `view` after `Window::on_create` returns"
		return view.native
	end
end
lib/android/ui/ui.nit:107,1--130,3

android :: ui_test $ Window
redef class Window

	private var layout = new VerticalLayout(parent=self)

	private var but_notif = new Button(parent=layout, text="Show Notification")
	private var but_toast = new Button(parent=layout, text="Show Toast")

	private var notif: nullable Notification = null

	init
	do
		but_notif.observers.add self
		but_toast.observers.add self
	end

	# Action when pressing `but_notif`
	fun act_notif
	do
		var notif = self.notif
		if notif == null then
			notif = new Notification("From app.nit", "Some content...")
			notif.ticker = "Ticker text..."
			notif.show
			self.notif = notif
		else
			notif.cancel
			self.notif = null
		end
	end

	# Action when pressing `but_toast`
	fun act_toast
	do
		app.toast("Sample toast from app.nit at {get_time}", false)
	end

	redef fun on_event(event)
	do
		print "on_event {event}"
		if event isa ButtonPressEvent then
			var sender = event.sender
			if sender == but_notif then
				act_notif
			else if sender == but_toast then
				act_toast
			end
		end
	end
end
lib/android/examples/src/ui_test.nit:39,1--87,3