Esempio n. 1
0
void
EditorSectorsMenu::delete_sector()
{
  Level* level = Editor::current()->get_level();
  auto dialog = std::make_unique<Dialog>();

  // Do not delete sector when there would be no left.
  if (level->get_sector_count() < 2) {
    // do not allow to delete the sector
    dialog->set_text(_("Each level must have at least one sector."));
    dialog->clear_buttons();
    dialog->add_cancel_button(_("Cancel"));
  } else {
    // confirmation dialog
    dialog->set_text(_("Do you really want to delete this sector?"));
    dialog->clear_buttons();
    dialog->add_cancel_button(_("Cancel"));
    dialog->add_button(_("Delete sector"), [] {
        MenuManager::instance().clear_menu_stack();
        Editor::current()->delete_current_sector();
      });
  }
  MenuManager::instance().set_dialog(std::move(dialog));
}
Esempio n. 2
0
void QtCalculator::keyReleaseEvent( QKeyEvent *e ){
  switch (e->key() ){

  case Key_Next:
     key_pressed = FALSE;
     pbAC->setOn(FALSE);
     break;
  case Key_Prior:
     key_pressed = FALSE;
     pbClear->setOn(FALSE);
     break;

  case Key_H:
    key_pressed = FALSE;
     pbhyp->setOn(FALSE);
     break;
  case Key_I:
    key_pressed = FALSE;
     pbinv->setOn(FALSE);
     break;
  case Key_A:
    key_pressed = FALSE;
     pbA->setOn(FALSE);
     break;
  case Key_E:
    key_pressed = FALSE;
    if (current_base == NB_HEX)
     pbE->setOn(FALSE);
    else
     pbEE->setOn(FALSE);
     break;
  case Key_Escape:
    key_pressed = FALSE;
     pbClear->setOn(FALSE);
     break;
  case Key_Delete:
    key_pressed = FALSE;
     pbAC->setOn(FALSE);
     break;
  case Key_S:
    key_pressed = FALSE;
     pbSin->setOn(FALSE);
     break;
  case Key_Backslash:
    key_pressed = FALSE;
     pbplusminus->setOn(FALSE);
     break;
  case Key_B:
    key_pressed = FALSE;
     pbB->setOn(FALSE);
     break;
  case Key_7:
    key_pressed = FALSE;
     pb7->setOn(FALSE);
     break;
  case Key_8:
    key_pressed = FALSE;
     pb8->setOn(FALSE);
     break;
  case Key_9:
    key_pressed = FALSE;
     pb9->setOn(FALSE);
     break;
  case Key_ParenLeft:
    key_pressed = FALSE;
     pbparenopen->setOn(FALSE);
     break;
  case Key_ParenRight:
    key_pressed = FALSE;
     pbparenclose->setOn(FALSE);
     break;
  case Key_Ampersand:
    key_pressed = FALSE;
     pband->setOn(FALSE);
     break;
  case Key_C:
    key_pressed = FALSE;
    if (current_base == NB_HEX)
     pbC->setOn(FALSE);
    else
     pbCos->setOn(FALSE);
     break;
  case Key_4:
    key_pressed = FALSE;
     pb4->setOn(FALSE);
     break;
  case Key_5:
    key_pressed = FALSE;
     pb5->setOn(FALSE);
     break;
  case Key_6:
    key_pressed = FALSE;
     pb6->setOn(FALSE);
     break;
  case Key_Asterisk:
    key_pressed = FALSE;
     pbX->setOn(FALSE);
     break;
  case Key_Slash:
    key_pressed = FALSE;
     pbdivision->setOn(FALSE);
     break;
  case Key_O:
    key_pressed = FALSE;
     pbor->setOn(FALSE);
     break;
  case Key_T:
    key_pressed = FALSE;
     pbTan->setOn(FALSE);
     break;
  case Key_Exclam:
    key_pressed = FALSE;
     pbfactorial->setOn(FALSE);
     break;
  case Key_D:
    key_pressed = FALSE;
    if(kcalcdefaults.style == 0)
      pbD->setOn(FALSE); // trig mode
    else
      pblog->setOn(FALSE);// stat mode
     break;
  case Key_1:
    key_pressed = FALSE;
     pb1->setOn(FALSE);
     break;
  case Key_2:
    key_pressed = FALSE;
     pb2->setOn(FALSE);
     break;
  case Key_3:
    key_pressed = FALSE;
     pb3->setOn(FALSE);
     break;
  case Key_Plus:
    key_pressed = FALSE;
     pbplus->setOn(FALSE);
     break;
  case Key_Minus:
    key_pressed = FALSE;
     pbminus->setOn(FALSE);
     break;
  case Key_Less:
    key_pressed = FALSE;
     pbshift->setOn(FALSE);
     break;
  case Key_N:
    key_pressed = FALSE;
     pbln->setOn(FALSE);
     break;
  case Key_L:
    key_pressed = FALSE;
     pblog->setOn(FALSE);
     break;
  case Key_AsciiCircum:
    key_pressed = FALSE;
     pbpower->setOn(FALSE);
     break;
  case Key_F:
    key_pressed = FALSE;
     pbF->setOn(FALSE);
     break;
  case Key_Period:
    key_pressed = FALSE;
     pbperiod->setOn(FALSE);
     break;
  case Key_Comma:
    key_pressed = FALSE;
     pbperiod->setOn(FALSE);
     break;
  case Key_0:
    key_pressed = FALSE;
     pb0->setOn(FALSE);
     break;
  case Key_Equal:
    key_pressed = FALSE;
     pbequal->setOn(FALSE);
     break;
  case Key_Return:
    key_pressed = FALSE;
     pbequal->setOn(FALSE);
     break;
  case Key_Enter:
     key_pressed = FALSE;
     pbequal->setOn(FALSE);
     break;
  case Key_Percent:
    key_pressed = FALSE;
     pbpercent->setOn(FALSE);
     break;
  case Key_AsciiTilde:
    key_pressed = FALSE;
     pbnegate->setOn(FALSE);
     break;
  case Key_Colon:
    key_pressed = FALSE;
     pbmod->setOn(FALSE);
     break;
  case Key_BracketLeft:
     key_pressed = FALSE;
     pbsquare->setOn(FALSE);
     break;
  case Key_Backspace:
     key_pressed = FALSE;
     pbAC->setOn(FALSE);
     break;
  case Key_R:
     key_pressed = FALSE;
     pbreci->setOn(FALSE);
     break;
  }

  clear_buttons();
}
Esempio n. 3
0
void menu_setup_devices()
{

	if(redraw)
	{
		clearDisplay();
		clear_buttons();
		redraw=0;

		draw_filledRect(0,0,LCD_WIDTH,35,155,100,100);

		draw_filledCircle(17,17,15,40,80,40);
		draw_text_8x6(7,10,"Back",255,100,100);

		uint16_t text_width =  get_text_width_16pt("Setup Devices");

		draw_text_16pt((LCD_WIDTH-text_width)>>1,9, "Setup Devices", 200,200,255);


		init_lineitems();
		char buf[30];
		char buf2[30];
		draw_lineitem("","<new>");
		for(int i = 0; i < get_device_count();i++)
		{
			snprintf(buf,30,"%i",get_device(i)->base_address);
		
			char classname[30];
			if(get_device(i)->device_class_uuid == 0)
			{
				strncpy(classname,"<empty>",30);
			}
			else if(get_device_class_by_uuid(get_device(i)->device_class_uuid) == NULL)
			{
				strncpy(classname,"<missing>",30);
			}
			else
			{
				strncpy(classname,get_device_class_by_uuid(get_device(i)->device_class_uuid)->name,30);
			}

			snprintf(buf2,30,"%s - %s",classname,get_device(i)->name);
			draw_lineitem(buf,buf2);
		}

		draw_scrollbar();

		draw_button_h(257,45,52,42,"^",155,0,0,0,255,0);
		if((get_device_count()<10)&&(active_row==0))
		{
			draw_button_h(257,92,52,42,"Add",155,0,0,0,255,0);
		}
		if(active_row>0)
		{
			draw_button_h(257,92,52,42,"Edit",155,0,0,0,255,0);
			draw_button_h(257,139,52,42,"Delete",155,0,0,0,255,0);
		}
		draw_button_h(257,186,52,42,"v",155,0,0,0,255,0);
	}

	uint8_t field=0;
	uint16_t x;
	uint16_t y;
	if(check_button_press(&x,&y)==1)
	{
		if(y > 41)
		{
			field=1;

			if(y > 184)
			{
				field=4;
			}else if(y > 136)
			{
				field=3;
			}else if(y > 89)
			{
				field=2;
			}
		}
		else
		{
			if(x < 40)
			{
				redraw=1;
				set_current_execution(menu_setup);
			}
		}
		
		if(field == 1)
		{
			if(active_row > 0)
			{
				if(active_row==scroll_offset)
				{
					scroll_offset--;
				}

				active_row--;
			}
			redraw=1;
		}
		if(field == 4)
		{
			if(active_row < (get_device_count()))
			{
				active_row++;
				int drawline = active_row-scroll_offset; 
				if(drawline==10)
				{
					scroll_offset++;
				}
			}
			redraw=1;
		}
		if(field == 2)
		{
			redraw=1;
			if(active_row==0)
			{
				if(get_device_count()<50)
				{
					set_current_execution(menu_setup_devices_add);
				}
			}
			else
			{
				set_current_execution(menu_setup_devices_edit);
				set_device_to_edit(active_row-1);
			}
		}
		if(field == 3)
		{
			redraw=1;
			
			if(active_row > 0)
			{
				del_device(active_row-1);
				if(active_row==scroll_offset)
				{
					scroll_offset--;
				}
				active_row--;
			}

		}
	}
}
Esempio n. 4
0
void menu_setup_devices_add()
{
	if(init_device)
	{
		new_device=my_malloc(sizeof(dmx_device_t));
		init_device=0;
		new_device->name=my_malloc(1);
		new_device->name[0]=0;
		new_device->uuid=rand();
		new_device->device_class_uuid=0;
		new_device->base_address=0;
		
		active_row = 0;
		scroll_offset = 0;

	}
	
	if(invoke != 0)
	{
		if(invoke==1)
		{
			char* name = get_keyboard_buffer();
			my_free(new_device->name);
			new_device->name=my_malloc(strlen(name)+1);
			strcpy(new_device->name, name);
		}
		else if(invoke==2)
		{
			new_device->device_class_uuid = get_choose_device_class();
		}
		else if(invoke==3)
		{
			new_device->base_address = get_keyboard_number();
		}
		invoke=0;
	}

	if(redraw)
	{
		clearDisplay();
		clear_buttons();
		redraw=0;

		draw_filledRect(0,0,LCD_WIDTH,35,155,100,100);

		draw_filledCircle(17,17,15,40,80,40);
		draw_text_8x6(7,10,"Back",255,100,100);

		uint16_t text_width =  get_text_width_16pt("Add Device");

		draw_text_16pt((LCD_WIDTH-text_width)>>1,9, "Add Device", 200,200,255);

		init_lineitems();
		draw_lineitem("Name",new_device->name);
		if(new_device->device_class_uuid == 0)
		{
			draw_lineitem("Class","<empty>");
		}
		else if(get_device_class_by_uuid(new_device->device_class_uuid) == NULL)
		{
			draw_lineitem("Class","<missing>");
		}
		else
		{
			draw_lineitem("Class",get_device_class_by_uuid(new_device->device_class_uuid)->name);
		}
		draw_lineitem_addr("Address",new_device->base_address);


		draw_scrollbar();

		draw_button_h(257,45,52,42,"^",155,0,0,0,255,0);
		draw_button_h(257,92,52,42,"Edit",155,0,0,0,255,0);
		draw_button_h(257,139,52,42,"Save",155,0,0,0,255,0);
		draw_button_h(257,186,52,42,"v",155,0,0,0,255,0);
	}

	uint8_t field=0;
	uint16_t x;
	uint16_t y;
	if(check_button_press(&x,&y)==1)
	{
		if(y > 41)
		{
			field=1;

			if(y > 184)
			{
				field=4;
			}else if(y > 136)
			{
				field=3;
			}else if(y > 89)
			{
				field=2;
			}
		}
		else
		{
			if(x < 40)
			{
				redraw=1;
				init_device=1;
				my_free(new_device->name);
				my_free(new_device);
				set_current_execution(menu_setup_devices);
			}
		}
		
		if(field == 1)
		{
			if(active_row > 0)
			{
				if(active_row==scroll_offset)
				{
					scroll_offset--;
				}

				active_row--;
			}
			redraw=1;
		}
		if(field == 4)
		{
			if(active_row < 2)
			{
				active_row++;
				int drawline = active_row-scroll_offset; 
				if(drawline==10)
				{
					scroll_offset++;
				}
			}
			redraw=1;
		}
		if(field == 2)
		{
			invoke=active_row+1;
			redraw=1;
			if(active_row==0)
			{
				invoke_keyboard("Enter Device Name",new_device->name);
			}
			else if(active_row==1)
			{
				invoke_choose_device_class(new_device->device_class_uuid);
			}
			else if(active_row==2)
			{
				invoke_numeric_keyboard("Enter Base Address",new_device->base_address);
			}
		}
		if(field == 3)
		{
			add_device(new_device);
			redraw=1;
			init_device=1;
			set_current_execution(menu_setup_devices);

		}
	}
}