1998-09-07 05:27:34 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: sashwin.h
|
|
|
|
// Purpose: wxSashWindow implementation. A sash window has an optional
|
|
|
|
// sash on each edge, allowing it to be dragged. An event
|
|
|
|
// is generated when the sash is released.
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 01/02/97
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-09-07 05:27:34 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SASHWIN_H_G_
|
|
|
|
#define _WX_SASHWIN_H_G_
|
|
|
|
|
1999-06-01 11:32:12 -04:00
|
|
|
#if wxUSE_SASH
|
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/window.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
|
|
|
#define wxSASH_DRAG_NONE 0
|
|
|
|
#define wxSASH_DRAG_DRAGGING 1
|
|
|
|
#define wxSASH_DRAG_LEFT_DOWN 2
|
|
|
|
|
|
|
|
enum wxSashEdgePosition {
|
|
|
|
wxSASH_TOP = 0,
|
|
|
|
wxSASH_RIGHT,
|
|
|
|
wxSASH_BOTTOM,
|
|
|
|
wxSASH_LEFT,
|
|
|
|
wxSASH_NONE = 100
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxSashEdge represents one of the four edges of a window.
|
|
|
|
*/
|
|
|
|
|
2003-08-01 21:04:55 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxSashEdge
|
1998-09-07 05:27:34 -04:00
|
|
|
{
|
|
|
|
public:
|
2006-02-06 12:37:26 -05:00
|
|
|
wxSashEdge()
|
|
|
|
{ m_show = false;
|
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
|
|
|
m_border = false;
|
|
|
|
#endif
|
|
|
|
m_margin = 0; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
bool m_show; // Is the sash showing?
|
2006-02-06 12:37:26 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
1998-09-07 05:27:34 -04:00
|
|
|
bool m_border; // Do we draw a border?
|
2006-02-06 12:37:26 -05:00
|
|
|
#endif
|
1998-09-07 05:27:34 -04:00
|
|
|
int m_margin; // The margin size
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* wxSashWindow flags
|
|
|
|
*/
|
|
|
|
|
1999-10-25 09:46:48 -04:00
|
|
|
#define wxSW_NOBORDER 0x0000
|
2000-07-15 15:51:35 -04:00
|
|
|
//#define wxSW_3D 0x0010
|
1999-10-25 09:46:48 -04:00
|
|
|
#define wxSW_BORDER 0x0020
|
2000-07-15 15:51:35 -04:00
|
|
|
#define wxSW_3DSASH 0x0040
|
|
|
|
#define wxSW_3DBORDER 0x0080
|
|
|
|
#define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER)
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* wxSashWindow allows any of its edges to have a sash which can be dragged
|
|
|
|
* to resize the window. The actual content window will be created as a child
|
|
|
|
* of wxSashWindow.
|
|
|
|
*/
|
|
|
|
|
2003-08-01 21:04:55 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxSashWindow: public wxWindow
|
1998-09-07 05:27:34 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Default constructor
|
2000-07-15 15:51:35 -04:00
|
|
|
wxSashWindow()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Normal constructor
|
2004-06-17 12:22:36 -04:00
|
|
|
wxSashWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
|
2002-12-04 09:11:26 -05:00
|
|
|
const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow"))
|
2000-07-15 15:51:35 -04:00
|
|
|
{
|
|
|
|
Init();
|
|
|
|
Create(parent, id, pos, size, style, name);
|
|
|
|
}
|
|
|
|
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxSashWindow();
|
1998-09-07 05:27:34 -04:00
|
|
|
|
2004-06-17 12:22:36 -04:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
|
2002-12-04 09:11:26 -05:00
|
|
|
const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow"));
|
2000-07-15 15:51:35 -04:00
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
// Set whether there's a sash in this position
|
|
|
|
void SetSashVisible(wxSashEdgePosition edge, bool sash);
|
|
|
|
|
|
|
|
// Get whether there's a sash in this position
|
2005-05-17 19:05:33 -04:00
|
|
|
bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
2006-02-06 12:37:26 -05:00
|
|
|
#if WXWIN_COMPATIBILITY_2_6
|
1998-09-07 05:27:34 -04:00
|
|
|
// Set whether there's a border in this position
|
2006-02-06 12:37:26 -05:00
|
|
|
// This value is unused in wxSashWindow.
|
2005-05-17 19:05:33 -04:00
|
|
|
void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Get whether there's a border in this position
|
2006-02-06 12:37:26 -05:00
|
|
|
// This value is unused in wxSashWindow.
|
2005-05-17 19:05:33 -04:00
|
|
|
bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; }
|
2006-02-06 12:37:26 -05:00
|
|
|
#endif
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Get border size
|
2005-05-17 19:05:33 -04:00
|
|
|
int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Sets the default sash border size
|
2005-05-17 19:05:33 -04:00
|
|
|
void SetDefaultBorderSize(int width) { m_borderSize = width; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Gets the default sash border size
|
2005-05-17 19:05:33 -04:00
|
|
|
int GetDefaultBorderSize() const { return m_borderSize; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Sets the addition border size between child and sash window
|
2005-05-17 19:05:33 -04:00
|
|
|
void SetExtraBorderSize(int width) { m_extraBorderSize = width; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Gets the addition border size between child and sash window
|
2005-05-17 19:05:33 -04:00
|
|
|
int GetExtraBorderSize() const { return m_extraBorderSize; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; }
|
|
|
|
virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; }
|
|
|
|
virtual int GetMinimumSizeX() const { return m_minimumPaneSizeX; }
|
|
|
|
virtual int GetMinimumSizeY() const { return m_minimumPaneSizeY; }
|
|
|
|
|
|
|
|
virtual void SetMaximumSizeX(int max) { m_maximumPaneSizeX = max; }
|
|
|
|
virtual void SetMaximumSizeY(int max) { m_maximumPaneSizeY = max; }
|
|
|
|
virtual int GetMaximumSizeX() const { return m_maximumPaneSizeX; }
|
|
|
|
virtual int GetMaximumSizeY() const { return m_maximumPaneSizeY; }
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
// Paints the border and sash
|
|
|
|
void OnPaint(wxPaintEvent& event);
|
|
|
|
|
|
|
|
// Handles mouse events
|
|
|
|
void OnMouseEvent(wxMouseEvent& ev);
|
|
|
|
|
|
|
|
// Adjusts the panes
|
|
|
|
void OnSize(wxSizeEvent& event);
|
|
|
|
|
2003-04-03 13:17:05 -05:00
|
|
|
#if defined(__WXMSW__) || defined(__WXMAC__)
|
2002-12-04 09:11:26 -05:00
|
|
|
// Handle cursor correctly
|
|
|
|
void OnSetCursor(wxSetCursorEvent& event);
|
|
|
|
#endif // wxMSW
|
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
// Draws borders
|
|
|
|
void DrawBorders(wxDC& dc);
|
|
|
|
|
|
|
|
// Draws the sashes
|
|
|
|
void DrawSash(wxSashEdgePosition edge, wxDC& dc);
|
|
|
|
|
|
|
|
// Draws the sashes
|
|
|
|
void DrawSashes(wxDC& dc);
|
|
|
|
|
|
|
|
// Draws the sash tracker (for whilst moving the sash)
|
|
|
|
void DrawSashTracker(wxSashEdgePosition edge, int x, int y);
|
|
|
|
|
|
|
|
// Tests for x, y over sash
|
|
|
|
wxSashEdgePosition SashHitTest(int x, int y, int tolerance = 2);
|
|
|
|
|
|
|
|
// Resizes subwindows
|
|
|
|
void SizeWindows();
|
|
|
|
|
|
|
|
// Initialize colours
|
|
|
|
void InitColours();
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
private:
|
|
|
|
void Init();
|
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
wxSashEdge m_sashes[4];
|
|
|
|
int m_dragMode;
|
|
|
|
wxSashEdgePosition m_draggingEdge;
|
|
|
|
int m_oldX;
|
|
|
|
int m_oldY;
|
|
|
|
int m_borderSize;
|
|
|
|
int m_extraBorderSize;
|
|
|
|
int m_firstX;
|
|
|
|
int m_firstY;
|
|
|
|
int m_minimumPaneSizeX;
|
|
|
|
int m_minimumPaneSizeY;
|
|
|
|
int m_maximumPaneSizeX;
|
|
|
|
int m_maximumPaneSizeY;
|
|
|
|
wxCursor* m_sashCursorWE;
|
|
|
|
wxCursor* m_sashCursorNS;
|
|
|
|
wxColour m_lightShadowColour;
|
|
|
|
wxColour m_mediumShadowColour;
|
|
|
|
wxColour m_darkShadowColour;
|
|
|
|
wxColour m_hilightColour;
|
|
|
|
wxColour m_faceColour;
|
2000-08-25 12:51:31 -04:00
|
|
|
bool m_mouseCaptured;
|
2002-12-04 09:11:26 -05:00
|
|
|
wxCursor* m_currentCursor;
|
1998-09-07 05:27:34 -04:00
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSashWindow)
|
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxSashWindow);
|
1998-09-07 05:27:34 -04:00
|
|
|
};
|
|
|
|
|
2009-01-12 09:26:13 -05:00
|
|
|
class WXDLLIMPEXP_FWD_ADV wxSashEvent;
|
|
|
|
|
2009-02-07 13:59:25 -05:00
|
|
|
wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_SASH_DRAGGED, wxSashEvent );
|
2001-02-06 10:03:46 -05:00
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
enum wxSashDragStatus
|
|
|
|
{
|
|
|
|
wxSASH_STATUS_OK,
|
|
|
|
wxSASH_STATUS_OUT_OF_RANGE
|
|
|
|
};
|
|
|
|
|
2003-08-01 21:04:55 -04:00
|
|
|
class WXDLLIMPEXP_ADV wxSashEvent: public wxCommandEvent
|
1998-09-07 05:27:34 -04:00
|
|
|
{
|
2002-12-04 09:11:26 -05:00
|
|
|
public:
|
2005-05-17 19:05:33 -04:00
|
|
|
wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE)
|
|
|
|
{
|
|
|
|
m_eventType = (wxEventType) wxEVT_SASH_DRAGGED;
|
|
|
|
m_id = id;
|
|
|
|
m_edge = edge;
|
|
|
|
}
|
1998-09-07 05:27:34 -04:00
|
|
|
|
2008-12-27 09:48:26 -05:00
|
|
|
wxSashEvent(const wxSashEvent& event)
|
|
|
|
: wxCommandEvent(event),
|
|
|
|
m_edge(event.m_edge),
|
|
|
|
m_dragRect(event.m_dragRect),
|
|
|
|
m_dragStatus(event.m_dragStatus) { }
|
|
|
|
|
2005-05-17 19:05:33 -04:00
|
|
|
void SetEdge(wxSashEdgePosition edge) { m_edge = edge; }
|
|
|
|
wxSashEdgePosition GetEdge() const { return m_edge; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
//// The rectangle formed by the drag operation
|
2005-05-17 19:05:33 -04:00
|
|
|
void SetDragRect(const wxRect& rect) { m_dragRect = rect; }
|
|
|
|
wxRect GetDragRect() const { return m_dragRect; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
//// Whether the drag caused the rectangle to be reversed (e.g.
|
|
|
|
//// dragging the top below the bottom)
|
2005-05-17 19:05:33 -04:00
|
|
|
void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; }
|
|
|
|
wxSashDragStatus GetDragStatus() const { return m_dragStatus; }
|
2004-06-17 12:22:36 -04:00
|
|
|
|
2008-12-27 09:48:26 -05:00
|
|
|
virtual wxEvent *Clone() const { return new wxSashEvent(*this); }
|
|
|
|
|
2002-12-04 09:11:26 -05:00
|
|
|
private:
|
1998-09-07 05:27:34 -04:00
|
|
|
wxSashEdgePosition m_edge;
|
|
|
|
wxRect m_dragRect;
|
|
|
|
wxSashDragStatus m_dragStatus;
|
2002-12-04 09:11:26 -05:00
|
|
|
|
|
|
|
private:
|
2008-12-27 09:48:26 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSashEvent)
|
1998-09-07 05:27:34 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&);
|
|
|
|
|
2005-05-17 19:05:33 -04:00
|
|
|
#define wxSashEventHandler(func) \
|
2009-01-12 09:26:13 -05:00
|
|
|
wxEVENT_HANDLER_CAST(wxSashEventFunction, func)
|
2005-05-17 19:05:33 -04:00
|
|
|
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SASH_DRAGGED(id, fn) \
|
2005-05-17 19:05:33 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_SASH_DRAGGED, id, wxSashEventHandler(fn))
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \
|
2005-05-17 19:05:33 -04:00
|
|
|
wx__DECLARE_EVT2(wxEVT_SASH_DRAGGED, id1, id2, wxSashEventHandler(fn))
|
1998-09-07 05:27:34 -04:00
|
|
|
|
1999-06-01 11:32:12 -04:00
|
|
|
#endif // wxUSE_SASH
|
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
#endif
|
|
|
|
// _WX_SASHWIN_H_G_
|