Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Zeug
Friday, March 28th, 2008 at 3:00:50pm UTC 

  1. /***************************************************************************
  2. *             __________               __   ___.
  3. *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
  4. *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
  5. *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
  6. *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
  7. *                     \/            \/     \/    \/            \/
  8. * $Id: viewport.c 16812 2008-03-26 03:35:24Z jdgordon $
  9. *
  10. * Copyright (C) 2008 by Jonathan Gordon
  11. *
  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.
  14. *
  15. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  16. * KIND, either express or implied.
  17. *
  18. ****************************************************************************/
  19.  
  20. #include "config.h"
  21. #include "lcd.h"
  22. #include "lcd-remote.h"
  23. #include "font.h"
  24. #include "sprintf.h"
  25. #include "string.h"
  26. #include "settings.h"
  27. #include "kernel.h"
  28. #include "system.h"
  29. #include "misc.h"
  30. #include "atoi.h"
  31. #include "viewport.h"
  32. #include "statusbar.h"
  33. #include "screen_access.h"
  34. #include "debug.h"
  35.  
  36. #define VP_STRUCTURE_PARAM_ERROR 0
  37.  
  38. int viewport_get_nb_lines(struct viewport *vp)
  39. {
  40. #ifdef HAVE_LCD_BITMAP
  41.     return vp->height/font_get(vp->font)->height;
  42. #else
  43.     (void)vp;
  44.     return 2;
  45. #endif
  46. }
  47.  
  48.  
  49. void viewport_set_defaults(struct viewport *vp, enum screen_type screen)
  50. {
  51.     vp->xmargin = 0;
  52.     vp->ymargin = 0;
  53.     vp->x = 0;
  54.     vp->width = screens[screen].width;
  55.    
  56.     vp->y = global_settings.statusbar?STATUSBAR_HEIGHT:0;
  57.     vp->height = screens[screen].height - vp->y;
  58. #ifdef HAVE_LCD_BITMAP
  59.     vp->drawmode = DRMODE_SOLID;
  60.     vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */
  61. #endif
  62.  
  63. #ifdef HAVE_REMOTE_LCD
  64.     /* We only need this test if there is a remote LCD */
  65.     if (screen == SCREEN_MAIN)
  66. #endif
  67.     {
  68. #ifdef HAVE_LCD_COLOR
  69.         vp->fg_pattern = global_settings.fg_color;
  70.         vp->bg_pattern = global_settings.bg_color;
  71.         vp->lss_pattern = global_settings.lss_color;
  72.         vp->lse_pattern = global_settings.lse_color;
  73.         vp->lst_pattern = global_settings.lst_color;
  74. #elif LCD_DEPTH > 1
  75.         vp->fg_pattern = LCD_DEFAULT_FG;
  76.         vp->bg_pattern = LCD_DEFAULT_BG;
  77. #endif
  78.     }
  79.  
  80. #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
  81.     if (screen == SCREEN_REMOTE)
  82.     {
  83.         vp->fg_pattern = LCD_REMOTE_DEFAULT_FG;
  84.         vp->bg_pattern = LCD_REMOTE_DEFAULT_BG;
  85.     }
  86. #endif
  87. }
  88.  
  89. /* custonlist code handles status bar seperately, since statusbar height
  90. * is ignored when the list y position > statusbar height */
  91. void viewport_set_defaults_ignoring_statusbar(struct viewport *vp, enum screen_type screen)
  92. {
  93.     viewport_set_defaults(vp, screen);
  94.     vp->y = 0;
  95.     vp->height = screens[screen].height;
  96. }
  97.  
  98. int viewport_parse_viewport(struct viewport *vp,
  99.          const char *bufptr, const char seperator, enum screen_type screen)
  100. {
  101.     /* parse the list to the viewport struct */
  102.     char *ptr = bufptr;
  103. #if LCD_DEPTH > 2
  104.     if (!(ptr = parse_list("dddddcc", seperator, ptr, &vp->x, &vp->y, &vp->width,
  105.         &vp->height, &vp->font, &vp->fg_pattern,&vp->bg_pattern)))
  106. #endif
  107. #if (LCD_DEPTH == 2) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2)
  108.     if (!(ptr = parse_list("dddddgg", seperator, ptr, &vp->x, &vp->y, &vp->width,
  109.             &vp->height, &vp->font, &vp->fg_pattern, &vp->bg_pattern)))
  110. #endif
  111. #if (LCD_DEPTH == 1) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 1)
  112.     if (!(ptr = parse_list("ddddd", seperator, ptr, &vp->x, &vp->y, &vp->width,
  113.                                                   &vp->height, &vp->font)))
  114. #endif
  115.     {
  116.         return VP_STRUCTURE_PARAM_ERROR;
  117.     }
  118.  
  119.  
  120.     /* Validate the viewport dimensions - we know that the numbers are
  121.        non-negative integers */
  122.     if ((vp->x >= screens[screen].width) ||
  123.         ((vp->x + vp->width) > screens[screen].width) ||
  124.         (vp->y >= screens[screen].height) ||
  125.         ((vp->y + vp->height) > screens[screen].height))
  126.     {
  127.         return VP_STRUCTURE_PARAM_ERROR;
  128.     }
  129.  
  130.     /* Default to using the user font if the font was an invalid number */
  131.     if ((vp->font != FONT_SYSFIXED) && (vp->font != FONT_UI))
  132.         vp->font = FONT_UI;
  133.  
  134.     return ptr;
  135. }

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right