コード例 #1
0
ファイル: Debugger.cpp プロジェクト: Michael-Z/Geometry-Wars
void CDebugger::Update(const CPlayer& Player, CBullets& Bullets, CEnemies& Enemies)
{
    static std::stringstream ss;
    static int mouse_x, mouse_y;
    static SDL_Surface* debug   = NULL;
    static SDL_Color white      = create_color(WHITE);

    if(this->IsDebug())
    {
        GetMousePosition(mouse_x, mouse_y);

        /* First, place (x, y) coordinates next to the player sprite. */
        ss << "(" << (int)Player.GetX() << ", " << (int)Player.GetY() << ")";
        debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG);
        this->Display.Blit(debug, (int)Player.GetX(), (int)Player.GetY() - get_text_height(this->debug_font, ss.str()));

        SDL_FreeSurface(debug); // Free memory
        ss.str(std::string());

        /* Then, place (x, y) coordinates next to the mouse. */
        ss << "(" << mouse_x << ", " << mouse_y << ")";
        debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG);
        this->Display.Blit(debug, mouse_x, mouse_y - get_text_height(this->debug_font, ss.str()));

        SDL_FreeSurface(debug); // Free memory
        ss.str(std::string());

        /* Every bullet also gets (x, y) info next to it. */
        for(CBullets::iterator i = Bullets.begin(); i != Bullets.end(); i++)
        {
            ss << "(" << (int)(*i)->GetX() << ", " << (int)(*i)->GetY() << ")";
            debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG);
            this->Display.Blit(debug, (int)(*i)->GetX(), (int)(*i)->GetY() - get_text_height(this->debug_font, ss.str()));

            SDL_FreeSurface(debug); // Free memory
            ss.str(std::string());
        }

        ss.str(std::string());

        /* And finally, every enemy gets (x, y) as well. */
        for(CEnemies::iterator i = Enemies.begin(); i != Enemies.end(); i++)
        {
            ss << "(" << (int)(*i)->GetX() << ", " << (int)(*i)->GetY() << ")";
            debug = render_text(this->debug_font, ss.str(), NULL, white, CREATE_SURFACE | TRANSPARENT_BG);
            this->Display.Blit(debug, (int)(*i)->GetX(), (int)(*i)->GetY() - get_text_height(this->debug_font, ss.str()));

            SDL_FreeSurface(debug);
            ss.str(std::string());
        }
    }
}
コード例 #2
0
ファイル: GTK_visual.c プロジェクト: dieface/radium-1
void setFontValues(struct Tracker_Windows *window){
  double width3 = R_MAX(get_text_width("D#6"), R_MAX(get_text_width("MUL"), get_text_width("STP")));
  window->fontwidth      = (int)ceil(width3/3.0);
  window->fontheight     = get_text_height("D#6");
  //window->fontheight     = pango_font_description_get_size(font_description)/PANGO_SCALE;
  window->org_fontheight = window->fontheight;
}
コード例 #3
0
ファイル: pebblerss2.c プロジェクト: SheepWillPrevail/pebble
void setup_message_layer() {
	int header_height = get_header_height();
	int text_height = get_text_height();
	setup_header(header_height);
	layer_set_frame(text_layer_get_layer(messagetext_layer), GRect(0, header_height, 144, text_height));
	scroll_layer_set_content_offset(message_layer, GPoint(0, 0), false);
	scroll_layer_set_content_size(message_layer, GSize(144, header_height + text_height));
	layer_set_hidden(scroll_layer_get_layer(message_layer), false);
}
コード例 #4
0
void GraphicGUI::create_objects()
{
	int margin = plugin->get_theme()->widget_border;
	int x = get_text_width(SMALLFONT, "-00") + LINE_W4 + margin;
	int y = margin;
	int freq_h = get_text_height(SMALLFONT) + LINE_W4;

	add_subwindow(canvas = new GraphicCanvas(plugin,
		this,
		x, 
		y, 
		get_w() - x - margin, 
		get_h() - 
//			BC_Pot::calculate_h() - 
			BC_TextBox::calculate_h(this, MEDIUMFONT, 1, 1) -
			margin * 3 - 
			y - 
			freq_h));
	y += canvas->get_h() + freq_h + margin;

	int x1 = x;
	int y1 = y;
	add_subwindow(freq_title = new BC_Title(x, y, "Frequency:"));
	x += freq_title->get_w() + margin;
	add_subwindow(freq_text = new FreqTextBox(plugin, this, x, y, 100));
	x += freq_text->get_w() + margin;

	add_subwindow(level_title = new BC_Title(x, y, "Level:"));
	x += level_title->get_w() + margin;
	add_subwindow(value_text = new ValueTextBox(plugin, this, x, y, 100));
	x += value_text->get_w() + margin;

	add_subwindow(reset = new GraphicReset(plugin, this, x, y));
	x += reset->get_w() + margin;
	

//	x = x1;
//	y += value_text->get_h() + margin;

	add_subwindow(size_title = new BC_Title(x, y, "Window size:"));
	x += size_title->get_w() + margin;
	add_subwindow(size = new GraphicSize(this, plugin, x, y));
	size->create_objects();
	size->update(plugin->config.window_size);
	x += size->get_w() + margin;

//	add_subwindow(title = new BC_Title(x, y, "Wetness:"));
//	x += title->get_w() + margin;
// 	add_subwindow(wetness = new GraphicWetness(this, plugin, 
// 		x, 
// 		y));

	draw_ticks();
	update_canvas();
	show_window();
}
コード例 #5
0
void RecordMonitorGUI::
display_video_text(int x, int y, const char *text, int font,
	int bg_color, int color, int alpha, double secs, double scale)
{
	lock_window("RecordMonitorGUI::display_text");
	set_font(font);
	int ch = get_text_height(font);
	int h = get_text_height(font,text) + ch/2;
	int w = get_text_width(font, text) + ch;
	BC_Pixmap pixmap(this, w, h);
	set_opaque();
	set_color(bg_color);
	draw_box(0, 0, w, h, &pixmap);
	set_color(color);
	draw_text(ch/2, ch, text, strlen(text), &pixmap);
	BC_Bitmap bitmap(this, w, h, BC_RGB888, 0);
	VFrame in(&bitmap, w, h, BC_RGB888, -1);
	Drawable drawable = pixmap.get_pixmap();
	bitmap.read_drawable(drawable, 0, 0, &in);
	unlock_window();
	record->display_vframe(&in, x, y, alpha, secs, scale);
}
コード例 #6
0
ファイル: bctitle.C プロジェクト: Cuchulain/cinelerra
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;
}
コード例 #7
0
ファイル: bcpan.C プロジェクト: Cuchulain/cinelerra
void BC_Pan::draw_popup()
{
	popup->draw_background(0, 0, popup->get_w(), popup->get_h());

	int x1, y1;
	float rotate_angle;
	float scale = (float)(popup->get_w() -
		get_resources()->pan_data[PAN_CHANNEL]->get_w()) /
		(virtual_r * 2);
	set_color(get_resources()->pan_text_color);
	set_font(SMALLFONT);

	for(int i = 0; i < total_values; i++)
	{
		x1 = (int)(value_x[i] * scale);
		y1 = (int)(value_y[i] * scale);
		rotate_angle = value_positions[i];
		rotate_angle = -rotate_angle;
		while(rotate_angle < 0) rotate_angle += 360;
		rotater->rotate(temp_channel,
			get_resources()->pan_data[PAN_CHANNEL],
			rotate_angle,
			0);
		BC_Pixmap *temp_pixmap = new BC_Pixmap(popup,
			temp_channel,
			PIXMAP_ALPHA);
		popup->draw_pixmap(temp_pixmap, x1, y1);
		delete temp_pixmap;

		char string[BCTEXTLEN];
		float value = values[i] + 0.005;
		sprintf(string, "%.1f", value);
		popup->draw_text(x1, y1 + get_text_height(SMALLFONT), string);
	}

	x1 = (int)(stick_x * scale);
	y1 = (int)(stick_y * scale);
	popup->draw_pixmap(images[PAN_STICK], x1, y1);
	popup->flash();
}
コード例 #8
0
ファイル: synthesizer.C プロジェクト: knutj/cinelerra
int SynthNote::draw_face(int flash, int flush)
{
	BC_Toggle::draw_face(0, 0);
	static const char *titles[] =
	{
		"C",
		"C#",
		"D",
		"D#",
		"E",
		"F",
		"F#",
		"G",
		"G#",
		"A",
		"A#",
		"B"
	};
	

	const char *text = titles[number % (sizeof(titles) / sizeof(char*))];
	char string[BCTEXTLEN];
	sprintf(string, "%s%d", text, number / 12);
//printf("SynthNote::draw_face %d %d %d %d %s\n", __LINE__, number, get_w(), get_h(), text);
	if(text[1] == '#')
	{
	}
	else
	{
		set_color(BLACK);
		draw_text(get_w() / 2 - get_text_width(MEDIUMFONT, string) / 2,
			get_h() - get_text_height(MEDIUMFONT, string) - window->synth->get_theme()->widget_border,
			string);
	}

	if(flash) this->flash(0);
	if(flush) this->flush();
	return 0;
}
コード例 #9
0
ファイル: chromakey.C プロジェクト: knutj/cinelerra
void
ChromaKeyWindow::create_objects ()
{
  int y = 10, y1, x1 = 0, x2 = 10;
  int x = 30;

  BC_Title *title;
  BC_Bar *bar;
  int ymargin = get_text_height(MEDIUMFONT) + 5;
  int ymargin2 = get_text_height(MEDIUMFONT) + 10;

  add_subwindow (title = new BC_Title (x2, y, _("Color:")));

  add_subwindow (color = new ChromaKeyColor (plugin, this, x, y + 25));

  add_subwindow (sample =
		 new BC_SubWindow (x + color->get_w () + 10, y, 100, 50));
  y += sample->get_h () + 10;

  add_subwindow (use_colorpicker =
		 new ChromaKeyUseColorPicker (plugin, this, x, y));
  y += use_colorpicker->get_h() + 10;
  add_subwindow (show_mask = new ChromaKeyShowMask (plugin, x2, y));
	y += show_mask->get_h() + 5;

	add_subwindow(bar = new BC_Bar(x2, y, get_w() - x2 * 2));
	y += bar->get_h() + 5;
	y1 = y;
  add_subwindow (new BC_Title (x2, y, _("Key parameters:")));
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Hue Tolerance:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Min. Brightness:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Max. Brightness:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Saturation Offset:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Min Saturation:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin2;

	add_subwindow(bar = new BC_Bar(x2, y, get_w() - x2 * 2));
	y += bar->get_h() + 5;
  add_subwindow (title = new BC_Title (x2, y, _("Mask tweaking:")));
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("In Slope:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Out Slope:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Alpha Offset:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin2;



	add_subwindow(bar = new BC_Bar(x2, y, get_w() - x2 * 2));
	y += bar->get_h() + 5;
  add_subwindow (title = new BC_Title (x2, y, _("Spill light control:")));
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Spill Threshold:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;
  add_subwindow (title = new BC_Title (x, y, _("Spill Compensation:")));
  if(title->get_w() > x1) x1 = title->get_w();
  y += ymargin;


	y = y1;
  y += ymargin;
	x1 += x;



  add_subwindow (tolerance = new ChromaKeyTolerance (plugin, x1, y));
  y += ymargin;
  add_subwindow (min_brightness = new ChromaKeyMinBrightness (plugin, x1, y));
  y += ymargin;
  add_subwindow (max_brightness = new ChromaKeyMaxBrightness (plugin, x1, y));
  y += ymargin;
  add_subwindow (saturation = new ChromaKeySaturation (plugin, x1, y));
  y += ymargin;
  add_subwindow (min_saturation = new ChromaKeyMinSaturation (plugin, x1, y));
  y += ymargin;

	y += bar->get_h() + 5;
  y += ymargin2;
  add_subwindow (in_slope = new ChromaKeyInSlope (plugin, x1, y));
  y += ymargin;
  add_subwindow (out_slope = new ChromaKeyOutSlope (plugin, x1, y));
  y += ymargin;
  add_subwindow (alpha_offset = new ChromaKeyAlphaOffset (plugin, x1, y));
   y += ymargin;

	y += bar->get_h() + 5;
  y += ymargin2;
  add_subwindow (spill_threshold = new ChromaKeySpillThreshold (plugin, x1, y));
  y += ymargin;
  add_subwindow (spill_amount = new ChromaKeySpillAmount (plugin, x1, y));

  color_thread = new ChromaKeyColorThread (plugin, this);

  update_sample ();
  show_window ();
}
コード例 #10
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);
			}
		}
	}
}
コード例 #11
0
ファイル: printing.cpp プロジェクト: parkovski/tsched
void
Page::printTruss(wxDC &dc, Truss *truss, int &top, int width) {
    // Make sure the height is at least 8.5ft.
    float truss_height = truss->getHeight();
    int bed_height_px = 8.5f * 12.0f * width / (60.0f * 12.0f);
    if (truss_height < 8.5f * 12.0f)
        truss_height = 8.5f * 12.0f;
    int truss_height_px = truss_height * width / (60.0f * 12.0f);
    int bed_top_px = truss_height_px - bed_height_px;
    
    // Write the title above the box (or "Untitled" if none).
    const wxString &truss_text = truss->gettext();
    if (!truss_text.empty()) {
		top += draw_ml(dc, truss_text, mleft, top, width);
    } else {
		top += draw_ml(dc, wxT("Untitled"), mleft, top, width);
    }
    
    int empty_line_height = get_text_height(dc, wxT("X"));
    
    // If there are any notes, write them too (after a half-line break).
    const wxString &truss_notes = truss->getnotes();
    if (!truss_notes.empty()) {
        top += empty_line_height / 2;
        top += draw_ml(dc, truss_notes, mleft, top, width);
    }
    
    truss->draw(dc, mleft, top, width + mleft, top + truss_height_px);
    
    // Draw the truck bed, which is always 8.5ft.
    wxPoint lines[] = {
        wxPoint(mleft, top + bed_top_px),
            wxPoint(width + mleft, top + bed_top_px),
        wxPoint(mleft, top + bed_top_px), wxPoint(mleft, top + truss_height_px),
        wxPoint(mleft, top + truss_height_px),
            wxPoint(width + mleft, top + truss_height_px),
        wxPoint(width + mleft, top + bed_top_px),
            wxPoint(width + mleft, top + truss_height_px)
    };
    dc.DrawLines(8, lines);
        
    int tick_mark_height = empty_line_height * 0.8;

    float two_feet = width / 30.0f;
    float ten_feet = two_feet * 5;
    
    for (float x1 = mleft; x1 < width + mleft - 1; x1 += ten_feet) {
        dc.DrawLine((wxCoord)x1, top + bed_top_px,
            (wxCoord)x1, top + truss_height_px);
    
        float x2 = x1 + two_feet;
        for (unsigned nr = 0; nr < 4; ++nr, x2 += two_feet) {
            dc.DrawLine((wxCoord)x2, top + bed_top_px,
                (wxCoord)x2, top + bed_top_px + tick_mark_height);
            dc.DrawLine((wxCoord)x2, top + truss_height_px - tick_mark_height,
                (wxCoord)x2, top + truss_height_px);
        }
    }
    
	truss->drawGuides(dc, mleft, top, width + mleft, top + truss_height_px);
    
    // This section comes from bedview.cpp but is modified for the printout.
    int flags = truss->get();
    if (flags) {
        // Find the widths and heights of each message to be displayed.
        wxCoord full_width = 0, full_height = 0;
        wxCoord os_width = 0, os_height = 0;
        wxCoord vos_width = 0, vos_height = 0;
        wxCoord overall_width, overall_height;
        int excl_img_width, excl_img_height;
        
        excl_img_width = excl_icon->GetWidth();
        excl_img_height = excl_icon->GetHeight();
        
        if (flags & Truss::kFull)
            dc.GetTextExtent(wxT(">> FULL TRUCK <<"),
                &full_width, &full_height);
        if (flags & Truss::kOversize)
            dc.GetTextExtent(wxT(">> OVERSIZE LOAD <<"),
                &os_width, &os_height);
        if (flags & Truss::kVeryOversize)
            dc.GetTextExtent(
                wxT(">> SPECIAL PERMIT REQ'D <<"),
                &vos_width, &vos_height);
        
        overall_width = full_width;
        if (os_width > overall_width)
            overall_width = os_width;
        if (vos_width > overall_width)
            overall_width = vos_width;
        
        overall_height = full_height + os_height + vos_height;
        
        wxCoord left_pt = mleft + width - overall_width - 3;
        wxCoord top_pt = top + bed_top_px +
            (truss_height_px - bed_top_px - overall_height) / 2;
        
        // If there is enough room, center the messages in the non-used part.
        unsigned truss_right_ext = (truss->getWidth() + 6) * two_feet / 24.0f;
        if (truss_right_ext < left_pt)
            left_pt = truss_right_ext + (width - truss_right_ext) / 2
                - overall_width / 2;
        
        //dc.DrawBitmap(*excl_icon,
        //    left_pt + overall_width / 2 - excl_img_width / 2, top_pt);
        //top_pt += excl_img_height;
        if (flags & Truss::kFull) {
            dc.DrawText(wxT(">> FULL TRUCK <<"),
                left_pt + overall_width / 2 - full_width / 2, top_pt);
            top_pt += full_height;
        }
        if (flags & Truss::kOversize) {
            dc.DrawText(wxT(">> OVERSIZE LOAD <<"),
                left_pt + overall_width / 2 - os_width / 2, top_pt);
            top_pt += os_height;
        }
        if (flags & Truss::kVeryOversize) {
            dc.DrawText(wxT(">> SPECIAL PERMIT REQ'D <<"),
                left_pt + overall_width / 2 - vos_width / 2, top_pt);
        }
    }
    
    top += truss_height_px;
    
    // Use "triple spacing" as padding between trusses.
    top += empty_line_height * 3;
}
コード例 #12
0
ファイル: printing.cpp プロジェクト: parkovski/tsched
void
TrussPrintout::OnPreparePrinting() {
    int page_width, page_height;
    int current_page_y = 0;
    GetPageSizePixels(&page_width, &page_height);
    wxDC *dc = GetDC();
    
    int printer_x, printer_y, screen_x, screen_y;
    GetPPIPrinter(&printer_x, &printer_y);
    GetPPIScreen(&screen_x, &screen_y);
    float scale = printer_x / (float)screen_x;
    
    // Use a 12pt font. For some reason wxFont doesn't use real points, so
    // we still have to scale it.
    wxFont &font = *wxTheFontList->FindOrCreateFont(
        12 * scale, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL,
        wxFONTWEIGHT_NORMAL
    );
    dc->SetFont(font);
    
    // Margins:
    int ml, mt, mr, mb;
    int widthmm, heightmm;
    GetPageSizeMM(&widthmm, &heightmm);
    double one_mm_px = page_width / (double)widthmm;
    
    wxPoint margintl = page_setup_dialog_data->GetMarginTopLeft();
    wxPoint marginbr = page_setup_dialog_data->GetMarginBottomRight();
    
    ml = margintl.x * one_mm_px;
    mt = margintl.y * one_mm_px;
    mr = marginbr.x * one_mm_px;
    mb = marginbr.y * one_mm_px;
        
    page_height -= mt + mb;
    page_width -= ml + mr;
    
    for (int i = 0; i < printitems.size(); ++i) {
        if (printitems[i]->isbreak()) {
            PageBreak *pb = static_cast<PageBreak *>(printitems[i]);
            
            // Add room for the page header/title.
            current_page_y = get_text_height(*dc, pb->header);
            
            pages.push_back(Page(pb->header, ml, mt, mr, mb));
            
            delete pb;
        } else {
            Truss *truss = static_cast<TrussContainer *>(printitems[i])->truss;
            
            int truss_height_px = truss->getHeight() * page_width
                                  / (60.0 * 12.0);
            int total_height = truss_height_px
                               + get_text_height(*dc, truss->gettext());
            
            if (!truss->getnotes().empty()) {
                total_height += get_text_height(*dc, truss->getnotes());
                // Add the 1/2 line padding in between title and notes
                total_height += get_text_height(*dc, wxT("X")) / 2;
            }
                        
            if (current_page_y + total_height > page_height) {
                current_page_y = get_text_height(*dc, "continuation...");
                pages.push_back(Page("continuation...", ml, mt, mr, mb));
            }
            
            pages.back().add(truss);
            
            current_page_y += total_height;
            // Add 3 blank lines of padding before the next truss.
            current_page_y += get_text_height(*dc, wxT("X")) * 3;
            
            delete static_cast<TrussContainer *>(printitems[i]);
        }
    }
    
    printitems.clear();
}
コード例 #13
0
ファイル: imewnd.cpp プロジェクト: 12019/system-config
int hdc_with_font::get_text_height(const string& str)
{
	return get_text_height(to_wstring(str));
}
コード例 #14
0
int AboutPrefs::create_objects()
{
	int x, y;

	BC_Resources *resources = BC_WindowBase::get_resources();

// 	add_subwindow(new BC_Title(mwindow->theme->preferencestitle_x, 
// 		mwindow->theme->preferencestitle_y, 
// 		_("About"), 
// 		LARGEFONT, 
// 		resources->text_default));
	
	x = mwindow->theme->preferencesoptions_x;
	y = mwindow->theme->preferencesoptions_y +
		get_text_height(LARGEFONT);

	set_font(LARGEFONT);
	set_color(resources->text_default);
	draw_text(x, y, PROGRAM_NAME " " CINELERRA_VERSION);

	y += get_text_height(LARGEFONT);

	set_font(MEDIUMFONT);
	draw_text(x, y, COPYRIGHTTEXT1
#if defined(COPYRIGHTTEXT2)
	"\n" COPYRIGHTTEXT2
#endif
#if defined(REPOMAINTXT)
	"\n" REPOMAINTXT
#endif
	);



	y += get_text_height(MEDIUMFONT) * 4;

	char versions[BCTEXTLEN];
	sprintf(versions, 
_("Quicktime version %d.%d.%d (%s)\n"
"Libmpeg3 version %d.%d.%d\n"),
quicktime_major(),
quicktime_minor(),
quicktime_release(),
FFMPEG_EXTERNALTEXT,
mpeg3_major(),
mpeg3_minor(),
mpeg3_release());
	draw_text(x, y, versions);



	y += get_text_height(MEDIUMFONT) * 3;
	set_font(LARGEFONT);
	draw_text(x, y, "Credits:");
	y += get_text_height(LARGEFONT);
	set_font(MEDIUMFONT);

	char credits[BCTEXTLEN];
	sprintf(credits,

"Jack Crossfire\n"
"Richard Baverstock\n"
"Karl Bielefeldt\n"
"Kevin Brosius\n"
"Jean-Luc Coulon\n"
"Jean-Michel POURE\n"
"Jerome Cornet\n"
"Pierre Marc Dumuid\n"
"Alex Ferrer\n"
"Jan Gerber\n"
"Koen Muylkens\n"
"Stefan de Konink\n"
"Nathan Kurz\n"
"Greg Mekkes\n"
"Eric Seigne\n"
"Joe Stewart\n"
"Dan Streetman\n"
#ifdef X_HAVE_UTF8_STRING
"Gustavo Iñiguez\n"
#else
"Gustavo I\361iguez\n"
#endif
"Johannes Sixt\n"
"Mark Taraba\n"
"Andraz Tori\n"
"Jonas Wulff\n"
"David Arendt\n"

);
	draw_text(x, y, credits);

	int x_indented;
	x_indented = x + get_text_width(MEDIUMFONT, "Pierre Marc Dumuid") + 20;

	char credits_cont1[BCTEXTLEN];
	sprintf(credits_cont1,

#ifdef X_HAVE_UTF8_STRING
"Einar Rünkaru\n"
#else
"Einar R\374nkaru\n"
#endif
"Monty Montgomery\n"

);
	draw_text(x_indented, y, credits_cont1);

	y = get_h() - 135;

	set_font(LARGEFONT);
	draw_text(x, y, "License:");
	y += get_text_height(LARGEFONT);

	set_font(MEDIUMFONT);

	char license3[BCTEXTLEN];
	sprintf(license3, _(
"This program is free software; you can redistribute it and/or modify it under the terms\n"
"of the GNU General Public License as published by the Free Software Foundation; either version\n"
"2 of the License, or (at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;\n"
"without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR\n"
"PURPOSE.  See the GNU General Public License for more details.\n"
"\n"));
	draw_text(x, y, license3);

	x = get_w() - mwindow->theme->about_bg->get_w() - 10;
	y = mwindow->theme->preferencesoptions_y;
	BC_Pixmap *temp_pixmap = new BC_Pixmap(this, 
		mwindow->theme->about_bg,
		PIXMAP_ALPHA);
	draw_pixmap(temp_pixmap, 
		x, 
		y);

	delete temp_pixmap;


	x += mwindow->theme->about_bg->get_w() + 10;
	y += get_text_height(LARGEFONT) * 2;


	flash();
	flush();
	return 0;
}
コード例 #15
0
ファイル: plugindialog.C プロジェクト: Cuchulain/cinelerra
int PluginDialog::resize_event(int w, int h)
{
	mwindow->session->plugindialog_w = w;
	mwindow->session->plugindialog_h = h;
	mwindow->theme->get_plugindialog_sizes();


	standalone_title->reposition_window(mwindow->theme->plugindialog_new_x, 
		mwindow->theme->plugindialog_new_y - 20);
	standalone_list->reposition_window(mwindow->theme->plugindialog_new_x, 
		mwindow->theme->plugindialog_new_y,
		mwindow->theme->plugindialog_new_w,
		mwindow->theme->plugindialog_new_h);
// 	if(standalone_attach)
// 		standalone_attach->reposition_window(mwindow->theme->plugindialog_newattach_x, 
// 			mwindow->theme->plugindialog_newattach_y);
// 	else
// 		standalone_change->reposition_window(mwindow->theme->plugindialog_newattach_x,
// 			mwindow->theme->plugindialog_newattach_y);





	shared_title->reposition_window(mwindow->theme->plugindialog_shared_x, 
		mwindow->theme->plugindialog_shared_y - 20);
	shared_list->reposition_window(mwindow->theme->plugindialog_shared_x, 
		mwindow->theme->plugindialog_shared_y,
		mwindow->theme->plugindialog_shared_w,
		mwindow->theme->plugindialog_shared_h);
// 	if(shared_attach)
// 		shared_attach->reposition_window(mwindow->theme->plugindialog_sharedattach_x, 
// 			mwindow->theme->plugindialog_sharedattach_y);
// 	else
// 		shared_change->reposition_window(mwindow->theme->plugindialog_sharedattach_x,
// 			mwindow->theme->plugindialog_sharedattach_y);
// 




	module_title->reposition_window(mwindow->theme->plugindialog_module_x, 
		mwindow->theme->plugindialog_module_y - 20);
	module_list->reposition_window(mwindow->theme->plugindialog_module_x, 
		mwindow->theme->plugindialog_module_y,
		mwindow->theme->plugindialog_module_w,
		mwindow->theme->plugindialog_module_h);
// 	if(module_attach)
// 		module_attach->reposition_window(mwindow->theme->plugindialog_moduleattach_x, 
// 			mwindow->theme->plugindialog_moduleattach_y);
// 	else
// 		module_change->reposition_window(mwindow->theme->plugindialog_moduleattach_x,
// 			mwindow->theme->plugindialog_moduleattach_y);


	if(single_standalone)
		single_standalone->reposition_window(mwindow->theme->plugindialog_new_x, 
			mwindow->theme->plugindialog_new_y + 
				mwindow->theme->plugindialog_new_h +
				get_text_height(MEDIUMFONT));

	flush();
	return 0;
}
コード例 #16
0
ファイル: theme-viewer.c プロジェクト: paravoid/marco
static void
run_theme_benchmark (void)
{
  GtkWidget* widget;
  GdkPixmap *pixmap;
  int top_height, bottom_height, left_width, right_width;
  MetaButtonState button_states[META_BUTTON_TYPE_LAST] =
  {
    META_BUTTON_STATE_NORMAL,
    META_BUTTON_STATE_NORMAL,
    META_BUTTON_STATE_NORMAL,
    META_BUTTON_STATE_NORMAL
  };
  PangoLayout *layout;
  clock_t start;
  clock_t end;
  GTimer *timer;
  int i;
  MetaButtonLayout button_layout;
#define ITERATIONS 100
  int client_width;
  int client_height;
  int inc;

  widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_widget_realize (widget);

  meta_theme_get_frame_borders (global_theme,
                                META_FRAME_TYPE_NORMAL,
                                get_text_height (widget),
                                get_flags (widget),
                                &top_height,
                                &bottom_height,
                                &left_width,
                                &right_width);

  layout = create_title_layout (widget);

  i = 0;
  while (i < MAX_BUTTONS_PER_CORNER)
    {
      button_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
      button_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
      ++i;
    }

  button_layout.left_buttons[0] = META_BUTTON_FUNCTION_MENU;

  button_layout.right_buttons[0] = META_BUTTON_FUNCTION_MINIMIZE;
  button_layout.right_buttons[1] = META_BUTTON_FUNCTION_MAXIMIZE;
  button_layout.right_buttons[2] = META_BUTTON_FUNCTION_CLOSE;

  timer = g_timer_new ();
  start = clock ();

  client_width = 50;
  client_height = 50;
  inc = 1000 / ITERATIONS; /* Increment to grow width/height,
                            * eliminates caching effects.
                            */

  i = 0;
  while (i < ITERATIONS)
    {
      /* Creating the pixmap in the loop is right, since
       * GDK does the same with its double buffering.
       */
      pixmap = gdk_pixmap_new (widget->window,
                               client_width + left_width + right_width,
                               client_height + top_height + bottom_height,
                               -1);

      meta_theme_draw_frame (global_theme,
                             widget,
                             pixmap,
                             NULL,
                             0, 0,
                             META_FRAME_TYPE_NORMAL,
                             get_flags (widget),
                             client_width, client_height,
                             layout,
                             get_text_height (widget),
                             &button_layout,
                             button_states,
                             meta_preview_get_mini_icon (),
                             meta_preview_get_icon ());

      g_object_unref (G_OBJECT (pixmap));

      ++i;
      client_width += inc;
      client_height += inc;
    }

  end = clock ();
  g_timer_stop (timer);

  milliseconds_to_draw_frame = (g_timer_elapsed (timer, NULL) / (double) ITERATIONS) * 1000;

  g_print (_("Drew %d frames in %g client-side seconds (%g milliseconds per frame) and %g seconds wall clock time including X server resources (%g milliseconds per frame)\n"),
           ITERATIONS,
           ((double)end - (double)start) / CLOCKS_PER_SEC,
           (((double)end - (double)start) / CLOCKS_PER_SEC / (double) ITERATIONS) * 1000,
           g_timer_elapsed (timer, NULL),
           milliseconds_to_draw_frame);

  g_timer_destroy (timer);
  g_object_unref (G_OBJECT (layout));
  gtk_widget_destroy (widget);

#undef ITERATIONS
}
コード例 #17
0
ファイル: interfaceprefs.C プロジェクト: knutj/cinelerra
void InterfacePrefs::create_objects()
{
	int x, y;
	BC_Resources *resources = BC_WindowBase::get_resources();
	int margin = mwindow->theme->widget_border;
	char string[BCTEXTLEN];
	x = mwindow->theme->preferencesoptions_x;
	y = mwindow->theme->preferencesoptions_y;

	add_subwindow(new BC_Title(x, y, 
		_("Time Format"), 
		LARGEFONT, 
		resources->text_default));

	y += get_text_height(LARGEFONT) + 5;


	add_subwindow(hms = new TimeFormatHMS(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_HMS, 
		x, y));
	y += 20;
	add_subwindow(hmsf = new TimeFormatHMSF(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_HMSF, 
		x, y));
	y += 20;
	add_subwindow(samples = new TimeFormatSamples(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_SAMPLES, 
		x, y));
	y += 20;
	add_subwindow(hex = new TimeFormatHex(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_SAMPLES_HEX, 
		x, y));
	y += 20;
	add_subwindow(frames = new TimeFormatFrames(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_FRAMES, 
		x, y));
	y += 20;
	int x1 = x;
	add_subwindow(feet = new TimeFormatFeet(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_FEET_FRAMES, 
		x1, y));
	x1 += feet->get_w() + margin;
	BC_Title *title;
	add_subwindow(title = new BC_Title(x1, y, _("Frames per foot:")));
	x1 += title->get_w() + margin;
	sprintf(string, "%0.2f", pwindow->thread->edl->session->frames_per_foot);
	add_subwindow(new TimeFormatFeetSetting(pwindow, 
		x1, y - 5, 	string));
	y += 20;
	add_subwindow(seconds = new TimeFormatSeconds(pwindow, this, 
		pwindow->thread->edl->session->time_format == TIME_SECONDS, 
		x, y));

	y += 35;
	add_subwindow(new UseTipWindow(pwindow, x, y));
	add_subwindow(new UseWarnIndecies(pwindow, x+200, y));

	y += 35;
	add_subwindow(new BC_Bar(5, y, 	get_w() - 10));
	y += 5;

	add_subwindow(new BC_Title(x, y, _("Index files"), LARGEFONT, resources->text_default));


	y += 25;
	add_subwindow(new BC_Title(x, y + 5, 
		_("Index files go here:"), MEDIUMFONT, resources->text_default));
	add_subwindow(ipathtext = new IndexPathText(x + 230, y, 
		pwindow, 
		pwindow->thread->preferences->index_directory));
	add_subwindow(ipath = new BrowseButton(mwindow, this,
		ipathtext, 
		x + 230 + ipathtext->get_w(), y, 
		pwindow->thread->preferences->index_directory,
		_("Index Path"), 
		_("Select the directory for index files"),
		1));

	y += 30;
	add_subwindow(new BC_Title(x, y + 5, 
		_("Size of index file:"), 
		MEDIUMFONT, 
		resources->text_default));
	sprintf(string, "" _LD "", pwindow->thread->preferences->index_size);
	x1 = x + 230;
	add_subwindow(isize = new IndexSize(x + 230, y, pwindow, string));
	add_subwindow(new ScanCommercials(pwindow, 350,y));
	y += 30;
	add_subwindow(new BC_Title(x, y + 5, _("Number of index files to keep:"), MEDIUMFONT, resources->text_default));
	sprintf(string, "%ld", (long)pwindow->thread->preferences->index_count);
	add_subwindow(icount = new IndexCount(x + 230, y, pwindow, string));
	add_subwindow(deleteall = new DeleteAllIndexes(mwindow, pwindow, 350, y));





	y += 35;
	add_subwindow(new BC_Bar(5, y, 	get_w() - 10));
	y += 5;

	add_subwindow(new BC_Title(x, y, _("Editing"), LARGEFONT, resources->text_default));

	y += 35;

	add_subwindow(thumbnails = new ViewThumbnails(x, y, pwindow));

	int x2 = x + 320, y2 = y;
	AndroidRemote *android_remote = new AndroidRemote(pwindow, x2, y2);
	add_subwindow(android_remote);
	y2 += android_remote->get_h() + 10;
	add_subwindow(title = new BC_Title(x2, y2, _("Port:")));
	int x3 = x2 + title->get_w() + margin;
	AndroidPort *android_port = new AndroidPort(pwindow, x3, y2);
	add_subwindow(android_port);
	y2 += title->get_h() + 10;
	add_subwindow(title = new BC_Title(x2, y2, _("PIN:")));
	AndroidPIN *android_pin = new AndroidPIN(pwindow, x3, y2);
	add_subwindow(android_pin);

	y += 35;
	add_subwindow(new BC_Title(x, y, _("Clicking on edit boundaries does what:")));
	y += 25;
	add_subwindow(new BC_Title(x, y, _("Button 1:")));
	
	ViewBehaviourText *text;
	add_subwindow(text = new ViewBehaviourText(80, y - 5, 
		behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[0]), 
			pwindow, 
			&(pwindow->thread->edl->session->edit_handle_mode[0])));
	text->create_objects();
	y += 30;
	add_subwindow(new BC_Title(x, y, _("Button 2:")));
	add_subwindow(text = new ViewBehaviourText(80, 
		y - 5, 
		behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[1]), 
			pwindow, 
			&(pwindow->thread->edl->session->edit_handle_mode[1])));
	text->create_objects();
	y += 30;
	add_subwindow(new BC_Title(x, y, _("Button 3:")));
	add_subwindow(text = new ViewBehaviourText(80, 
		y - 5, 
		behavior_to_text(pwindow->thread->edl->session->edit_handle_mode[2]), 
			pwindow, 
			&(pwindow->thread->edl->session->edit_handle_mode[2])));
	text->create_objects();

	y += 40;
	x1 = x;
	add_subwindow(title = new BC_Title(x, y + 5, _("Min DB for meter:")));
	x += title->get_w() + 10;
	sprintf(string, "%d", pwindow->thread->edl->session->min_meter_db);
	add_subwindow(min_db = new MeterMinDB(pwindow, string, x, y));

	x += min_db->get_w() + 10;
	add_subwindow(title = new BC_Title(x, y + 5, _("Max DB:")));
	x += title->get_w() + 10;
	sprintf(string, "%d", pwindow->thread->edl->session->max_meter_db);
	add_subwindow(max_db = new MeterMaxDB(pwindow, string, x, y));

	x = x1;
	y += 30;
	ViewTheme *theme;
	add_subwindow(new BC_Title(x, y, _("Theme:")));
	x += 60;
	add_subwindow(theme = new ViewTheme(x, y, pwindow));
	theme->create_objects();

}
コード例 #18
0
ファイル: synthesizer.C プロジェクト: knutj/cinelerra
void SynthWindow::update_notes()
{
	//int octave_w = white_key[0]->get_w() * 7;
	int white_w = white_key[0]->get_w();
	int black_w = black_key[0]->get_w();
	int white_w1 = white_w - black_w / 2 - 2;
	int white_w2 = white_w / 2;
	int white_w3 = white_w * 2 / 3;
	int y = 0;
	int x = 0;
	y1 = y + white_key[0]->get_h() + 10;
	y2 = y1 + get_text_height(MEDIUMFONT) + 10;
	y3 = y2 + get_text_height(MEDIUMFONT) + 10;
	text_black_margin = black_w / 2 - get_text_width(MEDIUMFONT, "O") / 2;
	text_white_margin = white_w / 2 - get_text_width(MEDIUMFONT, "O") / 2;


//printf("SynthWindow::update_notes %d\n", __LINE__);
	note_subwindow->clear_box(0, 0, get_w(), get_h());

	note_subwindow->set_color(get_resources()->default_text_color);

// Add new notes
// To get the stacking order:
// pass 0 is white keys
// pass 1 is black keys
	int current_title = 0;
	for(int pass = 0; pass < 2; pass++)
	{
		x = -note_scroll->get_position();

		for(int i = 0; i < TOTALNOTES; i++)
		{
			int octave_note = i % 12;
			if(!pass)
			{
// White keys
				switch(octave_note)
				{
					case 0:
						update_whitekey(i, &current_title, x, y);
						break;
					case 1:
						x += white_w;
						break;
					case 2:
						update_whitekey(i, &current_title, x, y);
						break;
					case 3:
						x += white_w;
						break;
					case 4:
						update_whitekey(i, &current_title, x, y);
						x += white_w;
						break;
					case 5:
						update_whitekey(i, &current_title, x, y);
						break;
					case 6:
						x += white_w;
						break;
					case 7:
						update_whitekey(i, &current_title, x, y);
						break;
					case 8:
						x += white_w;
						break;
					case 9:
						update_whitekey(i, &current_title, x, y);
						break;
					case 10:
						x += white_w;
						break;
					case 11:
						update_whitekey(i, &current_title, x, y);
						x += white_w;
						break;
				}
			}
			else
			{
// Black keys
				switch(octave_note)
				{
					case 1:
						update_blackkey(i, &current_title, x + white_w2, y);
						x += white_w;
						break;
					case 3:
						update_blackkey(i, &current_title, x + white_w3, y);
						x += white_w;
						break;
					case 4:
						x += white_w;
						break;
					case 6:
						update_blackkey(i, &current_title, x + white_w2, y);
						x += white_w;
						break;
					case 8:
						update_blackkey(i, &current_title, x + white_w1, y);
						x += white_w;
						break;
					case 10:
						update_blackkey(i, &current_title, x + white_w3, y);
						x += white_w;
						break;
					case 11:
						x += white_w;
						break;
				}
			}
		}
	}
}
コード例 #19
0
ファイル: synthesizer.C プロジェクト: knutj/cinelerra
void SynthWindow::create_objects()
{
	BC_MenuBar *menu;
	add_subwindow(menu = new BC_MenuBar(0, 0, get_w()));

	BC_Menu *levelmenu, *phasemenu, *harmonicmenu;
	menu->add_menu(levelmenu = new BC_Menu(_("Level")));
	menu->add_menu(phasemenu = new BC_Menu(_("Phase")));
	menu->add_menu(harmonicmenu = new BC_Menu(_("Harmonic")));

	levelmenu->add_item(new SynthLevelInvert(synth));
	levelmenu->add_item(new SynthLevelMax(synth));
	levelmenu->add_item(new SynthLevelRandom(synth));
	levelmenu->add_item(new SynthLevelSine(synth));
	levelmenu->add_item(new SynthLevelSlope(synth));
	levelmenu->add_item(new SynthLevelZero(synth));

	phasemenu->add_item(new SynthPhaseInvert(synth));
	phasemenu->add_item(new SynthPhaseRandom(synth));
	phasemenu->add_item(new SynthPhaseSine(synth));
	phasemenu->add_item(new SynthPhaseZero(synth));

	harmonicmenu->add_item(new SynthFreqEnum(synth));
	harmonicmenu->add_item(new SynthFreqEven(synth));
	harmonicmenu->add_item(new SynthFreqFibonacci(synth));
	harmonicmenu->add_item(new SynthFreqOdd(synth));
	harmonicmenu->add_item(new SynthFreqPrime(synth));

	int x = 10, y = 30;
	
	add_subwindow(new BC_Title(x, y, _("Waveform")));
	x += 240;
	add_subwindow(new BC_Title(x, y, _("Wave Function")));
	y += 20;
	x = 10;
	add_subwindow(canvas = new SynthCanvas(synth, this, x, y, 230, 160));
	canvas->update();

	x += 240;
	char string[BCTEXTLEN];
	waveform_to_text(string, synth->config.wavefunction);

	add_subwindow(waveform = new SynthWaveForm(synth, x, y, string));
	waveform->create_objects();
	y += 30;
	int x1 = x + waveform->get_w() + 10;


	add_subwindow(new BC_Title(x, y, _("Base Frequency:")));
	y += 30;
	add_subwindow(base_freq = new SynthBaseFreq(synth, this, x, y));
	base_freq->update((float)synth->config.base_freq[0]);
	x += base_freq->get_w() + synth->get_theme()->widget_border;
	add_subwindow(freqpot = new SynthFreqPot(synth, this, x, y - 10));
	base_freq->freq_pot = freqpot;
	freqpot->freq_text = base_freq;
	x -= base_freq->get_w() + synth->get_theme()->widget_border;
	y += 40;
	add_subwindow(new BC_Title(x, y, _("Wetness:")));
	add_subwindow(wetness = new SynthWetness(synth, x + 70, y - 10));

	y += 40;
	add_subwindow(new SynthClear(synth, x, y));


	x = 50;  
	y = 220;
	add_subwindow(new BC_Title(x, y, _("Level"))); 
	x += 75;
	add_subwindow(new BC_Title(x, y, _("Phase"))); 
	x += 75;
	add_subwindow(new BC_Title(x, y, _("Harmonic")));



	y += 20; x = 10;
	add_subwindow(osc_subwindow = new BC_SubWindow(x, y, 265, get_h() - y));
	x += 265;
	add_subwindow(osc_scroll = new OscScroll(synth, this, x, y, get_h() - y));


	x += 20;
	add_subwindow(new SynthAddOsc(synth, this, x, y));
	y += 30;
	add_subwindow(new SynthDelOsc(synth, this, x, y));

// Create keyboard
	y = 30;

#include "white_up_png.h"
#include "white_hi_png.h"
#include "white_dn_png.h"
#include "white_checked_png.h"
#include "white_checkedhi_png.h"
#include "black_up_png.h"
#include "black_hi_png.h"
#include "black_dn_png.h"
#include "black_checked_png.h"
#include "black_checkedhi_png.h"
	white_key[0] = new VFrame(white_up_png);
	white_key[1] = new VFrame(white_hi_png);
	white_key[2] = new VFrame(white_checked_png);
	white_key[3] = new VFrame(white_dn_png);
	white_key[4] = new VFrame(white_checkedhi_png);
	black_key[0] = new VFrame(black_up_png);
	black_key[1] = new VFrame(black_hi_png);
	black_key[2] = new VFrame(black_checked_png);
	black_key[3] = new VFrame(black_dn_png);
	black_key[4] = new VFrame(black_checkedhi_png);


	add_subwindow(note_subwindow = new BC_SubWindow(x1, 
		y, 
		get_w() - x1, 
		white_key[0]->get_h() + MARGIN +
		get_text_height(MEDIUMFONT) + MARGIN +
		get_text_height(MEDIUMFONT) + MARGIN));
	add_subwindow(note_scroll = new NoteScroll(synth,
		this,
		x1,
		note_subwindow->get_y() + note_subwindow->get_h(),
		note_subwindow->get_w()));

	add_subwindow(momentary = new SynthMomentary(this, 
		x1, 
		note_scroll->get_y() + note_scroll->get_h() + MARGIN, 
		_("Momentary notes")));


	add_subwindow(note_instructions = new BC_Title(
		x1,
		momentary->get_y() + momentary->get_h() + MARGIN,
		_("Ctrl or Shift to select multiple notes.")));

	update_scrollbar();
	update_oscillators();
	update_notes();

	show_window();
}
コード例 #20
0
ファイル: Font.cpp プロジェクト: awinslow/Awesome-Game
  void Font_FT::init(const String &filepath) {
    TTF_Font *font = TTF_OpenFont(filepath.c_str(), int(get_text_height() * m_vratio + 0.5f));
    if(!font)
      throw Font_Init_Failure();

    /*** Set Style ***/

    if(is_bold() && is_italic())
      TTF_SetFontStyle(font, TTF_STYLE_BOLD | TTF_STYLE_ITALIC);
    else if(is_bold())
      TTF_SetFontStyle(font, TTF_STYLE_BOLD);
    else if(is_italic())
      TTF_SetFontStyle(font, TTF_STYLE_ITALIC);

    /*** Determine Width & Height ***/

    float font_width = 0;
    float font_height = 0;
    SDL_Color color2 = {0xFF, 0xFF, 0xFF, 0xFF};
    SDL_Surface *source[256] = {0};
    for(unsigned char c = 1; c; ++c) {
      Core::assert_no_error();
      //char t[2] = {c, '\0'};
      //source[c] = TTF_RenderText_Blended(font, t, color2);
      source[c] = TTF_RenderGlyph_Blended(font, c, color2);
      Core::print_error();
      font_width = std::max(font_width, float(source[c] ? source[c]->w : 0));
      font_height = std::max(font_height, float(source[c] ? source[c]->h : 0));
    }

    /*** Initialize Intermediate SDL Surface ***/

    const int 
      next_w = int(pow(2.0f, ceil(log(float(16 * font_width))/log(2.0f)))), 
      next_h = int(pow(2.0f, ceil(log(float(16 * font_height))/log(2.0f))));
  
    SDL_Surface *font_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, next_w, next_h, 32, source[END_OF_TIME]->format->Rmask, source[END_OF_TIME]->format->Gmask, source[END_OF_TIME]->format->Bmask, source[END_OF_TIME]->format->Amask);
    if(!font_surface) {
      for(unsigned char c = 1; c; ++c)
        SDL_FreeSurface(source[c]);
      TTF_CloseFont(font);

      if(next_h > 1024) {
        m_vratio /= 2.0f;
        init(filepath);
        return;
      }
      else
        throw Font_Init_Failure();
    }

    SDL_LockSurface(font_surface);
    SDL_FillRect(font_surface, 0, SDL_MapRGBA(font_surface->format, 0, 0, 0, SDL_ALPHA_TRANSPARENT));
    SDL_UnlockSurface(font_surface);

    /*** Initialize Glyphs ***/

    SDL_Rect dstrect = {0, 0, Uint16(font_width), Uint16(font_height)};
    m_glyph[0] = 0;
    for(unsigned char c = 1; c; ++c) {
      dstrect.x = Sint16((c % 16) * font_width);
      dstrect.y = Sint16((c / 16) * font_height);
      m_glyph[c] = new Glyph(font, c, source[c], font_surface, dstrect, next_w, next_h, m_vratio);
    }

    /*** Correct Transparency ***/

    const Uint32 transparent_white = font_surface->format->Rmask | font_surface->format->Gmask | font_surface->format->Bmask;
    for(int i = 0; i < font_surface->h; ++i)
      for(Uint32 * src = reinterpret_cast<Uint32 *>(font_surface->pixels) + i * font_surface->pitch / 4,
                 * src_end = src + font_surface->w;
          src != src_end;
          ++src)
        if(*src & font_surface->format->Rmask)
          *src = transparent_white | ((*src & font_surface->format->Rmask) >> font_surface->format->Rshift << font_surface->format->Ashift);

    /*** Initialize Final Texture ***/
    
    m_texture = get_Video().create_Texture(font_surface, false);

    TTF_CloseFont(font);
  }
