### Eclipse Workspace Patch 1.0
#P rockbox
Index: firmware/drivers/lcd-16bit.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-16bit.c,v
retrieving revision 1.41
diff -u -r1.41 lcd-16bit.c
--- firmware/drivers/lcd-16bit.c	4 Jan 2007 12:13:56 -0000	1.41
+++ firmware/drivers/lcd-16bit.c	15 Jan 2007 22:26:42 -0000
@@ -59,6 +59,7 @@
 static int drawmode = DRMODE_SOLID;
 static int xmargin = 0;
 static int ymargin = 0;
+static int custom_width = LCD_WIDTH;
 static int curfont = FONT_SYSFIXED;
 
 /* scrolling */
@@ -141,6 +142,16 @@
     ymargin = y;
 }
 
+void lcd_set_custom_width(int width)
+{
+    custom_width = xmargin+width;
+}
+
+int lcd_get_custom_width(void)
+{
+    return custom_width;
+}
+
 int lcd_getxmargin(void)
 {
     return xmargin;
@@ -741,7 +752,7 @@
 
     ucs = bidi_l2v(str, 1);
 
-    while ((ch = *ucs++) != 0 && x < LCD_WIDTH)
+    while ((ch = *ucs++) != 0 && x < lcd_get_custom_width())
     {
         int width;
         const unsigned char *bits;
@@ -757,7 +768,9 @@
 
         bits = font_get_bits(pf, ch);
 
-        lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, width - ofs, pf->height);
+        lcd_mono_bitmap_part(bits, ofs, 0, width, x, y, 
+        	(x+width > lcd_get_custom_width()?lcd_get_custom_width()-x:width) - ofs, 
+        	pf->height);
 
         x += width - ofs;
         ofs = 0;
@@ -810,7 +823,7 @@
     lcd_putsxyofs(xpos, ypos, offset, str);
     drawmode ^= DRMODE_INVERSEVID;
     xrect = xpos + MAX(w - offset, 0);
-    lcd_fillrect(xrect, ypos, LCD_WIDTH - xrect, h);
+    lcd_fillrect(xrect, ypos, lcd_get_custom_width() - xrect, h);
     drawmode = lastmode;
 }
 
@@ -887,7 +900,7 @@
 
     lcd_getstringsize(string, &w, &h);
 
-    if (LCD_WIDTH - x * 8 - xmargin < w) {
+    if (lcd_get_custom_width() - x * 8 - xmargin < w) {
         /* prepare scroll line */
         char *end;
 
@@ -900,7 +913,7 @@
         /* scroll bidirectional or forward only depending on the string
            width */
         if ( bidir_limit ) {
-            s->bidir = s->width < (LCD_WIDTH - xmargin) *
+            s->bidir = s->width < (lcd_get_custom_width() - xmargin) *
                 (100 + bidir_limit) / 100;
         }
         else
@@ -913,7 +926,7 @@
         }
 
         end = strchr(s->line, '\0');
-        strncpy(end, string, LCD_WIDTH/2);
+        strncpy(end, string, lcd_get_custom_width()/2);
 
         s->len = utf8length(string);
         s->offset = offset;
@@ -965,9 +978,9 @@
                     s->backward = false;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
-                if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
+                if (s->offset >= s->width - (lcd_get_custom_width() - xpos)) {
                     /* at end of line */
-                    s->offset = s->width - (LCD_WIDTH - xpos);
+                    s->offset = s->width - (lcd_get_custom_width() - xpos);
                     s->backward = true;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
@@ -983,7 +996,8 @@
                        (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
             lcd_putsxyofs(xpos, ypos, s->offset, s->line);
             drawmode = lastmode;
-            lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
+            lcd_update_rect(xpos, ypos, lcd_get_custom_width() - xpos, 
+            				pf->height);
         }
 
         sleep(scroll_ticks);
Index: apps/screen_access.c
===================================================================
RCS file: /cvsroot/rockbox/apps/screen_access.c,v
retrieving revision 1.26
diff -u -r1.26 screen_access.c
--- apps/screen_access.c	1 Jul 2006 10:14:26 -0000	1.26
+++ apps/screen_access.c	24 Aug 2006 17:54:29 -0000
@@ -117,6 +117,8 @@
             screen->width=LCD_WIDTH;
             screen->height=LCD_HEIGHT;
             screen->setmargins=&lcd_setmargins;
+            screen->set_custom_width=&lcd_set_custom_width;
+            screen->get_custom_width=&lcd_get_custom_width;
             screen->getymargin=&lcd_getymargin;
             screen->getxmargin=&lcd_getxmargin;
             screen->setfont=&lcd_setfont;
Index: apps/screen_access.h
===================================================================
RCS file: /cvsroot/rockbox/apps/screen_access.h,v
retrieving revision 1.27
diff -u -r1.27 screen_access.h
--- apps/screen_access.h	1 Jul 2006 10:14:27 -0000	1.27
+++ apps/screen_access.h	24 Aug 2006 17:54:29 -0000
@@ -63,6 +63,8 @@
 
 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */
     void (*setmargins)(int x, int y);
+    void (*set_custom_width)(int width);
+    int (*get_custom_width)(void);
     int (*getxmargin)(void);
     int (*getymargin)(void);
 
Index: firmware/export/lcd.h
===================================================================
--- firmware/export/lcd.h	(revision 12887)
+++ firmware/export/lcd.h	(working copy)
@@ -306,6 +306,10 @@
 extern void lcd_setmargins(int xmargin, int ymargin);
 extern int  lcd_getxmargin(void);
 extern int  lcd_getymargin(void);
+
+extern int  lcd_get_custom_width(void);
+extern void  lcd_set_custom_width(int width);
+
 extern void lcd_setfont(int font);
 extern int  lcd_getstringsize(const unsigned char *str, int *w, int *h);
 
