2001-07-24 11:27:12 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2002-01-21 17:34:42 -05:00
|
|
|
// Name: dyntbar.h
|
|
|
|
// Purpose: wxDynamicToolBar header
|
2001-07-24 11:27:12 -04:00
|
|
|
// Author: Aleksandras Gluchovas
|
|
|
|
// Modified by:
|
|
|
|
// Created: ??/10/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Aleksandras Gluchovas
|
2002-01-21 17:34:42 -05:00
|
|
|
// Licence: wxWindows licence
|
2001-07-24 11:27:12 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __DYNTBAR_G__
|
|
|
|
#define __DYNTBAR_G__
|
|
|
|
|
2002-09-07 08:28:46 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2001-07-24 11:27:12 -04:00
|
|
|
#pragma interface "dyntbar.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/tbarbase.h"
|
|
|
|
#include "wx/dynarray.h"
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
Tool layout item.
|
|
|
|
*/
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
class wxToolLayoutItem : public wxObject
|
|
|
|
{
|
2002-02-08 08:36:14 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxToolLayoutItem)
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
wxRect mRect;
|
|
|
|
bool mIsSeparator;
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class wxDynToolInfo;
|
|
|
|
|
|
|
|
typedef wxToolLayoutItem* wxToolLayoutItemPtrT;
|
|
|
|
typedef wxDynToolInfo* wxDynToolInfoPtrT;
|
|
|
|
|
|
|
|
WX_DEFINE_ARRAY( wxToolLayoutItemPtrT, wxLayoutItemArrayT );
|
|
|
|
WX_DEFINE_ARRAY( wxDynToolInfoPtrT, wxDynToolInfoArrayT );
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
This is a base class for layout algorithm implementations.
|
|
|
|
*/
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
class LayoutManagerBase
|
|
|
|
{
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Constructor.
|
|
|
|
virtual void Layout( const wxSize& parentDim,
|
|
|
|
wxSize& resultingDim,
|
|
|
|
wxLayoutItemArrayT& items,
|
|
|
|
int horizGap,
|
|
|
|
int vertGap ) = 0;
|
|
|
|
|
|
|
|
// Destructor.
|
|
|
|
virtual ~LayoutManagerBase() {}
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
BagLayout lays out items in left-to-right order from
|
|
|
|
top to bottom.
|
|
|
|
*/
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
class BagLayout : public LayoutManagerBase
|
|
|
|
{
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Constructor.
|
|
|
|
virtual void Layout( const wxSize& parentDim,
|
|
|
|
wxSize& resultingDim,
|
|
|
|
wxLayoutItemArrayT& items,
|
|
|
|
int horizGap,
|
|
|
|
int vertGap );
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
This class holds dynamic toolbar item information.
|
|
|
|
*/
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
class wxDynToolInfo : public wxToolLayoutItem
|
|
|
|
{
|
2002-01-21 17:34:42 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxDynToolInfo)
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
wxWindow* mpToolWnd;
|
|
|
|
int mIndex;
|
|
|
|
wxSize mRealSize;
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Layout orientations for tools
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
#define LO_HORIZONTAL 0
|
|
|
|
#define LO_VERTICAL 1
|
|
|
|
#define LO_FIT_TO_WINDOW 2
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
/*
|
|
|
|
wxDynamicToolBar manages containment and layout of tool windows.
|
|
|
|
*/
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
class wxDynamicToolBar : public wxToolBarBase
|
|
|
|
{
|
2002-02-08 08:36:14 -05:00
|
|
|
protected:
|
2002-01-21 17:34:42 -05:00
|
|
|
friend class wxDynamicToolBarSerializer;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
wxDynToolInfoArrayT mTools;
|
|
|
|
LayoutManagerBase* mpLayoutMan;
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
protected:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Internal function for sizing tool windows.
|
|
|
|
virtual void SizeToolWindows();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
public: /* public properties */
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
int mSepartorSize; // default: 8
|
|
|
|
int mVertGap; // default: 0
|
|
|
|
int mHorizGap; // default: 0
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
public:
|
2002-01-21 17:34:42 -05:00
|
|
|
// Default constructor.
|
|
|
|
|
|
|
|
wxDynamicToolBar();
|
|
|
|
|
|
|
|
// Constructor: see the documentation for wxToolBar for details.
|
|
|
|
|
|
|
|
wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
|
|
|
const long style = wxNO_BORDER, const int orientation = wxVERTICAL,
|
|
|
|
const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
|
|
|
|
|
|
|
|
// Destructor.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
~wxDynamicToolBar(void);
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Creation function: see the documentation for wxToolBar for details.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
bool Create(wxWindow *parent, const wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
|
|
|
const long style = wxNO_BORDER, const int orientation = wxVERTICAL, const int RowsOrColumns = 1, const wxString& name = wxToolBarNameStr);
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Adds a tool. See the documentation for wxToolBar for details.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual void AddTool( int toolIndex,
|
|
|
|
wxWindow* pToolWindow,
|
2001-09-09 13:57:31 -04:00
|
|
|
const wxSize& size = wxDefaultSize );
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Adds a tool. See the documentation for wxToolBar for details.
|
|
|
|
|
|
|
|
virtual void AddTool( int toolIndex,
|
2001-09-09 13:57:31 -04:00
|
|
|
const wxString& imageFileName,
|
|
|
|
wxBitmapType imageFileType = wxBITMAP_TYPE_BMP,
|
|
|
|
const wxString& labelText = "", bool alignTextRight = FALSE,
|
|
|
|
bool isFlat = TRUE );
|
2002-01-21 17:34:42 -05:00
|
|
|
// Adds a tool. See the documentation for wxToolBar for details.
|
|
|
|
|
|
|
|
virtual void AddTool( int toolIndex, wxBitmap labelBmp,
|
2001-09-09 13:57:31 -04:00
|
|
|
const wxString& labelText = "", bool alignTextRight = FALSE,
|
|
|
|
bool isFlat = TRUE );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Method from wxToolBarBase (for compatibility), only
|
|
|
|
// the first two arguments are valid.
|
|
|
|
// See the documentation for wxToolBar for details.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual wxToolBarToolBase *AddTool(const int toolIndex, const wxBitmap& bitmap, const wxBitmap& pushedBitmap = wxNullBitmap,
|
2001-07-24 11:27:12 -04:00
|
|
|
const bool toggle = FALSE, const long xPos = -1, const long yPos = -1, wxObject *clientData = NULL,
|
|
|
|
const wxString& helpString1 = "", const wxString& helpString2 = "");
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Adds a separator. See the documentation for wxToolBar for details.
|
|
|
|
|
|
|
|
virtual void AddSeparator( wxWindow* pSepartorWnd = NULL );
|
|
|
|
|
|
|
|
// Returns tool information for the given tool index.
|
|
|
|
|
|
|
|
wxDynToolInfo* GetToolInfo( int toolIndex );
|
|
|
|
|
|
|
|
// Removes the given tool. Misspelt in order not to clash with a similar function
|
|
|
|
// in the base class.
|
|
|
|
|
|
|
|
void RemveTool( int toolIndex );
|
|
|
|
|
|
|
|
// Draws a separator. The default implementation draws a shaded line.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual void DrawSeparator( wxDynToolInfo& info, wxDC& dc );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Performs layout. See definitions of orientation types.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual bool Layout();
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Returns the preferred dimension, taking the given dimension and a reference to the result.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual void GetPreferredDim( const wxSize& givenDim, wxSize& prefDim );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Creates the default layout (BagLayout).
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual LayoutManagerBase* CreateDefaultLayout() { return new BagLayout(); }
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Sets the layout for this toolbar.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual void SetLayout( LayoutManagerBase* pLayout );
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Enables or disables the given tool.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
virtual void EnableTool(const int toolIndex, const bool enable = TRUE);
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Responds to size events, calling Layout.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
void OnSize( wxSizeEvent& event );
|
|
|
|
|
|
|
|
// Responds to paint events, drawing separators.
|
|
|
|
|
|
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
|
|
|
|
// Responds to background erase events. Currently does nothing.
|
|
|
|
|
|
|
|
void OnEraseBackground( wxEraseEvent& event );
|
|
|
|
|
|
|
|
// Overriden from wxToolBarBase; does nothing.
|
|
|
|
|
|
|
|
virtual bool Realize(void);
|
|
|
|
|
|
|
|
// Finds a tool for the given position.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x,
|
|
|
|
wxCoord y) const;
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Inserts a tool at the given position.
|
2001-07-24 11:27:12 -04:00
|
|
|
|
|
|
|
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Deletes a tool. The tool is still in m_tools list when this function is called, and it will
|
|
|
|
// only be deleted from it if it succeeds.
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Called when the tools enabled flag changes.
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Called when the tool is toggled.
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Called when the tools 'can be toggled' flag changes.
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
|
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Creates a toolbar tool.
|
|
|
|
|
2001-07-24 11:27:12 -04:00
|
|
|
virtual wxToolBarToolBase *CreateTool(int id,
|
2002-03-29 04:39:18 -05:00
|
|
|
const wxString& label,
|
|
|
|
const wxBitmap& bmpNormal,
|
|
|
|
const wxBitmap& bmpDisabled,
|
|
|
|
wxItemKind kind,
|
2001-07-24 11:27:12 -04:00
|
|
|
wxObject *clientData,
|
2002-03-29 04:39:18 -05:00
|
|
|
const wxString& shortHelp,
|
|
|
|
const wxString& longHelp);
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-01-21 17:34:42 -05:00
|
|
|
// Creates a toolbar tool.
|
|
|
|
|
|
|
|
virtual wxToolBarToolBase *CreateTool(wxControl *control);
|
2001-07-24 11:27:12 -04:00
|
|
|
|
2002-03-29 04:39:18 -05:00
|
|
|
private:
|
2002-01-21 17:34:42 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2002-03-29 04:39:18 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxDynamicToolBar)
|
2001-07-24 11:27:12 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* __DYNTBAR_G__ */
|
|
|
|
|