Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2008 by Jonathan Gordon |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 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. |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
Bertrik Sikken | 2843469 | 2008-04-28 16:18:04 +0000 | [diff] [blame] | 22 | #include <stdlib.h> |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 23 | #include "config.h" |
| 24 | #include "lcd.h" |
Dave Chapman | 2b7d48e | 2008-03-09 23:53:46 +0000 | [diff] [blame] | 25 | #include "lcd-remote.h" |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 26 | #include "font.h" |
| 27 | #include "sprintf.h" |
| 28 | #include "string.h" |
| 29 | #include "settings.h" |
| 30 | #include "kernel.h" |
| 31 | #include "system.h" |
| 32 | #include "misc.h" |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 33 | #include "viewport.h" |
| 34 | #include "statusbar.h" |
| 35 | #include "screen_access.h" |
| 36 | |
| 37 | int viewport_get_nb_lines(struct viewport *vp) |
| 38 | { |
| 39 | #ifdef HAVE_LCD_BITMAP |
| 40 | return vp->height/font_get(vp->font)->height; |
| 41 | #else |
| 42 | (void)vp; |
| 43 | return 2; |
| 44 | #endif |
| 45 | } |
| 46 | |
| 47 | |
| 48 | void viewport_set_defaults(struct viewport *vp, enum screen_type screen) |
| 49 | { |
| 50 | vp->x = 0; |
| 51 | vp->width = screens[screen].width; |
| 52 | |
Jonathan Gordon | daa8341 | 2008-05-04 10:58:05 +0000 | [diff] [blame] | 53 | vp->y = gui_statusbar_height(); |
Jonathan Gordon | 5ca1539 | 2008-03-26 03:35:24 +0000 | [diff] [blame] | 54 | vp->height = screens[screen].height - vp->y; |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 55 | #ifdef HAVE_LCD_BITMAP |
| 56 | vp->drawmode = DRMODE_SOLID; |
| 57 | vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ |
| 58 | #endif |
Dave Chapman | 2b7d48e | 2008-03-09 23:53:46 +0000 | [diff] [blame] | 59 | |
| 60 | #ifdef HAVE_REMOTE_LCD |
| 61 | /* We only need this test if there is a remote LCD */ |
| 62 | if (screen == SCREEN_MAIN) |
| 63 | #endif |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 64 | { |
| 65 | #ifdef HAVE_LCD_COLOR |
| 66 | vp->fg_pattern = global_settings.fg_color; |
| 67 | vp->bg_pattern = global_settings.bg_color; |
| 68 | vp->lss_pattern = global_settings.lss_color; |
| 69 | vp->lse_pattern = global_settings.lse_color; |
| 70 | vp->lst_pattern = global_settings.lst_color; |
| 71 | #elif LCD_DEPTH > 1 |
| 72 | vp->fg_pattern = LCD_DEFAULT_FG; |
| 73 | vp->bg_pattern = LCD_DEFAULT_BG; |
| 74 | #endif |
| 75 | } |
Dave Chapman | 2b7d48e | 2008-03-09 23:53:46 +0000 | [diff] [blame] | 76 | |
| 77 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 |
| 78 | if (screen == SCREEN_REMOTE) |
| 79 | { |
| 80 | vp->fg_pattern = LCD_REMOTE_DEFAULT_FG; |
| 81 | vp->bg_pattern = LCD_REMOTE_DEFAULT_BG; |
| 82 | } |
| 83 | #endif |
Jonathan Gordon | 0e5cec2 | 2008-03-05 09:58:30 +0000 | [diff] [blame] | 84 | } |