neo: Correct the documentation of neo.nit according to PR #734.
[nit.git] / lib / app.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2011-2014 Alexis Laferrière <alexis.laf@xymus.net>
4 #
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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 # app.nit is a framework to create cross-platform applications
18 #
19 # The features offered by this modules are common to all platforms, but
20 # may not be available on all devices.
21 module app is
22 new_annotation app_name
23 new_annotation app_version
24 end
25
26 # App subclasses are cross-platform applications
27 #
28 # This class is redefed by plateform modules and so
29 # App can be specialized directly in the user app.
30 class App
31 protected init do end
32
33 # Starts the internal setup of graphical and other stuff
34 # Is called just before run
35 fun setup do end
36
37 # Main entry point of your application
38 fun run do end
39
40 # Prefix to all log messages, used by `log_error`, `log_warning` and `log_info`.
41 fun log_prefix: String do return "app.nit"
42
43 # Helper function for logging errors
44 fun log_error(msg: String) do sys.stderr.write "{log_prefix} error: {msg}\n"
45
46 # Helper function for logging warnings
47 fun log_warning(msg: String) do sys.stderr.write "{log_prefix} warn: {msg}\n"
48
49 # Main init method for graphical stuff
50 # Is called when display is ready so graphical assets
51 # can be loaded at this time.
52 fun window_created do end
53
54 # Called before destroying the window
55 fun window_closing do end
56 end
57
58 protected fun app: App do return once new App
59 app.setup
60 app.run