Also fix Debug->View partitions when SECTOR_SIZE!=512
[kugel-rb.git] / apps / gui / viewport.h
blob0e5ad30f358f022c05a9c9450510b991886ceac0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef __VIEWPORT_H__
23 #define __VIEWPORT_H__
26 #include "config.h"
27 #include "lcd.h"
28 #include "system.h"
29 #include "screen_access.h"
31 /* return the number of text lines in the vp viewport */
32 int viewport_get_nb_lines(const struct viewport *vp);
34 void viewport_set_defaults(struct viewport *vp,
35 const enum screen_type screen);
37 /* Used to specify which screens the statusbar (SB) should be displayed on.
39 * The parameter is a bit OR'ed combination of the following (screen is
40 * SCREEN_MAIN or SCREEN_REMOTE from screen_access.h):
42 * VP_SB_HIDE_ALL means "hide the SB on all screens"
43 * VP_SB_ONSCREEN(screen) means "display the SB on the given screen
44 * as specified by the SB setting for that screen"
45 * VP_SB_IGNORE_SETTING(screen) means "ignore the SB setting for that screen"
46 * VP_SB_ALLSCREENS means "VP_SB_ONSCREEN for all screens"
48 * In most cases, VP_SB_ALLSCREENS should be used which means display the SB
49 * as specified by the settings.
50 * For the WPS (and other possible exceptions) use VP_SB_IGNORE_SETTING() to
51 * FORCE the statusbar on for the given screen (i.e it will show regardless
52 * of the setting)
54 * Returns the status before the call. This value can be used to restore the
55 * SB "displaying rules".
59 #define THEME_STATUSBAR (BIT_N(0))
60 #define THEME_UI_VIEWPORT (BIT_N(1))
61 #define THEME_BUTTONBAR (BIT_N(2))
62 #define THEME_LANGUAGE (BIT_N(3))
63 #define THEME_ALL (~(0u))
65 #define VP_SB_HIDE_ALL 0
66 #define VP_SB_ONSCREEN(screen) BIT_N(screen)
67 #define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen)
68 #define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1))
70 #ifndef __PCTOOL__
72 * Initialize the viewportmanager, which in turns initializes the UI vp and
73 * statusbar stuff
75 void viewportmanager_init(void);
76 int viewportmanager_get_statusbar(void);
77 int viewportmanager_set_statusbar(const int enabled);
81 * Initializes the given viewport with maximum dimensions minus status- and
82 * buttonbar
84 void viewport_set_fullscreen(struct viewport *vp,
85 const enum screen_type screen);
87 #ifdef HAVE_LCD_BITMAP
89 /* call this when a theme changed */
90 void viewportmanager_theme_changed(const int);
93 * Returns a pointer to the current viewport
94 * - That could be the UI vp, or a viewport passed to do_menu() or the like
96 struct viewport* viewport_get_current_vp(void);
99 * Set the UI vp pointer to a different one - NULL to reset to the UI vp
101 * This is needed since the UI viewport needs is kept in RAM.
103 void viewport_set_current_vp(struct viewport* vp);
106 * returns true if the ui viewport is active on the screen
108 bool viewport_ui_vp_get_state(const enum screen_type screen);
109 #ifdef HAVE_TOUCHSCREEN
110 bool viewport_point_within_vp(const struct viewport *vp,
111 const int x, const int y);
112 #endif
114 #else /* HAVE_LCD_CHARCELL */
115 #define viewport_set_current_vp(a)
116 #define viewport_get_current_vp() NULL
117 #define viewportmanager_theme_changed(a)
118 #endif
120 #endif /* __PCTOOL__ */
122 #ifdef HAVE_LCD_BITMAP
125 * Parse a viewport definition (vp_def), which looks like:
127 * Screens with depth > 1:
128 * X|Y|width|height|font|foregorund color|background color
129 * Screens with depth = 1:
130 * X|Y|width|height|font
132 * | is a separator and can be specified via the parameter
134 * Returns the pointer to the char after the last character parsed
135 * if everything went OK or NULL if an error happened (some values
136 * not specified in the definition)
138 const char* viewport_parse_viewport(struct viewport *vp,
139 enum screen_type screen,
140 const char *vp_def,
141 const char separator);
142 #endif /* HAVE_LCD_BITMAP */
143 #endif /* __VIEWPORT_H__ */