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 11 #ifndef __WX_COCOA_TOOLBAR_H__ 12 #define __WX_COCOA_TOOLBAR_H__ 13 14 #if wxUSE_TOOLBAR 15 16 // ======================================================================== 17 // wxToolBar 18 // ======================================================================== 19 #if defined(__LP64__) || defined(NS_BUILD_32_LIKE_64) 20 typedef struct CGPoint NSPoint; 21 #else 22 typedef struct _NSPoint NSPoint; 23 #endif 24 25 class wxToolBarTool; 26 27 class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase 28 { DECLARE_DYNAMIC_CLASS(wxToolBar)29 DECLARE_DYNAMIC_CLASS(wxToolBar) 30 // ------------------------------------------------------------------------ 31 // initialization 32 // ------------------------------------------------------------------------ 33 public: 34 wxToolBar() { Init(); } 35 wxToolBar( wxWindow *parent, 36 wxWindowID toolid, 37 const wxPoint& pos = wxDefaultPosition, 38 const wxSize& size = wxDefaultSize, 39 long style = 0, 40 const wxString& name = wxToolBarNameStr ) 41 { 42 Init(); 43 44 Create(parent, toolid, pos, size, style, name); 45 } 46 47 bool Create( wxWindow *parent, 48 wxWindowID toolid, 49 const wxPoint& pos = wxDefaultPosition, 50 const wxSize& size = wxDefaultSize, 51 long style = 0, 52 const wxString& name = wxToolBarNameStr ); 53 54 virtual ~wxToolBar(); 55 56 protected: 57 // common part of all ctors 58 void Init(); 59 60 // ------------------------------------------------------------------------ 61 // Cocoa 62 // ------------------------------------------------------------------------ 63 protected: 64 virtual bool Cocoa_acceptsFirstMouse(bool &acceptsFirstMouse, WX_NSEvent theEvent); 65 virtual bool Cocoa_drawRect(const NSRect &rect); 66 virtual bool Cocoa_mouseDown(WX_NSEvent theEvent); 67 virtual bool Cocoa_mouseDragged(WX_NSEvent theEvent); 68 wxToolBarTool *CocoaFindToolForPosition(const NSPoint& pos) const; 69 void CocoaToolClickEnded(); 70 // ------------------------------------------------------------------------ 71 // Implementation 72 // ------------------------------------------------------------------------ 73 public: 74 // override base class virtuals 75 virtual void SetMargins(int x, int y); 76 virtual void SetToolSeparation(int separation); 77 78 virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; 79 80 virtual void SetToolShortHelp(int toolid, const wxString& helpString); 81 82 virtual void SetWindowStyleFlag( long style ); 83 84 // implementation from now on 85 // -------------------------- 86 87 void OnInternalIdle(); 88 virtual bool Realize(); 89 virtual wxSize DoGetBestSize() const; 90 SetOwningFrame(wxFrame * owningFrame)91 void SetOwningFrame(wxFrame *owningFrame) 92 { m_owningFrame = owningFrame; } 93 protected: 94 // implement base class pure virtuals 95 virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); 96 virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); 97 98 virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); 99 virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); 100 virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); 101 102 virtual wxToolBarToolBase *CreateTool(int toolid, 103 const wxString& label, 104 const wxBitmap& bitmap1, 105 const wxBitmap& bitmap2, 106 wxItemKind kind, 107 wxObject *clientData, 108 const wxString& shortHelpString, 109 const wxString& longHelpString); 110 virtual wxToolBarToolBase *CreateTool(wxControl *control, 111 const wxString& label); 112 113 wxSize m_bestSize; 114 wxFrame *m_owningFrame; 115 wxToolBarTool *m_mouseDownTool; 116 }; 117 118 #endif // wxUSE_TOOLBAR 119 120 #endif // __WX_COCOA_TOOLBAR_H__ 121