merging in the toolbar changes

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4977 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-12-15 19:47:54 +00:00
parent 56f5d962ad
commit 8a0681f933
17 changed files with 4144 additions and 3737 deletions

View File

@@ -4,139 +4,92 @@
// Author: Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __TBARGTKH__
#define __TBARGTKH__
#ifndef _WX_GTK_TBARGTK_H_
#define _WX_GTK_TBARGTK_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "tbargtk.h"
#endif
#include "wx/defs.h"
#if wxUSE_TOOLBAR
#include "wx/control.h"
#include "wx/bitmap.h"
#include "wx/tbarbase.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxToolBarTool;
class wxToolBar;
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#define wxTOOL_STYLE_BUTTON 1
#define wxTOOL_STYLE_SEPARATOR 2
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const wxChar *wxToolBarNameStr;
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxToolBar
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxToolBar: public wxControl
class wxToolBar : public wxToolBarBase
{
public:
wxToolBar();
wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxToolBarNameStr );
~wxToolBar();
// construction/destruction
wxToolBar() { Init(); }
wxToolBar( wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr )
{
Init();
bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxToolBarNameStr);
Create(parent, id, pos, size, style, name);
}
// Only allow toggle if returns TRUE. Call when left button up.
virtual bool OnLeftClick(int toolIndex, bool toggleDown);
bool Create( wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr );
// Call when right button down.
virtual void OnRightClick(int toolIndex, float x, float y);
// Called when the mouse cursor enters a tool bitmap.
// Argument is -1 if mouse is exiting the toolbar.
virtual void OnMouseEnter(int toolIndex);
// If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states.
virtual wxToolBarTool *AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap = wxNullBitmap, bool toggle = FALSE,
wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = (wxObject *)NULL,
const wxString& helpString1 = "", const wxString& helpString2 = "");
// Add arbitrary control
virtual bool AddControl(wxControl *control);
// Add space
virtual void AddSeparator();
// Delete tool by index (=id)
virtual bool DeleteTool(int toolIndex);
// Delete all tools
virtual void ClearTools();
// Has to be called after adding tools or changing something
virtual bool Realize();
virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
virtual wxObject *GetToolClientData(int index) const;
virtual bool GetToolState(int toolIndex) const;
virtual bool GetToolEnabled(int toolIndex) const;
virtual ~wxToolBar();
// override base class virtuals
virtual void SetMargins(int x, int y);
void SetMargins(const wxSize& size) { SetMargins(size.x, size.y); };
virtual wxSize GetToolMargins(void) { return wxSize(m_xMargin, m_yMargin); }
virtual void SetToolPacking(int packing);
virtual void SetToolSeparation(int separation);
virtual int GetToolPacking();
virtual int GetToolSeparation();
virtual wxString GetToolLongHelp(int toolIndex);
virtual wxString GetToolShortHelp(int toolIndex);
virtual void SetToolLongHelp(int toolIndex, const wxString& helpString);
virtual void SetToolShortHelp(int toolIndex, const wxString& helpString);
void OnIdle( wxIdleEvent &ievent );
// implementation
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
// implementation from now on
// --------------------------
GtkToolbar *m_toolbar;
int m_separation;
wxList m_tools;
GdkColor *m_fg;
GdkColor *m_bg;
int m_xMargin;
int m_yMargin;
bool m_hasToolAlready;
GdkColor *m_fg;
GdkColor *m_bg;
bool m_blockNextEvent;
void OnInternalIdle();
protected:
// common part of all ctors
void Init();
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxToolBar)
};
#endif
#endif // wxUSE_TOOLBAR
#endif
// __TBARGTKH__
// _WX_GTK_TBARGTK_H_

View File

@@ -4,139 +4,92 @@
// Author: Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __TBARGTKH__
#define __TBARGTKH__
#ifndef _WX_GTK_TBARGTK_H_
#define _WX_GTK_TBARGTK_H_
#ifdef __GNUG__
#pragma interface
#pragma interface "tbargtk.h"
#endif
#include "wx/defs.h"
#if wxUSE_TOOLBAR
#include "wx/control.h"
#include "wx/bitmap.h"
#include "wx/tbarbase.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxToolBarTool;
class wxToolBar;
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#define wxTOOL_STYLE_BUTTON 1
#define wxTOOL_STYLE_SEPARATOR 2
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const wxChar *wxToolBarNameStr;
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxToolBar
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxToolBar: public wxControl
class wxToolBar : public wxToolBarBase
{
public:
wxToolBar();
wxToolBar( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxToolBarNameStr );
~wxToolBar();
// construction/destruction
wxToolBar() { Init(); }
wxToolBar( wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr )
{
Init();
bool Create( wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = wxToolBarNameStr);
Create(parent, id, pos, size, style, name);
}
// Only allow toggle if returns TRUE. Call when left button up.
virtual bool OnLeftClick(int toolIndex, bool toggleDown);
bool Create( wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxToolBarNameStr );
// Call when right button down.
virtual void OnRightClick(int toolIndex, float x, float y);
// Called when the mouse cursor enters a tool bitmap.
// Argument is -1 if mouse is exiting the toolbar.
virtual void OnMouseEnter(int toolIndex);
// If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states.
virtual wxToolBarTool *AddTool( int toolIndex, const wxBitmap& bitmap,
const wxBitmap& pushedBitmap = wxNullBitmap, bool toggle = FALSE,
wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = (wxObject *)NULL,
const wxString& helpString1 = "", const wxString& helpString2 = "");
// Add arbitrary control
virtual bool AddControl(wxControl *control);
// Add space
virtual void AddSeparator();
// Delete tool by index (=id)
virtual bool DeleteTool(int toolIndex);
// Delete all tools
virtual void ClearTools();
// Has to be called after adding tools or changing something
virtual bool Realize();
virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
virtual wxObject *GetToolClientData(int index) const;
virtual bool GetToolState(int toolIndex) const;
virtual bool GetToolEnabled(int toolIndex) const;
virtual ~wxToolBar();
// override base class virtuals
virtual void SetMargins(int x, int y);
void SetMargins(const wxSize& size) { SetMargins(size.x, size.y); };
virtual wxSize GetToolMargins(void) { return wxSize(m_xMargin, m_yMargin); }
virtual void SetToolPacking(int packing);
virtual void SetToolSeparation(int separation);
virtual int GetToolPacking();
virtual int GetToolSeparation();
virtual wxString GetToolLongHelp(int toolIndex);
virtual wxString GetToolShortHelp(int toolIndex);
virtual void SetToolLongHelp(int toolIndex, const wxString& helpString);
virtual void SetToolShortHelp(int toolIndex, const wxString& helpString);
void OnIdle( wxIdleEvent &ievent );
// implementation
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
// implementation from now on
// --------------------------
GtkToolbar *m_toolbar;
int m_separation;
wxList m_tools;
GdkColor *m_fg;
GdkColor *m_bg;
int m_xMargin;
int m_yMargin;
bool m_hasToolAlready;
GdkColor *m_fg;
GdkColor *m_bg;
bool m_blockNextEvent;
void OnInternalIdle();
protected:
// common part of all ctors
void Init();
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxToolBar)
};
#endif
#endif // wxUSE_TOOLBAR
#endif
// __TBARGTKH__
// _WX_GTK_TBARGTK_H_

