toolbar.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/toolbar.h
  3. // Purpose: wxToolBar class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_TOOLBAR_H_
  11. #define _WX_TOOLBAR_H_
  12. #if wxUSE_TOOLBAR
  13. #include "wx/tbarbase.h"
  14. #include "wx/dynarray.h"
  15. class WXDLLIMPEXP_CORE wxToolBar: public wxToolBarBase
  16. {
  17. DECLARE_DYNAMIC_CLASS(wxToolBar)
  18. public:
  19. /*
  20. * Public interface
  21. */
  22. wxToolBar() { Init(); }
  23. inline wxToolBar(wxWindow *parent, wxWindowID id,
  24. const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
  25. long style = wxTB_HORIZONTAL,
  26. const wxString& name = wxToolBarNameStr)
  27. {
  28. Init();
  29. Create(parent, id, pos, size, style, name);
  30. }
  31. virtual ~wxToolBar();
  32. bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
  33. long style = wxTB_HORIZONTAL,
  34. const wxString& name = wxToolBarNameStr);
  35. virtual void SetWindowStyleFlag(long style);
  36. virtual bool Destroy();
  37. // override/implement base class virtuals
  38. virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
  39. #ifndef __WXOSX_IPHONE__
  40. virtual bool Show(bool show = true);
  41. virtual bool IsShown() const;
  42. #endif
  43. virtual bool Realize();
  44. virtual void SetToolBitmapSize(const wxSize& size);
  45. virtual wxSize GetToolSize() const;
  46. virtual void SetRows(int nRows);
  47. virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap);
  48. virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap);
  49. #ifndef __WXOSX_IPHONE__
  50. // Add all the buttons
  51. virtual wxString MacGetToolTipString( wxPoint &where ) ;
  52. void OnPaint(wxPaintEvent& event) ;
  53. void OnMouse(wxMouseEvent& event) ;
  54. virtual void MacSuperChangedPosition() ;
  55. #endif
  56. #if wxOSX_USE_NATIVE_TOOLBAR
  57. // make all tools selectable
  58. void OSXSetSelectableTools(bool set);
  59. void OSXSelectTool(int toolId);
  60. bool MacInstallNativeToolbar(bool usesNative);
  61. void MacUninstallNativeToolbar();
  62. bool MacWantsNativeToolbar();
  63. bool MacTopLevelHasNativeToolbar(bool *ownToolbarInstalled) const;
  64. #endif
  65. virtual wxToolBarToolBase *CreateTool(int id,
  66. const wxString& label,
  67. const wxBitmap& bmpNormal,
  68. const wxBitmap& bmpDisabled = wxNullBitmap,
  69. wxItemKind kind = wxITEM_NORMAL,
  70. wxObject *clientData = NULL,
  71. const wxString& shortHelp = wxEmptyString,
  72. const wxString& longHelp = wxEmptyString);
  73. virtual wxToolBarToolBase *CreateTool(wxControl *control,
  74. const wxString& label);
  75. protected:
  76. // common part of all ctors
  77. void Init();
  78. void DoLayout();
  79. void DoSetSize(int x, int y, int width, int height, int sizeFlags);
  80. #ifndef __WXOSX_IPHONE__
  81. virtual void DoGetSize(int *width, int *height) const;
  82. virtual wxSize DoGetBestSize() const;
  83. #endif
  84. #ifdef __WXOSX_COCOA__
  85. virtual void DoGetPosition(int*x, int *y) const;
  86. #endif
  87. virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
  88. virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
  89. virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
  90. virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
  91. virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
  92. DECLARE_EVENT_TABLE()
  93. #if wxOSX_USE_NATIVE_TOOLBAR
  94. bool m_macUsesNativeToolbar ;
  95. void* m_macToolbar ;
  96. #endif
  97. #ifdef __WXOSX_IPHONE__
  98. WX_UIView m_macToolbar;
  99. #endif
  100. };
  101. #endif // wxUSE_TOOLBAR
  102. #endif
  103. // _WX_TOOLBAR_H_