struct widget * widget_new_text(struct widget * parent, int x, int y, char const * const text) { struct widget * obj; int w, h; if(text != NULL) { w = 2 + font_width(text) + 2; h = 1 + font_height() + 1; } else { w = 4; h = 4; } obj = widget_new_child(parent, x, y, w, h); assert(obj != NULL); if(obj != NULL) { widget_set_on_draw(obj, widget_draw); widget_set_ulong(obj, "type", WT_TEXT); widget_set_flags(obj, 0); if(text != NULL) widget_set_string(obj, "text", "%s", text); } return obj; }
int click_knowledge_handler(window_info *win, int mx, int my, Uint32 flags) { int x,y,idx; Uint8 str[3]; x= mx; y= my; if(x > win->len_x-win->box_size) return 0; if(y > booklist_y_len) return 0; if(flags&ELW_WHEEL_UP) { vscrollbar_scroll_up(win->window_id, knowledge_scroll_id); return 1; } else if(flags&ELW_WHEEL_DOWN) { vscrollbar_scroll_down(win->window_id, knowledge_scroll_id); return 1; } else { selected_book = -1; x = (x < (win->len_x-win->box_size)/2) ?0 :1; y/=booklist_y_step; idx = x + 2 *(y + vscrollbar_get_pos (win->window_id, knowledge_scroll_id)); if(idx < knowledge_count) { str[0] = GET_KNOWLEDGE_INFO; *(Uint16 *)(str+1) = SDL_SwapLE16((short)idx); my_tcp_send(my_socket,str,3); raw_knowledge_string[0] = '\0'; // Check if we display the book image and label knowledge_book_id = idx; if (knowledge_list[idx].present && knowledge_list[idx].has_book) { widget_unset_flags (win->window_id, knowledge_book_image_id, WIDGET_DISABLED); widget_unset_flags (win->window_id, knowledge_book_label_id, WIDGET_DISABLED); } else { widget_set_flags(win->window_id, knowledge_book_image_id, WIDGET_DISABLED); widget_set_flags(win->window_id, knowledge_book_label_id, WIDGET_DISABLED); } selected_book = idx; } do_click_sound(); } return 1; }
object_t *toolbar_widget_create( object_t *parent, int flags ) { object_t *object; assert_valid_widget( parent, "parent" ); object = object_create_from_class( toolbar_widget_type, parent ); widget_set_flags( object, flags ); object_realize( object ); return object; }
object_t *opengl_widget_create( object_t *parent, bounds_t *bounds, int flags ) { object_t *object; assert_valid_widget( parent, "parent" ); object = object_create_from_class( opengl_widget_type, parent ); widget_set_bounds( object, bounds ); widget_set_flags( object, flags ); object_realize( object ); return object; }
static void update_note_button_scrollbar(int nr) { int max_nr_rows = note_button_scroll_height / (note_button_height + note_button_y_space); int nr_rows = (nr_notes+1) / 2; if (nr_rows <= max_nr_rows) { widget_set_flags (main_note_tab_id, note_button_scroll_id, WIDGET_INVISIBLE|WIDGET_DISABLED); vscrollbar_set_bar_len (main_note_tab_id, note_button_scroll_id, 0); scroll_to_note_button (0); } else { widget_unset_flags (main_note_tab_id, note_button_scroll_id, WIDGET_INVISIBLE|WIDGET_DISABLED); vscrollbar_set_bar_len (main_note_tab_id, note_button_scroll_id, nr_rows - max_nr_rows); scroll_to_note_button (nr); } }
object_t *radiobutton_widget_create( object_t *parent, object_t *group, bounds_t *bounds, const char *label, int flags ) { object_t *object; assert_valid_widget( parent, "parent" ); assert_valid_radiogroup_widget( group, "group" ); object = object_create_from_class( radiobutton_widget_type, parent ); widget_set_bounds( object, bounds ); widget_set_flags( object, flags ); object_realize( object ); radiobutton_set_label( object, label ); radiobutton_set_group( object, group ); return object; }
void note_button_set_pos (int id) { int scroll_pos = vscrollbar_get_pos (main_note_tab_id, note_button_scroll_id); int max_nr_rows = note_button_scroll_height / (note_button_height + note_button_y_space); int row = id / 2 - scroll_pos; if (row < 0 || row >= max_nr_rows) { widget_set_flags (main_note_tab_id, note_list[id].button_id, WIDGET_INVISIBLE); } else { int x = 5 + (id % 2) * (note_button_width + note_button_x_space); int y = 50 + (note_button_height + note_button_y_space) * row; widget_unset_flags (main_note_tab_id, note_list[id].button_id, WIDGET_INVISIBLE); widget_move (main_note_tab_id, note_list[id].button_id, x, y); } }
object_t *menubar_widget_create( object_t *parent, int flags ) { window_widget_t *pwin = (window_widget_t *)parent; object_t *object; assert_valid_widget( parent, "parent" ); object = object_create_from_class( menubar_widget_type, parent ); widget_set_flags( object, flags ); list_widget_init( object, 2, CLIST_TYPE_PTR, CLIST_TYPE_STRING ); /* handle list operations */ object_addhandler( object, "new_row", menubar_new_item_handle ); object_addhandler( object, "remove_row", menubar_remove_item_handle ); pwin->menubar = (widget_t *)object; object_realize( object ); return object; }
struct widget * widget_new_title_credits(struct widget * parent, int x, int y, int width) { struct widget * obj; obj = widget_new_child(parent, x, y, width, 10); /* The height is in error here, but it should not matter. */ assert(obj != NULL); if(obj != NULL) { widget_set_on_draw(obj, draw); widget_set_ulong(obj, "type", WT_TITLE_CREDITS); widget_set_flags(obj, 0); widget_set_ulong(obj, "help_screen", 0); widget_set_ulong(obj, "credits_index", 0); widget_set_pointer(obj, "credits", 'P', read_credits(filenames[0])); widget_set_on_unload(obj, on_unload); #ifdef WITH_OPENGL if(globals.opengl) { struct gfxbuf * buf; buf = gfxbuf_new(GFXBUF_STATIC_2D, GL_QUADS, GFXBUF_COLOUR | GFXBUF_BLENDING); assert(buf != NULL); gfxbuf_resize(buf, 4 * 2); int vpos, cpos; vpos = cpos = 0; buf->vbuf[vpos++] = 0; buf->vbuf[vpos++] = font_height(); buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0xff; buf->vbuf[vpos++] = 0; buf->vbuf[vpos++] = 0; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0xff; buf->vbuf[vpos++] = 12; buf->vbuf[vpos++] = 0; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->vbuf[vpos++] = 12; buf->vbuf[vpos++] = font_height(); buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->vbuf[vpos++] = width - 12; buf->vbuf[vpos++] = font_height(); buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->vbuf[vpos++] = width - 12; buf->vbuf[vpos++] = 0; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->vbuf[vpos++] = width; buf->vbuf[vpos++] = 0; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0xff; buf->vbuf[vpos++] = width; buf->vbuf[vpos++] = font_height(); buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0x00; buf->cbuf[cpos++] = 0xff; gfxbuf_update(buf, 0, vpos / 2); widget_set_pointer(obj, "gfxbuf", 'P', buf); } #endif } return obj; }