#include <cursor.h>
Public Member Functions | |
Cursor (LPCSTR lpStdCsrName) | |
Loads a standard cursor from the operting system's resources. | |
Cursor (UINT32 wCsrID) | |
Loads the specified cursor from the kernel's application module. | |
Cursor (Tool_v1 *pTool, UINT32 wCsrID) | |
Loads the specified cursor from the specified tool. | |
Cursor (UINT32 wToolID, UINT32 wCsrID) | |
Loads the specified cursor from the specified tool. | |
Cursor (wxBitmap *pbmpAND, wxBitmap *pbmpXOR) | |
Creates a cursor from two bitmap masks (AND & XOR). See the Windows SDK documentation for the CreateCursor() function to understand how this is done. | |
virtual | ~Cursor () |
Destroys a cursor (if necessary). | |
BOOL | IsValid () const |
Tests that this object was constructed without any errors. | |
void | SetActive (bool fOnlyRendWnd=false) const |
Makes this Cursor object the active operating system cursor. | |
wxCursor * | Handle () |
BOOL | Show () |
Increments the cursor's semaphore, generally making the cursor visible. | |
BOOL | Hide () |
Decrements the cursor's semaphore, generally making the cursor invisible. | |
Static Public Member Functions | |
static BOOL | Init () |
Loads some standard GUI cursors from the operating system resources. Only three are found on most platforms - the arrow, the hour-glass, and the insertion beam. | |
static void | DeInit () |
Deallocates the Cursor objects created by Init(). | |
static INT32 | Width () |
(see above) | |
static INT32 | Height () |
(see above) | |
Static Public Attributes | |
static Cursor * | Arrow |
static Cursor * | Busy |
static Cursor * | Insert |
static Cursor * | CrossHair |
static Cursor * | Progress |
static Cursor * | PointingHand |
static Cursor * | SizeNWSE |
Private Member Functions | |
CC_DECLARE_MEMDUMP (Cursor) | |
Private Attributes | |
wxCursor | hCursor |
BOOL | bMustDestroy |
Definition at line 117 of file cursor.h.
|
Loads a standard cursor from the operting system's resources.
Definition at line 240 of file cursor.cpp. 00241 : hCursor(0), bMustDestroy(FALSE) // we must not try to destroy standard cursors! 00242 { 00243 PORTNOTETRACE("other","Cursor::Cursor(LPCSTR) - do nothing"); 00244 // Try to load the cursor (it is likely to be loaded already). 00245 // hCursor = wxCursor(lpStdCsrName); 00246 00247 /* hCursor = AfxGetApp()->LoadStandardCursor(lpStdCsrName); 00248 if (hCursor == 0) 00249 { 00250 if (IsWin32c() && lpStdCsrName == _R(IDC_SIZE)) 00251 { 00252 // ChicagoBodge 00253 // when marked as a 4.0 .exe it is unable to load _R(IDC_SIZE) or _R(IDC_ICON) resources, so we fall 00254 // back to _R(IDC_SIZEALL) 00255 hCursor = AfxGetApp()->LoadStandardCursor( _R(IDC_SIZEALL) ); 00256 } 00257 00258 #ifdef RALPH 00259 if(hCursor == 0) 00260 { 00261 TRACEUSER( "JustinF", _T("Cursor '%s' not found\n"), lpStdCsrName); 00262 hCursor = AfxGetApp()->LoadStandardCursor(_R(IDC_CROSS)); 00263 } 00264 #endif 00265 00266 if (hCursor == 0) 00267 ERROR3_PF(("Failed to load standard cursor %u", (INT32) LOWORD(lpStdCsrName))); 00268 } 00269 */ 00270 }
|
|
Loads the specified cursor from the kernel's application module.
Definition at line 290 of file cursor.cpp. 00291 : bMustDestroy(FALSE) 00292 { 00293 if (wCsrID > 0 && wCsrID <= wxCURSOR_MAX) 00294 { 00295 // Simply set the standard wxCursor 00296 hCursor = wxCursor(wCsrID); 00297 } 00298 else 00299 { 00300 wxImage *pImage = (CamArtProvider::Get())->FindImage( wCsrID ); 00301 ENSURE( NULL != pImage, "Failed to find cursor in Cursor::Cursor!\n"); 00302 00303 if (NULL == pImage) 00304 { 00305 hCursor = wxCursor(wxCURSOR_CROSS); 00306 return; 00307 } 00308 00309 // Try to load the specified cursor from the OILTool's module. 00310 hCursor = wxCursor(*pImage); 00311 } 00312 00313 // // Check that the resource ID is valid for a kernel resource. 00314 // 00315 // We no longer do this, as we are now using some non-system cursors which have 00316 // IDs outside this range. 00317 // 00318 // ENSURE(wCsrID >= KID_FIRST && wCsrID <= KID_LAST, 00319 // "Kernel cursor has out-of-range resource ID!\n"); 00320 00321 // Load from the application's global (ie. kernel) resources. 00322 // hCursor = wxCursor(wCsrID); 00323 /* 00324 hCursor = ::LoadCursor(AfxGetResourceHandle(), MAKEINTRESOURCE(wCsrID)); 00325 00326 #ifdef RALPH 00327 if(hCursor == 0) 00328 { 00329 TRACEUSER( "JustinF", _T("Cursor '%d' not found 2\n"), wCsrID); 00330 hCursor = AfxGetApp()->LoadStandardCursor(_R(IDC_CROSS)); 00331 } 00332 #endif 00333 */ 00334 // ENSURE(hCursor != 0, "Failed to load a kernel cursor in Cursor::Cursor!\n"); 00335 }
|
|
Loads the specified cursor from the specified tool.
Definition at line 356 of file cursor.cpp. 00357 : bMustDestroy(FALSE) 00358 { 00359 wxImage *pImage = (CamArtProvider::Get())->FindImage( wCsrID ); 00360 ENSURE( NULL != pImage, "Failed to find cursor in Cursor::Cursor!\n"); 00361 00362 if( NULL == pImage ) 00363 { 00364 hCursor = wxCursor( wxCURSOR_CROSS ); 00365 return; 00366 } 00367 00368 // Try to load the specified cursor from the OILTool's module. 00369 hCursor = wxCursor( *pImage ); 00370 }
|
|
Loads the specified cursor from the specified tool.
Definition at line 391 of file cursor.cpp. 00392 : hCursor(wxCURSOR_ARROW), bMustDestroy(FALSE) 00393 { 00394 wxImage *pImage = (CamArtProvider::Get())->FindImage( wCsrID ); 00395 ENSURE( NULL != pImage, "Failed to find cursor in Cursor::Cursor!\n"); 00396 00397 if( NULL == pImage ) 00398 { 00399 hCursor = wxCursor( wxCURSOR_CROSS ); 00400 return; 00401 } 00402 00403 // Try to load the specified cursor from the OILTool's module. 00404 hCursor = wxCursor( *pImage ); 00405 00406 // PORTNOTETRACE("other","Cursor::Cursor - do nothing"); 00407 #ifndef EXCLUDE_FROM_XARALX 00408 // Check that the resource ID is in the valid range for tools. 00409 /* ENSURE(wCsrID < KID_FIRST || wCsrID > KID_LAST, 00410 "Tool cursor has out-of-range resource ID!\n");*/ 00411 // Find the OILTool object associated with this tool. 00412 OILTool* ptOil = Tool::GetOILTool(wToolID); 00413 ENSURE(ptOil != 0, "Failed to find OIL tool in Cursor::Cursor!\n"); 00414 00415 // Try to load the specified cursor from the OILTool's module. 00416 hCursor = ptOil->LoadCursor(wCsrID); 00417 00418 #ifdef RALPH 00419 if(hCursor == 0) 00420 { 00421 TRACEUSER( "Richard", _T("Cursor '%d' not found 4\n"), wCsrID); 00422 hCursor = AfxGetApp()->LoadStandardCursor(_R(IDC_CROSS)); 00423 } 00424 #endif 00425 00426 ENSURE(hCursor != 0, "Failed to load a tool's cursor in Cursor::Cursor!\n"); 00427 #endif 00428 }
|
|
Creates a cursor from two bitmap masks (AND & XOR). See the Windows SDK documentation for the CreateCursor() function to understand how this is done.
Definition at line 451 of file cursor.cpp. 00452 : hCursor(0), bMustDestroy(TRUE) // destroy any cursor we create 00453 { 00454 PORTNOTETRACE("other","Cursor::Cursor(wxBitmap*, wxBitmap*) - do nothing"); 00455 #ifndef EXCLUDE_FROM_XARALX 00456 // Make the cursor from the bitmaps. The bitmaps must be of the correct size. 00457 BITMAP andInfo; 00458 pbmpAND->GetObject(sizeof(BITMAP), &andInfo); 00459 00460 // In the debug version make this check for both parameters. 00461 INT32 w = Width(); 00462 INT32 h = Height(); 00463 00464 #ifdef _DEBUG 00465 BITMAP xorInfo; 00466 pbmpXOR->GetObject(sizeof(BITMAP), &xorInfo); 00467 ENSURE((andInfo.bmWidth == w) && (andInfo.bmHeight == h) && 00468 (xorInfo.bmWidth == w) && (xorInfo.bmHeight == h), 00469 "Mask bitmaps are not cursor-sized in Cursor::Cursor!\n"); 00470 #endif // _DEBUG 00471 00472 // Copy the pixel data of the two masks into buffers allocated on the heap. 00473 size_t dwSize = andInfo.bmWidthBytes * andInfo.bmHeight; 00474 LPWORD lpwAndBits = new WORD[dwSize / 2 + 1]; 00475 LPWORD lpwXorBits = new WORD[dwSize / 2 + 1]; 00476 if (!lpwAndBits || 00477 !lpwXorBits || 00478 !pbmpAND->GetBitmapBits(dwSize, lpwAndBits) || 00479 !pbmpXOR->GetBitmapBits(dwSize, lpwXorBits)) 00480 { 00481 #ifdef _DEBUG 00482 if (IsUserName("JustinF")) 00483 TRACE( _T("Failed to allocate heap space for mask buffers in Cursor::Cursor!\n")); 00484 #endif // _DEBUG 00485 00486 delete[] lpwAndBits; 00487 delete[] lpwXorBits; 00488 return; 00489 } 00490 00491 // Now make the cursor. 00492 hCursor = ::CreateCursor(AfxGetApp()->m_hInstance, 00493 w / 2, h / 2, w, h, 00494 lpwAndBits, lpwXorBits); 00495 #ifdef _DEBUG 00496 if (hCursor == 0 && IsUserName("JustinF")) 00497 TRACE( _T("Failed to create cursor in Cursor::Cursor!\n")); 00498 #endif // _DEBUG 00499 00500 // Finally, deallocate all resources. 00501 delete[] lpwAndBits; 00502 delete[] lpwXorBits; 00503 #endif 00504 }
|
|
Destroys a cursor (if necessary).
Definition at line 524 of file cursor.cpp.
|
|
|
|
Deallocates the Cursor objects created by Init().
Definition at line 205 of file cursor.cpp. 00206 { 00207 delete Arrow; 00208 delete Busy; 00209 delete Insert; 00210 delete CrossHair; 00211 delete SizeNWSE; 00212 00213 Arrow = Busy = Insert = CrossHair = SizeNWSE = 0; 00214 00215 #ifdef RALPH 00216 delete PointingHand; 00217 PointingHand = 0; 00218 #endif 00219 00220 }
|
|
Definition at line 141 of file cursor.h. 00141 {return &hCursor;} // returns the (wxWindows) handle of the cursor
|
|
(see above)
Definition at line 721 of file cursor.cpp.
|
|
Decrements the cursor's semaphore, generally making the cursor invisible.
Definition at line 673 of file cursor.cpp. 00674 { 00675 // return ::ShowCursor(FALSE) < 0; 00676 ::wxSetCursor(wxNullCursor); 00677 return true; 00678 }
|
|
Loads some standard GUI cursors from the operating system resources. Only three are found on most platforms - the arrow, the hour-glass, and the insertion beam.
Definition at line 159 of file cursor.cpp. 00160 { 00161 Arrow = new Cursor( wxCURSOR_ARROW ); 00162 Busy = new Cursor( wxCURSOR_WAIT ); 00163 Insert = new Cursor( wxCURSOR_IBEAM ); 00164 CrossHair = new Cursor( wxCURSOR_CROSS ); 00165 SizeNWSE = new Cursor( wxCURSOR_SIZENWSE ); 00166 Progress = 0; 00167 00168 #ifdef RALPH 00169 //Graham 6/9/96: This is used in Ralph's No Tool mode. The No Tool mode is 00170 //implemented in DocView, but we can't initiate a cursor there, because we end up 00171 //creating a new cursor every time a new view is created. 00172 PointingHand = new Cursor(_R(IDC_POINTINGHANDCURSOR)); 00173 #endif //RALPH 00174 00175 return Arrow != 0 00176 && Busy != 0 00177 && Insert != 0 00178 && CrossHair != 0 00179 && SizeNWSE != 0 00180 && Arrow->IsValid() 00181 && Busy->IsValid() 00182 && Insert->IsValid() 00183 && CrossHair->IsValid() 00184 && SizeNWSE->IsValid(); 00185 }
|
|
Tests that this object was constructed without any errors.
Definition at line 547 of file cursor.cpp. 00548 { 00549 PORTNOTETRACE( "other", "Cursor::IsValid - pretend cursor is valid even though not supported" ); 00550 #ifndef EXCLUDE_FROM_XARALX 00551 return !hCursor.IsNull(); 00552 #else 00553 return true; 00554 #endif 00555 }
|
|
Makes this Cursor object the active operating system cursor.
Definition at line 575 of file cursor.cpp. 00576 { 00577 // If we have captured the mouse then release it 00578 wxWindow* pCaptureWnd = wxWindow::GetCapture(); 00579 if (pCaptureWnd) 00580 pCaptureWnd->ReleaseMouse(); 00581 00582 // Set the global cursor (but only if we have a Render window to 00583 // control its scope). Also make sure we're in the Render window, 00584 // this stops the cursor being hijacked when we pop. 00585 wxWindow* pRenderWnd = DocView::GetCurrentRenderWindow(); 00586 wxPoint ptDontCare; 00587 wxWindow* pWndAtPtr = wxFindWindowAtPointer( ptDontCare ); 00588 if( NULL != pRenderWnd ) 00589 { 00590 bool fDrawCtrl = NULL != pWndAtPtr ? pWndAtPtr->IsKindOf( CLASSINFO(wxCamDrawControl) ) : false; 00591 if( !fOnlyRendWnd || fDrawCtrl || pWndAtPtr == pRenderWnd ) 00592 wxSetCursor(hCursor); 00593 else 00594 wxSetCursor( *wxSTANDARD_CURSOR ); 00595 } 00596 00597 // If we have a RenderWindow and it doesn't have the capture then set its cursor 00598 if( pRenderWnd != NULL && pCaptureWnd != pRenderWnd) 00599 pRenderWnd->SetCursor(hCursor); 00600 00601 // If we did have the capture 00602 if (pCaptureWnd) 00603 { 00604 // Set the cursor on the relevant window and recapture the mouse 00605 pCaptureWnd->SetCursor(hCursor); 00606 pCaptureWnd->CaptureMouse(); 00607 } 00608 00609 #if FALSE // Phil's version 00610 // This works around various problems concerning cursor shape changing while the mouse is captured by gdk_pointer_grab 00611 // Note1: At the time of writing wxWindow::DoCaptureMouse won't use the global cursor if the local one is unset so we need to set both versions 00612 // Note2: At the time of writing gdk_pointer_grab seems to prevent cursor changes 00613 CNativeWnd* pRenderWnd = DocView::GetCurrentRenderWindow(); 00614 if (pRenderWnd && pRenderWnd->HasCapture()) 00615 { 00616 pRenderWnd->ReleaseMouse(); 00617 wxSetCursor(hCursor); 00618 pRenderWnd->SetCursor(hCursor); 00619 pRenderWnd->CaptureMouse(); 00620 } 00621 else 00622 { 00623 wxSetCursor(hCursor); 00624 if (pRenderWnd) 00625 pRenderWnd->SetCursor(hCursor); 00626 } 00627 #endif 00628 }
|
|
Increments the cursor's semaphore, generally making the cursor visible.
Definition at line 648 of file cursor.cpp. 00649 { 00650 // return ::ShowCursor(TRUE) >= 0; 00651 SetActive(); 00652 return true; 00653 }
|
|
(see above)
Definition at line 698 of file cursor.cpp.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|