// Go through the properties and commit the changes. void edit_dialog_ok (TextboxItem *item) { const gchar *value; Textbox *textbox; g_return_if_fail (item != NULL); g_return_if_fail (IS_TEXTBOX_ITEM (item)); textbox = TEXTBOX (sheet_item_get_data (SHEET_ITEM (item))); value = gtk_entry_get_text (GTK_ENTRY (prop_dialog->entry)); textbox_set_text (textbox, value); }
static gboolean create_textbox_event (Sheet *sheet, GdkEvent *event) { switch (event->type) { case GDK_3BUTTON_PRESS: case GDK_2BUTTON_PRESS: return TRUE; case GDK_BUTTON_PRESS: if (event->button.button == 4 || event->button.button == 5) return FALSE; if (event->button.button == 1) { if (sheet->state == SHEET_STATE_TEXTBOX_WAIT) sheet->state = SHEET_STATE_TEXTBOX_START; return TRUE; } else return FALSE; case GDK_BUTTON_RELEASE: if (event->button.button == 4 || event->button.button == 5) return FALSE; if (sheet->state == SHEET_STATE_TEXTBOX_START) { Textbox *textbox; Coords pos; sheet->state = SHEET_STATE_NONE; sheet_get_pointer (sheet, &pos.x, &pos.y); textbox = textbox_new (NULL); textbox_set_text (textbox, _ ("Label")); item_data_set_pos (ITEM_DATA (textbox), &pos); schematic_add_item (schematic_view_get_schematic_from_sheet (sheet), ITEM_DATA (textbox)); schematic_view_reset_tool (schematic_view_get_schematicview_from_sheet (sheet)); g_signal_handlers_disconnect_by_func (G_OBJECT (sheet), G_CALLBACK (create_textbox_event), sheet); } return TRUE; default: return FALSE; } return TRUE; }
void create_autoeditwin( list_item_t *item ) { int w, h, btn_w; char *srv_title, *chan_title, *srv_text, *chn_text; int text_w, c; object_t *aew_lbl_server, *aew_lbl_channels; layout_t *lt; bounds_t *b; char lt_str[512]; int enable = 1; aew_edit_item = item; w = 400; h = 150; btn_w = (w-20-(10*(2-1))) / 2; b = new_bounds( -1, -1, w, h ); autoeditwin = window_widget_create( bersirc->mainwin, b, cWindowModalDialog | cWindowCenterParent ); window_set_icon( autoeditwin, b_icon("bersirc") ); window_set_title( autoeditwin, lang_phrase_quick( (item==0?"addserver_t":"editserver_t") ) ); object_addhandler( autoeditwin, "destroy", b_autoeditwin_killed ); // input srv_title = lang_phrase_quick( "serveraddy_inp" ); chan_title = lang_phrase_quick( "channels_inp" ); srv_text = ""; chn_text = ""; if ( item != 0 ) { int *ip = item->data[0]; enable = *ip; srv_text = item->data[1]; chn_text = item->data[2]; } text_w = widget_font_string_width( bersirc->mainwin, srv_title, strlen( srv_title ) ); c = widget_font_string_width( bersirc->mainwin, chan_title, strlen( chan_title ) ); if ( c > text_w ) text_w = c; sprintf( lt_str, "[][{25}<|(%d)lblserver|<|txtserver|<][][{25}<|(%d)lblchannels|<|txtchannels|<]" "[][{25}<|enabled|<][][{25}<|btnsave|<|btncancel|<]", text_w, text_w ); lt = layout_create( autoeditwin, lt_str, *b, 10, 10 ); aew_lbl_server = label_widget_create_with_text( autoeditwin, lt_bounds(lt,"lblserver"), 0, srv_title ); aew_txt_server = textbox_widget_create( autoeditwin, lt_bounds(lt,"txtserver"), 0 ); textbox_set_text( aew_txt_server, srv_text ); aew_lbl_channels = label_widget_create_with_text( autoeditwin, lt_bounds(lt,"lblchannels"), 0, chan_title ); aew_txt_channels = textbox_widget_create( autoeditwin, lt_bounds(lt,"txtchannels"), 0 ); textbox_set_text( aew_txt_channels, chn_text ); object_addhandler( autoeditwin, "dialog_ok", b_autoeditwin_save ); object_addhandler( aew_txt_server, "changed", b_autoeditwin_txtchanged ); widget_focus( aew_txt_server ); aew_cbx_enabled = checkbox_widget_create_with_label( autoeditwin, lt_bounds(lt,"enabled"), 0, lang_phrase_quick( "autoitemenable" ) ); checkbox_set_checked( aew_cbx_enabled, enable ); // buttons aw_btnsave = button_widget_create_with_label( autoeditwin, lt_bounds(lt,"btnsave"), 0, lang_phrase_quick( "save" ) ); aw_btncancel = button_widget_create_with_label( autoeditwin, lt_bounds(lt,"btncancel"), 0, lang_phrase_quick( "cancel" ) ); object_addhandler( aw_btnsave, "pushed", b_autoeditwin_save ); object_addhandler( aw_btncancel, "pushed", b_autoeditwin_close ); if ( item == 0 ) widget_disable( OBJECT( aw_btnsave ) ); window_show( autoeditwin ); }
console init_console(int x, int y, int w, int h) { console c; button console_btn, chat_btn, log_btn; window_load_textures(); console_load_textures(); add_texture("/usr/local/share/vektor/ui/ui_content.texture", &texture_cpane); add_texture("/usr/local/share/vektor/ui/ui_input_bar.texture", &texture_input_bar); // allocate and initialize a new console c = calloc(1, sizeof(*c)); c->x = x; c->y = y; c->w = w; c->h = h; c->active = 1; user = getenv("USER"); main_console = c; c->win = add_window((float)x,(float)y,w,h); hide_window(c->win); // add tab bar and buttons c->tabs = add_tabbar(10, -26, 502, 36); // add textboxes c->tb_out = textbox_new(25, -80, 57, 16, 500000); c->tb_in = textbox_new(25, -300, 59, 1, 1000); console_data = c->tb_out->data; chat_data = calloc(500000,1); set_input(c->tb_in->data, 1000); textbox_set_text(c->tb_in, "v$ "); // add textbox listeners add_listener(&console_return, c->tb_in, vektor_event_return); add_listener(&chat_recv, c->tb_out, vektor_event_net_recv); // add content pane //c->cpane = add_bitmap(10, -65, 502, 262, &texture_cpane); //c->in_bar = add_bitmap(20, -293, 482, 25, &texture_input_bar); // add buttons console_btn = add_button(x + 5, y + 5, 87, 26, &texture_btn_console); chat_btn = add_button(x + 10 + 87, y + 5, 87, 26, &texture_btn_chat); log_btn = add_button(x + 15 + 174, y + 5, 87, 26, &texture_btn_log); // set button actions console_btn->action = &set_console; chat_btn->action = &set_chat; log_btn->action = &set_log; // attach buttons to tab bar tabbar_add_tab(c->tabs, console_btn); tabbar_add_tab(c->tabs, chat_btn); tabbar_add_tab(c->tabs, log_btn); // attach objects to window window_addchild(c->win, c->tabs, c->tabs->draw, c->tabs->move, c->tabs->resize, c->tabs->remove); //window_addchild(c->win, c->cpane, c->cpane->draw, c->cpane->move, c->cpane->resize, c->cpane->remove); //window_addchild(c->win, c->in_bar, c->in_bar->draw, c->in_bar->move, c->in_bar->resize, c->in_bar->remove); window_addchild(c->win, c->tb_out, c->tb_out->scene_data.draw, c->tb_out->move, c->tb_out->resize, c->tb_out->scene_data.remove); window_addchild(c->win, c->tb_in, c->tb_in->scene_data.draw, c->tb_in->move, c->tb_in->resize, c->tb_in->scene_data.remove); //add_object_2d(c, NULL, &draw_console, NULL, &free_console); keybind_add(c, &toggle_console, NULL, vektor_key_f1); toggle_console(c); return c; }
void quick_setup_textbox(u8 string_id) { create_battle_box(); display_textbox(); //textbox_set_text((u8 *)0x81C55C9, 1, 0, 1, 3, 1); textbox_set_text(battle_strings.string[string_id], 1, 0, 1, 3, 1); }