2000-02-28 08:42:59 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: treelay.h
|
|
|
|
// Purpose: wxTreeLayout class
|
|
|
|
// Author: Julian Smart
|
2001-05-02 15:48:15 -04:00
|
|
|
// Modified by:
|
2000-02-28 08:42:59 -05:00
|
|
|
// Created: 7/4/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) 1998 Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_TREELAY_H_
|
|
|
|
#define _WX_TREELAY_H_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "wxtree.h"
|
|
|
|
#endif
|
|
|
|
|
2001-07-07 19:02:09 -04:00
|
|
|
#ifndef WX_PRECOMP
|
2001-11-25 07:58:57 -05:00
|
|
|
#include "wx/object.h"
|
2001-07-07 19:02:09 -04:00
|
|
|
class wxList;
|
|
|
|
class wxDC;
|
|
|
|
class wxMouseEvent;
|
|
|
|
#endif
|
|
|
|
|
2001-11-25 07:58:57 -05:00
|
|
|
#include "wx/string.h"
|
2000-02-28 08:42:59 -05:00
|
|
|
|
2001-07-22 14:06:09 -04:00
|
|
|
#if wxUSE_TREELAYOUT
|
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
class WXDLLEXPORT wxTreeLayout: public wxObject
|
|
|
|
{
|
|
|
|
DECLARE_ABSTRACT_CLASS(wxTreeLayout)
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxTreeLayout();
|
2001-07-22 14:06:09 -04:00
|
|
|
virtual ~wxTreeLayout() { }
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
// Redefine these
|
|
|
|
virtual void GetChildren(long id, wxList& list) = 0;
|
|
|
|
virtual long GetNextNode(long id) = 0;
|
|
|
|
virtual long GetNodeParent(long id) = 0;
|
|
|
|
virtual long GetNodeX(long id) = 0;
|
|
|
|
virtual long GetNodeY(long id) = 0;
|
|
|
|
virtual void SetNodeX(long id, long x) = 0;
|
|
|
|
virtual void SetNodeY(long id, long y) = 0;
|
|
|
|
virtual void ActivateNode(long id, bool active) = 0;
|
|
|
|
virtual bool NodeActive(long id) = 0;
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
// Optional redefinition
|
|
|
|
void Initialize(void);
|
2001-05-02 15:48:15 -04:00
|
|
|
inline virtual void SetNodeName(long WXUNUSED(id), const wxString& WXUNUSED(name)) {}
|
|
|
|
inline virtual wxString GetNodeName(long WXUNUSED(id)) { return wxString(""); }
|
2000-02-28 08:42:59 -05:00
|
|
|
virtual void GetNodeSize(long id, long *x, long *y, wxDC& dc);
|
|
|
|
virtual void Draw(wxDC& dc);
|
|
|
|
virtual void DrawNodes(wxDC& dc);
|
|
|
|
virtual void DrawBranches(wxDC& dc);
|
|
|
|
virtual void DrawNode(long id, wxDC& dc);
|
|
|
|
virtual void DrawBranch(long from, long to, wxDC& dc);
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
// Don't redefine
|
|
|
|
virtual void DoLayout(wxDC& dc, long topNode = -1);
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
// Accessors -- don't redefine
|
|
|
|
inline void SetTopNode(long id) { m_parentNode = id; }
|
|
|
|
inline long GetTopNode(void) const { return m_parentNode; }
|
|
|
|
inline void SetSpacing(long x, long y) { m_xSpacing = x; m_ySpacing = y; }
|
|
|
|
inline long GetXSpacing(void) const { return m_xSpacing; }
|
|
|
|
inline long GetYSpacing(void) const { return m_ySpacing; }
|
|
|
|
inline void SetMargins(long x, long y) { m_leftMargin = x; m_topMargin = y; }
|
|
|
|
inline long GetTopMargin(void) const { return m_topMargin; }
|
|
|
|
inline long GetLeftMargin(void) const { return m_leftMargin; }
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
inline bool GetOrientation(void) const { return m_orientation; }
|
2000-07-15 15:51:35 -04:00
|
|
|
inline void SetOrientation(bool orient) { m_orientation = orient; }
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
private:
|
|
|
|
void CalcLayout(long node_id, int level, wxDC& dc);
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
// Members
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
protected:
|
|
|
|
long m_parentNode;
|
|
|
|
long m_lastY;
|
|
|
|
long m_lastX;
|
|
|
|
long m_xSpacing;
|
|
|
|
long m_ySpacing;
|
|
|
|
long m_topMargin;
|
|
|
|
long m_leftMargin;
|
|
|
|
bool m_orientation; // TRUE for top-to-bottom, FALSE for left-to-right
|
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxStoredNode
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxString m_name;
|
|
|
|
long m_x, m_y;
|
|
|
|
long m_parentId;
|
|
|
|
bool m_active;
|
|
|
|
long m_clientData;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A version of wxTreeLayout with storage for nodes
|
|
|
|
*/
|
|
|
|
|
2000-02-28 10:57:06 -05:00
|
|
|
class WXDLLEXPORT wxTreeLayoutStored: public wxTreeLayout
|
2000-02-28 08:42:59 -05:00
|
|
|
{
|
2000-02-28 10:57:06 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxTreeLayoutStored)
|
2000-02-28 08:42:59 -05:00
|
|
|
public:
|
2000-02-28 10:57:06 -05:00
|
|
|
wxTreeLayoutStored(int noNodes = 200);
|
2001-07-22 14:06:09 -04:00
|
|
|
virtual ~wxTreeLayoutStored(void);
|
2000-02-28 08:42:59 -05:00
|
|
|
void Initialize(int n);
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
wxString HitTest(wxMouseEvent& event, wxDC& dc);
|
|
|
|
wxStoredNode* GetNode(long id) const;
|
|
|
|
inline int GetNumNodes() const { return m_maxNodes; };
|
|
|
|
inline int GetNodeCount() const { return m_num; };
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
virtual void GetChildren(long id, wxList& list);
|
|
|
|
virtual long GetNextNode(long id);
|
|
|
|
virtual long GetNodeParent(long id);
|
|
|
|
virtual long GetNodeX(long id);
|
|
|
|
virtual long GetNodeY(long id);
|
|
|
|
virtual void SetNodeX(long id, long x);
|
|
|
|
virtual void SetNodeY(long id, long y);
|
|
|
|
virtual void SetNodeName(long id, const wxString& name);
|
|
|
|
virtual wxString GetNodeName(long id);
|
|
|
|
virtual void ActivateNode(long id, bool active);
|
|
|
|
virtual bool NodeActive(long id);
|
|
|
|
virtual void SetClientData(long id, long clientData);
|
|
|
|
virtual long GetClientData(long id) const;
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
virtual long AddChild(const wxString& name, const wxString& parent = "");
|
|
|
|
virtual long NameToId(const wxString& name);
|
2001-05-02 15:48:15 -04:00
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
// Data members
|
|
|
|
private:
|
|
|
|
wxStoredNode* m_nodes;
|
|
|
|
int m_num;
|
|
|
|
int m_maxNodes;
|
|
|
|
};
|
|
|
|
|
|
|
|
// For backward compatibility
|
2000-02-28 10:57:06 -05:00
|
|
|
#define wxStoredTree wxTreeLayoutStored
|
2000-02-28 08:42:59 -05:00
|
|
|
|
2001-07-22 14:06:09 -04:00
|
|
|
#endif
|
|
|
|
// wxUSE_TREELAYOUT
|
|
|
|
|
2000-02-28 08:42:59 -05:00
|
|
|
#endif
|
|
|
|
// _WX_TREELAY_H_
|
2001-05-02 15:48:15 -04:00
|
|
|
|