]> git.saurik.com Git - wxWidgets.git/blame - utils/framelayout/src/rowdragpl.h
fixed a canonical example of Stupid Bug(tm)
[wxWidgets.git] / utils / framelayout / src / rowdragpl.h
CommitLineData
bd9396d5
HH
1/////////////////////////////////////////////////////////////////////////////
2// Name: No names yet.
3// Purpose: Contrib. demo
4// Author: Aleksandras Gluchovas
5// Modified by:
6// Created: 06/10/98
7// RCS-ID: $Id$
8// Copyright: (c) Aleksandras Gluchovas
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef __ROWDRAGPL_G__
13#define __ROWDRAGPL_G__
14
15#include "controlbar.h"
16
17/*
18 * Plugin adds row-dragging fuctionality to the pane.
19 * Handles mouse/movement and pane-background erasing plugin-events.
20 * Behaviour and appearence resembles drag & drop posotioning
21 * of the toolbar-rows int Netscape Comunicator 4.xx.
22 */
23
24class cbRowDragPlugin : public cbPluginBase
25{
26 DECLARE_DYNAMIC_CLASS( cbRowDragPlugin )
27public:
28 // background colours for the highlighted/unhighlighted icons
29
30 wxColour mHightColor; // light-blue for NC-look
31 wxColour mLowColor; // light-gray -/-
32 wxColour mTrianInnerColor; // blue -/-
33 wxPen mTrianInnerPen; // black -/-
34
35protected:
36 friend class cbRowDragPluginSerializer;
37
38 // drag & drop state variables
39 bool mDragStarted;
40 bool mDecisionMode;
41 wxPoint mDragOrigin;
42 int mCurDragOfs;
43 bool mCaptureIsOn;
44
45 // saved margins of the pane
46 int mSvTopMargin;
47 int mSvBottomMargin;
48 int mSvLeftMargin;
49 int mSvRightMargin;
50
51 //on-screen drawing state variables
52 wxBitmap* mpPaneImage;
53 wxBitmap* mpRowImage;
54 wxBitmap* mpCombinedImage;
55
56 wxScreenDC* mpScrDc;
57 wxRect mCombRect;
58 wxSize mRowImgDim;
59 int mInitalRowOfs;
60
61 // NOTE:: if mpRowInFocus is not NULL, then mCollapsedIconInFocus is -1,
62 // and v.v. (two different items cannot be in focus at the same time)
63
64 cbRowInfo* mpRowInFocus;
65 int mCollapsedIconInFocus;
66
67 cbDockPane* mpPane; // is set up temorarely, while handling event
68
69 wxList mHiddenBars;
70
71 wxBitmap* CaptureDCArea( wxDC& dc, wxRect& area );
72
73 // helpers for drag&drop
74
75 int GetHRowsCountForPane( cbDockPane* pPane );
76
77 void SetMouseCapture( bool captureOn );
78 void PrepareForRowDrag();
79 void ShowDraggedRow( int offset );
80 void ShowPaneImage();
81 void FinishOnScreenDraw();
82 void CollapseRow( cbRowInfo* pRow );
83 void ExpandRow( int collapsedIconIdx );
84 void InsertDraggedRowBefore( cbRowInfo* pBeforeRow );
85 bool ItemIsInFocus();
86 void CheckPrevItemInFocus( cbRowInfo* pRow, int iconIdx );
87 void UnhiglightItemInFocus();
88
89 cbRowInfo* GetFirstRow();
90
91 // "hard-coded metafile" for NN-look
92
93 virtual void DrawTrianUp( wxRect& inRect, wxDC& dc );
94 virtual void DrawTrianDown( wxRect& inRect, wxDC& dc );
95 virtual void DrawTrianRight( wxRect& inRect, wxDC& dc );
96 virtual void Draw3DPattern( wxRect& inRect, wxDC& dc );
97 virtual void DrawRombShades( wxPoint& p1, wxPoint& p2, wxPoint& p3, wxPoint& p4, wxDC& dc );
98 virtual void DrawOrtoRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
99 virtual void DrawRomb( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
100 virtual void Draw3DRect( wxRect& inRect, wxDC& dc, wxBrush& bkBrush );
101 virtual void DrawRectShade( wxRect& inRect, wxDC& dc,
102 int level, wxPen& upperPen, wxPen& lowerPen );
103
104 virtual void GetRowHintRect( cbRowInfo* pRow, wxRect& rect );
105 virtual void GetCollapsedInconRect( int iconIdx, wxRect& rect );
106
107 virtual int GetCollapsedIconsPos();
108
109public:
110
111 cbRowDragPlugin(void);
112
113 cbRowDragPlugin( wxFrameLayout* pLayout, int paneMask = wxALL_PANES );
114 virtual ~cbRowDragPlugin();
115
116 virtual cbPluginBase* Clone() { return new cbRowDragPlugin(NULL,0); }
117
118 virtual void OnInitPlugin();
119
120 // handlers for plugin events (appearence-independent logic)
121
122 void OnMouseMove ( cbMotionEvent& event );
123 void OnLButtonDown( cbLeftDownEvent& event );
124 void OnLButtonUp ( cbLeftUpEvent& event );
125 void OnDrawPaneBackground( cbDrawPaneDecorEvent& event );
126
127 // overridables (appearence-depedent)
128
129 virtual void DrawCollapsedRowIcon( int index, wxDC& dc, bool isHighlighted );
130 virtual void DrawCollapsedRowsBorder( wxDC& dc );
131 virtual void DrawRowsDragHintsBorder( wxDC& dc );
132 virtual void DrawRowDragHint( cbRowInfo* pRow, wxDC& dc, bool isHighlighted );
133 virtual void DrawEmptyRow( wxDC& dc, wxRect& rowBounds );
134
135 virtual int GetCollapsedRowIconHeight();
136 virtual int GetRowDragHintWidth();
137
138 virtual void SetPaneMargins();
139
140
141 virtual bool HitTestCollapsedRowIcon( int iconIdx, const wxPoint& pos );
142 virtual bool HitTestRowDragHint( cbRowInfo* pRow, const wxPoint& pos );
143
144 DECLARE_EVENT_TABLE()
145};
146
147// internal helper-class
148
149class cbHiddenBarInfo : public wxObject
150{
151 DECLARE_DYNAMIC_CLASS( cbHiddenBarInfo )
152public:
153 cbBarInfo* mpBar;
154 int mRowNo;
155 int mIconNo;
156 int mAlignment;
157};
158
159#endif