Example #1
0
void
Inputbox::on_key_pressed(const Input::KeyboardEvent& ev)
{
  if (ev.keysym.sym == SDLK_BACKSPACE) // backspace
  {
    if (!text.empty())
    {
      text = text.substr(0, text.size()-1);
      on_change(text);
    }      
  }
  else if (ev.keysym.sym == SDLK_RETURN) // enter
  {
    on_change(text);
    on_enter(text);
  }
}
Example #2
0
File: scene.cpp Project: iyu9/mylib
void scene::update()
{
	if (state == state_enter)
	{
		on_enter();
		state = state_update;
		return;		
	}

	if (state == state_exit)
	{
		on_exit();
		return;		
	}

	on_update();
}
Example #3
0
void Edit::draw()
{
	if(is_visible())  // is it visible? 
	{
		if(is_active()) // is it disabled?
		{}
		double x = get_position().x;
		double y = get_position().y;
		double angle = get_angle();
		double scale_x = get_scale().x;
		double scale_y = get_scale().y;
		int width  = get_width();
		int height = get_height();
        int red    = get_color().x;
        int green  = get_color().y;
        int blue   = get_color().z;		
		int alpha  = get_color().w;
        void * font = (get_label() ? get_label()->get_font()->get_data() : nullptr);		
		Vector4 text_color = get_text_color();
		// Draw edit
		Renderer::draw_edit(get_text(), x, y, width, height, angle, scale_x, scale_y,
		    red, green, blue, alpha, multilined, cursor, cursor_x, cursor_y);
        // Draw text
		if(!label->get_string().empty())
		{
			label->draw();
			label->set_position(x, y + cursor_y);
			label->set_scale(0.5, 0.5);
			label->set_color(text_color);
		}
		// if mouse over edit, change mouse to I-beam	
		// edit is pressed, set cursor at position_pressed	
		on_hover();
		on_mousepress();
        on_keypress();
        on_backspace();
        on_enter();		
	}	
}
Example #4
0
void edit_side(int source,int smer)
  {
  TSTENA *p;
  CTL3D b1,b2,b3;
  char s[200];

  p=&mapa.sidedef[source][smer];
  memcpy(&b1,def_border(1,0),sizeof(CTL3D));
  memcpy(&b2,def_border(5,WINCOLOR),sizeof(CTL3D));
  memcpy(&b3,def_border(6,WINCOLOR),sizeof(CTL3D));
  default_font=vga_font;
  memcpy(f_default,flat_color(0x0000),sizeof(charcolors));
  sprintf(s,"Vlastnosti stˆn, sektor %d stˆna %d",source,smer);
  def_window(400,324,s);
  waktual->x=125;
  waktual->y=60;
  waktual->modal=1;
  define(CANCEL_BUTT,10,5,80,20,2,button,"Zru¨it");property(&b1,NULL,NULL,WINCOLOR);
    on_change(close_current);
  define(OK_BUTT,190,5,80,20,2,button,"Ok");property(&b1,NULL,NULL,WINCOLOR);
    on_change(edit_side_ok);
  define(3400,100,5,80,20,2,button,"P©edvolba");property(&b1,NULL,NULL,WINCOLOR);
    on_change(edit_side_predvolba_1);on_exit(edit_side_predvolba_2);
  define(10,5,20,300,35,0,label,"Prim rn¡:       Sekundarn¡:       Oblouk:");property(&b3,NULL,NULL,WINCOLOR);
  define(20,10,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->prim);
    on_enter(string_list_sup);
  define(30,110,35,90,12,0,str_line,side_names);property(&b2,NULL,NULL,WINCOLOR);c_default(p->sec);
    on_enter(string_list_sup);
  define(40,210,35,90,12,0,str_line,oblouky);property(&b2,NULL,NULL,WINCOLOR);c_default(p->oblouk & 0x0f);
    on_enter(string_list_sup);
  define(-1,5,60,250,12,0,label,"Animace primarn¡:");
  define(-1,5,75,250,12,0,label,"Animace sekundarn¡:");
  define(-1,5,90,250,12,0,label,"X pozice sek. stˆny:");
  define(-1,5,105,250,12,0,label,"Y pozice sek. stˆny:");
  define(-1,5,120,250,12,0,label,"C¡lov˜ sektor ud losti:");
  define(-1,5,135,250,12,0,label,"C¡lov  stˆna ud losti:");
  define(-1,5,150,250,12,0,label,"Popis akce:");
  define(-1,260,60,100,12,0,label,"Aplikuj na stˆnu:");
  define(50,200,60,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs((p->prim_anim & 0xf)+1));on_exit(test_int);
  define(60,200,75,50,10,0,input_line,10,1,16,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs((p->sec_anim & 0xf)+1));on_exit(test_int);
  define(70,200,90,50,10,0,input_line,10,0,499,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->xsec<<1));on_exit(test_int);
  define(80,200,105,50,10,0,input_line,10,0,511,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->ysec<<1));on_exit(test_int);
  define(90,200,120,50,10,0,input_line,10,0,65535,"%6d");property(&b2,NULL,NULL,WINCOLOR);
   set_default(strs(p->sector_tag));on_exit(test_int);
  define(100,200,135,50,10,0,str_line,steny2);property(&b2,NULL,NULL,WINCOLOR);
   c_default(p->side_tag & 0x3);on_enter(string_list_sup);
  define(110,100,150,150,10,0,str_line,actions);property(&b2,NULL,NULL,WINCOLOR);
   on_enter(string_list_sup); c_default(p->action);
  define(120,10,175,150,10,0,check_box,side_flgs[0]);
  define(130,10,187,150,10,0,check_box,side_flgs[1]);
  define(140,10,199,150,10,0,check_box,side_flgs[2]);
  define(150,10,211,150,10,0,check_box,side_flgs[3]);
  define(160,10,223,150,10,0,check_box,side_flgs[4]);
  define(170,10,235,150,10,0,check_box,side_flgs[5]);
  define(180,10,247,150,10,0,check_box,side_flgs[6]);
  define(190,10,259,150,10,0,check_box,side_flgs[7]);
  define(200,190,175,100,10,0,check_box,side_flgs[8]);
  define(210,190,187,100,10,0,check_box,side_flgs[9]);
  define(220,190,199,100,10,0,check_box,side_flgs[10]);
  define(230,190,211,150,10,0,check_box,side_flgs[11]);
  define(240,190,223,150,10,0,check_box,side_flgs[12]);
  define(250,190,235,150,10,0,check_box,side_flgs[13]);
  define(260,190,247,150,10,0,check_box,side_flgs[14]);
  define(270,190,259,150,10,0,check_box,side_flgs[15]);
  define(280,10,271,75,10,0,check_box,side_flgs[16]);
  define(290,10,283,75,10,0,check_box,side_flgs[17]);
  define(300,190,271,150,10,0,check_box,side_flgs[18]);
  define(310,10,295,75,11,0,check_box,side_flgs[19]);
  define(400,290,80,100,10,0,check_box,"Severn¡");
  define(410,290,95,100,10,0,check_box,"V˜chodn¡");
  define(420,290,110,100,10,0,check_box,"Ji‘n¡");
  define(430,290,125,100,10,0,check_box,"Z padn¡");
  define(340,290,150,100,15,0,button2,"V¡ce >>");on_change(action_flags);
  define(350,290,150,100,15,0,value_store,4);c_default(p->flags & 0xfff00000);
  define(360,290,150,100,15,0,value_store,4);c_default(source);
  define(370,290,150,100,15,0,value_store,4);c_default(smer);
  define(-1,5,20,60,10,1,label,"Lclip:");
  define(440,30,35,30,12,1,input_line,3,0,255,"%3d");
   property(&b2,NULL,NULL,WINCOLOR);
  set_default(strs(p->lclip));on_exit(test_int);
  define(450,10,220,30,30,1,radio_butts,3,"-","\x4","\x6");c_default((p->oblouk>>5) & 0x3);
   property(NULL,icones,NULL,WINCOLOR);
  define(460,10,175,80,12,1,button,"V˜klenek");on_change(edit_vyklenek_start);
  define(470,190,283,150,10,0,check_box,"Lze polo‘it za");c_default(p->oblouk>>7);
  define(480,10,307,75,10,0,check_box,"P©edsunout s.");c_default(p->side_tag>>7);
  fill_bit_fields(0,120,p->flags,20); if (source)
  fill_bit_fields(0,400,1<<smer,4); else fill_bit_fields(0,400,0xf,4);
  set_enable(0,3400,source!=0);
  set_enable(0,460,source!=0);
  redraw_window();
  }