Esempio n. 1
0
void t_list_view::__calculate_item_positions(t_size index_start)
{
	if (index_start >= get_item_count()) return;

	t_size y_pointer = 0;
	if (m_group_count)
		while (index_start && get_item_display_group_count(index_start) == 0) index_start--;
	if (!index_start)
		y_pointer += 0;//m_item_height * m_group_count;
	else
	{
		if (m_group_count)
			y_pointer = get_item_group_bottom(index_start-1)+1;
		else
			y_pointer = get_item_position(index_start-1)+get_item_height(index_start-1);
	}
	t_size i, count = m_items.get_count(), group_height_counter=0, group_minimum_inner_height = get_group_minimum_inner_height();
	for (i=index_start; i<count; i++)
	{
		t_size groups = get_item_display_group_count(i);
		if (groups)
		{
			if (group_height_counter && group_height_counter < group_minimum_inner_height)
				y_pointer += group_minimum_inner_height - group_height_counter;
			group_height_counter=0;
		}
		group_height_counter+=get_item_height(i);
		y_pointer += groups*m_group_height;
		m_items[i]->m_display_position = y_pointer;
		y_pointer+= get_item_height(i);
	}
}
Esempio n. 2
0
/* to reflect the shift in position */
void StMObDeleteItem(LVAL menu, LVAL item)
{
  HMENU addr;
  int n, i, j, id, flags;
  LVAL items;
  char *s;

  if (StMObAllocated(menu)) {
    addr = get_menu_address(menu);
    id = get_menu_id(menu);
    i = get_item_position(menu, item);
    for (j = 0, items = slot_value(menu, s_items);
	 j < i && consp(items);
	 j++, items = cdr(items));
    n = GetMenuItemCount((HMENU) addr);
    for (; i < n; n--) DeleteMenu((HMENU) addr, i, MF_BYPOSITION);
    if (consp(items)) items = cdr(items);
    for (; consp(items); items = cdr(items), i++) {
      item = car(items);
      s = get_item_string(item);
      if (s[0] == '-') AppendMenu((HMENU) addr, MF_SEPARATOR, 0, NULL);
      else {
	flags = MF_STRING;
	if (slot_value(item, s_mark) != NIL) flags |= MF_CHECKED;
	if (slot_value(item, s_enabled) == NIL) flags |= MF_GRAYED;
	AppendMenu((HMENU) addr, flags, MAKEITEMINDEX(id, i), s);
      }
    }
  }
}
Esempio n. 3
0
void tslider::child_callback_positioner_moved()
{
	sound::play_UI_sound(settings::sound_slider_adjust);

	if (callback_value_changed_) {
		callback_value_changed_(this, minimum_value_ + get_item_position() * get_step_size());
	}
}
Esempio n. 4
0
t_string tslider::get_value_label() const
{
	if(value_labels_) {
		return value_labels_(get_item_position(), get_item_count());
	} else if(!minimum_value_label_.empty() && get_value()
											   == get_minimum_value()) {
		return minimum_value_label_;
	} else if(!maximum_value_label_.empty() && get_value()
											   == get_maximum_value()) {
		return maximum_value_label_;
	} else {
		return t_string((formatter() << get_value()).str());
	}
}
Esempio n. 5
0
t_string tslider::get_value_label() const
{
	if(!value_labels_.empty()) {
		VALIDATE(value_labels_.size() == get_item_count(), null_str);
		return value_labels_[get_item_position()];
	} else if(!minimum_value_label_.empty()
			&& get_value() == get_minimum_value()) {
		return minimum_value_label_;
	} else if(!maximum_value_label_.empty()
			&& get_value() == get_maximum_value()) {
		return maximum_value_label_;
	} else {
		return t_string((formatter() << get_value()).str());
	}
}
t_string tslider::get_value_label() const
{
	if(!value_labels_.empty()) {
		assert(value_labels_.size() == get_item_count());
		return value_labels_[get_item_position()];
	} else if(!minimum_value_label_.empty()
			&& get_value() == get_minimum_value()) {
		return minimum_value_label_;
	} else if(!maximum_value_label_.empty()
			&& get_value() == get_maximum_value()) {
		return maximum_value_label_;
	} else {
		return t_string(formatter_(get_value()));
	}
}
Esempio n. 7
0
/* adjust internal implementation of allocated menu to new instance value */
void StMObSetItemProp(LVAL item, int which)
{
  char *s;
  HMENU theMenu;
  LVAL menu, title;
  int i, flags, id;

  menu = slot_value(item, s_menu);
  if (menu != NIL && StMObAllocated(menu)) {
    theMenu = get_menu_address(menu);
    id = get_menu_id(menu);
    i = get_item_position(menu, item);
    title = slot_value(item, s_title);
    if (! stringp(title))
      xlerror("title is not a string", title);
    s = (char *) getstring(title);
    if (s[0] == '-' && which != 'T') return;
    switch (which) {
    case 'T':
      if (s[0] == '-') {
	flags = MF_SEPARATOR | MF_BYPOSITION;
	ModifyMenu((HMENU) theMenu, i, flags, 0, NULL);
      }
      else {
	flags = MF_STRING | MF_BYPOSITION;
	flags |= (slot_value(item, s_mark) != NIL) ? MF_CHECKED : MF_UNCHECKED;
	flags |= (slot_value(item, s_enabled) != NIL) ? MF_ENABLED : MF_GRAYED;
	ModifyMenu((HMENU) theMenu, i, flags, MAKEITEMINDEX(id, i), s);
      }
      break;
    case 'K': break;
    case 'M':
      flags = (slot_value(item, s_mark) != NIL) ? MF_CHECKED : MF_UNCHECKED;
      flags |= MF_BYPOSITION;
      CheckMenuItem((HMENU) theMenu, i, flags);
      break;
    case 'A': break;
    case 'E':
      flags = (slot_value(item, s_enabled) != NIL) ? MF_ENABLED : MF_GRAYED;
      flags |= MF_BYPOSITION;
      EnableMenuItem((HMENU) theMenu, i, flags);
      break;
    default:  xlfail("unknown item instance variable");
    }
  }
}
Esempio n. 8
0
void t_list_view::create_inline_edit(const pfc::list_base_const_t<t_size> & indices, unsigned column)
{
	t_size indices_count = indices.get_count();
	if (!indices_count) return;
	if (!(column < m_columns.get_count()) || m_selecting)
	{
		//console::print("internal error - edit column index out of range");
		return;
	}

	{
		t_size item_count = m_items.get_count();
		for (t_size j = 0; j < indices_count; j++)
		{
			if (indices[j] >= item_count) return;
		}
	}

	t_size indices_spread = indices[indices_count-1] - indices[0] +1;
	t_size indices_total_height = get_item_position_bottom(indices[indices_count-1]) - get_item_position(indices[0]);

	t_size active_count = m_items.get_count();

	if (m_timer_inline_edit)
	{
		KillTimer(get_wnd(), EDIT_TIMER_ID);
		m_timer_inline_edit = false;
	}

	t_size median = indices[0] + indices_spread/2;//indices[(indices_count/2)];

	bool start_visible = is_visible(indices[0]);
	bool end_visible = is_visible(indices[indices_count-1]);

	if (!start_visible || !end_visible)
	{
		SCROLLINFO si;
		memset(&si, 0, sizeof(SCROLLINFO));
		si.cbSize = sizeof(si);
		si.fMask = SIF_POS|SIF_TRACKPOS|SIF_PAGE|SIF_RANGE;
		GetScrollInfo(get_wnd(), SB_VERT, &si);
		t_size target;
		if (indices_count > si.nPage)
		{
			target = median;
			scroll(false, get_item_position(target) + m_item_height/2 - ((si.nPage>1?si.nPage-1:0)/2));
		}
		else
		{
			target = get_item_position(indices[0]) > (t_size)m_scroll_position ? indices[indices_count-1] : indices[0];
			scroll(false, get_item_position(target) -(get_item_position(target) > (t_size)m_scroll_position ? (si.nPage>1?si.nPage-1:0) - m_item_height : 0));
		}
	}

	int x = 0;
	{
		
		{
			x = get_total_indentation();
		}
		
		{
			unsigned n, count = m_columns.get_count();
			for (n=0; n<count && n<column; n++)
			{
				x += m_columns[n].m_display_size;
			}
		}
	}

	RECT rc_playlist, rc_items;
	GetClientRect(get_wnd(), &rc_playlist);
	get_items_rect(&rc_items);

	int font_height = uGetFontHeight(m_font);
	int header_height = rc_items.top;//get_header_height();

	int y = (get_item_position(indices[0])-m_scroll_position) + header_height;
	if (y < header_height) y= header_height;
	int cx = m_columns[column].m_display_size;
	//if (column == 0)
	//	cx -= min(x,cx);
	int cy = min (indices_total_height, t_size(rc_items.bottom-rc_items.top));

	if (!m_autosize && ( (x - m_horizontal_scroll_position < 0) || x + cx - m_horizontal_scroll_position > rc_items.right))
	{
		/*SCROLLINFO si;
		memset(&si, 0, sizeof(SCROLLINFO));
		si.cbSize = sizeof(si);
		si.fMask = SIF_POS|SIF_TRACKPOS|SIF_PAGE|SIF_RANGE;
		GetScrollInfo(get_wnd(), SB_HORZ, &si);*/
		if (x - m_horizontal_scroll_position < 0)
		{
			scroll(false, x, true);
		}
		else if (x + cx - m_horizontal_scroll_position > rc_items.right)
		{
			const int x_right = x + cx - rc_items.right;
			scroll(false, cx > rc_items.right ? x : x_right, true);
		}
	}

	x -= m_horizontal_scroll_position;

	/*int horizontal_offset = 0;
	if (x-horizontal_offset + cx > rc_playlist.right)
		scroll(scroll_horizontally, scroll_position_delta, x-horizontal_offset + (cx>rc_playlist.right?0:cx-rc_playlist.right));
	else if (x-horizontal_offset < 0)
		scroll(scroll_horizontally, scroll_position_delta, x-horizontal_offset);

	x-=horizontal_offset;*/

	if (m_wnd_inline_edit)
	{
		save_inline_edit();

		//NEW
		m_inline_edit_prevent_kill = true;
		DestroyWindow(m_wnd_inline_edit);
		m_wnd_inline_edit=0;
		m_inline_edit_autocomplete.release();
		m_inline_edit_prevent_kill = false;
		//END NEW
	}

	//m_inline_edit_field.set_string(pfc::empty_string_t<char>());
	//m_inline_edit_items.remove_all();
	//m_inline_edit_items.set_count(indices_count);
	//pfc::list_t<bool> mask;

	pfc::string8 text;
	t_size flags = 0;
	mmh::comptr_t<IUnknown> pAutoCompleteEntries;
	if (!notify_create_inline_edit(indices, column, text, flags, pAutoCompleteEntries))
	{
		m_inline_edit_save = false;
		exit_inline_edit();
		return;
	}

	if (!m_wnd_inline_edit)
	{
		m_inline_edit_save = true;
		m_wnd_inline_edit = CreateWindowEx(0, WC_EDIT, pfc::stringcvt::string_os_from_utf8(text).get_ptr(), WS_CHILD|WS_CLIPSIBLINGS|WS_VISIBLE|ES_LEFT|
			ES_AUTOHSCROLL|ES_MULTILINE|ES_AUTOVSCROLL|WS_BORDER|WS_CLIPCHILDREN|((flags & inline_edit_uppercase) ? ES_UPPERCASE : 0), x, 
			y,
			cx, cy, get_wnd(), HMENU(667),
			core_api::get_my_instance(), 0);

		m_proc_original_inline_edit = (WNDPROC)GetWindowLongPtr(m_wnd_inline_edit,GWLP_WNDPROC);

		if (/*flags & inline_edit_autocomplete && */pAutoCompleteEntries.is_valid())
		{
			if (SUCCEEDED(m_inline_edit_autocomplete.instantiate(CLSID_AutoComplete)))
			{
				if (pAutoCompleteEntries.is_valid())
					m_inline_edit_autocomplete->Init(m_wnd_inline_edit, pAutoCompleteEntries, NULL, NULL);

				mmh::comptr_t<IAutoComplete2> pA2 = m_inline_edit_autocomplete;
				mmh::comptr_t<IAutoCompleteDropDown> pAutoCompleteDropDown = m_inline_edit_autocomplete;
				if (pA2.is_valid())
				{
					pA2->SetOptions(ACO_AUTOSUGGEST|ACO_UPDOWNKEYDROPSLIST);
				}
			}
		}

		SetWindowLongPtr(m_wnd_inline_edit,GWL_USERDATA,(LPARAM)(this));
		m_proc_inline_edit = (WNDPROC)SetWindowLongPtr(m_wnd_inline_edit,GWL_WNDPROC,(LPARAM)(g_on_inline_edit_message));

		SetWindowPos(m_wnd_inline_edit,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

		SendMessage(m_wnd_inline_edit, WM_SETFONT, (WPARAM)m_font.get(), MAKELONG(TRUE,0));
	}
#if 0
	else
	{
		if (m_inline_edit_autocomplete.is_valid())
			m_inline_edit_autocomplete->Enable(FALSE);
		SetWindowLongPtr(m_wnd_inline_edit, GWL_STYLE, (GetWindowLongPtr (m_wnd_inline_edit, GWL_STYLE) & ~ES_UPPERCASE) | ((flags & inline_edit_uppercase)  ? ES_UPPERCASE  : 0));
		SendMessage(m_wnd_inline_edit, WM_SETTEXT, 0, (LPARAM)_T(""));
		SetWindowPos(m_wnd_inline_edit, NULL, x, y,	cx, cy, SWP_NOZORDER);
		uSendMessageText(m_wnd_inline_edit, WM_SETTEXT, 0, text);

		if (m_inline_edit_autocomplete.is_valid())
		{
			if (pAutoCompleteEntries.is_valid())
			{
				m_inline_edit_autocomplete->Init(m_wnd_inline_edit, pAutoCompleteEntries, NULL, NULL);
				m_inline_edit_autocomplete->Enable(TRUE);
			}
		}
	}
#endif


	RECT rc;
	rc.left = x+2;
	rc.top = y + (cy-font_height)/2;
	rc.right = x+(cx>0?cx-2:0);
	rc.bottom = rc.top + font_height;
	MapWindowPoints(get_wnd(), m_wnd_inline_edit, (LPPOINT)&rc, 2);

	SendMessage(m_wnd_inline_edit, EM_SETRECT, NULL, (LPARAM)&rc);

	SendMessage(m_wnd_inline_edit, EM_SETSEL, 0, -1);
	SetFocus(m_wnd_inline_edit);

	m_inline_edit_indices.remove_all();
	m_inline_edit_indices.add_items(indices);
	m_inline_edit_column = column;
}
Esempio n. 9
0
	/** Inherited from tinteger_selector_. */
	int get_value() const override
	{
		return minimum_value_ + get_item_position() * get_step_size();
	}