⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dw_table.c

📁 嵌入式浏览器Dillo源码
💻 C
📖 第 1 页 / 共 4 页
字号:
                                   DwExtremes *extremes){   DwTable *table = DW_TABLE (widget);   gint32 diff;   if (table->num_cols > 0) {      if (table->sub == NULL)         Dw_table_sub_create (table);      DEBUG_MSG (DEBUG_EXTR_LEVEL + 3,                 "--> Dw_table_get_extremes for (%d x %d) table.\n",                 table->num_cols, table->num_rows);      Dw_table_sub_get_extremes (table->sub);      diff = 2 * widget->style->border_spacing +         p_Dw_style_box_diff_width (widget->style);      extremes->min_width = table->sub->total_extremes.min_width + diff;      extremes->max_width = table->sub->total_extremes.max_width + diff;      DEBUG_MSG (DEBUG_EXTR_LEVEL + 2, "<-- END\n");   } else {      extremes->min_width = widget->style->border_spacing         + p_Dw_style_box_diff_width (widget->style);      extremes->max_width = widget->style->border_spacing         + p_Dw_style_box_diff_width (widget->style);   }}/* * Standard Dw function. */static void Dw_table_size_allocate (DwWidget *widget,                                    DwAllocation *allocation){   DwTable *table = DW_TABLE (widget);   gint row, col, col2, n;   gint32 col_offset, cell_width, vdiff;   DwWidget *child;   DwAllocation child_allocation;   /*    * todo: This implementation depends on that size_request has been    *       called before. Can this be assumed?    */   DEBUG_MSG (2, "Dw_table_size_allocate: %d x %d x %d\n",              allocation->width, allocation->ascent, allocation->descent);   vdiff = allocation->y + p_Dw_style_box_offset_y (widget->style);   for (row = 0; row < table->num_rows; row++) {      col_offset = allocation->x + widget->style->border_spacing         + p_Dw_style_box_offset_x (widget->style);      for (col = 0; col < table->num_cols; col++) {         n = col + row * table->num_cols;         if (CHILD_DEFINED (table, n)) {            cell_width = (table->children[n]->data.cell.colspan - 1)               * widget->style->border_spacing;            for (col2 = col;                 col2 < col + table->children[n]->data.cell.colspan;                 col2++)               cell_width += table->col_width[col2];            child = table->children[n]->data.cell.widget;            child_allocation.x = col_offset;            child_allocation.y = vdiff + table->cum_height[row];            child_allocation.width = cell_width;            child_allocation.ascent =               table->cum_height[row + table->children[n]->data.cell.rowspan] -               table->cum_height[row] - widget->style->border_spacing;            child_allocation.descent = 0;            a_Dw_widget_size_allocate (child, &child_allocation);         }         col_offset += table->col_width[col] + widget->style->border_spacing;      }   }}/* * Standard Dw function. */static void Dw_table_set_width (DwWidget *widget,                                gint32 width){   DwTable *table;   table = DW_TABLE (widget);   /* If limit_text_width is set to YES, a queue_resize may also be      necessary. */   if (table->avail_width != width || prefs.limit_text_width) {      table->avail_width = width;      p_Dw_widget_queue_resize (widget, 0, FALSE);   }}/* * Standard Dw function. */static void Dw_table_set_ascent (DwWidget *widget,                                 gint32 ascent){   DwTable *table;   table = DW_TABLE (widget);   if (table->avail_ascent != ascent) {      table->avail_ascent = ascent;      p_Dw_widget_queue_resize (widget, 0, FALSE);   }}/* * Standard Dw function. */static void Dw_table_set_descent (DwWidget *widget,                                  gint32 descent){   DwTable *table;   table = DW_TABLE (widget);   if (table->avail_descent != descent) {      table->avail_descent = descent;      p_Dw_widget_queue_resize (widget, 0, FALSE);   }}/* * Standard Dw function. */static void Dw_table_draw (DwWidget *widget,                           DwRectangle *area,                           GdkEventExpose *event){   /* can be optimized, by iterating on the lines in area */   DwTable *table = DW_TABLE (widget);   DwRectangle child_area;   DwWidget *child;   gint i;   gint32 offx, offy, width;   p_Dw_widget_draw_widget_box (widget, area);   offx = p_Dw_style_box_offset_x (widget->style);   offy = p_Dw_style_box_offset_y (widget->style);   width = widget->allocation.width - p_Dw_style_box_diff_width(widget->style);   for (i = 0; i < table->num_rows; i++)      if (table->row_style[i])         p_Dw_widget_draw_box (widget, table->row_style[i], area,                               offx, offy + table->cum_height[i],                               width,                               table->cum_height[i + 1] - table->cum_height[i]                               - widget->style->border_spacing);   for (i = 0; i < table->num_children; i++)      if (CHILD_DEFINED (table, i)) {         child = table->children[i]->data.cell.widget;         if (p_Dw_widget_intersect (child, area, &child_area)) {#ifdef BORDERS            gdk_draw_rectangle               (DW_WIDGET_WINDOW (child),                widget->viewport->style->dark_gc[widget->viewport->state],                FALSE,                Dw_widget_x_world_to_viewport (child, child->allocation.x) - 1,                Dw_widget_y_world_to_viewport (child, child->allocation.y) - 1,                child->allocation.width + 2,                child->allocation.ascent + child->allocation.descent + 2);#endif            a_Dw_widget_draw (child, &child_area, event);         }      }#ifdef BORDERS   gdk_draw_rectangle (DW_WIDGET_WINDOW (widget),                       widget->style->color->gc, FALSE,                       Dw_widget_x_world_to_viewport (widget,                                                      widget->allocation.x),                       Dw_widget_y_world_to_viewport (widget,                                                      widget->allocation.y),                       widget->allocation.width,                       widget->allocation.ascent + widget->allocation.descent);#endif}/* * Standard Dw function. */static void Dw_table_add (DwContainer *container,                          DwWidget *widget){   a_Dw_table_add_cell (DW_TABLE (container), widget, 1, 1);}/* * Standard Dw function. */static void Dw_table_remove (DwContainer *container,                             DwWidget *widget){   /* used? */}/* * Standard Dw function. */static void Dw_table_forall (DwContainer *container,                             DwCallback callback,                             gpointer callback_data){   gint i;   DwTable *table = DW_TABLE (container);   for (i = 0; i < table->num_children; i++)      if (CHILD_DEFINED (table, i))         callback (table->children[i]->data.cell.widget, callback_data);}/* * Standard DwContainer function. */static gint Dw_table_findtext (DwContainer *container,                               gpointer FP, gpointer KP,                               gchar *NewKey){   DwWidget *widget;   DwTable *table = DW_TABLE (container);   FindData *F = *(FindData**)FP;   g_return_val_if_fail ((DW_WIDGET(table))->viewport != NULL && KP, 0);   if ( !F )      *(FindData **)FP = F = g_new0(FindData, 1);   if ( !F->Key || strcmp(F->Key->KeyStr, NewKey) ||        F->widget != DW_WIDGET (table) )      F->State = F_NewKey;   /* Let the FSM find the search string */   while ( 1 ) {      switch (F->State) {      case F_NewKey:         F->Key = KP;         F->widget = DW_WIDGET (table);         F->WordNum = 0;         F->State = F_Seek;         break;      case F_Seek:         for (   ; F->WordNum < table->num_children; F->WordNum++) {           if (CHILD_DEFINED (table, F->WordNum)){              widget = table->children[F->WordNum]->data.cell.widget;              if (DW_IS_CONTAINER (widget) &&                  a_Dw_container_findtext(DW_CONTAINER (widget),                                          (gpointer)&F->next,                                          (gpointer)F->Key,                                          NewKey)){                  F->State = F_Seek;                  return 1;              }           }         }         F->State = F_End;         break;      case F_GetPos:      case F_Found:      case F_End:         /* free memory */         g_free(F);         *(FindData **)FP = NULL;         return 0;      }   }   /* compiler happiness */   return 0;}/* * Make sure that there is enough space for table->children, * table->cum_height and table->row_style, and fill the rest of * table->children with NULL. */static void Dw_table_realloc_children (DwTable *table){   gint old_num_children, i;   table->num_rows++;   a_List_resize (table->cum_height, table->num_rows, table->cum_height_max);   table->num_rows--;   a_List_resize (table->row_style, table->num_rows, table->row_style_max);   old_num_children = table->num_children;   table->num_children = table->num_cols * table->num_rows;   a_List_resize (table->children, table->num_children,                  table->num_children_max);   for (i = old_num_children; i < table->num_children; i++)      table->children[i] = NULL;}/* * Add widget as a cell to table. colspan and rowspan have the same * meaning as the attributes of <td> and <th>. */void a_Dw_table_add_cell (DwTable *table,                          DwWidget *widget,                          gint colspan,                          gint rowspan){   gint col, row, old_num_cols, old_num_rows;   DwTableChild *child;   if (table->num_rows == 0)      /* to prevent a crash */      a_Dw_table_add_row (table, NULL);   /* todo: {col|row}span = 0 is not supported yet: */   if (colspan < 1)      colspan = 1;   if (rowspan < 1)      rowspan = 1;   while (table->cur_col < table->num_cols &&          (child = table->children[table->cur_row * table->num_cols                                   + table->cur_col]) != NULL &&          child->type == DW_TABLE_SPAN_SPACE)      table->cur_col++;   if (table->cur_row + rowspan > table->num_rows) {      old_num_rows = table->num_rows;      table->num_rows = table->cur_row + rowspan;      Dw_table_realloc_children (table);      for (row = old_num_rows; row < table->num_rows; row++)         table->row_style[row] = NULL;   }   if (table->cur_col + colspan > table->num_cols) {      old_num_cols = table->num_cols;      table->num_cols = table->cur_col + colspan;      a_List_resize (table->col_width, table->num_cols,                     table->num_col_width_max);      table->num_children = table->num_cols * table->num_rows;      a_List_resize (table->children, table->num_children,                     table->num_children_max);      for (row = table->num_rows - 1; row >= 0; row--) {         for (col = old_num_cols - 1; col >= 0; col--) {            table->children[row * table->num_cols + col] =               table->children[row * old_num_cols + col];         }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -