Index: apps/bookmark.c
===================================================================
RCS file: /cvsroot/rockbox/apps/bookmark.c,v
retrieving revision 1.56
diff -u -p -r1.56 bookmark.c
--- apps/bookmark.c	13 Nov 2006 00:45:19 -0000	1.56
+++ apps/bookmark.c	5 Jan 2007 19:29:01 -0000
@@ -442,7 +442,7 @@ bool bookmark_autoload(const char* file)
         FOR_NB_SCREENS(i)
         {
 #ifdef HAVE_LCD_BITMAP
-            screens[i].setmargins(0, STATUSBAR_HEIGHT);
+            screens[i].setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
             screens[i].puts_scroll(0,0, str(LANG_BOOKMARK_AUTOLOAD_QUERY));
             screens[i].puts(0,1, str(LANG_CONFIRM_WITH_PLAY_RECORDER));
             screens[i].puts(0,2, str(LANG_BOOKMARK_SELECT_LIST_BOOKMARKS));
@@ -566,10 +566,10 @@ static char* select_bookmark(const char*
 
 #ifdef HAVE_LCD_BITMAP
     int i;
-    int x = lcd_getxmargin();
+    int x = lcd_getleftmargin();
     int y = lcd_getymargin();
     FOR_NB_SCREENS(i)
-        screens[i].setmargins(0, 0);
+        screens[i].setmargins(0, LCD_WIDTH, 0);
 #endif
 
     bookmark_count = get_bookmark_count(bookmark_file_name);
@@ -620,12 +620,12 @@ static char* select_bookmark(const char*
                 if (global_settings.statusbar)
                 {
                     FOR_NB_SCREENS(i)
-                        screens[i].setmargins(0, STATUSBAR_HEIGHT);
+                        screens[i].setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
                 }
                 else
                 {
                    FOR_NB_SCREENS(i)
-                        screens[i].setmargins(0, 0);
+                        screens[i].setmargins(0, LCD_WIDTH, 0);
                 }
 #endif
                 action_signalscreenchange();
@@ -653,7 +653,7 @@ static char* select_bookmark(const char*
             case ACTION_BMS_EXIT:
 #ifdef HAVE_LCD_BITMAP
                 FOR_NB_SCREENS(i)
-                    screens[i].setmargins(x, y);
+                    screens[i].setmargins(x, LCD_WIDTH, y);
 #endif
                 action_signalscreenchange();
                 return NULL;
Index: apps/debug_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/debug_menu.c,v
retrieving revision 1.240
diff -u -p -r1.240 debug_menu.c
--- apps/debug_menu.c	4 Jan 2007 12:13:55 -0000	1.240
+++ apps/debug_menu.c	5 Jan 2007 19:29:02 -0000
@@ -118,7 +118,7 @@ static bool dbg_os(void)
     int line;
 #endif
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
     lcd_clear_display();
 
@@ -242,7 +242,7 @@ static bool dbg_audio_thread(void)
     char buf[32];
     struct audio_debug d;
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
 
     while(1)
@@ -314,7 +314,7 @@ static bool dbg_audio_thread(void)
 
     tick_add_task(dbg_audio_task);
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
     while(!done)
     {
@@ -484,7 +484,7 @@ static bool dbg_hw_info(void)
 
     system_memory_guard(oldmode);  /* re-enable memory guard */
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
     lcd_clear_display();
 
@@ -548,7 +548,7 @@ static bool dbg_hw_info(void)
 
     system_memory_guard(oldmode);  /* re-enable memory guard */
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
     lcd_clear_display();
 
@@ -570,7 +570,7 @@ static bool dbg_hw_info(void)
 #elif CONFIG_CPU == PP5020
     char buf[32];
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, 0, 0);
     lcd_setfont(FONT_SYSFIXED);
     lcd_clear_display();
 
@@ -769,7 +769,7 @@ static bool dbg_spdif(void)
     int spdif_source = spdif_get_output_source(&spdif_src_on);
     spdif_set_output_source(AUDIO_SRC_SPDIF, true);
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_clear_display();
     lcd_setfont(FONT_SYSFIXED);
 
@@ -975,7 +975,7 @@ bool dbg_ports(void)
     int adc_battery_voltage, adc_battery_level;
 
     lcd_setfont(FONT_SYSFIXED);
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_clear_display();
 
     while(1)
@@ -1026,7 +1026,7 @@ bool dbg_ports(void)
     char buf[128];
     int line;
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_clear_display();
     lcd_setfont(FONT_SYSFIXED);
 
@@ -1110,7 +1110,7 @@ bool dbg_ports(void)
     char buf[128];
     int line;
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_clear_display();
     lcd_setfont(FONT_SYSFIXED);
 
@@ -1290,7 +1290,7 @@ static bool dbg_cpufreq(void)
     int button;
 
 #ifdef HAVE_LCD_BITMAP
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
 #endif
     lcd_clear_display();
@@ -1352,7 +1352,7 @@ static bool view_battery(void)
     unsigned short maxv, minv;
     char buf[32];
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
 
     while(1)
@@ -1545,7 +1545,7 @@ static bool dbg_mmc_info(void)
 
     card_name[6] = '\0';
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
 
     while (!done)
@@ -1657,7 +1657,7 @@ static bool dbg_disk_info(void)
     char pio3[2], pio4[2];
 
 #ifdef HAVE_LCD_BITMAP
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
 
     while(!done)
@@ -1813,7 +1813,7 @@ static bool dbg_dircache_info(void)
     int line;
     char buf[32];
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
 
     while (!done)
@@ -1868,7 +1868,7 @@ static bool dbg_tagcache_info(void)
     char buf[32];
     struct tagcache_stat *stat;
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_setfont(FONT_SYSFIXED);
 
     while (!done)
@@ -1985,7 +1985,7 @@ static bool dbg_fm_radio(void)
     bool fm_detected;
 
 #ifdef HAVE_LCD_BITMAP
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
 
     while(1)
Index: apps/logfdisp.c
===================================================================
RCS file: /cvsroot/rockbox/apps/logfdisp.c,v
retrieving revision 1.11
diff -u -p -r1.11 logfdisp.c
--- apps/logfdisp.c	15 Aug 2006 12:27:04 -0000	1.11
+++ apps/logfdisp.c	5 Jan 2007 19:29:03 -0000
@@ -64,7 +64,7 @@ bool logfdisplay(void)
     if(!lines)
         return false;
 
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
     lcd_clear_display();
     
     do {
Index: apps/onplay.c
===================================================================
RCS file: /cvsroot/rockbox/apps/onplay.c,v
retrieving revision 1.97
diff -u -p -r1.97 onplay.c
--- apps/onplay.c	27 Dec 2006 02:37:12 -0000	1.97
+++ apps/onplay.c	5 Jan 2007 19:29:03 -0000
@@ -1037,9 +1037,9 @@ int onplay(char* file, int attr, int fro
 
 #ifdef HAVE_LCD_BITMAP
         if (global_settings.statusbar)
-            lcd_setmargins(0, STATUSBAR_HEIGHT);
+            lcd_setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
         else
-            lcd_setmargins(0, 0);
+            lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
     }
 
Index: apps/playlist.c
===================================================================
RCS file: /cvsroot/rockbox/apps/playlist.c,v
retrieving revision 1.181
diff -u -p -r1.181 playlist.c
--- apps/playlist.c	27 Dec 2006 01:51:33 -0000	1.181
+++ apps/playlist.c	5 Jan 2007 19:29:05 -0000
@@ -479,9 +479,9 @@ static int add_indices_to_playlist(struc
     
 #ifdef HAVE_LCD_BITMAP
     if(global_settings.statusbar)
-        lcd_setmargins(0, STATUSBAR_HEIGHT);
+        lcd_setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
     else
-        lcd_setmargins(0, 0);
+        lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
 
     gui_syncsplash(0, true, str(LANG_PLAYLIST_LOAD));
@@ -1658,9 +1658,9 @@ static void display_playlist_count(int c
 
 #ifdef HAVE_LCD_BITMAP
     if(global_settings.statusbar)
-        lcd_setmargins(0, STATUSBAR_HEIGHT);
+        lcd_setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
     else
-        lcd_setmargins(0, 0);
+        lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
 
     gui_syncsplash(0, true, fmt, count,
Index: apps/plugin.c
===================================================================
RCS file: /cvsroot/rockbox/apps/plugin.c,v
retrieving revision 1.206
diff -u -p -r1.206 plugin.c
--- apps/plugin.c	1 Jan 2007 13:21:19 -0000	1.206
+++ apps/plugin.c	5 Jan 2007 19:29:06 -0000
@@ -586,9 +586,9 @@ int plugin_load(const char* plugin, void
     plugin_loaded = true;
 
 #ifdef HAVE_LCD_BITMAP
-    xm = lcd_getxmargin();
+    xm = lcd_getleftmargin();
     ym = lcd_getymargin();
-    lcd_setmargins(0,0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
 
 #if LCD_DEPTH > 1
     old_backdrop = lcd_get_backdrop();
@@ -601,9 +601,9 @@ int plugin_load(const char* plugin, void
 #endif
 
 #ifdef HAVE_REMOTE_LCD
-    rxm = lcd_remote_getxmargin();
+    rxm = lcd_remote_getleftmargin();
     rym = lcd_remote_getymargin();
-    lcd_remote_setmargins(0, 0);
+    lcd_remote_setmargins(0, LCD_REMOTE_WIDTH, 0);
     lcd_remote_clear_display();
     lcd_remote_update();
 #endif
@@ -628,7 +628,7 @@ int plugin_load(const char* plugin, void
     lcd_set_drawmode(DRMODE_SOLID);
 #endif /* LCD_DEPTH */
     /* restore margins */
-    lcd_setmargins(xm,ym);
+    lcd_setmargins(xm, LCD_WIDTH, ym);
     lcd_clear_display();
     lcd_update();
 #endif /* HAVE_LCD_BITMAP */
@@ -640,7 +640,7 @@ int plugin_load(const char* plugin, void
 #else
     lcd_remote_set_drawmode(DRMODE_SOLID);
 #endif
-    lcd_remote_setmargins(rxm, rym);
+    lcd_remote_setmargins(rxm, LCD_REMOTE_WIDTH, rym);
     lcd_remote_clear_display();
     lcd_remote_update();
 #endif
Index: apps/plugin.h
===================================================================
RCS file: /cvsroot/rockbox/apps/plugin.h,v
retrieving revision 1.211
diff -u -p -r1.211 plugin.h
--- apps/plugin.h	1 Jan 2007 13:21:19 -0000	1.211
+++ apps/plugin.h	5 Jan 2007 19:29:06 -0000
@@ -148,7 +148,7 @@ struct plugin_api {
     void (*PREFIX(lcd_icon))(int icon, bool enable);
     void (*lcd_double_height)(bool on);
 #else
-    void (*lcd_setmargins)(int x, int y);
+    void (*lcd_setmargins)(int leftmargin, int rightmargin, int ymargin);
     void (*lcd_set_drawmode)(int mode);
     int  (*lcd_get_drawmode)(void);
     void (*lcd_setfont)(int font);
Index: apps/screen_access.c
===================================================================
RCS file: /cvsroot/rockbox/apps/screen_access.c,v
retrieving revision 1.30
diff -u -p -r1.30 screen_access.c
--- apps/screen_access.c	14 Oct 2006 01:32:58 -0000	1.30
+++ apps/screen_access.c	5 Jan 2007 19:29:07 -0000
@@ -46,7 +46,8 @@ void screen_init(struct screen * screen,
             screen->height=LCD_REMOTE_HEIGHT;
             screen->setmargins=&lcd_remote_setmargins;
             screen->getymargin=&lcd_remote_getymargin;
-            screen->getxmargin=&lcd_remote_getxmargin;
+            screen->getleftmargin=&lcd_remote_getleftmargin;
+            screen->getrightmargin=&lcd_remote_getrightmargin;
             screen->setfont=&lcd_remote_setfont;
             screen->setfont(FONT_UI);
             screen->getstringsize=&lcd_remote_getstringsize;
@@ -121,7 +122,8 @@ void screen_init(struct screen * screen,
             screen->height=LCD_HEIGHT;
             screen->setmargins=&lcd_setmargins;
             screen->getymargin=&lcd_getymargin;
-            screen->getxmargin=&lcd_getxmargin;
+            screen->getleftmargin=&lcd_getleftmargin;
+            screen->getrightmargin=&lcd_getrightmargin;
             screen->setfont=&lcd_setfont;
             screen->setfont(FONT_UI);
             screen->getstringsize=&lcd_getstringsize;
Index: apps/screen_access.h
===================================================================
RCS file: /cvsroot/rockbox/apps/screen_access.h,v
retrieving revision 1.28
diff -u -p -r1.28 screen_access.h
--- apps/screen_access.h	14 Oct 2006 01:32:58 -0000	1.28
+++ apps/screen_access.h	5 Jan 2007 19:29:07 -0000
@@ -62,8 +62,9 @@ struct screen
 #endif
 
 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD) /* always bitmap */
-    void (*setmargins)(int x, int y);
-    int (*getxmargin)(void);
+    void (*setmargins)(int x1, int x2, int y);
+    int (*getleftmargin)(void);
+    int (*getrightmargin)(void);
     int (*getymargin)(void);
 
     void (*setfont)(int newfont);
@@ -155,10 +156,10 @@ extern void screen_init(struct screen * 
 /*
  * Sets the x margin in pixels for the given screen
  * - screen : the screen structure
- * - xmargin : the number of pixels to the left of the screen
+ * - leftmargin : the number of pixels to the left of the screen
  */
 #define screen_set_xmargin(screen, xmargin) \
-    (screen)->setmargins(xmargin, (screen)->getymargin());
+    (screen)->setmargins(xmargin, (screen)->width, (screen)->getymargin());
 
 /*
  * Sets the y margin in pixels for the given screen
@@ -166,7 +167,7 @@ extern void screen_init(struct screen * 
  * - xmargin : the number of pixels to the top of the screen
  */
 #define screen_set_ymargin(screen, ymargin) \
-    (screen)->setmargins((screen)->getxmargin(), ymargin);
+    (screen)->setmargins((screen)->getleftmargin(), (screen)->width, ymargin);
 
 #if defined(HAVE_LCD_BITMAP) || defined(HAVE_REMOTE_LCD)
 /*
Index: apps/screens.c
===================================================================
RCS file: /cvsroot/rockbox/apps/screens.c,v
retrieving revision 1.181
diff -u -p -r1.181 screens.c
--- apps/screens.c	25 Dec 2006 14:01:34 -0000	1.181
+++ apps/screens.c	5 Jan 2007 19:29:08 -0000
@@ -644,7 +644,7 @@ bool quick_screen_quick(int button_enter
     struct option_select left_option;
     struct option_select bottom_option;
     struct option_select right_option;
-    int oldrepeat, old_x_margin, old_y_margin;
+    int oldrepeat, old_left_margin, old_right_margin, old_y_margin;
 
     static const struct opt_items left_items[] = {
         [0]={ STR(LANG_SYSFONT_OFF) },
@@ -670,9 +670,10 @@ bool quick_screen_quick(int button_enter
     };
     struct gui_quickscreen qs;
 
-    old_x_margin = lcd_getxmargin();
+    old_left_margin = lcd_getleftmargin();
+    old_right_margin = lcd_getrightmargin();
     old_y_margin = lcd_getymargin();
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
 
     option_select_init_items(&left_option,
                              (char *)str(LANG_SYSFONT_SHUFFLE),
@@ -713,7 +714,7 @@ bool quick_screen_quick(int button_enter
         }
         settings_save();
     }
-    lcd_setmargins(old_x_margin, old_y_margin);
+    lcd_setmargins(old_left_margin, old_right_margin, old_y_margin);
     return(res);
 }
 
@@ -736,7 +737,7 @@ bool quick_screen_f3(int button_enter)
     struct option_select left_option;
     struct option_select bottom_option;
     struct option_select right_option;
-    int old_x_margin, old_y_margin;
+    int old_left_margin, old_right_margin, old_y_margin;
 
     static const struct opt_items onoff_items[] = {
         [0]={ STR(LANG_SYSFONT_OFF) },
@@ -749,9 +750,10 @@ bool quick_screen_f3(int button_enter)
 
     struct gui_quickscreen qs;
 
-    old_x_margin = lcd_getxmargin();
+    old_left_margin = lcd_getrightmargin();
+    old_right_margin = lcd_getleftmargin();
     old_y_margin = lcd_getymargin();
-    lcd_setmargins(0, 0);
+    lcd_setmargins(0, LCD_WIDTH, 0);
 
     option_select_init_items(&left_option,
                              str(LANG_SYSFONT_SCROLL_BAR),
@@ -773,7 +775,7 @@ bool quick_screen_f3(int button_enter)
     res=gui_syncquickscreen_run(&qs, button_enter);
     if(!res)
         settings_save();
-    lcd_setmargins(old_x_margin, old_y_margin);
+    lcd_setmargins(old_left_margin, old_right_margin, old_y_margin);
     return(res);
 }
 #endif /* BUTTON_F3 */
@@ -880,9 +882,9 @@ bool set_time_screen(const char* string,
 
 #ifdef HAVE_LCD_BITMAP
     if(global_settings.statusbar)
-        lcd_setmargins(0, STATUSBAR_HEIGHT);
+        lcd_setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
     else
-        lcd_setmargins(0, 0);
+        lcd_setmargins(0, LCD_WIDTH, 0);
 #endif
     lcd_clear_display();
     lcd_puts_scroll(0, 0, string);
Index: apps/sound_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/sound_menu.c,v
retrieving revision 1.125
diff -u -p -r1.125 sound_menu.c
--- apps/sound_menu.c	26 Dec 2006 12:44:09 -0000	1.125
+++ apps/sound_menu.c	5 Jan 2007 19:29:09 -0000
@@ -888,7 +888,8 @@ bool rectrigger(void)
     int exit_request = false;
     enum trigger_menu_option selected = TRIGGER_MODE;
     bool retval = false;
-    int old_x_margin[NB_SCREENS];
+    int old_left_margin[NB_SCREENS];
+    int old_right_margin[NB_SCREENS];
     int old_y_margin[NB_SCREENS];
 
 #define TRIGGER_MODE_COUNT 3
@@ -960,12 +961,13 @@ bool rectrigger(void)
     {
         screens[i].clear_display();
 
-        old_x_margin[i] = screens[i].getxmargin();
+        old_left_margin[i] = lcd_getleftmargin();
+        old_right_margin[i] = lcd_getrightmargin();
         old_y_margin[i] = screens[i].getymargin();
         if(global_settings.statusbar)
-           screens[i].setmargins(0, STATUSBAR_HEIGHT);
+           screens[i].setmargins(0, LCD_WIDTH, STATUSBAR_HEIGHT);
       else
-          screens[i].setmargins(0, 0);
+          screens[i].setmargins(0, LCD_WIDTH, 0);
 
       screens[i].getstringsize("M", &w, &h);
 
@@ -1246,7 +1248,7 @@ bool rectrigger(void)
     FOR_NB_SCREENS(i)
     {
         screens[i].setfont(FONT_UI);
-        screens[i].setmargins(old_x_margin[i], old_y_margin[i]);
+        screens[i].setmargins(old_left_margin[i], old_right_margin[i], old_y_margin[i]);
     }
     action_signalscreenchange();
     return retval;
Index: apps/gui/gwps-common.c
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/gwps-common.c,v
retrieving revision 1.69
diff -u -p -r1.69 gwps-common.c
--- apps/gui/gwps-common.c	29 Dec 2006 19:17:03 -0000	1.69
+++ apps/gui/gwps-common.c	5 Jan 2007 19:29:11 -0000
@@ -21,6 +21,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <ctype.h>
 #include "system.h"
 #include "settings.h"
 #include "rtc.h"
@@ -1332,6 +1333,35 @@ static void format_display(struct gui_wp
             case 0:
                 *buf++ = '%';
                 break;
+
+            case 'm': /* margins */
+            {
+                int x1=0;
+                int x2=gwps->display->width;
+
+                fmt++;
+                if (*fmt=='|') {
+                    char *p=strchr(fmt, '|');
+                    if (p) {
+                        fmt = ++p;
+                        if (isdigit(*p)) {
+                            x1=atoi(p);
+                            p=strchr(p, '|');
+                            if (p) {
+                                fmt = ++p;
+                                if (isdigit(*p)) {
+                                    x2=atoi(p);
+                                    p=strchr(p, '|');
+                                    if (p)
+                                        fmt = ++p;
+                                }
+                            }
+                        }
+                    }
+                }
+                gwps->display->setmargins( x1, x2, gwps->display->getymargin() );
+            } break;
+
             case 'a':
                 ++fmt;
                 /* remember where the current aligned text started */
@@ -1884,7 +1914,7 @@ bool gui_wps_refresh(struct gui_wps *gwp
             else {
                 left_width = 0;
             }
-            left_xpos = 0;
+            left_xpos = display->getleftmargin();
 
             if (format_align.center != 0) {
                 display->getstringsize((unsigned char *)format_align.center,
@@ -1893,7 +1923,7 @@ bool gui_wps_refresh(struct gui_wps *gwp
             else {
                 center_width = 0;
             }
-            center_xpos=(display->width - center_width) / 2;
+            center_xpos=(display->getrightmargin()-display->getleftmargin() - center_width) / 2 + display->getleftmargin();
 
             if (format_align.right != 0) {
                 display->getstringsize((unsigned char *)format_align.right,
@@ -1902,7 +1932,7 @@ bool gui_wps_refresh(struct gui_wps *gwp
             else {
                 right_width = 0;
             }
-            right_xpos = (display->width - right_width);
+            right_xpos = (display->getrightmargin() - right_width);
 
             /* Checks for overlapping strings.
                If needed the overlapping strings will be merged, separated by a
@@ -1944,7 +1974,7 @@ bool gui_wps_refresh(struct gui_wps *gwp
                 format_align.right = format_align.center;
                 /* calculate the new width and position of the merged string */
                 right_width = center_width + space_width + right_width;
-                right_xpos = (display->width - right_width);
+                right_xpos = (display->getrightmargin() - right_width);
                 /* there is no centered string anymore */
                 center_width = 0;
             }
@@ -1955,7 +1985,7 @@ bool gui_wps_refresh(struct gui_wps *gwp
                 format_align.right = format_align.center;
                 /* calculate the new width and position of the string */
                 right_width = center_width;
-                right_xpos = (display->width - right_width);
+                right_xpos = (display->getrightmargin() - right_width);
                 /* there is no centered string anymore */
                 center_width = 0;
             }
@@ -1998,7 +2028,10 @@ bool gui_wps_refresh(struct gui_wps *gwp
                     ypos = (i*string_height)+display->getymargin();
                     update_line = true;
 
-                    if (left_width>display->width) {
+                    if ((left_width > display->width) || 
+                       (display->getrightmargin()-display->getleftmargin() < left_width) ||
+                       (display->getrightmargin()-display->getleftmargin() < center_width) ||
+                       (display->getrightmargin()-display->getleftmargin() < right_width)) {
                         display->puts_scroll(0, i,
                                              (unsigned char *)format_align.left);
                     } else {
@@ -2027,6 +2060,7 @@ bool gui_wps_refresh(struct gui_wps *gwp
                             display->putsxy(right_xpos, ypos,
                                             (unsigned char *)format_align.right);
                         }
+                        
                     }
 #else
                     display->puts_scroll(0, i, buf);
@@ -2069,6 +2103,8 @@ bool gui_wps_refresh(struct gui_wps *gwp
                         display->putsxy(right_xpos, ypos,
                                         (unsigned char *)format_align.right);
                     }
+                    
+                   
 #else
                     update_line = true;
                     display->puts(0, i, buf);
Index: apps/gui/gwps.c
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/gwps.c,v
retrieving revision 1.57
diff -u -p -r1.57 gwps.c
--- apps/gui/gwps.c	22 Dec 2006 05:19:55 -0000	1.57
+++ apps/gui/gwps.c	5 Jan 2007 19:29:12 -0000
@@ -85,11 +85,10 @@ static void gui_wps_set_margin(struct gu
 {
     int offset = 0;
     struct wps_data *data = gwps->data;
-    if(data->wps_sb_tag && data->show_sb_on_wps)
+    if((data->wps_sb_tag && data->show_sb_on_wps) || 
+       (global_settings.statusbar && !data->wps_sb_tag))
         offset = STATUSBAR_HEIGHT;
-    else if ( global_settings.statusbar && !data->wps_sb_tag)
-        offset = STATUSBAR_HEIGHT;
-    gwps->display->setmargins(0, offset);
+    gwps->display->setmargins(0, gwps->display->width, offset);
 }
 #endif
 
Index: apps/gui/list.c
===================================================================
RCS file: /cvsroot/rockbox/apps/gui/list.c,v
retrieving revision 1.39
diff -u -p -r1.39 list.c
--- apps/gui/list.c	25 Dec 2006 14:01:43 -0000	1.39
+++ apps/gui/list.c	5 Jan 2007 19:29:12 -0000
@@ -94,7 +94,7 @@ void gui_list_flash(struct gui_list * gu
     int line_ypos=display->getymargin()+display->char_height*selected_line;
     if (global_settings.invert_cursor)
     {
-        int line_xpos=display->getxmargin();
+        int line_xpos=display->getleftmargin();
         display->set_drawmode(DRMODE_COMPLEMENT);
         display->fillrect(line_xpos, line_ypos, display->width,
                           display->char_height);
Index: apps/plugins/solitaire.c
===================================================================
RCS file: /cvsroot/rockbox/apps/plugins/solitaire.c,v
retrieving revision 1.77
diff -u -p -r1.77 solitaire.c
--- apps/plugins/solitaire.c	3 Jan 2007 23:53:22 -0000	1.77
+++ apps/plugins/solitaire.c	5 Jan 2007 19:29:13 -0000
@@ -629,7 +629,7 @@ int solitaire_menu(bool in_game)
                 break;
 
             case 3:
-                rb->lcd_setmargins(0, 0);
+                rb->lcd_setmargins(0, LCD_WIDTH, 0);
                 if (solitaire_help() == HELP_USB)
                     result = MENU_USB;
                 break;
@@ -640,7 +640,7 @@ int solitaire_menu(bool in_game)
         }
     }
     rb->menu_exit(m);
-    rb->lcd_setmargins(0, 0);
+    rb->lcd_setmargins(0, LCD_WIDTH, 0);
     return result;
 }
 
Index: apps/plugins/viewer.c
===================================================================
RCS file: /cvsroot/rockbox/apps/plugins/viewer.c,v
retrieving revision 1.51
diff -u -p -r1.51 viewer.c
--- apps/plugins/viewer.c	19 Nov 2006 14:11:42 -0000	1.51
+++ apps/plugins/viewer.c	5 Jan 2007 19:29:14 -0000
@@ -1273,7 +1273,7 @@ static bool viewer_options_menu(void)
     result = rb->menu_run(m);
     rb->menu_exit(m);
 #ifdef HAVE_LCD_BITMAP
-    rb->lcd_setmargins(0,0);
+    rb->lcd_setmargins(0,LCD_WIDTH,0);
 
     /* Show-scrollbar mode for current view-width mode */
     if (!ONE_SCREEN_FITS_ALL())
@@ -1315,7 +1315,7 @@ static void viewer_menu(void)
     }
     rb->menu_exit(m);
 #ifdef HAVE_LCD_BITMAP
-    rb->lcd_setmargins(0,0);
+    rb->lcd_setmargins(0,LCD_WIDTH,0);
 #endif
     viewer_draw(col);
 }
Index: apps/recorder/recording.c
===================================================================
RCS file: /cvsroot/rockbox/apps/recorder/recording.c,v
retrieving revision 1.153
diff -u -p -r1.153 recording.c
--- apps/recorder/recording.c	25 Dec 2006 14:01:47 -0000	1.153
+++ apps/recorder/recording.c	5 Jan 2007 19:29:17 -0000
@@ -844,7 +844,7 @@ bool recording_screen(bool no_source)
     {
         screens[i].setfont(FONT_SYSFIXED);
         screens[i].getstringsize("M", &w, &h);
-        screens[i].setmargins(global_settings.invert_cursor ? 0 : w, 8);
+        screens[i].setmargins(global_settings.invert_cursor ? 0 : w, screens[i].width, 8);
         filename_offset[i] = ((screens[i].height >= 80) ? 1 : 0);
         pm_y[i] = 8 + h * (2 + filename_offset[i]);
     }
@@ -1230,7 +1230,7 @@ bool recording_screen(bool no_source)
                         {
                             screens[i].setfont(FONT_SYSFIXED);
                             screens[i].setmargins(
-                                global_settings.invert_cursor ? 0 : w, 8);
+                                global_settings.invert_cursor ? 0 : w, screens[i].width, 8);
                         }
                     }
                 }
Index: firmware/logf.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/logf.c,v
retrieving revision 1.10
diff -u -p -r1.10 logf.c
--- firmware/logf.c	10 Nov 2006 08:03:24 -0000	1.10
+++ firmware/logf.c	5 Jan 2007 19:29:17 -0000
@@ -54,7 +54,7 @@ static void displayremote(void)
     lcd_remote_getstringsize("A", &w, &h);
     lines = LCD_REMOTE_HEIGHT/h;
     columns = LCD_REMOTE_WIDTH/w;
-    lcd_remote_setmargins(0, 0);
+    lcd_remote_setmargins(0, LCD_REMOTE_WIDTH, 0);
     lcd_remote_clear_display();
     
     index = logfindex;
Index: firmware/drivers/lcd-16bit.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-16bit.c,v
retrieving revision 1.41
diff -u -p -r1.41 lcd-16bit.c
--- firmware/drivers/lcd-16bit.c	4 Jan 2007 12:13:56 -0000	1.41
+++ firmware/drivers/lcd-16bit.c	5 Jan 2007 19:29:17 -0000
@@ -57,7 +57,8 @@ static long lcd_backdrop_offset IDATA_AT
 NON_GB_STATIC unsigned fg_pattern IDATA_ATTR = LCD_DEFAULT_FG;
 NON_GB_STATIC unsigned bg_pattern IDATA_ATTR = LCD_DEFAULT_BG;
 static int drawmode = DRMODE_SOLID;
-static int xmargin = 0;
+static int leftmargin = 0;
+static int rightmargin = LCD_WIDTH;
 static int ymargin = 0;
 static int curfont = FONT_SYSFIXED;
 
@@ -135,15 +136,21 @@ void lcd_set_drawinfo(int mode, unsigned
     bg_pattern = bg_color;
 }
 
-void lcd_setmargins(int x, int y)
+void lcd_setmargins(int x1, int x2, int y)
 {
-    xmargin = x;
+    leftmargin = x1;
+    rightmargin = x2;
     ymargin = y;
 }
 
-int lcd_getxmargin(void)
+int lcd_getleftmargin(void)
 {
-    return xmargin;
+    return leftmargin;
+}
+
+int lcd_getrightmargin(void)
+{
+    return rightmargin;
 }
 
 int lcd_getymargin(void)
@@ -803,14 +810,17 @@ void lcd_puts_style_offset(int x, int y,
         return;
 
     lcd_getstringsize(str, &w, &h);
-    xpos = xmargin + x*w / utf8length(str);
+    xpos = leftmargin + x*w / utf8length(str);
     ypos = ymargin + y*h;
     drawmode = (style & STYLE_INVERT) ?
                (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
     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(xpos + w, ypos, rightmargin - (xpos + w), h);
+    if (LCD_WIDTH>rightmargin) {
+	lcd_fillrect(rightmargin, ypos, LCD_WIDTH - rightmargin, h);
+    }
     drawmode = lastmode;
 }
 
@@ -887,7 +897,7 @@ void lcd_puts_scroll_style_offset(int x,
 
     lcd_getstringsize(string, &w, &h);
 
-    if (LCD_WIDTH - x * 8 - xmargin < w) {
+    if (rightmargin - x * 8 - leftmargin < w) {
         /* prepare scroll line */
         char *end;
 
@@ -900,7 +910,7 @@ void lcd_puts_scroll_style_offset(int x,
         /* scroll bidirectional or forward only depending on the string
            width */
         if ( bidir_limit ) {
-            s->bidir = s->width < (LCD_WIDTH - xmargin) *
+            s->bidir = s->width < (rightmargin - leftmargin) *
                 (100 + bidir_limit) / 100;
         }
         else
@@ -913,12 +923,14 @@ void lcd_puts_scroll_style_offset(int x,
         }
 
         end = strchr(s->line, '\0');
-        strncpy(end, string, LCD_WIDTH/2);
+        strncpy(end, string, rightmargin/2);
 
         s->len = utf8length(string);
         s->offset = offset;
-        s->startx = xmargin + x * s->width / s->len;
+        s->startx = leftmargin + x * s->width / s->len;
         s->backward = false;
+        s->left_margin=leftmargin;
+        s->right_margin=rightmargin;
         scrolling_lines |= (1<<y);
     }
     else
@@ -965,9 +977,9 @@ static void scroll_thread(void)
                     s->backward = false;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
-                if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
+                if (s->offset >= s->width - (s->right_margin - xpos)) {
                     /* at end of line */
-                    s->offset = s->width - (LCD_WIDTH - xpos);
+                    s->offset = s->width - (s->right_margin - xpos);
                     s->backward = true;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
@@ -982,8 +994,12 @@ static void scroll_thread(void)
             drawmode = s->invert ?
                        (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
             lcd_putsxyofs(xpos, ypos, s->offset, s->line);
+            if (LCD_WIDTH>s->right_margin) {
+            drawmode ^= DRMODE_INVERSEVID;
+                lcd_fillrect(s->right_margin, ypos, LCD_WIDTH - s->right_margin, pf->height);
+            }
             drawmode = lastmode;
-            lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
+            lcd_update_rect(xpos, ypos, s->right_margin - xpos, pf->height);
         }
 
         sleep(scroll_ticks);
Index: firmware/drivers/lcd-1bit-vert.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-1bit-vert.c,v
retrieving revision 1.1
diff -u -p -r1.1 lcd-1bit-vert.c
--- firmware/drivers/lcd-1bit-vert.c	12 Nov 2006 13:22:58 -0000	1.1
+++ firmware/drivers/lcd-1bit-vert.c	5 Jan 2007 19:29:18 -0000
@@ -40,7 +40,8 @@
 unsigned char lcd_framebuffer[LCD_HEIGHT/8][LCD_WIDTH];
 
 static int drawmode = DRMODE_SOLID;
-static int xmargin = 0;
+static int leftmargin = 0;
+static int rightmargin = 0;
 static int ymargin = 0;
 static int curfont = FONT_SYSFIXED;
 
@@ -83,15 +84,21 @@ int lcd_get_drawmode(void)
     return drawmode;
 }
 
-void lcd_setmargins(int x, int y)
+void lcd_setmargins(int x1, int x2, int y)
 {
-    xmargin = x;
+    leftmargin = x1;
+    rightmargin = x2;
     ymargin = y;
 }
 
-int lcd_getxmargin(void)
+int lcd_getleftmargin(void)
 {
-    return xmargin;
+    return leftmargin;
+}
+
+int lcd_getrightmargin(void)
+{
+    return rightmargin;
 }
 
 int lcd_getymargin(void)
@@ -670,14 +677,17 @@ void lcd_puts_style_offset(int x, int y,
         return;
 
     lcd_getstringsize(str, &w, &h);
-    xpos = xmargin + x*w / utf8length(str);
+    xpos = leftmargin + x*w / utf8length(str);
     ypos = ymargin + y*h;
     drawmode = (style & STYLE_INVERT) ?
                (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
     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(xpos + w, ypos, rightmargin - (xpos + w), h);
+    if (LCD_WIDTH>rightmargin) {
+	lcd_fillrect(rightmargin, ypos, LCD_WIDTH - rightmargin, h);
+    }
     drawmode = lastmode;
 }
 
@@ -755,7 +765,7 @@ void lcd_puts_scroll_style_offset(int x,
 
     lcd_getstringsize(string, &w, &h);
 
-    if (LCD_WIDTH - x * 8 - xmargin < w) {
+    if (rightmargin - x * 8 - leftmargin < w) {
         /* prepare scroll line */
         char *end;
 
@@ -768,7 +778,7 @@ void lcd_puts_scroll_style_offset(int x,
         /* scroll bidirectional or forward only depending on the string
            width */
         if ( bidir_limit ) {
-            s->bidir = s->width < (LCD_WIDTH - xmargin) *
+            s->bidir = s->width < (rightmargin - leftmargin) *
                 (100 + bidir_limit) / 100;
         }
         else
@@ -781,12 +791,14 @@ void lcd_puts_scroll_style_offset(int x,
         }
 
         end = strchr(s->line, '\0');
-        strncpy(end, string, LCD_WIDTH/2);
+        strncpy(end, string, rightmargin/2);
 
         s->len = utf8length(string);
         s->offset = offset;
-        s->startx = xmargin + x * s->width / s->len;;
+        s->startx = leftmargin + x * s->width / s->len;
         s->backward = false;
+        s->left_margin=leftmargin;
+        s->right_margin=rightmargin;
         scrolling_lines |= (1<<y);
     }
     else
@@ -833,9 +845,9 @@ static void scroll_thread(void)
                     s->backward = false;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
-                if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
+                if (s->offset >= s->width - (s->right_margin - xpos)) {
                     /* at end of line */
-                    s->offset = s->width - (LCD_WIDTH - xpos);
+                    s->offset = s->width - (s->right_margin - xpos);
                     s->backward = true;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
@@ -850,8 +862,12 @@ static void scroll_thread(void)
             drawmode = s->invert ?
                        (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
             lcd_putsxyofs(xpos, ypos, s->offset, s->line);
+            if (LCD_WIDTH>s->right_margin) {
+            drawmode ^= DRMODE_INVERSEVID;
+                lcd_fillrect(s->right_margin, ypos, LCD_WIDTH - s->right_margin, pf->height);
+            }
             drawmode = lastmode;
-            lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
+            lcd_update_rect(xpos, ypos, s->right_margin - xpos, pf->height);
         }
 
         sleep(scroll_ticks);
Index: firmware/drivers/lcd-2bit-horz.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-2bit-horz.c,v
retrieving revision 1.22
diff -u -p -r1.22 lcd-2bit-horz.c
--- firmware/drivers/lcd-2bit-horz.c	13 Nov 2006 00:45:21 -0000	1.22
+++ firmware/drivers/lcd-2bit-horz.c	5 Jan 2007 19:29:19 -0000
@@ -121,15 +121,21 @@ void lcd_set_drawinfo(int mode, unsigned
     lcd_set_background(bg_brightness);
 }
 
-void lcd_setmargins(int x, int y)
+void lcd_setmargins(int x1, int x2, int y)
 {
-    xmargin = x;
+    leftmargin = x1;
+    rightmargin = x2;
     ymargin = y;
 }
 
-int lcd_getxmargin(void)
+int lcd_getleftmargin(void)
 {
-    return xmargin;
+    return leftmargin;
+}
+
+int lcd_getrightmargin(void)
+{
+    return rightmargin;
 }
 
 int lcd_getymargin(void)
Index: firmware/drivers/lcd-2bit-vert.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-2bit-vert.c,v
retrieving revision 1.3
diff -u -p -r1.3 lcd-2bit-vert.c
--- firmware/drivers/lcd-2bit-vert.c	13 Nov 2006 00:45:21 -0000	1.3
+++ firmware/drivers/lcd-2bit-vert.c	5 Jan 2007 19:29:19 -0000
@@ -54,7 +54,8 @@ static long lcd_backdrop_offset IDATA_AT
 static unsigned fg_pattern IDATA_ATTR = 0xFF; /* initially black */
 static unsigned bg_pattern IDATA_ATTR = 0x00; /* initially white */
 static int drawmode = DRMODE_SOLID;
-static int xmargin = 0;
+static int leftmargin = 0;
+static int rightmargin = 0;
 static int ymargin = 0;
 static int curfont = FONT_SYSFIXED;
 
@@ -124,17 +125,25 @@ void lcd_set_drawinfo(int mode, unsigned
     lcd_set_background(bg_brightness);
 }
 
-void lcd_setmargins(int x, int y)
+void lcd_setmargins(int x1, int x2, int y)
 {
-    xmargin = x;
+    leftmargin = x1;
+    rightmargin = x2;
     ymargin = y;
+
+}
+
+int lcd_getleftmargin(void)
+{
+    return leftmargin;
 }
 
-int lcd_getxmargin(void)
+int lcd_getrightmargin(void)
 {
-    return xmargin;
+    return rightmargin;
 }
 
+
 int lcd_getymargin(void)
 {
     return ymargin;
@@ -1003,14 +1012,17 @@ void lcd_puts_style_offset(int x, int y,
         return;
 
     lcd_getstringsize(str, &w, &h);
-    xpos = xmargin + x*w / utf8length((char *)str);
+    xpos = leftmargin + x*w / utf8length((char *)str);
     ypos = ymargin + y*h;
     drawmode = (style & STYLE_INVERT) ?
                (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
     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(xpos + w, ypos, rightmargin - (xpos + w), h);
+    if (LCD_WIDTH>rightmargin) {
+	lcd_fillrect(rightmargin, ypos, LCD_WIDTH - rightmargin, h);
+    }
     drawmode = lastmode;
 }
 
@@ -1087,7 +1099,7 @@ void lcd_puts_scroll_style_offset(int x,
 
     lcd_getstringsize(string, &w, &h);
 
-    if (LCD_WIDTH - x * 8 - xmargin < w) {
+    if (rightmargin - x * 8 - leftmargin < w) {
         /* prepare scroll line */
         char *end;
 
@@ -1100,7 +1112,7 @@ void lcd_puts_scroll_style_offset(int x,
         /* scroll bidirectional or forward only depending on the string
            width */
         if ( bidir_limit ) {
-            s->bidir = s->width < (LCD_WIDTH - xmargin) *
+            s->bidir = s->width < (rightmargin - leftmargin) *
                 (100 + bidir_limit) / 100;
         }
         else
@@ -1113,12 +1125,14 @@ void lcd_puts_scroll_style_offset(int x,
         }
 
         end = strchr(s->line, '\0');
-        strncpy(end, (char *)string, LCD_WIDTH/2);
+        strncpy(end, (char *)string, rightmargin/2);
 
         s->len = utf8length((char *)string);
         s->offset = offset;
-        s->startx = xmargin + x * s->width / s->len;
+        s->startx = leftmargin + x * s->width / s->len;
         s->backward = false;
+        s->left_margin=leftmargin;
+        s->right_margin=rightmargin;
         scrolling_lines |= (1<<y);
     }
     else
@@ -1165,9 +1179,9 @@ static void scroll_thread(void)
                     s->backward = false;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
-                if (s->offset >= s->width - (LCD_WIDTH - xpos)) {
+                if (s->offset >= s->width - (s->right_margin - xpos)) {
                     /* at end of line */
-                    s->offset = s->width - (LCD_WIDTH - xpos);
+                    s->offset = s->width - (s->right_margin - xpos);
                     s->backward = true;
                     s->start_tick = current_tick + scroll_delay * 2;
                 }
@@ -1182,8 +1196,12 @@ static void scroll_thread(void)
             drawmode = s->invert ?
                        (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
             lcd_putsxyofs(xpos, ypos, s->offset, s->line);
+            if (LCD_WIDTH>s->right_margin) {
+            drawmode ^= DRMODE_INVERSEVID;
+                lcd_fillrect(s->right_margin, ypos, LCD_WIDTH - s->right_margin, pf->height);
+            }
             drawmode = lastmode;
-            lcd_update_rect(xpos, ypos, LCD_WIDTH - xpos, pf->height);
+            lcd_update_rect(xpos, ypos, s->right_margin - xpos, pf->height);
         }
 
         sleep(scroll_ticks);
Index: firmware/drivers/lcd-h100-remote.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-h100-remote.c,v
retrieving revision 1.67
diff -u -p -r1.67 lcd-h100-remote.c
--- firmware/drivers/lcd-h100-remote.c	14 Nov 2006 02:46:58 -0000	1.67
+++ firmware/drivers/lcd-h100-remote.c	5 Jan 2007 19:29:20 -0000
@@ -69,7 +69,8 @@ fb_remote_data lcd_remote_framebuffer[LC
                                       IBSS_ATTR;
 
 static int drawmode = DRMODE_SOLID;
-static int xmargin = 0;
+static int leftmargin = 0;
+static int rightmargin = LCD_REMOTE_WIDTH;
 static int ymargin = 0;
 static int curfont = FONT_SYSFIXED;
 
@@ -686,15 +687,21 @@ int lcd_remote_get_drawmode(void)
     return drawmode;
 }
 
-void lcd_remote_setmargins(int x, int y)
+void lcd_remote_setmargins(int x1, int x2, int y)
 {
-    xmargin = x;
+    leftmargin = x1;
+    rightmargin = x2;
     ymargin = y;
 }
 
-int lcd_remote_getxmargin(void)
+int lcd_remote_getleftmargin(void)
 {
-    return xmargin;
+    return leftmargin;
+}
+
+int lcd_remote_getrightmargin(void)
+{
+    return rightmargin;
 }
 
 int lcd_remote_getymargin(void)
@@ -1278,7 +1285,7 @@ void lcd_remote_puts_style_offset(int x,
         return;
 
     lcd_remote_getstringsize(str, &w, &h);
-    xpos = xmargin + x*w / utf8length((char *)str);
+    xpos = leftmargin + x*w / utf8length((char *)str);
     ypos = ymargin + y*h;
     drawmode = (style & STYLE_INVERT) ?
                (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
@@ -1362,7 +1369,7 @@ void lcd_remote_puts_scroll_style_offset
 
     lcd_remote_getstringsize(string, &w, &h);
 
-    if (LCD_REMOTE_WIDTH - x * 8 - xmargin < w) {
+    if (LCD_REMOTE_WIDTH - x * 8 - leftmargin < w) {
         /* prepare scroll line */
         char *end;
 
@@ -1375,7 +1382,7 @@ void lcd_remote_puts_scroll_style_offset
         /* scroll bidirectional or forward only depending on the string
            width */
         if ( bidir_limit ) {
-            s->bidir = s->width < (LCD_REMOTE_WIDTH - xmargin) *
+            s->bidir = s->width < (LCD_REMOTE_WIDTH - leftmargin) *
                 (100 + bidir_limit) / 100;
         }
         else
@@ -1392,7 +1399,7 @@ void lcd_remote_puts_scroll_style_offset
 
         s->len = utf8length((char *)string);
         s->offset = offset;
-        s->startx = xmargin + x * s->width / s->len;;
+        s->startx = leftmargin + x * s->width / s->len;;
         s->backward = false;
         scrolling_lines |= (1<<y);
     }
Index: firmware/drivers/lcd-remote-2bit-vi.c
===================================================================
RCS file: /cvsroot/rockbox/firmware/drivers/lcd-remote-2bit-vi.c,v
retrieving revision 1.7
diff -u -p -r1.7 lcd-remote-2bit-vi.c
--- firmware/drivers/lcd-remote-2bit-vi.c	26 Nov 2006 14:26:08 -0000	1.7
+++ firmware/drivers/lcd-remote-2bit-vi.c	5 Jan 2007 19:29:21 -0000
@@ -50,7 +50,8 @@ static long remote_backdrop_offset IDATA
 static unsigned fg_pattern IDATA_ATTR = 0xFFFF; /* initially black */
 static unsigned bg_pattern IDATA_ATTR = 0x0000; /* initially white */
 static int drawmode = DRMODE_SOLID;
-static int xmargin = 0;
+static int leftmargin = 0;
+static int rightmargin = LCD_REMOTE_WIDTH;
 static int ymargin = 0;
 static int curfont = FONT_SYSFIXED;
 
@@ -130,17 +131,23 @@ void lcd_remote_set_drawinfo(int mode, u
     lcd_remote_set_background(bg_brightness);
 }
 
-void lcd_remote_setmargins(int x, int y)
+void lcd_remote_setmargins(int x1, int x2, int y)
 {
-    xmargin = x;
+    leftmargin = x1;
+    rightmargin = x2;    
     ymargin = y;
 }
 
-int lcd_remote_getxmargin(void)
+int lcd_remote_getleftmargin(void)
 {
-    return xmargin;
+    return leftmargin;
 }
 
+int lcd_remote_getrightmargin(void)
+{
+    return rightmargin;
+}
+ 
 int lcd_remote_getymargin(void)
 {
     return ymargin;
@@ -1008,7 +1015,7 @@ void lcd_remote_puts_style_offset(int x,
         return;
 
     lcd_remote_getstringsize(str, &w, &h);
-    xpos = xmargin + x*w / utf8length((char *)str);
+    xpos = leftmargin + x*w / utf8length((char *)str);
     ypos = ymargin + y*h;
     drawmode = (style & STYLE_INVERT) ?
                (DRMODE_SOLID|DRMODE_INVERSEVID) : DRMODE_SOLID;
@@ -1092,7 +1099,7 @@ void lcd_remote_puts_scroll_style_offset
 
     lcd_remote_getstringsize(string, &w, &h);
 
-    if (LCD_REMOTE_WIDTH - x * 8 - xmargin < w) {
+    if (LCD_REMOTE_WIDTH - x * 8 - leftmargin < w) {
         /* prepare scroll line */
         char *end;
 
@@ -1105,7 +1112,7 @@ void lcd_remote_puts_scroll_style_offset
         /* scroll bidirectional or forward only depending on the string
            width */
         if ( bidir_limit ) {
-            s->bidir = s->width < (LCD_REMOTE_WIDTH - xmargin) *
+            s->bidir = s->width < (LCD_REMOTE_WIDTH - leftmargin) *
                 (100 + bidir_limit) / 100;
         }
         else
@@ -1122,7 +1129,7 @@ void lcd_remote_puts_scroll_style_offset
 
         s->len = utf8length((char *)string);
         s->offset = offset;
-        s->startx = xmargin + x * s->width / s->len;;
+        s->startx = leftmargin + x * s->width / s->len;;
         s->backward = false;
         scrolling_lines |= (1<<y);
     }
Index: firmware/export/lcd-remote.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/export/lcd-remote.h,v
retrieving revision 1.24
diff -u -p -r1.24 lcd-remote.h
--- firmware/export/lcd-remote.h	26 Nov 2006 14:26:08 -0000	1.24
+++ firmware/export/lcd-remote.h	5 Jan 2007 19:29:21 -0000
@@ -125,8 +125,9 @@ extern void lcd_remote_set_flip(bool yes
 
 extern void lcd_remote_set_drawmode(int mode);
 extern int  lcd_remote_get_drawmode(void);
-extern void lcd_remote_setmargins(int xmargin, int ymargin);
-extern int  lcd_remote_getxmargin(void);
+extern void lcd_remote_setmargins(int leftmargin, int rightmargin, int ymargin);
+extern int  lcd_remote_getleftmargin(void);
+extern int  lcd_remote_getrightmargin(void);
 extern int  lcd_remote_getymargin(void);
 extern void lcd_remote_setfont(int font);
 extern int  lcd_remote_getstringsize(const unsigned char *str, int *w, int *h);
Index: firmware/export/lcd.h
===================================================================
RCS file: /cvsroot/rockbox/firmware/export/lcd.h,v
retrieving revision 1.77
diff -u -p -r1.77 lcd.h
--- firmware/export/lcd.h	4 Jan 2007 12:13:56 -0000	1.77
+++ firmware/export/lcd.h	5 Jan 2007 19:29:21 -0000
@@ -296,8 +296,9 @@ extern void lcd_set_flip(bool yesno);
 
 extern void lcd_set_drawmode(int mode);
 extern int  lcd_get_drawmode(void);
-extern void lcd_setmargins(int xmargin, int ymargin);
-extern int  lcd_getxmargin(void);
+extern void lcd_setmargins(int leftmargin, int rightmargin, int ymargin);
+extern int  lcd_getleftmargin(void);
+extern int  lcd_getrightmargin(void);
 extern int  lcd_getymargin(void);
 extern void lcd_setfont(int font);
 extern int  lcd_getstringsize(const unsigned char *str, int *w, int *h);
@@ -385,6 +386,8 @@ struct scrollinfo {
     bool bidir;
     bool invert; /* invert the scrolled text */
     long start_tick;
+    int left_margin;
+    int right_margin;
 };
 #else /* !HAVE_LCD_BITMAP */
 
