Exemplo n.º 1
0
print_titcop()
{
   register int   anything, font, i, j;
   int   more, nl, secondoff, secondx, x, y;
   long  fl;
   register char  *lin, *split;

   i = 0;
   do {
      more = FALSE;
      if (clip_img( liney[i].top, liney[i].size, &fl, &nl, &y )) {
         gr_clipx1 = 2;
         gr_clipy1 = (int)fl;
         gr_clipx2 = bitln - 2;
         gr_clipy2 = gr_clipy1 + nl - 1;
         scrbase = (long)s_image + (y? bytln * (long)y: -(bytln * fl));
         x = get_stringx( i, &secondoff, &secondx );
         font = (i < MAXTITLE)? (pageptr[PGTLRG+i]? MYLFONT: MYSFONT):
               MYTFONT;
         lin = &pageptr[(hpgline[i+1])];
         if (secondoff)
            *(split = &lin[secondoff - 1]) = '\0';
         gr_text( lin, x, font_info[font].fonth, 1, font );
         if (secondoff) {
            gr_text( ++split, secondx, font_info[font].fonth, 1, font );
            *(--split) = SPLITCHAR;
         }
      }
      if (voff + ahite >= liney[i].top + liney[i].size) {
         if (++i < MAXLIN)
            more = TRUE;
      }
   } while (!abortp && more);
}
Exemplo n.º 2
0
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_screen_locked()
{
    if (!show_text) {
        draw_background_locked(currentIcon);
        draw_progress_locked();
        // MStar Android Patch Begin
        draw_top_title_locked();
        draw_tip_title_locked(currentTip);
        draw_exit_recovery_tip_title_locked(currentExitRecoveryTip);
        // MStar Android Patch End
    } else {
        gr_color(0, 0, 0, 255);
        gr_clear();

        int y = 0;
        int i = 0;
        if (show_menu) {
            SetColor(HEADER);

            for (; i < menu_top + menu_items; ++i) {
                if (i == menu_top) SetColor(MENU);

                if (i == menu_top + menu_sel) {
                    // draw the highlight bar
                    SetColor(MENU_SEL_BG);
                    gr_fill(0, y-2, gr_fb_width(), y+char_height+2);
                    // white text of selected item
                    SetColor(MENU_SEL_FG);
                    if (menu[i][0]) gr_text(4, y, menu[i], 1);
                    SetColor(MENU);
                } else {
                    if (menu[i][0]) gr_text(4, y, menu[i], i < menu_top);
                }
                y += char_height+4;
            }
            SetColor(MENU);
            y += 4;
            gr_fill(0, y, gr_fb_width(), y+2);
            y += 4;
            ++i;
        }

        SetColor(LOG);

        // display from the bottom up, until we hit the top of the
        // screen, the bottom of the menu, or we've displayed the
        // entire text buffer.
        int ty;
        int row = (text_top+text_rows-1) % text_rows;
        for (int ty = gr_fb_height() - char_height, count = 0;
             ty > y+2 && count < text_rows;
             ty -= char_height, ++count) {
            gr_text(4, ty, text[row], 0);
            --row;
            if (row < 0) row = text_rows-1;
        }
    }
}
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_screen_locked() {
    if (!show_text) {
        draw_background_locked(currentIcon);
        draw_progress_locked();
    } else {
        gr_color(0, 0, 0, 255);
        gr_clear();

        int y = 0;
        if (show_menu) {
            char recovery_fingerprint[PROPERTY_VALUE_MAX];
            property_get("ro.bootimage.build.fingerprint", recovery_fingerprint, "");

            SetColor(INFO);
            DrawTextLine(&y, "Android Recovery", true);
            for (auto& chunk : android::base::Split(recovery_fingerprint, ":")) {
                DrawTextLine(&y, chunk.c_str(), false);
            }
            DrawTextLines(&y, HasThreeButtons() ? REGULAR_HELP : LONG_PRESS_HELP);

            SetColor(HEADER);
            DrawTextLines(&y, menu_headers_);

            SetColor(MENU);
            DrawHorizontalRule(&y);
            y += 4;
            for (int i = 0; i < menu_items; ++i) {
                if (i == menu_sel) {
                    // Draw the highlight bar.
                    SetColor(IsLongPress() ? MENU_SEL_BG_ACTIVE : MENU_SEL_BG);
                    gr_fill(0, y - 2, gr_fb_width(), y + char_height + 2);
                    // Bold white text for the selected item.
                    SetColor(MENU_SEL_FG);
                    gr_text(4, y, menu_[i], true);
                    SetColor(MENU);
                } else {
                    gr_text(4, y, menu_[i], false);
                }
                y += char_height + 4;
            }
            DrawHorizontalRule(&y);
        }

        // display from the bottom up, until we hit the top of the
        // screen, the bottom of the menu, or we've displayed the
        // entire text buffer.
        SetColor(LOG);
        int row = (text_top_ + text_rows_ - 1) % text_rows_;
        size_t count = 0;
        for (int ty = gr_fb_height() - char_height;
             ty >= y && count < text_rows_;
             ty -= char_height, ++count) {
            gr_text(0, ty, text_[row], false);
            --row;
            if (row < 0) row = text_rows_ - 1;
        }
    }
}
Exemplo n.º 4
0
void ScreenRecoveryUI::draw_dialog()
{
    int x, y, w, h;

   if (dialog_icon == HEADLESS) {
       return;
    }
    draw_header_icon();

    int iconHeight = gr_get_height(backgroundIcon[dialog_icon]);

    x = (gr_fb_width()/2 - (char_width*strlen(dialog_text))/2);
    if (dialog_show_log) {
        y = gr_get_height(headerIcon) + char_height;
    }
    else {
        y = (gr_fb_height()/2 + iconHeight/2);
    }

    SetColor(ERROR_TEXT);
    gr_text(x, y, dialog_text, 0);
    y += char_height+2;

    if (dialog_show_log) {
        int cx, cy;
        gr_set_font("log");
        gr_font_size(&cx, &cy);

        int row;
        for (row = 0; row < log_text_rows; ++row) {
            gr_text(4, y, text[row], 0);
            y += cy+2;
        }
        gr_set_font("menu");
    }

    if (dialog_icon == ERROR) {
        /*
         * This could be improved...
         *
         * Draw rect around text "Okay".
         * Text is centered horizontally.
         * Bottom of text is 4 lines from bottom of screen.
         * Rect width 4px
         * Rect padding 8px
         */
        w = char_width*4;
        h = char_height;
        x = gr_fb_width()/2 - w/2;
        y = gr_fb_height() - h - 4*char_height;
        SetColor(HEADER);
        gr_fill(x-(4+8), y-(4+8), x+w+(4+8), y+h+(4+8));
        SetColor(MENU_SEL_BG);
        gr_fill(x-8, y-8, x+w+8, y+h+8);
        SetColor(MENU_SEL_FG);
        gr_text(x, y, "Okay", 0);
    }
}
Exemplo n.º 5
0
void ScreenRecoveryUI::draw_menu_item(int textrow, const char *text, int selected)
{
    if (selected) {
        SetColor(MENU_SEL_BG);
        gr_fill(0, (textrow)*char_height,
                gr_fb_width(), (textrow+3)*char_height-1);
        SetColor(MENU_SEL_FG);
        gr_text(20, (textrow+1)*char_height-1, text, 0);
        SetColor(MENU);
    }
    else {
        SetColor(MENU);
        gr_text(20, (textrow+1)*char_height-1, text, 0);
    }
}
Exemplo n.º 6
0
static void menu_draw_text_line(int row, const char* t, void* ctx) 
{
	if (t[0] != '\0') {
		gr_text(0, (row+1)*CHAR_HEIGHT-1, t);
		gr_color(64, 96, 255, 255);
	}
}
Exemplo n.º 7
0
void draw_text_line(int row, const char* t) {
  if (t[0] != '\0') {
#ifdef NOT_ENOUGH_RAINBOWS
    if (ui_get_rainbow_mode()) ui_rainbow_mode();
#endif
    gr_text(0, (row+1)*CHAR_HEIGHT-1, t, 0);
  }
}
Exemplo n.º 8
0
// Exercises many of the gr_*() functions; useful for testing.
static void gr_test() {
    GRSurface** images;
    int frames;
    int result = res_create_multi_surface("icon_installing", &frames, &images);
    if (result < 0) {
        printf("create surface %d\n", result);
        gr_exit();
        return;
    }

    time_t start = time(NULL);
    int x;
    for (x = 0; x <= 1200; ++x) {
        if (x < 400) {
            gr_color(0, 0, 0, 255);
        } else {
            gr_color(0, (x-400)%128, 0, 255);
        }
        gr_clear();

        gr_color(255, 0, 0, 255);
        gr_surface frame = images[x%frames];
        gr_blit(frame, 0, 0, frame->width, frame->height, x, 0);

        gr_color(255, 0, 0, 128);
        gr_fill(400, 150, 600, 350);

        gr_color(255, 255, 255, 255);
        gr_text(500, 225, "hello, world!", 0);
        gr_color(255, 255, 0, 128);
        gr_text(300+x, 275, "pack my box with five dozen liquor jugs", 1);

        gr_color(0, 0, 255, 128);
        gr_fill(gr_draw->width - 200 - x, 300, gr_draw->width - x, 500);

        gr_draw = gr_backend->flip(gr_backend);
    }
    printf("getting end time\n");
    time_t end = time(NULL);
    printf("got end time\n");
    printf("start %ld end %ld\n", (long)start, (long)end);
    if (end > start) {
        printf("%.2f fps\n", ((double)x) / (end-start));
    }
}
Exemplo n.º 9
0
static int
paint_entry(Calendar *c, int x, int y, int maxchars, Paint_cache *cache_entry, XRectangle *rect)
{
    XFontSetExtents	fontextents;
    Props *p = (Props*)c->properties;
    int             nlines = 0, dt = get_int_prop(p, CP_DEFAULTDISP);
    new_XContext        *xc = c->xcontext;
    char            buf1[50], buf2[WHAT_LEN+1];
    Week            *w = (Week *)c->view->week_info;
    Tick		tick;

    /*
     * Write an appointment entry into a day
     */

    if (maxchars >= 40)             /* maxed out possible=40 */
        maxchars = 40;

    buf1[0] = '\0';
    buf2[0] = '\0';

    format_entry(cache_entry, buf1, buf2, dt);

    tick = cache_entry->start_time;

    if (cache_entry->show_time && !magic_time(tick) && (buf1[0] != '\0')) {
        maxchars = gr_nchars(w->day_width - 5, buf1,c->fonts->boldfont);
        buf1[min(cm_strlen(buf1), maxchars)] = '\0';
        gr_text(xc, x, y, c->fonts->boldfont, buf1, rect);
        nlines++;
        CalFontExtents(c->fonts->boldfont, &fontextents);
        y += fontextents.max_logical_extent.height;;
    }
    if (buf2[0] != '\0') {
        maxchars = gr_nchars(w->day_width - 5, buf2,
                             c->fonts->viewfont);
        buf2[min(cm_strlen(buf2), maxchars)] = '\0';
        gr_text(xc, x, y, c->fonts->viewfont, buf2, rect);
        nlines++;
    }

    return(nlines);
}
Exemplo n.º 10
0
void FORTRAN(gr_text)(
  double *x, double *y, char *string, unsigned char string_len)
{
  char *_string;

  _string = (char *) calloc(1, sizeof(char) * string_len);
  strncpy(_string, string, string_len);

  gr_text(*x, *y, _string);

  free(_string);
}
Exemplo n.º 11
0
//[email protected], 2012/06/11, Add for scroll the line when the string is too long
static void draw_focus_text_line(int row, const char* t){
    if ((t[0] != '\0')){
        switch (gFocusScrollState){
            case FOCUSSTATE_TYPE_INIT:
                focus_line_length = gr_text(0, (row+1)*CHAR_HEIGHT-1, t);
                if (focus_line_length > gr_fb_width()){
                    gFocusScrollState = FOCUSSTATE_TYPE_SCROLL;
                } else {
                    gFocusScrollState = FOCUSSTATE_TYPE_NOSCROLL;
                }
                break;
            case FOCUSSTATE_TYPE_NOSCROLL:
                gr_text(0, (row+1)*CHAR_HEIGHT-1, t);
                break;
            case FOCUSSTATE_TYPE_SCROLL:
                gr_text(cur_point, (row+1)*CHAR_HEIGHT-1, t);
                break;
            default:
                break;
        }
    }
}
Exemplo n.º 12
0
// Redraw everything on the screen.  Does not flip pages.
// Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_screen_locked()
{
    draw_background_locked(currentIcon);

    if (DialogShowing()) {
        draw_dialog();
        return;
    }

    SetColor(MENU);

    if (show_text) {

        if (currentIcon != ERASING && currentIcon != INSTALLING_UPDATE)
            draw_header_icon();

        if (currentIcon == ERASING || currentIcon == INSTALLING_UPDATE || currentIcon == VIEWING_LOG) {
            int y = currentIcon == INSTALLING_UPDATE ? gr_fb_height() / 4 : header_height + 4;

            SetColor(LOG);
            int cx, cy;
            gr_set_font("log");
            gr_font_size(&cx, &cy);
            // display from the bottom up, until we hit the top of the
            // screen or we've displayed the entire text buffer.
            int row = (text_first_row+log_text_rows-1) % log_text_rows;
            for (int ty = gr_fb_height() - cy, count = 0;
                 ty > y+2 && count < log_text_rows;
                 ty -= (cy+2), ++count) {
                gr_text(4, ty, text[row], 0);
                --row;
                if (row < 0) row = log_text_rows-1;
            }
            return;
        }

        if (show_menu) {
            gr_set_font("menu");

            int nr_items = menu_items - menu_show_start;
            if (nr_items > max_menu_rows)
                nr_items = max_menu_rows;
            for (int i = 0; i < nr_items; ++i) {
                draw_menu_item(text_first_row + 3*i, menu[menu_show_start+i],
                        ((menu_show_start+i) == menu_sel));
            }
        }
    }
}
Exemplo n.º 13
0
Arquivo: demo.c Projeto: Juanlu001/gr
int main(void)
{
  float positions[3] = {0, 0, 0}, colors[3] = {0.5, 0.5, 0.5}, radii[1] = {2};

  gr3_clear();
  gr_setviewport(0.1, 0.95, 0.1, 0.95);
  gr3_setbackgroundcolor(1, 1, 1, 1);
  gr3_drawspheremesh(1, positions, colors, radii);
  gr3_drawimage(0, 1, 0, 1, 500, 500, GR3_DRAWABLE_GKS);
  gr_axes(0.04, 0.04, 0, 0, 5, 5, -0.01);
  gr_settextalign(2, 4);
  gr_text(0.525, 0.95, "GR3 Demo");
  gr3_export("gr3demo.png", 500, 500);
  gr_updatews();
}
Exemplo n.º 14
0
static void version_test_output_multi_line(TestCase* thiz, char* buf)
{
	DECLES_PRIV(priv, thiz);
	char tmpbuf[priv->max_line_length];

	if ((int)strlen(buf) > priv->max_line_length) {
		char* ptr;
		char* end_ptr;
		ptr = buf;
		end_ptr = buf + strlen(buf);
		while (ptr < end_ptr) {
			memset(tmpbuf, 0, sizeof(tmpbuf));
			snprintf(tmpbuf, priv->max_line_length, ptr);
			gr_text(0, priv->start_y, tmpbuf);
			ptr += priv->max_line_length - 1;
			priv->start_y += CHAR_HEIGHT;
		}
	} else {
		gr_text(0, priv->start_y, buf);
		priv->start_y += CHAR_HEIGHT;
	}

	priv->start_y += CHAR_HEIGHT;
}
void healthd_board_mode_charger_draw_battery(
                struct android::BatteryProperties *batt_prop)
{
    char cap_str[STR_LEN];
    int x, y;
    int str_len_px;
    static int char_height = -1, char_width = -1;

