void spicker::handle_inside_event(Event &ev, image *screen, InputManager *inm)
{
  switch (ev.type)
  {
    case EV_MOUSE_MOVE :
    {
      if (activate_on_mouse_move())
      {
    int me;
    if (vert)
      me=last_sel+(ev.mouse_move.y-m_pos.y)/item_height();
    else
      me=last_sel+(ev.mouse_move.x-m_pos.x)/item_width();
    if (me<t && me>=0)
    {
      if (cur_sel!=me)
      {
        cur_sel=me;
        scroll_event(last_sel,screen);
        note_new_current(screen,inm,me);
      }
    }
      }
    } break;
    case EV_MOUSE_BUTTON :
    {
      int me;
      if (vert)
    me=last_sel+(ev.mouse_move.y-m_pos.y)/item_height();
      else
    me=last_sel+(ev.mouse_move.x-m_pos.x)/item_width();
      if (me<t && me>=0)
      {
    if (m)
    {
      if (ev.mouse_button)
      {
        if (ok_to_select(me))
        {
          set_select(me,!get_select(me));
          scroll_event(last_sel,screen);
          inm->grab_focus(this);
        }
      } else last_click=-1;

    } else if (ok_to_select(me))
    {
      if (cur_sel==me)
        note_selection(screen,inm,me);
      else
      {
        cur_sel=me;
        scroll_event(last_sel,screen);
        note_new_current(screen,inm,me);
      }
    }
      }
    } break;
  }
}
void w_saves::click(int x, int y)
{
    if (x == 0 && y == 0 && active) {
        // almost certainly a simulated click
        if (num_items > 0)
            item_selected();
    }
    else if (x >= trough_rect.x && x < trough_rect.x + trough_rect.w
             && y >= thumb_y && y <= thumb_y + thumb_height) {
        thumb_dragging = dirty = true;
        thumb_drag_y = y - thumb_y;
    } else {
        if (x < get_theme_space(LIST_WIDGET, L_SPACE) || x >= rect.w - get_theme_space(LIST_WIDGET, R_SPACE)
            || y < get_theme_space(LIST_WIDGET, T_SPACE) || y >= rect.h - get_theme_space(LIST_WIDGET, B_SPACE))
            return;
        
        if ((y - get_theme_space(LIST_WIDGET, T_SPACE)) / item_height() + top_item < min(num_items, top_item + shown_items))
        {
            size_t old_sel = selection;
            set_selection((y - get_theme_space(LIST_WIDGET, T_SPACE)) / item_height() + top_item);
            if (selection == old_sel && num_items > 0 && is_item_selectable(selection))
                item_selected();
        }
    }
}
Exemple #3
0
void spicker::area_config() {
	if (vert)
		l = item_width() + 4;
	else
		l = item_width() * c + 4;

	if (vert)
		h = item_height() * r + 4;
	else
		h = item_height() + 4;

}
 w_saves(std::vector<QuickSave>& saves, int width, int numRows) : w_list_base(width, numRows, 0), m_saves(saves)
 {
     saved_min_height = item_height() * static_cast<uint16>(shown_items) + get_theme_space(LIST_WIDGET, T_SPACE) + get_theme_space(LIST_WIDGET, B_SPACE);
     trough_rect.h = saved_min_height - get_theme_space(LIST_WIDGET, TROUGH_T_SPACE) - get_theme_space(LIST_WIDGET, TROUGH_B_SPACE);
     num_items = m_saves.size();
     new_items();
 }
Exemple #5
0
void spicker::scroll_event(int newx, image *screen) {
	last_sel = newx;
	int xa, ya, xo, yo;
	xo = x + 2;
	yo = y + 2;
	if (vert) {
		xa = 0;
		ya = item_height();
	} else {
		xa = item_width();
		ya = 0;
	}
	draw_background(screen);

	for (int i = newx; i < newx + vis(); i++) {
		if (i < t) {
			if (m)
				draw_item(screen, xo, yo, i, get_select(i));
			else
				draw_item(screen, xo, yo, i, i == cur_sel);
		}
		xo += xa;
		yo += ya;
	}
}
 virtual void draw_item(image *screen, int x, int y, int num, int active)
 {
     long x2 = x + item_width() - 1;
     long y2 = y + item_height() - 1;
     screen->Bar(ivec2(x, y), ivec2(x2, y2), 0);
     screen->Bar(ivec2(x, y), ivec2(x2 - 3, y2), sc + num);
     if(active)
     {
         screen->Rectangle(ivec2(x, y), ivec2(x2, y2), 255);
     }
 }
Exemple #7
0
void w_plugins::draw_items(SDL_Surface* s) const
{
  Plugins::iterator i = m_plugins.begin();
  int16 x = rect.x + get_theme_space(LIST_WIDGET, L_SPACE);
  int16 y = rect.y + get_theme_space(LIST_WIDGET, T_SPACE);
  uint16 width = rect.w -
                 get_theme_space(LIST_WIDGET, L_SPACE) - get_theme_space(
    LIST_WIDGET, R_SPACE);

  for (size_t n = 0; n < top_item; ++n)
  {
    ++i;
  }

  for (size_t n = top_item; n < top_item + MIN(shown_items, num_items);
       ++n, ++i, y = y + item_height())
    draw_item(i, s, x, y, width, n == selection && active);
}
void spicker::area_config()
{
    l = item_width() * (vert ? 1 : c) + 4;
    h = item_height() * (vert ? r : 1) + 4;
}