コード例 #1
0
void repaint_cover () {
	if (mainwindow_data.loading_skin) return;

 	gdk_window_copy_area (mainwindow_data.drawing_area->window,
    			      mainwindow_data.drawing_area->style->fg_gc[GTK_STATE_NORMAL],
    			      0,0,
    			      mainwindow_data.dbuf_pixmap,
    			      0,0,
			      plugin_config->skin_width,
			      plugin_config->skin_height);
}
コード例 #2
0
// Redraw parts of the window if requestet
void mainwindow_sigexpose (GtkWidget *widget,GdkEventExpose *event,gpointer data) {
	if (mainwindow_data.loading_skin) return;

	if (mainwindow_data.loading_cover==FALSE) {
		// Don't repaint entire window upon each exposure
  		gdk_window_set_back_pixmap (widget->window, NULL, FALSE);

  		// Refresh double buffer, then copy the "dirtied" area to
   		// the on-screen GdkWindow
  		gdk_window_copy_area(widget->window,
    			widget->style->fg_gc[GTK_STATE_NORMAL],
    			event->area.x, event->area.y,
    			mainwindow_data.dbuf_pixmap,
    			event->area.x, event->area.y,
    			event->area.width, event->area.height);
	}
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_copyArea
  (JNIEnv *env, jobject obj, jint x, jint y, 
   jint width, jint height, jint dx, jint dy)
{
  struct graphics *g;

  g = (struct graphics *) NSA_GET_PTR (env, obj);

  gdk_threads_enter ();
  gdk_window_copy_area ((GdkWindow *)g->drawable,
			g->gc,
			x + g->x_offset + dx, y + g->y_offset + dy,
			(GdkWindow *)g->drawable,
			x + g->x_offset, y + g->y_offset,
			width, height);
  gdk_flush ();
  gdk_threads_leave ();
}
JNIEXPORT void JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphics_copyPixmap
  (JNIEnv *env, jobject obj, jobject offscreen, 
   jint x, jint y, jint width, jint height)
{
  struct graphics *g1, *g2;

  g1 = (struct graphics *) NSA_GET_PTR (env, obj);
  g2 = (struct graphics *) NSA_GET_PTR (env, offscreen);

  gdk_threads_enter ();
  gdk_window_copy_area ((GdkWindow *)g1->drawable,
			g1->gc,
			x + g1->x_offset, y + g1->y_offset,
			(GdkWindow *)g2->drawable,
			0 + g2->x_offset, 0 + g2->y_offset, 
			width, height);
  gdk_flush ();
  gdk_threads_leave ();
}
コード例 #5
0
ファイル: horiz_specgram.c プロジェクト: UIKit0/eXtace
void draw_horiz_specgram()
{
	active_drawing_area = height-(2*border);
	gdk_threads_enter();
	if (display_markers)
	{
                update_freq_markers();
                clear_display = FALSE;
                display_markers = FALSE;
	}
	gdk_window_copy_area(main_pixmap,gc,
			0,border,
			main_pixmap,
			tape_scroll,border,
			width-horiz_spec_start,
			active_drawing_area);

	reducer(low_freq, high_freq, active_drawing_area);

	for (i=0; i < active_drawing_area; i++)
	{
		lvl=(gint)pip_arr[i]*4;
		if (lvl > (MAXBANDS-1))
			lvl=(MAXBANDS-1);
		gdk_gc_set_foreground(gc,&colortab[16][lvl]);

		gdk_draw_line(main_pixmap,gc,
				width-horiz_spec_start-tape_scroll, 
				active_drawing_area-i+border,
				width-horiz_spec_start,
				active_drawing_area-i+border);
	}

	gdk_window_clear(main_display->window);

	gdk_threads_leave();
}
コード例 #6
0
ファイル: spike_3d.c プロジェクト: djandruczyk/eXtace
void draw_spike_3d()
{
	extern gfloat det_axis_angle;
	gdk_threads_enter();
	gdk_window_copy_area(main_pixmap,gc,
			0,0,
			main_pixmap,
			xdet_scroll,
			zdet_scroll,
			width-xdet_scroll,
			height-zdet_scroll);
	if (xdet_scroll > 0)
	{
		gdk_draw_rectangle(main_pixmap,
				main_display->style->black_gc,
				TRUE, width-xdet_scroll,0,
				xdet_scroll,height);
	}
	else
	{
		gdk_draw_rectangle(main_pixmap,
				main_display->style->black_gc,
				TRUE, 0,0,
				abs(xdet_scroll),height);
	}

	if (zdet_scroll > 0)
	{
		gdk_draw_rectangle(main_pixmap,
				main_display->style->black_gc,
				TRUE, 0,height-zdet_scroll,
				width,zdet_scroll);
	}
	else
	{
		gdk_draw_rectangle(main_pixmap,
				main_display->style->black_gc,
				TRUE, 0,0,
				width,abs(zdet_scroll));
	}
	gdk_threads_leave();

	/* in pixels */
	x_draw_width = width - abs(xdet_scroll)-2*border;
	y_draw_height = height - abs(zdet_scroll)-2*border;

	/* in pixels */
	x_offset = (width-x_draw_width)/2;
	y_offset = (height-y_draw_height)/2;


	det_axis_angle_deg = det_axis_angle*90/M_PI_2;
	if (det_axis_angle_deg < 0.0)
		det_axis_angle_deg += 360.0;

	dir_angle_rad = (float)atan2((float)zdet_scroll,-(float)xdet_scroll);
	dir_angle_deg = dir_angle_rad*90/M_PI_2;
	if (dir_angle_deg < 0.0)
		dir_angle_deg += 360.0;


	if (spiketilt == FALSE)
	{
		x_tilt=0.0;
		y_tilt=0.0;
	}
	else
	{
		/* Perspecitve Tilting algorithm.  Probably severely flawed
		 * but it displays nicely..  
		 * 
		 * Note to self.  Learn how to use Trig properly... :)
		 */ 
		if ((dir_angle_deg >= 315.0) || (dir_angle_deg < 45.0))
		{
			//printf("Quad 4<->1\n");
			x_tilt = sin(dir_angle_rad);
			y_tilt = cos(dir_angle_rad);
		}
		else if ((dir_angle_deg >= 45.0) && (dir_angle_deg < 135.0))
		{
			//printf("Quad 1<->2\n");
			x_tilt = cos(dir_angle_rad);
			y_tilt = sin(dir_angle_rad);
		}
		else if ((dir_angle_deg >= 135.0) && (dir_angle_deg < 225.0))
		{
			//printf("Quad 2<->3\n");
			x_tilt = -sin(dir_angle_rad);
			y_tilt = -cos(dir_angle_rad);
		}
		else if  ((dir_angle_deg >= 225.0) && (dir_angle_deg < 315.0))
		{
			//printf("Quad 3<->4\n");
			x_tilt = -cos(dir_angle_rad);
			y_tilt = -sin(dir_angle_rad);
		}
	}

	x_axis_tilt = sin(det_axis_angle);
	y_axis_tilt = cos(det_axis_angle);

	x_tilt_weight = cos(det_axis_angle);
	y_tilt_weight = 0.0;
	x_axis_weight = 1.0;
	y_axis_weight = 1.0;

/*
	// Debugging Code....  

	printf("axis angle in deg is %f\n",det_axis_angle_deg);
	printf("direction angle in deg is %f\n",dir_angle_deg);
	printf("\nx_tilt %f, y_tilt %f\n",x_tilt,y_tilt);
	printf("x_tilt_weight %f, y_tilt_weight %f\n",x_tilt_weight,y_tilt_weight);
	printf("Scroll Tilt components (%f,%f)\n",x_tilt*x_tilt_weight,y_tilt*y_tilt_weight);
	printf("x_axis_tilt %f, y_axis_tilt %f\n",x_axis_tilt,y_axis_tilt);
	printf("x_axis_weight %f, y_axis_weight %f\n",x_axis_weight,y_axis_weight);
	printf("Perspective Tilt components (%f,%f)\n\n",x_axis_tilt*x_axis_weight,y_axis_tilt*y_axis_weight);
	
*/

	/* in pixels */
	start_x = width-((x_draw_width)*(1.0-xdet_end))-x_offset;
	end_x = width-((x_draw_width)*(1.0-xdet_start))-x_offset;
	start_y = height-((y_draw_height)*(1.0-ydet_end))-y_offset;
	end_y = height-((y_draw_height)*(1.0-ydet_start))-y_offset;

	/* in pixels */
	start_x = width-((x_draw_width)*(1.0-xdet_end))-x_offset;
	end_x = width-((x_draw_width)*(1.0-xdet_start))-x_offset;
	start_y = height-((y_draw_height)*(1.0-ydet_end))-y_offset;
	end_y = height-((y_draw_height)*(1.0-ydet_start))-y_offset;
	/* end_x - start_x is X screen space in pixels 
	 * the idea is to reduce the number of gdk_draw_lines to 
	 * the number in axis_length, instead of nsamp/2. which saves drawing 
	 * over the same location on the screen and wasting time.
	 * I guess when combining pips together we should AVG them. What
	 * other way might be better? (suggestions welcome...)
	 */

	/* disp_val[] is a malloc'd array storing pip values for ALL pips, 
	 * (1/2 NSAMP). pip_arr[] is malloc'd array that is length 
	 * "axis_length"and contains anti-aliased reduction of 
	 * disp[val] using linear interpolation to combine/average 
	 * multiple pip values into one viewable spike. Should be 
	 * fully scaling with best results of having bins_per_pip 
	 * being a multiple of nsamp/2.
	 */
	axis_length = (gint)sqrt(((end_x-start_x)*(end_x-start_x))+((end_y-start_y)*(end_y-start_y)));
	loc_bins_per_pip = ((float)nsamp/2.0)/(fabs(axis_length));

	reducer(low_freq, high_freq, axis_length);
	gdk_threads_enter();

	/* Do this here instead of in the loop  axis_length number of times..
	 * cpu savings... :)
	 */
	x_amplitude = (x_tilt*x_tilt_weight)+(x_axis_tilt*x_axis_weight);
	y_amplitude = (y_tilt*y_tilt_weight)+(y_axis_tilt*y_axis_weight);

	for( i=0; i < axis_length; i++ )
	{
		pt[0].x=width-(((i*x_draw_width)*(1-xdet_start))/axis_length)\
				-((((axis_length-i)*x_draw_width)*(1-xdet_end))\
				/(axis_length))-x_offset;
		pt[0].y=height-(((i*loc_bins_per_pip)*y_draw_height*ydet_start)\
				/(nsamp/2))-((((nsamp/2)-(i*loc_bins_per_pip))\
				*y_draw_height*ydet_end)/(nsamp/2))\
				-y_offset;
		pt[1].x=pt[0].x -(gint)pip_arr[i]*x_amplitude;
		pt[1].y=pt[0].y -(gint)pip_arr[i]*y_amplitude; \
		lvl=abs((gint)pip_arr[i]*4);
		if (lvl > (MAXBANDS-1))
			lvl=(MAXBANDS-1);
		else if (lvl <= 0)
			lvl = 0;

		gdk_gc_set_foreground(gc,&colortab[16][lvl]);

		gdk_draw_line(main_pixmap,gc,\
				pt[0].x,\
				pt[0].y,\
				pt[1].x,\
				pt[1].y);
	}
	gdk_window_clear(main_display->window);

	gdk_threads_leave();
}
コード例 #7
0
static void
gtk_border_combo_update (GtkWidget * widget, GtkBorderCombo * border_combo)
{
  gint i,j;
  gint focus_row = -1, focus_col = -1;
  gint new_row = -1, new_col = -1;
  gint new_selection=FALSE;
  gint row,column;
  GdkPixmap *window;

  row=border_combo->row;
  column=border_combo->column;

  for(i=0 ; i<border_combo->nrows; i++)
    for(j=0; j<border_combo->ncols; j++){    
      if(GTK_WIDGET_HAS_FOCUS(border_combo->button[i][j])){
            focus_row=i;
            focus_col=j;
      }
      if(border_combo->button[i][j]->state==GTK_STATE_ACTIVE){
        if(i != row || j != column){
            new_selection=TRUE;
            new_row=i;
            new_col=j;
        }
      }
    }

  if(!new_selection && focus_row >= 0 && focus_col >= 0){
     if(focus_row != row || focus_col != column){
       new_selection = TRUE;
       new_row=focus_row;
       new_col=focus_col;
     }
  }

  if(new_selection){
      if(row >= 0 && column >= 0){
          gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(border_combo->button[row][column]), FALSE);
          gtk_widget_queue_draw(border_combo->button[row][column]);
      }
      border_combo->row=new_row;
      border_combo->column=new_col;
      window=GTK_PIXMAP(GTK_BIN(GTK_COMBO_BUTTON(border_combo)->button)
                                                         ->child)->pixmap;
      gdk_window_copy_area(window,
                           widget->style->fg_gc[GTK_STATE_NORMAL],
                           0,0,
 GTK_PIXMAP(GTK_BIN(border_combo->button[new_row][new_col])->child)->pixmap,
                           0,0,16,16);

      gtk_widget_queue_draw(GTK_COMBO_BUTTON(border_combo)->button);
      
      gtk_signal_emit (GTK_OBJECT(border_combo), border_combo_signals[CHANGED],
                       new_row * border_combo->ncols + new_col);
  }

  if(!new_selection && row >= 0 && column >= 0){
          gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(border_combo->button[row][column]), TRUE);
          gtk_widget_queue_draw(border_combo->button[row][column]);

          gtk_signal_emit (GTK_OBJECT(border_combo),                     
                           border_combo_signals[CHANGED],
                           row * border_combo->ncols + column);
  }


  gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(GTK_COMBO_BUTTON(border_combo)->arrow), FALSE);

  gtk_grab_remove(GTK_COMBO_BUTTON(border_combo)->popwin);
  gdk_pointer_ungrab(GDK_CURRENT_TIME);
  gtk_widget_hide(GTK_COMBO_BUTTON(border_combo)->popwin);
  return;

}