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/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 ++++++++++--------- 11 files changed, 73 insertions(+), 65 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/clock/clock_draw.c b/apps/plugins/clock/clock_draw.c index 06711df..f9dbb3c 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 dbed316..391bd73 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 f50351f..b6c7a9a 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 d5c37ad..7c5925d 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 ea87720..44a6f16 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 bc659eb..96cb5a4 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 6f13cdd..086309a 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 f4a2914..38cd12e 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 e407cae..2fbdd60 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 b419d96..23bfd3c 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 184d2ef..146d743 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 -- cgit v1.1