int BC_ProgressBar::draw(int force, int flush)
{
	char string[32];
	int new_pixel;

	new_pixel = (int)(((float)position / length) * get_w());

	if(new_pixel != pixel || force)
	{
		pixel = new_pixel;
// Clear background
		draw_top_background(parent_window, 0, 0, get_w(), get_h());
		draw_3segmenth(0, 0, pixel, 0, get_w(), images[PROGRESS_HI]);
		draw_3segmenth(pixel, 0, get_w() - pixel, 0, get_w(), images[PROGRESS_UP]);


		if(do_text)
		{
			set_font(MEDIUMFONT);
			set_color(get_resources()->progress_text);     // draw decimal percentage
			sprintf(string, "%d%%", (int)(100 * (float)position / length + 0.5 / w));
			draw_center_text(w / 2, h / 2 + get_text_ascent(MEDIUMFONT) / 2, string);
		}
		flash(flush);
	}
	return 0;
}
示例#2
0
int BC_Title::draw(int flush)
{
	int i, j, x, y;

// Fix background for block fonts.
// This should eventually be included in a BC_WindowBase::is_blocked_font()

 	if(font == MEDIUM_7SEGMENT)
 	{
		//leave it up to the theme to decide if we need a background or not.
		if (top_level->get_resources()->draw_clock_background) {
			BC_WindowBase::set_color(get_bg_color());
			draw_box(0, 0, w, h);
		}
 	}
	else
 		draw_top_background(parent_window, 0, 0, w, h);

	set_font(font);
	BC_WindowBase::set_color(color);
	int text_len = strlen(text);
	j = 0;  x = 0;  y = get_text_ascent(font);
	for(i = 0; i <= text_len; i++)
	{
		if(text[i] == '\n' || text[i] == 0)
		{
			if(centered)
			{
				draw_center_text(get_w() / 2,
					y,
					&text[j],
					i - j);
				j = i + 1;
			}
			else
			{
				draw_text(x,
					y,
					&text[j],
					i - j);
				j = i + 1;
			}
			y += get_text_height(font);
		}
	}
	set_font(MEDIUMFONT);    // reset
	flash(flush);
	return 0;
}
示例#3
0
void ScopeGUI::draw_overlays(int overlays, int borders, int flush)
{
	if(overlays && borders)
	{
		clear_box(0, 0, get_w(), get_h());
	}

	if(overlays)
	{
		set_line_dashes(1);
		set_color(GREEN);
		set_font(SMALLFONT);

		if(histogram && (use_hist || use_hist_parade))
		{
			histogram->draw_line(hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN), 
					0, 
					hist_w * -FLOAT_MIN / (FLOAT_MAX - FLOAT_MIN), 
					hist_h);
			histogram->draw_line(hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN), 
					0, 
					hist_w * (1.0 - FLOAT_MIN) / (FLOAT_MAX - FLOAT_MIN), 
					hist_h);
			set_line_dashes(0);
			histogram->draw_point();
			set_line_dashes(1);
			histogram->flash(0);
		}

// Waveform overlay
		if(waveform && (use_wave || use_wave_parade))
		{
			set_color(GREEN);
			for(int i = 0; i <= WAVEFORM_DIVISIONS; i++)
			{
				int y = wave_h * i / WAVEFORM_DIVISIONS;
				int text_y = y + wave_y + get_text_ascent(SMALLFONT) / 2;
				CLAMP(text_y, waveform->get_y() + get_text_ascent(SMALLFONT), waveform->get_y() + waveform->get_h() - 1);
				int x = wave_x - 20;
				char string[BCTEXTLEN];
				sprintf(string, "%d", 
					(int)((FLOAT_MAX - 
					i * (FLOAT_MAX - FLOAT_MIN) / WAVEFORM_DIVISIONS) * 100));
				draw_text(x, text_y, string);

				int y1 = CLAMP(y, 0, waveform->get_h() - 1);
				waveform->draw_line(0, y1, wave_w, y1);
				//waveform->draw_rectangle(0, 0, wave_w, wave_h);
			}
			set_line_dashes(0);
			waveform->draw_point();
			set_line_dashes(1);
			waveform->flash(0);
		}


