1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/msw/toolbar.h
|
2016-02-21 08:39:19 +00:00
|
|
|
// Purpose: wxToolBar class
|
1998-05-20 14:12:05 +00:00
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
1998-08-07 23:52:45 +00:00
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 14:12:05 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2005-03-27 18:03:57 +00:00
|
|
|
#ifndef _WX_MSW_TBAR95_H_
|
|
|
|
#define _WX_MSW_TBAR95_H_
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-06-13 22:54:04 +00:00
|
|
|
#if wxUSE_TOOLBAR
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-12-04 22:34:54 +00:00
|
|
|
#include "wx/dynarray.h"
|
2005-03-27 18:03:57 +00:00
|
|
|
#include "wx/imaglist.h"
|
1999-12-04 22:34:54 +00:00
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxToolBar : public wxToolBarBase
|
1998-05-20 14:12:05 +00:00
|
|
|
{
|
1999-11-12 02:17:44 +00:00
|
|
|
public:
|
1999-12-15 19:47:54 +00:00
|
|
|
// ctors and dtor
|
|
|
|
wxToolBar() { Init(); }
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
wxToolBar(wxWindow *parent,
|
1999-11-12 02:17:44 +00:00
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2014-11-07 14:59:33 +00:00
|
|
|
long style = wxTB_DEFAULT_STYLE,
|
1999-11-12 02:17:44 +00:00
|
|
|
const wxString& name = wxToolBarNameStr)
|
|
|
|
{
|
|
|
|
Init();
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-12 02:17:44 +00:00
|
|
|
Create(parent, id, pos, size, style, name);
|
|
|
|
}
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-12 02:17:44 +00:00
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2014-11-07 14:59:33 +00:00
|
|
|
long style = wxTB_DEFAULT_STYLE,
|
1999-11-12 02:17:44 +00:00
|
|
|
const wxString& name = wxToolBarNameStr);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
virtual ~wxToolBar();
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
// override/implement base class virtuals
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const wxOVERRIDE;
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual bool Realize() wxOVERRIDE;
|
1998-11-28 13:38:40 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual void SetToolBitmapSize(const wxSize& size) wxOVERRIDE;
|
|
|
|
virtual wxSize GetToolSize() const wxOVERRIDE;
|
1998-08-13 10:19:16 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual void SetRows(int nRows) wxOVERRIDE;
|
1998-07-27 09:47:57 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual void SetToolNormalBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE;
|
|
|
|
virtual void SetToolDisabledBitmap(int id, const wxBitmap& bitmap) wxOVERRIDE;
|
2007-03-18 23:13:18 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual void SetToolPacking(int packing) wxOVERRIDE;
|
2015-12-13 17:49:35 +00:00
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual void SetWindowStyleFlag(long style) wxOVERRIDE;
|
2002-03-26 00:44:57 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual bool MSWCommand(WXUINT param, WXWORD id) wxOVERRIDE;
|
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) wxOVERRIDE;
|
1998-05-20 14:12:05 +00:00
|
|
|
|
1999-11-12 02:17:44 +00:00
|
|
|
void OnMouseEvent(wxMouseEvent& event);
|
|
|
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
2012-05-02 14:44:45 +00:00
|
|
|
void OnEraseBackground(wxEraseEvent& event);
|
1998-05-20 14:12:05 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
void SetFocus() wxOVERRIDE {}
|
2002-03-31 14:07:17 +00:00
|
|
|
|
2001-12-31 02:41:49 +00:00
|
|
|
static WXHBITMAP MapBitmap(WXHBITMAP bitmap, int width, int height);
|
|
|
|
|
2006-02-08 21:47:09 +00:00
|
|
|
// override WndProc mainly to process WM_SIZE
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) wxOVERRIDE;
|
2006-02-08 21:47:09 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const wxOVERRIDE;
|
2006-02-08 21:47:09 +00:00
|
|
|
|
2007-08-09 15:05:56 +00:00
|
|
|
// returns true if the platform should explicitly apply a theme border
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual bool CanApplyThemeBorder() const wxOVERRIDE { return false; }
|
2007-08-09 15:05:56 +00:00
|
|
|
|
2009-12-22 15:37:43 +00:00
|
|
|
#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual bool MSWEraseBgHook(WXHDC hDC) wxOVERRIDE;
|
|
|
|
virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child) wxOVERRIDE;
|
2009-12-22 15:37:43 +00:00
|
|
|
#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
|
|
|
|
2012-03-10 00:01:09 +00:00
|
|
|
virtual wxToolBarToolBase *CreateTool(int id,
|
|
|
|
const wxString& label,
|
|
|
|
const wxBitmap& bmpNormal,
|
|
|
|
const wxBitmap& bmpDisabled = wxNullBitmap,
|
|
|
|
wxItemKind kind = wxITEM_NORMAL,
|
|
|
|
wxObject *clientData = NULL,
|
|
|
|
const wxString& shortHelp = wxEmptyString,
|
2016-09-23 14:59:11 +00:00
|
|
|
const wxString& longHelp = wxEmptyString) wxOVERRIDE;
|
2012-03-10 00:01:09 +00:00
|
|
|
|
|
|
|
virtual wxToolBarToolBase *CreateTool(wxControl *control,
|
2016-09-23 14:59:11 +00:00
|
|
|
const wxString& label) wxOVERRIDE;
|
1998-05-20 14:12:05 +00:00
|
|
|
protected:
|
1999-11-12 02:17:44 +00:00
|
|
|
// common part of all ctors
|
|
|
|
void Init();
|
|
|
|
|
2003-01-10 23:23:49 +00:00
|
|
|
// create the native toolbar control
|
|
|
|
bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size);
|
2002-09-14 21:36:18 +00:00
|
|
|
|
|
|
|
// recreate the control completely
|
|
|
|
void Recreate();
|
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
// implement base class pure virtuals
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE;
|
|
|
|
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) wxOVERRIDE;
|
1999-12-04 22:34:54 +00:00
|
|
|
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable) wxOVERRIDE;
|
|
|
|
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle) wxOVERRIDE;
|
|
|
|
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) wxOVERRIDE;
|
1999-12-04 22:34:54 +00:00
|
|
|
|
2002-09-14 21:36:18 +00:00
|
|
|
// return the appropriate size and flags for the toolbar control
|
2016-09-23 14:59:11 +00:00
|
|
|
virtual wxSize DoGetBestSize() const wxOVERRIDE;
|
2002-09-14 21:36:18 +00:00
|
|
|
|
2002-03-15 23:42:42 +00:00
|
|
|
// handlers for various events
|
|
|
|
bool HandleSize(WXWPARAM wParam, WXLPARAM lParam);
|
2009-12-22 15:37:43 +00:00
|
|
|
#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
2002-03-15 23:42:42 +00:00
|
|
|
bool HandlePaint(WXWPARAM wParam, WXLPARAM lParam);
|
2009-12-22 15:37:43 +00:00
|
|
|
#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
2002-03-15 23:42:42 +00:00
|
|
|
void HandleMouseMove(WXWPARAM wParam, WXLPARAM lParam);
|
|
|
|
|
2002-09-14 21:36:18 +00:00
|
|
|
// should be called whenever the toolbar size changes
|
|
|
|
void UpdateSize();
|
|
|
|
|
2005-03-27 18:03:57 +00:00
|
|
|
// create m_disabledImgList (but doesn't fill it), set it to NULL if it is
|
|
|
|
// unneeded
|
|
|
|
void CreateDisabledImageList();
|
|
|
|
|
2006-07-24 14:57:57 +00:00
|
|
|
// get the Windows toolbar style of this control
|
|
|
|
long GetMSWToolbarStyle() const;
|
|
|
|
|
2015-12-14 20:50:27 +00:00
|
|
|
// set native toolbar padding
|
|
|
|
void MSWSetPadding(WXWORD padding);
|
2005-03-27 18:03:57 +00:00
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
// the big bitmap containing all bitmaps of the toolbar buttons
|
|
|
|
WXHBITMAP m_hBitmap;
|
|
|
|
|
2005-03-27 18:03:57 +00:00
|
|
|
// the image list with disabled images, may be NULL if we use
|
|
|
|
// system-provided versions of them
|
|
|
|
wxImageList *m_disabledImgList;
|
|
|
|
|
1999-12-15 19:47:54 +00:00
|
|
|
// the total number of toolbar elements
|
|
|
|
size_t m_nButtons;
|
1999-11-16 21:31:40 +00:00
|
|
|
|
2009-12-10 03:04:19 +00:00
|
|
|
// the sum of the sizes of the fixed items (i.e. excluding stretchable
|
|
|
|
// spaces) in the toolbar direction
|
|
|
|
int m_totalFixedSize;
|
|
|
|
|
2001-09-23 15:38:01 +00:00
|
|
|
// the tool the cursor is in
|
|
|
|
wxToolBarToolBase *m_pInTool;
|
|
|
|
|
1999-11-16 21:31:40 +00:00
|
|
|
private:
|
2009-01-26 23:20:17 +00:00
|
|
|
// makes sure tool bitmap size is sufficient for all tools
|
|
|
|
void AdjustToolBitmapSize();
|
|
|
|
|
2009-12-10 03:04:19 +00:00
|
|
|
// update the sizes of stretchable spacers to consume all extra space we
|
|
|
|
// have
|
|
|
|
void UpdateStretchableSpacersSize();
|
|
|
|
|
2009-12-22 15:37:43 +00:00
|
|
|
#ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
|
|
|
// do erase the toolbar background, always do it for the entire control as
|
|
|
|
// the caller sets the clipping region correctly to exclude parts which
|
|
|
|
// should not be erased
|
|
|
|
void MSWDoEraseBackground(WXHDC hDC);
|
|
|
|
|
|
|
|
// return the brush to use for erasing the toolbar background
|
|
|
|
WXHBRUSH MSWGetToolbarBgBrush();
|
|
|
|
#endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
|
|
|
|
|
2015-04-23 11:49:01 +00:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxToolBar);
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxToolBar);
|
1998-05-20 14:12:05 +00:00
|
|
|
};
|
|
|
|
|
1999-06-13 22:54:04 +00:00
|
|
|
#endif // wxUSE_TOOLBAR
|
|
|
|
|
2005-03-27 18:03:57 +00:00
|
|
|
#endif // _WX_MSW_TBAR95_H_
|
|
|
|
|