X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8e08b761b0c5ecb6df295785b78f1f3637331887..8d6d408976ba95f69a63bc618897bd416102cbc0:/contrib/include/wx/fl/rowdragpl.h diff --git a/contrib/include/wx/fl/rowdragpl.h b/contrib/include/wx/fl/rowdragpl.h index 6375d4f526..4e57159d9d 100644 --- a/contrib/include/wx/fl/rowdragpl.h +++ b/contrib/include/wx/fl/rowdragpl.h @@ -1,163 +1,226 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo +// Name: rowdragpl.h +// Purpose: cbRowDragPlugin class header. // Author: Aleksandras Gluchovas // Modified by: // Created: 06/10/98 // RCS-ID: $Id$ // Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef __ROWDRAGPL_G__ #define __ROWDRAGPL_G__ -#ifdef __GNUG__ - #pragma interface "rowdragpl.h" -#endif - #include "wx/fl/controlbar.h" /* - * Plugin adds row-dragging fuctionality to the pane. - * Handles mouse/movement and pane-background erasing plugin-events. - * Behaviour and appearence resembles drag & drop posotioning - * of the toolbar-rows int Netscape Comunicator 4.xx. - */ +This plugin adds row-dragging functionality to the pane. +It handles mouse movement and pane background-erasing plugin events. +The behaviour and appearance resembles drag and drop positioning +of the toolbar rows in Netscape Communicator 4.xx. +*/ -class cbRowDragPlugin : public cbPluginBase +class WXDLLIMPEXP_FL cbRowDragPlugin : public cbPluginBase { - DECLARE_DYNAMIC_CLASS( cbRowDragPlugin ) + DECLARE_DYNAMIC_CLASS( cbRowDragPlugin ) public: - // background colours for the highlighted/unhighlighted icons + // background colours for the highlighted/unhighlighted icons - wxColour mHightColor; // light-blue for NC-look - wxColour mLowColor; // light-gray -/- - wxColour mTrianInnerColor; // blue -/- - wxPen mTrianInnerPen; // black -/- + wxColour mHightColor; // light-blue for NC-look + wxColour mLowColor; // light-gray -/- + wxColour mTrianInnerColor; // blue -/- + wxPen mTrianInnerPen; // black -/- protected: - friend class cbRowDragPluginSerializer; + friend class cbRowDragPluginSerializer; + + // drag & drop state variables + bool mDragStarted; + bool mDecisionMode; + wxPoint mDragOrigin; + int mCurDragOfs; + bool mCaptureIsOn; + + // saved margins of the pane + int mSvTopMargin; + int mSvBottomMargin; + int mSvLeftMargin; + int mSvRightMargin; + + // on-screen drawing state variables + wxBitmap* mpPaneImage; + wxBitmap* mpRowImage; + wxBitmap* mpCombinedImage; + + wxScreenDC* mpScrDc; + wxRect mCombRect; + wxSize mRowImgDim; + int mInitialRowOfs; + + // NOTE:: if mpRowInFocus is not NULL, then mCollapsedIconInFocus is -1, + // and v.v. (two different items cannot be in focus at the same time) + + cbRowInfo* mpRowInFocus; + int mCollapsedIconInFocus; + + cbDockPane* mpPane; // is set up temorarely, while handling event + + wxList mHiddenBars; + + // Helper for drag and drop. + wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area ); + + // Helper for drag and drop. + int GetHRowsCountForPane( cbDockPane* pPane ); + + // Helper for drag and drop. + void SetMouseCapture( bool captureOn ); + + // Helper for drag and drop. + void PrepareForRowDrag(); - // drag & drop state variables - bool mDragStarted; - bool mDecisionMode; - wxPoint mDragOrigin; - int mCurDragOfs; - bool mCaptureIsOn; + // Helper for drag and drop. + void ShowDraggedRow( int offset ); - // saved margins of the pane - int mSvTopMargin; - int mSvBottomMargin; - int mSvLeftMargin; - int mSvRightMargin; + // Helper for drag and drop. + void ShowPaneImage(); - //on-screen drawing state variables - wxBitmap* mpPaneImage; - wxBitmap* mpRowImage; - wxBitmap* mpCombinedImage; + // Helper for drag and drop. + void FinishOnScreenDraw(); - wxScreenDC* mpScrDc; - wxRect mCombRect; - wxSize mRowImgDim; - int mInitialRowOfs; + // Helper for drag and drop. + void CollapseRow( cbRowInfo* pRow ); - // NOTE:: if mpRowInFocus is not NULL, then mCollapsedIconInFocus is -1, - // and v.v. (two different items cannot be in focus at the same time) + // Helper for drag and drop. + void ExpandRow( int collapsedIconIdx ); - cbRowInfo* mpRowInFocus; - int mCollapsedIconInFocus; + // Helper for drag and drop. + void InsertDraggedRowBefore( cbRowInfo* pBeforeRow ); - cbDockPane* mpPane; // is set up temorarely, while handling event + // Helper for drag and drop. + bool ItemIsInFocus(); - wxList mHiddenBars; + // Helper for drag and drop. + void CheckPrevItemInFocus( cbRowInfo* pRow, int iconIdx ); - wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area ); + // Helper for drag and drop. + void UnhighlightItemInFocus(); - // helpers for drag&drop + // Helper for drag and drop. + cbRowInfo* GetFirstRow(); - int GetHRowsCountForPane( cbDockPane* pPane ); + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawTrianUp( wxRect& inRect, wxDC& dc ); - void SetMouseCapture( bool captureOn ); - void PrepareForRowDrag(); - void ShowDraggedRow( int offset ); - void ShowPaneImage(); - void FinishOnScreenDraw(); - void CollapseRow( cbRowInfo* pRow ); - void ExpandRow( int collapsedIconIdx ); - void InsertDraggedRowBefore( cbRowInfo* pBeforeRow ); - bool ItemIsInFocus(); - void CheckPrevItemInFocus( cbRowInfo* pRow, int iconIdx ); - void UnhiglightItemInFocus(); + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawTrianDown( wxRect& inRect, wxDC& dc ); - cbRowInfo* GetFirstRow(); + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawTrianRight( wxRect& inRect, wxDC& dc ); - // "hard-coded metafile" for NN-look + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void Draw3DPattern( wxRect& inRect, wxDC& dc ); - virtual void DrawTrianUp( wxRect& inRect, wxDC& dc ); - virtual void DrawTrianDown( wxRect& inRect, wxDC& dc ); - virtual void DrawTrianRight( wxRect& inRect, wxDC& dc ); - virtual void Draw3DPattern( wxRect& inRect, wxDC& dc ); - virtual void DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc ); - virtual void DrawOrtoRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush ); - virtual void DrawRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush ); - virtual void Draw3DRect( wxRect& inRect, wxDC& dc, wxBrush& bkBrush ); - virtual void DrawRectShade( wxRect& inRect, wxDC& dc, - int level, wxPen& upperPen, wxPen& lowerPen ); + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc ); - virtual void GetRowHintRect( cbRowInfo* pRow, wxRect& rect ); - virtual void GetCollapsedInconRect( int iconIdx, wxRect& rect ); + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawOrtoRomb( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush ); - virtual int GetCollapsedIconsPos(); + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawRomb( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush ); + + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void Draw3DRect( wxRect& inRect, wxDC& dc, const wxBrush& bkBrush ); + + // Implements 'hard-coded metafile' for Netscape Navigator look. + virtual void DrawRectShade( wxRect& inRect, wxDC& dc, + int level, const wxPen& upperPen, const wxPen& lowerPen ); + + // Helper for drag and drop. + virtual void GetRowHintRect( cbRowInfo* pRow, wxRect& rect ); + + // Helper for drag and drop. + virtual void GetCollapsedInconRect( int iconIdx, wxRect& rect ); + + // Helper for drag and drop. + virtual int GetCollapsedIconsPos(); public: - cbRowDragPlugin(void); + // Default constructor. + cbRowDragPlugin(); + + // Constructor, taking paren layout frame and pane mask. + cbRowDragPlugin( wxFrameLayout* pLayout, int paneMask = wxALL_PANES ); + + // Destructor. + virtual ~cbRowDragPlugin(); - cbRowDragPlugin( wxFrameLayout* pLayout, int paneMask = wxALL_PANES ); - virtual ~cbRowDragPlugin(); + // Clone function, returning a new instance of this class. + virtual cbPluginBase* Clone() { return new cbRowDragPlugin(NULL,0); } - virtual cbPluginBase* Clone() { return new cbRowDragPlugin(NULL,0); } + // Called to initialize this plugin. + virtual void OnInitPlugin(); - virtual void OnInitPlugin(); + // Handles mouse move plugin events (appearance-independent logic). + void OnMouseMove ( cbMotionEvent& event ); - // handlers for plugin events (appearence-independent logic) + // Handles left button down plugin events (appearance-independent logic). + void OnLButtonDown( cbLeftDownEvent& event ); - void OnMouseMove ( cbMotionEvent& event ); - void OnLButtonDown( cbLeftDownEvent& event ); - void OnLButtonUp ( cbLeftUpEvent& event ); - void OnDrawPaneBackground( cbDrawPaneDecorEvent& event ); + // Handles left button up plugin events (appearance-independent logic). + void OnLButtonUp ( cbLeftUpEvent& event ); - // overridables (appearence-depedent) + // Handles pane drawing plugin events (appearance-independent logic). + void OnDrawPaneBackground( cbDrawPaneDecorEvent& event ); - virtual void DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted ); - virtual void DrawCollapsedRowsBorder( wxDC& dc ); - virtual void DrawRowsDragHintsBorder( wxDC& dc ); - virtual void DrawRowDragHint( cbRowInfo* pRow, wxDC& dc, bool isHighlighted ); - virtual void DrawEmptyRow( wxDC& dc, wxRect& rowBounds ); + // Draws collapsed row icon (appearance-dependent). + virtual void DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted ); - virtual int GetCollapsedRowIconHeight(); - virtual int GetRowDragHintWidth(); + // Draws collapsed rows border (appearance-dependent). + virtual void DrawCollapsedRowsBorder( wxDC& dc ); - virtual void SetPaneMargins(); + // Draws rows drag hints border (appearance-dependent). + virtual void DrawRowsDragHintsBorder( wxDC& dc ); + // Draws row drag hint (appearance-dependent). + virtual void DrawRowDragHint( cbRowInfo* pRow, wxDC& dc, bool isHighlighted ); - virtual bool HitTestCollapsedRowIcon( int iconIdx, const wxPoint& pos ); - virtual bool HitTestRowDragHint( cbRowInfo* pRow, const wxPoint& pos ); + // Draws empty row (appearance-dependent). + virtual void DrawEmptyRow( wxDC& dc, wxRect& rowBounds ); - DECLARE_EVENT_TABLE() + // Gets the collapsed row icon height. + virtual int GetCollapsedRowIconHeight(); + + // Gets the row drag hint width. + virtual int GetRowDragHintWidth(); + + // Sets the pane margins. + virtual void SetPaneMargins(); + + // Test for the collapsed row icon position. + virtual bool HitTestCollapsedRowIcon( int iconIdx, const wxPoint& pos ); + + // Test for the row drag hint position. + virtual bool HitTestRowDragHint( cbRowInfo* pRow, const wxPoint& pos ); + + DECLARE_EVENT_TABLE() }; -// internal helper-class +/* +Internal helper class. +*/ -class cbHiddenBarInfo : public wxObject +class WXDLLIMPEXP_FL cbHiddenBarInfo : public wxObject { - DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo ) + DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo ) public: - cbBarInfo* mpBar; - int mRowNo; - int mIconNo; - int mAlignment; + cbBarInfo* mpBar; + int mRowNo; + int mIconNo; + int mAlignment; }; #endif /* __ROWDRAGPL_G__ */