// Vectorscope overlay
		if(vectorscope && use_vector)
		{
			set_color(GREEN);
			int radius = MIN(vector_w / 2, vector_h / 2);
			for(int i = 1; i <= VECTORSCOPE_DIVISIONS; i += 2)
			{
				int x = vector_w / 2 - radius * i / VECTORSCOPE_DIVISIONS;
				int y = vector_h / 2 - radius * i / VECTORSCOPE_DIVISIONS;
				int text_x = vector_x - 20;
				int text_y = y + vector_y + get_text_ascent(SMALLFONT) / 2;
				int w = radius * i / VECTORSCOPE_DIVISIONS * 2;
				int h = radius * i / VECTORSCOPE_DIVISIONS * 2;
				char string[BCTEXTLEN];

				sprintf(string, "%d", 
					(int)((FLOAT_MAX / VECTORSCOPE_DIVISIONS * i) * 100));
				draw_text(text_x, text_y, string);
//printf("ScopeGUI::draw_overlays %d %d %d %s\n", __LINE__, text_x, text_y, string);
				
				vectorscope->draw_circle(x, y, w, h);
		//vectorscope->draw_rectangle(0, 0, vector_w, vector_h);
			}
		// 	vectorscope->draw_circle(vector_w / 2 - radius, 
		// 		vector_h / 2 - radius, 
		// 		radius * 2, 
		// 		radius * 2);

			set_line_dashes(0);
			vectorscope->draw_point();
			set_line_dashes(1);
			vectorscope->flash(0);
		}

		set_font(MEDIUMFONT);
		set_line_dashes(0);
	}

	if(borders)
	{
		if(use_hist || use_hist_parade)
		{
			draw_3d_border(hist_x - 2, 
				hist_y - 2, 
				hist_w + 4, 
				hist_h + 4, 
				get_bg_color(),
				BLACK,
				MDGREY, 
				get_bg_color());
		}

		if(use_wave || use_wave_parade)
		{
			draw_3d_border(wave_x - 2, 
				wave_y - 2, 
				wave_w + 4, 
				wave_h + 4, 
				get_bg_color(),
				BLACK,
				MDGREY, 
				get_bg_color());
		}

		if(use_vector)
		{
			draw_3d_border(vector_x - 2, 
				vector_y - 2, 
				vector_w + 4, 
				vector_h + 4, 
				get_bg_color(),
				BLACK,
				MDGREY, 
				get_bg_color());
		}
	}

	flash(0);
	if(flush) this->flush();
}
示例#4
0
void GraphicGUI::draw_ticks()
{
	int x = canvas->get_x() - 5 - get_text_width(SMALLFONT, "-00");
	int y = canvas->get_y() - 1;
	int x1 = canvas->get_x() - LINE_W3;
	int x2 = canvas->get_x() - LINE_W2;
	int x3 = canvas->get_x() - LINE_W1;
	char string[BCTEXTLEN];

// Amplitude
	set_font(SMALLFONT);
	int major_division = canvas->get_h() / (MAJOR_DIVISIONS - 1);
	for(int i = 0; i < MAJOR_DIVISIONS; i++)
	{
		int current_db = (MAJOR_DIVISIONS - 1 - i) * (MAX_DB - MIN_DB) / (MAJOR_DIVISIONS - 1) + MIN_DB;
		if(current_db == MIN_DB)
			sprintf(string, "oo");
		else
		if(current_db <= 0.0)
			sprintf(string, "%d", current_db);
		else
			sprintf(string, "+%d", current_db);

		set_color(BLACK);
		int y1 = y + 1 + i * canvas->get_h() / (MAJOR_DIVISIONS - 1);
		int x4 = canvas->get_x() - LINE_W4 - get_text_width(SMALLFONT, string);
		draw_text(x4 + 1, y1 + get_text_ascent(SMALLFONT) / 2 + 1, string);
		draw_line(x1 + 1, y1 + 1, x3 + 1, y1 + 1);
		set_color(RED);
		draw_text(x4, y1 + get_text_ascent(SMALLFONT) / 2, string);
		draw_line(x1, y1, x3, y1);


		if(i < MAJOR_DIVISIONS - 1)
		{
			for(int j = 0; j < MINOR_DIVISIONS; j++)
			{
				int y2 = y1 + j * major_division / MINOR_DIVISIONS;
				set_color(BLACK);
				draw_line(x2 + 1, y2 + 1, x3 + 1, y2 + 1);
				set_color(RED);
				draw_line(x2, y2, x3, y2);
			}
		}
	}


// Frequency
	for(int i = 0; i <= MAJOR_DIVISIONS; i++)
	{
		int freq = Freq::tofreq(i * TOTALFREQS / MAJOR_DIVISIONS);
		char string[BCTEXTLEN];
		x1 = canvas->get_x() + i * canvas->get_w() / MAJOR_DIVISIONS;
		int y1 = canvas->get_y() + canvas->get_h() + LINE_W1 - 1;
		sprintf(string, "%d", freq);
		int x2 = x1 - get_text_width(SMALLFONT, string);
		int y2 = canvas->get_y() + canvas->get_h() + LINE_W2 - 1;
		int y3 = canvas->get_y() + canvas->get_h() + LINE_W3 - 1;
		int y4 = canvas->get_y() + canvas->get_h() + get_text_height(SMALLFONT) + LINE_W4 - 1;
		
		set_color(BLACK);
		draw_text(x2 + 1, y4 + 1, string);
		draw_line(x1 + 1, y3 + 1, x1 + 1, y1 + 1);
		
		set_color(RED);
		draw_text(x2, y4, string);
		draw_line(x1, y3, x1, y1);
		
		if(i < MAJOR_DIVISIONS)
		{
			for(int j = 0; j < MINOR_DIVISIONS; j++)
			{
				int x3 = (int)(x1 +
					(canvas->get_w() / MAJOR_DIVISIONS) -
					exp(-(double)j * 0.7) *
					(canvas->get_w() / MAJOR_DIVISIONS));
				set_color(BLACK);
				draw_line(x3 + 1, y2 + 1, x3 + 1, y1 + 1);
				set_color(RED);
				draw_line(x3, y2, x3, y1);
			}
		}
	}
}