View File

@@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////////
// Name: toolbar.h
// Name: wx/motif/toolbar.h
// Purpose: wxToolBar class
// Author: Julian Smart
// Modified by:
// Modified by: 13.12.99 by VZ during toolbar classes reorganization
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
@@ -13,81 +13,60 @@
#define _WX_TOOLBAR_H_
#ifdef __GNUG__
#pragma interface "toolbar.h"
#pragma interface "toolbar.h"
#endif
#include "wx/tbarbase.h"
WXDLLEXPORT_DATA(extern const char*) wxToolBarNameStr;
class WXDLLEXPORT wxToolBar: public wxToolBarBase
class WXDLLEXPORT wxToolBar : public wxToolBarBase
{
DECLARE_DYNAMIC_CLASS(wxToolBar)
public:
/*
* Public interface
*/
public:
// ctors and dtor
wxToolBar() { Init(); }
wxToolBar();
wxToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
{
Init();
inline wxToolBar(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr):
m_widgets(wxKEY_INTEGER)
Create(parent, id, pos, size, style, name);
}
{
Create(parent, id, pos, size, style, name);
}
~wxToolBar();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr);
bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr);
virtual ~wxToolBar();
// If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states.
wxToolBarTool *AddTool(int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE, wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = NULL,
const wxString& helpString1 = "", const wxString& helpString2 = "");
// override/implement base class virtuals
virtual wxToolBarTool *FindToolForPosition(wxCoord x, wxCoord y) const;
// Set default bitmap size
void SetToolBitmapSize(const wxSize& size);
void EnableTool(int toolIndex, bool enable); // additional drawing on enabling
void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
void ClearTools();
virtual bool Realize();
// The button size is bigger than the bitmap size
wxSize GetToolSize() const;
// implementation from now on
wxSize GetMaxSize() const;
// Add all the buttons
virtual bool CreateTools();
virtual void LayoutTools() {}
// The post-tool-addition call. TODO: do here whatever's
// necessary for completing the toolbar construction.
bool Realize() { return CreateTools(); };
// Implementation
void DestroyPixmaps();
int FindIndexForWidget(WXWidget w);
WXWidget FindWidgetForIndex(int index);
WXWidget GetTopWidget() const;
WXWidget GetClientWidget() const;
WXWidget GetMainWidget() const;
// find tool by widget
wxToolBarTool *FindToolByWidget(WXWidget w) const;
protected:
// List of widgets in the toolbar, indexed by tool index
wxList m_widgets;
// common part of all ctors
void Init();
// List of pixmaps to destroy when tools are recreated or
// or toolbar is destroyed.
wxList m_pixmaps;
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarTool *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarTool *tool);
DECLARE_EVENT_TABLE()
virtual void DoEnableTool(wxToolBarTool *tool, bool enable);
virtual void DoToggleTool(wxToolBarTool *tool, bool toggle);
virtual void DoSetToggle(wxToolBarTool *tool, bool toggle);
private:
DECLARE_DYNAMIC_CLASS(wxToolBar)
};
#endif

View File

