2000-11-04 18:34:33 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: splittree.h
|
|
|
|
// Purpose: Classes to achieve a remotely-scrolled tree in a splitter
|
|
|
|
// window that can be scrolled by a scrolled window higher in the
|
|
|
|
// hierarchy
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 8/7/2000
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SPLITTREE_H_
|
|
|
|
#define _WX_SPLITTREE_H_
|
|
|
|
|
2002-09-07 08:28:46 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
2004-06-11 09:14:23 -04:00
|
|
|
#pragma interface "splittree.h"
|
2000-11-04 18:34:33 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Set this to 1 to use generic tree control (doesn't yet work properly)
|
|
|
|
#define USE_GENERIC_TREECTRL 0
|
|
|
|
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#include "wx/treectrl.h"
|
|
|
|
#include "wx/splitter.h"
|
|
|
|
#include "wx/scrolwin.h"
|
|
|
|
|
|
|
|
#if USE_GENERIC_TREECTRL
|
|
|
|
#include "wx/generic/treectlg.h"
|
|
|
|
#ifndef wxTreeCtrl
|
|
|
|
#define wxTreeCtrl wxGenericTreeCtrl
|
|
|
|
#define sm_classwxTreeCtrl sm_classwxGenericTreeCtrl
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class wxRemotelyScrolledTreeCtrl;
|
|
|
|
class wxThinSplitterWindow;
|
|
|
|
class wxSplitterScrolledWindow;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxRemotelyScrolledTreeCtrl
|
|
|
|
*
|
|
|
|
* This tree control disables its vertical scrollbar and catches scroll
|
|
|
|
* events passed by a scrolled window higher in the hierarchy.
|
|
|
|
* It also updates the scrolled window vertical scrollbar as appropriate.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class wxRemotelyScrolledTreeCtrl: public wxTreeCtrl
|
|
|
|
{
|
2004-06-11 09:14:23 -04:00
|
|
|
DECLARE_CLASS(wxRemotelyScrolledTreeCtrl)
|
2000-11-04 18:34:33 -05:00
|
|
|
public:
|
|
|
|
wxRemotelyScrolledTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pt = wxDefaultPosition,
|
|
|
|
const wxSize& sz = wxDefaultSize, long style = wxTR_HAS_BUTTONS);
|
2004-06-11 09:14:23 -04:00
|
|
|
~wxRemotelyScrolledTreeCtrl();
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
//// Events
|
2004-06-11 09:14:23 -04:00
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
void OnExpand(wxTreeEvent& event);
|
2000-11-04 18:34:33 -05:00
|
|
|
void OnScroll(wxScrollWinEvent& event);
|
|
|
|
|
|
|
|
//// Overrides
|
|
|
|
// Override this in case we're using the generic tree control.
|
|
|
|
// Calls to this should disable the vertical scrollbar.
|
|
|
|
|
|
|
|
// Number of pixels per user unit (0 or -1 for no scrollbar)
|
|
|
|
// Length of virtual canvas in user units
|
|
|
|
// Length of page in user units
|
|
|
|
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
|
|
|
|
int noUnitsX, int noUnitsY,
|
|
|
|
int xPos = 0, int yPos = 0,
|
2004-06-11 09:14:23 -04:00
|
|
|
bool noRefresh = false );
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
// In case we're using the generic tree control.
|
|
|
|
// Get the view start
|
|
|
|
virtual void GetViewStart(int *x, int *y) const;
|
|
|
|
|
|
|
|
// In case we're using the generic tree control.
|
|
|
|
virtual void PrepareDC(wxDC& dc);
|
|
|
|
|
|
|
|
// In case we're using the generic tree control.
|
|
|
|
virtual int GetScrollPos(int orient) const;
|
|
|
|
|
|
|
|
//// Helpers
|
2004-06-11 09:14:23 -04:00
|
|
|
void HideVScrollbar();
|
2000-11-04 18:34:33 -05:00
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
// Calculate the tree overall size so we can set the scrollbar
|
|
|
|
// correctly
|
|
|
|
void CalcTreeSize(wxRect& rect);
|
|
|
|
void CalcTreeSize(const wxTreeItemId& id, wxRect& rect);
|
2000-11-04 18:34:33 -05:00
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
// Adjust the containing wxScrolledWindow's scrollbars appropriately
|
|
|
|
void AdjustRemoteScrollbars();
|
2000-11-04 18:34:33 -05:00
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
// Find the scrolled window that contains this control
|
|
|
|
wxScrolledWindow* GetScrolledWindow() const;
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
// Scroll to the given line (in scroll units where each unit is
|
|
|
|
// the height of an item)
|
|
|
|
void ScrollToLine(int posHoriz, int posVert);
|
|
|
|
|
|
|
|
//// Accessors
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
// The companion window is one which will get notified when certain
|
|
|
|
// events happen such as node expansion
|
|
|
|
void SetCompanionWindow(wxWindow* companion) { m_companionWindow = companion; }
|
|
|
|
wxWindow* GetCompanionWindow() const { return m_companionWindow; }
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
protected:
|
2004-06-11 09:14:23 -04:00
|
|
|
wxWindow* m_companionWindow;
|
2000-11-04 18:34:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxTreeCompanionWindow
|
|
|
|
*
|
|
|
|
* A window displaying values associated with tree control items.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class wxTreeCompanionWindow: public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DECLARE_CLASS(wxTreeCompanionWindow)
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
wxTreeCompanionWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
|
2000-11-04 18:34:33 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& sz = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
//// Overrides
|
2004-06-11 09:14:23 -04:00
|
|
|
virtual void DrawItem(wxDC& dc, wxTreeItemId id, const wxRect& rect);
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
//// Events
|
2004-06-11 09:14:23 -04:00
|
|
|
void OnPaint(wxPaintEvent& event);
|
2000-11-04 18:34:33 -05:00
|
|
|
void OnScroll(wxScrollWinEvent& event);
|
2004-06-11 09:14:23 -04:00
|
|
|
void OnExpand(wxTreeEvent& event);
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
//// Operations
|
|
|
|
|
|
|
|
//// Accessors
|
2004-06-11 09:14:23 -04:00
|
|
|
wxRemotelyScrolledTreeCtrl* GetTreeCtrl() const { return m_treeCtrl; };
|
|
|
|
void SetTreeCtrl(wxRemotelyScrolledTreeCtrl* treeCtrl) { m_treeCtrl = treeCtrl; }
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
//// Data members
|
|
|
|
protected:
|
2004-06-11 09:14:23 -04:00
|
|
|
wxRemotelyScrolledTreeCtrl* m_treeCtrl;
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxThinSplitterWindow
|
|
|
|
*
|
|
|
|
* Implements a splitter with a less obvious sash
|
|
|
|
* than the usual one.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class wxThinSplitterWindow: public wxSplitterWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxThinSplitterWindow)
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
wxThinSplitterWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
|
2000-11-04 18:34:33 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& sz = wxDefaultSize,
|
|
|
|
long style = wxSP_3D | wxCLIP_CHILDREN);
|
2003-09-10 16:53:01 -04:00
|
|
|
~wxThinSplitterWindow();
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
//// Overrides
|
|
|
|
|
|
|
|
void SizeWindows();
|
|
|
|
// Tests for x, y over sash. Overriding this allows us to increase
|
|
|
|
// the tolerance.
|
|
|
|
bool SashHitTest(int x, int y, int tolerance = 2);
|
2004-06-11 09:14:23 -04:00
|
|
|
void DrawSash(wxDC& dc);
|
2000-11-04 18:34:33 -05:00
|
|
|
|
|
|
|
//// Events
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2000-11-04 18:34:33 -05:00
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
|
|
|
|
//// Operations
|
|
|
|
|
|
|
|
//// Accessors
|
|
|
|
|
|
|
|
//// Data members
|
|
|
|
protected:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxSplitterScrolledWindow
|
|
|
|
*
|
|
|
|
* This scrolled window is aware of the fact that one of its
|
|
|
|
* children is a splitter window. It passes on its scroll events
|
|
|
|
* (after some processing) to both splitter children for them
|
|
|
|
* scroll appropriately.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class wxSplitterScrolledWindow: public wxScrolledWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSplitterScrolledWindow)
|
|
|
|
|
2004-06-11 09:14:23 -04:00
|
|
|
wxSplitterScrolledWindow(wxWindow* parent, wxWindowID id = wxID_ANY,
|
2000-11-04 18:34:33 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& sz = wxDefaultSize,
|
|
|
|
long style = 0);
|
|
|
|
|
|
|
|
//// Overrides
|
|
|
|
|
|
|
|
//// Events
|
2004-06-11 09:14:23 -04:00
|
|
|
|
2000-11-04 18:34:33 -05:00
|
|
|
void OnScroll(wxScrollWinEvent& event);
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
|
|
|
|
//// Operations
|
|
|
|
|
|
|
|
//// Accessors
|
|
|
|
|
|
|
|
//// Data members
|
|
|
|
public:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _SPLITTREE_H_
|