void t_list_view::activate_inline_editing(t_size column_start) { unsigned count = m_columns.get_count(); if (count) { t_size focus = get_focus_item(); if (focus != pfc_infinite) { t_size i, pcount = m_items.get_count(); bit_array_bittable sel(pcount); get_selection_state(sel); pfc::list_t<t_size> indices; indices.prealloc(32); for (i=0; i<pcount; i++) if (sel[i]) indices.add_item(i); if (column_start > count) column_start = 0; unsigned column; for (column=column_start; column<count; column++) { if (notify_before_create_inline_edit(indices, column, false)) { create_inline_edit(indices, column); break; } } } } }
BOOL CALLBACK on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) { switch(msg) { case WM_INITDIALOG: { { HWND list = uGetDlgItem(wnd,IDC_DBLCLK); uSendMessageText(list,CB_ADDSTRING,0,"Send to autosend playlist"); uSendMessageText(list,CB_ADDSTRING,0,"Send to autosend playlist and play"); uSendMessageText(list,CB_ADDSTRING,0,"Send to playlist"); uSendMessageText(list,CB_ADDSTRING,0,"Send to playlist and play"); uSendMessageText(list,CB_ADDSTRING,0,"Add to active playlist"); SendMessage(list,CB_SETCURSEL,filter_panel::cfg_doubleclickaction,0); list = uGetDlgItem(wnd,IDC_MIDDLE); uSendMessageText(list,CB_ADDSTRING,0,"None"); uSendMessageText(list,CB_ADDSTRING,0,"Send to autosend playlist"); uSendMessageText(list,CB_ADDSTRING,0,"Send to autosend playlist and play"); uSendMessageText(list,CB_ADDSTRING,0,"Send to playlist"); uSendMessageText(list,CB_ADDSTRING,0,"Send to playlist and play"); uSendMessageText(list,CB_ADDSTRING,0,"Add to active playlist"); SendMessage(list,CB_SETCURSEL,filter_panel::cfg_middleclickaction,0); uSendDlgItemMessageText(wnd,IDC_EDGESTYLE,CB_ADDSTRING,0,"None"); uSendDlgItemMessageText(wnd,IDC_EDGESTYLE,CB_ADDSTRING,0,"Sunken"); uSendDlgItemMessageText(wnd,IDC_EDGESTYLE,CB_ADDSTRING,0,"Grey"); uSendDlgItemMessageText(wnd,IDC_EDGESTYLE,CB_SETCURSEL,filter_panel::cfg_edgestyle,0); uSendDlgItemMessageText(wnd,IDC_PRECEDENCE,CB_ADDSTRING,0,"By position in splitter"); uSendDlgItemMessageText(wnd,IDC_PRECEDENCE,CB_ADDSTRING,0,"By field list above"); uSendDlgItemMessageText(wnd,IDC_PRECEDENCE,CB_SETCURSEL,filter_panel::cfg_orderedbysplitters ? 0 : 1,0); SendDlgItemMessage(wnd,IDC_SPINPADDING,UDM_SETRANGE32,-100,100); HWND wnd_fields = m_field_list.create_in_dialog_units(wnd, ui_helpers::window_position_t(20,17,278,79)); SetWindowPos(wnd_fields, HWND_TOP, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); ShowWindow(wnd_fields, SW_SHOWNORMAL); } refresh_me(wnd); } break; case WM_DESTROY: { //if (m_changed) // filter_panel::g_on_fields_change(); m_field_list.destroy(); } break; case WM_COMMAND: switch(wp) { case IDC_FILTER_HELP: { const char * text = "You can use either enter field names (for remappings, separate multiple field names by a semi-colon) or titleformatting scripts to specify fields. " "For example, \"Album Artist;Artist\" or \"%album artist%\".\r\n\r\n" "Only the former format supports multiple values per field and is compatible with inline metadata editing."; message_window_t::g_run(wnd, "Filter Field Help", text); } break; case IDC_UP: { if (m_field_list.get_selection_count(2) == 1) { t_size index = 0, count = m_field_list.get_item_count(); while (!m_field_list.get_item_selected(index) && index < count) index++; if (index && filter_panel::cfg_field_list.get_count()) { filter_panel::cfg_field_list.swap_items(index, index-1); filter_panel::filter_panel_t::g_on_fields_swapped(index, index - 1); pfc::list_t<t_list_view::t_item_insert> items; get_insert_items(index-1, 2, items); m_field_list.replace_items(index-1, items); m_field_list.set_item_selected_single(index-1); } } } break; case IDC_DOWN: { if (m_field_list.get_selection_count(2) == 1) { t_size index = 0, count = m_field_list.get_item_count(); while (!m_field_list.get_item_selected(index) && index < count) index++; if (index+1 < count && index + 1 < filter_panel::cfg_field_list.get_count()) { filter_panel::cfg_field_list.swap_items(index, index+1); filter_panel::filter_panel_t::g_on_fields_swapped(index, index + 1); pfc::list_t<t_list_view::t_item_insert> items; get_insert_items(index, 2, items); m_field_list.replace_items(index, items); m_field_list.set_item_selected_single(index+1); } } } break; case IDC_NEW: { filter_panel::field_t temp; temp.m_name = "<enter name here>"; temp.m_field = "<enter field here>"; t_size index = filter_panel::cfg_field_list.add_item(temp); filter_panel::filter_panel_t::g_on_new_field(temp); pfc::list_t<t_list_view::t_item_insert> items; get_insert_items(index, 1, items); m_field_list.insert_items(index, 1, items.get_ptr()); m_field_list.set_item_selected_single(index); SetFocus(m_field_list.get_wnd()); m_field_list.activate_inline_editing(); } break; case IDC_REMOVE: { if (m_field_list.get_selection_count(2) == 1) { bit_array_bittable mask(m_field_list.get_item_count()); m_field_list.get_selection_state(mask); //bool b_found = false; t_size index=0, count=m_field_list.get_item_count(); while (index < count) { if (mask[index]) break; index++; } if (index < count && index < filter_panel::cfg_field_list.get_count()) { filter_panel::cfg_field_list.remove_by_idx(index); m_field_list.remove_item(index); filter_panel::filter_panel_t::g_on_field_removed(index); t_size new_count = m_field_list.get_item_count(); if (new_count) { if (index < new_count) m_field_list.set_item_selected_single(index); else if (index) m_field_list.set_item_selected_single(index-1); } } } } break; case IDC_SORT: { filter_panel::cfg_sort = (Button_GetCheck((HWND)lp) != BST_UNCHECKED); } break; case IDC_AUTOSEND: filter_panel::cfg_autosend = (Button_GetCheck((HWND)lp) != BST_UNCHECKED); break; case IDC_SHOWEMPTY: filter_panel::cfg_showemptyitems = (Button_GetCheck((HWND)lp) != BST_UNCHECKED); filter_panel::filter_panel_t::g_on_showemptyitems_change(filter_panel::cfg_showemptyitems); break; case (EN_CHANGE<<16)|IDC_SORT_STRING: { filter_panel::cfg_sort_string = string_utf8_from_window((HWND)lp); } break; case (EN_CHANGE<<16)|IDC_PADDING: if (!initialising) { filter_panel::cfg_vertical_item_padding = strtol(string_utf8_from_window((HWND)lp).get_ptr(), NULL, 10); filter_panel::filter_panel_t::g_on_vertical_item_padding_change(); } break; case IDC_PRECEDENCE | (CBN_SELCHANGE<<16): filter_panel::cfg_orderedbysplitters = SendMessage((HWND)lp,CB_GETCURSEL,0,0) == 0; filter_panel::filter_panel_t::g_on_orderedbysplitters_change(); break; case IDC_MIDDLE | (CBN_SELCHANGE<<16): filter_panel::cfg_middleclickaction = SendMessage((HWND)lp,CB_GETCURSEL,0,0); break; case IDC_DBLCLK | (CBN_SELCHANGE<<16): filter_panel::cfg_doubleclickaction = SendMessage((HWND)lp,CB_GETCURSEL,0,0); break; case IDC_EDGESTYLE | (CBN_SELCHANGE<<16): filter_panel::cfg_edgestyle = SendMessage((HWND)lp,CB_GETCURSEL,0,0); filter_panel::filter_panel_t::g_on_edgestyle_change(); break; } } return 0; }
BOOL CALLBACK on_message(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) { switch(msg) { case WM_INITDIALOG: { HWND wnd_fields = m_source_list.create_in_dialog_units(wnd, ui_helpers::window_position_t(20,44,276,80)); SetWindowPos(wnd_fields, HWND_TOP, 0,0,0,0,SWP_NOSIZE|SWP_NOMOVE); refresh_me(wnd); ShowWindow(wnd_fields, SW_SHOWNORMAL); } break; case WM_DESTROY: { on_scripts_change(); } break; case WM_COMMAND: switch(wp) { #if 0 case (EN_CHANGE<<16)|IDC_FRONT: artwork_panel::cfg_front = string_utf8_from_window((HWND)lp); m_changed = true; break; case (EN_CHANGE<<16)|IDC_BACK: artwork_panel::cfg_back = string_utf8_from_window((HWND)lp); m_changed = true; break; case (EN_CHANGE<<16)|IDC_DISC: artwork_panel::cfg_disc = string_utf8_from_window((HWND)lp); m_changed = true; break; case (EN_KILLFOCUS<<16)|IDC_FRONT: case (EN_KILLFOCUS<<16)|IDC_BACK: case (EN_KILLFOCUS<<16)|IDC_DISC: on_scripts_change(); break; #endif /*case (EN_CHANGE<<16)|IDC_ICON: artwork_panel::cfg_icon = string_utf8_from_window((HWND)lp); m_changed = true; break;*/ case IDC_FB2KARTWORK|(CBN_SELCHANGE<<16): artwork_panel::cfg_fb2k_artwork_mode = ComboBox_GetCurSel((HWND)lp); break; case IDC_EDGESTYLE|(CBN_SELCHANGE<<16): artwork_panel::cfg_edge_style = ComboBox_GetCurSel((HWND)lp); artwork_panel::artwork_panel_t::g_on_edge_style_change(); break; case IDC_ADD: { RECT rc; GetWindowRect((HWND)lp, &rc); HMENU menu = CreatePopupMenu(); enum {IDM_FRONT = 1}; t_size index, indexcount = tabsize(g_artwork_sources); for (index = 0; index < indexcount; index++) { AppendMenuW(menu,(MF_STRING),index+1,pfc::stringcvt::string_wide_from_utf8(g_artwork_sources[index].m_name)); } int cmd = TrackPopupMenu(menu,TPM_LEFTBUTTON|TPM_NONOTIFY|TPM_RETURNCMD,rc.left,rc.bottom,0,wnd,0); DestroyMenu(menu); if (cmd>0 && (t_size)cmd <= indexcount) { index = cmd-1; t_size subindex = g_artwork_sources[index].m_scripts->add_item("<enter script>"); t_size combined_index = get_combined_index(index, subindex); t_list_view::t_item_insert item; item.m_groups.add_item(g_artwork_sources[index].m_name); item.m_subitems.add_item("<enter script>"); m_source_list.insert_items(combined_index, 1, &item); SetFocus(m_source_list.get_wnd()); m_source_list.set_item_selected_single(combined_index); m_source_list.activate_inline_editing(); m_source_list.m_changed = true; } } break; case IDC_REMOVE: { if (m_source_list.get_selection_count(2) == 1) { bit_array_bittable mask(m_source_list.get_item_count()); m_source_list.get_selection_state(mask); //bool b_found = false; t_size combined_index=0, count=m_source_list.get_item_count(); while (combined_index < count) { if (mask[combined_index]) break; combined_index++; } t_size index, subindex; if (combined_index < count && get_separated_index(combined_index, index, subindex)) { g_artwork_sources[index].m_scripts->remove_by_idx(subindex); m_source_list.remove_item(combined_index); m_source_list.m_changed = true; t_size new_count = m_source_list.get_item_count(); if (new_count) { if (combined_index < new_count) m_source_list.set_item_selected_single(combined_index); else if (combined_index) m_source_list.set_item_selected_single(combined_index-1); } } } } break; case IDC_UP: { if (m_source_list.get_selection_count(2) == 1) { t_size combined_index = 0; { t_size count = m_source_list.get_item_count(); while (!m_source_list.get_item_selected(combined_index) && combined_index < count) combined_index++; } t_size index, subindex, combined_index_start, count; get_group_from_combined_index(combined_index, index, subindex, combined_index_start, count); if (subindex && count) { g_artwork_sources[index].m_scripts->swap_items(subindex, subindex-1); pfc::list_t<t_list_view::t_item_insert> items; items.set_count(2); items[0].m_groups.add_item(g_artwork_sources[index].m_name); items[1].m_groups.add_item(g_artwork_sources[index].m_name); items[0].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex-1]); items[1].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex]); m_source_list.replace_items(combined_index-1, items); m_source_list.set_item_selected_single(combined_index-1); m_source_list.m_changed = true; } } } break; case IDC_DOWN: { if (m_source_list.get_selection_count(2) == 1) { t_size combined_index = 0; { t_size count = m_source_list.get_item_count(); while (!m_source_list.get_item_selected(combined_index) && combined_index < count) combined_index++; } t_size index, subindex, combined_index_start, count; get_group_from_combined_index(combined_index, index, subindex, combined_index_start, count); if (subindex + 1 < count) { g_artwork_sources[index].m_scripts->swap_items(subindex, subindex+1); pfc::list_t<t_list_view::t_item_insert> items; items.set_count(2); items[0].m_groups.add_item(g_artwork_sources[index].m_name); items[1].m_groups.add_item(g_artwork_sources[index].m_name); items[0].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex]); items[1].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex+1]); m_source_list.replace_items(combined_index, items); m_source_list.set_item_selected_single(combined_index+1); m_source_list.m_changed = true; } } } break; } } return 0; }