@@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/tbar95.h
// Purpose: wxToolBar95 (Windows 95 toolbar) class
// Purpose: wxToolBar (Windows 95 toolbar) class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
@@ -13,21 +13,20 @@
#define _WX_TBAR95_H_
#ifdef __GNUG__
#pragma interface "tbar95.h"
#pragma interface "tbar95.h"
#endif
#if wxUSE_TOOLBAR
#include "wx/dynarray.h"
#include "wx/tbarbase.h"
class WXDLLEXPORT wxToolBar95 : public wxToolBarBase
class WXDLLEXPORT wxToolBar : public wxToolBarBase
{
public:
wxToolBar95() { Init(); }
// ctors and dtor
wxToolBar() { Init(); }
wxToolBar95(wxWindow *parent,
wxToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
@@ -39,8 +38,6 @@ public:
Create(parent, id, pos, size, style, name);
}
~wxToolBar95();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
@@ -48,36 +45,21 @@ public:
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr);
// override base class virtuals
virtual ~wxToolBar();
virtual wxToolBarTool *AddTool(int toolIndex,
const wxBitmap& bitmap,
const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE,
long xPos = -1, long yPos = -1,
wxObject *clientData = NULL,
const wxString& helpString1 = wxEmptyString,
const wxString& helpString2 = wxEmptyString);
virtual bool AddControl(wxControl *control);
// override/implement base class virtuals
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
virtual bool DeleteTool(int toolIndex);
virtual void ClearTools();
virtual bool Realize() { return CreateTools(); };
virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle);
virtual bool Realize();
virtual void SetToolBitmapSize(const wxSize& size);
virtual wxSize GetToolSize() const;
virtual wxSize GetMaxSize() const;
virtual bool GetToolState(int toolIndex) const;
virtual bool CreateTools();
virtual void SetRows(int nRows);
// IMPLEMENTATION
// implementation only from now on
// -------------------------------
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
@@ -88,34 +70,37 @@ protected:
// common part of all ctors
void Init();
// the array storing the id for each index
wxArrayInt m_ids;
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
// get index from id (returns wxNOT_FOUND if no such button)
int GetIndexFromId(int id) const;
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
// should be called whenever the toolbar size changes
void UpdateSize();
// override WndProc to process WM_SIZE
virtual long MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
// the big bitmap containing all bitmaps of the toolbar buttons
WXHBITMAP m_hBitmap;
DECLARE_EVENT_TABLE()
};
class WXDLLEXPORT wxToolBar : public wxToolBar95
{
public:
wxToolBar() { }
wxToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
: wxToolBar95(parent, id, pos, size, style, name)
{
}
// the total number of toolbar elements
size_t m_nButtons;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxToolBar)
};

View File

@@ -1,8 +1,8 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tbarmsw.h
// Purpose: wxToolBarMSW class
// Name: wx/msw/tbarmsw.h
// Purpose: wxToolBar for Win16
// Author: Julian Smart
// Modified by:
// Modified by: 13.12.99 by VZ during toolbar classes reorganization
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
@@ -24,117 +24,123 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxButtonBarNameStr;
class WXDLLEXPORT wxMemoryDC;
// Non-Win95 (WIN32, WIN16, UNIX) version
// ----------------------------------------------------------------------------
// wxToolBar for Win16
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxToolBarMSW: public wxToolBarBase
{
DECLARE_DYNAMIC_CLASS(wxToolBarMSW)
public:
/*
* Public interface
*/
wxToolBarMSW(void);
inline wxToolBarMSW(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL, const wxString& name = wxButtonBarNameStr)
{
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL, const wxString& name = wxButtonBarNameStr);
~wxToolBarMSW(void);
// Handle wxWindows events
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnMouseEvent(wxMouseEvent& event);
// If pushedBitmap is NULL, a reversed version of bitmap is
// created and used as the pushed/toggled image.
// If toggle is TRUE, the button toggles between the two states.
wxToolBarTool *AddTool(int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE, long xPos = -1, long yPos = -1, wxObject *clientData = NULL,
const wxString& helpString1 = wxEmptyString, const wxString& helpString2 = wxEmptyString);
void DrawTool(wxDC& dc, wxMemoryDC& memDc, wxToolBarTool *tool);
// Set default bitmap size
virtual void SetToolBitmapSize(const wxSize& size);
void EnableTool(int toolIndex, bool enable); // additional drawing on enabling
// The button size is bigger than the bitmap size
wxSize GetToolSize(void) const;
void LayoutTools();
// The post-tool-addition call
bool Realize() { Layout(); return TRUE; };
protected:
void DrawTool(wxDC& dc, wxToolBarTool *tool, int state);
void GetSysColors(void);
bool InitGlobalObjects(void);
void FreeGlobalObjects(void);
void PatB(WXHDC hdc,int x,int y,int dx,int dy, long rgb);
void CreateMask(WXHDC hDC, int xoffset, int yoffset, int dx, int dy);
void DrawBlankButton(WXHDC hdc, int x, int y, int dx, int dy, int state);
void DrawButton(WXHDC hdc, int x, int y, int dx, int dy, wxToolBarTool *tool, int state);
WXHBITMAP CreateDitherBitmap();
bool CreateDitherBrush(void);
bool FreeDitherBrush(void);
WXHBITMAP CreateMappedBitmap(WXHINSTANCE hInstance, void *lpBitmapInfo);
WXHBITMAP CreateMappedBitmap(WXHINSTANCE hInstance, WXHBITMAP hBitmap);
protected:
int m_currentRowsOrColumns;
long m_lastX, m_lastY;
WXHBRUSH m_hbrDither;
WXDWORD m_rgbFace;
WXDWORD m_rgbShadow;
WXDWORD m_rgbHilight;
WXDWORD m_rgbFrame;
//
// m_hdcMono is the DC that holds a mono bitmap, m_hbmMono
// that is used to create highlights
// of button faces.
// m_hbmDefault hold the default bitmap if there is one.
//
WXHDC m_hdcMono;
WXHBITMAP m_hbmMono;
WXHBITMAP m_hbmDefault;
DECLARE_EVENT_TABLE()
};
//
// States (not all of them currently used)
//
#define wxTBSTATE_CHECKED 0x01 // radio button is checked
#define wxTBSTATE_PRESSED 0x02 // button is being depressed (any style)
#define wxTBSTATE_ENABLED 0x04 // button is enabled
#define wxTBSTATE_HIDDEN 0x08 // button is hidden
#define wxTBSTATE_INDETERMINATE 0x10 // button is indeterminate
class WXDLLEXPORT wxToolBar : public wxToolBarMSW
class WXDLLEXPORT wxToolBar : public wxToolBarBase
{
public:
wxToolBar() { }
// construction
wxToolBar() { Init(); }
wxToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
: wxToolBarMSW(parent, id, pos, size, style, name)
long style = wxNO_BORDER|wxTB_HORIZONTAL,
const wxString& name = wxButtonBarNameStr)
{
Init();
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL,
const wxString& name = wxButtonBarNameStr);
~wxToolBar();
// implement/override base class (pure) virtuals
virtual wxToolBarToolBase *AddTool(int id,
const wxBitmap& bitmap,
const wxBitmap& pushedBitmap,
bool toggle,
wxCoord xPos,
wxCoord yPos = -1,
wxObject *clientData = NULL,
const wxString& helpString1 = wxEmptyString,
const wxString& helpString2 = wxEmptyString);
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
virtual void SetToolBitmapSize(const wxSize& size);
virtual wxSize GetToolSize() const;
virtual bool Realize();
// implementation only from now on
// -------------------------------
// Handle wxWindows events
void OnPaint(wxPaintEvent& event);
void OnMouseEvent(wxMouseEvent& event);
protected:
void Init();
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
void DoRedrawTool(wxToolBarToolBase *tool);
void DrawTool(wxDC& dc, wxToolBarToolBase *tool);
void DrawTool(wxDC& dc, wxToolBarToolBase *tool, int state);
void GetSysColors();
bool InitGlobalObjects();
void FreeGlobalObjects();
void PatB(WXHDC hdc,int x,int y,int dx,int dy, long rgb);
void CreateMask(WXHDC hDC, int xoffset, int yoffset, int dx, int dy);
void DrawBlankButton(WXHDC hdc, int x, int y, int dx, int dy, int state);
void DrawButton(WXHDC hdc, int x, int y, int dx, int dy,
wxToolBarTool *tool, int state);
WXHBITMAP CreateDitherBitmap();
bool CreateDitherBrush();
bool FreeDitherBrush();
WXHBITMAP CreateMappedBitmap(WXHINSTANCE hInstance, void *lpBitmapInfo);
WXHBITMAP CreateMappedBitmap(WXHINSTANCE hInstance, WXHBITMAP hBitmap);
int m_currentRowsOrColumns;
int m_pressedTool, m_currentTool;
wxCoord m_xPos, m_yPos;
wxCoord m_lastX, m_lastY;
WXHBRUSH m_hbrDither;
WXDWORD m_rgbFace;
WXDWORD m_rgbShadow;
WXDWORD m_rgbHilight;
WXDWORD m_rgbFrame;
//
// m_hdcMono is the DC that holds a mono bitmap, m_hbmMono
// that is used to create highlights
// of button faces.
// m_hbmDefault hold the default bitmap if there is one.
//
WXHDC m_hdcMono;
WXHBITMAP m_hbmMono;
WXHBITMAP m_hbmDefault;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxToolBar)
};

