void fields_list_view_t::notify_on_create() { set_single_selection(true); pfc::list_t<t_column> columns; columns.set_count(2); columns[0].m_title = "Name"; columns[0].m_size = 150; columns[1].m_title = "Field"; columns[1].m_size = 150; t_list_view::set_columns(columns); t_size count = m_fields.get_count(); pfc::list_t<t_list_view::t_item_insert> items; get_insert_items(0, count, items); insert_items(0, count, items.get_ptr()); }
void refresh_me(HWND wnd) { initialising = true; #if 0 HWND wnd_edit = GetDlgItem(wnd, IDC_FRONT); uSetWindowText(wnd_edit, artwork_panel::cfg_front); wnd_edit = GetDlgItem(wnd, IDC_BACK); uSetWindowText(wnd_edit, artwork_panel::cfg_back); wnd_edit = GetDlgItem(wnd, IDC_DISC); uSetWindowText(wnd_edit, artwork_panel::cfg_disc); //wnd_edit = GetDlgItem(wnd, IDC_ICON); //uSetWindowText(wnd_edit, artwork_panel::cfg_icon); #endif m_source_list.remove_items(bit_array_true()); t_size index, indexcount = tabsize(g_artwork_sources); for (index = 0; index < indexcount; index++) { t_size subindex, subindexcount = g_artwork_sources[index].m_scripts->get_count(); pfc::array_t<t_list_view::t_item_insert> items; items.set_count(subindexcount); for (subindex=0; subindex<subindexcount; subindex++) { items[subindex].m_groups.add_item(g_artwork_sources[index].m_name); items[subindex].m_subitems.add_item((*g_artwork_sources[index].m_scripts)[subindex]); } m_source_list.insert_items(m_source_list.get_item_count(), items.get_count(), items.get_ptr()); } HWND wnd_combo = GetDlgItem(wnd, IDC_FB2KARTWORK); ComboBox_AddString(wnd_combo, L"Disabled"); ComboBox_AddString(wnd_combo, L"Embedded artwork"); ComboBox_AddString(wnd_combo, L"Embedded and external artwork"); ComboBox_SetCurSel(wnd_combo, artwork_panel::cfg_fb2k_artwork_mode); wnd_combo = GetDlgItem(wnd, IDC_EDGESTYLE); ComboBox_AddString(wnd_combo, L"None"); ComboBox_AddString(wnd_combo, L"Sunken"); ComboBox_AddString(wnd_combo, L"Grey"); ComboBox_SetCurSel(wnd_combo, artwork_panel::cfg_edge_style); initialising = false; }
void refresh_me(HWND wnd) { initialising = true; HWND wnd_sort = GetDlgItem(wnd, IDC_SORT); HWND wnd_sort_string = GetDlgItem(wnd, IDC_SORT_STRING); HWND wnd_autosend = GetDlgItem(wnd, IDC_AUTOSEND); HWND wnd_showempty = GetDlgItem(wnd, IDC_SHOWEMPTY); uSetWindowText(wnd_sort_string, filter_panel::cfg_sort_string); Button_SetCheck(wnd_sort, filter_panel::cfg_sort ? BST_CHECKED : BST_UNCHECKED); Button_SetCheck(wnd_showempty, filter_panel::cfg_showemptyitems ? BST_CHECKED : BST_UNCHECKED); Button_SetCheck(wnd_autosend, filter_panel::cfg_autosend ? BST_CHECKED : BST_UNCHECKED); m_field_list.remove_items(bit_array_true()); pfc::list_t<t_list_view::t_item_insert> items; t_size count = filter_panel::cfg_field_list.get_count(); get_insert_items(0, count, items); m_field_list.insert_items(0, items.get_count(), items.get_ptr()); SendDlgItemMessage(wnd,IDC_SPINPADDING,UDM_SETPOS32,0,filter_panel::cfg_vertical_item_padding); initialising = false; }
void test_no_purge_items() { int errcode, N; int redval; int ctx[2]; int purge_sum[2] = {0, 0}; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; couchfile_modify_request purge_rq; fprintf(stderr, "\nExecuting test_no_purge_items...\n"); N = 211341; ctx[0] = N; ctx[1] = 1; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, count_reduce, count_rereduce, N); assert(root != NULL); redval = red_intval(root, 0); assert(redval == N); fprintf(stderr, "Initial reduce value equals N\n"); purge_rq = purge_request(&db->file, count_reduce, count_rereduce, keepall_purge_kp, keepall_purge_kv, (void *) purge_sum); newroot = guided_purge_btree(&purge_rq, root, &errcode); assert(purge_sum[0] == 0 && purge_sum[1] == 0); fprintf(stderr, "guided_purge returned correct accumulator {0,0}\n"); redval = red_intval(newroot, 0); assert(redval == N); fprintf(stderr, "Reduce value after guided purge equals N\n"); try(iter_btree(&db->file, newroot, &ctx, check_vals_callback)); fprintf(stderr, "Btree has same values after guided purge\n"); cleanup: free(root); if (root != newroot) { free(newroot); } couchstore_close_db(db); assert(errcode == 0); } void test_all_purge_items() { int errcode, N; int redval; int purge_sum[2] = {0, 0}; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; couchfile_modify_request purge_rq; fprintf(stderr, "\nExecuting test_all_purge_items...\n"); N = 211341; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, count_reduce, count_rereduce, N); assert(root != NULL); redval = red_intval(root, 0); assert(redval == N); fprintf(stderr, "Initial reduce value equals N\n"); purge_rq = purge_request(&db->file, count_reduce, count_rereduce, all_purge_kp, all_purge_kv, (void *) &purge_sum); newroot = guided_purge_btree(&purge_rq, root, &errcode); assert(purge_sum[0] == 0 && purge_sum[1] == N); fprintf(stderr, "guided_purge returned correct accumulator {0,N}\n"); redval = red_intval(newroot, 0); assert(redval == 0); fprintf(stderr, "Reduce value after guided purge equals 0\n"); assert(newroot == NULL); fprintf(stderr, "Btree is empty after guided purge\n"); cleanup: free(root); free(newroot); couchstore_close_db(db); assert(errcode == 0); } void test_partial_purge_items() { int errcode, N; int exp_evenodd[2]; int purge_count = 0; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; couchfile_modify_request purge_rq; fprintf(stderr, "\nExecuting test_partial_purge_items...\n"); N = 211341; exp_evenodd[0] = N / 2; exp_evenodd[1] = N / 2 + N % 2; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, evenodd_reduce, evenodd_rereduce, N); assert(root != NULL); assert(exp_evenodd[0] == red_intval(root, 0) && exp_evenodd[1] == red_intval(root, 1)); fprintf(stderr, "Initial reduce value equals {NumEven, NumOdd}\n"); purge_rq = purge_request(&db->file, evenodd_reduce, evenodd_rereduce, evenodd_purge_kp, evenodd_purge_kv, (void *) &purge_count); newroot = guided_purge_btree(&purge_rq, root, &errcode); assert(purge_count == exp_evenodd[1]); fprintf(stderr, "guided_purge returned correct accumulator {0,NumOdd}\n"); assert(red_intval(newroot, 0) == exp_evenodd[0] && red_intval(newroot, 1) == 0); fprintf(stderr, "Reduce value after guided purge equals {NumEven, 0}\n"); try(iter_btree(&db->file, newroot, NULL, check_odd_callback)); fprintf(stderr, "Btree has no odd values after guided purge\n"); cleanup: free(root); free(newroot); couchstore_close_db(db); assert(errcode == 0); } void test_partial_purge_items2() { int errcode, N; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; int range_start, range_end; int count, purge_count = 0, iter_context = -1; couchfile_modify_request purge_rq; fprintf(stderr, "\nExecuting test_partial_purge_items2...\n"); N = 320000; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, uniq_reduce, uniq_rereduce, N); assert(root != NULL); count = red_intval(root, 1); range_start = red_intval(root, 2); range_end = red_intval(root, count + 1); assert(range_start == 0 && range_end == 63); fprintf(stderr, "Initial reduce value equals seq{0, 63}\n"); purge_rq = purge_request(&db->file, uniq_reduce, uniq_rereduce, skip_purge_kp, skip_purge_kv, (void *) &purge_count); newroot = guided_purge_btree(&purge_rq, root, &errcode); assert(purge_count == N / 2); fprintf(stderr, "guided_purge returned correct accumulator N/2\n"); count = red_intval(newroot, 1); range_start = red_intval(newroot, 2); range_end = red_intval(newroot, count + 1); assert(red_intval(newroot, 0) == N / 2 && range_start == 0 && range_end == 31); fprintf(stderr, "Reduce value after guided purge equals {0, 31}\n"); try(iter_btree(&db->file, newroot, &iter_context, check_skiprange_callback)); fprintf(stderr, "Btree has only values within the range {0, 31} and keys are sorted\n"); cleanup: free(root); free(newroot); couchstore_close_db(db); assert(errcode == 0); } void test_partial_purge_with_stop() { int errcode, N; int exp_evenodd[2]; int purge_count = 0; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; couchfile_modify_request purge_rq; fprintf(stderr, "\nExecuting test_partial_purge_items...\n"); N = 211341; exp_evenodd[0] = N / 2; exp_evenodd[1] = N / 2 + N % 2; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, evenodd_reduce, evenodd_rereduce, N); assert(root != NULL); assert(exp_evenodd[0] == red_intval(root, 0) && exp_evenodd[1] == red_intval(root, 1)); fprintf(stderr, "Initial reduce value equals {NumEven, NumOdd}\n"); purge_rq = purge_request(&db->file, evenodd_reduce, evenodd_rereduce, evenodd_purge_kp, evenodd_stop_purge_kv, (void *) &purge_count); newroot = guided_purge_btree(&purge_rq, root, &errcode); assert(purge_count == 4); fprintf(stderr, "guided_purge returned correct accumulator - 4\n"); assert(red_intval(newroot, 0) == exp_evenodd[0]); assert(red_intval(newroot, 1) == (exp_evenodd[1] - 4)); fprintf(stderr, "Reduce value after guided purge equals {NumEven, NumOdd-4}\n"); try(iter_btree(&db->file, newroot, NULL, check_odd_stop_callback)); fprintf(stderr, "Btree does not contain first 4 odd values after guided purge\n"); cleanup: free(root); free(newroot); couchstore_close_db(db); assert(errcode == 0); } void test_add_remove_purge() { int errcode, N, i; int exp_evenodd[2]; int purge_count = 0; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; couchfile_modify_request purge_rq; int *arr = NULL; couchfile_modify_action *acts = NULL; sized_buf *keys = NULL; fprintf(stderr, "\nExecuting test_add_remove_purge...\n"); N = 211341; exp_evenodd[0] = N / 2; exp_evenodd[1] = N / 2 + N % 2; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, evenodd_reduce, evenodd_rereduce, N); assert(root != NULL); assert(exp_evenodd[0] == red_intval(root, 0) && exp_evenodd[1] == red_intval(root, 1)); fprintf(stderr, "Initial reduce value equals {NumEven, NumOdd}\n"); purge_rq = purge_request(&db->file, evenodd_reduce, evenodd_rereduce, evenodd_purge_kp, evenodd_purge_kv, (void *) &purge_count); /* Add few add and remove actions in the modify request */ arr = (int *) calloc(6, sizeof(int)); keys = (sized_buf *) calloc(6, sizeof(sized_buf)); acts = (couchfile_modify_action *) calloc(6, sizeof(couchfile_modify_action)); arr[0] = 2; arr[1] = 4; arr[2] = 10; arr[3] = 14006; arr[4] = 200000; arr[5] = 500000; acts[0].type = ACTION_INSERT; acts[1].type = ACTION_REMOVE; acts[2].type = ACTION_REMOVE; acts[3].type = ACTION_INSERT; acts[4].type = ACTION_REMOVE; acts[5].type = ACTION_INSERT; for (i = 0; i < 6; i++) { keys[i].size = sizeof(int); keys[i].buf = (void *) &arr[i]; acts[i].key = &keys[i]; acts[i].value.data = &keys[i]; } purge_rq.actions = acts; purge_rq.num_actions = 6; purge_rq.enable_purging = 1; newroot = modify_btree(&purge_rq, root, &errcode); assert(purge_count == exp_evenodd[1]); fprintf(stderr, "Btree add_remove with purge returned correct purge_count - Numodds\n"); assert(red_intval(newroot, 0) == (exp_evenodd[0] - 2) && red_intval(newroot, 1) == 0); fprintf(stderr, "Btree reduce value equals - {NumEven-2, 0}\n"); try(iter_btree(&db->file, newroot, NULL, check_odd2_callback)); fprintf(stderr, "Btree has no odd values after guided purge\n"); fprintf(stderr, "Keys 4,10,200000 are not in tree after guided purge\n"); cleanup: free(root); free(newroot); free(keys); free(acts); free(arr); couchstore_close_db(db); assert(errcode == 0); } void test_only_single_leafnode() { int errcode, N; int redval; int purge_sum[2] = {0,0}; Db *db = NULL; node_pointer *root = NULL, *newroot = NULL; couchfile_modify_request purge_rq; fprintf(stderr, "\nExecuting test_only_single_leafnode...\n"); N = 2; remove(testpurgefile); try(couchstore_open_db(testpurgefile, COUCHSTORE_OPEN_FLAG_CREATE, &db)); root = insert_items(&db->file, NULL, count_reduce, count_rereduce, N); assert(root != NULL); redval = red_intval(root, 0); assert(redval == N); fprintf(stderr, "Initial reduce value equals N\n"); purge_rq = purge_request(&db->file, count_reduce, count_rereduce, keepall_purge_kp, all_purge_kv, (void *) &purge_sum); newroot = guided_purge_btree(&purge_rq, root, &errcode); assert(purge_sum[0] == N && purge_sum[1] == 0); fprintf(stderr, "guided_purge returned correct accumulator {N,0}\n"); redval = red_intval(newroot, 0); assert(redval == 0); fprintf(stderr, "Reduce value after guided purge equals 0\n"); assert(newroot == NULL); fprintf(stderr, "Btree is empty after guided purge\n"); cleanup: free(root); free(newroot); couchstore_close_db(db); assert(errcode == 0); }
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; }
void playlist_switcher_t::add_items (t_size base, t_size count) { pfc::list_t<t_list_view::t_item_insert> items_insert; get_insert_items(base, count, items_insert); insert_items(base, items_insert.get_count(), items_insert.get_ptr()); }
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; }