From 205f3df7816a1eea9c812ea285d74a4f8ecfad2a Mon Sep 17 00:00:00 2001 From: Peter D'Hoye Date: Sat, 28 Jun 2008 20:45:21 +0000 Subject: Remove a viewport ambiguity by changing the screens width/heigth members into lcdwidth/lcdheight. Normal usercode should always use getwidth()/getheigth() as that returns the viewport width/height. Fixes issues that would have appeared in many places when introducing viewports with sizes != lcd sizes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17857 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/color_picker.c | 30 ++++++++++----------- apps/gui/gwps.c | 6 ++--- apps/gui/list.c | 2 +- apps/gui/pitchscreen.c | 26 +++++++++--------- apps/gui/quickscreen.c | 2 +- apps/gui/splash.c | 14 +++++----- apps/gui/statusbar.c | 8 +++--- apps/gui/viewport.c | 6 ++--- apps/gui/wps_parser.c | 7 ++--- apps/menus/eq_menu.c | 4 +-- apps/menus/recording_menu.c | 8 +++--- apps/plugins/clock/clock_draw.c | 2 +- apps/plugins/clock/clock_draw_analog.c | 48 ++++++++++++++++----------------- apps/plugins/clock/clock_draw_binary.c | 4 +-- apps/plugins/clock/clock_draw_digital.c | 15 ++++++----- apps/plugins/clock/clock_settings.c | 6 ++--- apps/plugins/demystify.c | 12 ++++----- apps/plugins/dice.c | 6 ++--- apps/plugins/jackpot.c | 11 ++++---- apps/plugins/maze.c | 4 +-- apps/plugins/star.c | 2 +- apps/plugins/zxbox/zxbox_keyb.c | 28 ++++++++++--------- apps/recorder/keyboard.c | 38 +++++++++++++------------- apps/recorder/recording.c | 11 +++++--- apps/screen_access.c | 12 ++++----- apps/screen_access.h | 2 +- 26 files changed, 165 insertions(+), 149 deletions(-) diff --git a/apps/gui/color_picker.c b/apps/gui/color_picker.c index 239a8b4c81..4ac4fa7fff 100644 --- a/apps/gui/color_picker.c +++ b/apps/gui/color_picker.c @@ -158,11 +158,11 @@ static void draw_screen(struct screen *display, char *title, enough to display the selected slider - calculate total height of display with three sliders present */ display_three_rows = - display->height >= MARGIN_TOP + - display->char_height*4 + /* Title + 3 sliders */ - TITLE_MARGIN_BOTTOM + - SELECTOR_TB_MARGIN*6 + /* 2 margins/slider */ - MARGIN_BOTTOM; + display->getheight() >= MARGIN_TOP + + display->char_height*4 + /* Title + 3 sliders */ + TITLE_MARGIN_BOTTOM + + SELECTOR_TB_MARGIN*6 + /* 2 margins/slider */ + MARGIN_BOTTOM; /* Figure out widest label character in case they vary - this function assumes labels are one character */ @@ -178,13 +178,13 @@ static void draw_screen(struct screen *display, char *title, /* Draw title string */ set_drawinfo(display, DRMODE_SOLID, text_color, background_color); display->getstringsize(title, &x, &y); - display->putsxy((display->width - x) / 2, MARGIN_TOP, title); + display->putsxy((display->getwidth() - x) / 2, MARGIN_TOP, title); /* Get slider positions and top starting position */ text_top = MARGIN_TOP + y + TITLE_MARGIN_BOTTOM + SELECTOR_TB_MARGIN; slider_left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN + max_label_width + SLIDER_MARGIN_LEFT; - slider_width = display->width - slider_left - SLIDER_MARGIN_RIGHT - + slider_width = display->getwidth() - slider_left - SLIDER_MARGIN_RIGHT - display->char_width*2 - SELECTOR_LR_MARGIN - SELECTOR_WIDTH - MARGIN_RIGHT; @@ -208,7 +208,7 @@ static void draw_screen(struct screen *display, char *title, /* Draw solid bar selection bar */ display->fillrect(0, text_top - SELECTOR_TB_MARGIN, - display->width, + display->getwidth(), display->char_height + SELECTOR_TB_MARGIN*2); @@ -225,8 +225,8 @@ static void draw_screen(struct screen *display, char *title, SELECTOR_HEIGHT) / 2; screen_put_iconxy(display, MARGIN_LEFT, top, Icon_Cursor); screen_put_iconxy(display, - display->width - MARGIN_RIGHT - - get_icon_width(display->screen_type), + display->getwidth() - MARGIN_RIGHT - + get_icon_width(display->screen_type), top, Icon_Cursor); } @@ -282,9 +282,9 @@ static void draw_screen(struct screen *display, char *title, /* Display color swatch on color screens only */ int left = MARGIN_LEFT + SELECTOR_WIDTH + SELECTOR_LR_MARGIN; int top = text_top + SWATCH_TOP_MARGIN; - int width = display->width - left - SELECTOR_LR_MARGIN - + int width = display->getwidth() - left - SELECTOR_LR_MARGIN - SELECTOR_WIDTH - MARGIN_RIGHT; - int height = display->height - top - MARGIN_BOTTOM; + int height = display->getheight() - top - MARGIN_BOTTOM; /* Only draw if room */ if (height >= display->char_height + 2) @@ -314,11 +314,11 @@ static void draw_screen(struct screen *display, char *title, display->getstringsize(buf, &x, &y); i = text_top + SWATCH_TOP_MARGIN; - if (i + y <= display->height - MARGIN_BOTTOM) + if (i + y <= display->getheight() - MARGIN_BOTTOM) { set_drawinfo(display, DRMODE_SOLID, text_color, background_color); - x = (display->width - x) / 2; - y = (i + display->height - MARGIN_BOTTOM - y) / 2; + x = (display->getwidth() - x) / 2; + y = (i + display->getheight() - MARGIN_BOTTOM - y) / 2; display->putsxy(x, y, buf); } } diff --git a/apps/gui/gwps.c b/apps/gui/gwps.c index d752cb3da5..a7c5295f48 100644 --- a/apps/gui/gwps.c +++ b/apps/gui/gwps.c @@ -788,17 +788,17 @@ static void statusbar_toggle_handler(void *data) if (!global_settings.statusbar && !draw) { vp->vp.y = 0; - vp->vp.height = screens[i].height; + vp->vp.height = screens[i].lcdheight; } else { vp->vp.y = STATUSBAR_HEIGHT; - vp->vp.height = screens[i].height - STATUSBAR_HEIGHT; + vp->vp.height = screens[i].lcdheight - STATUSBAR_HEIGHT; } } } #endif - + void gui_sync_wps_init(void) { int i; diff --git a/apps/gui/list.c b/apps/gui/list.c index 0ec40d3aed..96652ce0a9 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -78,7 +78,7 @@ void list_init_viewports(struct gui_synclist *list) { viewport_set_defaults(vp, i); list->parent[i]->y = gui_statusbar_height(); - list->parent[i]->height = screens[i].height - list->parent[i]->y; + list->parent[i]->height = screens[i].lcdheight - list->parent[i]->y; } } #ifdef HAVE_BUTTONBAR diff --git a/apps/gui/pitchscreen.c b/apps/gui/pitchscreen.c index c9d6750242..e0a7416ac6 100644 --- a/apps/gui/pitchscreen.c +++ b/apps/gui/pitchscreen.c @@ -64,7 +64,7 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) { w = snprintf((char *)buf, sizeof(buf), "%s: %d.%d%%",str(LANG_PITCH), pitch / 10, pitch % 10 ); - display->putsxy((display->width-(w*display->char_width))/2, + display->putsxy((display->lcdwidth-(w*display->char_width))/2, display->nb_lines/2,buf); } else /* bigger screen, show everything... */ @@ -77,9 +77,9 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) ptr = str(LANG_PITCH_UP_SEMITONE); } display->getstringsize(ptr,&w,&h); - display->putsxy((display->width-w)/2, 0, ptr); + display->putsxy((display->lcdwidth-w)/2, 0, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_UpArrow], - display->width/2 - 3, h, 7, 8); + display->lcdwidth/2 - 3, h, 7, 8); /* DOWN: Pitch Down */ if (pitch_mode == PITCH_MODE_ABSOLUTE) { @@ -88,33 +88,35 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) ptr = str(LANG_PITCH_DOWN_SEMITONE); } display->getstringsize(ptr,&w,&h); - display->putsxy((display->width-w)/2, display->height - h, ptr); + display->putsxy((display->lcdwidth-w)/2, display->lcdheight - h, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_DownArrow], - display->width/2 - 3, display->height - h*2, 7, 8); + display->lcdwidth/2 - 3, + display->lcdheight - h*2, 7, 8); /* RIGHT: +2% */ ptr = "+2%"; display->getstringsize(ptr,&w,&h); - display->putsxy(display->width-w, (display->height-h)/2, ptr); + display->putsxy(display->lcdwidth-w, (display->lcdheight-h)/2, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_FastForward], - display->width-w-8, (display->height-h)/2, 7, 8); + display->lcdwidth-w-8, + (display->lcdheight-h)/2, 7, 8); /* LEFT: -2% */ ptr = "-2%"; display->getstringsize(ptr,&w,&h); - display->putsxy(0, (display->height-h)/2, ptr); + display->putsxy(0, (display->lcdheight-h)/2, ptr); display->mono_bitmap(bitmap_icons_7x8[Icon_FastBackward], - w+1, (display->height-h)/2, 7, 8); + w+1, (display->lcdheight-h)/2, 7, 8); /* "Pitch" */ snprintf((char *)buf, sizeof(buf), str(LANG_PITCH)); display->getstringsize(buf,&w,&h); - display->putsxy((display->width-w)/2, (display->height/2)-h, buf); + display->putsxy((display->lcdwidth-w)/2, (display->lcdheight/2)-h, buf); /* "XX.X%" */ snprintf((char *)buf, sizeof(buf), "%d.%d%%", pitch / 10, pitch % 10 ); display->getstringsize(buf,&w,&h); - display->putsxy((display->width-w)/2, display->height/2, buf); + display->putsxy((display->lcdwidth-w)/2, display->lcdheight/2, buf); } display->update(); @@ -123,7 +125,7 @@ static void pitch_screen_draw(struct screen *display, int pitch, int pitch_mode) static int pitch_increase(int pitch, int delta, bool allow_cutoff) { int new_pitch; - + if (delta < 0) { if (pitch + delta >= PITCH_MIN) { new_pitch = pitch + delta; diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 3eb9426c39..ef1111fe3e 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -107,7 +107,7 @@ static void quickscreen_fix_viewports(struct gui_quickscreen *qs, vp_icons[screen].height = vps[screen][QUICKSCREEN_BOTTOM].y - vp_icons[screen].y; - if (left_width + right_width > display->width - CENTER_ICONAREA_WIDTH) + if (left_width + right_width > display->lcdwidth - CENTER_ICONAREA_WIDTH) { /* scrolling needed */ int width = (parent->width - CENTER_ICONAREA_WIDTH)/2; diff --git a/apps/gui/splash.c b/apps/gui/splash.c index 0405c0586d..b4b451eed6 100644 --- a/apps/gui/splash.c +++ b/apps/gui/splash.c @@ -91,14 +91,14 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #endif if (lastbreak) { - if (x + (next - lastbreak) * space_w + w > screen->width) + if (x + (next - lastbreak) * space_w + w > screen->lcdwidth) { /* too wide, wrap */ widths[line] = x; #ifdef HAVE_LCD_BITMAP if (x > maxw) maxw = x; #endif - if ((y + h > screen->height) || (line >= (MAXLINES-1))) + if ((y + h > screen->lcdheight) || (line >= (MAXLINES-1))) break; /* screen full or out of lines */ x = 0; y += h; @@ -132,8 +132,8 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #ifdef HAVE_LCD_BITMAP /* If we center the display, then just clear the box we need and put a nice little frame and put the text in there! */ - y = (screen->height - y) / 2; /* height => y start position */ - x = (screen->width - maxw) / 2 - 2; + y = (screen->lcdheight - y) / 2; /* height => y start position */ + x = (screen->lcdwidth - maxw) / 2 - 2; #if LCD_DEPTH > 1 if (screen->depth > 1) @@ -147,7 +147,7 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #endif screen->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - screen->fillrect(x, y-2, maxw+4, screen->height-y*2+4); + screen->fillrect(x, y-2, maxw+4, screen->lcdheight-y*2+4); #if LCD_DEPTH > 1 if (screen->depth > 1) @@ -156,7 +156,7 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) #endif screen->set_drawmode(DRMODE_SOLID); - screen->drawrect(x, y-2, maxw+4, screen->height-y*2+4); + screen->drawrect(x, y-2, maxw+4, screen->lcdheight-y*2+4); #else /* HAVE_LCD_CHARCELLS */ y = 0; /* vertical centering on 2 lines would be silly */ x = 0; @@ -167,7 +167,7 @@ static void splash(struct screen * screen, const char *fmt, va_list ap) for (i = 0; i <= line; i++) { - x = MAX((screen->width - widths[i]) / 2, 0); + x = MAX((screen->lcdwidth - widths[i]) / 2, 0); #ifdef HAVE_LCD_BITMAP screen->putsxy(x, y, lines[i]); diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c index b9941eb061..0a421e8b16 100644 --- a/apps/gui/statusbar.c +++ b/apps/gui/statusbar.c @@ -256,7 +256,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info))) { display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - display->fillrect(0, 0, display->width, STATUSBAR_HEIGHT); + display->fillrect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); display->set_drawmode(DRMODE_SOLID); if (bar->info.battery_state) @@ -329,7 +329,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw) if(!display->has_disk_led && bar->info.led) gui_statusbar_led(display); #endif - display->update_rect(0, 0, display->width, STATUSBAR_HEIGHT); + display->update_rect(0, 0, display->getwidth(), STATUSBAR_HEIGHT); bar->lastinfo = bar->info; } #endif /* HAVE_LCD_BITMAP */ @@ -573,7 +573,7 @@ static void gui_statusbar_icon_lock_remote(struct screen * display) static void gui_statusbar_led(struct screen * display) { display->mono_bitmap(bitmap_icon_disk, - STATUSBAR_DISK_X_POS(display->width), + STATUSBAR_DISK_X_POS(display->getwidth()), STATUSBAR_Y_POS, STATUSBAR_DISK_WIDTH, STATUSBAR_HEIGHT); } @@ -605,7 +605,7 @@ static void gui_statusbar_time(struct screen * display, struct tm *time) display->setfont(FONT_SYSFIXED); display->getstringsize(buffer, &width, &height); if (height <= STATUSBAR_HEIGHT) { - display->putsxy(STATUSBAR_TIME_X_END(display->width) - width, + display->putsxy(STATUSBAR_TIME_X_END(display->getwidth()) - width, STATUSBAR_Y_POS, buffer); } display->setfont(FONT_UI); diff --git a/apps/gui/viewport.c b/apps/gui/viewport.c index 6aad7c5b05..ef61494b71 100644 --- a/apps/gui/viewport.c +++ b/apps/gui/viewport.c @@ -48,10 +48,10 @@ int viewport_get_nb_lines(struct viewport *vp) void viewport_set_defaults(struct viewport *vp, enum screen_type screen) { vp->x = 0; - vp->width = screens[screen].width; - + vp->width = screens[screen].lcdwidth; + vp->y = gui_statusbar_height(); - vp->height = screens[screen].height - vp->y; + vp->height = screens[screen].lcdheight - vp->y; #ifdef HAVE_LCD_BITMAP vp->drawmode = DRMODE_SOLID; vp->font = FONT_UI; /* default to UI to discourage SYSFONT use */ diff --git a/apps/gui/wps_parser.c b/apps/gui/wps_parser.c index e89f2692cf..73516f604d 100644 --- a/apps/gui/wps_parser.c +++ b/apps/gui/wps_parser.c @@ -1550,16 +1550,17 @@ bool wps_data_load(struct wps_data *wps_data, /* Initialise the first (default) viewport */ wps_data->viewports[0].vp.x = 0; - wps_data->viewports[0].vp.width = display->width; + wps_data->viewports[0].vp.width = display->getwidth(); if (!global_settings.statusbar) { wps_data->viewports[0].vp.y = 0; - wps_data->viewports[0].vp.height = display->height; + wps_data->viewports[0].vp.height = display->getheight(); } else { wps_data->viewports[0].vp.y = STATUSBAR_HEIGHT; - wps_data->viewports[0].vp.height = display->height - STATUSBAR_HEIGHT; + wps_data->viewports[0].vp.height = display->getheight() - + STATUSBAR_HEIGHT; } #ifdef HAVE_LCD_BITMAP wps_data->viewports[0].vp.font = FONT_UI; diff --git a/apps/menus/eq_menu.c b/apps/menus/eq_menu.c index 13af7e6c14..279f8255c2 100644 --- a/apps/menus/eq_menu.c +++ b/apps/menus/eq_menu.c @@ -399,8 +399,8 @@ static int draw_eq_sliders(int current_band, enum eq_slider_mode mode) enum eq_type type; FOR_NB_SCREENS(i) - slider_width[i] = screens[i].width - 4; /* two pixel margin on each side */ - + slider_width[i] = screens[i].getwidth() - 4; /* 2 pixel margin + each side */ for (i=0; i<5; i++) { cutoff = *setting++; q = *setting++; diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index 6342bccde7..ae58472942 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c @@ -448,7 +448,7 @@ int rectrigger(void) int old_stop_gap = global_settings.rec_stop_gap; int old_trigger_mode = global_settings.rec_trigger_mode; int old_trigger_type = global_settings.rec_trigger_type; - + FOR_NB_SCREENS(i) { screens[i].clear_display(); @@ -457,11 +457,11 @@ int rectrigger(void) vp[i].height -= SYSFONT_HEIGHT*2; trig_xpos[i] = 0; trig_ypos[i] = vp[i].y + vp[i].height; - pm_y[i] = screens[i].height - SYSFONT_HEIGHT; - trig_width[i] = screens[i].width; + pm_y[i] = screens[i].getheight() - SYSFONT_HEIGHT; + trig_width[i] = screens[i].getwidth(); } /* TODO: what to do if there is < 4 lines on the screen? */ - + settings[TRIGGER_MODE] = find_setting(&global_settings.rec_trigger_mode, NULL); settings[TRIGGER_TYPE] = diff --git a/apps/plugins/clock/clock_draw.c b/apps/plugins/clock/clock_draw.c index 06711dff74..f9dbb3c809 100644 --- a/apps/plugins/clock/clock_draw.c +++ b/apps/plugins/clock/clock_draw.c @@ -35,7 +35,7 @@ void black_background(struct screen* display){ #endif { display->clear_display(); - display->fillrect(0,0,display->width,display->height); + display->fillrect(0,0,display->getwidth(),display->getheight()); } } diff --git a/apps/plugins/clock/clock_draw_analog.c b/apps/plugins/clock/clock_draw_analog.c index dbed316322..391bd73519 100644 --- a/apps/plugins/clock/clock_draw_analog.c +++ b/apps/plugins/clock/clock_draw_analog.c @@ -28,7 +28,7 @@ #define ANALOG_SECOND_RADIUS(screen, round) \ ANALOG_MINUTE_RADIUS(screen, round) #define ANALOG_MINUTE_RADIUS(screen, round) \ - (round?MIN(screen->height/2 -10, screen->width/2 -10):screen->height/2) + (round?MIN(screen->getheight()/2 -10, screen->getwidth()/2 -10):screen->getheight()/2) #define ANALOG_HOUR_RADIUS(screen, round) \ (2*ANALOG_MINUTE_RADIUS(screen, round)/3) @@ -52,8 +52,8 @@ void polar_to_cartesian_screen_centered(struct screen * display, int a, int r, int* x, int* y) { polar_to_cartesian(a, r, x, y); - *x+=display->width/2; - *y+=display->height/2; + *x+=display->getwidth()/2; + *y+=display->getheight()/2; } void angle_to_square(int square_width, int square_height, @@ -87,8 +87,8 @@ void angle_to_square_screen_centered(struct screen * display, int a, int* x, int* y) { angle_to_square(square_width, square_height, a, x, y); - *x+=display->width/2; - *y+=display->height/2; + *x+=display->getwidth()/2; + *y+=display->getheight()/2; } void draw_hand(struct screen* display, int angle, @@ -100,9 +100,9 @@ void draw_hand(struct screen* display, int angle, polar_to_cartesian_screen_centered(display, angle, radius, &x1, &y1); }else{/* fullscreen clock, hands describes square motions */ int square_width, square_height; - /* radius is defined smallest between width and height */ + /* radius is defined smallest between getwidth() and getheight() */ square_height=radius; - square_width=(radius*display->width)/display->height; + square_width=(radius*display->getwidth())/display->getheight(); angle_to_square_screen_centered( display, square_width, square_height, angle, &x1, &y1); } @@ -140,14 +140,14 @@ void draw_counter(struct screen* display, struct counter* counter) counter_time.hour, counter_time.minute); getstringsize(smalldigits_bitmaps, buffer, &hour_str_w, &str_h); draw_string(display, smalldigits_bitmaps, buffer, - display->width-hour_str_w, - display->height-2*str_h); + display->getwidth()-hour_str_w, + display->getheight()-2*str_h); rb->snprintf(buffer, 10, "%02d", counter_time.second); getstringsize(smalldigits_bitmaps, buffer, &second_str_w, &str_h); draw_string(display, smalldigits_bitmaps, buffer, - display->width-(hour_str_w+second_str_w)/2, - display->height-str_h); + display->getwidth()-(hour_str_w+second_str_w)/2, + display->getheight()-str_h); } void draw_date(struct screen* display, struct time* time, int date_format) @@ -166,14 +166,14 @@ void draw_date(struct screen* display, struct time* time, int date_format) /* draws month and day */ getstringsize(smalldigits_bitmaps, buffer, &monthday_str_w, &str_h); draw_string(display, smalldigits_bitmaps, buffer, - 0, display->height-year_line*str_h); + 0, display->getheight()-year_line*str_h); rb->snprintf(buffer, 10, "%04d", time->year); /* draws year */ getstringsize(smalldigits_bitmaps, buffer, &year_str_w, &str_h); draw_string(display, smalldigits_bitmaps, buffer, (monthday_str_w-year_str_w)/2, - display->height-monthday_line*str_h); + display->getheight()-monthday_line*str_h); } void draw_border(struct screen* display, int skin) @@ -181,7 +181,7 @@ void draw_border(struct screen* display, int skin) /* Draws square dots every 5 minutes */ int i; int x, y; - int size=display->height/50;/* size of the square dots */ + int size=display->getheight()/50;/* size of the square dots */ if(size%2)/* a pair number */ size++; for(i=0; i < 60; i+=5){ @@ -190,7 +190,7 @@ void draw_border(struct screen* display, int skin) ANALOG_MINUTE_RADIUS(display, skin), &x, &y); }else{ angle_to_square_screen_centered( - display, display->width/2-size/2, display->height/2-size/2, + display, display->getwidth()/2-size/2, display->getheight()/2-size/2, MINUTE_ANGLE(i, 0), &x, &y); } display->fillrect(x-size/2, y-size/2, size, size); @@ -222,15 +222,15 @@ void draw_hour(struct screen* display, struct time* time, void draw_center_cover(struct screen* display) { - display->hline((display->width/2)-1, - (display->width/2)+1, (display->height/2)+3); - display->hline((display->width/2)-3, - (display->width/2)+3, (display->height/2)+2); - display->fillrect((display->width/2)-4, (display->height/2)-1, 9, 3); - display->hline((display->width/2)-3, - (display->width/2)+3, (display->height/2)-2); - display->hline((display->width/2)-1, - (display->width/2)+1, (display->height/2)-3); + display->hline((display->getwidth()/2)-1, + (display->getwidth()/2)+1, (display->getheight()/2)+3); + display->hline((display->getwidth()/2)-3, + (display->getwidth()/2)+3, (display->getheight()/2)+2); + display->fillrect((display->getwidth()/2)-4, (display->getheight()/2)-1, 9, 3); + display->hline((display->getwidth()/2)-3, + (display->getwidth()/2)+3, (display->getheight()/2)-2); + display->hline((display->getwidth()/2)-1, + (display->getwidth()/2)+1, (display->getheight()/2)-3); } void analog_clock_draw(struct screen* display, struct time* time, diff --git a/apps/plugins/clock/clock_draw_binary.c b/apps/plugins/clock/clock_draw_binary.c index f50351f226..b6c7a9ac29 100644 --- a/apps/plugins/clock/clock_draw_binary.c +++ b/apps/plugins/clock/clock_draw_binary.c @@ -45,8 +45,8 @@ void binary_clock_draw(struct screen* display, struct time* time, int skin){ char buffer[9]; int i; const struct picture* binary_bitmaps = &(binary_skin[skin][display->screen_type]); - int y_offset=(display->height-(binary_bitmaps->height*3))/2; - int x_offset=(display->width-(binary_bitmaps->width*6))/2; + int y_offset=(display->getheight()-(binary_bitmaps->height*3))/2; + int x_offset=(display->getwidth()-(binary_bitmaps->width*6))/2; for(i=0;i<3;i++){ print_binary(buffer, lines_values[i], 6); draw_string(display, binary_bitmaps, buffer, x_offset, diff --git a/apps/plugins/clock/clock_draw_digital.c b/apps/plugins/clock/clock_draw_digital.c index d5c37ad8dc..7c5925d75f 100644 --- a/apps/plugins/clock/clock_draw_digital.c +++ b/apps/plugins/clock/clock_draw_digital.c @@ -64,19 +64,22 @@ void digital_clock_draw(struct screen* display, } } getstringsize(digits_bitmaps, buffer, &str_w, &str_h); - draw_string(display, digits_bitmaps, buffer, (display->width-str_w)/2, 0); + draw_string(display, digits_bitmaps, buffer, + (display->getwidth()-str_w)/2, 0); if(settings->digital.show_seconds){ buffer_pos=0; buffer_printf(buffer, buffer_pos, "%02d", time->second); getstringsize(digits_bitmaps, buffer, &str_w, &str_h); - draw_string(display, digits_bitmaps, buffer, (display->width-str_w)/2, + draw_string(display, digits_bitmaps, buffer, + (display->getwidth()-str_w)/2, digits_bitmaps->height); } if(settings->general.date_format!=NONE){ format_date(buffer, time, settings->general.date_format); getstringsize(smalldigits_bitmaps, buffer, &str_w, &str_h); - draw_string(display, smalldigits_bitmaps, buffer, (display->width-str_w)/2, - display->height-smalldigits_bitmaps->height*2); + draw_string(display, smalldigits_bitmaps, buffer, + (display->getwidth()-str_w)/2, + display->getheight()-smalldigits_bitmaps->height*2); } if(counter){ struct time counter_time; @@ -84,7 +87,7 @@ void digital_clock_draw(struct screen* display, rb->snprintf(buffer, 20, "%02d:%02d:%02d", counter_time.hour, counter_time.minute, counter_time.second); getstringsize(smalldigits_bitmaps, buffer, &str_w, &str_h); - draw_string(display, smalldigits_bitmaps, buffer, (display->width-str_w)/2, - display->height-str_h); + draw_string(display, smalldigits_bitmaps, buffer, + (display->getwidth()-str_w)/2, display->getheight()-str_h); } } diff --git a/apps/plugins/clock/clock_settings.c b/apps/plugins/clock/clock_settings.c index ea87720f87..44a6f164a7 100644 --- a/apps/plugins/clock/clock_settings.c +++ b/apps/plugins/clock/clock_settings.c @@ -144,11 +144,11 @@ void draw_logo(struct screen* display){ void draw_message(struct screen* display, int msg, int y){ const struct picture* message = &(messages[display->screen_type]); display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); - display->fillrect(0, display->height-message->height, - display->width, message->height); + display->fillrect(0, display->getheight()-message->height, + display->getwidth(), message->height); display->set_drawmode(DRMODE_SOLID); vertical_picture_draw_sprite(display, message, msg, - 0, display->height-(message->height*y)); + 0, display->getheight()-(message->height*y)); } void load_settings(void){ diff --git a/apps/plugins/demystify.c b/apps/plugins/demystify.c index bc659eb0d0..96cb5a4cc0 100644 --- a/apps/plugins/demystify.c +++ b/apps/plugins/demystify.c @@ -108,8 +108,8 @@ void polygon_init(struct polygon * polygon, struct screen * display) int i; for(i=0;ipoints[i].x=(rb->rand() % (display->width)); - polygon->points[i].y=(rb->rand() % (display->height)); + polygon->points[i].x=(rb->rand() % (display->getwidth())); + polygon->points[i].y=(rb->rand() % (display->getheight())); } } @@ -167,9 +167,9 @@ void polygon_update(struct polygon *polygon, struct screen * display, struct pol x=1; polygon_move->move_steps[i].x=get_new_step(step); } - else if(x>=display->width) + else if(x>=display->getwidth()) { - x=display->width-1; + x=display->getwidth()-1; polygon_move->move_steps[i].x=get_new_step(step); } polygon->points[i].x=x; @@ -182,9 +182,9 @@ void polygon_update(struct polygon *polygon, struct screen * display, struct pol y=1; polygon_move->move_steps[i].y=get_new_step(step); } - else if(y>=display->height) + else if(y>=display->getheight()) { - y=display->height-1; + y=display->getheight()-1; polygon_move->move_steps[i].y=get_new_step(step); } polygon->points[i].y=y; diff --git a/apps/plugins/dice.c b/apps/plugins/dice.c index 6f13cdd51a..086309a1b8 100644 --- a/apps/plugins/dice.c +++ b/apps/plugins/dice.c @@ -112,7 +112,7 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame void dice_init(struct dices* dice){ dice->nb_dices=INITIAL_NB_DICES; sides_index=INITIAL_NB_SIDES; - + } void dice_roll(struct dices* dice) { @@ -139,8 +139,8 @@ void dice_print(struct dices* dice, struct screen* display){ /* display characteristics */ int char_height, char_width; display->getstringsize("M", &char_width, &char_height); - int display_nb_row=display->height/char_height; - int display_nb_col=display->width/char_width; + int display_nb_row=display->getheight()/char_height; + int display_nb_col=display->getwidth()/char_width; int nb_dices_per_line=display_nb_col/4;/* 4 char per dice displayed*/ int nb_lines_required=dice->nb_dices/nb_dices_per_line; diff --git a/apps/plugins/jackpot.c b/apps/plugins/jackpot.c index f4a2914116..38cd12e993 100644 --- a/apps/plugins/jackpot.c +++ b/apps/plugins/jackpot.c @@ -173,8 +173,8 @@ void jackpot_display_slot_machine(struct jackpot* game, struct screen* display) display->putc(0, 0, '['); #else const struct picture* picture= &(jackpot_pictures[display->screen_type]); - int pos_x=(display->width-NB_SLOTS*(picture->width+1))/2; - int pos_y=(display->height-(picture->height))/2; + int pos_x=(display->getwidth()-NB_SLOTS*(picture->width+1))/2; + int pos_y=(display->getheight()-(picture->height))/2; #endif /* HAVE_LCD_CHARCELLS */ for(i=0;igetstringsize(message, &message_width, &message_height); - xpos=(display->width-message_width)/2; - ypos=display->height-message_height; - rb->screen_clear_area(display, 0, ypos, display->width, message_height); + xpos=(display->getwidth()-message_width)/2; + ypos=display->getheight()-message_height; + rb->screen_clear_area(display, 0, ypos, display->getwidth(), + message_height); display->putsxy(xpos,ypos,message); display->update(); #endif /* HAVE_LCD_CHARCELLS */ diff --git a/apps/plugins/maze.c b/apps/plugins/maze.c index e407caeb82..2fbdd60480 100644 --- a/apps/plugins/maze.c +++ b/apps/plugins/maze.c @@ -176,8 +176,8 @@ void maze_draw(struct maze* maze, struct screen* display) int point_width, point_height, point_offset_x, point_offset_y; unsigned short cell; - wx = (int) display->width / MAZE_WIDTH; - wy = (int) display->height / MAZE_HEIGHT; + wx = (int) display->getwidth() / MAZE_WIDTH; + wy = (int) display->getheight() / MAZE_HEIGHT; if(wx>3){ point_width=wx-3; diff --git a/apps/plugins/star.c b/apps/plugins/star.c index b419d965c5..23bfd3ceef 100644 --- a/apps/plugins/star.c +++ b/apps/plugins/star.c @@ -995,7 +995,7 @@ static int star_menu(void) rb->viewport_set_defaults(&vp[selection], selection); /* we are hiding the statusbar so fix the height also */ vp[selection].y = 0; - vp[selection].height = rb->screens[selection]->height; + vp[selection].height = rb->screens[selection]->lcdheight; #if LCD_DEPTH > 1 if (rb->screens[selection]->depth > 1) { diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c index 184d2ef4b5..146d7432b4 100644 --- a/apps/plugins/zxbox/zxbox_keyb.c +++ b/apps/plugins/zxbox/zxbox_keyb.c @@ -232,7 +232,8 @@ int zx_kbd_input(char* text/*, int buflen*/) param[l].font_h = param[l].font->height; /* check if FONT_UI fits the screen */ - if (2*param[l].font_h+3 + BUTTONBAR_HEIGHT > rb->screens[l]->height) { + if (2*param[l].font_h+3 + BUTTONBAR_HEIGHT > + rb->screens[l]->getheight()) { param[l].font = rb->font_get(FONT_SYSFIXED); param[l].font_h = param[l].font->height; param[l].curfont = FONT_SYSFIXED; @@ -259,9 +260,9 @@ int zx_kbd_input(char* text/*, int buflen*/) { if( param[l].kbd_buf[i] == '\n' ) { - k = ( rb->screens[l]->width / param[l].font_w ) - - i % ( rb->screens[l]->width / param[l].font_w ) - 1; - if( k == ( rb->screens[l]->width / param[l].font_w ) - 1 ) + k = ( rb->screens[l]->getwidth() / param[l].font_w ) - + i % ( rb->screens[l]->getwidth() / param[l].font_w ) - 1; + if( k == ( rb->screens[l]->getwidth() / param[l].font_w ) - 1 ) { param[l].nchars--; for( j = i; j < param[l].nchars; j++ ) @@ -303,17 +304,19 @@ int zx_kbd_input(char* text/*, int buflen*/) if (w > text_w) text_w = w; } - param[l].max_chars_text = rb->screens[l]->width / text_w - 2; + param[l].max_chars_text = rb->screens[l]->getwidth() / text_w - 2; /* calculate keyboard grid size */ - param[l].max_chars = rb->screens[l]->width / param[l].font_w; + param[l].max_chars = rb->screens[l]->getwidth() / param[l].font_w; if (!kbd_loaded) { param[l].lines = param[l].DEFAULT_LINES; param[l].keyboard_margin = DEFAULT_MARGIN; } else { - param[l].lines = (rb->screens[l]->height - BUTTONBAR_HEIGHT - statusbar_size) / param[l].font_h - 1; - param[l].keyboard_margin = rb->screens[l]->height - BUTTONBAR_HEIGHT - - statusbar_size - (param[l].lines+1)*param[l].font_h; + param[l].lines = (rb->screens[l]->lcdheight - BUTTONBAR_HEIGHT - + statusbar_size) / param[l].font_h - 1; + param[l].keyboard_margin = rb->screens[l]->lcdheight - + BUTTONBAR_HEIGHT - statusbar_size - + (param[l].lines+1)*param[l].font_h; if (param[l].keyboard_margin < 3) { param[l].lines--; param[l].keyboard_margin += param[l].font_h; @@ -342,7 +345,7 @@ int zx_kbd_input(char* text/*, int buflen*/) FOR_NB_SCREENS(l) rb->screens[l]->clear_display(); - + /* draw page */ FOR_NB_SCREENS(l) { @@ -360,12 +363,13 @@ int zx_kbd_input(char* text/*, int buflen*/) } } } - + /* separator */ FOR_NB_SCREENS(l) { - rb->screens[l]->hline(0, rb->screens[l]->width - 1, param[l].main_y - param[l].keyboard_margin); + rb->screens[l]->hline(0, rb->screens[l]->getwidth() - 1, + param[l].main_y - param[l].keyboard_margin); /* write out the text */ #if 0 diff --git a/apps/recorder/keyboard.c b/apps/recorder/keyboard.c index 2b0ba49fb3..a15b4cc346 100644 --- a/apps/recorder/keyboard.c +++ b/apps/recorder/keyboard.c @@ -7,7 +7,7 @@ * \/ \/ \/ \/ \/ * $Id$ * - * Copyright (C) 2002 by Björn Stenberg + * Copyright (C) 2002 by Bj�rn Stenberg * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -302,7 +302,7 @@ int kbd_input(char* text, int buflen) #if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 struct screen *sc = &screens[l]; - if (sc->width >= 160 && sc->height >= 96) + if (sc->getwidth() >= 160 && sc->getheight() >= 96) { pm->default_kbd = "ABCDEFG abcdefg !?\" @#$%+'\n" @@ -384,7 +384,8 @@ int kbd_input(char* text, int buflen) pm->font_h = pm->font->height; /* check if FONT_UI fits the screen */ - if (2*pm->font_h + 3 + statusbar_size + BUTTONBAR_HEIGHT > sc->height) + if (2*pm->font_h + 3 + statusbar_size + + BUTTONBAR_HEIGHT > sc->getheight()) { pm->font = font_get(FONT_SYSFIXED); pm->font_h = pm->font->height; @@ -419,11 +420,11 @@ int kbd_input(char* text, int buflen) { if (pm->kbd_buf[i] == '\n') { - int k = sc->width / pm->font_w - - i % ( sc->width / pm->font_w ) - 1; + int k = sc->getwidth() / pm->font_w + - i % ( sc->getwidth() / pm->font_w ) - 1; int j; - if (k == sc->width / pm->font_w - 1) + if (k == sc->getwidth() / pm->font_w - 1) { pm->nchars--; @@ -478,10 +479,10 @@ int kbd_input(char* text, int buflen) text_w = w; } - pm->max_chars_text = sc->width / text_w - 2; + pm->max_chars_text = sc->getwidth() / text_w - 2; /* Calculate keyboard grid size */ - pm->max_chars = sc->width / pm->font_w; + pm->max_chars = sc->getwidth() / pm->font_w; if (!kbd_loaded) { @@ -490,9 +491,9 @@ int kbd_input(char* text, int buflen) } else { - pm->lines = (sc->height - BUTTONBAR_HEIGHT - statusbar_size) + pm->lines = (sc->getheight() - BUTTONBAR_HEIGHT - statusbar_size) / pm->font_h - 1; - pm->keyboard_margin = sc->height - BUTTONBAR_HEIGHT - + pm->keyboard_margin = sc->getheight() - BUTTONBAR_HEIGHT - statusbar_size - (pm->lines+1)*pm->font_h; if (pm->keyboard_margin < 3) @@ -518,7 +519,7 @@ int kbd_input(char* text, int buflen) #ifdef KBD_MORSE_INPUT pm->old_main_y = pm->main_y; if (morse_mode) - pm->main_y = sc->height - pm->font_h; + pm->main_y = sc->getheight() - pm->font_h; #endif } @@ -587,7 +588,7 @@ int kbd_input(char* text, int buflen) } pm->x += w*5 - 3; - if (pm->x >= sc->width - w*6) + if (pm->x >= sc->getwidth() - w*6) { pm->x = 0; pm->y += 8; /* sysfixed font height */ @@ -639,10 +640,10 @@ int kbd_input(char* text, int buflen) doesn't collide */ sc->set_drawmode(DRMODE_SOLID | DRMODE_INVERSEVID); sc->fillrect(0, pm->main_y - pm->keyboard_margin - 1, - sc->width, pm->font_h + 4); + sc->getwidth(), pm->font_h + 4); sc->set_drawmode(DRMODE_SOLID); - sc->hline(0, sc->width - 1, pm->main_y - pm->keyboard_margin); + sc->hline(0, sc->getwidth() - 1, pm->main_y - pm->keyboard_margin); /* write out the text */ sc->setfont(pm->curfont); @@ -691,13 +692,14 @@ int kbd_input(char* text, int buflen) /* Draw nicer bitmap arrow if room, else settle for ">". */ if (text_w >= 6 && pm->font_h >= 8) { - screen_put_iconxy(sc, sc->width - text_w + (text_w - 6) / 2, + screen_put_iconxy(sc, sc->getwidth() - text_w + + (text_w - 6) / 2, pm->main_y + (pm->font_h - 8) / 2, Icon_Cursor); } else { - sc->putsxy(sc->width - text_w, pm->main_y, ">"); + sc->putsxy(sc->getwidth() - text_w, pm->main_y, ">"); } } @@ -729,7 +731,7 @@ int kbd_input(char* text, int buflen) #ifdef KBD_MODES if (pm->line_edit) sc->fillrect(0, pm->main_y - pm->keyboard_margin + 2, - sc->width, pm->font_h + 2); + sc->getwidth(), pm->font_h + 2); else /* highlight the key that has focus */ #endif sc->fillrect(pm->font_w*pm->x, @@ -801,7 +803,7 @@ int kbd_input(char* text, int buflen) if (morse_mode) { pm->old_main_y = pm->main_y; - pm->main_y = sc->height - pm->font_h; + pm->main_y = sc->getheight() - pm->font_h; } else { diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index 9251a1d609..de4a2e6805 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c @@ -1064,8 +1064,9 @@ bool recording_screen(bool no_source) screen_update = 1; screens[1].clear_display(); snprintf(buf, sizeof(buf), str(LANG_REMOTE_LCD_ON)); - screens[1].puts((screens[1].width/w - strlen(buf))/2 + 1, - screens[1].height/(h*2) + 1, buf); + screens[1].puts((screens[1].getwidth()/w - strlen(buf))/2 + + 1, + screens[1].getheight()/(h*2) + 1, buf); screens[1].update(); gui_syncsplash(0, str(LANG_REMOTE_LCD_OFF)); } @@ -1880,10 +1881,12 @@ bool recording_screen(bool no_source) /* draw the trigger status */ FOR_NB_SCREENS(i) { + /* NOTE: UGLY width setting based on height! To be fixed! */ trig_width[i] = ((vp[i].height < 64) || ((vp[i].height < 72) && (PM_HEIGHT > 1))) ? - screens[i].width - 14 * w : screens[i].width; - trig_xpos[i] = screens[i].width - trig_width[i]; + screens[i].getwidth() - 14 * w : + screens[i].getwidth(); + trig_xpos[i] = screens[i].getwidth() - trig_width[i]; trig_ypos[i] = ((vp[i].height < 72) && (PM_HEIGHT > 1)) ? h*2 : h*(1 + filename_offset[i] + PM_HEIGHT + diff --git a/apps/screen_access.c b/apps/screen_access.c index a1cabf67e3..de59537770 100644 --- a/apps/screen_access.c +++ b/apps/screen_access.c @@ -36,8 +36,8 @@ struct screen screens[NB_SCREENS] = { { .screen_type=SCREEN_MAIN, - .width=LCD_WIDTH, - .height=LCD_HEIGHT, + .lcdwidth=LCD_WIDTH, + .lcdheight=LCD_HEIGHT, .depth=LCD_DEPTH, #if defined(HAVE_LCD_COLOR) .is_color=true, @@ -134,8 +134,8 @@ struct screen screens[NB_SCREENS] = #if NB_SCREENS == 2 { .screen_type=SCREEN_REMOTE, - .width=LCD_REMOTE_WIDTH, - .height=LCD_REMOTE_HEIGHT, + .lcdwidth=LCD_REMOTE_WIDTH, + .lcdheight=LCD_REMOTE_HEIGHT, .depth=LCD_REMOTE_DEPTH, .is_color=false,/* No color remotes yet */ .pixel_format=LCD_REMOTE_PIXELFORMAT, @@ -230,8 +230,8 @@ void screen_access_init(void) #ifdef HAVE_LCD_BITMAP ((struct screen*)&screens[i])->setfont(FONT_UI); #endif - - int height=display->height; + + int height=display->lcdheight; #ifdef HAVE_LCD_BITMAP if(global_settings.statusbar) height -= STATUSBAR_HEIGHT; diff --git a/apps/screen_access.h b/apps/screen_access.h index 950551592e..d800c31489 100644 --- a/apps/screen_access.h +++ b/apps/screen_access.h @@ -58,7 +58,7 @@ typedef void screen_bitmap_func(const void *src, int x, int y, int width, struct screen { enum screen_type screen_type; - int width, height; + int lcdwidth, lcdheight; int depth; int nb_lines; #ifdef HAVE_LCD_BITMAP -- cgit v1.2.3