void TrackEditorPattern::paint_cursor(GUI::Painter &p,int p_row) {


	int rowsize=get_row_height();
	int fontofs=(rowsize-get_font_height())/2;
	int textofs=p_row*rowsize+fontofs;
	int columnwidth=get_font_width()*4;

	int column=Editor::get_singleton()->get_cursor_col();
	int field=Editor::get_singleton()->get_cursor_field();

	int xofs=column*columnwidth+get_font_width();

	//xofs+=VisualSettings::get_singleton()->get_pattern_cursor_offset().x;
	//textofs+=VisualSettings::get_singleton()->get_pattern_cursor_offset().y;

	switch( Editor::get_singleton()->get_track_edit_mode() ) {

		case Editor::EDIT_MODE_FRONT: {

			xofs+=2*field*get_font_width();
		} break;
		case Editor::EDIT_MODE_BACK: {

			xofs+=get_font_width()+field*get_font_width();
		} break;
	}

	p.draw_stylebox( stylebox( SB_TRACK_EDITOR_CURSOR ), GUI::Point(xofs,textofs), GUI::Size( get_font_width(), get_font_height() ) );
	
}
Beispiel #2
0
static void
e_contact_output (GtkPrintContext *context,
                  PangoFontDescription *font,
                  gdouble x,
                  gdouble y,
                  gdouble width,
                  const gchar *text)
{
	PangoLayout *layout;
	gdouble indent;
	cairo_t *cr;

	layout = gtk_print_context_create_pango_layout (context);

	if (width == -1 || get_font_width (context, font, text) <= width)
		indent = .0;
	else
		indent = get_font_width (context, font, "     ");

	pango_layout_set_font_description (layout, font);
	pango_layout_set_text (layout, text, -1);
	pango_layout_set_width (layout, pango_units_from_double (width));
	pango_layout_set_indent (layout, pango_units_from_double (indent));
	pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR);

	cr = gtk_print_context_get_cairo_context (context);

	cairo_save (cr);
	cairo_move_to (cr, x, y);
	pango_cairo_show_layout (cr, layout);
	cairo_restore (cr);

	g_object_unref (layout);
}
GUI::Size TrackEditorPattern::get_minimum_size_internal() {
	
	int cols=track->get_visible_columns();
	
	return GUI::Size( (2+3*cols+(cols-1))*get_font_width(), 0 );
	
}
void TrackEditorPattern::paint_selection(GUI::Painter&p,int p_clip_from,int p_clip_to) {
	
	if (!Editor::get_singleton()->is_selection_active())
		return;
	
	int sel_margin=constant(C_TRACK_EDITOR_SELECTION_MARGIN);
	int current_track=Editor::get_singleton()->get_song()->find_track_pos(track);
	int font_width=get_font_width();
	
	if ( Editor::get_singleton()->get_selection_begin_track() <= current_track && Editor::get_singleton()->get_selection_end_track() >= current_track &&
		    Editor::get_singleton()->get_selection_begin_row() <= (Editor::get_singleton()->get_window_rows()+Editor::get_singleton()->get_window_offset()+1) && (Editor::get_singleton()->get_selection_end_row()+1)>=Editor::get_singleton()->get_window_offset() ) {
		
		/* SELECTION VISIBLE */
		
		int from_y=Editor::get_singleton()->get_selection_begin_row()-Editor::get_singleton()->get_window_offset();
		
		int to_y=(Editor::get_singleton()->get_selection_end_row()+1)-Editor::get_singleton()->get_window_offset();
		
		from_y*=get_row_size();
		to_y*=get_row_size();
		
		if (from_y<0)
			from_y=0;
		if (to_y>size.height)
			to_y=size.height;

		//no point painting?
		if (from_y>p_clip_to || to_y<p_clip_from)
			return;
		
		if (from_y<p_clip_from)
			from_y=p_clip_from;
		
		if (to_y>p_clip_to)
			to_y=p_clip_to;
		
		int from_x=sel_margin;
		int to_x=size.width-sel_margin*2;
		
		if (Editor::get_singleton()->get_selection_begin_track()==current_track) {
			
			int col_from=Editor::get_singleton()->get_selection_begin_column();
			from_x=sel_margin+4*font_width*col_from;
		}
		
		if (Editor::get_singleton()->get_selection_end_track()==current_track) {
		
			int col_to=Editor::get_singleton()->get_selection_end_column();
			to_x=(font_width-sel_margin)+4*font_width*(col_to+1);
	
		}
		//printf("drawing from %i to %i\n",p_clip_from,p_clip_to);
		p.draw_fill_rect(GUI::Point(from_x,from_y),GUI::Size(to_x-from_x,to_y-from_y),color(COLOR_PATTERN_SELECTION));
	}
		    
	
}
void TrackEditorPattern::paint_row_lines(GUI::Painter &p) {

	int visible_rows=Editor::get_singleton()->get_window_rows()+1;
	int row_size=get_row_height();

	int font_w=get_font_width();
	
	
	for (int i=0;i<visible_rows;i++) {
		
		Tick tick=Editor::get_singleton()->get_row_ticks( Editor::get_singleton()->get_window_offset() + i );

		int from_x; 
		int width_x; 
			
		if (track->get_block_at_pos(Editor::get_singleton()->get_row_ticks( Editor::get_singleton()->get_window_offset()+i))>=0) {
			from_x = font_w;
			width_x = size.width-from_x*2;
		} else {
			from_x=0;
			width_x=size.width;
				
		}		
		if ( (tick % TICKS_PER_BEAT)==0 ) {//beat
			
			int block=track->find_block_at_pos( tick );
			bool paint=true;
			if ( block!=-1) {
				
				if (track->get_block_pos(block)==tick)
					paint=false;
				
				if (track->get_block_pos(block)+track->get_block(block)->get_length()==tick)
					paint=false;
				
			}
			
			
		
			if (song->get_bar_map().get_bar_beat(tick/TICKS_PER_BEAT)==0)  {
				p.draw_fill_rect(GUI::Point(from_x,i*row_size),GUI::Size(width_x,1),color(COLOR_PATTERN_BAR_LINE));
			} else  if (paint) {
				p.draw_fill_rect(GUI::Point(from_x,i*row_size),GUI::Size(width_x,1),color(COLOR_PATTERN_BEAT_LINE));
				
			}

		} else
			p.draw_fill_rect(GUI::Point(from_x,i*row_size),GUI::Size(width_x,1),color(COLOR_PATTERN_SUBBEAT_LINE));

		
		//p.drawGUI::Rect(0,i*row_size,size.width,0);


	}

}
Beispiel #6
0
/*
 * @breif 本函数功能是通过判断
 *
 */
