HWND uie::window::g_on_tab(HWND wnd_focus) { HWND rv = 0; HWND wnd_temp = GetAncestor(wnd_focus, GA_ROOT);/*_GetParent(wnd_focus); while (wnd_temp && GetWindowLong(wnd_temp, GWL_EXSTYLE) & WS_EX_CONTROLPARENT) { if (GetWindowLong(wnd_temp, GWL_STYLE) & WS_POPUP) break; else wnd_temp = _GetParent(wnd_temp); }*/ if (wnd_temp) { HWND wnd_next = GetNextDlgTabItem(wnd_temp, wnd_focus, (GetKeyState(VK_SHIFT) & KF_UP) ? TRUE : FALSE); if (wnd_next && wnd_next != wnd_focus) { unsigned flags = uSendMessage(wnd_next, WM_GETDLGCODE, 0, 0); if (flags & DLGC_HASSETSEL) uSendMessage(wnd_next, EM_SETSEL, 0, -1); SetFocus(wnd_next); rv = wnd_next; } } return rv; };
void Rebar_ShowAllBands(HWND wnd) { UINT count = uSendMessage(wnd, RB_GETBANDCOUNT, 0, 0); unsigned n; for (n = 0; n < count; n++) { uSendMessage(wnd, RB_SHOWBAND, n, TRUE); } }
int Rebar_FindItemById(HWND wnd, unsigned id) { /* Avoid RB_IDTOINDEX for backwards compatibility */ REBARBANDINFO rbbi; memset(&rbbi, 0, sizeof(rbbi)); rbbi.cbSize = sizeof(rbbi); rbbi.fMask = RBBIM_ID; UINT count = uSendMessage(wnd, RB_GETBANDCOUNT, 0, 0); unsigned n; for (n = 0; n < count; n++) { uSendMessage(wnd, RB_GETBANDINFO, n, (long)&rbbi); if (rbbi.wID == id) return n; } return -1; }
void size_windows() { if (!/*g_minimised*/IsIconic(g_main_window) && !ui_initialising) { RECT rc_main_client; GetClientRect(g_main_window, &rc_main_client); HDWP dwp = BeginDeferWindowPos(7); if (dwp) { int status_height = 0; if (g_status) { //uSendMessage(g_status, WM_SETREDRAW, FALSE, 0); uSendMessage(g_status,WM_SIZE,0,0); RECT rc_status; GetWindowRect(g_status, &rc_status); status_height += rc_status.bottom-rc_status.top; //dwp = DeferWindowPos(dwp, g_status, 0, 0, rc_main_client.bottom-status_height, rc_main_client.right-rc_main_client.left, status_height, SWP_NOZORDER|SWP_NOREDRAW); } if (g_status_pane.get_wnd()) { int cy = g_status_pane.get_ideal_height(); RedrawWindow(g_status_pane.get_wnd(), 0, 0, RDW_INVALIDATE); dwp = DeferWindowPos(dwp, g_status_pane.get_wnd(), 0, 0, rc_main_client.bottom-status_height-cy, rc_main_client.right-rc_main_client.left, cy, SWP_NOZORDER); status_height += cy; } int rebar_height=0; if (g_rebar) { RECT rc_rebar; GetWindowRect(g_rebar, &rc_rebar); rebar_height = rc_rebar.bottom-rc_rebar.top; } if (g_layout_window.get_wnd()) dwp = DeferWindowPos(dwp, g_layout_window.get_wnd(), 0, 0, rebar_height, rc_main_client.right-rc_main_client.left, rc_main_client.bottom-rc_main_client.top-rebar_height-status_height, SWP_NOZORDER); if (g_rebar) { dwp = DeferWindowPos(dwp, g_rebar, 0, 0, 0, rc_main_client.right-rc_main_client.left, rebar_height, SWP_NOZORDER); } EndDeferWindowPos(dwp); if (g_status) { status_bar::set_part_sizes(status_bar::t_parts_none); } } } }
bool is_item_selected(HWND p_listview,unsigned p_index) { LVITEM item = {}; item.mask = LVIF_STATE; item.iItem = p_index; item.stateMask = LVIS_SELECTED; if (!uSendMessage(p_listview,LVM_GETITEM,0,(LPARAM)&item)) return false; return (item.state & LVIS_SELECTED) ? true : false; }
void dsp_preset_switcher::clearEntires() const { CONST LRESULT ret = uSendMessage( wnd_my_combo_box , CB_RESETCONTENT , 0 , 0 ); if( ret < 0 ) { console::printf( CONSOLE_HEADER "%s() failed" , __FUNCTION__ ); } return; }
unsigned int playlist_view::calculate_header_height() { unsigned rv = 0; if (wnd_header) { HFONT font = (HFONT)uSendMessage(wnd_header, WM_GETFONT, 0, 0); rv = uGetFontHeight(font) + 5; } return rv; }
/* no range checks here !*/ void playlist_view::process_keydown(int offset, bool alt_down, bool prevent_redrawing, bool repeat) { static_api_ptr_t<playlist_manager> playlist_api; int focus = playlist_api->activeplaylist_get_focus_item(); int count = playlist_api->activeplaylist_get_item_count(); // if (focus < 0) focus =0; // if (focus >= count) focus = count-1; // int alt_offset = offset; if ((focus + offset) < 0) offset -= (focus + offset); if ((focus + offset) >= count) offset = (count - 1 - focus); bool focus_sel = playlist_api->activeplaylist_is_item_selected(focus); if (prevent_redrawing) uSendMessage(wnd_playlist, WM_SETREDRAW, FALSE, 0); if ((GetKeyState(VK_SHIFT) & KF_UP) && (GetKeyState(VK_CONTROL) & KF_UP)) { if (!repeat) playlist_api->activeplaylist_undo_backup(); playlist_api->activeplaylist_move_selection(offset); } else if ((GetKeyState(VK_CONTROL) & KF_UP)) playlist_api->activeplaylist_set_focus_item(focus + offset); else if (GetKeyState(VK_SHIFT) & KF_UP) { set_sel_range(cfg_alternative_sel ? focus : g_shift_item_start, focus + offset, (cfg_alternative_sel != 0), (cfg_alternative_sel ? !focus_sel : false)); playlist_api->activeplaylist_set_focus_item(focus + offset); } else { // console::info(pfc::string_printf("%i",focus+offset)); set_sel_single(focus + offset, false, true, (GetKeyState(VK_SHIFT) & KF_UP) ? false : true); } if (prevent_redrawing) { uSendMessage(wnd_playlist, WM_SETREDRAW, TRUE, 0); RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } }
bool set_item_selection(HWND p_listview,unsigned p_index,bool p_state) { LVITEM item; memset(&item,0,sizeof(item)); item.mask = LVIF_STATE; item.iItem = p_index; item.stateMask = LVIS_SELECTED; item.state = p_state ? LVIS_SELECTED : 0; return uSendMessage(p_listview,uLVM_SETITEM,0,(LPARAM)&item) ? true : false; }
bool dsp_preset_switcher::setEntry( const int idx ) const { CONST LRESULT ret = uSendMessage( wnd_my_combo_box , CB_SETCURSEL , idx , NULL ); if( ret < 0 ) { console::printf( CONSOLE_HEADER "%s() failed" , __FUNCTION__ ); return false; } return true; }
void album_list_dlg::completion_notify_new_album::on_completion (unsigned p_code) { pfc::string8 album_title = trim (*m_str); if ((p_code & InPlaceEdit::KEditMaskReason) == InPlaceEdit::KEditEnter && !album_title.is_empty ()) { auto p_listview = m_listview; // Need to declare a copy of m_listview to work correctly run_in_separate_thread ([=] () // Need to use separate thread because of UI freezes during http-requests { listview_helper::set_item_text (p_listview, 0, 0, album_title.get_ptr ()); user_album_list user_albums; if (!user_albums.add_item (album_title)) { uSendMessage (p_listview, LVM_DELETEITEM, 0, 0); if (!user_albums.aborted ()) uErrorBox ("Error while creating new album", user_albums.get_error ()); } }); } else uSendMessage (m_listview, LVM_DELETEITEM, 0, 0); }
bool set_item_text(HWND p_listview,unsigned p_index,unsigned p_column,const char * p_name) { LVITEM item = {}; pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); item.mask = LVIF_TEXT; item.iItem = p_index; item.iSubItem = p_column; item.pszText = const_cast<TCHAR*>(os_string_temp.get_ptr()); return uSendMessage(p_listview,LVM_SETITEM,0,(LPARAM)&item) ? true : false; }
unsigned insert_item(HWND p_listview,unsigned p_index,const char * p_name,LPARAM p_param) { if (p_index == ~0) p_index = ListView_GetItemCount(p_listview); LVITEM item = {}; pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); item.mask = LVIF_TEXT | LVIF_PARAM; item.iItem = p_index; item.lParam = p_param; item.pszText = const_cast<TCHAR*>(os_string_temp.get_ptr()); LRESULT ret = uSendMessage(p_listview,LVM_INSERTITEM,0,(LPARAM)&item); if (ret < 0) return ~0; else return (unsigned) ret; }
unsigned insert_column(HWND p_listview,unsigned p_index,const char * p_name,unsigned p_width_dlu) { pfc::stringcvt::string_os_from_utf8 os_string_temp(p_name); RECT rect = {0,0,p_width_dlu,0}; MapDialogRect(GetParent(p_listview),&rect); LVCOLUMN data = {}; data.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT; data.fmt = LVCFMT_LEFT; data.cx = rect.right; data.pszText = const_cast<TCHAR*>(os_string_temp.get_ptr()); LRESULT ret = uSendMessage(p_listview,LVM_INSERTCOLUMN,p_index,(LPARAM)&data); if (ret < 0) return ~0; else return (unsigned) ret; }
bool dsp_preset_switcher::getSelection( int &idx_out , pfc::string8 &str_out ) const { idx_out = uSendMessage( wnd_my_combo_box , CB_GETCURSEL , 0 , 0 ); if( idx_out == CB_ERR ) { console::printf( CONSOLE_HEADER "CB_GETCURSEL get CB_ERR" ); return false; } CONST BOOL ret = uComboBox_GetText( wnd_my_combo_box , idx_out , str_out ); if( !ret ) { console::printf( CONSOLE_HEADER "uComboBox_GetText() failed" ); return false; } return true; }
void playlist_view::on_playlist_activate(unsigned p_old,unsigned p_new) { //if (!cfg_nohscroll) g_save_columns(); // g_reset_columns(); unsigned n, count = playlist_view::list_playlist.get_count(); for (n=0; n<count; n++) { playlist_view * p_playlist = playlist_view::list_playlist.get_item(n); t_local_cache::t_local_cache_entry * p_cache = NULL; if (p_playlist->m_cache.get_entry(p_old, p_cache)) { p_cache->set_last_position(p_playlist->scroll_item_offset); } p_playlist->update_scrollbar(true); if (p_playlist->wnd_header) { p_playlist->rebuild_header(); p_playlist->move_header(true, false); } if (p_playlist->m_cache.get_entry(p_new, p_cache)) { unsigned temp; if (p_cache->get_last_position(temp)) { SCROLLINFO scroll; memset(&scroll, 0, sizeof(SCROLLINFO)); scroll.fMask = SIF_POS; scroll.nPos = temp; scroll.cbSize = sizeof(SCROLLINFO); p_playlist->scroll_item_offset = SetScrollInfo(p_playlist->wnd_playlist, SB_VERT, &scroll, true); } else p_playlist->ensure_visible(static_api_ptr_t<playlist_manager>()->playlist_get_focus_item(p_new)); } uSendMessage(p_playlist->wnd_playlist, WM_SETREDRAW, TRUE, 0); RedrawWindow(p_playlist->wnd_playlist,0,0,RDW_INVALIDATE|RDW_UPDATENOW); } }
static LRESULT WINAPI EditHook(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { /* case WM_KEYDOWN: if (!(HIWORD(lp) & KF_REPEAT) && (wp == 'a' || wp =='A') && (GetKeyState(VK_CONTROL) & KF_UP)) { uSendMessage(wnd, EM_SETSEL, 0, -1); return 0; } break;*/ case WM_CHAR: if (!(HIWORD(lp) & KF_REPEAT) && (wp == 1) && (GetKeyState(VK_CONTROL) & KF_UP)) { uSendMessage(wnd, EM_SETSEL, 0, -1); return 0; } break; } return uCallWindowProc(editproc, wnd, msg, wp, lp); }
void album_list_dlg::on_init_dialog () { g_dlg_pos.AddWindow (*this); HWND p_listview = GetDlgItem (IDC_LISTVIEW_ALBUMS); // Add one column LVCOLUMN data = {}; data.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; data.fmt = LVCFMT_LEFT; data.cx = 160; data.pszText = L"Album title"; uSendMessage (p_listview, LVM_INSERTCOLUMN, 0, (LPARAM)&data); // Window must have WS_CLIPCHILDREN for inline editing ::SetWindowLong (p_listview, GWL_STYLE, ::GetWindowLong (p_listview, GWL_STYLE) | WS_CLIPCHILDREN); const auto & p_albums = user_album_list ().get_albums (); if (p_albums.get_count ()) listview_fill (p_listview, p_albums); else on_refresh_albums (); }
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { uTCITEM tabs; memset(&tabs, 0, sizeof(tabs)); HWND wnd_tab = GetDlgItem(wnd, IDC_TAB1); tabs.mask = TCIF_TEXT; tabs.pszText = "Variables"; uTabCtrl_InsertItem(wnd_tab, 0, &tabs); tabs.pszText = "Style"; uTabCtrl_InsertItem(wnd_tab, 1, &tabs); TabCtrl_SetCurSel(wnd_tab, g_cur_tab2); uSendDlgItemMessageText(wnd, IDC_CHAR7, WM_SETTEXT, 0, "\x07"); colour_code_gen(wnd, IDC_COLOUR, false, true); uSendDlgItemMessage(wnd, IDC_STRING, EM_LIMITTEXT, 0, 0); refresh_me(wnd); editproc = (WNDPROC)SetWindowLongPtr(GetDlgItem(wnd, IDC_STRING), GWLP_WNDPROC, (LPARAM)EditHook); g_editor_font_notify.set(GetDlgItem(wnd, IDC_STRING)); } break; case WM_NOTIFY: switch (((LPNMHDR)lp)->idFrom) { case IDC_TAB1: switch (((LPNMHDR)lp)->code) { case TCN_SELCHANGE: { save_string(wnd); int id = TabCtrl_GetCurSel(GetDlgItem(wnd, IDC_TAB1)); g_cur_tab2 = id; uSendDlgItemMessageText(wnd, IDC_STRING, WM_SETTEXT, 0, (g_cur_tab2 == 0 ? cfg_globalstring : cfg_colour)); } break; } break; } break; case WM_DESTROY: { g_editor_font_notify.release(); save_string(wnd); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); } break; case WM_COMMAND: switch (wp) { case IDC_GLOBAL: cfg_global = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_DATE: cfg_playlist_date = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); set_day_timer(); pvt::ng_playlist_view_t::g_on_use_date_info_change(); break; case IDC_TFHELP: { RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_TFHELP), &rc); // MapWindowPoints(HWND_DESKTOP, wnd, (LPPOINT)(&rc), 2); HMENU menu = CreatePopupMenu(); enum { IDM_TFHELP = 1, IDM_GHELP = 2, IDM_SPEEDTEST, IDM_PREVIEW, IDM_EDITORFONT, IDM_RESETSTYLE }; uAppendMenu(menu, (MF_STRING), IDM_TFHELP, "Titleformatting &help"); uAppendMenu(menu, (MF_STRING), IDM_GHELP, "&Global help"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_SPEEDTEST, "&Speed test"); uAppendMenu(menu, (MF_STRING), IDM_PREVIEW, "&Preview to console"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_EDITORFONT, "Change editor &font"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_RESETSTYLE, "&Reset style string"); int cmd = TrackPopupMenu(menu, TPM_LEFTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, wnd, 0); DestroyMenu(menu); if (cmd == IDM_TFHELP) { standard_commands::main_titleformat_help(); } else if (cmd == IDM_GHELP) { uMessageBox(wnd, COLOUR_HELP "\n\nNew global format: $set_global(var, val), retreive values using $get_global(var)", "Global help", 0); } else if (cmd == IDM_SPEEDTEST) { speedtest(g_columns, cfg_global != 0, cfg_oldglobal != 0, cfg_playlist_date != 0); } else if (cmd == IDM_PREVIEW) { preview_to_console(string_utf8_from_window(wnd, IDC_STRING), g_cur_tab2 != 0 && cfg_global); } else if (cmd == IDM_EDITORFONT) { if (font_picker(wnd, cfg_editor_font)) g_editor_font_notify.on_change(); } else if (cmd == IDM_RESETSTYLE) { extern const char * g_default_colour; cfg_colour = g_default_colour; if (g_cur_tab2 == 1) uSendDlgItemMessageText(wnd, IDC_STRING, WM_SETTEXT, 0, cfg_colour); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); } } break; case IDC_OLDGLOBAL: cfg_oldglobal = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_GLOBALSORT: cfg_global_sort = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_APPLY: save_string(wnd); refresh_all_playlist_views(); pvt::ng_playlist_view_t::g_update_all_items(); break; case IDC_PICK_COLOUR: colour_code_gen(wnd, IDC_COLOUR, false, false); break; } } return 0; }
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { refresh_me(wnd); initialised = true; } break; case WM_DESTROY: { initialised = false; } break; case WM_COMMAND: switch (wp) { case (EN_CHANGE << 16) | IDC_STRING: main_window::config_notification_icon_script.set(string_utf8_from_window((HWND)lp)); break; case IDC_NOWPL: { cfg_np = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; case IDC_USE_CUSTOM_ICON: { cfg_custom_icon = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); create_icon_handle(); create_systray_icon(); } break; case IDC_BROWSE_ICON: { pfc::string8 path = cfg_tray_icon_path; if (uGetOpenFileName(wnd, "Icon Files (*.ico)|*.ico|All Files (*.*)|*.*", 0, "ico", "Choose Icon", NULL, path, FALSE)) { cfg_tray_icon_path = path; if (cfg_custom_icon) { create_icon_handle(); create_systray_icon(); } } } break; case IDC_MINIMISE_TO_SYSTRAY: { cfg_minimise_to_tray = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; case IDC_SHOW_SYSTRAY: { cfg_show_systray = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); // EnableWindow(GetDlgItem(wnd, IDC_MINIMISE_TO_SYSTRAY), cfg_show_systray); if (g_main_window) { auto is_iconic = IsIconic(g_main_window) != 0; if (cfg_show_systray && !g_icon_created) { create_systray_icon(); } else if (!cfg_show_systray && g_icon_created && (!is_iconic || !cfg_minimise_to_tray)) { destroy_systray_icon(); if (is_iconic) standard_commands::main_activate(); } if (g_status) update_systray(); } } break; case IDC_BALLOON: { cfg_balloon = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; } } return 0; }
BOOL dialog_proc( HWND wnd, UINT msg, WPARAM wp, LPARAM lp ) { switch ( msg ) { case WM_INITDIALOG: { this->wnd = wnd; uSendDlgItemMessage( wnd, IDC_OVERRIDE, BM_SETCHECK, cfg_control_override, 0 ); { insync( lock ); changed_info = false; changed_controls = false; update(); } SetTimer( wnd, 0, 100, 0 ); cfg_placement.on_window_creation(wnd); } return 1; case WM_TIMER: { insync( lock ); if ( changed_info ) { changed_info = false; update(); } } break; case WM_DESTROY: { cfg_placement.on_window_destruction( wnd ); KillTimer( wnd, 0 ); uSetWindowLong( wnd, DWL_USER, 0 ); delete this; dialog = 0; } break; case WM_COMMAND: if ( wp == IDCANCEL ) { DestroyWindow( wnd ); } else if ( wp == IDC_OVERRIDE ) { insync( lock ); cfg_control_override = uSendMessage((HWND)lp,BM_GETCHECK,0,0); BOOL enable = song_renderer != 0 && cfg_control_override; for ( unsigned i = 0, j = DUMB_IT_N_CHANNELS; i < j; ++i ) { EnableWindow( GetDlgItem( wnd, IDC_VOICE1 + i ), enable ); } changed_controls = true; } else if ( wp == IDC_RESET ) { insync( lock ); changed_controls = mute_mask != 0; mute_mask = 0; if ( changed_controls ) { update(); } } else if ( wp - IDC_VOICE1 < DUMB_IT_N_CHANNELS ) { unsigned voice = wp - IDC_VOICE1; t_uint64 mask = ~(1 << voice); t_uint64 bit = uSendMessage((HWND)lp,BM_GETCHECK,0,0) ? 0 : ( 1 << voice ); insync( lock ); changed_controls = true; mute_mask = ( mute_mask & mask ) | bit; } break; } return 0; }
static BOOL CALLBACK SpectrumPopupProc(HWND wnd,UINT msg,WPARAM wp,LPARAM lp) { switch(msg) { case WM_INITDIALOG: SetWindowLongPtr(wnd,DWLP_USER,lp); { spec_param * ptr = reinterpret_cast<spec_param*>(lp); ptr->m_scope.initialize(FindOwningPopup(wnd)); uSendDlgItemMessage(wnd, IDC_BARS, BM_SETCHECK, ptr->ptr->mode == MODE_BARS, 0); HWND wnd_combo = GetDlgItem(wnd, IDC_FRAME_COMBO); EnableWindow(wnd_combo, ptr->b_show_frame); if (ptr->b_show_frame) { ComboBox_AddString(wnd_combo, _T("None")); ComboBox_AddString(wnd_combo, _T("Sunken")); ComboBox_AddString(wnd_combo, _T("Grey")); ComboBox_SetCurSel(wnd_combo, ptr->frame); } wnd_combo = GetDlgItem(wnd, IDC_SCALE); ComboBox_AddString(wnd_combo, _T("Linear")); ComboBox_AddString(wnd_combo, _T("Logarithmic")); ComboBox_SetCurSel(wnd_combo, ptr->m_scale); wnd_combo = GetDlgItem(wnd, IDC_VERTICAL_SCALE); ComboBox_AddString(wnd_combo, _T("Linear")); ComboBox_AddString(wnd_combo, _T("Logarithmic")); ComboBox_SetCurSel(wnd_combo, ptr->m_vertical_scale); } return TRUE; case WM_ERASEBKGND: SetWindowLongPtr(wnd, DWLP_MSGRESULT, TRUE); return TRUE; case WM_PAINT: uih::HandleModernBackgroundPaint(wnd, GetDlgItem(wnd, IDOK)); return TRUE; case WM_CTLCOLORSTATIC: { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); if (GetDlgItem(wnd, IDC_PATCH_FORE) == (HWND)lp) { HDC dc =(HDC)wp; if (!ptr->br_fore) { ptr->br_fore = CreateSolidBrush(ptr->cr_fore); } return (BOOL)ptr->br_fore; } else if (GetDlgItem(wnd, IDC_PATCH_BACK) == (HWND)lp) { HDC dc =(HDC)wp; if (!ptr->br_back) { ptr->br_back = CreateSolidBrush(ptr->cr_back); } return (BOOL)ptr->br_back; } else return (BOOL)GetSysColorBrush(COLOR_3DHIGHLIGHT); } break; case WM_COMMAND: switch(wp) { case IDCANCEL: EndDialog(wnd,0); return TRUE; case IDC_CHANGE_BACK: { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); COLORREF COLOR = ptr->cr_back; COLORREF COLORS[16] = {get_default_colour(colours::COLOUR_BACK),GetSysColor(COLOR_3DFACE),0,0,0,0,0,0,0,0,0,0,0,0,0,0}; if (uChooseColor(&COLOR, wnd, &COLORS[0])) { ptr->cr_back = COLOR; ptr->flush_back(); RedrawWindow(GetDlgItem(wnd, IDC_PATCH_BACK), 0, 0, RDW_INVALIDATE|RDW_UPDATENOW); } } break; case IDC_CHANGE_FORE: { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); COLORREF COLOR = ptr->cr_fore; COLORREF COLORS[16] = {get_default_colour(colours::COLOUR_TEXT),GetSysColor(COLOR_3DSHADOW),0,0,0,0,0,0,0,0,0,0,0,0,0,0}; if (uChooseColor(&COLOR, wnd, &COLORS[0])) { ptr->cr_fore = COLOR; ptr->flush_fore(); RedrawWindow(GetDlgItem(wnd, IDC_PATCH_FORE), 0, 0, RDW_INVALIDATE|RDW_UPDATENOW); } } break; case IDC_BARS: { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); ptr->mode = (uSendMessage((HWND)lp, BM_GETCHECK, 0, 0) != TRUE ? MODE_STANDARD : MODE_BARS); } break; case IDC_FRAME_COMBO|(CBN_SELCHANGE<<16): { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); ptr->frame = ComboBox_GetCurSel(HWND(lp)); } break; case IDC_SCALE|(CBN_SELCHANGE<<16): { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); ptr->m_scale = ComboBox_GetCurSel(HWND(lp)); } break; case IDC_VERTICAL_SCALE|(CBN_SELCHANGE<<16): { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); ptr->m_vertical_scale = ComboBox_GetCurSel(HWND(lp)); } break; case IDOK: { spec_param * ptr = reinterpret_cast<spec_param*>(GetWindowLongPtr(wnd,DWLP_USER)); EndDialog(wnd,1); } return TRUE; default: return FALSE; } default: return FALSE; } }
void playlist_view::g_set_sort( unsigned column, bool descending, bool selection_only) { static_api_ptr_t<playlist_manager> playlist_api; unsigned active_playlist = playlist_api->get_active_playlist(); if (active_playlist != -1 && (!playlist_api->playlist_lock_is_present(active_playlist) || !(playlist_api->playlist_lock_get_filter_mask(active_playlist) & playlist_lock::filter_reorder))) { unsigned act_column = g_cache.active_column_active_to_actual(column); // const columns_class & columns = playlist_view::g_get_columns(); unsigned n,count = playlist_api->activeplaylist_get_item_count(); pfc::array_t<unsigned> order; order.set_size(count); pfc::ptr_list_t<sort_info> data; pfc::string8_fast_aggressive temp; pfc::string8_fast_aggressive temp2; temp.prealloc(512); pfc::string8 spec; bool custom_sort = columns[act_column]->use_custom_sort; /*if (custom_sort) */spec = custom_sort ? columns[act_column]->sort_spec : columns[act_column]->spec; //columns.get_string(act_column, spec, custom_sort ? STRING_SORT : STRING_DISPLAY); global_variable_list extra_items; bool extra = (cfg_global_sort != 0); bool b_legacy = cfg_oldglobal != 0; bit_array_bittable mask(count); if (selection_only) playlist_api->activeplaylist_get_selection_mask(mask); service_ptr_t<titleformat_object> to_sort; static_api_ptr_t<titleformat_compiler> titleformat_api; titleformat_api->compile_safe(to_sort, spec); bool date = cfg_playlist_date != 0; SYSTEMTIME st; if (date) GetLocalTime(&st); for(n=0;n<count;n++) { if (!selection_only || mask[n] == true) { // if (custom_sort) { if (extra) { extra_items.delete_all(); g_cache.active_make_extra(n, extra_items, date ? &st : 0, b_legacy); } // g_oper->format_title(n, temp,spec,(extra ? extra_items.get_ptr() : 0)); playlist_api->activeplaylist_item_format_title(n, &titleformat_hook_splitter_pt3(extra ? &titleformat_hook_set_global<false,true>(extra_items, b_legacy) : 0 , date ? &titleformat_hook_date(&st) : 0, &titleformat_hook_playlist_name()), temp, to_sort, 0, play_control::display_level_none); } /* else { g_playlist_entries.get_display_name(n, column, temp); }*/ const char * ptr = temp.get_ptr(); if (strchr(ptr,3)) { titleformat_compiler::remove_color_marks(ptr,temp2); ptr = temp2; } data.add_item(new(std::nothrow) sort_info(ptr,n)); } } if (descending) { data.sort(sort_info_callback_base<sort_info*>::desc_sort_callback()); } else { sort_info_callback_base<sort_info*>::asc_sort_callback cc; data.sort(cc); } unsigned new_count = data.get_count(), i=0; for(n=0;n<count;n++) { if (!selection_only || mask[n] == true) { order[n]=data[/*descending ? new_count - 1 - i :*/i]->index; //or we could use diff sortproc i++; } else { order[n] = n; } } data.delete_all(); unsigned window_count = playlist_view::list_playlist.get_count(); for (n=0; n<window_count; n++) { playlist_view * p_playlist = playlist_view::list_playlist.get_item(n); uSendMessage(p_playlist->wnd_playlist, WM_SETREDRAW, FALSE, 0); } playlist_api->activeplaylist_undo_backup(); playlist_api->activeplaylist_reorder_items(order.get_ptr(), count); for (n=0; n<window_count; n++) { playlist_view * p_playlist = playlist_view::list_playlist.get_item(n); uSendMessage(p_playlist->wnd_playlist, WM_SETREDRAW, TRUE, 0); RedrawWindow(p_playlist->wnd_playlist, 0, 0, RDW_INVALIDATE|RDW_UPDATENOW); } if (!selection_only) { g_remove_sort();//change so only if diff idx g_cache.active_set_playlist_sort(column, descending); g_update_sort(); } } }
LRESULT album_list_window::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_CREATE: { list_wnd.add_item(this); initialised = true; modeless_dialog_manager::g_add(wnd); create_tree(); create_filter(); if (cfg_populate) refresh_tree(); static_api_ptr_t<library_manager_v3>()->register_callback(this); } break; /*case WM_GETMINMAXINFO: { LPMINMAXINFO mmi = LPMINMAXINFO(lp); mmi->ptMinTrackSize.y = cfg_height; return 0; }*/ case WM_SIZE: on_size(LOWORD(lp), HIWORD(lp)); break; /* case DM_GETDEFID: return (DC_HASDEFID<<16|IDOK); case WM_GETDLGCODE: return DLGC_DEFPUSHBUTTON;*/ // break; case WM_TIMER: if (wp == EDIT_TIMER_ID) { refresh_tree(); KillTimer(wnd, wp); m_timer = false; } break; case WM_COMMAND: switch (wp) { case IDC_FILTER | (EN_CHANGE << 16) : if (m_timer) KillTimer(wnd_edit, 500); m_timer = SetTimer(wnd, EDIT_TIMER_ID, 500, NULL) != 0; return TRUE; case IDOK: if (GetKeyState(VK_SHIFT) & KF_UP) do_playlist(p_selection, false); else if (GetKeyState(VK_CONTROL) & KF_UP) do_playlist(p_selection, true, true); else do_playlist(p_selection, true); return 0; } break; case WM_CONTEXTMENU: { enum { ID_SEND = 1, ID_ADD, ID_NEW, ID_AUTOSEND, ID_REMOVE, ID_REMOVEDEAD, ID_REFRESH, ID_FILT, ID_CONF, ID_VIEW_BASE }; HMENU menu = CreatePopupMenu(); POINT pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; service_ptr_t<contextmenu_manager> p_menu_manager; unsigned IDM_MANAGER_BASE = 0; HWND list = wnd_tv; HTREEITEM treeitem = NULL; TVHITTESTINFO ti; memset(&ti, 0, sizeof(ti)); if (pt.x != -1 && pt.y != -1) { ti.pt = pt; ScreenToClient(list, &ti.pt); uSendMessage(list, TVM_HITTEST, 0, (long)&ti); if (ti.hItem && (ti.flags & TVHT_ONITEM)) { //FIX THIS AND AUTOSEND //TreeView_Select(list, ti.hItem, TVGN_DROPHILITE); //uSendMessage(list,TVM_SELECTITEM,TVGN_DROPHILITE,(long)ti.hItem); treeitem = ti.hItem; } } else { treeitem = TreeView_GetSelection(list); RECT rc; if (treeitem && TreeView_GetItemRect(wnd_tv, treeitem, &rc, TRUE)) { MapWindowPoints(wnd_tv, HWND_DESKTOP, (LPPOINT)&rc, 2); pt.x = rc.left; pt.y = rc.top + (rc.bottom - rc.top) / 2; } else { GetMessagePos(&pt); } } TreeView_Select(list, treeitem, TVGN_DROPHILITE); HMENU menu_view = CreatePopupMenu(); unsigned n, m = cfg_view_list.get_count(); string8_fastalloc temp; temp.prealloc(32); uAppendMenu(menu_view, MF_STRING | (!stricmp_utf8(directory_structure_view_name, view) ? MF_CHECKED : 0), ID_VIEW_BASE + 0, directory_structure_view_name); list_t<string_simple, pfc::alloc_fast> views; views.add_item(string_simple(directory_structure_view_name)); for (n = 0; n<m; n++) { temp = cfg_view_list.get_name(n); string_simple item(temp.get_ptr()); if (item) { uAppendMenu(menu_view, MF_STRING | (!stricmp_utf8(temp, view) ? MF_CHECKED : 0), ID_VIEW_BASE + views.add_item(item), temp); } } IDM_MANAGER_BASE = ID_VIEW_BASE + views.get_count(); uAppendMenu(menu, MF_STRING | MF_POPUP, (UINT)menu_view, "View"); if (!m_populated && !cfg_populate) uAppendMenu(menu, MF_STRING, ID_REFRESH, "Populate"); uAppendMenu(menu, MF_STRING | (m_filter ? MF_CHECKED : 0), ID_FILT, "Filter"); uAppendMenu(menu, MF_STRING, ID_CONF, "Settings"); bool show_shortcuts = standard_config_objects::query_show_keyboard_shortcuts_in_menus(); node * p_node = NULL; TVITEMEX tvi; memset(&tvi, 0, sizeof(tvi)); tvi.hItem = treeitem; tvi.mask = TVIF_HANDLE | TVIF_PARAM; TreeView_GetItem(list, &tvi); p_node = (node*)tvi.lParam; if (treeitem && p_node) { uAppendMenu(menu, MF_SEPARATOR, 0, ""); uAppendMenu(menu, MF_STRING, ID_SEND, (show_shortcuts ? "&Send to playlist\tEnter" : "&Send to playlist")); uAppendMenu(menu, MF_STRING, ID_ADD, show_shortcuts ? "&Add to playlist\tShift+Enter" : "&Add to playlist"); uAppendMenu(menu, MF_STRING, ID_NEW, show_shortcuts ? "Send to &new playlist\tCtrl+Enter" : "Send to &new playlist"); uAppendMenu(menu, MF_STRING, ID_AUTOSEND, "Send to &autosend playlist"); if (!static_api_ptr_t<core_version_info_v2>()->test_version(0, 9, 6, 0)) { uAppendMenu(menu, MF_STRING, ID_REMOVE, "&Remove from library"); uAppendMenu(menu, MF_STRING, ID_REMOVEDEAD, "Remove &dead entries (slow)"); } uAppendMenu(menu, MF_SEPARATOR, 0, ""); contextmenu_manager::g_create(p_menu_manager); p_node->sort_entries(); if (p_menu_manager.is_valid()) { p_menu_manager->init_context(p_node->get_entries(), 0); p_menu_manager->win32_build_menu(menu, IDM_MANAGER_BASE, -1); menu_helpers::win32_auto_mnemonics(menu); } } int cmd = TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, 0, get_wnd(), 0); DestroyMenu(menu); TreeView_Select(list, NULL, TVGN_DROPHILITE); if (cmd) { if (p_menu_manager.is_valid() && (unsigned)cmd >= IDM_MANAGER_BASE) { p_menu_manager->execute_by_id(cmd - IDM_MANAGER_BASE); } else if (cmd >= ID_VIEW_BASE) { unsigned n = cmd - ID_VIEW_BASE; if (n<views.get_count()) { view = views[n].get_ptr(); refresh_tree(); } } else if (cmd<ID_VIEW_BASE) { unsigned cmd2 = 0; switch (cmd) { case ID_NEW: do_playlist(p_node, true, true); break; case ID_SEND: do_playlist(p_node, true); break; case ID_ADD: do_playlist(p_node, false); break; case ID_AUTOSEND: do_autosend_playlist(p_node, view, true); break; case ID_CONF: { static_api_ptr_t<ui_control>()->show_preferences(g_guid_preferences_album_list_panel); } break; case ID_FILT: { m_filter = !m_filter; create_or_destroy_filter(); } break; case ID_REMOVE: p_node->remove_from_db(); break; case ID_REMOVEDEAD: p_node->remove_dead(); break; case ID_REFRESH: if (!m_populated && !cfg_populate) refresh_tree(); break; } if (cmd2) uSendMessage(get_wnd(), WM_COMMAND, cmd2, 0); } } p_menu_manager.release(); /* if (treeitem_context && (treeitem_context != treeitem) && cfg_autosend) TreeView_SelectItem(wnd_tv,treeitem);*/ } return 0; case WM_NOTIFY: { LPNMHDR hdr = (LPNMHDR)lp; switch (hdr->idFrom) { case IDC_TREE: { if (hdr->code == TVN_ITEMEXPANDING) { LPNMTREEVIEW param = (LPNMTREEVIEW)hdr; if (cfg_picmixer && (param->action == TVE_EXPAND)) { TreeView_CollapseOtherNodes(param->hdr.hwndFrom, param->itemNew.hItem); } } else if (hdr->code == TVN_SELCHANGED) { LPNMTREEVIEW param = (LPNMTREEVIEW)hdr; p_selection = (node*)param->itemNew.lParam; if ((param->action == TVC_BYMOUSE || param->action == TVC_BYKEYBOARD)) { if (cfg_autosend) do_autosend_playlist(p_selection, view); } if (m_selection_holder.is_valid()) { m_selection_holder->set_selection(p_selection.is_valid() ? p_selection->get_entries() : metadb_handle_list()); } #if 0 if (cfg_picmixer) { HTREEITEM ti_parent_old = TreeView_GetParent(param->hdr.hwndFrom, param->itemOld.hItem); HTREEITEM ti_parent_new = TreeView_GetParent(param->hdr.hwndFrom, param->itemNew.hItem); if (/*ti_parent_old != param->itemNew.hItem && */!TreeView_IsChild(param->hdr.hwndFrom, param->itemNew.hItem, param->itemOld.hItem)) { HTREEITEM ti = //TreeView_GetLevel(param->hdr.hwndFrom, param->itemNew.hItem) < TreeView_GetLevel(param->hdr.hwndFrom, param->itemOld.hItem) ? TreeView_GetCommonParentChild(param->hdr.hwndFrom, param->itemOld.hItem, param->itemNew.hItem) //: param->itemOld.hItem ; if (ti && ti != TVI_ROOT) TreeView_Expand(param->hdr.hwndFrom, ti, TVE_COLLAPSE); } if (ti_parent_new) { HTREEITEM child = TreeView_GetChild(param->hdr.hwndFrom, ti_parent_new); while (child) { if (child != param->itemNew.hItem) { } } } } #endif } } break; } } break; case WM_DESTROY: static_api_ptr_t<library_manager_v3>()->unregister_callback(this); modeless_dialog_manager::g_remove(wnd); destroy_tree(); destroy_filter(); m_selection_holder.release(); m_root.release(); p_selection.release(); if (initialised) { list_wnd.remove_item(this); if (list_wnd.get_count() == 0) { DeleteFont(g_font); g_font = 0; } initialised = false; } break; } return DefWindowProc(wnd, msg, wp, lp); }
LRESULT playlist_view::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_NCCREATE: wnd_playlist = wnd; initialised = true; list_playlist.add_item(this); g_playlist_message_window.add_ref(); break; case WM_CREATE: { pfc::com_ptr_t<IDropTarget_playlist> IDT_playlist = new IDropTarget_playlist(this); RegisterDragDrop(wnd, IDT_playlist.get_ptr()); if (true) { m_theme = IsThemeActive() && IsAppThemed() ? OpenThemeData(wnd, L"ListView") : NULL; SetWindowTheme(wnd, L"Explorer", NULL); } m_always_show_focus = config_object::g_get_data_bool_simple(standard_config_objects::bool_playback_follows_cursor, false); on_playlist_font_change(); create_header(true); drawing_enabled = true; m_cache.initialise(); } return 0; case WM_DESTROY: m_edit_save = false; exit_inline_edit(); m_cache.deinitialise(); RevokeDragDrop(wnd); SendMessage(wnd, WM_SETFONT, 0, 0); SendMessage(wnd_header, WM_SETFONT, 0, 0); { if (m_theme) CloseThemeData(m_theme); m_theme = NULL; } m_selection_holder.release(); break; case WM_NCDESTROY: g_playlist_message_window.release(); wnd_playlist = 0; initialised = false; list_playlist.remove_item(this); m_shown = false; // if (!list_playlist.get_count()) // { // g_playlist_entries.rebuild_all(); // } break; case WM_THEMECHANGED: { if (m_theme) CloseThemeData(m_theme); m_theme = IsThemeActive() && IsAppThemed() ? OpenThemeData(wnd, L"ListView") : 0; } break; case WM_SHOWWINDOW: if (wp == TRUE && lp == 0 && !m_shown) { static_api_ptr_t<playlist_manager> playlist_api; ensure_visible(playlist_api->activeplaylist_get_focus_item()); m_shown = true; } break; case WM_WINDOWPOSCHANGED: { LPWINDOWPOS lpwp = (LPWINDOWPOS)lp; if (!(lpwp->flags & SWP_NOSIZE)) { on_size(lpwp->cx, lpwp->cy); } } break; case WM_ERASEBKGND: return TRUE; break; case WM_PAINT: { PAINTSTRUCT ps; HDC dc_paint = BeginPaint(wnd, &ps); RECT rc_update, rc_playlist; get_playlist_rect(&rc_playlist); rc_update = ps.rcPaint; if (rc_update.top<rc_playlist.top) rc_update.top = rc_playlist.top; if (rc_update.bottom >= rc_update.top) { int item_height = get_item_height(); int start_item = (rc_update.top - rc_playlist.top) / item_height; int end_item = (rc_update.bottom - rc_playlist.top) / item_height; if (((end_item - start_item) + 1)*item_height < rc_update.bottom - rc_update.top) end_item++; { draw_items(dc_paint, start_item, 1 + (end_item - start_item)); } } EndPaint(wnd, &ps); } return 0; case WM_SETREDRAW: drawing_enabled = (wp != 0); return 0; case WM_MOUSEACTIVATE: if (GetFocus() != wnd) m_no_next_edit = true; return MA_ACTIVATE; case WM_UPDATEUISTATE: RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE); break; case WM_KILLFOCUS: RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); m_selection_holder.release(); break; case WM_SETFOCUS: //if (msg == WM_SETFOCUS && (HWND)wp != wnd) //m_no_next_edit = true; RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); m_selection_holder = static_api_ptr_t<ui_selection_manager>()->acquire(); m_selection_holder->set_playlist_selection_tracking(); break; case WM_GETDLGCODE: return DLGC_WANTALLKEYS; case WM_KEYDOWN: { static_api_ptr_t<playlist_manager> playlist_api; uie::window_ptr p_this = this; //DWORD vk_slash = VkKeyScan('/'); if (wp == VK_CONTROL) g_drag_lmb = true; if (m_prevent_wm_char_processing = process_keydown(msg, lp, wp, true)) return 0; else { SendMessage(wnd, WM_CHANGEUISTATE, MAKEWPARAM(UIS_CLEAR, UISF_HIDEFOCUS), NULL); if (wp == VK_HOME || wp == VK_DOWN || wp == VK_END || wp == VK_PRIOR || wp == VK_NEXT || wp == VK_UP) { int focus = playlist_api->activeplaylist_get_focus_item(); int total = playlist_api->activeplaylist_get_item_count(); if ((wp == VK_HOME || wp == VK_PRIOR || wp == VK_UP)) { // if (focus == 0) return 0; } if ((wp == VK_END || wp == VK_NEXT || wp == VK_DOWN)) { // if (focus == total - 1) return 0; } SCROLLINFO si; memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_PAGE | SIF_POS; GetScrollInfo(wnd_playlist, SB_VERT, &si); int offset = 0; int scroll = scroll_item_offset; if (wp == VK_HOME) scroll = 0; else if (wp == VK_PRIOR && focus == scroll_item_offset) scroll -= si.nPage; else if (wp == VK_UP) { if (focus <= scroll_item_offset) scroll = focus - 1; else if (focus > si.nPos + si.nPage - 1) scroll = focus - 1 - si.nPage + 1; } else if (wp == VK_DOWN) { if (focus < scroll_item_offset) scroll = focus + 1; else if (focus >= si.nPos + si.nPage - 1) scroll = focus + 1 - si.nPage + 1; } else if (wp == VK_END) scroll = total - 1; else if (wp == VK_NEXT && focus == si.nPos + si.nPage - 1) scroll += si.nPage; drawing_enabled = false; si.nPos = scroll; si.fMask = SIF_POS; scroll_item_offset = SetScrollInfo(wnd_playlist, SB_VERT, &si, true); if (wp == VK_HOME) offset = 0 - focus; else if (wp == VK_PRIOR) offset = scroll_item_offset - focus; else if (wp == VK_END) offset = total - focus - 1; else if (wp == VK_NEXT) offset = get_last_viewable_item() - focus; else if (wp == VK_DOWN) offset = 1; else if (wp == VK_UP) offset = -1; //if (offset) process_keydown(offset, ((HIWORD(lp) & KF_ALTDOWN) != 0), drawing_enabled, (HIWORD(lp) & KF_REPEAT) != 0); drawing_enabled = true; RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); return 0; } else if (wp == VK_SPACE) { int focus = playlist_api->activeplaylist_get_focus_item(); set_sel_single(focus, true, false, false); return 0; } else if (wp == VK_RETURN) { bool ctrl_down = 0 != (GetKeyState(VK_CONTROL) & KF_UP); int focus = playlist_api->activeplaylist_get_focus_item(); unsigned active = playlist_api->get_active_playlist(); if (ctrl_down) { if (active != -1 && focus != -1) playlist_api->queue_add_item_playlist(active, focus); } else { // playlist_api->set_playing_playlist(active); unsigned focus = playlist_api->activeplaylist_get_focus_item(); //unsigned active = playlist_api->get_active_playlist(); //playlist_api->playlist_set_playback_cursor(active, focus); playlist_api->activeplaylist_execute_default_action(focus); //static_api_ptr_t<play_control>()->play_start(play_control::track_command_settrack); } return 0; } else if (wp == VK_SHIFT) { if (!(HIWORD(lp) & KF_REPEAT)) g_shift_item_start = playlist_api->activeplaylist_get_focus_item(); } else if (wp == VK_F2) { unsigned count = g_get_cache().active_column_get_active_count(); if (count) { unsigned focus = playlist_api->activeplaylist_get_focus_item(); if (focus != pfc_infinite) { t_size i, pcount = playlist_api->activeplaylist_get_item_count(); bit_array_bittable sel(pcount); playlist_api->activeplaylist_get_selection_mask(sel); pfc::list_t<t_size> indices; indices.prealloc(32); for (i = 0; i<pcount; i++) if (sel[i]) indices.add_item(i); /*t_size start = focus, end = focus; if (sel[start] && pcount) { while (start>0 && sel[start-1]) start--; while (end<pcount-1 && sel[end+1]) end++; }*/ unsigned count = g_get_cache().active_column_get_active_count(); unsigned column; for (column = 0; column<count; column++) { if (!g_get_columns()[g_get_cache().active_column_active_to_actual(column)]->edit_field.is_empty()) { //create_inline_edit_v2(start, end-start+1, column); create_inline_edit_v2(indices, column); break; } } } } } else if (wp == VK_DELETE) { playlist_api->activeplaylist_undo_backup(); playlist_api->activeplaylist_remove_selection(); } else if (wp == VK_F3) { standard_commands::main_playlist_search(); } /*else if (vk_slash != -1 && wp == LOWORD(vk_slash)) { HWND wnd_search = m_searcher.create(wnd); on_size(); ShowWindow(wnd_search, SW_SHOWNORMAL); ; }*/ } } break; case WM_CHAR: if (!m_prevent_wm_char_processing) { //if (!(HIWORD(lp) & KF_REPEAT)) { if ((GetKeyState(VK_CONTROL) & KF_UP)) { static_api_ptr_t<playlist_manager> playlist_api; if (wp == 1) //Ctrl-A { playlist_api->activeplaylist_set_selection(bit_array_true(), bit_array_true()); return 0; } else if (wp == 26) //Ctrl-Z { playlist_api->activeplaylist_undo_restore(); return 0; } else if (wp == 25) //Ctrl-Y { playlist_api->activeplaylist_redo_restore(); return 0; } else if (wp == 24) //Ctrl-X { playlist_utils::cut(); return 0; } else if (wp == 3) //Ctrl-C { playlist_utils::copy(); return 0; } else if (wp == 6) //Ctrl-F { standard_commands::main_playlist_search(); return 0; } else if (wp == 22) //Ctrl-V { playlist_utils::paste(wnd); return 0; } } } } break; case WM_KEYUP: if (process_keydown(msg, lp, wp, true)) return 0; break; case WM_SYSKEYUP: if (process_keydown(msg, lp, wp, true)) return 0; break; case WM_SYSKEYDOWN: { uie::window_ptr p_this = this; if (m_prevent_wm_char_processing = process_keydown(msg, lp, wp, true)) return 0; } break; case WM_LBUTTONDOWN: { if (0 && g_tooltip) { MSG message; memset(&message, 0, sizeof(MSG)); message.hwnd = wnd; message.message = msg; message.wParam = wp; message.lParam = lp; uSendMessage(g_tooltip, TTM_RELAYEVENT, 0, (LPARAM)&message); } bool b_was_focused = GetFocus() == wnd; if (!b_was_focused) m_no_next_edit = true; //#ifdef INLINE_EDIT exit_inline_edit(); // g_no_next_edit = false; //#endif dragged = false; SetFocus(wnd); SetCapture(wnd); static_api_ptr_t<playlist_manager> playlist_api; g_drag_lmb = true; int focus = playlist_api->activeplaylist_get_focus_item(); drag_start_lmb.x = GET_X_LPARAM(lp); drag_start_lmb.y = GET_Y_LPARAM(lp); int item_height = get_item_height(); int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); // int idx = ((GET_Y_LPARAM(lp) -get_header_height()) / item_height) + scroll_item_offset; // if( idx >= 0 && idx <playlist_api->activeplaylist_get_item_count() && GET_X_LPARAM(lp) < g_playlist_entries.get_total_width_actual()) if (idx >= 0) { // playlist_oper * playlist_api = playlist_api; // playlist_api->set_playback_cursor(idx); //#ifdef INLINE_EDIT m_prev_sel = (playlist_api->activeplaylist_is_item_selected(idx) && !m_wnd_edit && (playlist_api->activeplaylist_get_selection_count(2) == 1)); //#endif if (!is_visible(idx)) SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); if (wp & MK_CONTROL && wp & MK_SHIFT) { playlist_api->activeplaylist_move_selection(idx - focus); dragged = true; drag_type = 0; } else if (wp & MK_SHIFT) { drag_type = 2; dragitem = idx, dragstartitem = idx; int n = (cfg_alternative_sel ? focus : g_shift_item_start), t = idx; bool focus_sel = playlist_api->activeplaylist_is_item_selected(focus); set_sel_range(n, t, (cfg_alternative_sel != 0), (cfg_alternative_sel ? !focus_sel : false)); playlist_api->activeplaylist_set_focus_item(idx); dragged = true; } else if (wp & MK_CONTROL) { /* drag_type = 2; dragitem = idx,dragstartitem=idx; set_sel_single(idx, false, true, false); dragged = true;*/ } else if (playlist_api->activeplaylist_is_item_selected(idx)) { drag_type = 1; dragitem = idx, dragstartitem = idx; playlist_api->activeplaylist_undo_backup(); playlist_api->activeplaylist_set_focus_item(idx); dragged = false; } else { drag_type = 2; dragitem = idx, dragstartitem = idx;//item irrelevant actually; set_sel_single(idx, false, true, true); /* bit_array_bittable mask(playlist_api->activeplaylist_get_item_count()); // playlist_api->activeplaylist_is_item_selected_mask(mask); int n, t = playlist_api->activeplaylist_get_item_count(); for (n = 0;n <t;n++) { if (n==idx) mask.set(n, true); else mask.set(n, false); } console::info("crap"); playlist_api->set_sel_mask(mask); playlist_api->activeplaylist_set_focus_item(idx);*/ dragged = false; } } else { // console::info("wow"); // bit_array_bittable mask(playlist_api->activeplaylist_get_item_count()); playlist_api->activeplaylist_set_selection(bit_array_true(), bit_array_false()); dragged = true; drag_type = 0; } } break; case WM_RBUTTONUP: m_no_next_edit = false; break; case WM_MBUTTONUP: { m_no_next_edit = false; unsigned idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); playlist_mclick_actions::run(cfg_playlist_middle_action, idx != -1, idx); } break; case WM_LBUTTONUP: { if (0 && g_tooltip) { MSG message; memset(&message, 0, sizeof(MSG)); message.hwnd = wnd; message.message = msg; message.wParam = wp; message.lParam = lp; uSendMessage(g_tooltip, TTM_RELAYEVENT, 0, (LPARAM)&message); } ReleaseCapture(); g_drag_lmb = false; int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), true); //((GET_Y_LPARAM(lp) -get_header_height()) / get_item_height()) + scroll_item_offset; static_api_ptr_t<playlist_manager> playlist_api; if (!dragged) { if (wp & MK_CONTROL) { // int idx_down = hittest_item(drag_start_lmb.x, drag_start_lmb.y); if (idx >= 0) set_sel_single(idx, true, true, false); } else { // int item_height = get_item_height(); // int idx = ((GET_Y_LPARAM(lp) - get_header_height()) / item_height) + scroll_item_offset; if (idx >= 0 /*&& idx < playlist_api->activeplaylist_get_item_count() && (GET_X_LPARAM(lp) < g_playlist_entries.get_total_width_actual())*/) { if (!m_no_next_edit && cfg_inline_edit && playlist_api->activeplaylist_is_item_selected(idx) && m_prev_sel /*&& !dragged*/) { //if (m_no_next_edit && GetCapture() == wnd) ReleaseCapture(); { exit_inline_edit(); if (main_window::config_get_inline_metafield_edit_mode() != main_window::mode_disabled) { m_edit_index = idx; long width; m_edit_column = hittest_column(GET_X_LPARAM(lp), width); if (m_edit_column >= 0 && !g_get_columns()[g_get_cache().active_column_active_to_actual(m_edit_column)]->edit_field.is_empty()) { m_edit_timer = (SetTimer(wnd, EDIT_TIMER_ID, GetDoubleClickTime(), 0) != 0); } } } } int focus = playlist_api->activeplaylist_get_focus_item(); set_sel_single(focus, false, false, true); } } } dragged = true; drag_type = 0; dragstartitem = 0; dragitem = 0; //#ifdef INLINE_EDIT m_no_next_edit = false; //#endif } break; case WM_MOUSEMOVE: { if (0 && g_tooltip) { MSG message; memset(&message, 0, sizeof(MSG)); message.hwnd = wnd; message.message = msg; message.wParam = wp; message.lParam = lp; uSendMessage(g_tooltip, TTM_RELAYEVENT, 0, (LPARAM)&message); } const unsigned cx_drag = (unsigned)abs(GetSystemMetrics(SM_CXDRAG)); const unsigned cy_drag = (unsigned)abs(GetSystemMetrics(SM_CYDRAG)); if (!g_dragging && ((g_dragging1 && wp & MK_RBUTTON && (abs(drag_start.x - GET_X_LPARAM(lp)) > cx_drag || abs(drag_start.y - GET_Y_LPARAM(lp)) > cy_drag)) || (g_drag_lmb && (wp & MK_LBUTTON) && (wp & MK_CONTROL) && (abs(drag_start_lmb.x - GET_X_LPARAM(lp)) > 3 || abs(drag_start_lmb.y - GET_Y_LPARAM(lp)) > 3)))) { static_api_ptr_t<playlist_manager> playlist_api; metadb_handle_list data; playlist_api->activeplaylist_get_selected_items(data); if (data.get_count() > 0) { static_api_ptr_t<playlist_incoming_item_filter> incoming_api; IDataObject * pDataObject = incoming_api->create_dataobject(data); if (pDataObject) { //RegisterClipboardFormat(_T("foo_ui_columns"); if (g_tooltip) { DestroyWindow(g_tooltip); g_tooltip = 0; last_idx = -1; last_column = -1; } DWORD blah; { pfc::com_ptr_t<IDropSource_playlist> p_IDropSource_playlist = new IDropSource_playlist(this); DoDragDrop(pDataObject, p_IDropSource_playlist.get_ptr(), DROPEFFECT_COPY, &blah); } pDataObject->Release(); } } data.remove_all(); g_dragging = false; g_dragging1 = false; g_drag_lmb = false; if (wp & MK_LBUTTON) { dragged = true; drag_type = 0; dragstartitem = 0; dragitem = 0; } } if (cfg_tooltip && (GET_Y_LPARAM(lp) > get_header_height())) { int item_height = get_item_height(); int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp)); long cx; int column = hittest_column(GET_X_LPARAM(lp), cx); // unsigned act_col = g_cache.active_column_active_to_actual(column); if (column >= 0 && idx >= 0) { if (last_idx != (idx) || last_column != column) { if (!cfg_tooltips_clipped || is_item_clipped(idx, column)) { pfc::string8 src; g_cache.active_get_display_name(idx, column, src); pfc::string8 temp; titleformat_compiler::remove_color_marks(src, temp); temp.replace_char(9, 0x20); CreateToolTip(temp); } else { DestroyWindow(g_tooltip); g_tooltip = 0; last_idx = -1; last_column = -1; } POINT a; a.x = cx + 3; a.y = (idx - scroll_item_offset) * item_height + get_header_height(); ClientToScreen(wnd_playlist, &a); tooltip.top = a.y; tooltip.bottom = a.y + item_height; tooltip.left = a.x; tooltip.right = a.x + get_column_width(column); } last_idx = idx; last_column = column; } else { DestroyWindow(g_tooltip); g_tooltip = 0; last_idx = -1; last_column = -1; } } if (drag_type && (wp & MK_LBUTTON) && !(GetKeyState(VK_SHIFT) & KF_UP) && !(GetKeyState(VK_CONTROL) & KF_UP)) { RECT rc; get_playlist_rect(&rc); static_api_ptr_t<playlist_manager> playlist_api; int total = playlist_api->activeplaylist_get_item_count(); int item_height = get_item_height(); int valid_idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), false); int idx = hittest_item_no_scroll(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), false); // (GET_Y_LPARAM(lp) - get_header_height()) / (item_height); int items_count = ((rc.bottom - rc.top) / item_height) + 1; if ((idx + scroll_item_offset) != dragitem || GET_Y_LPARAM(lp) < get_header_height()) //(idx + scroll_item_offset) < playlist_api->activeplaylist_get_item_count() { if (idx >= items_count - 1) { bool need_redrawing = false; int focus = playlist_api->activeplaylist_get_focus_item(); SCROLLINFO si; memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo(wnd_playlist, SB_VERT, &si); int old_offset = si.nPos; si.nPos += 3; scroll_item_offset = SetScrollInfo(wnd_playlist, SB_VERT, &si, true); if (old_offset != scroll_item_offset) need_redrawing = true; int t = scroll_item_offset + items_count - 2; //n=dragitem, if (t > total) t = total - 1; if (t != dragitem) { drawing_enabled = false; if (drag_type == 1) playlist_api->activeplaylist_move_selection((rc.bottom - rc.top) / item_height + scroll_item_offset - focus - 1); else if (drag_type == 2) { set_sel_range(dragstartitem, t, false); playlist_api->activeplaylist_set_focus_item(t); } dragitem = t; drawing_enabled = true; need_redrawing = true; } if (need_redrawing) RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } else if (idx < 0 || GET_Y_LPARAM(lp) < get_header_height() || GET_Y_LPARAM(lp) < 0) { int focus = playlist_api->activeplaylist_get_focus_item(); bool need_redrawing = false; SCROLLINFO si; memset(&si, 0, sizeof(si)); si.cbSize = sizeof(si); si.fMask = SIF_POS; GetScrollInfo(wnd_playlist, SB_VERT, &si); int old_offset = si.nPos; si.nPos -= 3; scroll_item_offset = SetScrollInfo(wnd_playlist, SB_VERT, &si, true); if (old_offset != scroll_item_offset) need_redrawing = true; if (dragitem != scroll_item_offset) { drawing_enabled = false; if (drag_type == 1) playlist_api->activeplaylist_move_selection(scroll_item_offset - focus); else if (drag_type == 2) { set_sel_range(dragstartitem, scroll_item_offset, false); playlist_api->activeplaylist_set_focus_item(scroll_item_offset); RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } dragitem = scroll_item_offset; drawing_enabled = true; need_redrawing = true; } if (need_redrawing) RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } else { int focus = playlist_api->activeplaylist_get_focus_item(); if (drag_type == 1) playlist_api->activeplaylist_move_selection(idx + scroll_item_offset - focus); else if (drag_type == 2) { if (valid_idx >= 0) { drawing_enabled = false; set_sel_range(dragstartitem, valid_idx, false); playlist_api->activeplaylist_set_focus_item(valid_idx); drawing_enabled = true; RedrawWindow(wnd_playlist, 0, 0, RDW_INVALIDATE | RDW_UPDATENOW); } } dragitem = valid_idx; dragged = true; } } } else if (!(wp & MK_LBUTTON)) drag_type = 0; } break; case WM_LBUTTONDBLCLK: { int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), true); if (idx >= 0) { //#ifdef INLINE_EDIT exit_inline_edit(); m_no_next_edit = true; //#endif //if (!is_visible(idx)) uSendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0),0); #if 0 // DEATH's code case WM_LBUTTONDBLCLK: { int idx = item_from_point((short)HIWORD(lp)); if (idx >= 0 && idx<(int)m_api->activeplaylist_get_item_count()) { m_api->activeplaylist_set_focus_item(idx); static_api_ptr_t<play_control>()->play_start(play_control::TRACK_COMMAND_SETTRACK); } } return 0; #endif static_api_ptr_t<playlist_manager> playlist_api; //unsigned active = playlist_api->get_active_playlist(); // playlist_api->set_playing_playlist(active); //playlist_api->playlist_set_playback_cursor(active, idx); //playlist_api->queue_flush(); unsigned focus = playlist_api->activeplaylist_get_focus_item(); playlist_api->activeplaylist_execute_default_action(focus); } else if (cfg_playlist_double.get_value().m_command != pfc::guid_null) { mainmenu_commands::g_execute(cfg_playlist_double.get_value().m_command); } dragged = true; } break; case WM_RBUTTONDOWN: { if (wnd_playlist) SetFocus(wnd_playlist); g_dragging1 = true; drag_start.x = GET_X_LPARAM(lp); drag_start.y = GET_Y_LPARAM(lp); static_api_ptr_t<playlist_manager> playlist_api; // int item_height = get_item_height(); // int idx = ((GET_Y_LPARAM(lp) - get_header_height()) / item_height) + scroll_item_offset; int idx = hittest_item(GET_X_LPARAM(lp), GET_Y_LPARAM(lp), true); if (idx != -1 && !is_visible(idx)) SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0), 0); if (idx >= 0 /*&& idx < playlist_api->activeplaylist_get_item_count() && (GET_X_LPARAM(lp) < g_playlist_entries.get_total_width_actual())*/) { if (!playlist_api->activeplaylist_is_item_selected(idx) && !(GetKeyState(VK_CONTROL) & KF_UP)) { set_sel_single(idx, false, false, true); } playlist_api->activeplaylist_set_focus_item(idx); } } break; case WM_MOUSEWHEEL: {//GET_WHEEL_DELTA_WPARAM exit_inline_edit(); if (1 || (wp & MK_CONTROL)) { LONG_PTR style = GetWindowLongPtr(wnd_playlist, GWL_STYLE); if (!(style & WS_VSCROLL) || ((wp & MK_CONTROL) && (style & WS_HSCROLL))) { if ((style & WS_HSCROLL)) { SCROLLINFO si; memset(&si, 0, sizeof(SCROLLINFO)); si.fMask = SIF_PAGE; si.cbSize = sizeof(SCROLLINFO); GetScrollInfo(wnd, SB_HORZ, &si); int new_pos = horizontal_offset; int old_pos = horizontal_offset; unsigned scroll_lines = GetNumScrollLines(); int zDelta = short(HIWORD(wp)); if (scroll_lines == -1) { scroll_lines = si.nPage > 1 ? si.nPage - 1 : 1; } else scroll_lines *= 3; int delta = MulDiv(zDelta, scroll_lines, 120); if (!si.nPage) si.nPage++; if (delta < 0 && delta*-1 > si.nPage) { delta = si.nPage*-1; if (delta >1) delta--; } else if (delta > 0 && delta > si.nPage) { delta = si.nPage; if (delta >1) delta--; } scroll(scroll_horizontally, scroll_position_delta, -delta); } return 1; } } SCROLLINFO si; memset(&si, 0, sizeof(SCROLLINFO)); si.fMask = SIF_PAGE; si.cbSize = sizeof(SCROLLINFO); GetScrollInfo(wnd, SB_VERT, &si); int new_pos = scroll_item_offset; int old_pos = scroll_item_offset; unsigned scroll_lines = GetNumScrollLines(); int zDelta = short(HIWORD(wp)); if (scroll_lines == -1) { scroll_lines = si.nPage > 1 ? si.nPage - 1 : 1; } int delta = MulDiv(zDelta, scroll_lines, 120); if (!si.nPage) si.nPage++; if (delta < 0 && delta*-1 > si.nPage) { delta = si.nPage*-1; if (delta >1) delta--; } else if (delta > 0 && delta > si.nPage) { delta = si.nPage; if (delta >1) delta--; } scroll(scroll_vertically, scroll_position_delta, -delta); } return 1; case WM_VSCROLL: { exit_inline_edit(); scroll(scroll_vertically, scroll_sb, LOWORD(wp)); } return 0; case WM_HSCROLL: { exit_inline_edit(); scroll(scroll_horizontally, scroll_sb, LOWORD(wp)); } return 0; case WM_MENUSELECT: { if (HIWORD(wp) & MF_POPUP) { m_status_override.release(); } else { if (g_main_menu_a.is_valid() || g_main_menu_b.is_valid()) { unsigned id = LOWORD(wp); bool set = false; pfc::string8 desc; if (g_main_menu_a.is_valid() && id < MENU_B_BASE) { set = g_main_menu_a->get_description(id - MENU_A_BASE, desc); } else if (g_main_menu_b.is_valid()) { contextmenu_node * node = g_main_menu_b->find_by_id(id - MENU_B_BASE); if (node) set = node->get_description(desc); } service_ptr_t<ui_status_text_override> p_status_override; if (set) { get_host()->override_status_text_create(p_status_override); if (p_status_override.is_valid()) { p_status_override->override_text(desc); } } m_status_override = p_status_override; } } } break; case WM_CONTEXTMENU: { uie::window_ptr p_this_temp = this; if ((HWND)wp == wnd_header) { POINT pt = { (short)LOWORD(lp), (short)HIWORD(lp) }; POINT temp; temp.x = pt.x; temp.y = pt.y; ScreenToClient(wnd_header, &temp); HDHITTESTINFO hittest; hittest.pt.x = temp.x; hittest.pt.y = temp.y; uSendMessage(wnd_header, HDM_HITTEST, 0, (LPARAM)&hittest); enum { IDM_ASC = 1, IDM_DES = 2, IDM_SEL_ASC, IDM_SEL_DES, IDM_AUTOSIZE, IDM_PREFS, IDM_EDIT_COLUMN, IDM_CUSTOM_BASE }; HMENU menu = CreatePopupMenu(); HMENU selection_menu = CreatePopupMenu(); if (!(hittest.flags & HHT_NOWHERE)) { uAppendMenu(menu, (MF_STRING), IDM_ASC, "&Sort ascending"); uAppendMenu(menu, (MF_STRING), IDM_DES, "Sort &descending"); uAppendMenu(selection_menu, (MF_STRING), IDM_SEL_ASC, "Sort a&scending"); uAppendMenu(selection_menu, (MF_STRING), IDM_SEL_DES, "Sort d&escending"); uAppendMenu(menu, MF_STRING | MF_POPUP, (UINT)selection_menu, "Se&lection"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING), IDM_EDIT_COLUMN, "&Edit this column"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); uAppendMenu(menu, (MF_STRING | (cfg_nohscroll ? MF_CHECKED : MF_UNCHECKED)), IDM_AUTOSIZE, "&Auto-sizing columns"); uAppendMenu(menu, (MF_STRING), IDM_PREFS, "&Preferences"); uAppendMenu(menu, (MF_SEPARATOR), 0, ""); pfc::string8 playlist_name; static_api_ptr_t<playlist_manager> playlist_api; playlist_api->activeplaylist_get_name(playlist_name); pfc::string8_fast_aggressive filter, name; int s, e = columns.get_count(); for (s = 0; s<e; s++) { bool add = false; switch (columns[s]->filter_type) { case FILTER_NONE: { add = true; break; } case FILTER_SHOW: { if (wildcard_helper::test(playlist_name, columns[s]->filter, true)) { add = true; /* g_columns.get_string(s, name, STRING_NAME); uAppendMenu(menu,MF_STRING|MF_CHECKED,IDM_CUSTOM_BASE+s,name);*/ } } break; case FILTER_HIDE: { if (!wildcard_helper::test(playlist_name, columns[s]->filter, true)) { add = true; /* g_columns.get_string(s, name, STRING_NAME); uAppendMenu(menu,MF_STRING|MF_CHECKED,IDM_CUSTOM_BASE+s,name);*/ } } break; } if (add) { uAppendMenu(menu, MF_STRING | (columns[s]->show ? MF_CHECKED : MF_UNCHECKED), IDM_CUSTOM_BASE + s, columns[s]->name); } } } else { uAppendMenu(menu, (MF_STRING | (cfg_nohscroll ? MF_CHECKED : MF_UNCHECKED)), IDM_AUTOSIZE, "&Auto-sizing columns"); uAppendMenu(menu, (MF_STRING), IDM_PREFS, "&Preferences"); } menu_helpers::win32_auto_mnemonics(menu); int cmd = TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, 0, wnd, 0); DestroyMenu(menu); if (cmd == IDM_ASC) { g_set_sort(hittest.iItem, false); } else if (cmd == IDM_DES) { g_set_sort(hittest.iItem, true); } else if (cmd == IDM_SEL_ASC) { g_set_sort(hittest.iItem, false, true); } else if (cmd == IDM_SEL_DES) { g_set_sort(hittest.iItem, true, true); } else if (cmd == IDM_EDIT_COLUMN) { g_set_tab("Columns"); cfg_cur_prefs_col = g_cache.active_column_active_to_actual(hittest.iItem); //get_idx static_api_ptr_t<ui_control>()->show_preferences(columns::config_get_playlist_view_guid()); } else if (cmd == IDM_AUTOSIZE) { cfg_nohscroll = cfg_nohscroll == 0; update_all_windows(); pvt::ng_playlist_view_t::g_on_autosize_change(); } else if (cmd == IDM_PREFS) { static_api_ptr_t<ui_control>()->show_preferences(columns::config_get_main_guid()); } else if (cmd >= IDM_CUSTOM_BASE) { if (t_size(cmd - IDM_CUSTOM_BASE) < columns.get_count()) { columns[cmd - IDM_CUSTOM_BASE]->show = !columns[cmd - IDM_CUSTOM_BASE]->show; //g_columns //if (!cfg_nohscroll) g_save_columns(); //g_cache.flush_all(); g_reset_columns(); update_all_windows(); pvt::ng_playlist_view_t::g_on_columns_change(); } } return 0; } else if ((HWND)wp == wnd) { //DWORD mp = GetMessagePos(); POINT px, pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; static_api_ptr_t<playlist_manager> playlist_api; if (playlist_api->activeplaylist_get_selection_count(1) > 0 && 1) { if (pt.x == -1 && pt.y == -1) { int focus = playlist_api->activeplaylist_get_focus_item(); unsigned last = get_last_viewable_item(); if (focus == -1 || focus < scroll_item_offset || focus > last) { px.x = 0; px.y = 0; } else { RECT rc; get_playlist_rect(&rc); px.x = 0; unsigned item_height = get_item_height(); px.y = (focus - scroll_item_offset)*(item_height)+item_height / 2 + rc.top; } pt = px; MapWindowPoints(wnd, HWND_DESKTOP, &pt, 1); } else { px = pt; ScreenToClient(wnd, &px); //int idx = hittest_item(px.x, px.y); //if (!is_visible(idx)) // SendMessage(wnd_playlist, WM_VSCROLL, MAKEWPARAM(SB_LINEDOWN, 0),0); } // int idx = hittest_item(px.x, px.y); enum { ID_PLAY = 1, ID_CUT, ID_COPY, ID_PASTE, ID_SELECTION, ID_CUSTOM_BASE = 0x8000 }; HMENU menu = CreatePopupMenu();//LoadMenu(core_api::get_my_instance(),MAKEINTRESOURCE(IDR_TREEPOPUP)); service_ptr_t<mainmenu_manager> p_manager_selection; service_ptr_t<contextmenu_manager> p_manager_context; p_manager_selection = standard_api_create_t<mainmenu_manager>(); contextmenu_manager::g_create(p_manager_context); if (p_manager_selection.is_valid()) { p_manager_selection->instantiate(mainmenu_groups::edit_part2_selection); p_manager_selection->generate_menu_win32(menu, ID_SELECTION, ID_CUSTOM_BASE - ID_SELECTION, standard_config_objects::query_show_keyboard_shortcuts_in_menus() ? contextmenu_manager::FLAG_SHOW_SHORTCUTS : 0); if (GetMenuItemCount(menu) > 0) uAppendMenu(menu, MF_SEPARATOR, 0, ""); } AppendMenu(menu, MF_STRING, ID_CUT, L"Cut"); AppendMenu(menu, MF_STRING, ID_COPY, L"Copy"); if (playlist_utils::check_clipboard()) AppendMenu(menu, MF_STRING, ID_PASTE, L"Paste"); AppendMenu(menu, MF_SEPARATOR, 0, NULL); if (p_manager_context.is_valid()) { const keyboard_shortcut_manager::shortcut_type shortcuts[] = { keyboard_shortcut_manager::TYPE_CONTEXT_PLAYLIST, keyboard_shortcut_manager::TYPE_CONTEXT }; p_manager_context->set_shortcut_preference(shortcuts, tabsize(shortcuts)); p_manager_context->init_context_playlist(standard_config_objects::query_show_keyboard_shortcuts_in_menus() ? contextmenu_manager::FLAG_SHOW_SHORTCUTS : 0); p_manager_context->win32_build_menu(menu, ID_CUSTOM_BASE, -1); } menu_helpers::win32_auto_mnemonics(menu); MENU_A_BASE = ID_SELECTION; MENU_B_BASE = ID_CUSTOM_BASE; g_main_menu_a = p_manager_selection; g_main_menu_b = p_manager_context; int cmd = TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, 0, wnd, 0); if (m_status_override.is_valid()) { m_status_override.release(); } DestroyMenu(menu); if (cmd) { if (cmd == ID_CUT) { playlist_utils::cut(); } else if (cmd == ID_COPY) { playlist_utils::copy(); } else if (cmd == ID_PASTE) { playlist_utils::paste(wnd); } else if (cmd >= ID_SELECTION && cmd<ID_CUSTOM_BASE) { if (p_manager_selection.is_valid()) { p_manager_selection->execute_command(cmd - ID_SELECTION); } } else if (cmd >= ID_CUSTOM_BASE) { if (p_manager_context.is_valid()) { p_manager_context->execute_by_id(cmd - ID_CUSTOM_BASE); } } } g_main_menu_a.release(); g_main_menu_b.release(); } // contextmenu_manager::win32_run_menu_context_playlist(wnd, 0, config_object::g_get_data_bool_simple(standard_config_objects::bool_show_keyboard_shortcuts_in_menus, true) ? contextmenu_manager::FLAG_SHOW_SHORTCUTS : 0); } } return 0; //#ifdef INLINE_EDIT case WM_PARENTNOTIFY: { if (wp == WM_DESTROY) { if (m_wnd_edit && (HWND)lp == m_wnd_edit) m_wnd_edit = 0; } } break; case MSG_KILL_INLINE_EDIT: exit_inline_edit(); return 0; #if 1 case WM_COMMAND: switch (wp) { case (EN_CHANGE << 16) | 667: { m_edit_changed = true; } break; } break; #endif case WM_TIMER: { if (wp == EDIT_TIMER_ID) { create_inline_edit_v2(m_edit_index, m_edit_column); if (m_edit_timer) { KillTimer(wnd_playlist, EDIT_TIMER_ID); m_edit_timer = false; } return 0; } } break; //#endif case WM_NOTIFY: switch (((LPNMHDR)lp)->idFrom) { case ID_PLAYLIST_TOOLTIP: switch (((LPNMHDR)lp)->code) { case TTN_SHOW: RECT rc, rc_tt; rc = tooltip; GetWindowRect(g_tooltip, &rc_tt); int offset = MulDiv(get_item_height() - rc_tt.bottom + rc_tt.top, 1, 2); rc.top += offset; SetWindowPos(g_tooltip, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); return TRUE; } break; case 5001: switch (((LPNMHDR)lp)->code) { case HDN_BEGINTRACKA: case HDN_BEGINTRACKW: { return (cfg_nohscroll ? TRUE : FALSE); } case HDN_ENDDRAG: { if (((LPNMHEADERA)lp)->iButton == 0) { if (((LPNMHEADERA)lp)->pitem && (((LPNMHEADERA)lp)->pitem->mask & HDI_ORDER)) { int from = ((LPNMHEADERA)lp)->iItem; int to = ((LPNMHEADERA)lp)->pitem->iOrder; if (to >= 0 && from != to) { int act_from = g_cache.active_column_active_to_actual(from), act_to = g_cache.active_column_active_to_actual(to); columns.move(act_from, act_to); //if (!cfg_nohscroll) g_save_columns(); g_reset_columns(); update_all_windows(); pvt::ng_playlist_view_t::g_on_columns_change(); } } else { } } return (TRUE); } case HDN_DIVIDERDBLCLICK: if (!cfg_nohscroll) { static_api_ptr_t<playlist_manager> playlist_api; HDC hdc; hdc = GetDC(wnd_playlist); int size; pfc::string8 text; SelectObject(hdc, g_font); int w = 0, n, t = playlist_api->activeplaylist_get_item_count(); for (n = 0; n<t; n++) { // playlist_api->format_title(n, text, g_playlist_entries.get_display_spec(((LPNMHEADER)lp)->iItem), NULL); g_cache.active_get_display_name(n, ((LPNMHEADER)lp)->iItem, text); size = ui_helpers::get_text_width_color(hdc, text, text.length()); if (size > w) w = size; } // g_playlist_entries.get_column(((LPNMHEADER)lp)->iItem)->_set_width(w+5); columns[g_cache.active_column_active_to_actual(((LPNMHEADER)lp)->iItem)]->width = w + 15; ReleaseDC(wnd_playlist, hdc); update_all_windows(); g_save_columns(); pvt::ng_playlist_view_t::g_on_column_widths_change(); } return 0; case HDN_ITEMCLICK: { bool des = false; static_api_ptr_t<playlist_manager> playlist_api; unsigned col; bool descending; bool sorted = g_cache.active_get_playlist_sort(col, &descending); if (sorted && col == ((LPNMHEADER)lp)->iItem) des = !descending; g_set_sort(((LPNMHEADER)lp)->iItem, des /*, playlist_api->activeplaylist_get_selection_count(1) && cfg_sortsel != 0*/); } break; case HDN_ITEMCHANGED: { if (!cfg_nohscroll) { if (((LPNMHEADER)lp)->pitem->mask & HDI_WIDTH) columns[g_cache.active_column_active_to_actual(((LPNMHEADER)lp)->iItem)]->width = ((LPNMHEADER)lp)->pitem->cxy; update_all_windows(wnd_header); g_save_columns(); pvt::ng_playlist_view_t::g_on_column_widths_change(); } } break; } break; } } return uDefWindowProc(wnd, msg, wp, lp); }
void splitter_window_impl::refresh_children() { unsigned n, count = m_panels.get_count(), size_cumulative = 0; pfc::array_t<bool> new_items; new_items.set_count(count); new_items.fill_null(); for (n = 0; n<count; n++) { if (!m_panels[n]->m_wnd) { uie::window_ptr p_ext; p_ext = m_panels[n]->m_child; bool b_new = false; if (!p_ext.is_valid()) { ui_extension::window::create_by_guid(m_panels[n]->m_guid, p_ext); b_new = true; } if (!m_panels[n]->m_interface.is_valid()) { service_ptr_t<service_base> temp; g_splitter_host_vert.instance_create(temp); uie::window_host_ptr ptr; if (temp->service_query_t(ptr)) { m_panels[n]->m_interface = static_cast<splitter_host_impl*>(ptr.get_ptr()); m_panels[n]->m_interface->set_window_ptr(this); } } if (p_ext.is_valid() && p_ext->is_available(uie::window_host_ptr(static_cast<uie::window_host*>(m_panels[n]->m_interface.get_ptr())))) { pfc::string8 name; if (m_panels[n]->m_use_custom_title) { name = m_panels[n]->m_custom_title; } else { if (!p_ext->get_short_name(name)) p_ext->get_name(name); } HWND wnd_host = m_panels[n]->m_container.create(m_wnd); m_panels[n]->m_container.set_window_ptr(this); uSetWindowText(wnd_host, name); if (wnd_host) { if (b_new) { try { p_ext->set_config(&stream_reader_memblock_ref(m_panels[n]->m_child_data.get_ptr(), m_panels[n]->m_child_data.get_size()), m_panels[n]->m_child_data.get_size(), abort_callback_impl()); } catch (const exception_io & e) { console::formatter() << "Error setting panel config: " << e.what(); } } HWND wnd_panel = p_ext->create_or_transfer_window(wnd_host, uie::window_host_ptr(m_panels[n]->m_interface.get_ptr())); //FIXX if (wnd_panel) { SetWindowLongPtr(wnd_panel, GWL_STYLE, GetWindowLongPtr(wnd_panel, GWL_STYLE) | WS_CLIPSIBLINGS); MINMAXINFO mmi; memset(&mmi, 0, sizeof(MINMAXINFO)); mmi.ptMaxTrackSize.x = MAXLONG; mmi.ptMaxTrackSize.y = MAXLONG; uSendMessage(wnd_panel, WM_GETMINMAXINFO, 0, (LPARAM)&mmi); clip_minmaxinfo(mmi); m_panels[n]->m_wnd = wnd_host; m_panels[n]->m_wnd_child = wnd_panel; m_panels[n]->m_child = p_ext; m_panels[n]->m_size_limits.min_height = mmi.ptMinTrackSize.y; m_panels[n]->m_size_limits.min_width = mmi.ptMinTrackSize.x; m_panels[n]->m_size_limits.max_width = mmi.ptMaxTrackSize.x; m_panels[n]->m_size_limits.max_height = mmi.ptMaxTrackSize.y; /*console::formatter() << "name: " << name << " min width: " << (t_int32)mmi.ptMinTrackSize.x << " min height: " << (t_int32)mmi.ptMinTrackSize.y << " max width: " << (t_int32)mmi.ptMaxTrackSize.y << " max height: " << (t_int32)mmi.ptMaxTrackSize.y;*/ } else { m_panels[n]->m_container.destroy(); } } } new_items[n] = true;//b_new; } } on_size_changed(); if (IsWindowVisible(get_wnd())) { for (n = 0; n<count; n++) { if (new_items[n]) { ShowWindow(m_panels[n]->m_wnd_child, SW_SHOWNORMAL); ShowWindow(m_panels[n]->m_wnd, SW_SHOWNORMAL); } } get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); RedrawWindow(get_wnd(), 0, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); } }
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { uSendDlgItemMessage(wnd, IDC_SPINPL, UDM_SETRANGE32, -100, 100); uSendDlgItemMessage(wnd, IDC_SWITCH_SPIN, UDM_SETRANGE32, 0, 10000); refresh_me(wnd); initialised = true; } break; case WM_DESTROY: { initialised = false; } break; case WM_COMMAND: switch (wp) { case (EN_CHANGE << 16) | IDC_SWITCH_DELAY: { if (initialised) { BOOL result; unsigned new_height = GetDlgItemInt(wnd, IDC_SWITCH_DELAY, &result, FALSE); if (result) cfg_autoswitch_delay = new_height; } } break; case (EN_CHANGE << 16) | IDC_DROP_STRING: cfg_pgenstring = string_utf8_from_window((HWND)lp); break; #if 0 case IDC_DROP_NAME: cfg_pgen_dir = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_DROP_PLAYLIST: cfg_pgen_playlist = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; #endif case IDC_REMOVE_UNDERSCORES: cfg_replace_drop_underscores = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_DROP_USE_STRING: cfg_pgen_tf = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_ACTIVATE_TARGET: main_window::config_set_activate_target_playlist_on_dropped_items(0 != SendMessage((HWND)lp, BM_GETCHECK, 0, 0)); break; case IDC_AUTOSWITCH: { cfg_drag_autoswitch = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; } } return 0; }
BOOL CALLBACK playlists_dropdown::preferences::DisplayDlgProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case MSG_UPDATEPREVIEW: { static_api_ptr_t<playlist_manager> pm; t_size playlist = pm->get_active_playlist(); if (playlist != pfc_infinite) { static_api_ptr_t<titleformat_compiler> cmp; titleformat_object::ptr title_format; if (cmp->compile(title_format, cfg::title_string)) { titleformat_hook_impl_splitter hook(titleformat_hook_impl_splitter( &title_format_hook(playlist, false), &titleformat_hook_impl_list(playlist, pm->get_playlist_count()))); pfc::string8 title; title_format->run(&hook, title, NULL); pfc::string8 preview; cmp->remove_color_marks(title, preview); preview.replace_char('\t', ' '); uSetDlgItemText(wnd, IDC_PREVIEW, preview); } else { uSetDlgItemText(wnd, IDC_PREVIEW, "COMPILATION ERROR"); } } else { uSetDlgItemText(wnd, IDC_PREVIEW, "N/A"); } } break; case WM_COMMAND: switch (wp) { // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // GENERAL // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_SHOW_ICONS: cfg::show_icons = uButton_GetCheck(wnd, IDC_SHOW_ICONS); playlists_dropdown::g_reload_icons(); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_ICON_UTILS: { HMENU menu = CreatePopupMenu(); uAppendMenu(menu, MF_STRING, 1, "Clear custom icons history"); uAppendMenu(menu, MF_STRING, 2, "Reset all icons to default"); RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_ICON_UTILS), &rc); int cmd = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, GetDlgItem(wnd, IDC_ICON_UTILS), 0); DestroyMenu(menu); if (cmd == 1 && uMessageBox(wnd, "Are you sure you want to clear all custom icons history?", "Continue?", MB_YESNO) == IDYES) { cfg::custom_icons_history.reset(); } else if (cmd == 2 && uMessageBox(wnd, "Are you sure you want to reset all icons to default?", "Continue?", MB_YESNO) == IDYES) { try { static_api_ptr_t<playlist_manager_v2> pm2; for (int i = 0, total = pm2->get_playlist_count(); i < total; i++) { pm2->playlist_remove_property(i, guid_icon_path); } } catch(...) { } } playlists_dropdown::g_reload_icons(); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); } break; case IDC_MIN_VISIBLE | EN_CHANGE << 16: cfg::min_visible = uGetDlgItemInt(wnd, IDC_MIN_VISIBLE, NULL, true); playlists_dropdown::g_update_all_min_visible(); break; case IDC_FORMATTING_STRING | EN_CHANGE << 16: if (TabCtrl_GetDlgCurSel(wnd, IDC_FS_TAB) == 0) { uGetDlgItemText(wnd, IDC_FORMATTING_STRING, cfg::title_string); uSendMessage(wnd, MSG_UPDATEPREVIEW, 0, 0); } else { uGetDlgItemText(wnd, IDC_FORMATTING_STRING, cfg::style_string); } uEnableWindow(uGetDlgItem(wnd, IDC_APPLY), true); break; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // PADDING // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_PADDING_TOP | EN_CHANGE << 16: cfg::padding.get_value().top = uGetDlgItemInt(wnd, IDC_PADDING_TOP, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_PADDING_RIGHT | EN_CHANGE << 16: cfg::padding.get_value().right = uGetDlgItemInt(wnd, IDC_PADDING_RIGHT, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_PADDING_BOTTOM | EN_CHANGE << 16: cfg::padding.get_value().bottom = uGetDlgItemInt(wnd, IDC_PADDING_BOTTOM, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; case IDC_PADDING_LEFT | EN_CHANGE << 16: cfg::padding.get_value().left = uGetDlgItemInt(wnd, IDC_PADDING_LEFT, NULL, true); playlists_dropdown::g_update_all_sizes(); playlists_dropdown::g_redraw_all(); break; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // FIELDS BUTTON // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_FIELDS: { HMENU menu = CreatePopupMenu(); for (int i = 1; i < tabsize(g_fields_list); i++) { uAppendMenu(menu, !!g_fields_list[i].label ? MF_STRING : MF_SEPARATOR, i, g_fields_list[i].label); } RECT rc; GetWindowRect(GetDlgItem(wnd, IDC_FIELDS), &rc); int cmd = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD, rc.left, rc.bottom, 0, GetDlgItem(wnd, IDC_FIELDS), 0); DestroyMenu(menu); if (cmd >= 0 && cmd < tabsize(g_fields_list) && !!g_fields_list[cmd].label) { uSendDlgItemMessageText(wnd, IDC_FORMATTING_STRING, EM_REPLACESEL, TRUE, g_fields_list[cmd].label); SetFocus(GetDlgItem(wnd, IDC_FORMATTING_STRING)); } } break; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // APPLY // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= case IDC_APPLY: apply_config(); uEnableWindow(uGetDlgItem(wnd, IDC_APPLY), FALSE); break; } break; case WM_INITDIALOG: { EnableTheming(wnd); // Setup "Display/Style" TabControl HWND hTabWnd = uGetDlgItem(wnd, IDC_FS_TAB); uTabCtrl_InsertItemText(hTabWnd, 0, "Display"); uTabCtrl_InsertItemText(hTabWnd, 1, "Style"); TabCtrl_SetCurSel(hTabWnd, cfg::last_fs_tab); uSetDlgItemText(wnd, IDC_FORMATTING_STRING, get_formatting_string(TabCtrl_GetCurSel(hTabWnd))); uButton_SetCheck(wnd, IDC_SHOW_ICONS, cfg::show_icons); SetDlgSpinner(wnd, IDC_MIN_VISIBLE_SPIN, IDC_MIN_VISIBLE, 1, 1000, cfg::min_visible); SetDlgSpinner(wnd, IDC_PADDING_TOP_SPIN, IDC_PADDING_TOP, 0, 1024, cfg::padding.get_value().top); SetDlgSpinner(wnd, IDC_PADDING_RIGHT_SPIN, IDC_PADDING_RIGHT, 0, 1024, cfg::padding.get_value().right); SetDlgSpinner(wnd, IDC_PADDING_BOTTOM_SPIN, IDC_PADDING_BOTTOM, 0, 1024, cfg::padding.get_value().bottom); SetDlgSpinner(wnd, IDC_PADDING_LEFT_SPIN, IDC_PADDING_LEFT, 0, 1024, cfg::padding.get_value().left); uEnableWindow(uGetDlgItem(wnd, IDC_APPLY), FALSE); SendMessage(wnd, MSG_UPDATEPREVIEW, 0, 0); } break; case WM_DESTROY: cfg::last_fs_tab = TabCtrl_GetDlgCurSel(wnd, IDC_FS_TAB); break; case WM_NOTIFY: if (((LPNMHDR) lp)->idFrom == IDC_FS_TAB && ((LPNMHDR) lp)->code == TCN_SELCHANGE) { uSetDlgItemText(wnd, IDC_FORMATTING_STRING, get_formatting_string(TabCtrl_GetDlgCurSel(wnd, IDC_FS_TAB))); } break; default: return false; } return true; }
bool ensure_visible(HWND p_listview,unsigned p_index) { return uSendMessage(p_listview,LVM_ENSUREVISIBLE,p_index,FALSE) ? true : false; }
static BOOL CALLBACK ConfigProc(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_INITDIALOG: { uSendDlgItemMessageText(wnd, IDC_PLISTEDGE, CB_ADDSTRING, 0, "None"); uSendDlgItemMessageText(wnd, IDC_PLISTEDGE, CB_ADDSTRING, 0, "Sunken"); uSendDlgItemMessageText(wnd, IDC_PLISTEDGE, CB_ADDSTRING, 0, "Grey"); uSendDlgItemMessage(wnd, IDC_SPINPL, UDM_SETRANGE32, -100, 100); uSendDlgItemMessage(wnd, IDC_SWITCH_SPIN, UDM_SETRANGE32, 0, 10000); refresh_me(wnd); initialised = true; } break; case WM_DESTROY: { initialised = false; SendMessage(wnd, WM_COMMAND, IDC_APPLY, 0); } break; case WM_COMMAND: switch (wp) { case (EN_CHANGE << 16) | IDC_PLHEIGHT: { if (initialised) { BOOL result; int new_height = GetDlgItemInt(wnd, IDC_PLHEIGHT, &result, TRUE); if (result) cfg_plheight = new_height; // if (g_plist) uSendMessage(g_plist, LB_SETITEMHEIGHT, 0, get_pl_item_height()); playlist_switcher_t::g_on_vertical_item_padding_change(); } } break; case IDC_APPLY: if (playlist_switcher_string_changed) { playlist_switcher_t::g_refresh_all_items(); playlist_switcher_string_changed = false; } break; case IDC_PLAUTOHIDE: { cfg_pl_autohide = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); g_on_autohide_tabs_change(); // if (g_main_window) // { // bool move = false; // if (create_plist()) move = true; // if (create_tabs()) move = true; // if (move) {move_window_controls();RedrawWindow(g_main_window, 0, 0, RDW_INVALIDATE|RDW_UPDATENOW);} // } } break; case IDC_MCLICK: cfg_mclick = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; //case IDC_SHIFT_LMB: // cfg_playlists_shift_lmb = SendMessage((HWND)lp,BM_GETCHECK,0,0); // break; //case IDC_DELETE: //cfg_playlist_panel_delete = uSendMessage((HWND)lp,BM_GETCHECK,0,0); //break; case (EN_CHANGE << 16) | IDC_PLAYLIST_TF: cfg_playlist_switcher_tagz = string_utf8_from_window((HWND)lp); playlist_switcher_string_changed = true; break; case IDC_SIDEBAR_TOOLTIPS: cfg_playlist_sidebar_tooltips = SendMessage((HWND)lp, BM_GETCHECK, 0, 0); break; case IDC_USE_PLAYLIST_TF: cfg_playlist_switcher_use_tagz = SendMessage((HWND)lp, BM_GETCHECK, 0, 0); playlist_switcher_t::g_refresh_all_items(); playlist_switcher_string_changed = false; break; case IDC_TABS_MULTILINE: { cfg_tabs_multiline = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); g_on_multiline_tabs_change(); #if 0 if (g_main_window && g_tab) { // create_tabs(); long flags = WS_CHILD | TCS_HOTTRACK | TCS_TABS | (cfg_tabs_multiline ? TCS_MULTILINE : TCS_SINGLELINE) | WS_VISIBLE | WS_CLIPSIBLINGS | TCS_SINGLELINE; uSetWindowLong(g_tab, GWL_STYLE, flags); move_window_controls(); } #endif } break; case IDC_MCLICK3: { cfg_plm_rename = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; case IDC_PLDRAG: { cfg_drag_pl = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; #if 0 case IDC_MCLICK2: { cfg_mclick2 = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); } break; case IDC_TABS: { cfg_tabs = uSendMessage((HWND)lp, BM_GETCHECK, 0, 0); if (g_main_window) { create_tabs(); move_window_controls(); } } break; #endif case (CBN_SELCHANGE << 16) | IDC_PLISTEDGE: { cfg_plistframe = uSendMessage((HWND)lp, CB_GETCURSEL, 0, 0); playlist_switcher_t::g_on_edgestyle_change(); } break; } } return 0; }