mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-29 09:13:39 +01:00
Make all list controls copy by default.
Yay. Much better than screenshots.
This commit is contained in:
1 parent
9e8e9ec62f
commit
7deeb813a7
2 files changed
+59
-10
No files matched your search
+56
-10
@@ -61,20 +61,24 @@ namespace W32Util
|
||||
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const char *text) {
|
||||
std::wstring wtext = ConvertUTF8ToWString(text);
|
||||
return CopyTextToClipboard(hwnd, wtext);
|
||||
}
|
||||
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const std::wstring &wtext) {
|
||||
OpenClipboard(hwnd);
|
||||
EmptyClipboard();
|
||||
HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (wtext.size() + 1) * sizeof(wchar_t));
|
||||
if (hglbCopy == NULL) {
|
||||
CloseClipboard();
|
||||
return FALSE;
|
||||
}
|
||||
HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (wtext.size() + 1) * sizeof(wchar_t));
|
||||
if (hglbCopy == NULL) {
|
||||
CloseClipboard();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Lock the handle and copy the text to the buffer.
|
||||
// Lock the handle and copy the text to the buffer.
|
||||
|
||||
wchar_t *lptstrCopy = (wchar_t *)GlobalLock(hglbCopy);
|
||||
wcscpy(lptstrCopy, wtext.c_str());
|
||||
lptstrCopy[wtext.size()] = (wchar_t) 0; // null character
|
||||
GlobalUnlock(hglbCopy);
|
||||
wchar_t *lptstrCopy = (wchar_t *)GlobalLock(hglbCopy);
|
||||
wcscpy(lptstrCopy, wtext.c_str());
|
||||
lptstrCopy[wtext.size()] = (wchar_t) 0; // null character
|
||||
GlobalUnlock(hglbCopy);
|
||||
SetClipboardData(CF_UNICODETEXT, hglbCopy);
|
||||
CloseClipboard();
|
||||
return TRUE;
|
||||
@@ -216,11 +220,53 @@ LRESULT CALLBACK GenericListControl::wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
case WM_SIZE:
|
||||
list->ResizeColumns();
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch (wParam)
|
||||
{
|
||||
case VK_INSERT:
|
||||
case 'C':
|
||||
if (KeyDownAsync(VK_CONTROL))
|
||||
list->ProcessCopy();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return (LRESULT)CallWindowProc((WNDPROC)list->oldProc,hwnd,msg,wParam,lParam);
|
||||
}
|
||||
|
||||
void GenericListControl::ProcessCopy()
|
||||
{
|
||||
int start = ListView_GetSelectionMark(handle);
|
||||
int size;
|
||||
if (start == -1)
|
||||
size = GetRowCount();
|
||||
else
|
||||
size = ListView_GetSelectedCount(handle);
|
||||
|
||||
CopyRows(start, size);
|
||||
}
|
||||
|
||||
void GenericListControl::CopyRows(int start, int size)
|
||||
{
|
||||
std::wstring data;
|
||||
for (int r = start; r < start + size; ++r)
|
||||
{
|
||||
for (int c = 0; c < columnCount; ++c)
|
||||
{
|
||||
stringBuffer[0] = 0;
|
||||
GetColumnText(stringBuffer, r, c);
|
||||
data.append(stringBuffer);
|
||||
if (c < columnCount - 1)
|
||||
data.append(L"\t");
|
||||
else
|
||||
data.append(L"\r\n");
|
||||
}
|
||||
}
|
||||
W32Util::CopyTextToClipboard(handle, data);
|
||||
}
|
||||
|
||||
int GenericListControl::GetSelectedIndex()
|
||||
{
|
||||
return ListView_GetNextItem(handle, -1, LVNI_SELECTED);
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace W32Util
|
||||
HBITMAP CreateBitmapFromARGB(HWND someHwnd, DWORD *image, int w, int h);
|
||||
void NiceSizeFormat(size_t size, char *out);
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const char *text);
|
||||
BOOL CopyTextToClipboard(HWND hwnd, const std::wstring &wtext);
|
||||
void MakeTopMost(HWND hwnd, bool topMost);
|
||||
}
|
||||
|
||||
@@ -41,9 +42,11 @@ protected:
|
||||
virtual int GetRowCount() = 0;
|
||||
virtual void OnDoubleClick(int itemIndex, int column) { };
|
||||
virtual void OnRightClick(int itemIndex, int column, const POINT& point) { };
|
||||
virtual void CopyRows(int start, int size);
|
||||
private:
|
||||
static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||
void ResizeColumns();
|
||||
void ProcessCopy();
|
||||
|
||||
HWND handle;
|
||||
WNDPROC oldProc;
|
||||
|
||||
Reference in new issue
Block a user