cursor.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cursor.h
  3. // Purpose: wxCursor base header
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created:
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows Licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CURSOR_H_BASE_
  11. #define _WX_CURSOR_H_BASE_
  12. #include "wx/defs.h"
  13. /*
  14. wxCursor classes should have the following public API:
  15. class WXDLLIMPEXP_CORE wxCursor : public wxGDIObject
  16. {
  17. public:
  18. wxCursor();
  19. wxCursor(const wxImage& image);
  20. wxCursor(const wxString& name,
  21. wxBitmapType type = wxCURSOR_DEFAULT_TYPE,
  22. int hotSpotX = 0, int hotSpotY = 0);
  23. wxCursor(wxStockCursor id) { InitFromStock(id); }
  24. #if WXWIN_COMPATIBILITY_2_8
  25. wxCursor(int id) { InitFromStock((wxStockCursor)id); }
  26. #endif
  27. virtual ~wxCursor();
  28. };
  29. */
  30. #if defined(__WXMSW__)
  31. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
  32. #include "wx/msw/cursor.h"
  33. #elif defined(__WXMOTIF__)
  34. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XBM
  35. #include "wx/motif/cursor.h"
  36. #elif defined(__WXGTK20__)
  37. #ifdef __WINDOWS__
  38. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
  39. #else
  40. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
  41. #endif
  42. #include "wx/gtk/cursor.h"
  43. #elif defined(__WXGTK__)
  44. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
  45. #include "wx/gtk1/cursor.h"
  46. #elif defined(__WXX11__)
  47. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_XPM
  48. #include "wx/x11/cursor.h"
  49. #elif defined(__WXDFB__)
  50. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
  51. #include "wx/dfb/cursor.h"
  52. #elif defined(__WXMAC__)
  53. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE
  54. #include "wx/osx/cursor.h"
  55. #elif defined(__WXCOCOA__)
  56. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_MACCURSOR_RESOURCE
  57. #include "wx/cocoa/cursor.h"
  58. #elif defined(__WXPM__)
  59. #define wxCURSOR_DEFAULT_TYPE wxBITMAP_TYPE_CUR_RESOURCE
  60. #include "wx/os2/cursor.h"
  61. #endif
  62. #include "wx/utils.h"
  63. /* This is a small class which can be used by all ports
  64. to temporarily suspend the busy cursor. Useful in modal
  65. dialogs.
  66. Actually that is not (any longer) quite true.. currently it is
  67. only used in wxGTK Dialog::ShowModal() and now uses static
  68. wxBusyCursor methods that are only implemented for wxGTK so far.
  69. The BusyCursor handling code should probably be implemented in
  70. common code somewhere instead of the separate implementations we
  71. currently have. Also the name BusyCursorSuspender is a little
  72. misleading since it doesn't actually suspend the BusyCursor, just
  73. masks one that is already showing.
  74. If another call to wxBeginBusyCursor is made while this is active
  75. the Busy Cursor will again be shown. But at least now it doesn't
  76. interfere with the state of wxIsBusy() -- RL
  77. */
  78. class wxBusyCursorSuspender
  79. {
  80. public:
  81. wxBusyCursorSuspender()
  82. {
  83. if( wxIsBusy() )
  84. {
  85. wxSetCursor( wxBusyCursor::GetStoredCursor() );
  86. }
  87. }
  88. ~wxBusyCursorSuspender()
  89. {
  90. if( wxIsBusy() )
  91. {
  92. wxSetCursor( wxBusyCursor::GetBusyCursor() );
  93. }
  94. }
  95. };
  96. #endif
  97. // _WX_CURSOR_H_BASE_