1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: toolbar.h
|
|
|
|
// Purpose: wxToolBar class
|
1999-10-17 23:30:47 -04:00
|
|
|
// Author: David Webster
|
1999-07-29 01:11:30 -04:00
|
|
|
// Modified by:
|
1999-10-17 23:30:47 -04:00
|
|
|
// Created: 10/17/98
|
1999-07-29 01:11:30 -04:00
|
|
|
// RCS-ID: $Id$
|
1999-10-17 23:30:47 -04:00
|
|
|
// Copyright: (c) David Webster
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-29 01:11:30 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_TOOLBAR_H_
|
|
|
|
#define _WX_TOOLBAR_H_
|
|
|
|
|
1999-10-17 23:30:47 -04:00
|
|
|
#if wxUSE_TOOLBAR
|
2002-08-25 14:20:22 -04:00
|
|
|
#include "wx/timer.h"
|
1999-07-29 01:11:30 -04:00
|
|
|
#include "wx/tbarbase.h"
|
|
|
|
|
2002-07-09 01:03:04 -04:00
|
|
|
#define ID_TOOLTIMER 100
|
|
|
|
#define ID_TOOLEXPTIMER 101
|
|
|
|
|
1999-07-29 01:11:30 -04:00
|
|
|
class WXDLLEXPORT wxToolBar: public wxToolBarBase
|
|
|
|
{
|
1999-12-17 00:42:26 -05:00
|
|
|
public:
|
|
|
|
/*
|
|
|
|
* Public interface
|
|
|
|
*/
|
|
|
|
|
2002-07-09 01:03:04 -04:00
|
|
|
wxToolBar()
|
|
|
|
: m_vToolTimer(this, ID_TOOLTIMER)
|
|
|
|
, m_vToolExpTimer(this, ID_TOOLEXPTIMER)
|
|
|
|
{ Init(); }
|
1999-12-17 00:42:26 -05:00
|
|
|
|
|
|
|
inline wxToolBar( wxWindow* pParent
|
|
|
|
,wxWindowID vId
|
|
|
|
,const wxPoint& rPos = wxDefaultPosition
|
|
|
|
,const wxSize& rSize = wxDefaultSize
|
2002-07-01 18:22:13 -04:00
|
|
|
,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL
|
1999-12-17 00:42:26 -05:00
|
|
|
,const wxString& rName = wxToolBarNameStr
|
2002-07-09 01:03:04 -04:00
|
|
|
) : m_vToolTimer(this, ID_TOOLTIMER)
|
|
|
|
, m_vToolExpTimer(this, ID_TOOLEXPTIMER)
|
1999-12-17 00:42:26 -05:00
|
|
|
{
|
2002-07-01 18:22:13 -04:00
|
|
|
Init();
|
1999-12-17 00:42:26 -05:00
|
|
|
Create( pParent
|
|
|
|
,vId
|
|
|
|
,rPos
|
|
|
|
,rSize
|
|
|
|
,lStyle
|
|
|
|
,rName
|
|
|
|
);
|
|
|
|
}
|
2002-07-01 18:22:13 -04:00
|
|
|
virtual ~wxToolBar();
|
|
|
|
|
1999-12-17 00:42:26 -05:00
|
|
|
bool Create( wxWindow* pParent
|
|
|
|
,wxWindowID vId
|
|
|
|
,const wxPoint& rPos = wxDefaultPosition
|
|
|
|
,const wxSize& rSize = wxDefaultSize
|
2002-07-01 18:22:13 -04:00
|
|
|
,long lStyle = wxNO_BORDER | wxTB_HORIZONTAL
|
1999-12-17 00:42:26 -05:00
|
|
|
,const wxString& rName = wxToolBarNameStr
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2002-07-01 18:22:13 -04:00
|
|
|
//
|
|
|
|
// Override/implement base class virtuals
|
|
|
|
//
|
|
|
|
virtual wxToolBarToolBase* FindToolForPosition( wxCoord vX
|
|
|
|
,wxCoord vY
|
1999-12-17 00:42:26 -05:00
|
|
|
) const;
|
2002-07-01 18:22:13 -04:00
|
|
|
virtual bool Realize(void);
|
|
|
|
virtual void SetRows(int nRows);
|
1999-12-17 00:42:26 -05:00
|
|
|
|
2002-07-07 23:38:01 -04:00
|
|
|
//
|
|
|
|
// Special overrides for OS/2
|
|
|
|
//
|
|
|
|
virtual wxToolBarToolBase* InsertControl( size_t nPos
|
|
|
|
,wxControl* pControl
|
|
|
|
);
|
|
|
|
virtual wxToolBarToolBase* InsertSeparator(size_t nPos);
|
|
|
|
virtual wxToolBarToolBase* InsertTool( size_t nPos
|
|
|
|
,int nId
|
|
|
|
,const wxString& rsLabel
|
|
|
|
,const wxBitmap& rBitmap
|
|
|
|
,const wxBitmap& rBmpDisabled = wxNullBitmap
|
|
|
|
,wxItemKind eKind = wxITEM_NORMAL
|
|
|
|
,const wxString& rsShortHelp = wxEmptyString
|
|
|
|
,const wxString& rsLongHelp = wxEmptyString
|
|
|
|
,wxObject* pClientData = NULL
|
|
|
|
);
|
|
|
|
wxToolBarToolBase* InsertTool( size_t nPos
|
|
|
|
,int nId
|
|
|
|
,const wxBitmap& rBitmap
|
|
|
|
,const wxBitmap& rBmpDisabled = wxNullBitmap
|
|
|
|
,bool bToggle = FALSE
|
|
|
|
,wxObject* pClientData = NULL
|
|
|
|
,const wxString& rsShortHelp = wxEmptyString
|
|
|
|
,const wxString& rsLongHelp = wxEmptyString
|
|
|
|
)
|
|
|
|
{
|
|
|
|
return InsertTool( nPos
|
|
|
|
,nId
|
|
|
|
,wxEmptyString
|
|
|
|
,rBitmap
|
|
|
|
,rBmpDisabled
|
|
|
|
,bToggle ? wxITEM_CHECK : wxITEM_NORMAL
|
|
|
|
,rsShortHelp
|
|
|
|
,rsLongHelp
|
|
|
|
,pClientData
|
|
|
|
);
|
|
|
|
}
|
|
|
|
virtual bool DeleteTool(int nId);
|
|
|
|
virtual bool DeleteToolByPos(size_t nPos);
|
|
|
|
|
2002-07-01 18:22:13 -04:00
|
|
|
//
|
|
|
|
// Event handlers
|
|
|
|
//
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
void OnMouseEvent(wxMouseEvent& event);
|
|
|
|
void OnKillFocus(wxFocusEvent& event);
|
1999-10-17 23:30:47 -04:00
|
|
|
|
1999-07-29 01:11:30 -04:00
|
|
|
protected:
|
2002-07-01 18:22:13 -04:00
|
|
|
//
|
|
|
|
// Common part of all ctors
|
|
|
|
//
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Implement base class pure virtuals
|
|
|
|
//
|
|
|
|
virtual wxToolBarToolBase* DoAddTool( int id
|
|
|
|
,const wxString& label
|
|
|
|
,const wxBitmap& bitmap
|
|
|
|
,const wxBitmap& bmpDisabled
|
|
|
|
,wxItemKind kind
|
|
|
|
,const wxString& shortHelp = wxEmptyString
|
|
|
|
,const wxString& longHelp = wxEmptyString
|
|
|
|
,wxObject *clientData = NULL
|
|
|
|
,wxCoord xPos = -1
|
|
|
|
,wxCoord yPos = -1
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual bool DoInsertTool( size_t nPos
|
|
|
|
,wxToolBarToolBase* pTool
|
|
|
|
);
|
|
|
|
virtual bool DoDeleteTool( size_t nPos
|
|
|
|
, wxToolBarToolBase* pTool
|
|
|
|
);
|
|
|
|
|
|
|
|
virtual void DoEnableTool( wxToolBarToolBase* pTool
|
|
|
|
,bool bEnable
|
|
|
|
);
|
|
|
|
virtual void DoToggleTool( wxToolBarToolBase* pTool
|
|
|
|
,bool bToggle
|
|
|
|
);
|
|
|
|
virtual void DoSetToggle( wxToolBarToolBase* pTool
|
|
|
|
,bool bToggle
|
|
|
|
);
|
1999-12-17 00:42:26 -05:00
|
|
|
|
|
|
|
virtual wxToolBarToolBase* CreateTool( int vId
|
2002-04-05 17:09:25 -05:00
|
|
|
,const wxString& rsLabel
|
2002-07-01 18:22:13 -04:00
|
|
|
,const wxBitmap& rBmpNormal
|
|
|
|
,const wxBitmap& rBmpDisabled
|
|
|
|
,wxItemKind eKind
|
1999-12-17 00:42:26 -05:00
|
|
|
,wxObject* pClientData
|
2002-07-01 18:22:13 -04:00
|
|
|
,const wxString& rsShortHelp
|
|
|
|
,const wxString& rsLongHelp
|
1999-12-17 00:42:26 -05:00
|
|
|
);
|
|
|
|
virtual wxToolBarToolBase* CreateTool(wxControl* pControl);
|
|
|
|
|
2002-07-01 18:22:13 -04:00
|
|
|
//
|
|
|
|
// Helpers
|
|
|
|
//
|
|
|
|
void DrawTool(wxToolBarToolBase *tool);
|
|
|
|
virtual void DrawTool( wxDC& rDC
|
|
|
|
,wxToolBarToolBase* pTool
|
|
|
|
);
|
|
|
|
virtual void SpringUpButton(int nIndex);
|
|
|
|
|
|
|
|
int m_nCurrentRowsOrColumns;
|
|
|
|
int m_nPressedTool;
|
|
|
|
int m_nCurrentTool;
|
|
|
|
wxCoord m_vLastX;
|
|
|
|
wxCoord m_vLastY;
|
|
|
|
wxCoord m_vMaxWidth;
|
|
|
|
wxCoord m_vMaxHeight;
|
|
|
|
wxCoord m_vXPos;
|
|
|
|
wxCoord m_vYPos;
|
|
|
|
wxCoord m_vTextX;
|
|
|
|
wxCoord m_vTextY;
|
1999-12-17 00:42:26 -05:00
|
|
|
|
2002-07-01 18:22:13 -04:00
|
|
|
private:
|
|
|
|
void LowerTool( wxToolBarToolBase* pTool
|
|
|
|
,bool bLower = TRUE
|
|
|
|
);
|
|
|
|
void RaiseTool( wxToolBarToolBase* pTool
|
|
|
|
,bool bRaise = TRUE
|
|
|
|
);
|
2002-07-09 01:03:04 -04:00
|
|
|
void OnTimer(wxTimerEvent& rEvent);
|
1999-12-17 00:42:26 -05:00
|
|
|
|
2002-07-01 18:22:13 -04:00
|
|
|
static bool m_bInitialized;
|
1999-12-17 00:42:26 -05:00
|
|
|
|
2002-07-09 01:03:04 -04:00
|
|
|
wxTimer m_vToolTimer;
|
|
|
|
wxTimer m_vToolExpTimer;
|
2002-07-09 18:02:07 -04:00
|
|
|
wxToolTip* m_pToolTip;
|
|
|
|
wxCoord m_vXMouse;
|
|
|
|
wxCoord m_vYMouse;
|
2002-07-09 01:03:04 -04:00
|
|
|
|
2003-04-15 17:08:31 -04:00
|
|
|
//
|
|
|
|
// Virtual function hiding supression
|
|
|
|
virtual wxToolBarToolBase *InsertTool (size_t nPos, wxToolBarToolBase* pTool)
|
|
|
|
{
|
|
|
|
return( wxToolBarBase::InsertTool( nPos
|
|
|
|
,pTool
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
1999-12-17 00:42:26 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxToolBar)
|
1999-07-29 01:11:30 -04:00
|
|
|
};
|
|
|
|
|
1999-10-17 23:30:47 -04:00
|
|
|
#endif // wxUSE_TOOLBAR
|
|
|
|
|
1999-07-29 01:11:30 -04:00
|
|
|
#endif
|
|
|
|
// _WX_TOOLBAR_H_
|