View File

@@ -26,7 +26,8 @@
#include "wx/list.h"
#include "wx/control.h"
class WXDLLEXPORT wxToolBar;
class WXDLLEXPORT wxToolBarBase;
class WXDLLEXPORT wxToolBarToolBase;
// ----------------------------------------------------------------------------
// constants
@@ -36,7 +37,7 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
enum
enum wxToolBarToolStyle
{
wxTOOL_STYLE_BUTTON = 1,
wxTOOL_STYLE_SEPARATOR = 2,
@@ -44,60 +45,128 @@ enum
};
// ----------------------------------------------------------------------------
// wxToolBarTool is one button/separator/whatever in the toolbar
// wxToolBarTool is a toolbar element.
//
// It has a unique id (except for the separators which always have id -1), the
// style (telling whether it is a normal button, separator or a control), the
// state (toggled or not, enabled or not) and short and long help strings. The
// default implementations use the short help string for the tooltip text which
// is popped up when the mouse pointer enters the tool and the long help string
// for the applications status bar.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxToolBarTool : public wxObject
class WXDLLEXPORT wxToolBarToolBase : public wxObject
{
public:
// ctors & dtor
// ------------
wxToolBarTool() { }
wxToolBarToolBase(wxToolBarBase *tbar = (wxToolBarBase *)NULL,
int id = wxID_SEPARATOR,
const wxBitmap& bitmap1 = wxNullBitmap,
const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE,
wxObject *clientData = (wxObject *) NULL,
const wxString& shortHelpString = wxEmptyString,
const wxString& longHelpString = wxEmptyString)
: m_shortHelpString(shortHelpString),
m_longHelpString(longHelpString)
{
m_tbar = tbar;
m_id = id;
m_clientData = clientData;
#ifdef __WXGTK__
wxToolBarTool(wxToolBar *owner,
int theIndex = 0,
const wxBitmap& bitmap1 = wxNullBitmap,
const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE,
wxObject *clientData = (wxObject *) NULL,
const wxString& shortHelpString = wxEmptyString,
const wxString& longHelpString = wxEmptyString,
GtkWidget *pixmap = (GtkWidget *) NULL );
#else // !GTK
wxToolBarTool(int theIndex,
const wxBitmap& bitmap1 = wxNullBitmap,
const wxBitmap& bitmap2 = wxNullBitmap,
bool toggle = FALSE,
long xPos = -1,
long yPos = -1,
const wxString& shortHelpString = wxEmptyString,
const wxString& longHelpString = wxEmptyString);
#endif // GTK/!GTK
m_bitmap1 = bitmap1;
m_bitmap2 = bitmap2;
wxToolBarTool(wxControl *control);
m_isToggle = toggle;
m_enabled = TRUE;
m_toggled = FALSE;
~wxToolBarTool();
m_toolStyle = id == wxID_SEPARATOR ? wxTOOL_STYLE_SEPARATOR
: wxTOOL_STYLE_BUTTON;
}
wxToolBarToolBase(wxToolBarBase *tbar, wxControl *control)
{
m_tbar = tbar;
m_control = control;
m_id = control->GetId();
m_isToggle = FALSE;
m_enabled = TRUE;
m_toggled = FALSE;
m_toolStyle = wxTOOL_STYLE_CONTROL;
}
~wxToolBarToolBase();
// accessors
// ---------
void SetSize( long w, long h ) { m_width = w; m_height = h; }
long GetWidth() const { return m_width; }
long GetHeight() const { return m_height; }
// general
int GetId() const { return m_id; }
wxControl *GetControl() const
{
wxASSERT_MSG( m_toolStyle == wxTOOL_STYLE_CONTROL,
_T("this toolbar tool is not a control") );
wxASSERT_MSG( IsControl(), _T("this toolbar tool is not a control") );
return m_control;
}
public:
int m_toolStyle;
int m_index;
wxToolBarBase *GetToolBar() const { return m_tbar; }
// style
int IsButton() const { return m_toolStyle == wxTOOL_STYLE_BUTTON; }
int IsControl() const { return m_toolStyle == wxTOOL_STYLE_CONTROL; }
int IsSeparator() const { return m_toolStyle == wxTOOL_STYLE_SEPARATOR; }
int GetStyle() const { return m_toolStyle; }
// state
bool IsEnabled() const { return m_enabled; }
bool IsToggled() const { return m_toggled; }
bool CanBeToggled() const { return m_isToggle; }
// attributes
const wxBitmap& GetBitmap1() const { return m_bitmap1; }
const wxBitmap& GetBitmap2() const { return m_bitmap2; }
const wxBitmap& GetBitmap() const
{ return IsToggled() ? m_bitmap2 : m_bitmap1; }
wxString GetShortHelp() const { return m_shortHelpString; }
wxString GetLongHelp() const { return m_longHelpString; }
wxObject *GetClientData() const
{
wxASSERT_MSG( m_toolStyle != wxTOOL_STYLE_CONTROL,
_T("this toolbar tool doesn't have client data") );
return m_clientData;
}
// modifiers: return TRUE if the state really changed
bool Enable(bool enable);
bool Toggle(bool toggle);
bool SetToggle(bool toggle);
bool SetShortHelp(const wxString& help);
bool SetLongHelp(const wxString& help);
void Toggle() { Toggle(!IsToggled()); }
void SetBitmap1(const wxBitmap& bmp) { m_bitmap1 = bmp; }
void SetBitmap2(const wxBitmap& bmp) { m_bitmap2 = bmp; }
// add tool to/remove it from a toolbar
virtual void Detach() { m_tbar = (wxToolBarBase *)NULL; }
virtual void Attach(wxToolBarBase *tbar) { m_tbar = tbar; }
protected:
wxToolBarBase *m_tbar; // the toolbar to which we belong (may be NULL)
int m_toolStyle; // see enum wxToolBarToolStyle
int m_id; // the tool id, wxID_SEPARATOR for separator
// as controls have their own client data, no need to waste memory
union
@@ -106,33 +175,23 @@ public:
wxControl *m_control;
};
wxCoord m_x;
wxCoord m_y;
wxCoord m_width;
wxCoord m_height;
// tool state
bool m_toggled;
bool m_isToggle;
bool m_enabled;
bool m_toggleState;
bool m_isToggle;
bool m_enabled;
bool m_isMenuCommand;
// normal and toggles bitmaps
wxBitmap m_bitmap1;
wxBitmap m_bitmap2;
bool m_deleteSecondBitmap;
wxBitmap m_bitmap1;
wxBitmap m_bitmap2;
wxString m_shortHelpString;
wxString m_longHelpString;
#ifdef __WXGTK__
wxToolBar *m_owner;
GtkWidget *m_item;
GtkWidget *m_pixmap;
#endif // GTK
private:
DECLARE_DYNAMIC_CLASS(wxToolBarTool)
// short and long help strings
wxString m_shortHelpString;
wxString m_longHelpString;
};
// a list of toolbar tools
WX_DECLARE_LIST(wxToolBarToolBase, wxToolBarToolsList);
// ----------------------------------------------------------------------------
// the base class for all toolbars
// ----------------------------------------------------------------------------
@@ -141,7 +200,7 @@ class WXDLLEXPORT wxToolBarBase : public wxControl
{
public:
wxToolBarBase();
~wxToolBarBase();
virtual ~wxToolBarBase();
// toolbar construction
// --------------------
@@ -149,50 +208,93 @@ public:
// If pushedBitmap is NULL, a reversed version of bitmap is created and
// used as the pushed/toggled image. If toggle is TRUE, the button toggles
// between the two states.
virtual wxToolBarTool *AddTool(int toolIndex,
wxToolBarToolBase *AddTool(int id,
const wxBitmap& bitmap,
const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE,
wxObject *clientData = NULL,
const wxString& shortHelpString = wxEmptyString,
const wxString& longHelpString = wxEmptyString)
{
return AddTool(id, bitmap, pushedBitmap, toggle,
-1, -1, clientData, shortHelpString, longHelpString);
}
// the old version of AddTool() kept for compatibility
virtual wxToolBarToolBase *AddTool
(
int id,
const wxBitmap& bitmap,
const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE,
wxCoord xPos = -1,
const wxBitmap& pushedBitmap,
bool toggle,
wxCoord xPos,
wxCoord yPos = -1,
wxObject *clientData = NULL,
const wxString& helpString1 = wxEmptyString,
const wxString& helpString2 = wxEmptyString);
const wxString& helpString2 = wxEmptyString
);
// add an arbitrary control to the toolbar at given index, return TRUE if
// ok (notice that the control will be deleted by the toolbar and that it
// will also adjust its position/size)
// insert the new tool at the given position, if pos == GetToolsCount(), it
// is equivalent to AddTool()
virtual wxToolBarToolBase *InsertTool
(
size_t pos,
int id,
const wxBitmap& bitmap,
const wxBitmap& pushedBitmap = wxNullBitmap,
bool toggle = FALSE,
wxObject *clientData = NULL,
const wxString& help1 = wxEmptyString,
const wxString& help2 = wxEmptyString
);
// add an arbitrary control to the toolbar, return TRUE if ok (notice that
// the control will be deleted by the toolbar and that it will also adjust
// its position/size)
//
// NB: the control should have toolbar as its parent
virtual bool AddControl(wxControl * WXUNUSED(control)) { return FALSE; }
virtual wxToolBarToolBase *AddControl(wxControl *control);
virtual wxToolBarToolBase *InsertControl(size_t pos, wxControl *control);
virtual void AddSeparator();
// add a separator to the toolbar
virtual wxToolBarToolBase *AddSeparator();
virtual wxToolBarToolBase *InsertSeparator(size_t pos);
// remove the tool from the toolbar: the caller is responsible for actually
// deleting the pointer
virtual wxToolBarToolBase *RemoveTool(int id);
// delete tool either by index or by position
virtual bool DeleteToolByPos(size_t pos);
virtual bool DeleteTool(int id);
// delete all tools
virtual void ClearTools();
// must be called after all buttons have been created to finish toolbar
// initialisation
virtual bool Realize() = 0;
virtual bool Realize();
// tools state
// -----------
virtual void EnableTool(int toolIndex, bool enable);
// toggle is TRUE if toggled on
virtual void ToggleTool(int toolIndex, bool toggle);
virtual void EnableTool(int id, bool enable);
virtual void ToggleTool(int id, bool toggle);
// Set this to be togglable (or not)
virtual void SetToggle(int toolIndex, bool toggle);
virtual void SetToggle(int id, bool toggle);
virtual wxObject *GetToolClientData(int index) const;
virtual bool GetToolState(int toolIndex) const;
virtual bool GetToolEnabled(int toolIndex) const;
virtual wxToolBarTool *FindToolForPosition(long x, long y) const;
// return TRUE if the tool is toggled
virtual bool GetToolState(int id) const;
virtual void SetToolShortHelp(int toolIndex, const wxString& helpString);
virtual wxString GetToolShortHelp(int toolIndex) const;
virtual void SetToolLongHelp(int toolIndex, const wxString& helpString);
virtual wxString GetToolLongHelp(int toolIndex) const;
virtual bool GetToolEnabled(int id) const;
virtual void SetToolShortHelp(int id, const wxString& helpString);
virtual wxString GetToolShortHelp(int id) const;
virtual void SetToolLongHelp(int id, const wxString& helpString);
virtual wxString GetToolLongHelp(int id) const;
// margins/packing/separation
// --------------------------
@@ -200,48 +302,58 @@ public:
virtual void SetMargins(int x, int y);
void SetMargins(const wxSize& size)
{ SetMargins((int) size.x, (int) size.y); }
virtual void SetToolPacking(int packing);
virtual void SetToolSeparation(int separation);
virtual void SetToolPacking(int packing)
{ m_toolPacking = packing; }
virtual void SetToolSeparation(int separation)
{ m_toolSeparation = separation; }
virtual wxSize GetToolMargins() { return wxSize(m_xMargin, m_yMargin); }
virtual int GetToolPacking() { return m_toolPacking; }
virtual int GetToolSeparation() { return m_toolSeparation; }
// toolbar geometry
// ----------------
// set the number of toolbar rows
virtual void SetRows(int nRows);
// the toolbar can wrap - limit the number of columns or rows it may take
void SetMaxRowsCols(int rows, int cols)
{ m_maxRows = rows; m_maxCols = cols; }
int GetMaxRows() const { return m_maxRows; }
int GetMaxCols() const { return m_maxCols; }
// tool(bar) size
// -------------
// get/set the size of the bitmaps used by the toolbar: should be called
// before adding any tools to the toolbar
virtual void SetToolBitmapSize(const wxSize& size)
{ m_defaultWidth = size.x; m_defaultHeight = size.y; };
virtual wxSize GetToolBitmapSize() const
{ return wxSize(m_defaultWidth, m_defaultHeight); }
// After the toolbar has initialized, this is the size the tools take up
virtual wxSize GetMaxSize() const;
// The button size (in some implementations) is bigger than the bitmap size: this returns
// the total button size.
// the button size in some implementations is bigger than the bitmap size:
// get the total button size (by default the same as bitmap size)
virtual wxSize GetToolSize() const
{ return wxSize(m_defaultWidth, m_defaultHeight); } ;
{ return GetToolBitmapSize(); } ;
// Handle wxToolBar events
// -----------------------
// returns a (non separator) tool containing the point (x, y) or NULL if
// there is no tool at this point (corrdinates are client)
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
wxCoord y) const = 0;
// event handlers
// --------------
// NB: these functions are deprecated, use EVT_TOOL_XXX() instead!
// Only allow toggle if returns TRUE. Call when left button up.
virtual bool OnLeftClick(int toolIndex, bool toggleDown);
virtual bool OnLeftClick(int id, bool toggleDown);
// Call when right button down.
virtual void OnRightClick(int toolIndex, long x, long y);
virtual void OnRightClick(int id, long x, long y);
// Called when the mouse cursor enters a tool bitmap.
// Argument is -1 if mouse is exiting the toolbar.
virtual void OnMouseEnter(int toolIndex);
virtual void OnMouseEnter(int id);
// more deprecated functions
// -------------------------
@@ -255,103 +367,75 @@ public:
virtual void SetDefaultSize(const wxSize& size) { SetToolBitmapSize(size); }
virtual wxSize GetDefaultSize() const { return GetToolBitmapSize(); }
virtual wxSize GetDefaultButtonSize() const { return GetToolSize(); }
void GetMaxSize ( long * width, long * height ) const
{ wxSize maxSize(GetMaxSize()); *width = maxSize.x; *height = maxSize.y; }
#endif // WXWIN_COMPATIBILITY
// implementation only from now on
// -------------------------------
wxList& GetTools() const { return (wxList&) m_tools; }
size_t GetToolsCount() const { return m_tools.GetCount(); }
// Lay the tools out
virtual void LayoutTools();
// Add all the buttons: required for Win95.
virtual bool CreateTools() { return TRUE; }
void Command(wxCommandEvent& event);
// SCROLLING: this has to be copied from wxScrolledWindow since wxToolBarBase
// inherits from wxControl. This could have been put into wxToolBarSimple,
// but we might want any derived toolbar class to be scrollable.
// Number of pixels per user unit (0 or -1 for no scrollbar)
// Length of virtual canvas in user units
virtual void SetScrollbars(int horizontal, int vertical,
int x_length, int y_length,
int x_pos = 0, int y_pos = 0);
// Physically scroll the window
virtual void Scroll(int x_pos, int y_pos);
virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
virtual void AdjustScrollbars();
// Prepare the DC by translating it according to the current scroll position
virtual void PrepareDC(wxDC& dc);
int GetScrollPageSize(int orient) const ;
void SetScrollPageSize(int orient, int pageSize);
// Get the view start
virtual void ViewStart(int *x, int *y) const;
// Actual size in pixels when scrolling is taken into account
virtual void GetVirtualSize(int *x, int *y) const;
void OnIdle(wxIdleEvent& event);
// Do the toolbar button updates (check for EVT_UPDATE_UI handlers)
virtual void DoToolbarUpdates();
// event handlers
void OnScroll(wxScrollEvent& event);
void OnSize(wxSizeEvent& event);
void OnIdle(wxIdleEvent& event);
protected:
wxList m_tools;
// to implement in derived classes
// -------------------------------
int m_maxRows;
int m_maxCols;
long m_maxWidth,
m_maxHeight;
// the tool is not yet inserted into m_tools list when this function is
// called and will only be added to it if this function succeeds
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool) = 0;
int m_currentTool; // Tool where mouse currently is
int m_pressedTool; // Tool where mouse pressed
// the tool is still in m_tools list when this function is called, it will
// only be deleted from it if it succeeds
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool) = 0;
int m_xMargin;
int m_yMargin;
int m_toolPacking;
int m_toolSeparation;
// called when the tools enabled flag changes
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable) = 0;
wxCoord m_defaultWidth;
wxCoord m_defaultHeight;
// called when the tool is toggled
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle) = 0;
public:
////////////////////////////////////////////////////////////////////////
//// IMPLEMENTATION
// called when the tools "can be toggled" flag changes
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle) = 0;
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollEvent& event);
// the functions to create toolbar tools
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString) = 0;
virtual wxToolBarToolBase *CreateTool(wxControl *control) = 0;
////////////////////////////////////////////////////////////////////////
//// PROTECTED DATA
protected:
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
int m_xScrollPosition;
int m_yScrollPosition;
bool m_calcScrolledOffset; // If TRUE, wxCanvasDC uses scrolled offsets
int m_xScrollLines;
int m_yScrollLines;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
// helper functions
// ----------------
// find the tool by id
wxToolBarToolBase *FindById(int id) const;
// the list of all our tools
wxToolBarToolsList m_tools;
// the offset of the first tool
int m_xMargin;
int m_yMargin;
// the maximum number of toolbar rows/columns
int m_maxRows;
int m_maxCols;
// the tool packing and separation
int m_toolPacking,
m_toolSeparation;
// the size of the toolbar bitmaps
wxCoord m_defaultWidth, m_defaultHeight;
private:
DECLARE_EVENT_TABLE()
DECLARE_ABSTRACT_CLASS(wxToolBarBase)
};
#endif

