tbarwce.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/wince/tbarwce.h
  3. // Purpose: Windows CE wxToolBar class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 2003-07-12
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_BARWCE_H_
  11. #define _WX_BARWCE_H_
  12. #if wxUSE_TOOLBAR
  13. #include "wx/dynarray.h"
  14. // Smartphones don't have toolbars, so use a dummy class
  15. #ifdef __SMARTPHONE__
  16. class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase
  17. {
  18. public:
  19. // ctors and dtor
  20. wxToolBar() { }
  21. wxToolBar(wxWindow *parent,
  22. wxWindowID id,
  23. const wxPoint& pos = wxDefaultPosition,
  24. const wxSize& size = wxDefaultSize,
  25. long style = wxTB_HORIZONTAL,
  26. const wxString& name = wxToolBarNameStr)
  27. {
  28. Create(parent, id, pos, size, style, name);
  29. }
  30. bool Create(wxWindow *parent,
  31. wxWindowID id,
  32. const wxPoint& pos = wxDefaultPosition,
  33. const wxSize& size = wxDefaultSize,
  34. long style = wxTB_HORIZONTAL,
  35. const wxString& name = wxToolBarNameStr);
  36. // override/implement base class virtuals
  37. virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
  38. virtual bool Realize() { return true; }
  39. protected:
  40. // implement base class pure virtuals
  41. virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
  42. virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
  43. virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
  44. virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
  45. virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
  46. virtual wxToolBarToolBase *CreateTool(int id,
  47. const wxString& label,
  48. const wxBitmap& bmpNormal,
  49. const wxBitmap& bmpDisabled,
  50. wxItemKind kind,
  51. wxObject *clientData,
  52. const wxString& shortHelp,
  53. const wxString& longHelp);
  54. virtual wxToolBarToolBase *CreateTool(wxControl *control,
  55. const wxString& label);
  56. private:
  57. DECLARE_EVENT_TABLE()
  58. DECLARE_DYNAMIC_CLASS(wxToolBar)
  59. wxDECLARE_NO_COPY_CLASS(wxToolBar);
  60. };
  61. #else
  62. // For __POCKETPC__
  63. #include "wx/msw/toolbar.h"
  64. class WXDLLIMPEXP_CORE wxToolMenuBar : public wxToolBar
  65. {
  66. public:
  67. // ctors and dtor
  68. wxToolMenuBar() { Init(); }
  69. wxToolMenuBar(wxWindow *parent,
  70. wxWindowID id,
  71. const wxPoint& pos = wxDefaultPosition,
  72. const wxSize& size = wxDefaultSize,
  73. long style = wxTB_HORIZONTAL,
  74. const wxString& name = wxToolBarNameStr,
  75. wxMenuBar* menuBar = NULL)
  76. {
  77. Init();
  78. Create(parent, id, pos, size, style, name, menuBar);
  79. }
  80. bool Create(wxWindow *parent,
  81. wxWindowID id,
  82. const wxPoint& pos = wxDefaultPosition,
  83. const wxSize& size = wxDefaultSize,
  84. long style = wxTB_HORIZONTAL,
  85. const wxString& name = wxToolBarNameStr,
  86. wxMenuBar* menuBar = NULL);
  87. virtual ~wxToolMenuBar();
  88. // override/implement base class virtuals
  89. virtual bool Realize();
  90. // implementation only from now on
  91. // -------------------------------
  92. // Override in order to bypass wxToolBar's overridden function
  93. virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
  94. virtual bool MSWCommand(WXUINT param, WXWORD id);
  95. // Return HMENU for the menu associated with the commandbar
  96. WXHMENU GetHMenu();
  97. // Set the wxMenuBar associated with this commandbar
  98. void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
  99. // Returns the wxMenuBar associated with this commandbar
  100. wxMenuBar* GetMenuBar() const { return m_menuBar; }
  101. protected:
  102. // common part of all ctors
  103. void Init();
  104. // create the native toolbar control
  105. bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size, wxMenuBar* menuBar);
  106. // recreate the control completely
  107. void Recreate();
  108. // implement base class pure virtuals
  109. virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
  110. virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
  111. virtual wxToolBarToolBase *CreateTool(int id,
  112. const wxString& label,
  113. const wxBitmap& bmpNormal,
  114. const wxBitmap& bmpDisabled,
  115. wxItemKind kind,
  116. wxObject *clientData,
  117. const wxString& shortHelp,
  118. const wxString& longHelp);
  119. virtual wxToolBarToolBase *CreateTool(wxControl *control,
  120. const wxString& label);
  121. // The menubar associated with this toolbar
  122. wxMenuBar* m_menuBar;
  123. private:
  124. DECLARE_EVENT_TABLE()
  125. DECLARE_DYNAMIC_CLASS(wxToolMenuBar)
  126. wxDECLARE_NO_COPY_CLASS(wxToolMenuBar);
  127. };
  128. #endif
  129. // __SMARTPHONE__
  130. #endif // wxUSE_TOOLBAR
  131. #endif
  132. // _WX_BARWCE_H_