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

📄 dw_table.c

📁 飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序
💻 C
📖 第 1 页 / 共 5 页
字号:
      /* Below the last row: We create an iterator of the last child,       * starting at the end (if possible). */      it = Dw_table_construct_last_iterator (table, &char_pos);   else {      if (y < table->cum_height[row] + offy) {         /* Before the row: Start at first column. */         col = 0;      } else {         /* Within the row: Search column.          * NOTE: col may be table->num_cols, this is intended, see below */         cum_width =            p_Dw_style_box_offset_x (DW_WIDGET(table)->style) +            cellspacing + table->col_width[0];         col = 0;         while (col < table->num_cols && x > cum_width) {            col++;            cum_width += table->col_width[col] + cellspacing;         }         /* Already right of the middle of the next column?          * (Actually, this feature is only needed for cases where widgets          * are added to a table, which do not process mouse events. This          * is never the case in dillo. But it works.) */         if (col < table->num_cols &&             x >= cum_width - table->col_width[col] / 2)            col++;      }      n = col + row * table->num_cols;      /* If col == table->num_cols, this may be happen: */      if (n == table->num_children)         it = Dw_table_construct_last_iterator (table, &char_pos);      else {         /* some corrections */         for (; n < table->num_children; n++) {            if ((child = table->children[n]) &&                child->type == DW_TABLE_CELL) {               it = Dw_table_construct_iterator (table, n);               break;            }         }      }   }   if (it) {      return fn (GTK_DW_VIEWPORT(DW_WIDGET(table)->viewport)->selection,                 it, char_pos, -1, event, FALSE);   } else      return FALSE;}#endif/* * Standard Dw function. */static gboolean Dw_table_button_press (DwWidget *widget,                                       gint32 x,                                       gint32 y,                                       DWORD flags){#if 0   return Dw_table_send_selection_event (DW_TABLE (widget),                                         a_Selection_button_press, x, y,                                         flags);#endif   return TRUE;}/* * Standard Dw function. */static gboolean Dw_table_button_release (DwWidget *widget,                                         gint32 x,                                         gint32 y,                                         DWORD flags){#if 0   return Dw_table_send_selection_event (DW_TABLE (widget),                                         a_Selection_button_release, x, y,                                         flags);#endif   return TRUE;}/* * Standard Dw function. */static gboolean Dw_table_motion_notify (DwWidget *widget,                                        gint32 x,                                        gint32 y,                                        DWORD flags){#if 0   if (event && (event->state & GDK_BUTTON1_MASK))      return Dw_table_send_selection_event (DW_TABLE (widget),                                            a_Selection_button_motion, x, y,                                            NULL);   else#endif      return FALSE;}/* * 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);}/* * Make sure that there is enough space for table->children, * table->cum_height etc., 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);   a_List_resize (table->baseline, table->num_rows, table->baseline_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];         }         for (col = old_num_cols; col < table->num_cols; col++)            table->children[row * table->num_cols + col] = NULL;      }   }   for (col = 0; col < colspan; col++)      for (row = 0; row < rowspan; row++)         if (!(col == 0 && row == 0)) {            child = g_new (DwTableChild, 1);            child->type = DW_TABLE_SPAN_SPACE;            child->data.span_space.start_col = table->cur_col;            child->data.span_space.start_row = table->cur_row;            table->children[(table->cur_row + row) * table->num_cols                           + (table->cur_col + col)] = child;         }   child = g_new (DwTableChild, 1);   child->type = DW_TABLE_CELL;   child->data.cell.widget = widget;   child->data.cell.colspan = colspan;   child->data.cell.rowspan = rowspan;   table->children[table->cur_row * table->num_cols + table->cur_col] = child;   table->cur_col += colspan;   p_Dw_widget_set_parent (widget, DW_WIDGET (table));   if (table->row_style[table->cur_row] != NULL)      p_Dw_widget_set_bg_color         (widget, table->row_style[table->cur_row]->background_color);   p_Dw_widget_queue_resize (widget, 0, TRUE);   /* The cell structure has changed, so the subtables have to be rebuilt. */   if (table->sub) {      Dw_table_sub_free (table->sub);      table->sub = NULL;   }}/* * Add a new row to the table, and start adding cells from the * left-most column. */void a_Dw_table_add_row (DwTable *table,                         DwStyle *style){   gint row, old_num_rows;   table->cur_row++;   if (table->cur_row >= table->num_rows) {      old_num_rows = table->num_rows;      table->num_rows = table->cur_row + 1;      Dw_table_realloc_children (table);      for (row = old_num_rows; row < table->num_rows; row++)         table->row_style[row] = NULL;   }   if (table->row_style[table->cur_row])      a_Dw_style_unref (table->row_style[table->cur_row]);   table->row_style[table->cur_row] = style;   if (style)      a_Dw_style_ref (style);   table->cur_col = 0;}/* * Returns the DwTableCell to be passed to a_Dw_table_cell_new(). */DwTableCell* a_Dw_table_get_cell_ref (DwTable *table){   gint row, n;   DwWidget *child;   for (row = 0; row <= table->num_rows; row++) {      n = table->cur_col + row * table->num_cols;      if (CHILD_DEFINED (table, n)) {         child = table->children[n]->data.cell.widget;         if (DW_IS_TABLE_CELL (child))            return DW_TABLE_CELL (child);      }   }   return NULL;}/* ---------------------------------------------------------------------- * *    General Functions for Subtables * * ---------------------------------------------------------------------- */static gboolean Dw_table_sub_spans_width (DwTableSub *sub,                                         gint row){   gint n, start_col, start_row, start_n, colspan;   n = sub->start_col + sub->table->num_cols * row;   if (sub->table->children[n]) {      if (sub->table->children[n]->type == DW_TABLE_CELL) {         start_col = sub->start_col;         start_row = row;      } else {         start_col = sub->table->children[n]->data.span_space.start_col;         start_row = sub->table->children[n]->data.span_space.start_row;      }      start_n = start_col + sub->table->num_cols * start_row;      colspan = sub->table->children[start_n]->data.cell.colspan;      return (start_col <= sub->start_col &&              start_col + colspan >= sub->end_col);   } else      return FALSE;}/* * Fill the DwTableSub and create the sub DwTableSub's. Only for use * by Dw_table_get_sub. */static void Dw_table_sub_calc_subs (DwTableSub *sub){   gint col, row, n, start_n, colspan, most_right, start_col, start_row;   if (sub->start_col + 1 == sub->end_col) {      DEBUG_MSG (DEBUG_CALC_LEVEL + 2, "   single column at %d\n",                 sub->start_col);      sub->num_subs = 0;      sub->subs = NULL;      for (row = 0; row < sub->table->num_rows; row++)         if (!a_Bitvec_get_bit (sub->removed_rows, row)) {            a_Bitvec_set_bit (sub->spanning_rows, row);

⌨️ 快捷键说明

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