Ejemplo n.º 1
0
void MultiTabs::Pack()
{
  // Update buttons position
  prev_tab_bt->SetPosition(position.x + MARGIN, position.y + 2);
  next_tab_bt->SetPosition(position.x + size.x - MARGIN - next_tab_bt->GetSizeX(),
                           position.y + 2);

  // Update tabs position
  Point2i tab_pos(position.x + MARGIN, position.y + GetHeaderHeight());
  Point2i tab_size(size.x - 2*MARGIN, size.y - GetHeaderHeight() - MARGIN);

  for (std::vector<Tab>::iterator it=tabs.begin(); it!=tabs.end(); it++) {
    (*it).box->SetPosition(tab_pos);
    (*it).box->SetSize(tab_size);
    (*it).box->Pack();
  }

  // Compute how many tabs can be displayed
  nb_visible_tabs = std::min(uint(tabs.size()), uint(GetSizeX() / TAB_MIN_WIDTH));
  nb_visible_tabs = std::min(nb_visible_tabs, max_visible_tabs);

  if (nb_visible_tabs == 0)
    nb_visible_tabs = 1;

  // Compute tab size in the header
  tab_header_width = ((next_tab_bt->GetPositionX() -
                      (prev_tab_bt->GetPositionX() + prev_tab_bt->GetSizeX()) - 10))
                   / nb_visible_tabs;
}
Ejemplo n.º 2
0
int	rem_var(t_vars *p, char *data)
{
  int	i;

  p->taille_env = tab_size(p->env);
  if (check_existing_variable(p, data) != 0)
    return (-1);
  i = p->var_position + 1;
  while (i < p->taille_env - 1)
    {
      p->env[i] = p->env[i + 1];
      ++i;
    }
  p->env[i] = NULL;
  return (0);
}
Ejemplo n.º 3
0
int	add_var(t_vars *p, char *data)
{
  int	i;
  int	len;
  char	**new_env;

  len = tab_size(p->env);
  data = correctdata(data);
  if ((new_env = malloc(sizeof(*new_env) * (len + 3))) == NULL)
    return (1);
  i = -1;
  while (++i < len)
    new_env[i] = strdup(p->env[i]);
  new_env[i] = data;
  new_env[i + 1] = NULL;
  free_tab(p->env);
  p->env = new_env;
  return (0);
}