cursor.cpp

Go to the documentation of this file.
00001 // $Id: cursor.cpp 1709 2006-08-18 14:28:54Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // The Cursor class (platform-dependent implementation).
00099 
00100 /*
00101 */
00102 
00103 
00104 #include "camtypes.h"
00105 
00106 //#include "cursor.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 //#include "ensure.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00108 //#include "oiltool.h"
00109 //#include "resource.h"
00110 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00111 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 #include "camelot.h"
00113 #include "csrstack.h"
00114 #include "cartprov.h"
00115 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "camframe.h"
00117 #include "drawctl.h"
00118 
00119 //#include "hotlink.h"  //For the pointing hand cursor
00120 
00121 DECLARE_SOURCE("$Revision: 1709 $");
00122 
00123 // Memory dump info
00124 CC_IMPLEMENT_MEMDUMP(Cursor, CC_CLASS_MEMDUMP)
00125 #define new CAM_DEBUG_NEW
00126 
00127 
00128 // Pointers to our "built-in" cursors.
00129 Cursor* Cursor::Arrow;                              // the bog-standard pointer
00130 Cursor* Cursor::Busy;                               // the hour-glass
00131 Cursor* Cursor::Insert;                             // the I-beam
00132 Cursor* Cursor::CrossHair;                          // the crosshair
00133 Cursor* Cursor::Progress;                           // special animated percentage counter
00134 Cursor* Cursor::SizeNWSE;                           // resize north-west south-east
00135 
00136 #ifdef RALPH
00137     Cursor* Cursor::PointingHand;                   // Netscape-style pointing hand
00138 #endif
00139 
00140 
00141 
00142 /********************************************************************************************
00143 
00144 >   static BOOL Cursor::Init()
00145 
00146     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00147     Created:    12/11/93
00148     Inputs:     -
00149     Outputs:    -
00150     Returns:    TRUE if initialisation successful.
00151     Purpose:    Loads some standard GUI cursors from the operating system resources.  Only
00152                 three are found on most platforms - the arrow, the hour-glass, and the
00153                 insertion beam.
00154     Errors:     -
00155     SeeAlso:    Cursor::DeInit; CursorStack::Init
00156 
00157 ********************************************************************************************/
00158 
00159 BOOL Cursor::Init()
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 }
00186 
00187 
00188 
00189 
00190 /********************************************************************************************
00191 
00192 >   static void Cursor::DeInit()
00193 
00194     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00195     Created:    12/11/93
00196     Inputs:     -
00197     Outputs:    -
00198     Returns:    -
00199     Purpose:    Deallocates the Cursor objects created by Init().
00200     Errors:     -
00201     SeeAlso:    Cursor::Init; CursorStack::DeInit
00202 
00203 ********************************************************************************************/
00204 
00205 void Cursor::DeInit()
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 }
00221 
00222 
00223 
00224 
00225 /********************************************************************************************
00226 
00227 >   Cursor::Cursor(LPCSTR lpStdCsrName)
00228 
00229     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00230     Created:    11/11/93
00231     Inputs:     The (string) identifier of a standard Windows cursor, eg. _R(IDC_WAIT).
00232     Outputs:    -
00233     Returns:    -
00234     Purpose:    Loads a standard cursor from the operting system's resources.
00235     Errors:     Will trap in debugging version if the load fails.
00236     SeeAlso:    -
00237 
00238 ********************************************************************************************/
00239 
00240 Cursor::Cursor(LPCSTR lpStdCsrName)
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 }
00271 
00272 
00273 
00274 
00275 /********************************************************************************************
00276 
00277 >   Cursor::Cursor(UINT32 wCsrID)
00278 
00279     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00280     Created:    17/11/93
00281     Inputs:     The numeric identifier of the cursor in the kernel's resources.
00282     Outputs:    -
00283     Returns:    -
00284     Purpose:    Loads the specified cursor from the kernel's application module.
00285     Errors:     ENSURE failure if the cursor can't be loaded.
00286     SeeAlso:    -
00287 
00288 ********************************************************************************************/
00289 
00290 Cursor::Cursor(UINT32 wCsrID)
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 }
00336 
00337 
00338 
00339 
00340 /********************************************************************************************
00341 
00342 >   Cursor::Cursor(Tool* pTool, UINT32 wCsrID)
00343 
00344     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00345     Created:    11/11/93
00346     Inputs:     A pointer to the tool associated with the desired cursor and the numeric
00347                 resource identifier of the particular cursor.
00348     Outputs:    -
00349     Returns:    -
00350     Purpose:    Loads the specified cursor from the specified tool.
00351     Errors:     In the debugging version traps a failure to load.
00352     SeeAlso:    -
00353 
00354 ********************************************************************************************/
00355 
00356 Cursor::Cursor(Tool_v1*, UINT32 wCsrID)
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 }
00371 
00372 
00373 
00374 
00375 /********************************************************************************************
00376 
00377 >   Cursor::Cursor(UINT32 wToolID, UINT32 wCsrID)
00378 
00379     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00380     Created:    11/11/93
00381     Inputs:     The ID of the tool associated with the desired cursor and the numeric
00382                 resource identifier of the particular cursor.
00383     Outputs:    -
00384     Returns:    -
00385     Purpose:    Loads the specified cursor from the specified tool.
00386     Errors:     In the debugging version traps a failure to load.
00387     SeeAlso:    -
00388 
00389 ********************************************************************************************/
00390 
00391 Cursor::Cursor(UINT32 wToolID, UINT32 wCsrID)
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 }
00429 
00430 
00431 
00432 
00433 /********************************************************************************************
00434 
00435 >   Cursor::Cursor(CBitmap* pbmpAND, CBitmap* pbmpXOR)
00436 
00437     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00438     Created:    11/11/93
00439     Inputs:     Two pointers to the bitmaps which are used as masks when creating the
00440                 cursor.
00441     Outputs:    -
00442     Returns:    -
00443     Purpose:    Creates a cursor from two bitmap masks (AND & XOR).  See the Windows
00444                 SDK documentation for the CreateCursor() function to understand how
00445                 this is done.
00446     Errors:     Checks that the bitmaps are of the same size as cursors.
00447     SeeAlso:    -
00448 
00449 ********************************************************************************************/
00450 
00451 Cursor::Cursor(wxBitmap* pbmpAND, wxBitmap* pbmpXOR)
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 }
00505 
00506 
00507 
00508 
00509 /********************************************************************************************
00510 
00511 >   virtual Cursor::~Cursor()
00512 
00513     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00514     Created:    11/11/93
00515     Inputs:     -
00516     Outputs:    -
00517     Returns:    -
00518     Purpose:    Destroys a cursor (if necessary).
00519     Errors:     -
00520     SeeAlso:    -
00521 
00522 ********************************************************************************************/
00523 
00524 Cursor::~Cursor()
00525 {
00526 //  if (hCursor != 0 && bMustDestroy) ::DestroyCursor(hCursor);
00527 }
00528 
00529 
00530 
00531 
00532 /********************************************************************************************
00533 
00534 >   BOOL Cursor::IsValid() const
00535 
00536     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00537     Created:    11/11/93
00538     Inputs:     -
00539     Outputs:    -
00540     Returns:    TRUE if the Cursor object was successfully loaded/created.
00541     Purpose:    Tests that this object was constructed without any errors.
00542     Errors:     -
00543     SeeAlso:    -
00544 
00545 ********************************************************************************************/
00546 
00547 BOOL Cursor::IsValid() const
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 }
00556 
00557 
00558 
00559 
00560 /********************************************************************************************
00561 
00562 >   void Cursor::SetActive() const
00563 
00564     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00565     Created:    11/11/93
00566     Inputs:     -
00567     Outputs:    -
00568     Returns:    -
00569     Purpose:    Makes this Cursor object the active operating system cursor.
00570     Errors:     If the cursor could not be loaded or created, this call does nothing.
00571     SeeAlso:    Cursor::Show; Cursor::Hide
00572 
00573 ********************************************************************************************/
00574 
00575 void Cursor::SetActive( bool fOnlyRendWnd /*= true*/ ) const
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 }
00629 
00630 
00631 
00632 
00633 /********************************************************************************************
00634 
00635 >   static BOOL Cursor::Show()
00636 
00637     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00638     Created:    11/11/93
00639     Inputs:     -
00640     Outputs:    -
00641     Returns:    TRUE if the cursor is visible after this function call.
00642     Purpose:    Increments the cursor's semaphore, generally making the cursor visible.
00643     Errors:     -
00644     SeeAlso:    Cursor::Hide
00645 
00646 ********************************************************************************************/
00647 
00648 BOOL Cursor::Show()
00649 {
00650 //  return ::ShowCursor(TRUE) >= 0;
00651     SetActive();
00652     return true;
00653 }
00654 
00655 
00656 
00657 
00658 /********************************************************************************************
00659 
00660 >   static BOOL Cursor::Hide()
00661 
00662     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00663     Created:    11/11/93
00664     Inputs:     -
00665     Outputs:    -
00666     Returns:    TRUE if the cursor is no longer visible.
00667     Purpose:    Decrements the cursor's semaphore, generally making the cursor invisible.
00668     Errors:     -
00669     SeeAlso:    Cursor::Show
00670 
00671 ********************************************************************************************/
00672 
00673 BOOL Cursor::Hide()
00674 {
00675 //  return ::ShowCursor(FALSE) < 0;
00676     ::wxSetCursor(wxNullCursor);
00677     return true;
00678 }
00679 
00680 
00681 
00682 
00683 /********************************************************************************************
00684 
00685 >   static INT32 Cursor::Width()
00686 
00687     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00688     Created:    11/11/93
00689     Inputs:     -
00690     Outputs:    -
00691     Returns:    The width of a cursor, in pixels, for this system & video mode.
00692     Purpose:    (see above)
00693     Errors:     -
00694     SeeAlso:    Cursor::Height
00695 
00696 ********************************************************************************************/
00697 
00698 INT32 Cursor::Width()
00699 {
00700     return wxSystemSettings::GetMetric( wxSYS_CURSOR_X );
00701 }
00702 
00703 
00704 
00705 
00706 /********************************************************************************************
00707 
00708 >   static INT32 Cursor::Height()
00709 
00710     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00711     Created:    11/11/93
00712     Inputs:     -
00713     Outputs:    -
00714     Returns:    The height of a cursor, in pixels, for this system & video mode.
00715     Purpose:    (see above)
00716     Errors:     -
00717     SeeAlso:    -
00718 
00719 ********************************************************************************************/
00720 
00721 INT32 Cursor::Height()
00722 {
00723     return wxSystemSettings::GetMetric( wxSYS_CURSOR_Y );
00724 }

Generated on Sat Nov 10 03:48:19 2007 for Camelot by  doxygen 1.4.4