replace all cells in current grid with updated grid
559918
def replace_grid(self, updated_grid):
        
        for col in range(self.get_grid_width()):
            for row in range(self.get_grid_height()):
                if updated_grid[row][col] == EMPTY:
                    self.set_empty(row, col)
                else:
                    self.set_full(row, col)
917516
def ResetView(self):
        

        grid = self.grid

        current_rows = self.grid.GetNumberRows()
        current_cols = self.grid.GetNumberCols()

        grid.BeginBatch()

        for current, new, delmsg, addmsg in [
            (current_rows, self.GetNumberRows(),
             wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED,
             wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
            (current_cols, self.GetNumberCols(),
             wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED,
             wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED)]:

            if new < current:
                msg = wx.grid.GridTableMessage(self, delmsg, new,
                                               current - new)
                grid.ProcessTableMessage(msg)
            elif new > current:
                msg = wx.grid.GridTableMessage(self, addmsg, new - current)
                grid.ProcessTableMessage(msg)
                self.UpdateValues()

        grid.EndBatch()

        # Reset cell sizes to standard cell size

        grid.SetDefaultRowSize(grid.GetDefaultRowSize(),
                               resizeExistingRows=True)
        grid.SetDefaultColSize(grid.GetDefaultColSize(),
                               resizeExistingCols=True)

        # Adjust rows
        row_heights = grid.code_array.row_heights
        for key in row_heights:
            if key[1] == grid.current_table and \
               key[0] < self.code_array.shape[0]:
                row = key[0]
                if row_heights[key] is None:
                    # Default row size
                    grid.SetRowSize(row, grid.GetDefaultRowSize())
                else:
                    grid.SetRowSize(row, row_heights[key])

        # Adjust columns
        col_widths = grid.code_array.col_widths
        for key in col_widths:
            if key[1] == grid.current_table and \
               key[0] < self.code_array.shape[1]:
                col = key[0]
                if col_widths[key] is None:
                    # Default row size
                    grid.SetColSize(col, grid.GetDefaultColSize())
                else:
                    grid.SetColSize(col, col_widths[key])

        # update the scrollbars and the displayed part
        # of the grid

        grid.Freeze()
        grid.AdjustScrollbars()
        grid.Refresh()
        grid.Thaw()
1175068
def _adjust_rowcol(self, insertion_point, no_to_insert, axis, tab=None):
        """"""

        if axis == 2:
            self._shift_rowcol(insertion_point, no_to_insert)
            return

        assert axis in (0, 1)

        cell_sizes = self.col_widths if axis else self.row_heights
        set_cell_size = self.set_col_width if axis else self.set_row_height

        new_sizes = {}
        del_sizes = []

        for pos, table in cell_sizes:
            if pos > insertion_point and (tab is None or tab == table):
                if 0 <= pos + no_to_insert < self.shape[axis]:
                    new_sizes[(pos + no_to_insert, table)] = \
                        cell_sizes[(pos, table)]
                del_sizes.append((pos, table))

        for pos, table in new_sizes:
            set_cell_size(pos, table, new_sizes[(pos, table)])

        for pos, table in del_sizes:
            if (pos, table) not in new_sizes:
                set_cell_size(pos, table, None)
1111509
def replace(self, nodes, node):
        """"""
        nodes = nodes if isinstance(nodes, list) else [nodes]
        # Is the new node part of the replace nodes (i.e. want to collapse
        # a group of nodes into one of them)?
        collapse = self.id(node) in self.nodes
        # Add new node and edges
        if not collapse:
            self.add_node(node)
        for in_node in self.incoming(nodes):
            # TODO: check specifically for output_shape is not generic. Consider refactoring.
            self.add_edge(in_node, node, in_node.output_shape if hasattr(in_node, "output_shape") else None)
        for out_node in self.outgoing(nodes):
            self.add_edge(node, out_node, node.output_shape if hasattr(node, "output_shape") else None)
        # Remove the old nodes
        for n in nodes:
            if collapse and n == node:
                continue
            self.remove(n)
410284
def replaceAll(self):
        
        while self.replaceSelected():
            pass

        self.qteWidget.SCISetStylingEx(0, 0, self.styleOrig)
        self.qteMain.qteKillMiniApplet()
584356
def OnGridSelection(self, event):
        """"""

        current_table = copy(self.main_window.grid.current_table)

        post_command_event(self, self.GridActionTableSwitchMsg,
                           newtable=self.last_table)
        if is_gtk():
            try:
                wx.Yield()
            except:
                pass

        sel_start, sel_stop = self.last_selection

        shape = self.main_window.grid.code_array.shape
        selection_string = event.selection.get_access_string(shape,
                                                             current_table)

        self.Replace(sel_start, sel_stop, selection_string)
        self.last_selection = sel_start, sel_start + len(selection_string)

        post_command_event(self, self.GridActionTableSwitchMsg,
                           newtable=current_table)
1327143
function autoplaceGridItems (decl, result, gap, autoflowValue = 'row') {
  let { parent } = decl

  let rowDecl = parent.nodes.find(i => i.prop === 'grid-template-rows')
  let rows = normalizeRowColumn(rowDecl.value)
  let columns = normalizeRowColumn(decl.value)

  // Build array of area names with dummy values. If we have 3 columns and
  // 2 rows, filledRows will be equal to ['1 2 3', '4 5 6']
  let filledRows = rows.map((_, rowIndex) => {
    return Array.from({ length: columns.length }, (v, k) =>
      k + (rowIndex * columns.length) + 1).join(' ')
  })

  let areas = parseGridAreas({ rows: filledRows, gap })
  let keys = Object.keys(areas)
  let items = keys.map(i => areas[i])

  // Change the order of cells if grid-auto-flow value is 'column'
  if (autoflowValue.includes('column')) {
    items = items.sort((a, b) => a.column.start - b.column.start)
  }

  // Insert new rules
  items.reverse().forEach((item, index) => {
    let { column, row } = item
    let nodeSelector = parent.selectors.map(sel =>
      sel + ` > *:nth-child(${ keys.length - index })`).join(', ')

    // create new rule
    let node = parent.clone().removeAll()

    // change rule selector
    node.selector = nodeSelector

    // insert prefixed row/column values
    node.append({ prop: '-ms-grid-row', value: row.start })
    node.append({ prop: '-ms-grid-column', value: column.start })

    // insert rule
    parent.after(node)
  })

  return undefined
}
122562
function re_initGridCompFixedColumn() {
    var oThis = this;
    var w = 0;
    var removeArr = [];
    $.each(this.gridCompColumnArr, function (i) {
        if (this.options.fixed == true) {
            oThis.gridCompColumnFixedArr.push(this);
        }
    });
    $.each(this.gridCompColumnFixedArr, function (i) {
        if (this.options.fixed != true) {
            oThis.gridCompColumnArr.push(this);
            removeArr.push(this);
        }
    });
    $.each(removeArr, function (i) {
        for (var i = oThis.gridCompColumnFixedArr.length; i > -1; i--) {
            if (this == oThis.gridCompColumnFixedArr[i]) {
                oThis.gridCompColumnFixedArr.splice(i, 1);
                break;
            }
        }
    });
    $.each(this.gridCompColumnFixedArr, function (i) {
        for (var i = oThis.gridCompColumnArr.length; i > -1; i--) {
            if (oThis.gridCompColumnArr[i] == this) {
                oThis.gridCompColumnArr.splice(i, 1);
                break;
            }
        }
    });
}
287517
def BeginEdit(self, row, col, grid):
        

        # Disable if cell is locked, enable if cell is not locked
        grid = self.main_window.grid
        key = grid.actions.cursor

        locked = grid.code_array.cell_attributes[key]["locked"]or \
            grid.code_array.cell_attributes[key]["button_cell"]
        self._tc.Enable(not locked)
        self._tc.Show(not locked)

        if locked:
            grid.code_array.result_cache.clear()
            self._execute_cell_code(row, col, grid)

        # Mirror our changes onto the main_window's code bar
        self._tc.Bind(wx.EVT_CHAR, self.OnChar)
        self._tc.Bind(wx.EVT_KEY_UP, self.OnKeyUp)

        # Save cell and grid info
        self._row = row
        self._col = [col, ]  # List of columns we are occupying
        self._grid = grid

        start_value = grid.GetTable().GetValue(*key)

        try:
            start_value_list = [start_value[i:i+self.max_char_width]
                                for i in xrange(0, len(start_value),
                                                self.max_char_width)]
            startValue = "\n".join(start_value_list)
            self.startValue = startValue

        except TypeError:
            self.startValue = u""

        # Set up the textcontrol to look like this cell (TODO: Does not work)
        try:
            self._tc.SetValue(unicode(startValue))
        except (TypeError, AttributeError, UnboundLocalError):
            self._tc.SetValue(u"")

        self._tc.SetFont(grid.GetCellFont(row, col))
        self._tc.SetBackgroundColour(grid.GetCellBackgroundColour(row, col))
        self._update_control_length()

        self._tc.SetInsertionPointEnd()

        h_scroll_pos = grid.GetScrollPos(wx.SB_HORIZONTAL)
        v_scroll_pos = grid.GetScrollPos(wx.SB_VERTICAL)

        self._tc.SetFocus()

        # GTK Bugfix for jumping grid when focusing the textctrl
        if grid.GetScrollPos(wx.SB_HORIZONTAL) != h_scroll_pos or \
           grid.GetScrollPos(wx.SB_VERTICAL) != v_scroll_pos:
            wx.ScrolledWindow.Scroll(grid, (h_scroll_pos, v_scroll_pos))

        # Select the text
        self._tc.SetSelection(0, self._tc.GetLastPosition())
159636
def _redraw(self):
        
        for row in self._rows:
            for widget in row:
                widget.grid_forget()

        offset = 0 if not self.headers else 1
        for i, row in enumerate(self._rows):
            for j, widget in enumerate(row):
                widget.grid(row=i+offset, column=j)
441131
def OnButtonCell(self, event):
        """"""

        # The button text
        text = event.text

        with undo.group(_("Button")):
            self.grid.actions.set_attr("button_cell", text)

        self.grid.ForceRefresh()

        self.grid.update_attribute_toolbar()

        event.Skip()
756115
def clean_up(self):#, grid):
        
        if self.selected_col:
            col_label_value = self.grid.GetColLabelValue(self.selected_col)
            col_label_value = col_label_value.strip('\nEDIT ALL')
            self.grid.SetColLabelValue(self.selected_col, col_label_value)
            for row in range(self.grid.GetNumberRows()):
                self.grid.SetCellBackgroundColour(row, self.selected_col, 'white')
        self.grid.ForceRefresh()
1105545
def _redraw(self):
        
        if self._blank_label:
            self._blank_label.grid_forget()
            self._blank_label.destroy()
            self._blank_label = None

        for slot in self._slots:
            slot.grid_forget()

        self._slots = [slot for slot in self._slots if not slot.deleted]

        max_per_col = 8
        for i, slot in enumerate(self._slots):
            slot.grid(row=i % max_per_col,
                      column=int(i / max_per_col), sticky='ew')
688025
def ApplyEdit(self, row, col, grid):
        

        val = self._tc.GetValue()
        grid.GetTable().SetValue(row, col, val)  # update the table

        self.startValue = ''
        self._tc.SetValue('')
817032
function updateColumns(item, newColumns) {
  item._tableStructure.columns = newColumns;
  if (item._tableStructure.columns.length === 0) {
    // Nothing to show, so the attempt to redraw will fail; need to explicitly hide the existing regions.
    item._regionMapping.hideImageryLayer();
    item.terria.currentViewer.notifyRepaintRequired();
  }
  // Close any picked features, as the description of any associated with this catalog item may change.
  item.terria.pickedFeatures = undefined;
}
309979
def change_grid_shape(self, shape):
        """"""

        # Mark content as changed
        post_command_event(self.main_window, self.ContentChangedMsg)

        self.code_array.shape = shape

        # Update TableChoiceIntCtrl
        post_command_event(self.main_window, self.ResizeGridMsg, shape=shape)

        # Change grid table dimensions
        self.grid.GetTable().ResetView()

        # Clear caches
        self.code_array.result_cache.clear()
1063879
function insertColumn(
    opts: Options,
    change: Change,
    at?: number, // Column index
    getCell?: (column: number, row: number) => Block
): Change {
    const { value } = change;
    const { startKey } = value;

    const pos = TablePosition.create(opts, value.document, startKey);
    const { table } = pos;

    const columnIndex =
        typeof at === 'undefined' ? pos.getColumnIndex() + 1 : at;

    // Insert the new cell
    table.nodes.forEach((row, rowIndex) => {
        const newCell = getCell
            ? getCell(columnIndex, rowIndex)
            : createCell(opts);
        change.insertNodeByKey(row.key, columnIndex, newCell, {
            normalize: false
        });
    });

    // Update the selection (not doing can break the undo)
    return moveSelection(
        opts,
        change,
        pos.getColumnIndex() + 1,
        pos.getRowIndex()
    );
}