예제 #1
0
CMapToolEraser::CMapToolEraser(KActionCollection *actionCollection,CMapManager *manager,QObject *parent)
	: CMapToolBase(actionCollection,
                   i18n("Eraser"),
                   BarIcon("kmud_eraser.png"),
                   manager,"toolsEraser",0,parent)
{

	QBitmap delete_cb( 32, 32, delete_cb_bits, TRUE );
	QBitmap delete_cm( 32, 32, delete_cm_bits, TRUE );

	deleteCursor = new QCursor( delete_cb, delete_cm, 1,1);
}
예제 #2
0
파일: sfpr_list.c 프로젝트: edgarliu/easygx
int sfpr_list_delete(sfpr_list_t *list, int(*cmp_cb)(void  *src, void *cmp_param), void *cmp_param,
											void(*delete_cb)(void *data,void *delete_param),void *delete_param)
{
	sfpr_list_node_t *q ,*p;

	if(list->head == NULL)
	{
		return SFPR_ERROR;
	}
	sfpr_mutex_lock(&list->mutex);
	
	if(!cmp_cb){
		cmp_cb = list_cmp_cb_default;
	}
	if(!delete_cb){
		delete_cb = list_delete_cb_default;
	}
	if(cmp_cb(list->head->data, cmp_param) == 0)		/**< 要删除的数据为头结点数据*/
    {		
            p = list->head;
			list->head = list->head->next;
			
			delete_cb(p->data, delete_param);
			if(list->pool){
				sfpr_mem_free(list->pool,p);
			}else{
				free(p);
			}
			list->count--;
          	sfpr_mutex_unlock(&list->mutex);	
			return SFPR_SUCCESS;
    }
	
	p = list->head;	
	q = list->head->next;
	while(q != list->tail->next)				/**< 否则*/
	{
		if(cmp_cb(q->data, cmp_param) == 0)
        {
                q = p->next;
                p->next = q->next;
				delete_cb(p->data, delete_param);
				if(list->pool){
					sfpr_mem_free(list->pool,q);
				}else{
					free(q);
				}
                list->count--;
                break;
        }
        else
        {
                p = p->next;
                q = q->next;
        }
        if(q == NULL)
        {
                sfpr_mutex_unlock(&list->mutex);
                return SFPR_ERROR;
        }		
	}
	sfpr_mutex_unlock(&list->mutex);
	return SFPR_SUCCESS;
}
예제 #3
0
int Puzzle_Window::handle(int event) {
  int x = Fl::event_x();
  int y = Fl::event_y();
  switch (event) {
  case FL_KEY:
    switch (Fl::event_key()) {
    case FL_Escape:
    case 'Q':
    case 'q':
      exit(0);
      break;
    case 'S':
    case 's':
      solve_cb(this,0);
      break;
    case 'D':
    case 'd':
      piece = selectPiece(x, y);
      delete_cb(this,0);
      break;
    case 'R':
    case 'r':
      reset_cb(this,0);
      break;
    case 'O':
    case 'o':
      reset_view_cb(this,0);
      break;
    default:
      break;
    }
    return 1;

  case FL_PUSH:
    mousex = curX = x;
    mousey = curY = y;
    switch (Fl::event_button()) {
    case 1:
      set_solving(0);
      left_mouse = true;
      sel_piece = selectPiece(mousex, mousey);
      if (!sel_piece) {
	left_mouse = false;
	middle_mouse = true; // let it rotate object
      } else {
	float selx, sely;
	if (computeCoords(sel_piece, mousex, mousey, &selx, &sely)) {
	  grabPiece(sel_piece, selx, sely);
	}
      }
      redraw();
      break;
    case 2:
      middle_mouse = true;
      redraw();
      break;
    default:
      piece = selectPiece(x, y);
      if (piece) menu->child(2)->activate(); else menu->child(2)->deactivate();
      menu->popup(x, y);
      return 1;
    }
    // fall through to drag handler:

  case FL_DRAG:
    if (middle_mouse && !left_mouse) {
      if (mousex != x || mousey != y) {
	trackball(lastquat,
		  (2.0*mousex - W) / W,
		  (H - 2.0*mousey) / H,
		  (2.0*x - W) / W,
		  (H - 2.0*y) / H);
	spinning = 1;
      } else {
	spinning = 0;
      }
      changeState();
    } else {
      float selx, sely;
      computeCoords(sel_piece, x, y, &selx, &sely);
      moveSelection(selx, sely);
    }
    mousex = x;
    mousey = y;
    redraw();
    return 1;

  case FL_RELEASE:
    if (left_mouse) {
      left_mouse = false;
      dropSelection();
      redraw();
    } else if (middle_mouse) {
      middle_mouse = GL_FALSE;
      redraw();
    }
    return 1;

  }
  return Fl_Gl_Window::handle(event);
}
예제 #4
0
파일: new_net.c 프로젝트: benihana/libnnal
/* New dialog */
void
new_cb()
{
	// If another nn is open, call delete_cb()
	if(nn != NULL)
		delete_cb();
	
	GtkWidget *tmp;	

	// Dialog where select the net neurons number
	new_w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	gtk_window_set_title(GTK_WINDOW(new_w), "New Neural Network");
	gtk_window_resize(GTK_WINDOW(new_w), 300, 180);
	//g_signal_connect(G_OBJECT(window), "destroy", 
	//                     G_CALLBACK(gtk_main_quit), NULL);
    
	GtkWidget *mbox = gtk_vbox_new(1, 0);
	gtk_container_add(GTK_CONTAINER(new_w), mbox);


	GtkWidget *menu = gtk_menu_bar_new();
	gtk_box_pack_start(GTK_BOX(mbox),menu,TRUE,TRUE,0);

	// 
	GtkWidget *menu_file = gtk_menu_item_new_with_label("File");
	gtk_menu_bar_append (GTK_MENU_BAR(menu), menu_file);

	GtkWidget *menu_sub = gtk_menu_new();
	gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_file), menu_sub);

	GtkWidget *menuitem = gtk_menu_item_new_with_label ("Quit");
	g_signal_connect(G_OBJECT(menuitem), "clicked", G_CALLBACK(save_cb), NULL);
	gtk_menu_append(GTK_MENU(menu_sub), menuitem);


	// Input neurons
	tmp = gtk_hbox_new(0,0);
	gtk_box_pack_start(GTK_BOX(mbox),tmp,FALSE,FALSE,0);

	gtk_box_pack_start(GTK_BOX(tmp),gtk_label_new("Input neurons: "),FALSE,FALSE,0);
	input_spin = gtk_spin_button_new(
		GTK_ADJUSTMENT(gtk_adjustment_new(2.0, 0.0, 10000.0, 1.0, 10.0, 10.0)), 
		1.0, 0);
	gtk_box_pack_start(GTK_BOX(tmp),input_spin,FALSE,FALSE,0);

	// Hidden neurons
	tmp = gtk_hbox_new(0,0);
	gtk_box_pack_start(GTK_BOX(mbox),tmp,FALSE,FALSE,0);

	gtk_box_pack_start(GTK_BOX(tmp),gtk_label_new("Hidden neurons: "),FALSE,FALSE,0);
	hidden_spin = gtk_spin_button_new(
		GTK_ADJUSTMENT(gtk_adjustment_new(3.0, 0.0, 10000.0, 1.0, 10.0, 10.0)), 
		1.0, 0);
	gtk_box_pack_start(GTK_BOX(tmp),hidden_spin,FALSE,FALSE,0);

	// Output neurons
	tmp = gtk_hbox_new(0,0);
	gtk_box_pack_start(GTK_BOX(mbox),tmp,FALSE,FALSE,0);

	gtk_box_pack_start(GTK_BOX(tmp),gtk_label_new("Output neurons: "),FALSE,FALSE,0);
	output_spin = gtk_spin_button_new(
		GTK_ADJUSTMENT(gtk_adjustment_new(1.0, 0.0, 10000.0, 1.0, 10.0, 10.0)), 
		1.0, 0);
	gtk_box_pack_start(GTK_BOX(tmp),output_spin,FALSE,FALSE,0);
	
	// Learning neurons
	tmp = gtk_hbox_new(0,0);
	gtk_box_pack_start(GTK_BOX(mbox),tmp,FALSE,FALSE,0);

	gtk_box_pack_start(GTK_BOX(tmp),gtk_label_new("Learning rate: "),FALSE,FALSE,0);
	learning_spin = gtk_spin_button_new(
		GTK_ADJUSTMENT(gtk_adjustment_new(0.6, 0.0, 1.0, 0.02, 0.6, 0.1)), 
		1.0, 2);
	gtk_box_pack_start(GTK_BOX(tmp),learning_spin,FALSE,FALSE,0);
	
	// Combo for transfer function
	
	tmp = gtk_hbox_new(0,0);
	gtk_box_pack_start(GTK_BOX(mbox),tmp,FALSE,FALSE,0);
	GtkWidget *new_button = gtk_button_new_with_label("New");
	g_signal_connect(G_OBJECT(new_button), "clicked", G_CALLBACK(new_do_cb), NULL);
	gtk_container_add(GTK_CONTAINER(tmp), new_button);
	GtkWidget *cancel_button = gtk_button_new_with_label("Cancel");
	g_signal_connect(G_OBJECT(cancel_button), "clicked", G_CALLBACK(new_cancel_cb), NULL);
	gtk_container_add(GTK_CONTAINER(tmp), cancel_button);
	 
	gtk_widget_show_all(new_w);
}