    if (char_height == -1 && char_width == -1)
        gr_font_size(gr_sys_font(), &char_width, &char_height);
    snprintf(cap_str, (STR_LEN - 1), "%d%%", batt_prop->batteryLevel);
    str_len_px = gr_measure(gr_sys_font(), cap_str);
    x = (gr_fb_width() - str_len_px) / 2;
    y = (gr_fb_height() + char_height) / 2;
    gr_color(0, 0, 0, 255);
    gr_text(gr_sys_font(), x, y, cap_str, 0);
}
Exemplo n.º 16
0
extern void
paint_day_header(Calendar *c, Tick date, void *rect)
{
	Props *p = (Props*)c->properties;
	OrderingType ot = get_int_prop(p, CP_DATEORDERING);
	int pfy, x;
	char buf[100];
	Boolean inrange = False;
	Colormap cmap;
	Pixel foreground_pixel;
	XFontSetExtents fontextents;
	struct tm *tm;
	_Xltimeparams localtime_buf;

	tm = _XLocaltime(&date, localtime_buf);

	CalFontExtents(c->fonts->labelfont, &fontextents);
	pfy = fontextents.max_logical_extent.height;
        XtVaGetValues(c->canvas, XmNcolormap, &cmap, NULL);
        XtVaGetValues(c->canvas, XmNforeground, &foreground_pixel, NULL);
        buf [0] = '\0';
	/* NL_COMMENT
	   Attention Translator:

	   This string is used in the calendar day view.  In the C locale
	   it has the form:

		Monday, January 16, 1995

	   strftime conversion string: "%A, %B %e, %Y" is used.  

	   Use the appropriate strftime conversion for your locale.
	*/
	strftime(buf, 100, catgets(c->DT_catd, 1, 992, "%A, %B %e, %Y"), tm);
	inrange = today_inrange(c, date);
	x = gr_center(c->view->winw-(int)MOBOX_AREA_WIDTH, buf,
			c->fonts->labelfont) + (int)MOBOX_AREA_WIDTH;
	if (c->xcontext->screen_depth >= 8 && inrange) 
        	gr_text_rgb(c->xcontext, x, c->view->topoffset - (pfy/2),
                        c->fonts->labelfont, buf, foreground_pixel, 
			cmap, rect);
	else
        	gr_text(c->xcontext, x, c->view->topoffset - (pfy/2),
                        c->fonts->labelfont, buf, rect);
}
Exemplo n.º 17
0
static void show_slash_draw_screen_locked(const char * msg)
{
    draw_background_locked(gCurrentIcon);
   
    // background color
    gr_color(0, 0, 0, 160);
    gr_fill(0, 0, gr_fb_width(), gr_fb_height());
  
    // printed text color 
    set_gr_color(COLOR_YELLOW);
 

    if (msg[0] != '\0') {
        //gr_text_scale(1, (1)*CHAR_HEIGHT-1, msg, 2); //will use this in future
        gr_text(1, (1)*CHAR_HEIGHT-1, msg);
    }
    
}
Exemplo n.º 18
0
static void draw_text_line(int row, const char* t, int align) {
    int col = 0;
    if (t[0] != '\0') {
        int length = strnlen(t, MENU_MAX_COLS) * CHAR_WIDTH;
        switch(align)
        {
            case LEFT_ALIGN:
                col = 1;
                break;
            case CENTER_ALIGN:
                col = ((gr_fb_width() - length) / 2);
                break;
            case RIGHT_ALIGN:
                col = gr_fb_width() - length - 1;
                break;
        }
        gr_text(col, (row+1)*CHAR_HEIGHT-1, t);
    }
}
Exemplo n.º 19
0
static void
paint_dayview_appts(Calendar *c, Paint_cache *cache, int a_total, void *rect)
{
	int w = c->view->boxw;
	int h = c->view->boxh;
	int begin_time, end_time;
	int x, x2, y, y2, num_hrs, i, last_hr, hr, x_off;
	Cal_Font *pf = c->fonts->boldfont;
	Cal_Font *pf2 = c->fonts->viewfont;
	XFontSetExtents fontextents;
	XFontSetExtents fontextents2;
	Props *p = (Props*)c->properties;
	Boolean am = True;
	char buf[5], *appt_str;
	int pfy, curr_line, maxlines;
	Lines *lines = NULL, *headlines = NULL;
	DisplayType disp_t;
	Colormap cmap;
	Pixel fg;
	Tick start_tick, end_tick;
	int	nop, hrbox_margin;

	CalFontExtents(pf, &fontextents);
	CalFontExtents(pf2, &fontextents2);


	XtVaGetValues(c->canvas, XmNcolormap, &cmap, XmNforeground, &fg, NULL);

	/* draw horizontal lines */
	begin_time = get_int_prop(p, CP_DAYBEGIN);
	end_time = get_int_prop(p, CP_DAYEND);
	disp_t = get_int_prop(p, CP_DEFAULTDISP);
	num_hrs = end_time - begin_time + 1;

	if (disp_t == HOUR12)
		CalTextExtents(pf, "12pm", 4, &nop, &nop, &hrbox_margin, &nop);
	else
		CalTextExtents(pf, "24 ", 3, &nop, &nop, &hrbox_margin, &nop);

	x = MOBOX_AREA_WIDTH+2;
	x2 = x + w;
	y = c->view->topoffset;
	for (i = 0; i <= num_hrs; i++) {
		gr_draw_line(c->xcontext, x, y, x2, y, gr_solid, rect);
		y += h;
	}
	/* draw vertical line */
	y = c->view->topoffset;
	y2 = y + num_hrs * h;
	x += hrbox_margin;
	gr_draw_line(c->xcontext, x, y, x, y2, gr_solid, rect);

	x = MOBOX_AREA_WIDTH+3;
	y += h/2+4;

	/* draw in hours */
	for (i = begin_time - 1; i < end_time; i++) {
		hr = i;
		if (i < begin_time)
			(void) sprintf(buf, "");
		else if (disp_t == HOUR12) {
			am = adjust_hour(&hr);
			(void) sprintf(buf, "%d%s", hr, am ? "a" : "p");
		}
		else
			(void) sprintf(buf, "%02d", hr);
		x_off = gr_center(hrbox_margin, buf, pf); 

/* REVISIT: unclear why we're still distinguishing between gr_text[_rgb]
		if (c->xcontext->screen_depth >= 8) 
			gr_text_rgb(c->xcontext, x+x_off, y, pf,
				buf, fg, cmap, rect);
		else
*/
			gr_text(c->xcontext, x+x_off, y, pf, buf, rect);

		y += h;
	}

	/* draw in appointments */

	x = MOBOX_AREA_WIDTH + hrbox_margin + 6;
	pfy = fontextents2.max_logical_extent.height;

	maxlines = (h - 6) / pfy;
	curr_line = last_hr = 0;

	/* loop thru, getting out the "no time" appointments */

        for (i = 0; i < a_total; i++) {
		if (i != a_total)
			last_hr = hr;
		hr = begin_time;
		if (cache[i].show_time == 0) {
			if (last_hr != hr) curr_line = 0;
			y = c->view->topoffset + 2 + pfy;
			if (curr_line < maxlines) {
				y += (curr_line * pfy) + h * (hr - begin_time);
				headlines = lines = text_to_lines(cache[i].summary, 4);

				start_tick = cache[i].start_time;
				end_tick = cache[i].end_time;
				if (lines != NULL && lines->s != NULL) { 
					appt_str = ckalloc(cm_strlen(lines->s)+18);
					format_line(start_tick, lines->s, 
						appt_str, end_tick, 
						cache[i].show_time, disp_t);
					lines = lines->next;
				}
				else {
					appt_str = ckalloc(15);
					format_line(start_tick, (char*)NULL, 
						appt_str, end_tick, 
						cache[i].show_time, disp_t);
				}
				appt_str[cm_strlen(appt_str)]=NULL;

/* REVISIT: unclear why we're still distinguishing between gr_text[_rgb]
				if (c->xcontext->screen_depth >= 8) 
					gr_text_rgb(c->xcontext, x, y,
					   pf2, appt_str, fg, cmap, rect);
				else
*/
					gr_text(c->xcontext, x, y,
					   pf2, appt_str, rect);

				free(appt_str); appt_str = NULL;
				curr_line++;
				if (curr_line < maxlines && lines != NULL) {
				 	appt_str = ckalloc(324);
					cm_strcpy(appt_str, "    ");
					while (lines != NULL) { 
						if (lines->s != NULL) 
							cm_strcat(appt_str, lines->s);
						lines = lines->next;
						if (lines != NULL && lines->s != NULL)
							cm_strcat(appt_str, " - ");
					}
					y += pfy;

/* REVISIT: unclear why we're still distinguishing between gr_text[_rgb]

					if (c->xcontext->screen_depth >= 8) 
						gr_text_rgb(c->xcontext, x, y,
						   pf2, appt_str, fg,
						   cmap, rect);
					else
*/
						gr_text(c->xcontext, x, y,
						   pf2, appt_str, rect);

					curr_line++;
					free(appt_str); appt_str = NULL;
				}
				destroy_lines(headlines); lines=NULL;
			}
		}
	}

        for (i = 0; i < a_total; i++) {
		if (i != a_total)
			last_hr = hr;

		start_tick = cache[i].start_time;
		end_tick = cache[i].end_time;
		hr = hour(start_tick);
		if (hr >= begin_time && hr < end_time && (cache[i].show_time && !magic_time(start_tick))) {
			if (last_hr != hr) curr_line = 0;
			y = c->view->topoffset + 2 + pfy;
			if (curr_line < maxlines) {
				y += (curr_line * pfy) + h * (hr - begin_time + 1);
				headlines = lines = text_to_lines(cache[i].summary, 4);
				if (lines != NULL && lines->s != NULL) { 
					appt_str = ckalloc(cm_strlen(lines->s)+18);
					format_line(start_tick, lines->s, 
						appt_str, end_tick, 
						cache[i].show_time, disp_t);
					lines = lines->next;
				}
				else {
					appt_str = ckalloc(15);
					format_line(start_tick, (char*)NULL, 
						appt_str, end_tick, 
						cache[i].show_time, disp_t);
				}
				appt_str[cm_strlen(appt_str)]=NULL;

/* REVISIT: unclear why we're still distinguishing between gr_text[_rgb]
				if (c->xcontext->screen_depth >= 8) 
					gr_text_rgb(c->xcontext, x, y,
					   pf2, appt_str, fg, cmap, rect);
				else
*/
					gr_text(c->xcontext, x, y,
					   pf2, appt_str, rect);

				free(appt_str); appt_str = NULL;
				curr_line++;
				if (curr_line < maxlines && lines != NULL) {
				 	appt_str = ckalloc(324);
					cm_strcpy(appt_str, "    ");
					while (lines != NULL) { 
						if (lines->s != NULL) 
							cm_strcat(appt_str, lines->s);
						lines = lines->next;
						if (lines != NULL && lines->s != NULL)
							cm_strcat(appt_str, " - ");
					}
					y += pfy;

/* REVISIT: unclear why we're still distinguishing between gr_text[_rgb]

					if (c->xcontext->screen_depth >= 8) 
						gr_text_rgb(c->xcontext, x, y,
						   pf2, appt_str, fg,
						   cmap, rect);
					else 
*/
						gr_text(c->xcontext, x, y,
						   pf2, appt_str, rect);

					curr_line++;
					free(appt_str); appt_str = NULL;
				}
				destroy_lines(headlines); lines=NULL;
			}
		}
	}
}
Exemplo n.º 20
0
static void draw_text_line(int row, const char* t) {
  if (t[0] != '\0') {
    gr_text(0, (row+1)*CHAR_HEIGHT-1, t);
  }
}
void ScreenRecoveryUI::DrawTextLine(int* y, const char* line, bool bold) {
    gr_text(4, *y, line, bold);
    *y += char_height + 4;
}
Exemplo n.º 22
0
void ScreenRecoveryUI::draw_text_line(int row, const char* t) {
  if (t[0] != '\0') {
    gr_text(0, (row+1)*CHAR_HEIGHT-1, t);
  }
}
Exemplo n.º 23
0
void ui_text(int x, int y, char *str) {
    pthread_mutex_lock(&gUpdateMutex);
    gr_text(x,y,str);
    pthread_mutex_unlock(&gUpdateMutex);
}
Exemplo n.º 24
0
static void draw_text_line(int row, const char* t) {
  if (t[0] != '\0') {
    if (ui_get_rainbow_mode()) ui_rainbow_mode();
    gr_text(0, (row+1)*CHAR_HEIGHT-1, t);
  }
}
Exemplo n.º 25
0
ex_format()
{
#if DISKFLAG
	register int trackno,i,driveno,nsides;
	int error,saveMP;
	char progress[80],trackstr[3];

	if (do_dial(fmtaddr,-1,0L) == CANFMT) return;
	if (midiplexer) saveMP=MPoff();

/* drive A (0) or B (1) ? */
	driveno= whichbutton(fmtaddr,DRIVEA,2);
/* single (0) or double (1) sided ? */
	nsides= whichbutton(fmtaddr,SIDE1,2);

	graf_mouse(BEE_MOUSE);
	
/* format 80 tracks, 9 sectors per track, 1 or 2 sides, drive A or B,
	abort on any error */
	trackno= 0;
	copy_words(scrbase,cnxscrsave,800L);	/* save progress display area */
	set_words(scrbase,800L,0);
	do
	{
		strcpy(progress,FMT_MSG);
		itoa(trackno,trackstr,2);
		strcat(progress,trackstr);
		strcat(progress,FMT2_MSG);
		gr_text(progress,40-strlen(progress)/2,1);			/* centered */
		for (i=error=0; !error&&(i<=nsides); i++)
			if (Flopfmt(scrsave,0L,driveno,9,trackno,i,1,0x87654321L,0xe5e5))
				error=1;
		if (getmouse(&dummy,&dummy)) error=2; /* abort on mouse button */
	}
	while ( ((++trackno)<80) && !error);
	copy_words(cnxscrsave,scrbase,800L);	/* restore progress display area */

	if (!error)
	{
		set_words(scrsave,4608L,0);
		if (Flopwr(scrsave,0L,driveno,1,0,0,9)) error=1;    /* zero the FAT */
		if (!error)
		{
			if (Flopwr(scrsave,0L,driveno,1,1,0,9)) error=1;
			if (!error)
			{
				Protobt(scrsave,0x01000000,2+nsides,0);   /* write a boot sector */
				if (Flopwr(scrsave,0L,driveno,1,0,0,1)) error=1;
			}
		}
	}

	waitmouse();	/* in case formatting was aborted via mouse */
	graf_mouse(ARROWMOUSE);
	if (!error) make_tone();					/* no error */
	if (error==1) form_alert(1,BADFMT);		/* error */
	if (error==2) form_alert(1,BADFMT2);	/* aborted */
	if (midiplexer&&saveMP) MPon();

#endif
}	/* end ex_format() */
Exemplo n.º 26
0
static void
draw_chart(Calendar *c, register Week *w, XRectangle *rect)
{
    register int    x, y;
    int     n;
    XFontSetExtents fontextents;
    int 	char_height;
    char    label[5];
    new_XContext *xc = c->xcontext;
    Props *p = (Props*)c->properties;
    DisplayType dt = get_int_prop(p, CP_DEFAULTDISP);

    CalFontExtents(w->font, &fontextents);
    char_height = fontextents.max_logical_extent.height;

    /*
     * Draw chart. We first draw all the lines, then the labels
     * so that Xlib can batch the lines into 1 X request
     */

    /* Draw horizontal lines for time */
    x = w->chart_x;
    y = w->chart_y;
    for (n = w->begin_hour; n <= w->end_hour; n++) {
        gr_draw_line(xc, x, y, x + w->chart_width, y, gr_solid, rect);
        y += w->chart_hour_height + w->add_pixels;
    }

    /* Draw vertical lines for days */
    y = w->chart_y;
    for (n = 0; n < 7; n++) {
        gr_draw_line(xc, w->chart_x + (w->chart_day_width * n),
                     y, w->chart_x + (w->chart_day_width * n),
                     y + w->chart_height, gr_solid, rect);
    }

    /*
     * Draw box around the whole thing.
     */
    gr_draw_box(xc, w->chart_x, w->chart_y, w->chart_width,
                w->chart_height, rect);
    gr_draw_box(xc, w->chart_x - 1, w->chart_y - 1,
                w->chart_width + 2, w->chart_height + 2, rect);
    /* Label horizontal lines with time of day */
    x = w->chart_x;
    y = w->chart_y;
    for (n = w->begin_hour; n <= w->end_hour; n++) {
        if (dt == HOUR12)
            sprintf(label, "%2d", n > 12 ? n - 12 : n);
        else
            sprintf(label, "%2d", n);
        gr_text(xc, w->x - 8, y+3,
                w->small_bold_font, label, rect);
        y += w->chart_hour_height + w->add_pixels;
    }

    /* Label  vertical lines with day labels */
    y = w->chart_y;
    for (n = 0; n < 7; n++) {
        x = gr_center(w->chart_day_width, days3[n+1], w->font);
        gr_text(xc, w->chart_x + (w->chart_day_width * n) + x,
                y - char_height / 2, w->font, days3[n+1], rect);
    }

}
Exemplo n.º 27
0
static int wifi_test_start(TestCase* thiz)
{
	DECLES_PRIV(priv, thiz);

	LOGE("%s: start wifi test...", __func__);
	FILE* fd;
	int cell_num = 0;
	char buffer[1024];
	char* ptr = NULL;
	struct wifi_cell cell;
	int start_y = 50;
	char cell_info[148];

	wifi_test(1);

	gr_color(0, 0, 0, 255);
	ui_draw_title(gr_fb_height()/2, WIFI_WAIT_PROMPT);

	fd = fopen("/data/wifi_test.txt", "r");
	if (fd == NULL) {
		LOGE("%s: open /data/wifi_test.txt fail", __func__);
		goto out;
	}

	gr_color(0, 255, 255, 255);

	do {
		char* tmp = NULL;
		ptr = fgets(buffer, 1024, fd);
		if (ptr == NULL)
			break;

		tmp = strstr(ptr, ADDRESS_WIFI);
		if (tmp != NULL) {
			tmp += strlen(ADDRESS_WIFI) + 1;
			memset(cell.address, 0, sizeof(cell.address));
			strncpy(cell.address, tmp, strlen(tmp) - 1);
		}

		tmp = strstr(ptr, ESSID_WIFI);
		if (tmp != NULL) {
			char* m;
			tmp += strlen(ESSID_WIFI) + 1;
			m = strchr(tmp, '"');
			memset(cell.ssid, 0, sizeof(cell.ssid));
			strncpy(cell.ssid, tmp, m - tmp);
			memset(cell_info, 0, sizeof(cell_info));
			sprintf(cell_info, "%s (%s)", cell.ssid, cell.address);
			gr_text(10, start_y, cell_info);
			start_y += CHAR_HEIGHT;
			cell_num ++;
		}

	} while(1);

	fclose(fd);
out:
	wifi_test(0);

	priv->passed = cell_num > 0 ? 1 : 0;

	if (priv->passed) {
		return 0;
	} else {
		return -1;
	}
}
Exemplo n.º 28
0
static void
draw_week(Calendar *c, XRectangle *rect, Boundary boundary)
{
    Week *w = (Week *)c->view->week_info;
    register int    current_day;
    register int    n;
    register int    x, y;
    int             char_height;
    int             start_date;
    char            **day_names;
    char            label[80];
    char		buf[MAXNAMELEN];
    char		*footer_message = NULL;
    int             start_ind, end_ind;
    int             today_dom, day_om;
    new_XContext        *xc;
    Props           *p = (Props*)c->properties;
    XRectangle      chartrect;
    OrderingType	ot = get_int_prop(p, CP_DATEORDERING);
    Tick		start_tick, end_tick;
    time_t start, stop;
    CSA_return_code stat;
    CSA_entry_handle *list;
    CSA_attribute *range_attrs;
    CSA_enum *ops;
    CSA_uint32 a_total;
    int i, lower_bound = 0, upper_bound = 0;
    XFontSetExtents regfontextents, boldfontextents;
    int	notused, width1, width2, width3;

    CalFontExtents(w->font, &regfontextents);
    char_height = regfontextents.max_logical_extent.height;
    start_date      = w->start_date;
    xc              = c->xcontext;

    start = (time_t) lowerbound(start_date);
    stop = (time_t) next_ndays(start, 7) - 1;

    if (c->paint_cache == NULL) {
        setup_range(&range_attrs, &ops, &i, start, stop, CSA_TYPE_EVENT,
                    0, B_FALSE, c->general->version);
        csa_list_entries(c->cal_handle, i, range_attrs, ops,
                         &a_total, &list, NULL);
        free_range(&range_attrs, &ops, i);
        allocate_paint_cache(list, a_total, &c->paint_cache);
        c->paint_cache_size = a_total;
        csa_free(list);
    }


    gr_clear_box(xc, 0, 0, w->canvas_w, w->canvas_h);

    CalTextExtents(w->font, days2[3], cm_strlen(days2[3]),
                   &notused, &notused, &width1, &notused);
    CalTextExtents(w->font, "  00", cm_strlen("  00"),
                   &notused, &notused, &width2, &notused);
    CalTextExtents(w->font, "Wed 00", cm_strlen("Wed 00"),
                   &notused, &notused, &width3, &notused);
    if (width1 + width2 <= w->day_width - 2)
        day_names = days2;
    else if (width3 <= w->day_width - 2)
        day_names = days;
    else
        day_names = days3;
    x = w->x;
    y = w->y;

    format_week_header(start_date, ot, label);
    gr_text(xc, x, y - char_height / 2, w->font, label, rect);

    /*
     * Draw bold box around first 5 days
     */
    gr_draw_box(xc, x, y, w->width, w->day_height, rect);
    gr_draw_box(xc, x - 1, y - 1, w->width + 2, w->day_height + 2, rect);
    gr_draw_line(xc, x, y + w->label_height, x + w->width,
                 y + w->label_height, gr_solid, rect);

    /*
     * Draw bold box around last 2 days
     */
    x += 3 * w->day_width;
    y += w->day_height;

    gr_draw_box(xc, x, y, 2 * w->day_width, w->day_height, rect);
    gr_draw_box(xc, x - 1, y, 2 * w->day_width + 2, w->day_height + 1,rect);
    gr_draw_line(xc, x, y + w->label_height, x + 2 * w->day_width,
                 y + w->label_height, gr_solid, rect);
    y = w->y;
    x = w->x + w->day_width;
    for (n = 0; n < 4; n++) {
        if (n < 3) {
            gr_draw_line(xc, x, y, x, y + w->day_height,
                         gr_solid, rect);
        } else {
            gr_draw_line(xc, x, y, x, y + 2 * w->day_height,
                         gr_solid, rect);
        }
        x += w->day_width;
    }
    /*
      * Fill in week with appointments
      */
    x = w->x;
    y = w->y;
    current_day = start_date;
    today_dom = dom(time(0));

    /* Crock alert!!!!  The obscure code below is doing something
       really nasty.  The variable boundary indicates whether the
       week being displayed falls across a boundary with the
       beginning or the end of time.  In the case of the beginning
       of time, the code then assumes that the first 2 days in the
       week need to be unbuttoned, and the rest buttoned and painted.
       Likewise, with the end of time case, the code assumes the last
       3 days of the week need similar treatment. */

    for (n = 0; n < 7; n++)  {

        if (n == 5) {
            y += w->day_height;
            x = w->x + 3 * w->day_width;
        }

        if (boundary == okay) {
            day_om = dom(current_day);
            display_hot_btn(c, n, day_om);
            fill_day(c, w, x, y, current_day,
                     c->paint_cache, c->paint_cache_size, rect);
            current_day += daysec;
            if (lower_bound > 0) {
                sprintf(buf, "%s", catgets(c->DT_catd, 1, 623, "Calendar does not display dates prior to January 1, 1970"));
                footer_message = buf;
            }
            else
                footer_message = NULL;
        }
        else if (boundary == lower) {
            /* skip days before Jan 1, 1970 */
            clear_hot_btn(c, n);
            if (lower_bound++ == 2)
                boundary = okay;
        }
        else if (boundary == upper) {
            day_om = dom(current_day);
            if (++upper_bound <= 4)
                display_hot_btn(c, n, day_om);
            fill_day(c, w, x, y, current_day,
                     c->paint_cache, c->paint_cache_size, rect);
            current_day += daysec;
            sprintf(buf, "%s", catgets(c->DT_catd, 1, 624, "Calendar does not display dates after December 31, 2037"));
            footer_message = buf;
            if (upper_bound > 4)
                clear_hot_btn(c, n);
        }
        x += w->day_width;
    }
    if (rect != NULL) {
        CalFontExtents(w->small_bold_font, &boldfontextents);

        chartrect.x = w->x;
        chartrect.y = w->chart_y - w->label_height;
        chartrect.width = w->chart_width +
                          3*boldfontextents.max_logical_extent.width;
        chartrect.height = w->chart_height + 2*w->label_height;
    }

    if (rect == NULL || myrect_intersectsrect(rect,  &chartrect)) {
        for (i = 0; i < c->paint_cache_size; i++) {
            start_tick = (c->paint_cache)[i].start_time;
            end_tick = (c->paint_cache)[i].end_time;
            cm_update_segs(w, start_tick,
                           (end_tick ? (end_tick - start_tick) : 0),
                           &start_ind, &end_ind, True);
        }
        chart_draw_appts(w, 0, w->segs_in_array);
        draw_chart(c, w, NULL);
    }

    /* do not repaint the footer message in a damage display.
       For some reason this causes the damage routine to get called
       again, resulting in a recursive dsaster. */

    if (footer_message && !rect)
        set_message(c->message_text, footer_message);
}