toolbar.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/toolbar.h
  3. // Purpose: wxToolBar
  4. // Author: David Elliott
  5. // Modified by:
  6. // Created: 2003/08/17
  7. // Copyright: (c) 2003 David Elliott
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef __WX_COCOA_TOOLBAR_H__
  11. #define __WX_COCOA_TOOLBAR_H__
  12. #if wxUSE_TOOLBAR
  13. // ========================================================================
  14. // wxToolBar
  15. // ========================================================================
  16. #if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64)
  17. typedef struct CGPoint NSPoint;
  18. #else
  19. typedef struct _NSPoint NSPoint;
  20. #endif
  21. class wxToolBarTool;
  22. class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase
  23. {
  24. DECLARE_DYNAMIC_CLASS(wxToolBar)
  25. // ------------------------------------------------------------------------
  26. // initialization
  27. // ------------------------------------------------------------------------
  28. public:
  29. wxToolBar() { Init(); }
  30. wxToolBar( wxWindow *parent,
  31. wxWindowID toolid,
  32. const wxPoint& pos = wxDefaultPosition,
  33. const wxSize& size = wxDefaultSize,
  34. long style = 0,
  35. const wxString& name = wxToolBarNameStr )
  36. {
  37. Init();
  38. Create(parent, toolid, pos, size, style, name);
  39. }
  40. bool Create( wxWindow *parent,
  41. wxWindowID toolid,
  42. const wxPoint& pos = wxDefaultPosition,
  43. const wxSize& size = wxDefaultSize,
  44. long style = 0,
  45. const wxString& name = wxToolBarNameStr );
  46. virtual ~wxToolBar();
  47. protected:
  48. // common part of all ctors
  49. void Init();
  50. // ------------------------------------------------------------------------
  51. // Cocoa
  52. // ------------------------------------------------------------------------
  53. protected:
  54. virtual bool Cocoa_acceptsFirstMouse(bool &acceptsFirstMouse, WX_NSEvent theEvent);
  55. virtual bool Cocoa_drawRect(const NSRect &rect);
  56. virtual bool Cocoa_mouseDown(WX_NSEvent theEvent);
  57. virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent);
  58. wxToolBarTool *CocoaFindToolForPosition(const NSPoint& pos) const;
  59. void CocoaToolClickEnded();
  60. // ------------------------------------------------------------------------
  61. // Implementation
  62. // ------------------------------------------------------------------------
  63. public:
  64. // override base class virtuals
  65. virtual void SetMargins(int x, int y);
  66. virtual void SetToolSeparation(int separation);
  67. virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
  68. virtual void SetToolShortHelp(int toolid, const wxString& helpString);
  69. virtual void SetWindowStyleFlag( long style );
  70. // implementation from now on
  71. // --------------------------
  72. void OnInternalIdle();
  73. virtual bool Realize();
  74. virtual wxSize DoGetBestSize() const;
  75. void SetOwningFrame(wxFrame *owningFrame)
  76. { m_owningFrame = owningFrame; }
  77. protected:
  78. // implement base class pure virtuals
  79. virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
  80. virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
  81. virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
  82. virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
  83. virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
  84. virtual wxToolBarToolBase *CreateTool(int toolid,
  85. const wxString& label,
  86. const wxBitmap& bitmap1,
  87. const wxBitmap& bitmap2,
  88. wxItemKind kind,
  89. wxObject *clientData,
  90. const wxString& shortHelpString,
  91. const wxString& longHelpString);
  92. virtual wxToolBarToolBase *CreateTool(wxControl *control,
  93. const wxString& label);
  94. wxSize m_bestSize;
  95. wxFrame *m_owningFrame;
  96. wxToolBarTool *m_mouseDownTool;
  97. };
  98. #endif // wxUSE_TOOLBAR
  99. #endif // __WX_COCOA_TOOLBAR_H__