bool playlist_view::draw_items(int start_item, int count) { HDC dc = GetDC(wnd_playlist); bool ret = draw_items(dc, start_item, count); ReleaseDC(wnd_playlist, dc); return ret; }
void sigwinch(int sig) { int i; (void)sig; fflush(l.f_out); fprintf(l.f_out, "\n\nThis alpha version have resize disabled\n"); fflush(l.f_out); fflush(f_result); fclose(f_result); exit(1); ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz); if (winsz.ws_row <= nb_items_per_page) l.items_per_page = winsz.ws_row - 1; else l.items_per_page = nb_items_per_page; l.col_width = winsz.ws_col; calibre_width(&l); for (i = 0 ; i != l.items_per_page; i++) { if (l.nb_colsw[i] > l.col_width) while(l.nb_colsw[i]-- > l.col_width) fprintf(l.f_out, "%s", dcstr); } draw_items(&l); signal(SIGWINCH, sigwinch); }
void mainmenu(int sel) { int i; textattr(0x90); window(1,1,80,25); clrscr(); textattr(BORDER); gotoxy(M_LX,M_UY); cputs("Ú"); for (i = 1; i < (M_WIDTH-1); i++) cputs("Ä"); cputs("¿"); gotoxy(M_LX,M_UY+1); cputs("³ ³"); textattr(BANNER); gotoxy(M_LX+2,M_UY+1); cputs(" Main menu"); textattr(BORDER); gotoxy(M_LX,M_UY+2); cputs("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´"); for (i = 3; i < (menu_count + M_HEIGHT-1); i++) { gotoxy(M_LX,M_UY+i); cputs("³ ³"); } gotoxy(M_LX,M_UY+i); cputs("À"); for (i = 1; i < (M_WIDTH-1); i++) cputs("Ä"); cputs("Ù"); draw_items(menu_items,menu_count,M_LX+1,M_UY+3,sel); }
void radio_paint(t_radio *x, t_object *view) { t_rect rect; ebox_get_rect_for_view((t_ebox *)x, &rect); draw_background(x, view, &rect); draw_items(x, view, &rect); }
bool playlist_view::draw_items_wrapper(int start_item, int count) { if (count < 1 || start_item < 0) return false; bool rv = false; static_api_ptr_t<playlist_manager> playlist_api; RECT rect; get_playlist_rect(&rect); int item_height = get_item_height(); int total = playlist_api->activeplaylist_get_item_count(); int visible_first = scroll_item_offset; //we minus 1 because this is a count, last_offset is zero-based index int visible_last = scroll_item_offset + (rect.bottom - rect.top) / item_height - 1; //is there a partially obscured item ?? if ((visible_last - visible_first + 1)*item_height < rect.bottom - rect.top) visible_last++; if (visible_last >= total) visible_last = total - 1; if (start_item + count - 1 < visible_first || start_item > visible_last) return false; int new_first = start_item; int new_count = count; if (new_first < visible_first) { new_count -= visible_first - new_first; new_first = visible_first; } if (new_first + new_count - 1 > visible_last) { new_count -= ((new_first + new_count - 1) - visible_last); } int relative_item = new_first - scroll_item_offset; draw_items(relative_item, new_count); return true; }
Boolean handle_menu (short item, HMENU) { short i,j,k; Boolean to_return = FALSE; item_record_type store_i; if ((file_in_mem == FALSE) && ((item == 1) || (item == 3) || (item >= 40)) && (item != 200) && (item != 100)) { display_strings(20,5,0,0,"Editing party",57,707,0); item = -1; } switch (item) { case -1: break; case 1: save_file(0); break; case 2: if (verify_restore_quit(1) == TRUE) load_file(); update_item_menu(item_menus_lock); break; case 3: save_file(1); break; case 4: All_Done = verify_restore_quit(0); break; case 41: edit_gold_or_food(0); redraw_screen(); break; case 42: edit_gold_or_food(1); redraw_screen(); break; case 44: if (party.stuff_done[304][0] > 0) { FCD(909,0); break; } FCD(901,0); leave_town(); break; case 45: if (party.stuff_done[304][0] == 0) { FCD(911,0); break; } FCD(910,0); c_town.p_loc.x = party.stuff_done[304][1]; c_town.p_loc.y = party.stuff_done[304][2]; party.stuff_done[304][0] = 0; for (i = 0; i < 6; i++) if (adven[i].main_status >= 10) adven[i].main_status -= 10; redraw_screen(); break; case 48: display_strings(20,20,0,0,"Editing party",57,707,0); for (i = 0; i < 4; i++) party.creature_save[i].which_town = 200; break; case 51: // damage display_strings(20,1,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) adven[i].cur_health = adven[i].max_health; redraw_screen(); break; case 52: // spell pts display_strings(20,2,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) adven[i].cur_sp = adven[i].max_sp; redraw_screen(); break; case 53: // raise dead display_strings(20,3,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) if ((adven[i].main_status == 2) || (adven[i].main_status == 3) || (adven[i].main_status == 4)) adven[i].main_status = 1; redraw_screen(); break; case 54: // conditions display_strings(20,4,0,0,"Editing party",57,715,0); for (i = 0; i < 6; i++) { adven[i].status[2] = 0; if (adven[i].status[3] < 0) adven[i].status[3] = 0; adven[i].status[6] = 0; adven[i].status[7] = 0; adven[i].status[9] = 0; adven[i].status[11] = 0; adven[i].status[12] = 0; adven[i].status[13] = 0; } redraw_screen(); break; case 55: if (party_in_scen == FALSE) { display_strings(20,25,0,0,"Editing party",57,715,0); break; } if (FCD(912,0) != 1) break; remove_party_from_scen(); party.stuff_done[304][0] = 0; redraw_screen(); break; case 62: display_alchemy(); break; case 63: // all property display_strings(20,6,0,0,"Editing party",57,707,0); for (i = 0; i < 30; i++) { party.boats[i].property = FALSE; party.horses[i].property = FALSE; } break; case 70: // edit day edit_day(); break; case 71: // out maps if (party_in_scen == FALSE) { display_strings(20,25,0,0,"Editing party",57,715,0); break; } display_strings(20,13,0,0,"Editing party",57,715,0); for (i = 0; i < 96; i++) for (j = 0; j < 96; j++) out_e[i][j] = 1; for (i = 0; i < 100; i++) for (j = 0; j < 6; j++) for (k = 0; k < 48; k++) o_maps.outdoor_maps[i][j][k] = 255; break; case 72: // town maps if (party_in_scen == FALSE) { display_strings(20,25,0,0,"Editing party",57,715,0); break; } display_strings(20,14,0,0,"Editing party",57,715,0); for (i = 0; i < 64; i++) for (j = 0; j < 64; j++) c_town.explored[i][j] = 1; for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++) town_maps.town_maps[i][j][k] = 255; break; case 100: // index WinHelp(mainPtr,"Blades of Exile.hlp",HELP_CONTENTS,0L); break; case 200: // about FCD(1062,0); break; default: item -= 600; store_i = scen_item_list.scen_items[item]; if(store_i.variety == 3){ party.gold += get_ran(1,1,20); redraw_screen(); break; } if(store_i.variety == 11){ party.food += get_ran(1,1,20); redraw_screen(); break; } give_to_pc(current_active_pc,store_i,FALSE); draw_items(1); break; } return to_return; }
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); }
int main(int ac, char **av) { int c; int ch; int i; int count_items; char **items; int shortcut[] = {'1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 0}; int shortcut_len = sizeof shortcut / sizeof(int); int l_num; int mode = 0; if (ac == 1) usage(); init_locale(); f_result = stderr; l.f_out = stdout; i = get_options(ac, av); items = av + i; count_items = ac - i; if (count_items == 0) return (1); if (nb_items_per_page <= 0 || nb_items_per_page >= shortcut_len) return 1; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &= ~( ICANON | ECHO ); tcsetattr( STDIN_FILENO, TCSANOW, &newt); terminit(); l.prefix = shortcut; l.upstr = upstr; l.dcstr = dcstr; l.bottom_msg[0] = '\0'; l.bottom_msg_col_s = 0; l.y = 0; l.cursor_y = 0; l.item_top_page = 0; set_items_per_page(&l, nb_items_per_page); set_items(&l, items, count_items); signal(SIGWINCH, sigwinch); ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsz); l.col_width = winsz.ws_col; calibre_width(&l); draw_items(&l); fflush(l.f_out); while ((c = getchar()) != 'q') { if (c == -1) { if (errno == EINTR) continue; exit(1); } switch (c) { case '/': tcsetattr( STDIN_FILENO, TCSANOW, &oldt); search(); l.cur_page = 0; l.cursor_y = 0; draw_items(&l); tcsetattr( STDIN_FILENO, TCSANOW, &newt); break; case 'n' /*|| ' ' || 'j' */: page_seek(&l, RELATIVE, 1); break; case 'p' /*|| 'k'*/: page_seek(&l, RELATIVE, -1); break; case 'j': cursor_seek(&l, 1, 1); break; case 'k': cursor_seek(&l, 1, -1); break; case ' ': select_item(&l, l.cursor_y); cursor_seek(&l, RELATIVE, 1); break; case '\n': enter_selected_items(); cleanup_exit(0); break; default: if ((l_num = has_c(c, shortcut)) >= 0) { enter_result(l_num + l.item_top_page); cleanup_exit(0); } break; } fflush(l.f_out); } cleanup_exit(0); return 0; }
void redraw_screen() { draw_main_screen(); display_party(6,1); draw_items(1); }
void draw_terrain() { short q,r,x,i,small_i; location which_pt,where_draw; RECT draw_rect,clipping_rect = {8,8,260,332}; unsigned char t_to_draw; RECT tiny_to,tiny_to_base = {29,37,36,44},tiny_from,from_rect,to_rect; HBITMAP store_bmp; COLORREF gray = RGB(128,128,128); COLORREF red = RGB(255,0,0); COLORREF white = RGB(255,255,255); HBRUSH new_brush; HDC hdc; HPEN old_pen; if (overall_mode >= 60) return; if (cur_viewing_mode == 0) { paint_pattern(ter_draw_gworld,0,terrain_rect,1); } hdc = CreateCompatibleDC(main_dc); SetBkMode(hdc,TRANSPARENT); SelectObject(hdc,small_bold_font); store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld); new_brush = CreateSolidBrush(gray); FrameRect(hdc,&terrain_rect,new_brush); DeleteObject(new_brush); old_pen = (HPEN)SelectObject(hdc,GetStockObject(NULL_PEN)); SelectObject(hdc,store_bmp); if (cur_viewing_mode == 0) { for (q = 0; q < 9; q++) for (r = 0; r < 9; r++) { where_draw.x = q; where_draw.y = r; if (editing_town == TRUE) { t_to_draw = t_d.terrain[cen_x + q - 4][cen_y + r - 4]; } else { if (cen_x + q - 4 == -1) t_to_draw = borders[3][cen_y + r - 4]; else if (cen_x + q - 4 == 48) t_to_draw = borders[1][cen_y + r - 4]; else if (cen_y + r - 4 == -1) t_to_draw = borders[0][cen_x + q - 4]; else if (cen_y + r - 4 == 48) t_to_draw = borders[2][cen_x + q - 4]; else t_to_draw = current_terrain.terrain[cen_x + q - 4][cen_y + r - 4]; } draw_one_terrain_spot(q,r,t_to_draw); which_pt.x = cen_x + q - 4; which_pt.y =cen_y + r - 4; tiny_to = tiny_to_base; OffsetRect(&tiny_to,28 * q, 36 * r); // draw start icon, if starting point if ((editing_town == TRUE) && (cur_town == scenario.which_town_start) && (scenario.where_start.x == cen_x + q - 4) && (scenario.where_start.y == cen_y + r - 4)) { from_rect = start_button_from; to_rect = tiny_to; to_rect.left -= 14; rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0); OffsetRect(&tiny_to,0,-7); } if ((editing_town == FALSE) && (scenario.out_sec_start.x == cur_out.x) && (scenario.out_sec_start.y == cur_out.y) && (scenario.out_start.x == cen_x + q - 4) && (scenario.out_start.y == cen_y + r - 4)) { from_rect = start_button_from; to_rect = tiny_to; to_rect.left -= 14; rect_draw_some_item(editor_mixed,from_rect,ter_draw_gworld,to_rect,0,0); OffsetRect(&tiny_to,0,-7); } small_i = small_icons[scenario.ter_types[t_to_draw].special]; if ((small_i == 30) && (scenario.ter_types[t_to_draw].flag2 >= 5)) small_i = 31; if ((small_i == 31) && (scenario.ter_types[t_to_draw].flag2 == 10)) small_i = 32; tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); if (small_i > 0) { rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } if (is_special(cen_x + q - 4,cen_y + r - 4) == TRUE) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (7),7 * (0)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } if ((t_to_draw == 7) || (t_to_draw == 10) || (t_to_draw == 13) || (t_to_draw == 16)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (3),7 * (2)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } if (editing_town == FALSE) { for (i = 0; i < 4; i++) if ((cen_x + q - 4 == current_terrain.wandering_locs[i].x) && (cen_y + r - 4 == current_terrain.wandering_locs[i].y)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (2),7 * (1)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); i = 4; } } if (editing_town == TRUE) { for (i = 0; i < 4; i++) if ((cen_x + q - 4 == town.start_locs[i].x) && (cen_y + r - 4 == town.start_locs[i].y)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (6 + i),7 * (1)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); } for (i = 0; i < 4; i++) if ((cen_x + q - 4 == town.wandering_locs[i].x) && (cen_y + r - 4 == town.wandering_locs[i].y)) { tiny_from = base_small_button_from; OffsetRect(&tiny_from,7 * (2),7 * (1)); rect_draw_some_item(editor_mixed,tiny_from,ter_draw_gworld,tiny_to,0,0); OffsetRect(&tiny_to,0,-7); i = 4; } if (is_web(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(5,0); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_crate(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(6,0); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_barrel(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(7,0); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_fire_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(0,2); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_quickfire(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(7,1); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } if (is_force_barrier(cen_x + q - 4,cen_y + r - 4) == TRUE) { from_rect = calc_rect(2,2); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } for (i = 0; i < 8; i++) if (is_sfx(cen_x + q - 4,cen_y + r - 4,i)) { from_rect = calc_rect(i,3); Draw_Some_Item(field_gworld,from_rect,ter_draw_gworld,where_draw,1,0); } for (x = 0; x < 64; x++) if ((cen_x + q - 4 == town.preset_items[x].item_loc.x) && (cen_y + r - 4 == town.preset_items[x].item_loc.y) && (town.preset_items[x].item_code >= 0)) { } for (x = 0; x < 60; x++) if ((cen_x + q - 4 == t_d.creatures[x].start_loc.x) && (cen_y + r - 4 == t_d.creatures[x].start_loc.y) && (t_d.creatures[x].number != 0)) { } } } if (editing_town == TRUE) { draw_monsts(hdc); draw_items(hdc); } store_bmp = (HBITMAP)SelectObject(hdc,ter_draw_gworld); ClipRect(hdc,&clipping_rect); if (editing_town == TRUE) { // draw info rects for (i = 0; i < 16; i++) if (t_d.room_rect[i].left > -1) { draw_rect.left = 22 + 28 * (t_d.room_rect[i].left - cen_x + 4); draw_rect.right = 22 + 28 * (t_d.room_rect[i].right - cen_x + 4); draw_rect.top = 24 + 36 * (t_d.room_rect[i].top - cen_y + 4); draw_rect.bottom = 24 + 36 * (t_d.room_rect[i].bottom - cen_y + 4); //c = GetNearestPaletteIndex(hpal,red); new_brush = CreateSolidBrush(red); FrameRect(hdc,&draw_rect,new_brush); DeleteObject(new_brush); } // draw border rect draw_rect.left = 21 + 28 * (town.in_town_rect.left - cen_x + 4); draw_rect.right = 21 + 28 * (town.in_town_rect.right - cen_x + 4); draw_rect.top = 25 + 36 * (town.in_town_rect.top - cen_y + 4); draw_rect.bottom = 25 + 36 * (town.in_town_rect.bottom - cen_y + 4); // c = GetNearestPaletteIndex(hpal,white); new_brush = CreateSolidBrush(white); FrameRect(hdc,&draw_rect,new_brush); DeleteObject(new_brush); } if (editing_town == FALSE) { // draw info rects for (i = 0; i < 8; i++) if (current_terrain.info_rect[i].left > -1) { draw_rect.left = 22 + 28 * (current_terrain.info_rect[i].left - cen_x + 4); draw_rect.right = 22 + 28 * (current_terrain.info_rect[i].right - cen_x + 4); draw_rect.top = 24 + 36 * (current_terrain.info_rect[i].top - cen_y + 4); draw_rect.bottom = 24 + 36 * (current_terrain.info_rect[i].bottom - cen_y + 4); //c = GetNearestPaletteIndex(hpal,red); new_brush = CreateSolidBrush(red); FrameRect(hdc,&draw_rect,new_brush); DeleteObject(new_brush); } } undo_clip(hdc); SelectObject(hdc,store_bmp); small_any_drawn = FALSE; } if (cur_viewing_mode == 1) { if (small_any_drawn == FALSE) { InsetRect(&terrain_rect,1,1); paint_pattern(ter_draw_gworld,0,terrain_rect,1); InsetRect(&terrain_rect,-1,-1); //FrameRect(&terrain_rect); } for (q = 0; q < ((editing_town == TRUE) ? max_dim[town_type] : 48); q++) for (r = 0; r < ((editing_town == TRUE) ? max_dim[town_type] : 48); r++) { t_to_draw = (editing_town == TRUE) ? t_d.terrain[q][r] : current_terrain.terrain[q][r]; if ((small_what_drawn[q][r] != t_to_draw) || (small_any_drawn == FALSE)) { draw_one_tiny_terrain_spot(q,r,t_to_draw,hdc); small_what_drawn[q][r] = t_to_draw; } } small_any_drawn = TRUE; } SelectObject(hdc,old_pen); DeleteObject(hdc); //draw_cur_string(); place_location(); rect_draw_some_item(ter_draw_gworld,terrain_rect,ter_draw_gworld,world_screen,0,1); }
//extern Rect pc_area_buttons[6][6] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later //extern Rect item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 - bool handle_action(EventRecord event,short mode) //short mode; // ignore, { short i; Point the_point; short choice = 4; bool to_return = false; the_point = event.where; GlobalToLocal(&the_point); if (file_in_mem == false) return false; for (i = 0; i < 6; i++) if ((PtInRect(the_point,&pc_area_buttons[i][0]) == true) && (univ.party[i].main_status > 0)) { do_button_action(0,i); current_active_pc = i; display_party(6,1); draw_items(1); } for (i = 0; i < 5; i++) if ((PtInRect(the_point,&edit_rect[i][0]) == true) && (univ.party[current_active_pc].main_status > 0)) { do_button_action(0,i + 10); if (save_blocked == false) if ((choice = FCD(904,0)) == 1) return to_return; else save_blocked = true; switch(i) { case 0: display_pc(current_active_pc,0,0); break; case 1: display_pc(current_active_pc,1,0); break; case 2: pick_race_abil(&univ.party[current_active_pc],0,0); break; case 3: spend_xp(current_active_pc,1,0); break; case 4: edit_xp(&univ.party[current_active_pc]); break; } } for (i = 0; i < 24; i++) if ((PtInRect(the_point,&item_string_rects[i][1]) == true) && // drop item (univ.party[current_active_pc].items[i].variety > 0)) { // variety = 0 no item in slot/ non 0 item exists flash_rect(item_string_rects[i][1]); take_item(current_active_pc,i); draw_items(1); } for (i = 0; i < 24; i++) if ((PtInRect(the_point,&item_string_rects[i][2]) == true) && // identify item (univ.party[current_active_pc].items[i].variety > 0)) { flash_rect(item_string_rects[i][2]); univ.party[current_active_pc].items[i].ident = true; draw_items(1); } return to_return; }