| 1 | /* $Id: clipboard.cpp,v 1.12 2001-06-09 14:50:16 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 Clipboard API functions for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998 Sander van Leeuwen
|
|---|
| 7 | * Copyright 1998 Patrick Haller
|
|---|
| 8 | * Copyright 1998 Peter Fitzsimmons
|
|---|
| 9 | *
|
|---|
| 10 | *
|
|---|
| 11 | * NOTE: Use OS/2 frame handles for Open32 functions
|
|---|
| 12 | *
|
|---|
| 13 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 14 | *
|
|---|
| 15 | */
|
|---|
| 16 |
|
|---|
| 17 | #include <os2win.h>
|
|---|
| 18 | #include "win32wbase.h"
|
|---|
| 19 | #include <unicode.h>
|
|---|
| 20 |
|
|---|
| 21 | #define DBG_LOCALLOG DBG_clipboard
|
|---|
| 22 | #include "dbglocal.h"
|
|---|
| 23 |
|
|---|
| 24 | //******************************************************************************
|
|---|
| 25 | //******************************************************************************
|
|---|
| 26 | BOOL WIN32API ChangeClipboardChain( HWND hwndRemove, HWND hwndNext)
|
|---|
| 27 | {
|
|---|
| 28 | Win32BaseWindow *wndRemove, *wndNext;
|
|---|
| 29 | HWND hwndOS2Remove, hwndOS2Next;
|
|---|
| 30 |
|
|---|
| 31 | wndRemove = Win32BaseWindow::GetWindowFromHandle(hwndRemove);
|
|---|
| 32 | if(!wndRemove) {
|
|---|
| 33 | dprintf(("ChangeClipboardChain, window %x not found", hwndRemove));
|
|---|
| 34 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 35 | return 0;
|
|---|
| 36 | }
|
|---|
| 37 | hwndOS2Remove = wndRemove->getOS2WindowHandle();
|
|---|
| 38 | RELEASE_WNDOBJ(wndRemove);
|
|---|
| 39 |
|
|---|
| 40 | wndNext = Win32BaseWindow::GetWindowFromHandle(hwndNext);
|
|---|
| 41 | if(!wndNext) {
|
|---|
| 42 | dprintf(("ChangeClipboardChain, window %x not found", hwndNext));
|
|---|
| 43 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 44 | return 0;
|
|---|
| 45 | }
|
|---|
| 46 | hwndOS2Next = wndNext->getOS2WindowHandle();
|
|---|
| 47 | RELEASE_WNDOBJ(wndNext);
|
|---|
| 48 |
|
|---|
| 49 | dprintf(("USER32: ChangeClipboardChain\n"));
|
|---|
| 50 | return O32_ChangeClipboardChain(hwndOS2Remove, hwndOS2Next);
|
|---|
| 51 | }
|
|---|
| 52 | //******************************************************************************
|
|---|
| 53 | //******************************************************************************
|
|---|
| 54 | BOOL WIN32API CloseClipboard(void)
|
|---|
| 55 | {
|
|---|
| 56 | dprintf(("USER32: CloseClipboard\n"));
|
|---|
| 57 | return O32_CloseClipboard();
|
|---|
| 58 | }
|
|---|
| 59 | //******************************************************************************
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | int WIN32API CountClipboardFormats(void)
|
|---|
| 62 | {
|
|---|
| 63 | dprintf(("USER32: CountClipboardFormats\n"));
|
|---|
| 64 | return O32_CountClipboardFormats();
|
|---|
| 65 | }
|
|---|
| 66 | //******************************************************************************
|
|---|
| 67 | //******************************************************************************
|
|---|
| 68 | BOOL WIN32API EmptyClipboard(void)
|
|---|
| 69 | {
|
|---|
| 70 | dprintf(("USER32: EmptyClipboard\n"));
|
|---|
| 71 | return O32_EmptyClipboard();
|
|---|
| 72 | }
|
|---|
| 73 | //******************************************************************************
|
|---|
| 74 | //******************************************************************************
|
|---|
| 75 | UINT WIN32API EnumClipboardFormats(UINT arg1)
|
|---|
| 76 | {
|
|---|
| 77 | dprintf(("USER32: EnumClipboardFormats\n"));
|
|---|
| 78 | return O32_EnumClipboardFormats(arg1);
|
|---|
| 79 | }
|
|---|
| 80 | //******************************************************************************
|
|---|
| 81 | //******************************************************************************
|
|---|
| 82 | HANDLE WIN32API GetClipboardData( UINT arg1)
|
|---|
| 83 | {
|
|---|
| 84 | dprintf(("USER32: GetClipboardData\n"));
|
|---|
| 85 | return O32_GetClipboardData(arg1);
|
|---|
| 86 | }
|
|---|
| 87 | //******************************************************************************
|
|---|
| 88 | //******************************************************************************
|
|---|
| 89 | int WIN32API GetClipboardFormatNameA(UINT format,LPSTR lpszFormatName,int cchMaxCount)
|
|---|
| 90 | {
|
|---|
| 91 | dprintf(("USER32: GetClipboardFormatNameA %d\n",format));
|
|---|
| 92 | return O32_GetClipboardFormatName(format,lpszFormatName,cchMaxCount);
|
|---|
| 93 | }
|
|---|
| 94 | //******************************************************************************
|
|---|
| 95 | //******************************************************************************
|
|---|
| 96 | int WIN32API GetClipboardFormatNameW(UINT format,LPWSTR lpszFormatName,int cchMaxCount)
|
|---|
| 97 | {
|
|---|
| 98 | int rc;
|
|---|
| 99 | char *astring = (CHAR*)malloc(cchMaxCount);
|
|---|
| 100 |
|
|---|
| 101 | dprintf(("USER32: GetClipboardFormatNameW %d\n",format));
|
|---|
| 102 | rc = O32_GetClipboardFormatName(format,astring,cchMaxCount);
|
|---|
| 103 | if (rc) AsciiToUnicode(astring,lpszFormatName);
|
|---|
| 104 | free(astring);
|
|---|
| 105 | return(rc);
|
|---|
| 106 | }
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | //******************************************************************************
|
|---|
| 109 | HWND WIN32API GetClipboardOwner(void)
|
|---|
| 110 | {
|
|---|
| 111 | HWND hwndOwner;
|
|---|
| 112 | Win32BaseWindow *window;
|
|---|
| 113 |
|
|---|
| 114 | dprintf(("USER32: GetClipboardOwner\n"));
|
|---|
| 115 | hwndOwner = O32_GetClipboardOwner();
|
|---|
| 116 |
|
|---|
| 117 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwndOwner);
|
|---|
| 118 | if(!window) {
|
|---|
| 119 | //an OS/2 window probably owns the clipboard, we pretend nobody owns it
|
|---|
| 120 | return NULL;
|
|---|
| 121 | }
|
|---|
| 122 | hwndOwner = window->getWindowHandle();
|
|---|
| 123 | RELEASE_WNDOBJ(window);
|
|---|
| 124 | return hwndOwner;
|
|---|
| 125 | }
|
|---|
| 126 | //******************************************************************************
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | HWND WIN32API GetClipboardViewer(void)
|
|---|
| 129 | {
|
|---|
| 130 | Win32BaseWindow *window;
|
|---|
| 131 | HWND hwndViewer;
|
|---|
| 132 |
|
|---|
| 133 | dprintf(("USER32: GetClipboardViewer\n"));
|
|---|
| 134 | hwndViewer = O32_GetClipboardViewer();
|
|---|
| 135 |
|
|---|
| 136 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwndViewer);
|
|---|
| 137 | if(!window) {
|
|---|
| 138 | //probably an OS/2 window, we pretend it's nobody
|
|---|
| 139 | return NULL;
|
|---|
| 140 | }
|
|---|
| 141 | hwndViewer = window->getWindowHandle();
|
|---|
| 142 | RELEASE_WNDOBJ(window);
|
|---|
| 143 | return hwndViewer;
|
|---|
| 144 | }
|
|---|
| 145 | //******************************************************************************
|
|---|
| 146 | //******************************************************************************
|
|---|
| 147 | HWND WIN32API GetOpenClipboardWindow(void)
|
|---|
| 148 | {
|
|---|
| 149 | Win32BaseWindow *window;
|
|---|
| 150 | HWND hwnd;
|
|---|
| 151 |
|
|---|
| 152 | dprintf(("USER32: GetOpenClipboardWindow\n"));
|
|---|
| 153 | hwnd = O32_GetOpenClipboardWindow();
|
|---|
| 154 |
|
|---|
| 155 | window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
|
|---|
| 156 | if(!window) {
|
|---|
| 157 | //probably an OS/2 window, we pretend it's nobody
|
|---|
| 158 | return NULL;
|
|---|
| 159 | }
|
|---|
| 160 | hwnd = window->getWindowHandle();
|
|---|
| 161 | RELEASE_WNDOBJ(window);
|
|---|
| 162 | return hwnd;
|
|---|
| 163 | }
|
|---|
| 164 | //******************************************************************************
|
|---|
| 165 | //******************************************************************************
|
|---|
| 166 | int WIN32API GetPriorityClipboardFormat( PUINT arg1, int arg2)
|
|---|
| 167 | {
|
|---|
| 168 | dprintf(("USER32: GetPriorityClipboardFormat\n"));
|
|---|
| 169 | return O32_GetPriorityClipboardFormat(arg1, arg2);
|
|---|
| 170 | }
|
|---|
| 171 | //******************************************************************************
|
|---|
| 172 | //******************************************************************************
|
|---|
| 173 | BOOL WIN32API IsClipboardFormatAvailable( UINT arg1)
|
|---|
| 174 | {
|
|---|
| 175 | dprintf(("USER32: IsClipboardFormatAvailable %x", arg1));
|
|---|
| 176 | return O32_IsClipboardFormatAvailable(arg1);
|
|---|
| 177 | }
|
|---|
| 178 | //******************************************************************************
|
|---|
| 179 | //******************************************************************************
|
|---|
| 180 | BOOL WIN32API OpenClipboard( HWND hwnd)
|
|---|
| 181 | {
|
|---|
| 182 | Win32BaseWindow *window;
|
|---|
| 183 |
|
|---|
| 184 | if (hwnd) {
|
|---|
| 185 | window = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 186 | if(!window) {
|
|---|
| 187 | dprintf(("OpenClipboard, window %x not found", hwnd));
|
|---|
| 188 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 189 | return 0;
|
|---|
| 190 | }
|
|---|
| 191 | hwnd = window->getOS2WindowHandle();
|
|---|
| 192 | RELEASE_WNDOBJ(window);
|
|---|
| 193 | }
|
|---|
| 194 | dprintf(("USER32: OpenClipboard %x", hwnd));
|
|---|
| 195 | return O32_OpenClipboard(hwnd);
|
|---|
| 196 | }
|
|---|
| 197 | //******************************************************************************
|
|---|
| 198 | //******************************************************************************
|
|---|
| 199 | UINT WIN32API RegisterClipboardFormatA( LPCSTR arg1)
|
|---|
| 200 | {
|
|---|
| 201 | dprintf(("USER32: RegisterClipboardFormatA %s", arg1));
|
|---|
| 202 | return O32_RegisterClipboardFormat(arg1);
|
|---|
| 203 | }
|
|---|
| 204 | //******************************************************************************
|
|---|
| 205 | //******************************************************************************
|
|---|
| 206 | UINT WIN32API RegisterClipboardFormatW(LPCWSTR arg1)
|
|---|
| 207 | {
|
|---|
| 208 | UINT rc;
|
|---|
| 209 | char *astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 210 |
|
|---|
| 211 | dprintf(("USER32: RegisterClipboardFormatW %s\n", astring));
|
|---|
| 212 | rc = O32_RegisterClipboardFormat(astring);
|
|---|
| 213 | FreeAsciiString(astring);
|
|---|
| 214 | dprintf(("USER32: RegisterClipboardFormatW returned %d\n", rc));
|
|---|
| 215 | return(rc);
|
|---|
| 216 | }
|
|---|
| 217 | //******************************************************************************
|
|---|
| 218 | //******************************************************************************
|
|---|
| 219 | HANDLE WIN32API SetClipboardData( UINT arg1, HANDLE arg2)
|
|---|
| 220 | {
|
|---|
| 221 | dprintf(("USER32: SetClipboardData\n"));
|
|---|
| 222 | return O32_SetClipboardData(arg1, arg2);
|
|---|
| 223 | }
|
|---|
| 224 | //******************************************************************************
|
|---|
| 225 | //******************************************************************************
|
|---|
| 226 | HWND WIN32API SetClipboardViewer( HWND hwndNew)
|
|---|
| 227 | {
|
|---|
| 228 | Win32BaseWindow *wndnew, *wndold;
|
|---|
| 229 | HWND hwndOld;
|
|---|
| 230 | HWND hwndOS2New;
|
|---|
| 231 |
|
|---|
| 232 | wndnew = Win32BaseWindow::GetWindowFromHandle(hwndNew);
|
|---|
| 233 | if(!wndnew) {
|
|---|
| 234 | dprintf(("SetClipboardViewer, window %x not found", hwndNew));
|
|---|
| 235 | SetLastError(ERROR_INVALID_WINDOW_HANDLE);
|
|---|
| 236 | return 0;
|
|---|
| 237 | }
|
|---|
| 238 | dprintf(("USER32: SetClipboardViewer %x", hwndNew));
|
|---|
| 239 | hwndOS2New = wndnew->getOS2WindowHandle();
|
|---|
| 240 | RELEASE_WNDOBJ(wndnew);
|
|---|
| 241 |
|
|---|
| 242 | hwndOld = O32_SetClipboardViewer(hwndOS2New);
|
|---|
| 243 |
|
|---|
| 244 | wndold = Win32BaseWindow::GetWindowFromOS2Handle(hwndOld);
|
|---|
| 245 | if(!wndold) {
|
|---|
| 246 | //probably an OS/2 window, so pretend it's nobody
|
|---|
| 247 | return 0;
|
|---|
| 248 | }
|
|---|
| 249 | hwndOld = wndold->getWindowHandle();
|
|---|
| 250 | RELEASE_WNDOBJ(wndold);
|
|---|
| 251 | return hwndOld;
|
|---|
| 252 | }
|
|---|
| 253 | //******************************************************************************
|
|---|
| 254 | //******************************************************************************
|
|---|