static void listview_resize ( widget *wid, short w, short h ) { listview *lv = (listview *) wid; lv->widget.w = MAX ( 0, w ); lv->widget.h = MAX ( 0, h ); int height = lv->widget.h - widget_padding_get_padding_height ( WIDGET ( lv ) ); int spacing_vert = distance_get_pixel ( lv->spacing, ORIENTATION_VERTICAL ); lv->max_rows = ( spacing_vert + height ) / ( lv->element_height + spacing_vert ); lv->max_elements = lv->max_rows * lv->menu_columns; if ( lv->scrollbar->widget.index == 0 ) { widget_move ( WIDGET ( lv->scrollbar ), widget_padding_get_left ( WIDGET ( lv ) ), widget_padding_get_top ( WIDGET ( lv ) ) ); } else { widget_move ( WIDGET ( lv->scrollbar ), lv->widget.w - widget_padding_get_right ( WIDGET ( lv ) ) - widget_get_width ( WIDGET ( lv->scrollbar ) ), widget_padding_get_top ( WIDGET ( lv ) ) ); } widget_resize ( WIDGET ( lv->scrollbar ), widget_get_width ( WIDGET ( lv->scrollbar ) ), height ); listview_recompute_elements ( lv ); widget_queue_redraw ( wid ); }
static int ui_scale_buddy_handler(window_info *win) { int button_len_y = (int)(0.5 + win->current_scale * 20); buddy_border_space = (int)(0.5 + win->current_scale * 5); buddy_name_step_y = (int)(0.5 + win->current_scale * 12); buddy_menu_x_len = win->box_size + MAX_USERNAME_LENGTH * win->small_font_len_x + 2 * buddy_border_space; buddy_menu_y_len = button_len_y + 2* buddy_border_space + num_displayed_buddies * buddy_name_step_y; request_box_start_x = buddy_menu_x_len - win->box_size - (int)(0.5 + (strlen(buddy_request_str) + 2) * win->small_font_len_x); resize_window(win->window_id, buddy_menu_x_len, buddy_menu_y_len); button_resize(win->window_id, buddy_button_id, buddy_menu_x_len, button_len_y, win->current_scale); widget_move(win->window_id, buddy_button_id, 0, buddy_menu_y_len - button_len_y); widget_resize(win->window_id, buddy_scroll_id, win->box_size, buddy_menu_y_len - win->box_size - button_len_y); widget_move(win->window_id, buddy_scroll_id, buddy_menu_x_len - win->box_size, win->box_size); if (buddy_add_win >= 0) destroy_window(buddy_add_win); if (buddy_change_win >= 0) destroy_window(buddy_change_win); buddy_add_win = buddy_change_win = -1; return 1; }
static int ui_scale_accept_handler(window_info *win) { int label_id = 101, yes_button = 102, no_button = 103; int win_width = (int)(0.5 + win->current_scale * 400); int win_height = 3 * buddy_border_space + 2 * win->small_font_len_y; char string[250] = {0}; int current_window; for(current_window = 0; current_window < MAX_ACCEPT_BUDDY_WINDOWS; current_window++) if(accept_windows[current_window].window_id == win->window_id) break; if(current_window == MAX_ACCEPT_BUDDY_WINDOWS) return 0; safe_snprintf(string, sizeof(string), buddy_wants_to_add_str, accept_windows[current_window].name); put_small_colored_text_in_box_zoomed(c_blue1, (unsigned char*)string, strlen(string), win_width - 2 * buddy_border_space, accept_windows[current_window].text, win->current_scale); widget_resize(win->window_id, accept_windows[current_window].checkbox, win->small_font_len_y, win->small_font_len_y); widget_move(win->window_id, accept_windows[current_window].checkbox, buddy_border_space, win_height); widget_set_size(win->window_id, label_id, win->current_scale* DEFAULT_SMALL_RATIO); widget_move(win->window_id, label_id, 2 * buddy_border_space + win->small_font_len_y, win_height); win_height += widget_get_height(win->window_id, accept_windows[current_window].checkbox) + 2 * buddy_border_space; button_resize(win->window_id, yes_button, 0, 0, win->current_scale); button_resize(win->window_id, no_button, 0, 0, win->current_scale); widget_move(win->window_id, yes_button, (win_width/2 - widget_get_width(win->window_id, yes_button)) / 2, win_height); widget_move(win->window_id, no_button, win_width/2 + (win_width/2 - widget_get_width(win->window_id, no_button)) / 2, win_height); win_height += widget_get_height(win->window_id, yes_button) + buddy_border_space; resize_window(win->window_id, win_width, win_height); return 1; }
/* called each resize, recalculate the number of recipes that can be displayed and update the scrollbar */ static int resize_recipe_handler(window_info *win, int width, int height) { widget_resize(win->window_id, recipe_win_scroll_id, win->box_size, win->len_y - win->box_size); widget_move(win->window_id, recipe_win_scroll_id, win->len_x - win->box_size, 0); num_displayed_recipes = (int)(win->len_y / SLOT_SIZE); vscrollbar_set_bar_len(win->window_id, recipe_win_scroll_id, num_recipe_entries - num_displayed_recipes); return 1; }
// The size available to the names list has changed so resize/move elements. // void List_Window::resized_name_panel(window_info *win) { calc_num_show_names(); cm_remove_regions(win_id); cm_add_region(cm_names_menu, win_id, 0, get_size_y()-get_names_size_y(), get_size_y(), get_names_size_y()); widget_resize(win_id, names_scroll_id, ELW_BOX_SIZE, get_names_size_y()-ELW_BOX_SIZE); widget_move(win_id, names_scroll_id, win->len_x-ELW_BOX_SIZE, get_grid_size()*num_grid_rows); make_active_visable(); update_scroll_len(); }
static int resize_knowledge_handler(window_info *win, int new_width, int new_height) { int gap_y; int image_size = (int)(0.5 + win->current_scale * 50); int label_width = 0; int label_height = 0; int book_x_off = 0; int label_x_left = 0; int book_x_left = 0; text_border = win->small_font_len_x / 2; booklist_y_step = win->small_font_len_y - 2; booklist_y_len = 2 * text_border + (int)(0.5 + booklist_y_step * displayed_book_rows); progressbox_y_len = booklist_y_len + 2 * text_border + (int)(0.5 + win->small_font_len_y * info_lines); gap_y = (win->len_y - progressbox_y_len - win->small_font_len_y - 4) / 2; progress_top_y = progressbox_y_len + gap_y; progress_bot_y = win->len_y - gap_y; progress_right_x = win->len_x - (int)(0.5 + win->current_scale * 15); progress_left_x = win->len_x - (int)(0.5 + win->current_scale * 140); widget_resize(win->window_id, knowledge_scroll_id, win->box_size, booklist_y_len); widget_move(win->window_id, knowledge_scroll_id, win->len_x - win->box_size, 0); widget_set_size(win->window_id, knowledge_book_label_id, win->current_scale * 0.8); widget_resize(win->window_id, knowledge_book_label_id, strlen(knowledge_read_book) * win->default_font_len_x * 0.8, win->default_font_len_y * 0.8); widget_resize(win->window_id, knowledge_book_image_id, image_size, image_size); label_width = widget_get_width(win->window_id, knowledge_book_label_id); label_height = widget_get_height(win->window_id, knowledge_book_label_id); book_x_off = (label_width > image_size) ?label_width :image_size; gap_y = booklist_y_len + (progressbox_y_len - booklist_y_len - image_size - label_height)/ 2; label_x_left = progress_right_x - book_x_off/2 - label_width/2; book_x_left = progress_right_x - book_x_off/2 - image_size/2; book_start_x = (label_x_left < book_x_left) ?label_x_left :book_x_left; widget_move(win->window_id, knowledge_book_label_id, label_x_left, gap_y); widget_move(win->window_id, knowledge_book_image_id, book_x_left, gap_y + label_height); return 0; }
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) { scrollbar * sb = scrollbar_create ( NULL, "scrollbar" ); widget_resize ( WIDGET (sb), 10, 100); scrollbar_set_handle ( NULL, 10213); scrollbar_set_max_value ( NULL, 10 ); scrollbar_set_handle_length ( NULL , 1000); scrollbar_set_max_value ( sb, 10000); TASSERTE ( sb->length, 10000 ); scrollbar_set_handle_length ( sb, 10); TASSERTE ( sb->pos_length, 10 ); scrollbar_set_handle ( sb , 5000 ); TASSERTE ( sb->pos, 5000 ); scrollbar_set_handle ( sb , 15000 ); TASSERTE ( sb->pos, 10000 ); scrollbar_set_handle ( sb , UINT32_MAX ); TASSERTE ( sb->pos, 10000 ); scrollbar_set_handle_length ( sb, 15000); TASSERTE ( sb->pos_length, 10000 ); scrollbar_set_handle_length ( sb, 0); TASSERTE ( sb->pos_length, 1 ); guint cl = scrollbar_scroll_get_line ( sb, 10 ); TASSERTE ( cl, 1010); cl = scrollbar_scroll_get_line ( sb, 20 ); TASSERTE ( cl, 2020); cl = scrollbar_scroll_get_line ( sb, 0 ); TASSERTE ( cl, 0); cl = scrollbar_scroll_get_line ( sb, 99 ); TASSERTE ( cl, 9999); scrollbar_set_handle_length ( sb, 1000); cl = scrollbar_scroll_get_line ( sb, 10 ); TASSERTE ( cl, 555); cl = scrollbar_scroll_get_line ( sb, 20 ); TASSERTE ( cl, 1666); cl = scrollbar_scroll_get_line ( sb, 0 ); TASSERTE ( cl, 0); cl = scrollbar_scroll_get_line ( sb, 99 ); TASSERTE ( cl, 9999); widget_free( WIDGET (sb ) ); }
void resize_all_root_windows (Uint32 w, Uint32 h) { if (game_root_win >= 0) resize_window (game_root_win, w, h); if (console_root_win >= 0) resize_window (console_root_win, w, h); if (map_root_win >= 0) resize_window (map_root_win, w, h); if (login_root_win >= 0) resize_window (login_root_win, w, h); if (rules_root_win >= 0) resize_window (rules_root_win, w, h); if (opening_root_win >= 0) resize_window (opening_root_win, w, h); if (newchar_root_win >= 0) resize_window (newchar_root_win, w, h); if (update_root_win >= 0) resize_window (update_root_win, w, h); if (input_widget->window_id != chat_win) { widget_resize (input_widget->window_id, input_widget->id, w-HUD_MARGIN_X, input_widget->len_y); widget_move (input_widget->window_id, input_widget->id, 0, h-input_widget->len_y-HUD_MARGIN_Y); } #ifdef NEW_NEW_CHAR_WINDOW resize_newchar_hud_window(); #endif }
static void hori_calculate_size ( box *b ) { int spacing = distance_get_pixel ( b->spacing, ROFI_ORIENTATION_HORIZONTAL ); int expanding_widgets = 0; int active_widgets = 0; int rem_width = widget_padding_get_remaining_width ( WIDGET ( b ) ); int rem_height = widget_padding_get_remaining_height ( WIDGET ( b ) ); for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( child->enabled && child->expand == FALSE ) { widget_resize ( child, widget_get_desired_width ( child ), //child->w, rem_height ); } } b->max_size = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( !child->enabled ) { continue; } active_widgets++; if ( child->expand == TRUE ) { expanding_widgets++; continue; } // Size used by fixed width widgets. if ( child->h > 0 ) { b->max_size += child->w; } } b->max_size += MAX ( 0, ( ( active_widgets - 1 ) * spacing ) ); if ( b->max_size > ( rem_width ) ) { b->max_size = rem_width; g_debug ( "Widgets to large (width) for box: %d %d", b->max_size, b->widget.w ); return; } if ( active_widgets > 0 ) { int left = widget_padding_get_left ( WIDGET ( b ) ); double rem = rem_width - b->max_size; int index = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( child->enabled == FALSE ) { continue; } if ( child->expand == TRUE ) { // Re-calculate to avoid round issues leaving one pixel left. int expanding_widgets_size = ( rem ) / ( expanding_widgets - index ); widget_move ( child, left, widget_padding_get_top ( WIDGET ( b ) ) ); left += expanding_widgets_size; widget_resize ( child, expanding_widgets_size, rem_height ); left += spacing; rem -= expanding_widgets_size; index++; } else { widget_move ( child, left, widget_padding_get_top ( WIDGET ( b ) ) ); left += widget_get_width ( child ); left += spacing; } } } b->max_size += widget_padding_get_padding_width ( WIDGET ( b ) ); }
static void vert_calculate_size ( box *b ) { int spacing = distance_get_pixel ( b->spacing, ROFI_ORIENTATION_VERTICAL ); int expanding_widgets = 0; int active_widgets = 0; int rem_width = widget_padding_get_remaining_width ( WIDGET ( b ) ); int rem_height = widget_padding_get_remaining_height ( WIDGET ( b ) ); for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( child->enabled && child->expand == FALSE ) { widget_resize ( child, rem_width, widget_get_desired_height ( child ) ); } } b->max_size = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( !child->enabled ) { continue; } active_widgets++; if ( child->expand == TRUE ) { expanding_widgets++; continue; } if ( child->h > 0 ) { b->max_size += child->h; } } if ( active_widgets > 0 ) { b->max_size += ( active_widgets - 1 ) * spacing; } if ( b->max_size > rem_height ) { b->max_size = rem_height; g_debug ( "Widgets to large (height) for box: %d %d", b->max_size, b->widget.h ); return; } if ( active_widgets > 0 ) { int top = widget_padding_get_top ( WIDGET ( b ) ); double rem = rem_height - b->max_size; int index = 0; for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) { widget * child = (widget *) iter->data; if ( child->enabled == FALSE ) { continue; } if ( child->expand == TRUE ) { // Re-calculate to avoid round issues leaving one pixel left. int expanding_widgets_size = ( rem ) / ( expanding_widgets - index ); widget_move ( child, widget_padding_get_left ( WIDGET ( b ) ), top ); top += expanding_widgets_size; widget_resize ( child, rem_width, expanding_widgets_size ); top += spacing; rem -= expanding_widgets_size; index++; } else { widget_move ( child, widget_padding_get_left ( WIDGET ( b ) ), top ); top += widget_get_height ( child ); top += spacing; } } } b->max_size += widget_padding_get_padding_height ( WIDGET ( b ) ); }
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) { { box *b = box_create ( "box", BOX_HORIZONTAL ); //box_set_padding ( b, 5 ); widget_resize ( WIDGET (b), 100, 20); widget *wid1 = g_malloc0(sizeof(widget)); box_add ( b , WIDGET( wid1 ), TRUE, 0 ); // Widget not enabled. no width allocated. TASSERTE ( wid1->h, 0); TASSERTE ( wid1->w, 0 ); widget_enable ( WIDGET ( wid1 ) ); widget_update ( WIDGET ( b ) ) ; // Widget enabled. so width allocated. TASSERTE ( wid1->h, 20); TASSERTE ( wid1->w, 100 ); widget *wid2 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid2 ) ); box_add ( b , WIDGET( wid2 ), TRUE, 1 ); TASSERTE ( wid1->h, 20); TASSERTE ( wid1->w, 49); TASSERTE ( wid2->h, 20); TASSERTE ( wid2->w, 49); widget *wid3 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid3 ) ); box_add ( b , WIDGET( wid3 ), FALSE, 2 ); TASSERTE ( wid1->h, 20); TASSERTE ( wid1->w, 48); TASSERTE ( wid2->h, 20); TASSERTE ( wid2->w, 48); widget_resize ( WIDGET (wid3) , 20, 10 ); // TODO should this happen automagically? widget_update ( WIDGET ( b ) ) ; TASSERTE ( wid1->h, 20); TASSERTE ( wid1->w, 38); TASSERTE ( wid2->h, 20); TASSERTE ( wid2->w, 38); TASSERTE ( wid3->h, 20); TASSERTE ( wid3->w, 20); widget_resize ( WIDGET (b ), 200, 20 ); TASSERTE ( wid1->h, 20); TASSERTE ( wid1->w, 88); TASSERTE ( wid2->h, 20); TASSERTE ( wid2->w, 88); TASSERTE ( wid3->h, 20); TASSERTE ( wid3->w, 20); // TASSERTE ( box_get_fixed_pixels ( b ) , 24 ); widget *wid4 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid4 ) ); widget_resize ( WIDGET ( wid4 ), 20, 20 ); box_add ( b , WIDGET( wid4 ), FALSE, 5 ); TASSERTE ( wid4->x, 200-20); widget *wid5 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid5 ) ); widget_resize ( WIDGET ( wid5 ), 20, 20 ); box_add ( b , WIDGET( wid5 ), TRUE, 6 ); TASSERTE ( wid5->x, 149); widget_free ( WIDGET ( b ) ); } { box *b = box_create ( "box", BOX_VERTICAL ); widget_resize ( WIDGET (b), 20, 100); //box_set_padding ( b, 5 ); widget *wid1 = g_malloc0(sizeof(widget)); box_add ( b , WIDGET( wid1 ), TRUE, 0 ); // Widget not enabled. no width allocated. TASSERTE ( wid1->h, 0); TASSERTE ( wid1->w, 0 ); widget_enable ( WIDGET ( wid1 ) ); widget_update ( WIDGET ( b ) ) ; // Widget enabled. so width allocated. TASSERTE ( wid1->h, 100); TASSERTE ( wid1->w, 20 ); widget *wid2 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid2 ) ); box_add ( b , WIDGET( wid2 ), TRUE, 1 ); TASSERTE ( wid1->w, 20); TASSERTE ( wid1->h, 49); TASSERTE ( wid2->w, 20); TASSERTE ( wid2->h, 49); widget *wid3 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid3 ) ); box_add ( b , WIDGET( wid3 ), FALSE, 2 ); TASSERTE ( wid1->w, 20); TASSERTE ( wid1->h, 48); TASSERTE ( wid2->w, 20); TASSERTE ( wid2->h, 48); widget_resize ( WIDGET (wid3) , 10, 20 ); // TODO should this happen automagically? widget_update ( WIDGET ( b ) ) ; TASSERTE ( wid1->w, 20); TASSERTE ( wid1->h, 48); TASSERTE ( wid2->w, 20); TASSERTE ( wid2->h, 48); TASSERTE ( wid3->w, 20); TASSERTE ( wid3->h, 0); widget_resize ( WIDGET (b ), 20, 200 ); TASSERTE ( wid1->w, 20); TASSERTE ( wid1->h, 98); TASSERTE ( wid2->w, 20); TASSERTE ( wid2->h, 98); TASSERTE ( wid3->w, 20); // has no height, gets no height. TASSERTE ( wid3->h, 0); // TASSERTE ( box_get_fixed_pixels ( b ) , 4 ); widget *wid4 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid4 ) ); widget_resize ( WIDGET ( wid4 ), 20, 20 ); box_add ( b , WIDGET( wid4 ), FALSE, 5 ); TASSERTE ( wid4->y, 200); widget *wid5 = g_malloc0(sizeof(widget)); widget_enable ( WIDGET ( wid5 ) ); widget_resize ( WIDGET ( wid5 ), 20, 20 ); box_add ( b , WIDGET( wid5 ), TRUE, 6 ); TASSERTE ( wid5->y, 136); widget_free ( WIDGET ( b ) ); } { box *b = box_create ( "box", BOX_VERTICAL ); widget_resize ( WIDGET (b), 20, 100); //box_set_padding ( b, 5 ); widget *wid1 = g_malloc0(sizeof(widget)); widget_enable(wid1); wid1->clicked = test_widget_clicked; box_add ( b , WIDGET( wid1 ), TRUE, 0 ); widget *wid2 = g_malloc0(sizeof(widget)); widget_enable(wid2); box_add ( b , WIDGET( wid2 ), TRUE, 1 ); xcb_button_press_event_t xce; xce.event_x = 10; xce.event_y = 60; TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0); xce.event_y = 50; TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0); xce.event_y = 48; TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1); widget_disable ( wid2 ); xce.event_y = 60; TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 1); widget_disable ( wid1 ); widget_enable ( wid2 ); TASSERTE ( widget_clicked ( WIDGET(b), &xce ), 0); widget_free ( WIDGET ( b ) ); } }
int main ( G_GNUC_UNUSED int argc, G_GNUC_UNUSED char **argv ) { // box 20 by 40 widget *wid= (widget*)g_malloc0(sizeof(widget)); widget_resize ( wid, 20, 40); widget_move ( wid, 10, 10); // Getter, setter x pos // TASSERT( widget_get_x_pos ( wid ) == 10 ); TASSERT( widget_get_y_pos ( wid ) == 10 ); // Left of box TASSERT ( widget_intersect ( wid, 0, 0) == 0 ); TASSERT ( widget_intersect ( wid, 0, 10) == 0 ); TASSERT ( widget_intersect ( wid, 0, 25) == 0 ); TASSERT ( widget_intersect ( wid, 0, 40) == 0 ); TASSERT ( widget_intersect ( wid, 0, 50) == 0 ); TASSERT ( widget_intersect ( wid, 9, 0) == 0 ); TASSERT ( widget_intersect ( wid, 9, 10) == 0 ); TASSERT ( widget_intersect ( wid, 9, 25) == 0 ); TASSERT ( widget_intersect ( wid, 9, 40) == 0 ); TASSERT ( widget_intersect ( wid, 9, 50) == 0 ); TASSERT ( widget_intersect ( wid, 10, 0) == 0 ); TASSERT ( widget_intersect ( wid, 10, 10) == 1 ); TASSERT ( widget_intersect ( wid, 10, 25) == 1 ); TASSERT ( widget_intersect ( wid, 10, 40) == 1 ); TASSERT ( widget_intersect ( wid, 10, 50) == 0 ); // Middle TASSERT ( widget_intersect ( wid, 25, 0) == 0 ); TASSERT ( widget_intersect ( wid, 25, 10) == 1 ); TASSERT ( widget_intersect ( wid, 25, 25) == 1 ); TASSERT ( widget_intersect ( wid, 25, 40) == 1 ); TASSERT ( widget_intersect ( wid, 25, 50) == 0 ); // Right TASSERT ( widget_intersect ( wid, 29, 0) == 0 ); TASSERT ( widget_intersect ( wid, 29, 10) == 1 ); TASSERT ( widget_intersect ( wid, 29, 25) == 1 ); TASSERT ( widget_intersect ( wid, 29, 40) == 1 ); TASSERT ( widget_intersect ( wid, 29, 50) == 0 ); TASSERT ( widget_intersect ( wid, 30, 0) == 0 ); TASSERT ( widget_intersect ( wid, 30, 10) == 0 ); TASSERT ( widget_intersect ( wid, 30, 25) == 0 ); TASSERT ( widget_intersect ( wid, 30, 40) == 0 ); TASSERT ( widget_intersect ( wid, 30, 50) == 0 ); widget_move ( wid, 30, 30); // Left of box TASSERT ( widget_intersect ( wid, 10, 20) == 0 ); TASSERT ( widget_intersect ( wid, 10, 30) == 0 ); TASSERT ( widget_intersect ( wid, 10, 45) == 0 ); TASSERT ( widget_intersect ( wid, 10, 60) == 0 ); TASSERT ( widget_intersect ( wid, 10, 70) == 0 ); TASSERT ( widget_intersect ( wid, 19, 20) == 0 ); TASSERT ( widget_intersect ( wid, 19, 30) == 0 ); TASSERT ( widget_intersect ( wid, 19, 45) == 0 ); TASSERT ( widget_intersect ( wid, 19, 60) == 0 ); TASSERT ( widget_intersect ( wid, 19, 70) == 0 ); TASSERT ( widget_intersect ( wid, 30, 20) == 0 ); TASSERT ( widget_intersect ( wid, 30, 30) == 1 ); TASSERT ( widget_intersect ( wid, 30, 45) == 1 ); TASSERT ( widget_intersect ( wid, 30, 60) == 1 ); TASSERT ( widget_intersect ( wid, 30, 70) == 0 ); // Middle TASSERT ( widget_intersect ( wid, 20+25,20+ 0) == 0 ); TASSERT ( widget_intersect ( wid, 20+25,20+ 10) == 1 ); TASSERT ( widget_intersect ( wid, 20+25,20+ 25) == 1 ); TASSERT ( widget_intersect ( wid, 20+25,20+ 40) == 1 ); TASSERT ( widget_intersect ( wid, 20+25,20+ 50) == 0 ); TASSERT ( widget_intersect ( wid, 20+29, 20+0) == 0 ); TASSERT ( widget_intersect ( wid, 20+29, 20+10) == 1 ); TASSERT ( widget_intersect ( wid, 20+29, 20+25) == 1 ); TASSERT ( widget_intersect ( wid, 20+29, 20+40) == 1 ); TASSERT ( widget_intersect ( wid, 20+29, 20+50) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+0) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+10) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+25) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 ); // Right TASSERT ( widget_intersect ( wid, 20+29, 20+0) == 0 ); TASSERT ( widget_intersect ( wid, 20+29, 20+10) == 1 ); TASSERT ( widget_intersect ( wid, 20+29, 20+25) == 1 ); TASSERT ( widget_intersect ( wid, 20+29, 20+40) == 1 ); TASSERT ( widget_intersect ( wid, 20+29, 20+50) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+0) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+10) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+25) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+40) == 0 ); TASSERT ( widget_intersect ( wid, 20+30, 20+50) == 0 ); TASSERT ( widget_intersect ( wid, -100, -100) == 0); TASSERT ( widget_intersect ( wid, INT_MIN, INT_MIN) == 0); TASSERT ( widget_intersect ( wid, INT_MAX, INT_MAX) == 0); // Other wrappers. TASSERT ( widget_get_height ( wid ) == wid->h); TASSERT ( widget_get_width ( wid ) == wid->w); TASSERT ( widget_enabled ( wid ) == FALSE ); widget_enable ( wid ); TASSERT ( widget_enabled ( wid ) == TRUE ); widget_disable ( wid ); TASSERT ( widget_enabled ( wid ) == FALSE ); // Null pointer tests. TASSERT ( widget_intersect ( NULL, 0, 0) == 0 ); widget_move ( NULL, 0, 0 ); TASSERT ( widget_get_height ( NULL ) == 0); TASSERT ( widget_get_width ( NULL ) == 0); TASSERT ( widget_enabled ( NULL ) == 0); widget_disable ( NULL ); widget_enable ( NULL ); widget_draw ( NULL, NULL ); widget_free ( NULL ); widget_resize ( NULL, 0, 0); widget_update ( NULL ); widget_queue_redraw ( NULL ); TASSERT (widget_need_redraw ( NULL ) == FALSE); widget_clicked ( NULL, NULL ); widget_set_clicked_handler ( NULL, NULL, NULL ); g_free(wid); }