Esempio n. 1
0
//-------------------------------------------------------------------
void gui_osd_draw_ev_video(int is_osd_edit)
{
#if CAM_EV_IN_VIDEO
    if (!is_video_recording() && !is_osd_edit) return;

    int visible = get_ev_video_avail() || is_osd_edit;

    int x0=conf.ev_video_pos.x, y0=conf.ev_video_pos.y;
    int i, deltax;

    twoColors col = user_color(conf.osd_color);

    draw_rectangle(x0,y0,x0+70,y0+24, visible? MAKE_COLOR(BG_COLOR(col),BG_COLOR(col)): COLOR_TRANSPARENT, RECT_BORDER1|DRAW_FILLED);

    if (!visible) { return; }

    for (i=0;i<9;i++) draw_line(x0+2+i*8,   y0+12, x0+2+i*8,   y0+12-(i&1 ? 5 : 10), col);
    for (i=0;i<9;i++) draw_line(x0+2+i*8+1, y0+12, x0+2+i*8+1, y0+12-(i&1 ? 5 : 10), col);

    deltax=8*get_ev_video();

    x0+=deltax;

    draw_line(x0+34,y0+16,x0+34,y0+22,col);
    draw_line(x0+35,y0+16,x0+35,y0+22,col);

    draw_line(x0+32,y0+19,x0+32,y0+22,col);
    draw_line(x0+33,y0+18,x0+33,y0+22,col);
    draw_line(x0+36,y0+18,x0+36,y0+22,col);
    draw_line(x0+37,y0+19,x0+37,y0+22,col);
#endif
}
Esempio n. 2
0
void p1_state::set_palette_luts(void)
{
	/* Setup 2bpp palette lookup table */
	// HIRES
	if ( m_video.color_select_68 & 0x80 )
	{
		m_video.palette_lut_2bpp[0] = 0;
	}
	else
	{
		m_video.palette_lut_2bpp[0] = BG_COLOR(m_video.color_select_68);
	}
	// B&W -- XXX
/*
    if ( m_video.mode_control_6a & 0x40 )
    {
        m_video.palette_lut_2bpp[1] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 3;
        m_video.palette_lut_2bpp[2] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 4;
        m_video.palette_lut_2bpp[3] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 7;
    }
    else
*/
	{
		// PALETTE
		if ( m_video.color_select_68 & 0x20 )
		{
			m_video.palette_lut_2bpp[1] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 3;
			m_video.palette_lut_2bpp[2] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 5;
			m_video.palette_lut_2bpp[3] = ( ( m_video.color_select_68 & 0x20 ) >> 2 ) | 7;
		}
		else
		{
Esempio n. 3
0
File: qw.c Progetto: Distrotech/joe
static void dispqwn(QW *qw)
{
	int y;
	W *w = qw->parent;

	/* Set cursor position */
	if (w->win->watom->follow && w->win->object)
		w->win->watom->follow(w->win->object);
	if (w->win->watom->disp && w->win->object)
		w->win->watom->disp(w->win->object, 1);
	w->curx = w->win->curx;
	w->cury = w->win->cury + w->win->y - w->y;

	/* Generate prompt */
	for (y = 0; y != w->h; ++y) {
		unsigned char *s = qw->prompt;
		int l = qw->promptlen;
		break_height(locale_map, &s, &l, qw->org_w, y);
		w->t->t->updtab[w->y + y] = 1;
		genfield(w->t->t,
		         w->t->t->scrn + (w->y + y) * w->t->t->co + w->x,
		         w->t->t->attr + (w->y + y) * w->t->t->co + w->x,
		         w->x,
		         w->y + y,
		         0,
		         s,
		         l,
		         BG_COLOR(bg_prompt),
		         w->w - w->x,
		         1,NULL);
	}
}
Esempio n. 4
0
//-------------------------------------------------------------------
int gui_read_init(const char* file) {
    static struct STD_stat   st;
    read_file = safe_open(file, O_RDONLY, 0777);
    if (strcmp(file, conf.reader_file)!=0) {
        conf.reader_pos = 0;
        strcpy(conf.reader_file, file);
    }
    read_on_screen = 0;
    read_file_size = (read_file>=0 && safe_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;
    x=camera_screen.ts_button_border+6;
    y=FONT_HEIGHT;
    w=camera_screen.width-camera_screen.ts_button_border*2-6-6-8;
    h=camera_screen.height-y;
    last_time = get_tick_count();

    reader_is_active=1;
    old_mode = gui_set_mode(&GUI_MODE_READ);

    draw_filled_rect(0, 0, camera_screen.width-1, y-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK));
    draw_filled_rect(0, y, camera_screen.width-1, camera_screen.height-1, MAKE_COLOR(BG_COLOR(conf.reader_color), BG_COLOR(conf.reader_color)));

    gui_read_draw_scroll_indicator();
    gui_read_draw_batt();

    return (read_file >= 0);
}
Esempio n. 5
0
void edupd(int flg)
{
	W *w;
	int wid, hei;

	if (dostaupd) {
		staupd = 1;
		dostaupd = 0;
	}
	ttgtsz(&wid, &hei);
	if (nresize(maint->t, wid, hei)) {
		sresize(maint);
#ifdef MOUSE_GPM
		gpm_mx = wid;
		gpm_my = hei;
#endif
	}
	dofollows();
	ttflsh();
	nscroll(maint->t, BG_COLOR(bg_text));
	help_display(maint);
	w = maint->curwin;
	do {
		if (w->y != -1) {
			if (w->object && w->watom->disp)
				w->watom->disp(w->object, flg);
			msgout(w);
		}
		w = (W *) (w->link.next);
	} while (w != maint->curwin);
	cpos(maint->t, maint->curwin->x + maint->curwin->curx, maint->curwin->y + maint->curwin->cury);
	staupd = 0;
}
Esempio n. 6
0
File: qw.c Progetto: Distrotech/joe
static void dispqw(QW *qw)
{
	int y;
	W *w = qw->parent;

	/* Generate prompt */
	for (y = 0; y != w->h; ++y) {
		unsigned char *s = qw->prompt;
		int l = qw->promptlen;
		break_height(locale_map, &s, &l, qw->org_w, y);
		w->t->t->updtab[w->y + y] = 1;
		genfield(w->t->t,
		         w->t->t->scrn + (w->y + y) * w->t->t->co + w->x,
		         w->t->t->attr + (w->y + y) * w->t->t->co + w->x,
		         w->x,
		         w->y + y,
		         0,
		         s,
		         l,
		         BG_COLOR(bg_prompt),
		         w->w - w->x,
		         1,NULL);
		w->cury = y;
		w->curx = w->x + joe_wcswidth(locale_map, s, l);
	}
}
Esempio n. 7
0
static void gui_osd_draw_single_histo(int hist, coord x, coord y, int small)
{
    twoColors hc = user_color(conf.histo_color);
    twoColors hc2 = user_color(conf.histo_color2);

    register unsigned int i, v, threshold;
    register color cl, cl_over, cl_bg = BG_COLOR(hc);
    coord w=HISTO_WIDTH, h=HISTO_HEIGHT;

    switch (hist) 
    {
        case HISTO_R: 
            cl=COLOR_RED;
            break;
        case HISTO_G: 
            cl=COLOR_GREEN;
            break;
        case HISTO_B:
            cl=COLOR_BLUE;
            break;
        case HISTO_RGB:
        case HISTO_Y:
        default:
            cl=FG_COLOR(hc);
            break;
    }

    if (small) {
        h>>=1; w>>=1;
        for (i=0; i<w; ++i) {
            threshold = (histogram[hist][i<<1]+histogram[hist][(i<<1)+1])>>2;

            for (v=1; v<h-1; ++v)
                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl:cl_bg);
            cl_over = (threshold==h && conf.show_overexp)?BG_COLOR(hc2):cl;
            for (; v<h; ++v)
                draw_pixel(x+1+i, y+h-v, (v<=threshold)?cl_over:cl_bg);
        }
    } else {
        for (i=0; i<w; ++i) {
Esempio n. 8
0
void gui_osd_draw_clock(int x, int y, twoColors cl, int is_osd_edit)
{
    if (conf.show_clock || is_osd_edit)
    {
        static char *ampm[2][3] = { { " AM", "A", " "}, { " PM", "P", "." } };

        struct tm *ttm = get_localtime();

        int w = 0;          // Extra width from AM/PM indicator and seconds (if displayed)

        if ((FG_COLOR(cl) == 0) && (BG_COLOR(cl) == 0)) cl = user_color(conf.osd_color);

        if ((camera_info.state.is_shutter_half_press == 0) || (conf.clock_halfpress == 0) || is_osd_edit)
        {
            unsigned int hour = (ttm->tm_hour);
            char *ampm_ind = "";    // AM / PM indicator

            if (conf.clock_format == CLOCK_FORMAT_12)
            {
                ampm_ind = ampm[hour/12][conf.clock_indicator]; //(hour >= 12) ? pm : am; 
                w = strlen(ampm_ind);
                if (hour == 0)
                    hour = 12;
                else if (hour > 12)
                    hour = hour - 12;
            }

            if ((conf.show_clock != CLOCK_WITHOUT_SEC) || is_osd_edit)
            {
                sprintf(osd_buf, "%2u:%02u:%02u%s", hour, ttm->tm_min, ttm->tm_sec, ampm_ind);
                w += 3;
            }
            else
            {
                sprintf(osd_buf, "%2u:%02u%s", hour, ttm->tm_min, ampm_ind);
            }

            if (x)  // for gui_4wins.c
                draw_string(x, y, osd_buf, cl);
            else
                draw_osd_string(conf.clock_pos, 0, 0, osd_buf, cl, conf.clock_scale);
        }
        else if (camera_info.state.is_shutter_half_press && (conf.clock_halfpress == 1))
        {
            sprintf(osd_buf, "%02u", ttm->tm_sec);
            if (conf.clock_pos.x >= 4*FONT_WIDTH) w = 3;
            draw_osd_string(conf.clock_pos, w*FONT_WIDTH, 0, osd_buf, cl, conf.clock_scale);
        }
    }
}
Esempio n. 9
0
File: pw.c Progetto: Distrotech/joe
static void disppw(BW *bw, int flg)
{
	W *w = bw->parent;
	PW *pw = (PW *) bw->object;

	if (!flg) {
		return;
	}

	/* Scroll buffer and position prompt */
	if (pw->promptlen > w->w - 5) {
		pw->promptofst = pw->promptlen - w->w / 2;
		if (piscol(bw->cursor) < w->w - (pw->promptlen - pw->promptofst)) {
			bw->offset = 0;
		} else {
			bw->offset = piscol(bw->cursor) - (w->w - (pw->promptlen - pw->promptofst) - 1);
		}
	} else {
		if (piscol(bw->cursor) < w->w - pw->promptlen) {
			pw->promptofst = 0;
			bw->offset = 0;
		} else if (piscol(bw->cursor) >= w->w) {
			pw->promptofst = pw->promptlen;
			bw->offset = piscol(bw->cursor) - (w->w - 1);
		} else {
			pw->promptofst = pw->promptlen - (w->w - piscol(bw->cursor) - 1);
			bw->offset = piscol(bw->cursor) - (w->w - (pw->promptlen - pw->promptofst) - 1);
		}
	}

	/* Set cursor position */
	w->curx = piscol(bw->cursor) - bw->offset + pw->promptlen - pw->promptofst;
	w->cury = 0;

	/* Generate prompt */
	w->t->t->updtab[w->y] = 1;
	genfmt(w->t->t, w->x, w->y, pw->promptofst, pw->prompt, BG_COLOR(bg_prompt), 0);

	/* Position and size buffer */
	bwmove(bw, w->x + pw->promptlen - pw->promptofst, w->y);
	bwresz(bw, w->w - (pw->promptlen - pw->promptofst), 1);

	/* Generate buffer */
	bwgen(bw, 0);
}
Esempio n. 10
0
static void gui_print_osd_dof_string_dist(const char * title, int value, short use_good_color, short is_hyp) {
  strcpy(osd_buf, title);
  int i=strlen(osd_buf);
  twoColors col = user_color(conf.osd_color);
  twoColors valid_col = MAKE_COLOR(BG_COLOR(col), COLOR_GREEN);
  if (i<8) {
    draw_osd_string(conf.values_pos, 0, m, osd_buf, col, conf.values_scale);
    if (is_hyp) {
        sprintf_dist_hyp(osd_buf, value);
    } else {
        sprintf_dist(osd_buf, value);
    }
    sprintf(osd_buf+strlen(osd_buf), "%9s", "");
    osd_buf[9-i]=0;
    draw_osd_string(conf.values_pos, i*FONT_WIDTH, m, osd_buf, use_good_color?valid_col:col, conf.values_scale);
  } else {
    osd_buf[9]=0;
    draw_osd_string(conf.values_pos, 0, m, osd_buf, col,conf.values_scale);
  }
  m+=FONT_HEIGHT;
}
Esempio n. 11
0
int point_is_free(int y, int x)
{
	int top;
	chtype oldch;
	int oldfg;
	int oldbg;

	top = y % 2;

	/* Convert to screen coordinates. */
	y = (y - 1) / 2;
	x--;

	/* Get character at position. */
	oldch = mvinch(y, x);
	oldfg = FG_COLOR(oldch);
	oldbg = BG_COLOR(oldch);

	if (top) {
		switch (oldch & 0xff) {
			case 0xdc:
				return (oldbg == BACKGROUND_COLOR);
			case 0xdf:
			case 0xdb:
				return (oldfg == BACKGROUND_COLOR);
			default:
				return 1;
		}
	} else {
		switch (oldch & 0xff) {
			case 0xdf:
				return (oldbg == BACKGROUND_COLOR);
			case 0xdc:
			case 0xdb:
				return (oldfg == BACKGROUND_COLOR);
			default:
				return 1;
		}
	}
}
Esempio n. 12
0
void gui_osd_draw_dof(int is_osd_edit) 
{
    if (conf.show_dof != DOF_DONT_SHOW)
        shooting_update_dof_values();

    if (is_osd_edit ||
        (camera_info.state.mode_rec_or_review && ((conf.show_dof == DOF_SHOW_IN_DOF) || (conf.show_dof == DOF_SHOW_IN_DOF_EX)) &&
         (((camera_info.state.is_shutter_half_press || camera_info.state.state_kbd_script_run || shooting_get_common_focus_mode()) &&
           (camera_info.state.mode_photo || camera_info.state.mode_shooting==MODE_STITCH)) ||
          ((camera_info.state.mode_video || is_video_recording()) && conf.show_values_in_video))))
    {
        twoColors col = user_color(conf.osd_color);
        twoColors valid_col = MAKE_COLOR(BG_COLOR(col), COLOR_GREEN);
        int i = 8, j;
        short f_ex = (conf.show_dof==DOF_SHOW_IN_DOF_EX);
        draw_osd_string(conf.dof_pos, 0, 0, "S/NL/FL:", col, conf.dof_scale);
        sprintf_dist(osd_buf, camera_info.dof_values.subject_distance);
        j = strlen(osd_buf);
        draw_osd_string(conf.dof_pos, i*FONT_WIDTH, 0, osd_buf, (f_ex && (camera_info.dof_values.distance_valid || shooting_get_focus_mode()))?valid_col:col, conf.dof_scale);
        i = i+j;
        draw_osd_string(conf.dof_pos, i*FONT_WIDTH, 0, "/", col, conf.dof_scale);
        sprintf_dist(osd_buf, camera_info.dof_values.near_limit);
        j = strlen(osd_buf);
        draw_osd_string(conf.dof_pos, (++i)*FONT_WIDTH, 0, osd_buf, (f_ex && camera_info.dof_values.distance_valid)?valid_col:col, conf.dof_scale);
        i = i+j;
	    draw_osd_string(conf.dof_pos, i*FONT_WIDTH, 0, "/", col, conf.dof_scale);
        sprintf_dist(osd_buf, camera_info.dof_values.far_limit);
	    draw_osd_string(conf.dof_pos, (++i)*FONT_WIDTH, 0, osd_buf, (f_ex && camera_info.dof_values.distance_valid)?valid_col:col, conf.dof_scale);
        i = 8;
	    draw_osd_string(conf.dof_pos, 0, FONT_HEIGHT, "DOF/HYP:", col, conf.dof_scale);
        sprintf_dist(osd_buf, camera_info.dof_values.depth_of_field);
        j = strlen(osd_buf);
	    draw_osd_string(conf.dof_pos, i*FONT_WIDTH, FONT_HEIGHT, osd_buf, (f_ex && camera_info.dof_values.distance_valid)?valid_col:col, conf.dof_scale);
        i = i+j;
	    draw_osd_string(conf.dof_pos, i*FONT_WIDTH, FONT_HEIGHT, "/", col, conf.dof_scale);
        sprintf_dist_hyp(osd_buf, camera_info.dof_values.hyperfocal_distance);
	    draw_osd_string(conf.dof_pos, (++i)*FONT_WIDTH, FONT_HEIGHT, osd_buf, (f_ex && camera_info.dof_values.hyperfocal_valid)?valid_col:col, conf.dof_scale);
    }
}
Esempio n. 13
0
//-------------------------------------------------------------------
void gui_calendar_draw() {
    int x, y;
    static char str[32];
    int w, d, i;
    static struct tm *ttm;

    if (need_redraw == 2)
        gui_calendar_initial_draw();

    ttm = get_localtime();
    sprintf(str, " %2u %s %04u  %2u:%02u:%02u   ", ttm->tm_mday, lang_str(months[ttm->tm_mon]), 1900+ttm->tm_year, ttm->tm_hour, ttm->tm_min, ttm->tm_sec);
    draw_string(camera_screen.disp_left+FONT_WIDTH*8, 0, str, MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));

    if (need_redraw) {
        need_redraw = 0;
        
        i = strlen(lang_str(months[cal_month]));
        x = cal_x + (cal_w-FONT_WIDTH*2-FONT_WIDTH*4-FONT_WIDTH*2-i*FONT_WIDTH)/2;
        y = cal_y + 4;
        draw_rectangle(cal_x+FONT_WIDTH, y, cal_x+cal_w-FONT_WIDTH-FONT_WIDTH*4-FONT_WIDTH, y+FONT_HEIGHT, MAKE_COLOR(BG_COLOR(TITLE_COLOR), BG_COLOR(TITLE_COLOR)), RECT_BORDER0|DRAW_FILLED);
        draw_string(x+FONT_WIDTH, y, lang_str(months[cal_month]), TITLE_COLOR);
        
        sprintf(str, "%04d", cal_year);
        draw_string(cal_x+cal_w-FONT_WIDTH*2-FONT_WIDTH*4, y, str, TITLE_COLOR);

        d = calendar_days_in_month(cal_month+1, cal_year);
        w = calendar_day_of_week(1, cal_month+1, cal_year);

        y += FONT_HEIGHT+4+4;

        y += FONT_HEIGHT+4;
        for (x=0; x<w; ++x) {
            draw_string(cal_x+x*FONT_WIDTH*4, y, "    ", (x<5)?CALENDAR_COLOR:WEEKEND_COLOR);
        }
        
        for (i=1; i<=d; ++i) {
            sprintf(str, " %2d ", i);
            draw_string(cal_x+x*FONT_WIDTH*4, y, str, (x<5)?CALENDAR_COLOR:WEEKEND_COLOR);
            
            if (++x>6) {
              x=0;
              y += FONT_HEIGHT+4;
            }
        }
        for (; y<cal_y+cal_h; y += FONT_HEIGHT+4, x=0) {
            for (; x<7; ++x) {
                draw_string(cal_x+x*FONT_WIDTH*4, y, "    ", (x<5)?CALENDAR_COLOR:WEEKEND_COLOR);
            }
        }
    }
}
Esempio n. 14
0
/*
 * Display help text
 */
void help_display(Screen *t)
{
	unsigned char *str;
	int y, x, c, z;
	int atr = BG_COLOR(bg_help);

	if (help_actual) {
		str = help_actual->text;
	} else {
		str = NULL;
	}

	for (y = skiptop; y != t->wind; ++y) {
		if (t->t->updtab[y]) {
			unsigned char *start = str, *eol;
			int width=0;
			int nspans=0;
			int spanwidth;
			int spancount=0;
			int spanextra;
			int len;

			eol = zchr(str, '\n');

			/* First pass: count no. springs \| and determine minimum width */
			while(*str && *str!='\n') {
				if (*str == '\\') {
					++str;
					switch(*str) {
						case 'i':
						case 'I':
						case 'u':
						case 'U':
						case 'd':
						case 'D':
						case 'b':
						case 'B':
						case 'f':
						case 'F':
							++str;
							break;
						case '|':
							++str;
							++nspans;
							break;
						case 0:
							break;
						default:
							++str;
							++width;
					}
				} else {
					len = eol - str;
					if (help_is_utf8)
						c = utf8_decode_fwrd(&str, &len);
					else {
						c = *str++;
						--len;
					}
					width += joe_wcwidth(!!locale_map->type, c);
				}
			}
			str = start;
			/* Now calculate span width */
			if (width >= t->w - 1 || nspans==0) {
				spanwidth = 0;
				spanextra = nspans;
			} else {
				spanwidth = ((t->w - 1) - width)/nspans;
				spanextra = nspans - ((t->w - 1) - width - nspans*spanwidth);
			}
			/* Second pass: display text */
			for (x = 0; x != t->w - 1; ++x) {
				if (*str == '\n' || !*str) {
					if (eraeol(t->t, x, y, BG_COLOR(bg_help))) {
						return;
					} else {
						break;
					}
				} else {
					if (*str == '\\') {
						switch (*++str) {
						case '|':
							++str;
							for (z=0;z!=spanwidth;++z)
								outatr(locale_map,t->t,t->t->scrn+x+y*t->w+z,t->t->attr+x+y*t->w+z,x+z,y,' ',atr);
							if (spancount++ >= spanextra) {
								outatr(locale_map,t->t,t->t->scrn+x+y*t->w+z,t->t->attr+x+y*t->w+z,x+z,y,' ',atr);
								++z;
							}
							x += z-1;
							continue;
						case 'i':
						case 'I':
							atr ^= INVERSE;
							++str;
							--x;
							continue;
						case 'u':
						case 'U':
							atr ^= UNDERLINE;
							++str;
							--x;
							continue;
						case 'd':
						case 'D':
							atr ^= DIM;
							++str;
							--x;
							continue;
						case 'b':
						case 'B':
							atr ^= BOLD;
							++str;
							--x;
							continue;
						case 'f':
						case 'F':
							atr ^= BLINK;
							++str;
							--x;
							continue;
						case 0:	
							--x;
							continue;
						}
					}
					len = eol - str;
					if (help_is_utf8)
						c = utf8_decode_fwrd(&str, &len);
					else {
						c = *str++;
						--len;
					}

					outatr(locale_map,
					       t->t, t->t->scrn + x + y * t->w, 
				       	       t->t->attr + x + y * t->w, x, y,
					       c, atr);
					x += (joe_wcwidth(!!locale_map->type, c) - 1);
				}
			}
			atr = BG_COLOR(bg_help);
			t->t->updtab[y] = 0;
		}

		while (*str && *str != '\n')
			++str;
		if (*str == '\n')
			++str;
	}
}
Esempio n. 15
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. 16
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. 17
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. 18
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;
}
Esempio n. 19
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. 20
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. 21
0
void set_point(int y, int x, unsigned char color)
{
	int top;
	chtype oldch;
	int oldfg;
	int oldbg;
	char c;
	int fg;
	int bg;

	top = y % 2;

	/* Convert to screen coordinates. */
	y = (y - 1) / 2;
	x--;

	/* Get character at position. */
	oldch = mvinch(y, x);
	oldfg = FG_COLOR(oldch);
	oldbg = BG_COLOR(oldch);

	if (top) {
		/* Get bottom color. */
		int bottom_color;
		switch (oldch & 0xff) {
			case 0xdf:
				bottom_color = oldbg;
				break;
			case 0xdc:
			case 0xdb:
				bottom_color = oldfg;
				break;
			default:
				bottom_color = BACKGROUND_COLOR;
		}

		if (color == bottom_color) {
			c = (char) 0xdb; /* Top and bottom. */
			fg = color;
			bg = color;
		} else {
			c = (char) 0xdf; /* Top. */
			fg = color;
			bg = bottom_color;
		}
	} else {
		/* Get top color. */
		int top_color;
		switch (oldch & 0xff) {
			case 0xdc:
				top_color = oldbg;
				break;
			case 0xdf:
			case 0xdb:
				top_color = oldfg;
				break;
			default:
				top_color = BACKGROUND_COLOR;
		}

		if (color == top_color) {
			c = (char) 0xdb; /* Top and bottom. */
			fg = color;
			bg = color;
		} else {
			c = (char) 0xdc; /* Bottom. */
			fg = color;
			bg = top_color;
		}
	}

	mvaddch(y, x, MAKE_CHARACTER(c, fg, bg));
}
Esempio n. 22
0
//-------------------------------------------------------------------
static void gui_calendar_initial_draw() {
    int x, i;

    draw_rectangle(camera_screen.disp_left, 0, camera_screen.disp_right, camera_screen.height-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK), RECT_BORDER0|DRAW_FILLED);
    draw_string(camera_screen.disp_left+FONT_WIDTH, 0, lang_str(LANG_CALENDAR_TODAY), MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
    draw_rectangle(cal_x-3, cal_y-3, cal_x+cal_w+2, cal_y+cal_h+2, CALENDAR_COLOR, RECT_BORDER1);
    draw_rectangle(cal_x-1, cal_y-1, cal_x+cal_w, cal_y+FONT_HEIGHT+8, TITLE_COLOR, RECT_BORDER1|DRAW_FILLED);
    draw_rectangle(cal_x-1, cal_y+FONT_HEIGHT+8, cal_x+cal_w, cal_y+cal_h, CALENDAR_COLOR, RECT_BORDER1|DRAW_FILLED);

    draw_rectangle(cal_x+cal_w-FONT_WIDTH*4*2, cal_y+FONT_HEIGHT+8+1, cal_x+cal_w-1, cal_y+cal_h-1, MAKE_COLOR(BG_COLOR(WEEKEND_COLOR), BG_COLOR(WEEKEND_COLOR)), RECT_BORDER0|DRAW_FILLED);
    for (x=cal_x+FONT_WIDTH/2, i=0; i<7; x+=FONT_WIDTH*4, ++i) {
        draw_string(x, cal_y+4+FONT_HEIGHT+4+4, lang_str(days[i]), (i<5)?CALENDAR_COLOR:WEEKEND_COLOR);
    }
}