Changeset 1077 for trunk/src/user32/caret.cpp
- Timestamp:
- Sep 28, 1999, 10:00:58 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/caret.cpp
r1071 r1077 1 /* $Id: caret.cpp,v 1. 1 1999-09-27 18:20:00dengert Exp $ */1 /* $Id: caret.cpp,v 1.2 1999-09-28 08:00:56 dengert Exp $ */ 2 2 3 3 /* … … 9 9 10 10 #define INCL_WIN 11 #define INCL_GPI 11 12 #include <os2.h> 12 13 #include <os2sel.h> … … 19 20 #include "oslibwin.h" 20 21 #include "dcdata.h" 22 #include "dc.h" 23 #include "caret.h" 21 24 22 25 #undef SEVERITY_ERROR … … 26 29 #define OPEN32API _System 27 30 #endif 31 32 #pragma data_seg(_GLOBALDATA) 28 33 29 34 static HWND hwndCaret; … … 33 38 static BOOL CaretIsVisible; 34 39 40 #pragma data_seg() 41 42 PVOID APIENTRY GpiQueryDCData (HPS hps); 43 VOID OPEN32API _O32_SetLastError( DWORD ); 44 BOOL OPEN32API _O32_CreateCaret (HWND hwnd, HBITMAP hbm, int width, int height); 45 BOOL APIENTRY _DestroyCaret (void); 46 UINT APIENTRY _GetCaretBlinkTime (void); 47 BOOL APIENTRY _HideCaret (HWND hwnd); 48 BOOL APIENTRY _SetCaretBlinkTime (UINT mSecs); 49 BOOL APIENTRY _ShowCaret (HWND hwnd); 50 35 51 BOOL WIN32API CreateCaret (HWND hwnd, HBITMAP hBmp, int width, int height) 36 52 { 53 dprintf(("USER32: CreateCaret")); 54 37 55 if (hwnd == NULLHANDLE) 38 56 { … … 69 87 USHORT sel = RestoreOS2FS(); 70 88 89 dprintf(("USER32: DestroyCaret")); 90 71 91 hwndCaret = 0; 72 92 hbmCaret = 0; … … 81 101 } 82 102 103 BOOL WIN32API SetCaretBlinkTime (UINT mSecs) 104 { 105 USHORT sel = RestoreOS2FS(); 106 BOOL rc; 107 108 dprintf(("USER32: SetCaretBlinkTime")); 109 110 rc = _SetCaretBlinkTime (mSecs); 111 112 SetFS(sel); 113 return (rc); 114 } 83 115 84 116 UINT WIN32API GetCaretBlinkTime() … … 87 119 USHORT sel = RestoreOS2FS(); 88 120 121 dprintf(("USER32: GetCaretBlinkTime")); 122 89 123 rc = _GetCaretBlinkTime(); 90 124 … … 93 127 } 94 128 129 BOOL WIN32API SetCaretPos (int x, int y) 130 { 131 USHORT sel = RestoreOS2FS(); 132 LONG xNew = 0, yNew = 0; 133 BOOL result = TRUE; 134 BOOL rc; 135 CURSORINFO cursorInfo; 136 POINTL caretPos = { x, y }; 137 138 dprintf(("USER32: SetCaretPos")); 139 140 rc = WinQueryCursorInfo (HWND_DESKTOP, &cursorInfo); 141 if (rc == TRUE) 142 { 143 HWND hwnd = cursorInfo.hwnd; 144 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromOS2Handle (hwnd); 145 if (wnd) 146 { 147 if (wnd->isOwnDC()) 148 { 149 HPS hps = wnd->getOwnDC(); 150 pDCData pHps = (pDCData)GpiQueryDCData(hps); 151 if (!pHps) 152 { 153 _O32_SetLastError (ERROR_INTERNAL_ERROR); 154 SetFS(sel); 155 return FALSE; 156 } 157 GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 1, &caretPos); 158 xNew = caretPos.x; 159 160 if (isYup (pHps)) 161 yNew = caretPos.y; 162 else 163 yNew = caretPos.y - cursorInfo.cy; 164 } 165 else 166 { 167 long height = wnd->getWindowHeight(); 168 caretPos.y = height - caretPos.y - 1; 169 xNew = caretPos.x; 170 yNew = caretPos.y - cursorInfo.cy; 171 } 172 173 hwndCaret = wnd->getWindowHandle(); 174 CaretPosX = x; 175 CaretPosY = y; 176 177 rc = WinCreateCursor (cursorInfo.hwnd, xNew, yNew, 0, 0, CURSOR_SETPOS, NULL); 178 } 179 } 180 if (rc == FALSE) 181 { 182 _O32_SetLastError (ERROR_INVALID_PARAMETER); 183 result = FALSE; 184 } 185 186 SetFS(sel); 187 return (result); 188 } 189 95 190 BOOL WIN32API GetCaretPos (PPOINT pPoint) 96 191 { 97 192 USHORT sel = RestoreOS2FS(); 98 193 CURSORINFO cursorInfo; 194 195 dprintf(("USER32: GetCaretPos")); 99 196 100 197 if (WinQueryCursorInfo (HWND_DESKTOP, &cursorInfo)) … … 102 199 if (cursorInfo.hwnd != HWND_DESKTOP) 103 200 { 104 HPS hps = NULLHANDLE;201 HPS hps = NULLHANDLE; 105 202 HWND hwnd = cursorInfo.hwnd; 106 203 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromOS2Handle (hwnd); … … 115 212 cursorInfo.y = caretPos.y; 116 213 } else { 117 caretPos.y += cursorInfo.cy;118 c onvertDevicePoint( cursorInfo.hwnd, &caretPos, 1);119 cursorInfo.y = caretPos.y;214 long height = wnd->getWindowHeight(); 215 caretPos.y += cursorInfo.cy; 216 cursorInfo.y = height - caretPos.y - 1; 120 217 } 121 218 } … … 133 230 } 134 231 232 BOOL WIN32API ShowCaret (HWND hwnd) 233 { 234 USHORT sel = RestoreOS2FS(); 235 BOOL rc = FALSE; 236 237 dprintf(("USER32: ShowCaret")); 238 239 CaretIsVisible = TRUE; 240 rc = _ShowCaret (Win32BaseWindow::Win32ToOS2Handle (hwnd)); 241 242 SetFS(sel); 243 return (rc); 244 } 245 135 246 BOOL WIN32API HideCaret (HWND hwnd) 136 247 { 137 248 USHORT sel = RestoreOS2FS(); 138 249 BOOL rc = FALSE; 139 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd); 250 251 dprintf(("USER32: HideCaret")); 140 252 141 253 CaretIsVisible = FALSE; 142 143 if (wnd) 144 rc = _HideCaret (wnd->getOS2WindowHandle()); 145 146 SetFS(sel); 147 return (rc); 148 } 149 150 BOOL WIN32API SetCaretBlinkTime (UINT mSecs) 151 { 152 USHORT sel = RestoreOS2FS(); 153 BOOL rc; 154 155 rc = _SetCaretBlinkTime (mSecs); 156 157 SetFS(sel); 158 return (rc); 159 } 160 161 BOOL WIN32API SetCaretPos (int x, int y) 162 { 163 USHORT sel = RestoreOS2FS(); 164 LONG xNew = 0, yNew = 0; 165 BOOL result = TRUE; 166 BOOL rc; 254 rc = _HideCaret (Win32BaseWindow::Win32ToOS2Handle (hwnd)); 255 256 SetFS(sel); 257 return (rc); 258 } 259 260 void recreateCaret (HWND hwndFocus) 261 { 167 262 CURSORINFO cursorInfo; 168 POINTL caretPos = { x, y }; 169 170 rc = WinQueryCursorInfo (HWND_DESKTOP, &cursorInfo); 171 if (rc == TRUE) 172 { 173 HWND hwnd = cursorInfo.hwnd; 174 Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromOS2Handle (hwnd); 175 if (wnd && wnd->isOwnDC()) 176 { 177 HPS hps = wnd->getOwnDC(); 178 pDCData pHps = (pDCData)GpiQueryDCData(hps); 179 if (!pHps) 180 { 181 _O32_SetLastError (ERROR_INTERNAL_ERROR); 182 SetFS(sel); 183 return FALSE; 184 } 185 #if 0 186 convertWinWorldPointToPMDevicePoint (pHps, &caretPos, 1); 187 188 xNew = caretPos.x; 189 190 if (doesYAxisGrowNorth(pHps) == TRUE) 191 { 192 yNew = caretPos.y; 193 } 194 else 195 { 196 yNew = caretPos.y - cursorInfo.cy; 197 } 198 #endif 199 } 200 else 201 { 202 // convertWinDevicePointToPMDevicePoint (cursorInfo.hwnd, &caretPos, 1); 203 xNew = caretPos.x; 204 yNew = caretPos.y - cursorInfo.cy; 205 } 206 207 hwndCaret = wnd->getWindowHandle(); 208 CaretPosX = x; 209 CaretPosY = y; 210 211 rc = WinCreateCursor (cursorInfo.hwnd, xNew, yNew, 0, 0, CURSOR_SETPOS, NULL); 212 } 213 if (rc == FALSE) 214 { 215 _O32_SetLastError (ERROR_INVALID_PARAMETER); 216 result = FALSE; 217 } 218 219 SetFS(sel); 220 return (result); 221 } 222 223 BOOL WIN32API ShowCaret (HWND hwnd) 224 { 225 USHORT sel = RestoreOS2FS(); 226 BOOL rc = FALSE; 227 228 CaretIsVisible = TRUE; 229 rc = _ShowCaret (Win32ToOS2Handle (hwnd)); 230 231 SetFS(sel); 232 return (result); 233 } 234 235 void recreateCaret (HWND hwndFocus) 236 { 237 CURSORINFO cursorInfo; 238 239 if ((hwndCaret == hwndFocus) 240 && !WinQueryCursorInfo (HWND_DESKTOP, &cursorInfo)) 263 264 if ((hwndCaret == hwndFocus) && 265 !WinQueryCursorInfo (HWND_DESKTOP, &cursorInfo)) 241 266 { 242 267 CreateCaret (hwndCaret, hbmCaret, CaretWidth, CaretHeight);
Note:
See TracChangeset
for help on using the changeset viewer.