si_t   shortcut_update_all_areas ( struct shortcut * sh )
{
	struct rectangle area;
	/* 总字数 , 单字宽度,单字高度,每行字数 ,总行数,最后一行的字数 */
	si_t char_total_num ;
	si_t font_height;
	si_t font_width;
	si_t text_line_num;
	si_t maxlen;

    application_widget_absolute_area(WIDGET_POINTER(sh), &area);


	if(shortcut_get_is_text_visiable(sh) == 1)
	{
		/* 总字数 , 单字宽度,单字高度 */
		char_total_num = strlen( sh->text );
		font_height = get_font_height( sh->gd ) ;
		font_width  = get_font_width( sh->gd ) ;
		maxlen = area.width * 2 / font_width;

		text_line_num = char_total_num / maxlen + 1;
		if( font_height  > sh->area.height || font_width  >sh->area.width)
		{
            EGUI_PRINT_ERROR("font for desktop shortcut is too large");

        	return -1;
		}

		sh->text_field.x = area.x ;
		sh->text_field.y = area.y + area.height - ( text_line_num * font_height );
		sh->text_field.width = area.width;
		sh->text_field.height = text_line_num * font_height ;

		sh->img_field.x = area.x  ;
		//sh->img_field.x = area.x + area.width/4 ;
		sh->img_field.y = area.y  ;
		sh->img_field.width = area.width ;
		sh->img_field.height = area.height - sh->text_field.height;

	}
	else
	{
		sh->img_field.x = area.x ;
		sh->img_field.y = area.y ;
		sh->img_field.width = area.width ;
		sh->img_field.height = area.height ;
	}
    return 1;
}
Beispiel #7
0
si_t shortcut_show_text(struct shortcut * sh)
{

	/* 总字数 , 单字宽度,单字高度,每行字数 ,总行数,最后一行的字数 */
	si_t char_total_num ;
	si_t font_width;
	si_t font_height;
	si_t maxlen;
	si_t text_line_num;
	si_t last_line_text_num;

	si_t i = 0;


	char_total_num = strlen( sh->text );

	font_width  = get_font_width( sh->gd ) ;

	font_height = get_font_height( sh->gd ) ;

	maxlen = (sh->area.width * 2 )/ font_width;

	last_line_text_num = char_total_num % maxlen ;

	text_line_num = char_total_num / maxlen + 1;

	set_color(sh->gd, sh->fore_color.r, sh->fore_color.g, sh->fore_color.b, sh->fore_color.a);

	/* 设置区域 , 文字区域*/
 	set_area(sh->gd,  sh->text_field.x , sh->text_field.y , sh->text_field.width , sh->text_field.height);

/*	 填充矩形 
	fill_rectangle(sh->gd,  sh->text_field.x, sh->text_field.y, sh->text_field.width , sh->text_field.height);
*  */
	/* 显示文字 */
	for( i = 0; i < text_line_num -1; i++ )
	{
		show_text(sh->gd, sh->text_field.x, sh->text_field.y + i * font_height  , sh->text + i*maxlen ,maxlen);
	}

	show_text(  sh->gd,
			    sh->text_field.x + ( sh->text_field.width  - last_line_text_num * font_width ) / 2,
			    sh->text_field.y + i * font_height  ,
			    sh->text + i * maxlen ,
			    last_line_text_num
			 );
	return 0;

}
void TrackEditorPattern::get_row_column_and_field(GUI::Point p_pos,int *p_row,int *p_column,int *p_field) {
	
	int rowsize=get_row_height();
	int columnwidth=get_font_width()*4;

	int click_x=p_pos.x;
	if (Editor::get_singleton()->get_track_edit_mode()==Editor::EDIT_MODE_FRONT)
		click_x+=get_font_width()/2; //makes clicking easier
	click_x-=get_font_width();
	if (click_x<0)
		click_x=0;

	*p_row=p_pos.y/get_row_height();
	*p_column= click_x / columnwidth;
	int col_x=click_x % columnwidth;
	*p_field=col_x*2/columnwidth;
	
	if (*p_column>=track->get_visible_columns()) {
		
		*p_column=track->get_visible_columns()-1;
		*p_field=1;
	}
		
}
Beispiel #9
0
// returns how far to move for the next char, or negative on error
int	draw_char_scaled(unsigned char cur_char, int cur_x, int cur_y, float displayed_font_x_size, float displayed_font_y_size)
{
	float u_start,u_end,v_start,v_end;
	int chr,col,row;
	int displayed_font_x_width;
	int	font_bit_width, ignored_bits;

	chr= find_font_char(cur_char);
	if(chr < 0)	// watch for illegal/non-display characters
		{
			return 0;
		}

	// first, see where that char is, in the font.bmp
	col= chr/FONT_CHARS_PER_LINE;
	row= chr%FONT_CHARS_PER_LINE;

	//displayed_font_x_width=(int)displayed_font_x_size;
	font_bit_width= get_font_width(chr);
	displayed_font_x_width= (int)(0.5f+((float)font_bit_width)*displayed_font_x_size/12.0);
	ignored_bits= (12-font_bit_width)/2;	// how many bits on each side of the char are ignored?

	//now get the texture coordinates
	u_start= (float)(row*FONT_X_SPACING+ignored_bits)/256.0f;
	u_end= (float)(row*FONT_X_SPACING+FONT_X_SPACING-7-ignored_bits)/256.0f;
#ifdef NEW_TEXTURES
	v_start= (float)(1+col*FONT_Y_SPACING)/256.0f;
	v_end= (float)(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#else
	v_start= (float)1.0f-(1+col*FONT_Y_SPACING)/256.0f;
	v_end= (float)1.0f-(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#endif //NEW_TEXTURES

	// and place the text from the graphics on the map
	glTexCoord2f(u_start,v_start);
	glVertex3i(cur_x,cur_y,0);

	glTexCoord2f(u_start,v_end);
	glVertex3i(cur_x,cur_y+(displayed_font_y_size+1),0);

	glTexCoord2f(u_end,v_end);
	glVertex3i(cur_x+displayed_font_x_width,cur_y+(displayed_font_y_size+1),0);

	glTexCoord2f(u_end,v_start);
	glVertex3i(cur_x+displayed_font_x_width,cur_y,0);

	return(displayed_font_x_width);	// return how far to move for the next character
}
Beispiel #10
0
extern si_t text_line_get_max_line_shown(struct text_line* t)
{
    si_t fontx, fonty, max_line;

    /**
     * make sure the font size fits the area
     * the magic number 12 is:
     * 4 for outter frame
     * + 6 for inner frame
     * + 2 for margin between text and the inner frame
     **/
    ++ t->font;
    do{
        -- t->font;
        set_font(t->gd, t->font);
        fontx = get_font_width(t->gd);
        fonty = get_font_height(t->gd);
    }while(fonty > (t->area.height - 12) || fontx > t->area.width - 12);
    max_line = (t->area.height - 12) / fonty;
    t->chars_per_line = (t->area.width - 12) / fontx;

    return max_line;
}
Beispiel #11
0
/**
 * Prints the provided string after formatting it to increase readability.
 */
void print_long_text(char *string, Renderer *renderer) {
  char log_buffer[MAXIMUM_STRING_SIZE];
  const int font_width = get_font_width();
  const int width = get_window_width() - 2 * get_padding() * font_width;
  TTF_Font *font = get_font();
  SDL_Surface *surface;
  SDL_Texture *texture;
  SDL_Color color = to_sdl_color(COLOR_DEFAULT_FOREGROUND);
  SDL_Rect position;
  position.x = get_padding() * font_width;
  position.y = get_padding() * font_width;
  clear(renderer);
  /* Validate that the string is not empty and that x and y are nonnegative. */
  if (string == NULL || string[0] == '\0') {
    return;
  }
  remove_first_breaks(string);
  surface = TTF_RenderText_Blended_Wrapped(font, string, color, width);
  if (surface == NULL) {
    sprintf(log_buffer, CREATE_SURFACE_FAIL, "print_long_text()");
    log_message(log_buffer);
    return;
  }
  texture = SDL_CreateTextureFromSurface(renderer, surface);
  if (texture == NULL) {
    sprintf(log_buffer, CREATE_TEXTURE_FAIL, "print_long_text()");
    log_message(log_buffer);
    return;
  }
  /* Copy destination width and height from the texture. */
  SDL_QueryTexture(texture, NULL, NULL, &position.w, &position.h);
  SDL_RenderCopy(renderer, texture, NULL, &position);
  SDL_DestroyTexture(texture);
  SDL_FreeSurface(surface);
  present(renderer);
}
Beispiel #12
0
static si_t text_line_default_show_text(struct text_line* t, si_t x, si_t y)
{
    si_t fontx, fonty, startx, starty, rulerx, rulery1, rulery2, max_line;

    /**
     * start axis;
     * the magic number 6 is:
     * 2 for outter frame
     * + 3 for inner frame
     * + 1 for margin between text and the inner frame
     **/
    max_line = text_line_get_max_line_shown(t);
    fonty = get_font_height(t->gd);
    fontx = get_font_width(t->gd);
    startx = x + 6;
    starty = y + 6 + (t->area.height - 12 - fonty * max_line) / 2;

    /**
     * if there are text in buffer
     **/
    if(strlen(t->buf) != 0)
    {
        char* strshow;
        char* start;
        si_t i = 0;
        si_t lines;

        /**
         * adjust start index
         * also, lines refers to the line that current ruler is in
         **/
        lines = lines_between(t->show_start, t->ruler_cur, t->chars_per_line, t->is_enter_enable, t->is_linewrap);
        if(lines == -1)
        {
            start = get_prev_line_start(t->show_start, t->chars_per_line, t->is_enter_enable, t->is_linewrap);
            if(!start)
                return -1;
            t->show_start = start;
            lines = 0;

            /**
             * dispatch page up event to subscriber
             **/
            event_to_be_dispatched = TEXT_LINE_EVENT_PAGE_UP;
            list_for_each(&t->subscribe_info_list, do_handle_event);
        }
        else if(lines == max_line)
        {
            start = get_next_line_start(t->show_start, t->chars_per_line, t->is_enter_enable, t->is_linewrap);
            if(!start)
                return -1;
            t->show_start = start;
            lines = max_line - 1;

            /**
             * dispatch page down event to subscriber
             **/
            event_to_be_dispatched = TEXT_LINE_EVENT_PAGE_DOWN;
            list_for_each(&t->subscribe_info_list, do_handle_event);
        }

        /**
         * show line by line
         **/
        strshow = t->show_start;
        while(i != max_line && strshow != NULL)
        {
            char* next = get_next_line_start(strshow, t->chars_per_line, t->is_enter_enable, t->is_linewrap);
            si_t showlen;
            if(next == NULL)
            {
                showlen = strlen(strshow);
            }
            else
            {
                showlen = next - strshow;
            }

            /**
             * locate ruler
             **/
            if(i == lines)
            {
                t->ruler_line_start = strshow;
                rulerx = startx + (t->ruler_cur - strshow) * fontx; 
                rulery1 = starty;
                rulery2 = starty + fonty;
            }

            /**
             * show text
             **/
            set_color(t->gd,
                t->fore_color.r,
                t->fore_color.g,
                t->fore_color.b,
                t->fore_color.a);
            if(text_line_is_keybd_type_password(t))
            {
                char tmpstr[MAXBUF];
                si_t left = showlen;

                while(left > MAXBUF)
                {
                    memset(tmpstr, '*', MAXBUF);
                    show_text(t->gd, startx, starty, tmpstr, MAXBUF);

                    left -= MAXBUF;
                    startx += MAXBUF * fontx;
                }

                memset(tmpstr, '*', left - 1);
                if(t->keybd_focus)
                    tmpstr[left - 1] = strshow[showlen - 1];
                else
                    tmpstr[left - 1] = '*';
                show_text(t->gd, startx, starty, tmpstr, left);
            }
            else
            {
                /**
                 * enter cannot be shown!
                 **/
                if(showlen > 0 && strshow[showlen - 1] == '\n')
                    show_text(t->gd, startx, starty, strshow, showlen - 1);
                else
                    show_text(t->gd, startx, starty, strshow, showlen);

            }
            ++ i;
            strshow = next;
            starty += fonty;
        }
    }
    /**
     * else if placeholder need to be displayed
     **/
    else if(t->placeholder != NULL && !t->keybd_focus)
    {
	/* FIXME */
        set_color(t->gd, t->frame_color.r, t->frame_color.g, t->frame_color.b, t->frame_color.a);
        show_text(t->gd, startx, starty, t->placeholder, strlen(t->placeholder) + 1);
        return 0;
    }
    /**
     * no input; just a ruler
     **/
    else
    {
        rulerx = startx;
        rulery1 = starty;
        rulery2 = starty + fonty;
    }

    /**
     * show ruler
     **/
    if(t->keybd_focus)
    {
        set_color(t->gd, t->fore_color.r, t->fore_color.g, t->fore_color.b, t->fore_color.a);
        draw_line(t->gd, rulerx, rulery1, rulerx, rulery2);
    }

    return 0;
}
Beispiel #13
0
extern si_t text_line_get_line_total(struct text_line* t)
{
    si_t fontx = get_font_width(t->gd);
    t->chars_per_line = (t->area.width - 12) / fontx;
    return lines_between(t->buf, t->buf + strlen(t->buf), t->chars_per_line, t->is_enter_enable, t->is_linewrap);
}
void TrackEditorPattern::paint_multiple_nonvisible_events( GUI::Painter& p, int p_row, const NoteList& p_list) {

	
	
	int font_width=get_font_width();
	int rowsize=get_row_size();
	int fontofs=(rowsize-get_font_height())/2;
	int eventofs=p_row*rowsize+fontofs;
	int notewidth=get_font_width()*3;
	int columnwidth=get_font_width()*4;

	NoteList::const_iterator I=p_list.begin();

	int howmany=p_list.size();
	int maxevents=(rowsize-4)/2;
	if (howmany>maxevents)
		howmany=maxevents;
	int maxsize=(rowsize-4)-(howmany-1);

	for (int i=0;i<howmany;I++,i++) {

		NoteListElement note = *I;
		int xofs=font_width+note.pos.column*columnwidth;

		int from=i*maxsize/howmany;
		int to=((i+1)*maxsize/howmany);
		int eheight = to-from;
		if (eheight<=0) eheight=1;
		from+=i;

		//printf("%i - from %i, height %i\n",i,from,eheight);
		//GUI::Color col=color(COLOR_PATTERN_FONT);


		if (note.note.is_note()) {

			switch( Editor::get_singleton()->get_track_edit_mode() ) {
				case Editor::EDIT_MODE_FRONT: {
					GUI::Color bg=GUI::Color(COLOR_PATTERN_NOTE_BG);
					GUI::Color fg=color(COLOR_PATTERN_FONT);
	
					int note_w=get_note_display_column_pos(notewidth,note.note.note);
	
					p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),bg);
					p.draw_fill_rect(GUI::Point(xofs+note_w,eventofs+from),GUI::Size(constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT),eheight),fg);
				} break;

				case Editor::EDIT_MODE_BACK: {

					GUI::Color bg=GUI::Color(COLOR_PATTERN_VOLUME_BG);
					GUI::Color fg=color(COLOR_PATTERN_FONT_VOLUME);
	
					int vol_w=(note.note.volume*notewidth)/PatternTrack::Note::MAX_VOLUME;
					p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),bg);
					p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(vol_w,eheight),fg);
				} break;
			}
		} else if (note.note.is_note_off()) {
			GUI::Color col = color(COLOR_PATTERN_SUBBEAT_LINE); 
			p.draw_fill_rect(GUI::Point(xofs,eventofs+from),GUI::Size(notewidth,eheight),col);
		} else {

			//printf("WTF!!\n");
		}
	}
}
Beispiel #15
0
void draw_ingame_string(float x, float y,const unsigned char * our_string,
						int max_lines,int big)
{
	float u_start,u_end,v_start,v_end;
	int col,row;
	float displayed_font_x_size;
	float displayed_font_y_size;

	float displayed_font_x_width;
	int font_x_size=FONT_X_SPACING;
	int font_y_size=FONT_Y_SPACING;
	int	font_bit_width, ignored_bits;

	unsigned char cur_char;
	int chr;
	int i;
	float cur_x,cur_y;
	int current_lines=0;

	if(big)
		{
			displayed_font_x_size=0.17*zoom_level*name_zoom/3.0;
			displayed_font_y_size=0.25*zoom_level*name_zoom/3.0;
		}
	else
		{
			displayed_font_x_size=SMALL_INGAME_FONT_X_LEN*zoom_level*name_zoom/3.0;
			displayed_font_y_size=SMALL_INGAME_FONT_Y_LEN*zoom_level*name_zoom/3.0;
		}


   	glEnable(GL_ALPHA_TEST);//enable alpha filtering, so we have some alpha key
    glAlphaFunc(GL_GREATER,0.1f);
	get_and_set_texture_id(font_text);

	i=0;
	cur_x=x;
	cur_y=y;
	glBegin(GL_QUADS);
	while(1)
		{
			cur_char=our_string[i];
			if(!cur_char)
				{
					break;
				}
			else if(cur_char=='\n')
				{
					cur_y+=displayed_font_y_size;
					cur_x=x;
					i++;
					current_lines++;
					if(current_lines>=max_lines)break;
					continue;
				}
			else if(cur_char >127 && cur_char<=127+c_grey4)
				{
					glEnd();	//Ooops - NV bug fix!!
				}
			chr=find_font_char(cur_char);
			if(chr >= 0)
				{
					col=chr/FONT_CHARS_PER_LINE;
					row=chr%FONT_CHARS_PER_LINE;


					font_bit_width=get_font_width(chr);
					displayed_font_x_width=((float)font_bit_width)*displayed_font_x_size/12.0;
					ignored_bits=(12-font_bit_width)/2;	// how many bits on each side of the char are ignored?
					if(ignored_bits < 0)ignored_bits=0;

					//now get the texture coordinates
					u_start=(float)(row*font_x_size+ignored_bits)/256.0f;
					u_end=(float)(row*font_x_size+font_x_size-7-ignored_bits)/256.0f;
					v_start=(float)1.0f-(1+col*font_y_size)/256.0f;
					v_end=(float)1.0f-(col*font_y_size+font_y_size-1)/256.0f;
					//v_end=(float)1.0f-(col*font_y_size+font_y_size-2)/256.0f;

					glTexCoord2f(u_start,v_start);
					glVertex3f(cur_x,0,cur_y+displayed_font_y_size);
		
					glTexCoord2f(u_start,v_end);
					glVertex3f(cur_x,0,cur_y);

					glTexCoord2f(u_end,v_end);
					glVertex3f(cur_x+displayed_font_x_width,0,cur_y);

					glTexCoord2f(u_end,v_start);
					glVertex3f(cur_x+displayed_font_x_width,0,cur_y+displayed_font_y_size);
					

					//cur_x+=displayed_font_x_size;
					cur_x+=displayed_font_x_width;
				}
			else if(cur_char >127 && cur_char<=127+c_grey4)
				{
					glBegin(GL_QUADS);	//Ooops - NV bug fix!!
				}

			i++;
		}

    glEnd();
	glDisable(GL_ALPHA_TEST);
}
void TrackEditorPattern::paint_note_event( GUI::Painter& p, int p_row, NoteListElement & p_note, bool p_repeat ) {

	
	GUI::FontID f=font(FONT_TRACK_EDITOR);
	
	GUI::Color font_col=color(COLOR_PATTERN_FONT);
	GUI::Color font_col_repeat=color(COLOR_PATTERN_FONT_REPEAT);
	GUI::Color font_col_vol=color(COLOR_PATTERN_FONT_VOLUME);
	GUI::Color font_col_nofit=color(COLOR_PATTERN_FONT_NOFIT);

	
	int rowsize=get_row_height();
	int fontofs=constant(C_TRACK_EDITOR_ROW_MARGIN);
	int textofs=p_row*rowsize+fontofs+p.get_font_ascent(font(FONT_TRACK_EDITOR));
	int volofs=p_row*rowsize+fontofs+p.get_font_height( font(FONT_TRACK_EDITOR) ) + constant(C_TRACK_EDITOR_VOL_NOTE_BAR_SEPAATION);
	int notewidth=get_font_width()*3;
	int columnwidth=get_font_width()*4;

	int fontxofs=get_font_width()+p_note.pos.column*columnwidth;

	
	Tick row_ticks=Editor::get_singleton()->get_ticks_per_row();
	Tick note_ofs=p_note.pos.tick; //p_row*row_ticksp_note.pos.tick-Editor::get_singleton()->get_row_ticks( Editor::get_singleton()->get_window_offset() ); 
	
	
	if (note_ofs!=0) {
		int pix_ofs=(int)note_ofs*get_row_size()/(int)row_ticks;
		textofs+=pix_ofs;
		volofs+=pix_ofs;
		font_col=font_col_nofit;
		font_col_vol=font_col_nofit;
		font_col_repeat=font_col_vol;
		
	} 


	static char buf[4]={0,0,0,0};
	if (p_note.note.is_note()) {

		switch( Editor::get_singleton()->get_track_edit_mode() ) {

		case Editor::EDIT_MODE_FRONT: { // note


			int note=p_note.note.note % 12;
			int octave = p_note.note.note / 12;

			buf[0]=note_str[note][0];
			buf[1]=note_str[note][1];
			buf[2]=(octave>9)?('A'+(char)(octave-10)):('0'+octave);
			p.draw_text(f,GUI::Point(fontxofs,textofs),buf,font_col);
			// volume

			p.draw_fill_rect(GUI::Point(fontxofs,volofs),GUI::Size(notewidth,constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT)),color(COLOR_PATTERN_VOLUME_BG));
			int vol_w=(p_note.note.volume*notewidth)/PatternTrack::Note::MAX_VOLUME;
			p.draw_fill_rect(GUI::Point(fontxofs,volofs),GUI::Size(vol_w,constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT)),color(COLOR_PATTERN_VOLUME_BAR));

		} break;
		case Editor::EDIT_MODE_BACK: { // volume


			buf[0]=' ';
			buf[1]='0'+p_note.note.volume/10;
			buf[2]='0'+p_note.note.volume%10;
			p.draw_text(f,GUI::Point(fontxofs,textofs),buf,font_col_vol);

			p.draw_fill_rect(GUI::Point(fontxofs,volofs),GUI::Size(notewidth,constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT)),color(COLOR_PATTERN_NOTE_BG));
//check this color later
			int note_w=get_note_display_column_pos(notewidth,p_note.note.note);

			p.draw_fill_rect(GUI::Point(fontxofs+note_w,volofs),GUI::Size(2,constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT)),color(COLOR_PATTERN_NOTE_BAR));
		} break;


		}
		
		GUI::Color col=color(COLOR_PATTERN_SUBBEAT_LINE);
		p.draw_fill_rect(GUI::Point(fontxofs,volofs),GUI::Size(1,constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT)),col);
		p.draw_fill_rect(GUI::Point(size.width-fontxofs,volofs),GUI::Size(1,constant(C_TRACK_EDITOR_VOL_NOTE_BAR_HEIGHT)),col);
		
		
	} else if (p_note.note.is_note_off()) {

		buf[0]='*';
		buf[1]='*';
		buf[2]='*';
		p.draw_text(f,GUI::Point(fontxofs,textofs),buf,font_col);

	}

	// draw volume

	if (p_note.note.is_note()) {
	}



}
void TrackEditorPattern::paint_frames(GUI::Painter& p) {

	int begin_pos=-1;
	int old_block_idx=-1;
	int visible_rows=Editor::get_singleton()->get_window_rows();
	GUI::StyleBox sb=stylebox(SB_PATTERN_BLOCK);
	GUI::StyleBox sb_shared=stylebox(SB_PATTERN_BLOCK_SHARED);
	
	int last_block_idx=-1;
	for (int i=0;i<(visible_rows+3);i++) {
		Tick tick=Editor::get_singleton()->get_row_ticks( Editor::get_singleton()->get_window_offset() + i );
		int block_idx=track->get_block_at_pos(tick);
		if (block_idx!=last_block_idx && block_idx!=-1)
			last_block_idx=block_idx;
			

		bool begin=(block_idx!=-1 && track->get_block_pos(block_idx)==tick);

		if (block_idx!=-1 && i==0 && !begin) {

			begin_pos=-1;
		}

		if (i==0)
			old_block_idx=block_idx;

		bool end=((old_block_idx!=block_idx || i==(visible_rows+2)) && old_block_idx!=-1);
		
		old_block_idx=block_idx;

		if (end) {

			int row_size=get_row_height();
			int begin_h=begin_pos*row_size;
			int len_h=(i-begin_pos)*row_size;

			
			p.draw_stylebox(sb, GUI::Point(0,begin_h),GUI::Size(size.width,len_h));
			
			if (last_block_idx!=-1 && track->get_block(last_block_idx)->get_refcount()>1) {

				p.draw_stylebox(sb_shared, GUI::Point(0,begin_h),GUI::Size(size.width,len_h));
			}
		

		}

		if (begin)
			begin_pos=i;

	}

	
	for (int i=0;i<(track->get_visible_columns()-1);i++ ) {
		
		int font_width=get_font_width();
		int ofs=font_width/2+font_width*4*(i+1);	
		
		p.draw_fill_rect(GUI::Point(ofs,0),GUI::Size(1,size.height),color(COLOR_PATTERN_SUBBEAT_LINE));
	}
	
}
Beispiel #18
0
void draw_ortho_ingame_string(float x, float y,float z, const unsigned char * our_string,
						int max_lines, float font_x_scale, float font_y_scale)
{
	float u_start,u_end,v_start,v_end;
	int col,row;
	float displayed_font_x_size;
	float displayed_font_y_size;

	float displayed_font_x_width;
#ifndef SKY_FPV_OPTIONAL
	int font_x_size=FONT_X_SPACING;
	int font_y_size=FONT_Y_SPACING;
#endif // not SKY_FPV_OPTIONAL
	int	font_bit_width, ignored_bits;

	unsigned char cur_char;
	int chr;
	int i;
	float cur_x,cur_y;
	int current_lines=0;

#ifndef SKY_FPV_OPTIONAL
	/*
	if(big)
		{
			displayed_font_x_size=0.17*zoom_level*name_zoom/3.0;
			displayed_font_y_size=0.25*zoom_level*name_zoom/3.0;
		}
	else
		{
			displayed_font_x_size=SMALL_INGAME_FONT_X_LEN*zoom_level*name_zoom/3.0;
			displayed_font_y_size=SMALL_INGAME_FONT_Y_LEN*zoom_level*name_zoom/3.0;
		}
	*/
#endif // not SKY_FPV_OPTIONAL
	displayed_font_x_size=font_x_scale*name_zoom*12.0;
	displayed_font_y_size=font_y_scale*name_zoom*12.0;

	glEnable(GL_ALPHA_TEST);//enable alpha filtering, so we have some alpha key
	glAlphaFunc(GL_GREATER,0.1f);
#ifdef	NEW_TEXTURES
	bind_texture(font_text);
#else	/* NEW_TEXTURES */
	get_and_set_texture_id(font_text);
#endif	/* NEW_TEXTURES */

	i=0;
	cur_x=x;
	cur_y=y;
	glBegin(GL_QUADS);
#ifndef SKY_FPV_OPTIONAL
	while(1)
		{
			cur_char=our_string[i];
			if(!cur_char)
				{
					break;
				}
			else if(cur_char=='\n')
				{
					cur_y+=displayed_font_y_size;
					cur_x=x;
					i++;
					current_lines++;
					if(current_lines>=max_lines)break;
					continue;
				}
			else if (is_color (cur_char))
				{
					glEnd();	//Ooops - NV bug fix!!
				}
			chr=find_font_char(cur_char);
			if(chr >= 0)
				{
					col=chr/FONT_CHARS_PER_LINE;
					row=chr%FONT_CHARS_PER_LINE;


					font_bit_width=get_font_width(chr);
					displayed_font_x_width=((float)font_bit_width)*displayed_font_x_size/12.0;
					ignored_bits=(12-font_bit_width)/2;	// how many bits on each side of the char are ignored?
					if(ignored_bits < 0)ignored_bits=0;

					//now get the texture coordinates
					u_start=(float)(row*font_x_size+ignored_bits)/256.0f;
					u_end=(float)(row*font_x_size+font_x_size-7-ignored_bits)/256.0f;
#ifdef NEW_TEXTURES
					v_start=(float)(1+col*font_y_size)/256.0f;
					v_end=(float)(col*font_y_size+font_y_size-1)/256.0f;
#else
					v_start=(float)1.0f-(1+col*font_y_size)/256.0f;
					v_end=(float)1.0f-(col*font_y_size+font_y_size-1)/256.0f;
#endif //NEW_TEXTURES
					//v_end=(float)1.0f-(col*font_y_size+font_y_size-2)/256.0f;

					glTexCoord2f(u_start,v_start);
					glVertex3f(cur_x,cur_y+displayed_font_y_size,z);

					glTexCoord2f(u_start,v_end);
					glVertex3f(cur_x,cur_y,z);

					glTexCoord2f(u_end,v_end);
					glVertex3f(cur_x+displayed_font_x_width,cur_y,z);

					glTexCoord2f(u_end,v_start);
					glVertex3f(cur_x+displayed_font_x_width,cur_y+displayed_font_y_size,z);


					//cur_x+=displayed_font_x_size;
					cur_x+=displayed_font_x_width;
				}
			else if (is_color (cur_char))
				{
					glBegin(GL_QUADS);	//Ooops - NV bug fix!!
				}

#else // SKY_FPV_OPTIONAL
	while(1){
		cur_char=our_string[i];
		if(!cur_char){
			break;
		} else if(cur_char=='\n'){
			cur_y+=displayed_font_y_size;
			cur_x=x;
#endif // SKY_FPV_OPTIONAL
			i++;
#ifdef SKY_FPV_OPTIONAL
			current_lines++;
			if(current_lines>=max_lines)break;
			continue;
		} else if (is_color (cur_char)){
			glEnd();	//Ooops - NV bug fix!!
			glBegin(GL_QUADS);
		}
		chr=find_font_char(cur_char);
		if(chr >= 0){
			col=chr/FONT_CHARS_PER_LINE;
			row=chr%FONT_CHARS_PER_LINE;

			font_bit_width=get_font_width(chr);
			displayed_font_x_width=((float)font_bit_width)*displayed_font_x_size/12.0;
			ignored_bits=(12-font_bit_width)/2;	// how many bits on each side of the char are ignored?
			if(ignored_bits < 0)ignored_bits=0;

			//now get the texture coordinates
			u_start=(float)(row*FONT_X_SPACING+ignored_bits)/256.0f;
			u_end=(float)(row*FONT_X_SPACING+FONT_X_SPACING-7-ignored_bits)/256.0f;
#ifdef NEW_TEXTURES
			v_start=(float)(1+col*FONT_Y_SPACING)/256.0f;
			v_end=(float)(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#else
			v_start=(float)1.0f-(1+col*FONT_Y_SPACING)/256.0f;
			v_end=(float)1.0f-(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#endif //NEW_TEXTURES

			glTexCoord2f(u_start,v_start);
			glVertex3f(cur_x,cur_y+displayed_font_y_size,z);

			glTexCoord2f(u_start,v_end);
			glVertex3f(cur_x,cur_y,z);

			glTexCoord2f(u_end,v_end);
			glVertex3f(cur_x+displayed_font_x_width,cur_y,z);

			glTexCoord2f(u_end,v_start);
			glVertex3f(cur_x+displayed_font_x_width,cur_y+displayed_font_y_size,z);

			cur_x+=displayed_font_x_width;
		} else if(is_color (cur_char)){
			glEnd();	//Ooops - NV bug fix!!
			glBegin(GL_QUADS);
#endif // SKY_FPV_OPTIONAL
		}
#ifdef SKY_FPV_OPTIONAL
	i++;
	}
#endif // SKY_FPV_OPTIONAL

	glEnd();
	glDisable(GL_ALPHA_TEST);
}

void draw_ingame_string(float x, float y,const unsigned char * our_string,
						int max_lines, float font_x_scale, float font_y_scale)
{
	float u_start,u_end,v_start,v_end;
	int col,row;
	float displayed_font_x_size;
	float displayed_font_y_size;

	float displayed_font_x_width;
#ifndef SKY_FPV_OPTIONAL
	//int font_x_size=FONT_X_SPACING;
	//int font_y_size=FONT_Y_SPACING;
#endif // not SKY_FPV_OPTIONAL
	int	font_bit_width, ignored_bits;

	unsigned char cur_char;
	int chr;
	int i;
	float cur_x,cur_y;
	int current_lines=0;
#ifdef SKY_FPV_OPTIONAL
	double model[16], proj[16],hx,hy,hz;
	int view[4];

	displayed_font_x_size=font_x_scale*name_zoom*12.0*font_scale;
	displayed_font_y_size=font_y_scale*name_zoom*12.0*font_scale;

	glGetDoublev(GL_MODELVIEW_MATRIX, model);
	glGetDoublev(GL_PROJECTION_MATRIX, proj);
	glGetIntegerv(GL_VIEWPORT, view);
	gluProject((double)x,0.0f,(double)y,model, proj, view, &hx,&hy,&hz);
	glPushMatrix();
	glLoadIdentity();
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(view[0],view[2]+view[0],view[1],view[3]+view[1],0.0f,-1.0f);
#endif // SKY_FPV_OPTIONAL

#ifndef SKY_FPV_OPTIONAL
	displayed_font_x_size=font_x_scale*zoom_level*name_zoom/3.0;
	displayed_font_y_size=font_y_scale*zoom_level*name_zoom/3.0;
#endif // not SKY_FPV_OPTIONAL

	glEnable(GL_ALPHA_TEST);//enable alpha filtering, so we have some alpha key
	glAlphaFunc(GL_GREATER,0.1f);
#ifdef	NEW_TEXTURES
	bind_texture(font_text);
#else	/* NEW_TEXTURES */
	get_and_set_texture_id(font_text);
#endif	/* NEW_TEXTURES */

	i=0;
#ifndef SKY_FPV_OPTIONAL
	cur_x=x;
	cur_y=y;
#else // SKY_FPV_OPTIONAL
	cur_x=hx;
	cur_y=hy;
#endif // SKY_FPV_OPTIONAL
	glBegin(GL_QUADS);
#ifndef SKY_FPV_OPTIONAL
	while(1)
		{
			cur_char=our_string[i];
			if(!cur_char)
				{
					break;
				}
			else if(cur_char=='\n')
				{
					cur_y+=displayed_font_y_size;
					cur_x=x;
					i++;
					current_lines++;
					if(current_lines>=max_lines)break;
					continue;
				}
			else if(is_color (cur_char))
				{
					glEnd();	//Ooops - NV bug fix!!
				}
			chr=find_font_char(cur_char);
			if(chr >= 0)
				{
					col=chr/FONT_CHARS_PER_LINE;
					row=chr%FONT_CHARS_PER_LINE;

					font_bit_width=get_font_width(chr);
					displayed_font_x_width=((float)font_bit_width)*displayed_font_x_size/12.0;
					ignored_bits=(12-font_bit_width)/2;	// how many bits on each side of the char are ignored?
					if(ignored_bits < 0)ignored_bits=0;

					//now get the texture coordinates
					u_start=(float)(row*FONT_X_SPACING+ignored_bits)/256.0f;
					u_end=(float)(row*FONT_X_SPACING+FONT_X_SPACING-7-ignored_bits)/256.0f;
#ifdef NEW_TEXTURES
					v_start=(float)(1+col*FONT_Y_SPACING)/256.0f;
					v_end=(float)(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#else
					v_start=(float)1.0f-(1+col*FONT_Y_SPACING)/256.0f;
					v_end=(float)1.0f-(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#endif //NEW_TEXTURES

					glTexCoord2f(u_start,v_start);
					glVertex3f(cur_x,0,cur_y+displayed_font_y_size);

					glTexCoord2f(u_start,v_end);
					glVertex3f(cur_x,0,cur_y);

					glTexCoord2f(u_end,v_end);
					glVertex3f(cur_x+displayed_font_x_width,0,cur_y);

					glTexCoord2f(u_end,v_start);
					glVertex3f(cur_x+displayed_font_x_width,0,cur_y+displayed_font_y_size);

					cur_x+=displayed_font_x_width;
				}
			else if (is_color (cur_char))
				{
					glBegin(GL_QUADS);	//Ooops - NV bug fix!!
				}
#else // SKY_FPV_OPTIONAL
	while(1){
		cur_char=our_string[i];
		if(!cur_char){
			break;
		}else if(cur_char=='\n'){
			cur_y+=displayed_font_y_size;
			cur_x=hx;
#endif // SKY_FPV_OPTIONAL
			i++;
#ifdef SKY_FPV_OPTIONAL
			current_lines++;
			if(current_lines>=max_lines)break;
			continue;
		}
		else if (is_color (cur_char))
		{
			glEnd();	//Ooops - NV bug fix!!
			glBegin(GL_QUADS);
		}
		chr=find_font_char(cur_char);
		if(chr >= 0){
			col=chr/FONT_CHARS_PER_LINE;
			row=chr%FONT_CHARS_PER_LINE;

			font_bit_width=get_font_width(chr);
			displayed_font_x_width=((float)font_bit_width)*displayed_font_x_size/12.0;
			ignored_bits=(12-font_bit_width)/2;	// how many bits on each side of the char are ignored?
			if(ignored_bits < 0)ignored_bits=0;

			//now get the texture coordinates
			u_start=(float)(row*FONT_X_SPACING+ignored_bits)/256.0f;
			u_end=(float)(row*FONT_X_SPACING+FONT_X_SPACING-7-ignored_bits)/256.0f;
#ifdef NEW_TEXTURES
			v_start=(float)(1+col*FONT_Y_SPACING)/256.0f;
			v_end=(float)(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#else
			v_start=(float)1.0f-(1+col*FONT_Y_SPACING)/256.0f;
			v_end=(float)1.0f-(col*FONT_Y_SPACING+FONT_Y_SPACING-1)/256.0f;
#endif // NEW_TEXTURES

			glTexCoord2f(u_start,v_start);
			glVertex3f(cur_x,cur_y+displayed_font_y_size,0);

			glTexCoord2f(u_start,v_end);
			glVertex3f(cur_x,cur_y,0);

			glTexCoord2f(u_end,v_end);
			glVertex3f(cur_x+displayed_font_x_width,cur_y,0);

			glTexCoord2f(u_end,v_start);
			glVertex3f(cur_x+displayed_font_x_width,cur_y+displayed_font_y_size,0);

			cur_x+=displayed_font_x_width;
		}
		else if (is_color (cur_char))
		{
			glEnd();	//Ooops - NV bug fix!!
			glBegin(GL_QUADS);
#endif // SKY_FPV_OPTIONAL
		}
#ifdef SKY_FPV_OPTIONAL
		i++;
	}
#endif // SKY_FPV_OPTIONAL

	glEnd();
	glDisable(GL_ALPHA_TEST);
#ifdef SKY_FPV_OPTIONAL
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

#endif // SKY_FPV_OPTIONAL
}
#endif //!MAP_EDITOR_2
#endif	//ELC



// font handling
int get_font_width(int cur_char)
{
	// ignore unknown characters
	if (cur_char < 0) {
		return 0;
	}
	// return width of character + spacing between chars (supports variable width fonts)
	return (fonts[cur_font_num]->widths[cur_char] + fonts[cur_font_num]->spacing);
}

int get_char_width(unsigned char cur_char)
{
	return get_font_width(get_font_char(cur_char));
}


int get_string_width(const unsigned char *str)
{
	return get_nstring_width(str, strlen((char*)str));
}


int get_nstring_width(const unsigned char *str, int len)
{
	int	i, wdt=0;

	for(i=0; i<len; i++) {
		wdt+= get_char_width(str[i]);
	}

	// adjust to ignore the final spacing
	wdt-= fonts[cur_font_num]->spacing;

	return wdt;
}
Beispiel #19
0
static void begin_print(GtkPrintOperation *operation, GtkPrintContext *context, gpointer user_data)
{
	DocInfo *dinfo = user_data;
	PangoFontDescription *desc;
	gint i;
	gint style_max;

	if (dinfo == NULL)
		return;

	gtk_widget_show(main_widgets.progressbar);

	desc = pango_font_description_from_string(interface_prefs.editor_font);

	/* init dinfo fields */
	dinfo->lines = sci_get_line_count(dinfo->doc->editor->sci);
	dinfo->lines_per_page = 0;
	dinfo->cur_line = 0;
	dinfo->cur_pos = 0;
	dinfo->long_line = FALSE;
	dinfo->print_time = time(NULL);
	dinfo->max_line_number_margin = get_line_numbers_arity(dinfo->lines) + 1;
	/* increase font width by 1 (looks better) */
	dinfo->font_width = get_font_width(context, desc) + 1;
	/* create a PangoLayout to be commonly used in get_page_count and draw_page */
	dinfo->layout = setup_pango_layout(context, desc);
	/* this is necessary because of possible line breaks on the printed page and then
	 * lines_per_page differs from document line count */
	dinfo->n_pages = get_page_count(context, dinfo);

	/* read all styles from Scintilla */
	style_max = pow(2, scintilla_send_message(dinfo->doc->editor->sci, SCI_GETSTYLEBITS, 0, 0));
	/* if the lexer uses only the first 32 styles(style bits = 5),
	 * we need to add the pre-defined styles */
	if (style_max == 32)
		style_max = STYLE_LASTPREDEFINED;
	for (i = 0; i < style_max; i++)
	{
		dinfo->styles[i][FORE] = ROTATE_RGB(scintilla_send_message(
			dinfo->doc->editor->sci, SCI_STYLEGETFORE, i, 0));
		if (i == STYLE_LINENUMBER)
		{	/* ignore background colour for line number margin to avoid trouble with wrapped lines */
			dinfo->styles[STYLE_LINENUMBER][BACK] = ROTATE_RGB(scintilla_send_message(
				dinfo->doc->editor->sci, SCI_STYLEGETBACK, STYLE_DEFAULT, 0));
		}
		else
		{
			dinfo->styles[i][BACK] = ROTATE_RGB(scintilla_send_message(
				dinfo->doc->editor->sci, SCI_STYLEGETBACK, i, 0));
		}
		/* use white background color unless foreground is white to save ink */
		if (dinfo->styles[i][FORE] != 0xffffff)
			dinfo->styles[i][BACK] = 0xffffff;
		dinfo->styles[i][BOLD] =
			scintilla_send_message(dinfo->doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
		dinfo->styles[i][ITALIC] =
			scintilla_send_message(dinfo->doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
	}

	if (dinfo->n_pages >= 0)
		gtk_print_operation_set_n_pages(operation, dinfo->n_pages);

	pango_font_description_free(desc);
}
Beispiel #20
0
static void
e_contact_print_contact (EContact *contact,
                         EContactPrintContext *ctxt)
{
	GtkPageSetup *setup;
	gchar *file_as;
	cairo_t *cr;
	gdouble page_height;
	gint field;

	setup = gtk_print_context_get_page_setup (ctxt->context);
	page_height = gtk_page_setup_get_page_height (setup, GTK_UNIT_POINTS);

	cr = gtk_print_context_get_cairo_context (ctxt->context);
	cairo_save (cr);
	ctxt->y += get_font_height (ctxt->style->headings_font) * .2;

	file_as = e_contact_get (contact, E_CONTACT_FILE_AS);

	if (ctxt->style->print_using_grey && ctxt->pages == ctxt->page_nr) {
		cairo_save (cr);
		cairo_set_source_rgb (cr, .85, .85, .85);
		cairo_rectangle (cr, ctxt->x, ctxt->y, ctxt->column_width,
			e_contact_text_height (ctxt->context,
				ctxt->style->headings_font, file_as));
		cairo_fill (cr);
		cairo_restore (cr);
	}

	if (ctxt->pages == ctxt->page_nr)
		e_contact_output (
			ctxt->context, ctxt->style->headings_font,
			ctxt->x, ctxt->y, ctxt->column_width + 4, file_as);
	ctxt->y += e_contact_text_height (
		ctxt->context, ctxt->style->headings_font, file_as);

	g_free (file_as);

	ctxt->y += get_font_height (ctxt->style->headings_font) * .2;

	for (field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++)
	{
		const gchar *value;
		gchar *text;
		gint wrapped_lines = 0;

		if (ctxt->y > page_height)
			e_contact_start_new_column (ctxt);

		value = e_contact_get_const (contact, field);
		if (value == NULL || *value == '\0')
			continue;

		text = g_strdup_printf ("%s:  %s",
			e_contact_pretty_name (field), value);

		if (ctxt->pages == ctxt->page_nr)
			e_contact_output (
				ctxt->context, ctxt->style->body_font,
				ctxt->x, ctxt->y, ctxt->column_width + 4, text);

		if (get_font_width (ctxt->context,
			ctxt->style->body_font, text) > ctxt->column_width)
			wrapped_lines =
				(get_font_width (ctxt->context,
				ctxt->style->body_font, text) /
				(ctxt->column_width + 4)) + 1;
		ctxt->y =
			ctxt->y + ((wrapped_lines + 1) *
			e_contact_text_height (ctxt->context,
			ctxt->style->body_font, text));

		ctxt->y += .2 * get_font_height (ctxt->style->body_font);

		g_free (text);
	}

	ctxt->y += get_font_height (ctxt->style->headings_font) * .4 + 8;

	cairo_restore (cr);
}
Beispiel #21
0
int get_char_width(unsigned char cur_char)
{
	return get_font_width(get_font_char(cur_char));
}
Beispiel #22
0
static LRESULT CALLBACK
startup_wnd_proc(
	HWND		hWnd,
	UINT		uMsg,
	WPARAM		wParam,
	LPARAM		lParam)
{
	MSG				msg;
	Sint32			screenType;
	Sint32			drawMode;
	Sint32			drawMethod;
	Sint32			vsync;
	Sint32			psgType;
	Sint32			soundBuffer;

	switch (uMsg)
	{
	case WM_CREATE:
		EnableWindow(WINMAIN_GetHwnd(), FALSE);//メインウィンドウを無効化してモーダルに。
		_hFontB = CreateFont(  0,						// 高さ。0 = デフォルト
		                       0,						// 幅。0なら高さに合った幅
    		                   0,						// 角度
        		               0,						// ベースラインとの角度
            		           FW_NORMAL,				// 太さ
                		       FALSE,					// イタリック
	                    	   FALSE,					// アンダーライン
		                       FALSE,					// 打ち消し線
    		                   0,						// 日本語を取り扱うときはSHIFTJIS_CHARSETにする。
        		               0,						// 出力精度
            		           0,						// クリッピング精度
                		       0,						// 出力品質
                    		   0,						// ピッチとファミリー
		                       ""						// 書体名
							); //英語のデフォルトフォントに設定
		_FontWidth	= get_font_width(hWnd);
		_FontHeight = get_font_height(hWnd);
		set_window_size(hWnd);
		break;

	case WM_PAINT:
		update_window(hWnd);
		break;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
			case BUTTON_CDROM:
				_CDorHu = 1; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_CUE:
				_CDorHu = 2; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_HUCARD:
				_CDorHu = 3; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_REPLAY:
				_CDorHu = 4; //戻り値を設定
				PostMessage(hWnd, WM_CLOSE, 0, 0);
				break;
			case BUTTON_OPTION:
				soundBuffer = 0; //全項目の値が設定されたかどうかの判断にも使用。
				OPTION_Init(_hInstance, &screenType, &drawMode, &drawMethod, &vsync, &psgType, &soundBuffer); //Optionウィンドウを表示
				//メッセージループ
				while (soundBuffer == 0) //ダイアログが結果を返すまでループ
				{ 
					GetMessage(&msg ,NULL, 0, 0);
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
				//Ok(SET)ボタンが押されていた場合、スクリーン設定を変更する。
				if (screenType > 0)
				{
					switch (screenType)
					{
						case 1:	APP_SetStartFullScreen(FALSE); break;
						case 2:
							APP_SetMagnification(2); //x2倍に設定
							APP_SetStartFullScreen(FALSE);
							break;
						case 3:
							APP_SetMagnification(3); //x3倍に設定
							APP_SetStartFullScreen(FALSE);
							break;
						case 4:
							APP_SetMagnification(4); //x4倍に設定
							APP_SetStartFullScreen(FALSE);
							break;
						case 5:	APP_SetStartFullScreen(TRUE); break;
						case 6:
							APP_SetFullScreen640(); //640x480に設定
							APP_SetStartFullScreen(TRUE);
							break;
					}
				}
				//Ok(SET)ボタンが押されていた場合、DrawMode設定を変更する。
				if (drawMode > 0)
				{
					switch (drawMode)
					{
						case 1: APP_SetScanLineType(1,TRUE); break;
						case 2: APP_SetScanLineType(4,TRUE); break;
						case 3: APP_SetScanLineType(2,TRUE); break;
						case 4: APP_SetScanLineType(0,TRUE); break;
					}
				}
				//Ok(SET)ボタンが押されていた場合、DrawMethod設定を変更する。
				if (drawMethod > 0)
				{
					APP_SetDrawMethod(drawMethod);
				}
				//Ok(SET)ボタンが押されていた場合、V-Sync設定を変更する。
				if (screenType > 0)
				{
					if (vsync == 2)
						APP_SetSyncTo60HzScreen(FALSE);
					else //==1
						APP_SetSyncTo60HzScreen(TRUE);
				}
				//Ok(SET)ボタンが押されていた場合、PSGクォリティ設定を変更する。
				if (psgType > 0)
				{
					if (psgType == 3)
						APP_SetPsgQuality(1);
					else if (psgType == 2)
						APP_SetPsgQuality(2);
					else //==1
						APP_SetPsgQuality(4);
				}
				//Ok(SET)ボタンが押されていた場合、PSGクォリティ設定を変更する。
				if (soundBuffer > 0)
				{
					switch (soundBuffer)
					{
						case  1: APP_SetSoundBufferSize(1024); break;
						case  2: APP_SetSoundBufferSize(1152); break;
						case  3: APP_SetSoundBufferSize(1280); break;
						case  4: APP_SetSoundBufferSize(1408); break;
						case  5: APP_SetSoundBufferSize(1536); break;
						case  7: APP_SetSoundBufferSize(1792); break;
						case  8: APP_SetSoundBufferSize(2048); break;
						case  9: APP_SetSoundBufferSize(2176); break;
						case 10: APP_SetSoundBufferSize(2304); break;
						case 11: APP_SetSoundBufferSize(2560); break;
						case 12: APP_SetSoundBufferSize(3072); break;
						default: //==6
							APP_SetSoundBufferSize(1664); break;
					}
				}
				break;
		}
		break;

	case WM_KEYDOWN:
		if (wParam == VK_ESCAPE)
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		if ((wParam == 'C')||(wParam == VK_RETURN)) //「C」キーまたは 「Enter」キー
		{
			_CDorHu = 1; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		if (wParam == 'P') //「P」キー
		{
			_CDorHu = 2; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		if ((wParam == 'H')||(wParam == 'O')||(wParam == VK_SPACE)) //「H」キー「O」キーまたは スペースキー
		{
			_CDorHu = 3; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		if (wParam == 'R') //「R」キー
		{
			_CDorHu = 4; //戻り値を設定
			PostMessage(hWnd, WM_CLOSE, 0, 0);
		}
		break;

	case WM_CLOSE:
		STARTUP_Deinit();
		return 0;
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}