X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/88ac883a0d005437c97a60d8195bd5e4719b1154..7d3f6b4ded6aa412cb1cc306fef478955d448c5b:/include/wx/generic/sashwin.h?ds=inline diff --git a/include/wx/generic/sashwin.h b/include/wx/generic/sashwin.h index 847a4054a5..88af9589e9 100644 --- a/include/wx/generic/sashwin.h +++ b/include/wx/generic/sashwin.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: sashwin.h +// Name: wx/generic/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. @@ -8,16 +8,12 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_SASHWIN_H_G_ #define _WX_SASHWIN_H_G_ -#ifdef __GNUG__ -#pragma interface "sashwin.h" -#endif - #if wxUSE_SASH #include "wx/defs.h" @@ -40,13 +36,20 @@ enum wxSashEdgePosition { * wxSashEdge represents one of the four edges of a window. */ -class WXDLLEXPORT wxSashEdge +class WXDLLIMPEXP_ADV wxSashEdge { public: - wxSashEdge() { m_show = FALSE; m_border = FALSE; m_margin = 0; } + wxSashEdge() + { m_show = false; +#if WXWIN_COMPATIBILITY_2_6 + m_border = false; +#endif + m_margin = 0; } bool m_show; // Is the sash showing? +#if WXWIN_COMPATIBILITY_2_6 bool m_border; // Do we draw a border? +#endif int m_margin; // The margin size }; @@ -54,7 +57,12 @@ public: * wxSashWindow flags */ -#define wxSW_3D 0x0004 +#define wxSW_NOBORDER 0x0000 +//#define wxSW_3D 0x0010 +#define wxSW_BORDER 0x0020 +#define wxSW_3DSASH 0x0040 +#define wxSW_3DBORDER 0x0080 +#define wxSW_3D (wxSW_3DSASH | wxSW_3DBORDER) /* * wxSashWindow allows any of its edges to have a sash which can be dragged @@ -62,49 +70,58 @@ public: * of wxSashWindow. */ -class WXDLLEXPORT wxSashWindow: public wxWindow +class WXDLLIMPEXP_ADV wxSashWindow: public wxWindow { - DECLARE_DYNAMIC_CLASS(wxSashWindow) - public: - -//////////////////////////////////////////////////////////////////////////// -// Public API - // Default constructor - wxSashWindow(); + wxSashWindow() + { + Init(); + } // Normal constructor - wxSashWindow(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = "sashWindow"); - ~wxSashWindow(); + wxSashWindow(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow")) + { + Init(); + Create(parent, id, pos, size, style, name); + } + + virtual ~wxSashWindow(); + + bool Create(wxWindow *parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, long style = wxSW_3D|wxCLIP_CHILDREN, const wxString& name = wxT("sashWindow")); // Set whether there's a sash in this position void SetSashVisible(wxSashEdgePosition edge, bool sash); // Get whether there's a sash in this position - inline bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; } + bool GetSashVisible(wxSashEdgePosition edge) const { return m_sashes[edge].m_show; } +#if WXWIN_COMPATIBILITY_2_6 // Set whether there's a border in this position - inline void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; } + // This value is unused in wxSashWindow. + void SetSashBorder(wxSashEdgePosition edge, bool border) { m_sashes[edge].m_border = border; } // Get whether there's a border in this position - inline bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; } + // This value is unused in wxSashWindow. + bool HasBorder(wxSashEdgePosition edge) const { return m_sashes[edge].m_border; } +#endif // Get border size - inline int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; } + int GetEdgeMargin(wxSashEdgePosition edge) const { return m_sashes[edge].m_margin; } // Sets the default sash border size - inline void SetDefaultBorderSize(int width) { m_borderSize = width; } + void SetDefaultBorderSize(int width) { m_borderSize = width; } // Gets the default sash border size - inline int GetDefaultBorderSize() const { return m_borderSize; } + int GetDefaultBorderSize() const { return m_borderSize; } // Sets the addition border size between child and sash window - inline void SetExtraBorderSize(int width) { m_extraBorderSize = width; } + void SetExtraBorderSize(int width) { m_extraBorderSize = width; } // Gets the addition border size between child and sash window - inline int GetExtraBorderSize() const { return m_extraBorderSize; } + int GetExtraBorderSize() const { return m_extraBorderSize; } virtual void SetMinimumSizeX(int min) { m_minimumPaneSizeX = min; } virtual void SetMinimumSizeY(int min) { m_minimumPaneSizeY = min; } @@ -128,6 +145,11 @@ public: // Adjusts the panes void OnSize(wxSizeEvent& event); +#if defined(__WXMSW__) || defined(__WXMAC__) + // Handle cursor correctly + void OnSetCursor(wxSetCursorEvent& event); +#endif // wxMSW + // Draws borders void DrawBorders(wxDC& dc); @@ -149,7 +171,9 @@ public: // Initialize colours void InitColours(); -protected: +private: + void Init(); + wxSashEdge m_sashes[4]; int m_dragMode; wxSashEdgePosition m_draggingEdge; @@ -170,11 +194,18 @@ protected: wxColour m_darkShadowColour; wxColour m_hilightColour; wxColour m_faceColour; + bool m_mouseCaptured; + wxCursor* m_currentCursor; -DECLARE_EVENT_TABLE() +private: + DECLARE_DYNAMIC_CLASS(wxSashWindow) + DECLARE_EVENT_TABLE() + wxDECLARE_NO_COPY_CLASS(wxSashWindow); }; -#define wxEVT_SASH_DRAGGED (wxEVT_FIRST + 1200) +class WXDLLIMPEXP_FWD_ADV wxSashEvent; + +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_SASH_DRAGGED, wxSashEvent ); enum wxSashDragStatus { @@ -182,35 +213,54 @@ enum wxSashDragStatus wxSASH_STATUS_OUT_OF_RANGE }; -class WXDLLEXPORT wxSashEvent: public wxCommandEvent +class WXDLLIMPEXP_ADV wxSashEvent: public wxCommandEvent { - DECLARE_DYNAMIC_CLASS(wxSashEvent) - - public: - 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; } +public: + wxSashEvent(int id = 0, wxSashEdgePosition edge = wxSASH_NONE) + { + m_eventType = (wxEventType) wxEVT_SASH_DRAGGED; + m_id = id; + m_edge = edge; + } + + wxSashEvent(const wxSashEvent& event) + : wxCommandEvent(event), + m_edge(event.m_edge), + m_dragRect(event.m_dragRect), + m_dragStatus(event.m_dragStatus) { } + + void SetEdge(wxSashEdgePosition edge) { m_edge = edge; } + 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; } + void SetDragRect(const wxRect& rect) { m_dragRect = rect; } + 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; } - private: + void SetDragStatus(wxSashDragStatus status) { m_dragStatus = status; } + wxSashDragStatus GetDragStatus() const { return m_dragStatus; } + + virtual wxEvent *Clone() const { return new wxSashEvent(*this); } + +private: wxSashEdgePosition m_edge; wxRect m_dragRect; wxSashDragStatus m_dragStatus; + +private: + DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSashEvent) }; typedef void (wxEvtHandler::*wxSashEventFunction)(wxSashEvent&); -#define EVT_SASH_DRAGGED(id, fn) { wxEVT_SASH_DRAGGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL }, -#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) { wxEVT_SASH_DRAGGED, id1, id2, (wxObjectEventFunction) (wxEventFunction) (wxSashEventFunction) & fn, NULL }, +#define wxSashEventHandler(func) \ + wxEVENT_HANDLER_CAST(wxSashEventFunction, func) + +#define EVT_SASH_DRAGGED(id, fn) \ + wx__DECLARE_EVT1(wxEVT_SASH_DRAGGED, id, wxSashEventHandler(fn)) +#define EVT_SASH_DRAGGED_RANGE(id1, id2, fn) \ + wx__DECLARE_EVT2(wxEVT_SASH_DRAGGED, id1, id2, wxSashEventHandler(fn)) #endif // wxUSE_SASH