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
|
2003-03-17 05:34:04 -05:00
|
|
|
// Licence: wxWindows licence
|
1998-09-07 05:27:34 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SASHWIN_H_G_
|
|
|
|
#define _WX_SASHWIN_H_G_
|
|
|
|
|
2002-08-31 07:29:13 -04:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1998-09-07 05:27:34 -04:00
|
|
|
#pragma interface "sashwin.h"
|
|
|
|
#endif
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSashEdge
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSashEdge() { m_show = FALSE; m_border = FALSE; m_margin = 0; }
|
|
|
|
|
|
|
|
bool m_show; // Is the sash showing?
|
|
|
|
bool m_border; // Do we draw a border?
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSashWindow: public wxWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Default constructor
|
2000-07-15 15:51:35 -04:00
|
|
|
wxSashWindow()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Normal constructor
|
|
|
|
wxSashWindow(wxWindow *parent, wxWindowID id = -1, 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);
|
|
|
|
}
|
|
|
|
|
1998-09-07 05:27:34 -04:00
|
|
|
~wxSashWindow();
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id = -1, 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
|
1998-11-17 18:03:15 -05:00
|
|
|
inline bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Set whether there's a border in this position
|
|
|
|
inline void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; }
|
|
|
|
|
|
|
|
// Get whether there's a border in this position
|
1998-11-17 18:03:15 -05:00
|
|
|
inline bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; }
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
// Get border size
|
1998-11-17 18:03:15 -05:00
|
|
|
inline 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
|
|
|
|
inline void SetDefaultBorderSize(int width) { m_borderSize = width; }
|
|
|
|
|
|
|
|
// Gets the default sash border size
|
|
|
|
inline int GetDefaultBorderSize() const { return m_borderSize; }
|
|
|
|
|
|
|
|
// Sets the addition border size between child and sash window
|
|
|
|
inline void SetExtraBorderSize(int width) { m_extraBorderSize = width; }
|
|
|
|
|
|
|
|
// Gets the addition border size between child and sash window
|
|
|
|
inline int GetExtraBorderSize() const { return m_extraBorderSize; }
|
|
|
|
|
|
|
|
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()
|
2003-01-02 18:38:11 -05:00
|
|
|
DECLARE_NO_COPY_CLASS(wxSashWindow)
|
1998-09-07 05:27:34 -04:00
|
|
|
};
|
|
|
|
|
2001-02-06 10:03:46 -05:00
|
|
|
BEGIN_DECLARE_EVENT_TYPES()
|
|
|
|
DECLARE_EVENT_TYPE(wxEVT_SASH_DRAGGED, wxEVT_FIRST + 1200)
|
|
|
|
END_DECLARE_EVENT_TYPES()
|
|
|
|
|
|
|
|
// #define wxEVT_SASH_DRAGGED (wxEVT_FIRST + 1200)
|
1998-09-07 05:27:34 -04:00
|
|
|
|
|
|
|
enum wxSashDragStatus
|
|
|
|
{
|
|
|
|
wxSASH_STATUS_OK,
|
|
|
|
wxSASH_STATUS_OUT_OF_RANGE
|
|
|
|
};
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSashEvent: public wxCommandEvent
|
|
|
|
{
|
2002-12-04 09:11:26 -05:00
|
|
|
public:
|
1998-09-07 05:27:34 -04:00
|
|
|
inline wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE) {
|
|
|
|
m_eventType = (wxEventType) wxEVT_SASH_DRAGGED; m_id = id; m_edge = edge; }
|
|
|
|
|
|
|
|
inline void SetEdge(wxSashEdgePosition edge) { m_edge = edge; }
|
|
|
|
inline wxSashEdgePosition GetEdge() const { return m_edge; }
|
|
|
|
|
|
|
|
//// The rectangle formed by the drag operation
|
|
|
|
inline void SetDragRect(const wxRect& rect) { m_dragRect = rect; }
|
|
|
|
inline wxRect GetDragRect() const { return m_dragRect; }
|
|
|
|
|
|
|
|
//// Whether the drag caused the rectangle to be reversed (e.g.
|
|
|
|
//// dragging the top below the bottom)
|
|
|
|
inline void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; }
|
|
|
|
inline wxSashDragStatus GetDragStatus() const { return m_dragStatus; }
|
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:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSashEvent)
|
1998-09-07 05:27:34 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&);
|
|
|
|
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SASH_DRAGGED(id, fn) \
|
2001-01-31 12:16:40 -05:00
|
|
|
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SASH_DRAGGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL ),
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \
|
2001-01-31 12:16:40 -05:00
|
|
|
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SASH_DRAGGED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL ),
|
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_
|