quick fix for FS#8729
[Rockbox.git] / apps / gui / viewport.c
blob8f9998b2d62893670f1c9d416e4d169ebaadb8a4
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2008 by Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include <stdlib.h>
21 #include "config.h"
22 #include "lcd.h"
23 #include "lcd-remote.h"
24 #include "font.h"
25 #include "sprintf.h"
26 #include "string.h"
27 #include "settings.h"
28 #include "kernel.h"
29 #include "system.h"
30 #include "misc.h"
31 #include "viewport.h"
32 #include "statusbar.h"
33 #include "screen_access.h"
35 int viewport_get_nb_lines(struct viewport *vp)
37 #ifdef HAVE_LCD_BITMAP
38 return vp->height/font_get(vp->font)->height;
39 #else
40 (void)vp;
41 return 2;
42 #endif
46 void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
48 vp->x = 0;
49 vp->width = screens[screen].width;
51 vp->y = gui_statusbar_height();
52 vp->height = screens[screen].height - vp->y;
53 #ifdef HAVE_LCD_BITMAP
54 vp->drawmode = DRMODE_SOLID;
55 vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */
56 #endif
58 #ifdef HAVE_REMOTE_LCD
59 /* We only need this test if there is a remote LCD */
60 if (screen == SCREEN_MAIN)
61 #endif
63 #ifdef HAVE_LCD_COLOR
64 vp->fg_pattern = global_settings.fg_color;
65 vp->bg_pattern = global_settings.bg_color;
66 vp->lss_pattern = global_settings.lss_color;
67 vp->lse_pattern = global_settings.lse_color;
68 vp->lst_pattern = global_settings.lst_color;
69 #elif LCD_DEPTH > 1
70 vp->fg_pattern = LCD_DEFAULT_FG;
71 vp->bg_pattern = LCD_DEFAULT_BG;
72 #endif
75 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
76 if (screen == SCREEN_REMOTE)
78 vp->fg_pattern = LCD_REMOTE_DEFAULT_FG;
79 vp->bg_pattern = LCD_REMOTE_DEFAULT_BG;
81 #endif