/////////////////////////////////////////////////////////////////////////////
-// 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__
#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
{
- 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;
+ // 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;
+ // saved margins of the pane
+ int mSvTopMargin;
+ int mSvBottomMargin;
+ int mSvLeftMargin;
+ int mSvRightMargin;
- //on-screen drawing state variables
- wxBitmap* mpPaneImage;
- wxBitmap* mpRowImage;
- wxBitmap* mpCombinedImage;
+ // on-screen drawing state variables
+ wxBitmap* mpPaneImage;
+ wxBitmap* mpRowImage;
+ wxBitmap* mpCombinedImage;
- wxScreenDC* mpScrDc;
- wxRect mCombRect;
- wxSize mRowImgDim;
- int mInitialRowOfs;
+ 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)
+ // 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;
+ cbRowInfo* mpRowInFocus;
+ int mCollapsedIconInFocus;
- cbDockPane* mpPane; // is set up temorarely, while handling event
+ cbDockPane* mpPane; // is set up temorarely, while handling event
- wxList mHiddenBars;
+ wxList mHiddenBars;
- wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area );
+ // Helper for drag and drop.
+ wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area );
- // helpers for drag&drop
+ // Helper for drag and drop.
+ int GetHRowsCountForPane( cbDockPane* pPane );
- int GetHRowsCountForPane( cbDockPane* pPane );
+ // Helper for drag and drop.
+ void SetMouseCapture( bool captureOn );
- 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();
+ // Helper for drag and drop.
+ void PrepareForRowDrag();
- cbRowInfo* GetFirstRow();
+ // Helper for drag and drop.
+ void ShowDraggedRow( int offset );
- // "hard-coded metafile" for NN-look
+ // Helper for drag and drop.
+ void ShowPaneImage();
- 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 );
+ // Helper for drag and drop.
+ void FinishOnScreenDraw();
- virtual void GetRowHintRect( cbRowInfo* pRow, wxRect& rect );
- virtual void GetCollapsedInconRect( int iconIdx, wxRect& rect );
+ // Helper for drag and drop.
+ void CollapseRow( cbRowInfo* pRow );
- virtual int GetCollapsedIconsPos();
+ // Helper for drag and drop.
+ void ExpandRow( int collapsedIconIdx );
+
+ // Helper for drag and drop.
+ void InsertDraggedRowBefore( cbRowInfo* pBeforeRow );
+
+ // Helper for drag and drop.
+ bool ItemIsInFocus();
+
+ // Helper for drag and drop.
+ void CheckPrevItemInFocus( cbRowInfo* pRow, int iconIdx );
+
+ // Helper for drag and drop.
+ void UnhighlightItemInFocus();
+
+ // Helper for drag and drop.
+ cbRowInfo* GetFirstRow();
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawTrianUp( wxRect& inRect, wxDC& dc );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawTrianDown( wxRect& inRect, wxDC& dc );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawTrianRight( wxRect& inRect, wxDC& dc );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void Draw3DPattern( wxRect& inRect, wxDC& dc );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawOrtoRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void Draw3DRect( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
+
+ // Implements 'hard-coded metafile' for Netscape Navigator look.
+ virtual void DrawRectShade( wxRect& inRect, wxDC& dc,
+ int level, wxPen& upperPen, 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
{
- 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__ */