1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2011-2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Base of the _app.nit_ framework, defines `App`
19 new_annotation app_name
20 new_annotation app_namespace
21 new_annotation app_version
22 new_annotation app_files
25 # App subclasses are cross-platform applications
27 # This class is refined by platform modules and so
28 # App can be specialized directly in the user application code.
34 # Starts the internal setup of graphical and other stuff
35 # Is called just before run
38 # Main entry point of your application
42 # An element of an application that is notified of the application life cycle
44 # Most users of _app.nit_ need only to implement `on_create` to setup the application.
46 # On mobile devices, the application can be stopped a anytime when another application takes the foreground.
47 # Implement the callbacks `on_save_state` and `on_load_state` to keep the state of the application between execution,
48 # for an illusion of continuous execution.
49 abstract class AppComponent
51 # The application is being created
53 # You should build the UI at this time.
56 # The application is starting or restarting, it is visible to the user
59 # The application enters the active state, it is in the foreground and interactive
62 # The application leaves the active state but is still partially visible
64 # It may still be visible in the background.
65 # It may then go back to `on_resume` or `on_stop`.
68 # The application is completely hidden from the user
70 # It may then be destroyed (`on_destroy`) or go back to `on_start`.
73 # The application is being destroyed
76 # The application may be destroyed soon, save its state for a future `on_restore_state`
77 fun on_save_state
do end
79 # The application is launching, restore its state from a previous `on_save_state`
80 fun on_restore_state
do end
84 fun print_warning
(object
: Object)
86 sys
.stderr
.write object
.to_s
91 fun app
: App do return once
new App