Esempio n. 1
0
//-------------------------------------------------------------------
void gui_menu_init(CMenu *menu_ptr) {

    if (menu_ptr) {
        if (conf.menu_select_first_entry)
            gui_menu_set_curr_menu(menu_ptr, 0, 0);
        else 
            gui_menu_set_curr_menu(menu_ptr, 0, -1);
        gui_menu_stack_ptr = 0;

        // Set active Tv override menu entry if present
        extern void set_tv_override_menu(CMenu *menu);
        set_tv_override_menu(curr_menu);
    }

    num_lines = camera_screen.height/rbf_font_height()-1;
    x = camera_screen.menu_border_width;
    w = camera_screen.width-x-x;
    len_bool = rbf_str_width("\x95");
    len_int = rbf_str_width("99999");
    len_enum = rbf_str_width("WUBfS3a");
    len_space = rbf_char_width(' ');
    len_br1 = rbf_char_width('[');
    len_br2 = rbf_char_width(']');
    cl_rect = rbf_font_height() - 4;
    int_incr = 1;

    gui_menu_redraw=2;
}
Esempio n. 2
0
//-------------------------------------------------------------------
// Draw menu scroll bar if needed, and title bar
static void gui_draw_initial()
{ 
    count = gui_menu_disp_rows();

    if (count > num_lines)
    {
        y = ((camera_screen.height-(num_lines-1)*rbf_font_height())>>1);
        wplus = 8; 
        // scrollbar background 
        draw_rectangle((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR(BG_COLOR(user_color(conf.menu_color)), BG_COLOR(user_color(conf.menu_color))), RECT_BORDER0|DRAW_FILLED);
    }
Esempio n. 3
0
//-------------------------------------------------------------------
// Draw menu scroll bar if needed, and title bar
void gui_menu_draw_initial()
{ 
    count = gui_menu_rows();

    if (count > num_lines)
    {
        y = ((camera_screen.height-(num_lines-1)*rbf_font_height())>>1);
        wplus = 8; 
        // scrollbar background 
        draw_filled_rect((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR(BG_COLOR(conf.menu_color), BG_COLOR(conf.menu_color))); 
    }
Esempio n. 4
0
//-------------------------------------------------------------------
static void gui_init(CMenu *menu_ptr) {

    if (menu_ptr) {
        gui_menu_set_curr_menu(menu_ptr, 0, 0);
        gui_menu_stack_ptr = 0;
    }

    num_lines = camera_screen.height/rbf_font_height()-1;
    x = camera_screen.disp_left + camera_screen.menu_border_width;
    w = camera_screen.disp_width - camera_screen.menu_border_width;
    len_bool = rbf_str_width("\x95");
    len_space = rbf_char_width(' ');

    gui_menu_redraw=2;
}
Esempio n. 5
0
        strcpy(conf.reader_file, file);
    }
    read_on_screen = 0;
    read_file_size = (read_file>=0 && stat((char*)file, &st)==0)?st.st_size:0;
    if (read_file_size<=conf.reader_pos) {
        conf.reader_pos = 0;
    }
    pause = 0;
    read_to_draw = 1;
    reader_needs_full_redraw=1;
    return (read_file >= 0);
}

//-------------------------------------------------------------------
static void read_goto_next_line() {
    draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(conf.reader_color>>8, conf.reader_color>>8));
    xx  = x;
    yy += rbf_font_height();
}

//-------------------------------------------------------------------
static int read_fit_next_char(int ch) {
    return (xx+rbf_char_width(ch) < x+w);
}

//-------------------------------------------------------------------
void gui_read_draw() {
    if (reader_needs_full_redraw) {
	x=6; 
	y=FONT_HEIGHT;
	w=screen_width-6-6-8;
Esempio n. 6
0
//-------------------------------------------------------------------
static void read_goto_next_line() {
    draw_filled_rect(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(conf.reader_color), BG_COLOR(conf.reader_color)));
    xx  = x;
    yy += rbf_font_height();
}
Esempio n. 7
0
//-------------------------------------------------------------------
void gui_read_draw(int enforce_redraw) {
    if (conf.reader_autoscroll && !pause && get_tick_count()-last_time >= conf.reader_autoscroll_delay*1000 && (conf.reader_pos+read_on_screen)<read_file_size) {
        conf.reader_pos += read_on_screen;
        read_to_draw = 1;
    }
    if (read_to_draw) {
        int n, i, ii, ll, new_word=1;

        xx=x;
        yy=y;

        lseek(read_file, conf.reader_pos, SEEK_SET);
        read_on_screen=0;

        while (yy<=y+h-rbf_font_height()) {
            n=read(read_file, buffer, READ_BUFFER_SIZE);
            if (n==0) {
                read_goto_next_line();
                if (yy < y+h)
                    draw_filled_rect(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(conf.reader_color), BG_COLOR(conf.reader_color)));
                break;
            }
            i=0;
            while (i<n && yy<=y+h-rbf_font_height()) {
                switch (buffer[i]) {
                case '\r':
                    new_word = 1;
                    break;
                case '\n':
                    read_goto_next_line();
                    new_word = 1;
                    break;
                case '\t':
                    buffer[i] = ' ';
                // no break here
                default:
                    if (conf.reader_wrap_by_words) {
                        if (buffer[i] == ' ') {
                            new_word = 1;
                            if (xx==x) //ignore leading spaces
                                break;
                        } else if (new_word) {
                            new_word = 0;
                            for (ii=i, ll=0; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) {
                                ll+=rbf_char_width(buffer[ii]);
                            }
                            if (ii==n) {
                                memcpy(buffer, buffer+i, n-i);
                                n=ii=n-i;
                                read_on_screen+=i;
                                i=0;
                                n+=read(read_file, buffer+n, READ_BUFFER_SIZE-n);
                                for (; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) {
                                    ll+=rbf_char_width(buffer[ii]);
                                }
                            }
                            if (xx+ll>=x+w && ll<w) {
                                read_goto_next_line();
                                continue;
                            }
                        }
                    }
                    if (!read_fit_next_char(buffer[i])) {
                        read_goto_next_line();
                        continue;
                    }
                    xx+=rbf_draw_char(xx, yy, buffer[i], conf.reader_color);
                    break;
                }
                ++i;
                if (xx >= x+w) {
                    xx  = x;
                    yy += rbf_font_height();
                }
            }
            read_on_screen+=i;
        }

        sprintf(buffer, "(%3d%%) %d/%d  ", (read_file_size)?(conf.reader_pos*100/read_file_size):0, conf.reader_pos, read_file_size);
        buffer[camera_screen.width/FONT_WIDTH]=0;
        draw_txt_string((camera_screen.ts_button_border/FONT_WIDTH), 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE)); //title infoline

        // scrollbar
        if (read_file_size) {
            i=h-1 -1;           // full height
            n=i*read_on_screen/read_file_size;           // bar height
            if (n<20) n=20;
            i=(i-n)*conf.reader_pos/read_file_size;   // top pos
            draw_filled_rect(x+w+6+2, y+1,   x+w+6+6, y+1+i,   MAKE_COLOR(COLOR_BLACK, COLOR_BLACK));
            draw_filled_rect(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK));
            draw_filled_rect(x+w+6+2, y+1+i, x+w+6+6, y+i+n,   MAKE_COLOR(COLOR_WHITE, COLOR_WHITE));
        } else {
            draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1,
                             (x+w)*FONT_WIDTH+6, (y+h)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK));
        }

        read_to_draw = 0;
        last_time = get_tick_count();
    }
    gui_read_draw_batt();
    gui_read_draw_clock();
}
Esempio n. 8
0
//-------------------------------------------------------------------
static void read_goto_next_line() {
    twoColors col = user_color(conf.reader_color);
    draw_rectangle(xx, yy, x+w-1, yy+rbf_font_height()-1, MAKE_COLOR(BG_COLOR(col), BG_COLOR(col)), RECT_BORDER0|DRAW_FILLED);
    xx  = x;
    yy += rbf_font_height();
}
Esempio n. 9
0
//-------------------------------------------------------------------
void gui_read_draw(int force_redraw)
{
    if (do_not_draw)
        return;
    busy_drawing = 1;
    twoColors col = user_color(conf.reader_color);

    static int first_draw = 1;
    if (first_draw || force_redraw)
    {
        if (first_draw)
        {
            // font has to be loaded from here (SpyTask)
            rbf_load_from_file(conf.reader_rbf_file, conf.reader_codepage);
        }
        draw_rectangle(camera_screen.disp_left, 0,
                       camera_screen.disp_right, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED);
        draw_rectangle(camera_screen.disp_left, y,
                       camera_screen.disp_right, camera_screen.height-1, MAKE_COLOR(BG_COLOR(col), BG_COLOR(col)), RECT_BORDER0|DRAW_FILLED);
        gui_read_draw_scroll_indicator();
        read_to_draw = 1;
        first_draw = 0;
    }

    if (conf.reader_autoscroll && !pause && get_tick_count()-last_time >= conf.reader_autoscroll_delay*1000 && (conf.reader_pos+read_on_screen)<read_file_size)
    {
        conf.reader_pos += read_on_screen;
        read_to_draw = 1;
    }
    if (read_to_draw)
    {
        int n, m, i, ii, ll, new_word=1;

        xx=x; yy=y;

        lseek(read_file, conf.reader_pos, SEEK_SET);
        read_on_screen=0;

        while (yy<=y+h-rbf_font_height()) {
            n=read(read_file, buffer, READ_BUFFER_SIZE);
            if (n==0) {
                 read_goto_next_line();
                 if (yy < y+h)
                     draw_rectangle(x, yy, x+w-1, y+h-1, MAKE_COLOR(BG_COLOR(col), BG_COLOR(col)), RECT_BORDER0|DRAW_FILLED);
                 break;
            }
            else if (n<0) {
                // read failed
                do_not_draw = 1;
                busy_drawing = 0;
                return;
            }
            i=0;
            while (i<n && yy<=y+h-rbf_font_height()) {
                switch (buffer[i]) {
                    case '\r':
                        new_word = 1;
                        break;
                    case '\n':
                        read_goto_next_line();
                        new_word = 1;
                        break;
                    case '\t':
                        buffer[i] = ' ';
                        // no break here
                    default:
                        if (conf.reader_wrap_by_words) {
                            if (buffer[i] == ' ') {
                                new_word = 1;
                                if (xx==x) //ignore leading spaces
                                    break;
                            } else if (new_word) {
                                new_word = 0;
                                for (ii=i, ll=0; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) {
                                    ll+=rbf_char_width(buffer[ii]);
                                }
                                if (ii==n) {
                                    memcpy(buffer, buffer+i, n-i);
                                    n=ii=n-i;
                                    read_on_screen+=i;
                                    i=0;
                                    m=read(read_file, buffer+n, READ_BUFFER_SIZE-n);
                                    if (m<0) {
                                        // read failed
                                        do_not_draw = 1;
                                        busy_drawing = 0;
                                        return;
                                    }
                                    n+=m;
                                    for (; ii<n && buffer[ii]!=' ' && buffer[ii]!='\t' && buffer[ii]!='\r' && buffer[ii]!='\n'; ++ii) {
                                        ll+=rbf_char_width(buffer[ii]);
                                    }
                                }
                                if (xx+ll>=x+w && ll<w) {
                                    read_goto_next_line();
                                    continue;
                                }
                            }
                        }
                        if (!read_fit_next_char(buffer[i])) {
                            read_goto_next_line();
                            continue;
                        }
                        xx+=rbf_draw_char(xx, yy, buffer[i], col);
                        break;
                }
                ++i;
                if (xx >= x+w) {
                    xx  = x;
                    yy += rbf_font_height();
                }
            }
            read_on_screen+=i;
        }
    
        sprintf(buffer, "(%3d%%) %d/%d", (read_file_size)?(conf.reader_pos*100/read_file_size):0, conf.reader_pos, read_file_size);
        draw_string_justified(camera_screen.disp_left, 0, buffer, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE), 0, 20*FONT_WIDTH, TEXT_LEFT|TEXT_FILL); //title infoline

        // scrollbar
        if (read_file_size) {
            i=h-1 -1;           // full height
            n=i*read_on_screen/read_file_size;           // bar height
            if (n<20) n=20;
            i=(i-n)*conf.reader_pos/read_file_size;   // top pos
            draw_rectangle(x+w+6+2, y+1,   x+w+6+6, y+1+i,   MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED);
            draw_rectangle(x+w+6+2, y+i+n, x+w+6+6, y+h-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED);
            draw_rectangle(x+w+6+2, y+1+i, x+w+6+6, y+i+n,   MAKE_COLOR(COLOR_WHITE, COLOR_WHITE), RECT_BORDER0|DRAW_FILLED);
        } else {
            draw_rectangle((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1,
                           (x+w)*FONT_WIDTH+6, (y+h)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED);
        }

        read_to_draw = 0;
        last_time = get_tick_count();
    }
    gui_read_draw_batt();
    gui_read_draw_clock();
    busy_drawing = 0;
}