View File

@@ -1,13 +0,0 @@
#ifndef _WX_TBARMSW_H_BASE_
#define _WX_TBARMSW_H_BASE_
#if defined(__WXMSW__)
#include "wx/msw/tbarmsw.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/tbarmsw.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tbarmsw.h"
#endif
#endif
// _WX_TBARMSW_H_BASE_

View File

@@ -1,81 +1,173 @@
/////////////////////////////////////////////////////////////////////////////
// Name: tbarsmpl.h
// Name: wx/tbarsmpl.h
// Purpose: wxToolBarSimple class
// Author: Julian Smart
// Modified by:
// Modified by: VZ on 14.12.99 during wxToolBar classes reorganization
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TBARSMPLH__
#define _WX_TBARSMPLH__
#ifdef __GNUG__
#pragma interface "tbarsmpl.h"
#pragma interface "tbarsmpl.h"
#endif
#include "wx/defs.h"
#if wxUSE_TOOLBAR
#include "wx/bitmap.h"
#include "wx/list.h"
#include "wx/tbarbase.h"
#if wxUSE_TOOLBAR_SIMPLE
class WXDLLEXPORT wxMemoryDC;
WXDLLEXPORT_DATA(extern const wxChar*) wxToolBarNameStr;
WXDLLEXPORT_DATA(extern const wxSize) wxDefaultSize;
WXDLLEXPORT_DATA(extern const wxPoint) wxDefaultPosition;
// ----------------------------------------------------------------------------
// wxToolBarSimple is a generic toolbar implementation in pure wxWindows
// ----------------------------------------------------------------------------
// XView can't cope properly with panels that behave like canvases
// (e.g. no scrollbars in panels)
class WXDLLEXPORT wxToolBarSimple : public wxToolBarBase
{
DECLARE_DYNAMIC_CLASS(wxToolBarSimple)
public:
// ctors and dtor
wxToolBarSimple() { Init(); }
public:
wxToolBarSimple(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
{
Init();
wxToolBarSimple(void);
inline wxToolBarSimple(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
{
Create(parent, id, pos, size, style, name);
}
~wxToolBarSimple(void);
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER|wxTB_HORIZONTAL, const wxString& name = wxToolBarNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr);
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnKillFocus(wxFocusEvent& event);
virtual ~wxToolBarSimple();
// Handle wxToolBar events
// override/implement base class virtuals
virtual wxToolBarToolBase *AddTool
(
int id,
const wxBitmap& bitmap,
const wxBitmap& pushedBitmap,
bool toggle,
wxCoord xPos,
wxCoord yPos = -1,
wxObject *clientData = NULL,
const wxString& helpString1 = wxEmptyString,
const wxString& helpString2 = wxEmptyString
);
virtual void DrawTool(wxDC& dc, wxMemoryDC& memDC, wxToolBarTool *tool);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
virtual void SpringUpButton(int index);
virtual bool Realize();
virtual void LayoutTools();
virtual void SetRows(int nRows);
// The post-tool-addition call
virtual bool Realize() { LayoutTools(); return TRUE; };
// implementation from now on
// --------------------------
// SCROLLING: this has to be copied from wxScrolledWindow since
// wxToolBarBase inherits from wxControl. This could have been put into
// wxToolBarSimple, but we might want any derived toolbar class to be
// scrollable.
// Number of pixels per user unit (0 or -1 for no scrollbar)
// Length of virtual canvas in user units
virtual void SetScrollbars(int horizontal, int vertical,
int x_length, int y_length,
int x_pos = 0, int y_pos = 0);
// Physically scroll the window
virtual void Scroll(int x_pos, int y_pos);
virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
virtual void AdjustScrollbars();
// Prepare the DC by translating it according to the current scroll position
virtual void PrepareDC(wxDC& dc);
int GetScrollPageSize(int orient) const ;
void SetScrollPageSize(int orient, int pageSize);
// Get the view start
virtual void ViewStart(int *x, int *y) const;
// Actual size in pixels when scrolling is taken into account
virtual void GetVirtualSize(int *x, int *y) const;
int CalcScrollInc(wxScrollEvent& event);
// event handlers
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnMouseEvent(wxMouseEvent& event);
void OnKillFocus(wxFocusEvent& event);
void OnScroll(wxScrollEvent& event);
protected:
int m_currentRowsOrColumns;
long m_lastX, m_lastY;
// common part of all ctors
void Init();
DECLARE_EVENT_TABLE()
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
// helpers
void DrawTool(wxToolBarToolBase *tool);
virtual void DrawTool(wxDC& dc, wxToolBarToolBase *tool);
virtual void SpringUpButton(int index);
int m_currentRowsOrColumns;
int m_pressedTool, m_currentTool;
wxCoord m_lastX, m_lastY;
wxCoord m_maxWidth, m_maxHeight;
wxCoord m_xPos, m_yPos;
// scrolling data
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
int m_xScrollPosition;
int m_yScrollPosition;
bool m_calcScrolledOffset; // If TRUE, wxCanvasDC uses scrolled offsets
int m_xScrollLines;
int m_yScrollLines;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxToolBarSimple)
};
#endif // wxUSE_TOOLBAR
#endif // wxUSE_TOOLBAR_SIMPLE
#endif
// _WX_TBARSMPLH__

View File

@@ -14,29 +14,32 @@
#include "wx/tbarbase.h" // the base class for all toolbars
#if 0
class WXDLLEXPORT wxToolBar : public wxControl
{
};
#endif // 0
#if defined(__WXMSW__) && defined(__WIN95__)
# include "wx/msw/tbar95.h"
#elif defined(__WXMSW__)
# include "wx/msw/tbarmsw.h"
#elif defined(__WXMOTIF__)
# include "wx/motif/toolbar.h"
#elif defined(__WXGTK__)
# include "wx/gtk/tbargtk.h"
#elif defined(__WXQT__)
# include "wx/qt/tbarqt.h"
#elif defined(__WXMAC__)
# include "wx/mac/toolbar.h"
#elif defined(__WXPM__)
# include "wx/os2/toolbar.h"
#elif defined(__WXSTUBS__)
# include "wx/stubs/toolbar.h"
#endif
#if wxUSE_TOOLBAR
#if !wxUSE_TOOLBAR_NATIVE
// the wxToolBarSimple is *the* toolbar class in this case
#define wxToolBarSimple wxToolBar
#include "wx/tbarsmpl.h"
#else // wxUSE_TOOLBAR_NATIVE
#if defined(__WXMSW__) && defined(__WIN95__)
#include "wx/msw/tbar95.h"
#elif defined(__WXMSW__)
#include "wx/msw/tbarmsw.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/toolbar.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tbargtk.h"
#elif defined(__WXQT__)
#include "wx/qt/tbarqt.h"
#elif defined(__WXMAC__)
#include "wx/mac/toolbar.h"
#elif defined(__WXPM__)
#include "wx/os2/toolbar.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/toolbar.h"
#endif
#endif // !wxUSE_TOOLBAR_NATIVE/wxUSE_TOOLBAR_NATIVE
#endif // wxUSE_TOOLBAR
#endif
// _WX_TOOLBAR_H_BASE_