df8731366b37d788e2ab5ff86258e018221fb4da
[jvcard.git] / src / be / nikiroo / jvcard / tui / panes / MainContent.java
1 package be.nikiroo.jvcard.tui.panes;
2
3 import java.util.List;
4
5 import be.nikiroo.jvcard.tui.KeyAction;
6
7 import com.googlecode.lanterna.gui2.Direction;
8 import com.googlecode.lanterna.gui2.LinearLayout;
9 import com.googlecode.lanterna.gui2.Panel;
10
11 /**
12 * This class represents the main content that you can see in this application
13 * (i.e., everything but the title and the actions keys is a {@link Panel}
14 * extended from this class).
15 *
16 * @author niki
17 *
18 */
19 abstract public class MainContent extends Panel {
20
21 public MainContent() {
22 super();
23 }
24
25 public MainContent(Direction dir) {
26 super();
27 LinearLayout layout = new LinearLayout(dir);
28 layout.setSpacing(0);
29 setLayoutManager(layout);
30 }
31
32 /**
33 * The title to display instead of the application name, or NULL for the
34 * default application name.
35 *
36 * @return the title or NULL
37 */
38 abstract public String getTitle();
39
40 /**
41 * Returns an error message ready to be displayed if we should ask something
42 * to the user before exiting.
43 *
44 * @return an error message or NULL
45 */
46 abstract public String getExitWarning();
47
48 /**
49 * The {@link KeyAction#Mode} that links to this {@link MainContent}.
50 *
51 * @return the linked mode
52 */
53 abstract public KeyAction.Mode getMode();
54
55 /**
56 * The kind of data displayed by this {@link MainContent}.
57 *
58 * @return the kind of data displayed
59 */
60 abstract public KeyAction.DataType getDataType();
61
62 /**
63 * Returns the list of actions and the keys that are bound to it.
64 *
65 * @return the list of actions
66 */
67 abstract public List<KeyAction> getKeyBindings();
68
69 /**
70 * Move the active cursor (not the text cursor, but the currently active
71 * item).
72 *
73 * @param x
74 * the horizontal move (&lt; 0 for left, &gt; 0 for right)
75 * @param y
76 * the vertical move (&lt; 0 for up, &gt; 0 for down)
77 *
78 * @return the error message to display if any
79 */
80 abstract public String move(int x, int y);
81 }