コード例 #21
0
ファイル: plugindialog.C プロジェクト: Cuchulain/cinelerra
void PluginDialog::create_objects()
{
//	int use_default = 1;
	char string[BCTEXTLEN];
	mwindow->theme->get_plugindialog_sizes();

	lock_window("PluginDialog::create_objects");
 	if(thread->plugin)
	{
		strcpy(string, thread->plugin->title);
		//use_default = 0;
	}
	else
	{
// no plugin
		sprintf(string, _("None"));
	}






// GET A LIST OF ALL THE PLUGINS AVAILABLE
	mwindow->search_plugindb(thread->data_type == TRACK_AUDIO, 
		thread->data_type == TRACK_VIDEO, 
		1, 0, 0, plugindb);

	mwindow->edl->get_shared_plugins(thread->track,
		&plugin_locations,
		thread->is_mainmenu,
		thread->data_type);
	mwindow->edl->get_shared_tracks(thread->track,
		&module_locations,
		thread->is_mainmenu,
		thread->data_type);

// Construct listbox items
	for(int i = 0; i < plugindb.total; i++)
		standalone_data.append(new BC_ListBoxItem(_(plugindb.values[i]->title)));
	for(int i = 0; i < plugin_locations.total; i++)
	{
		Track *track = mwindow->edl->tracks->number(plugin_locations.values[i]->module);
		char *track_title = track->title;
		int number = plugin_locations.values[i]->plugin;
		Plugin *plugin = track->get_current_plugin(mwindow->edl->local_session->get_selectionstart(1), 
			number, 
			PLAY_FORWARD,
			1,
			0);
		char *plugin_title = plugin->title;
		char string[BCTEXTLEN];

		sprintf(string, "%s: %s", track_title, _(plugin_title));
		shared_data.append(new BC_ListBoxItem(string));
	}
	for(int i = 0; i < module_locations.total; i++)
	{
		Track *track = mwindow->edl->tracks->number(module_locations.values[i]->module);
		module_data.append(new BC_ListBoxItem(track->title));
	}





// Create widgets
	add_subwindow(standalone_title = new BC_Title(mwindow->theme->plugindialog_new_x, 
		mwindow->theme->plugindialog_new_y - 20, 
		_("Plugins:")));
	add_subwindow(standalone_list = new PluginDialogNew(this, 
		&standalone_data, 
		mwindow->theme->plugindialog_new_x, 
		mwindow->theme->plugindialog_new_y,
		mwindow->theme->plugindialog_new_w,
		mwindow->theme->plugindialog_new_h));
// 
// 	if(thread->plugin)
// 		add_subwindow(standalone_change = new PluginDialogChangeNew(mwindow,
// 			this,
// 			mwindow->theme->plugindialog_newattach_x,
// 			mwindow->theme->plugindialog_newattach_y));
// 	else
// 		add_subwindow(standalone_attach = new PluginDialogAttachNew(mwindow, 
// 			this, 
// 			mwindow->theme->plugindialog_newattach_x, 
// 			mwindow->theme->plugindialog_newattach_y));
// 







	add_subwindow(shared_title = new BC_Title(mwindow->theme->plugindialog_shared_x, 
		mwindow->theme->plugindialog_shared_y - 20, 
		_("Shared effects:")));
	add_subwindow(shared_list = new PluginDialogShared(this, 
		&shared_data, 
		mwindow->theme->plugindialog_shared_x, 
		mwindow->theme->plugindialog_shared_y,
		mwindow->theme->plugindialog_shared_w,
		mwindow->theme->plugindialog_shared_h));
// 	if(thread->plugin)
//       add_subwindow(shared_change = new PluginDialogChangeShared(mwindow,
//          this,
//          mwindow->theme->plugindialog_sharedattach_x,
//          mwindow->theme->plugindialog_sharedattach_y));
//    else
// 		add_subwindow(shared_attach = new PluginDialogAttachShared(mwindow, 
// 			this, 
// 			mwindow->theme->plugindialog_sharedattach_x, 
// 			mwindow->theme->plugindialog_sharedattach_y));
// 








	add_subwindow(module_title = new BC_Title(mwindow->theme->plugindialog_module_x, 
		mwindow->theme->plugindialog_module_y - 20, 
		_("Shared tracks:")));
	add_subwindow(module_list = new PluginDialogModules(this, 
		&module_data, 
		mwindow->theme->plugindialog_module_x, 
		mwindow->theme->plugindialog_module_y,
		mwindow->theme->plugindialog_module_w,
		mwindow->theme->plugindialog_module_h));
// 	if(thread->plugin)
//       add_subwindow(module_change = new PluginDialogChangeModule(mwindow,
//          this,
//          mwindow->theme->plugindialog_moduleattach_x,
//          mwindow->theme->plugindialog_moduleattach_y));
//    else
// 		add_subwindow(module_attach = new PluginDialogAttachModule(mwindow, 
// 			this, 
// 			mwindow->theme->plugindialog_moduleattach_x, 
// 			mwindow->theme->plugindialog_moduleattach_y));
// 


// Add option for the menu invocation
// 	add_subwindow(file_title = new BC_Title(
// 		mwindow->theme->menueffect_file_x, 
// 		mwindow->theme->menueffect_file_y, 
// 		_("One standalone effect is attached to the first track.\n"
// 		"Shared effects are attached to the remaining tracks.")));

	if(thread->is_mainmenu)
		add_subwindow(single_standalone = new PluginDialogSingle(this, 
			mwindow->theme->plugindialog_new_x + BC_OKButton::calculate_w() + 10, 
			mwindow->theme->plugindialog_new_y + 
				mwindow->theme->plugindialog_new_h +
				get_text_height(MEDIUMFONT)));



	add_subwindow(new BC_OKButton(this));
	add_subwindow(new BC_CancelButton(this));

	selected_available = -1;
	selected_shared = -1;
	selected_modules = -1;
	
	show_window();
	flush();
	unlock_window();
}