[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]
[XaraXtreme-commits] Commit Complete
Commit by : gerry
Repository : xara
Revision : 1139
Date : Fri May 19 18:47:14 BST 2006
Changed paths:
M /Trunk/XaraLX/Kernel/coldlog.cpp
M /Trunk/XaraLX/Kernel/draginfo.h
M /Trunk/XaraLX/Kernel/ngitem.cpp
M /Trunk/XaraLX/Kernel/sgbitmap.cpp
M /Trunk/XaraLX/Kernel/sgcolour.cpp
M /Trunk/XaraLX/Kernel/sgframe.cpp
M /Trunk/XaraLX/Kernel/sglayer.cpp
M /Trunk/XaraLX/Kernel/sglcart.cpp
M /Trunk/XaraLX/Kernel/sglfills.cpp
M /Trunk/XaraLX/Kernel/sgline.cpp
M /Trunk/XaraLX/Kernel/sgname.cpp
M /Trunk/XaraLX/Kernel/sgtree.cpp
M /Trunk/XaraLX/Kernel/sgtree.h
M /Trunk/XaraLX/wxOil/camframe.cpp
M /Trunk/XaraLX/wxOil/camframe.h
M /Trunk/XaraLX/wxOil/camview.cpp
M /Trunk/XaraLX/wxOil/ccolbar.cpp
M /Trunk/XaraLX/wxOil/dragmgr.cpp
M /Trunk/XaraLX/wxOil/dragmgr.h
M /Trunk/XaraLX/wxOil/sgfonts.cpp
Fixed fast clicks giving button up drags
Diff:
Index: Trunk/XaraLX/Kernel/sgline.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgline.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sgline.cpp (revision 1139)
@@ -776,7 +776,7 @@
GalleryLineDragInfo* pInfo;
pInfo = new GalleryLineDragInfo(this, Mouse, MiscInfo, Mouse->MenuClick);
- if (pInfo != NULL) DragManagerOp::StartDrag(pInfo);
+ if (pInfo != NULL) DragManagerOp::StartDrag(pInfo, GetListWindow());
}
}
Index: Trunk/XaraLX/Kernel/coldlog.cpp
===================================================================
--- Trunk/XaraLX/Kernel/coldlog.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/coldlog.cpp (revision 1139)
@@ -3284,7 +3284,7 @@
{
ColourDragInformation *DragCol;
DragCol = new ColourDragInformation(TheColour, FALSE, (Document *)ParentList->GetParentDocument());
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, GetReadWriteWindowID());
}
}
*/
@@ -6940,7 +6940,7 @@
{
ColEditorDragInfo *DragCol;
DragCol = new ColEditorDragInfo(TheColour, FALSE, (Document *)ParentList->GetParentDocument());
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, GetReadWriteWindowID());
}
return; // Don't pass the call on to the picker
Index: Trunk/XaraLX/Kernel/sgtree.h
===================================================================
--- Trunk/XaraLX/Kernel/sgtree.h (revision 1138)
+++ Trunk/XaraLX/Kernel/sgtree.h (revision 1139)
@@ -105,8 +105,6 @@
#include "doccolor.h"
#endif
-
-
// Pre-declarations
class Document; // defined in document.h
class Library; // defined in sgscan.h
@@ -772,6 +770,8 @@
void DrawBitmap(RenderRegion *Renderer, DocRect *BoundsRect, UINT32 ResID);
// Draw a kernel-bitmap-resource bitmap into the gallery window
+ CWindowID GetListWindow(void);
+ // Gets the list box window (for starting drags)
protected: // Derived class methods for background-redraw support
virtual void RegisterForBGRedraw(void);
@@ -1130,11 +1130,6 @@
-
-
-
-
-
/***********************************************************************************************
> class SGDisplayRoot : public SGDisplayNode
Index: Trunk/XaraLX/Kernel/sglayer.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sglayer.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sglayer.cpp (revision 1139)
@@ -1031,7 +1031,7 @@
SGListDragInfo* pDragInfo = new SGListDragInfo(ParentGallery,this,Mouse,Mouse->MenuClick);
if (pDragInfo != NULL)
- DragManagerOp::StartDrag(pDragInfo);
+ DragManagerOp::StartDrag(pDragInfo, GetParentGallery()->GetReadWriteWindowID());
}
return(TRUE); // Claim this event - nobody else can own this click
Index: Trunk/XaraLX/Kernel/sgname.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgname.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sgname.cpp (revision 1139)
@@ -473,7 +473,7 @@
GalleryNameDragInfo* pInfo =
new GalleryNameDragInfo(this, pMouse, pMiscInfo, pAttrib,
pMouse->MenuClick);
- if (pInfo != 0) DragManagerOp::StartDrag(pInfo);
+ if (pInfo != 0) DragManagerOp::StartDrag(pInfo, GetListWindow());
}
}
Index: Trunk/XaraLX/Kernel/sglcart.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sglcart.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sglcart.cpp (revision 1139)
@@ -2740,7 +2740,7 @@
DragClipart = new GalleryClipartDragInfo(this, Mouse, MiscInfo,
Mouse->MenuClick, XSize, YSize);
if (DragClipart != NULL)
- DragManagerOp::StartDrag(DragClipart);
+ DragManagerOp::StartDrag(DragClipart, GetListWindow());
else
{
if(LibClipartSGallery::TmpDraggingBitmap != NULL)
Index: Trunk/XaraLX/Kernel/draginfo.h
===================================================================
--- Trunk/XaraLX/Kernel/draginfo.h (revision 1138)
+++ Trunk/XaraLX/Kernel/draginfo.h (revision 1139)
@@ -125,7 +125,7 @@
class CCAPI DragInformation : public CCObject
{
friend class DragManagerOp;
- friend class CaptureWnd;
+ friend class CaptureHandler;
CC_DECLARE_DYNCREATE(DragInformation)
Index: Trunk/XaraLX/Kernel/sgtree.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgtree.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sgtree.cpp (revision 1139)
@@ -2803,6 +2803,26 @@
/***********************************************************************************************
+> CWindowID SGDisplayNode::GetListWindow(void)
+
+ Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 18/05/2006
+
+ Purpose: Returns the window id of the list box window of the parent gallery
+
+ SeeAlso: -
+
+***********************************************************************************************/
+
+CWindowID SGDisplayNode::GetListWindow(void)
+{
+ return(DialogManager::GetGadget(GetParentGallery()->GetReadWriteWindowID(), GetParentGallery()->GetListGadgetID()));
+}
+
+
+
+/***********************************************************************************************
+
> virtual void SGDisplayNode::DumpSubtree(INT32 TreeLevel = 1)
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
@@ -4193,7 +4213,7 @@
MouseInfo->MenuClick);
if (DragInfo != NULL)
- DragManagerOp::StartDrag(DragInfo);
+ DragManagerOp::StartDrag(DragInfo, GetListWindow());
}
}
break;
@@ -5104,7 +5124,7 @@
DragGroup = new SGListDragInfo(GetParentGallery(), this,
Mouse, Mouse->MenuClick);
if (DragGroup != NULL)
- DragManagerOp::StartDrag(DragGroup);
+ DragManagerOp::StartDrag(DragGroup, GetListWindow());
// The DragWasReallyAClick handler will take care of clicks
}
}
Index: Trunk/XaraLX/Kernel/sglfills.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sglfills.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sglfills.cpp (revision 1139)
@@ -287,7 +287,7 @@
// the fills to his hard disk:
if(CResDll::GetExecutablePath((TCHAR*)DefaultLibraryPath))
{
- // Look for the resources in the main Xara X¹ folder first
+ // Look for the resources in the main Xara X folder first
String_256 LibDirName;
GetLibraryDirectoryName(&LibDirName);
DefaultLibraryPath += "\";
@@ -1849,7 +1849,7 @@
DragFill = new GalleryFillsDragInfo(this, Mouse, MiscInfo,
Mouse->MenuClick, XSize, YSize);
if (DragFill != NULL)
- DragManagerOp::StartDrag(DragFill);
+ DragManagerOp::StartDrag(DragFill, GetListWindow());
else
if(LibraryGallery::TmpDraggingBitmap != NULL)
{
Index: Trunk/XaraLX/Kernel/sgframe.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgframe.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sgframe.cpp (revision 1139)
@@ -862,7 +862,7 @@
SGListDragInfo* pDragInfo = new SGListDragInfo(ParentGallery,this,Mouse,Mouse->MenuClick);
if (pDragInfo != NULL)
- DragManagerOp::StartDrag(pDragInfo);
+ DragManagerOp::StartDrag(pDragInfo, GetListWindow());
}
return(TRUE); // Claim this event - nobody else can own this click
Index: Trunk/XaraLX/Kernel/sgcolour.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgcolour.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sgcolour.cpp (revision 1139)
@@ -1331,7 +1331,7 @@
Mouse->MenuClick);
if (DragCol != NULL)
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, GetListWindow());
}
}
@@ -1851,7 +1851,7 @@
DragCol = new GalleryColourDragInfo(this, Mouse, MiscInfo, Mouse->MenuClick);
if (DragCol != NULL)
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, GetListWindow());
}
}
Index: Trunk/XaraLX/Kernel/sgbitmap.cpp
===================================================================
--- Trunk/XaraLX/Kernel/sgbitmap.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/sgbitmap.cpp (revision 1139)
@@ -1379,7 +1379,7 @@
DragBmp = new GalleryBitmapDragInfo(this, Mouse, MiscInfo,
Mouse->MenuClick);
if (DragBmp != NULL)
- DragManagerOp::StartDrag(DragBmp);
+ DragManagerOp::StartDrag(DragBmp, GetListWindow());
}
return(TRUE); // Claim this event - nobody else can own this click
Index: Trunk/XaraLX/Kernel/ngitem.cpp
===================================================================
--- Trunk/XaraLX/Kernel/ngitem.cpp (revision 1138)
+++ Trunk/XaraLX/Kernel/ngitem.cpp (revision 1139)
@@ -883,7 +883,7 @@
// a drag operation.
SGNameDrag* pDragInfo = new SGNameDrag(this, pMouseInfo, pMiscInfo);
ERRORIF(pDragInfo == 0, _R(IDE_NOMORE_MEMORY), FALSE);
- DragManagerOp::StartDrag(pDragInfo);
+ DragManagerOp::StartDrag(pDragInfo, GetListWindow());
}
else
#endif
Index: Trunk/XaraLX/wxOil/ccolbar.cpp
===================================================================
--- Trunk/XaraLX/wxOil/ccolbar.cpp (revision 1138)
+++ Trunk/XaraLX/wxOil/ccolbar.cpp (revision 1139)
@@ -4671,7 +4671,7 @@
#endif
}
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, this);
#endif
return;
}
@@ -4688,7 +4688,7 @@
ColourDragInformation * DragCol;
DragCol = new ColourDragInformation(NULL, (Modifier < 0),
Document::GetSelected());
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, this);
#endif
break;
@@ -4742,7 +4742,7 @@
ColourDragInformation *DragCol;
DragCol = new ColourDragInformation(IndexedColToDrag, (Modifier < 0),
Document::GetSelected());
- DragManagerOp::StartDrag(DragCol);
+ DragManagerOp::StartDrag(DragCol, this);
}
#endif
break;
@@ -5408,18 +5408,17 @@
// ASSERT_VALID(TheColourBar);
ERROR3IF(Result == NULL, _T("CColourBar::GetStatusLineText - NULL Result parameter is bad"));
- wxPoint TempPos = ::wxGetMousePosition();
+ wxPoint ScreenPos = ::wxGetMousePosition();
- wxPoint Pos(TempPos);
- if (::wxChildWindowFromPoint(Pos, FALSE, -1) != TheColourBar)
+ if (::wxChildWindowFromPoint(ScreenPos, false, -1) != TheColourBar)
return(FALSE);
- Pos = TheColourBar->ScreenToClient(Pos); // make relative to window
+ wxPoint ClientPos = TheColourBar->ScreenToClient(ScreenPos); // make relative to window
static String_64 HelpStringStore;
// StringBase *HelpString = NULL;
- INT32 Item = TheColourBar->WhereIsMouse(Pos);
+ INT32 Item = TheColourBar->WhereIsMouse(ClientPos);
if (Item >= CLICKED_NOTHING)
{
switch(Item)
Index: Trunk/XaraLX/wxOil/camview.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camview.cpp (revision 1138)
+++ Trunk/XaraLX/wxOil/camview.cpp (revision 1139)
@@ -1863,9 +1863,8 @@
if (!HRuler||!VRuler||!OGadget)
return OVER_NO_RULERS;
- // get the mouse position in screen coords
- wxPoint ScrMousePos = ::wxGetMousePosition();
- wxWindow* pWindow = ::wxChildWindowFromPoint(ScrMousePos, FALSE, -1);
+ // Find the window the pointer is over
+ wxWindow* pWindow = ::wxChildWindowFromPoint(::wxGetMousePosition(), false, -1);
// check the HWND against the rulers
if (pWindow == (wxWindow*)HRuler)
Index: Trunk/XaraLX/wxOil/camframe.h
===================================================================
--- Trunk/XaraLX/wxOil/camframe.h (revision 1138)
+++ Trunk/XaraLX/wxOil/camframe.h (revision 1139)
@@ -124,8 +124,6 @@
wxRect m_WndRect; // Used to remember the unmin/maximised position
- CaptureWnd* m_pCaptureWnd;
-
public:
CCamFrame( wxDocManager *manager, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size,
long type ); /* TYPENOTE: Correct */
@@ -151,9 +149,6 @@
/// Creates the controls and sizers
void CreateControls();
- void StartDragManagerDrag(CaptureWnd* pWnd);
- void EndDragManagerDrag(CaptureWnd* pWnd);
-
void UpdateWndSize();
#if !defined(USE_WXAUI)
@@ -162,10 +157,6 @@
#endif
void OnCloseWindow(wxCloseEvent& event);
- void OnMouseMove(wxMouseEvent& event);
- void OnLButtonUp(wxMouseEvent& event);
- void OnRButtonUp(wxMouseEvent& event);
-
void OnMenuCommand ( wxCommandEvent& event );
void OnZoomIn ( wxCommandEvent& event );
Index: Trunk/XaraLX/wxOil/sgfonts.cpp
===================================================================
--- Trunk/XaraLX/wxOil/sgfonts.cpp (revision 1138)
+++ Trunk/XaraLX/wxOil/sgfonts.cpp (revision 1139)
@@ -1479,7 +1479,7 @@
}
if (DragFont != NULL)
- DragManagerOp::StartDrag(DragFont);
+ DragManagerOp::StartDrag(DragFont, GetListWindow());
}
return(TRUE); // Claim this event - nobody else can own this click
}
@@ -6705,7 +6705,7 @@
}
if (DragFont != NULL)
- DragManagerOp::StartDrag(DragFont);
+ DragManagerOp::StartDrag(DragFont, GetListWindow());
}
return TRUE; // Claim this event - nobody else can own this click
}
Index: Trunk/XaraLX/wxOil/dragmgr.h
===================================================================
--- Trunk/XaraLX/wxOil/dragmgr.h (revision 1138)
+++ Trunk/XaraLX/wxOil/dragmgr.h (revision 1139)
@@ -110,33 +110,33 @@
/********************************************************************************************
-> class CaptureWnd : public CWnd
+> class CaptureHandler : public CWnd
- Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 13/01/95
- Purpose: A hidden window to centralise all click detection during a drag
+ Purpose: An event handler to centralise the mouse handling during a drag
SeeAlso:
********************************************************************************************/
-class CaptureWnd : public wxFrame
+class CaptureHandler : public wxEvtHandler
{
- DECLARE_DYNAMIC_CLASS(CaptureWnd)
+ DECLARE_DYNAMIC_CLASS(CaptureHandler)
friend class DragManagerOp;
friend class DragInformation;
- public:
- CaptureWnd();
- ~CaptureWnd();
- BOOL Create();
+public:
+ CaptureHandler(wxWindow* pWindow = NULL);
+ ~CaptureHandler();
- void OnWindowCreate(wxWindowCreateEvent& event);
void OnMouseMove(wxMouseEvent& event);
void OnLButtonUp(wxMouseEvent& event);
void OnRButtonUp(wxMouseEvent& event);
public:
+ BOOL StartCapture();
+
BOOL SetUpSolidDrag(wxPoint StartPos);
BOOL CleanUpSolidDrag();
@@ -148,13 +148,15 @@
BOOL DrawTransparentDrag(wxPoint point, INT32 Transparency);
protected:
- wxScreenDC* pDisplayDC;
+ wxWindow* m_pWindow;
+ BOOL m_bHasCapture;
+ wxScreenDC* m_pDisplayDC;
- wxBitmap* BackBitmap;
- wxRect DragRect;
+ wxBitmap* m_pBackBitmap;
+ wxRect m_DragRect;
// Some things for semi-transparent drags
- wxBitmap* MaskBitmap;
+ wxBitmap* m_pMaskBitmap;
DECLARE_EVENT_TABLE()
};
@@ -184,7 +186,7 @@
friend class DragTarget;
friend class KernelDragTarget;
friend class OilDragTarget;
-friend class CaptureWnd;
+friend class CaptureHandler;
friend class DragInformation;
CC_DECLARE_DYNCREATE(DragManagerOp)
@@ -198,7 +200,7 @@
public: // External drag management methods
- static void StartDrag(DragInformation *Descriptor);
+ static void StartDrag(DragInformation *Descriptor, CWindowID DragWindow);
// To start a drag going
static void EndDrag(INT32 Flags);
@@ -211,7 +213,7 @@
// Returns NULL, or a pointer to the current drag manager
static BOOL GetStatusText(String_256 * StatusText);
- static CaptureWnd * GetDragCaptureWnd();
+ static CaptureHandler * GetDragCaptureHandler();
static DragInformation * GetCurrentDragInfo();
@@ -275,7 +277,7 @@
DragEventType LastEvent; // Type of the last Drag Event processed
- static CaptureWnd * TheCaptureWindow; // The window we use to centralised mouse handling
+ static CaptureHandler * TheCaptureHandler; // The event handler we use to centralised mouse handling
static BOOL DragPending; // Drag pending flag ie. this may be a click !
Index: Trunk/XaraLX/wxOil/camframe.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camframe.cpp (revision 1138)
+++ Trunk/XaraLX/wxOil/camframe.cpp (revision 1139)
@@ -166,9 +166,6 @@
IMPLEMENT_CLASS( CCamFrame, wxDocMDIParentFrame )
BEGIN_EVENT_TABLE( CCamFrame, wxDocMDIParentFrame )
- EVT_LEFT_UP( CCamFrame::OnLButtonUp )
- EVT_RIGHT_UP( CCamFrame::OnRButtonUp )
- EVT_MOTION( CCamFrame::OnMouseMove )
EVT_MENU_RANGE( AUTO_MENU_ID_MIN, AUTO_MENU_ID_MAX, CCamFrame::OnMenuCommand )
@@ -250,7 +247,6 @@
#if defined(USE_WXAUI)
m_pFrameManager = NULL;
#endif
- m_pCaptureWnd = NULL;
m_pStatusBar = NULL;
Create( frame, wxID_ANY, title, pos, size, type );
@@ -499,88 +495,6 @@
/***************************************************************************************************************************/
-
-void CCamFrame::StartDragManagerDrag(CaptureWnd* pWnd)
-{
- TRACEUSER("Gerry", _T("StartDragManagerDrag"));
- // Vector mouse capture related stuff to this "window"
-
- if (HasCapture())
- {
- TRACEUSER("Gerry", _T("Already got capture"));
- }
-
- CaptureMouse();
-
- if (HasCapture())
- {
- TRACEUSER("Gerry", _T("Got capture"));
- m_pCaptureWnd = pWnd;
- }
-}
-
-
-void CCamFrame::EndDragManagerDrag(CaptureWnd* pWnd)
-{
- TRACEUSER("Gerry", _T("EndDragManagerDrag"));
- if (m_pCaptureWnd)
- {
- ERROR3IF(m_pCaptureWnd != pWnd, "EndDrag different window to StartDrag");
-
- m_pCaptureWnd = NULL;
- if (HasCapture())
- {
- ReleaseMouse();
- if (HasCapture())
- {
- TRACEUSER("Gerry", _T("Still got capture"));
- }
- else
- {
- TRACEUSER("Gerry", _T("Capture released"));
- }
-
- }
- else
- {
- TRACEUSER("Gerry", _T("Haven't got capture"));
- }
- }
- else
- {
- TRACEUSER("Gerry", _T("No CaptureWnd"));
- }
-}
-
-
-void CCamFrame::OnLButtonUp(wxMouseEvent& event)
-{
- TRACEUSER("Gerry", _T("CCamFrame::OnLButtonUp"));
- if (m_pCaptureWnd)
- m_pCaptureWnd->OnLButtonUp(event);
- else
- event.Skip();
-}
-
-void CCamFrame::OnRButtonUp(wxMouseEvent& event)
-{
- TRACEUSER("Gerry", _T("CCamFrame::OnRButtonUp"));
- if (m_pCaptureWnd)
- m_pCaptureWnd->OnRButtonUp(event);
- else
- event.Skip();
-}
-
-void CCamFrame::OnMouseMove(wxMouseEvent& event)
-{
- if (m_pCaptureWnd)
- m_pCaptureWnd->OnMouseMove(event);
- else
- event.Skip();
-}
-
-
-
void CCamFrame::UpdateWndSize()
{
if (!IsIconized() && !IsMaximized())
Index: Trunk/XaraLX/wxOil/dragmgr.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dragmgr.cpp (revision 1138)
+++ Trunk/XaraLX/wxOil/dragmgr.cpp (revision 1139)
@@ -112,7 +112,6 @@
#include "oilcoord.h"
#include "camframe.h"
#include "cursor.h"
-//#include "resource.h"
#include "gbrush.h"
#include "grndrgn.h"
@@ -120,51 +119,48 @@
#include "osrndrgn.h"
CC_IMPLEMENT_DYNCREATE(DragManagerOp, Operation)
-IMPLEMENT_DYNAMIC_CLASS(CaptureWnd, wxFrame)
+IMPLEMENT_DYNAMIC_CLASS(CaptureHandler, wxEvtHandler)
#define new CAM_DEBUG_NEW
-// Define this to make drag captures use the methods in CCamFrame rather than creating a CaptureWnd
-// This is currently required to make this stuff work on wxGTK.
-#define DRAG_MAINFRAME
-
//------------------------------------------------------------------------------------------
-// CaptureWnd
+// CaptureHandler
//------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
-// CaptureWnd Message map - maintained by Class Wizard NOT !!!.
+// CaptureHandler event table
-BEGIN_EVENT_TABLE( CaptureWnd, wxFrame )
- EVT_LEFT_UP( CaptureWnd::OnLButtonUp )
- EVT_RIGHT_UP( CaptureWnd::OnRButtonUp )
- EVT_MOTION( CaptureWnd::OnMouseMove )
- EVT_WINDOW_CREATE( CaptureWnd::OnWindowCreate)
+BEGIN_EVENT_TABLE( CaptureHandler, wxEvtHandler )
+ EVT_LEFT_UP( CaptureHandler::OnLButtonUp )
+ EVT_RIGHT_UP( CaptureHandler::OnRButtonUp )
+ EVT_MOTION( CaptureHandler::OnMouseMove )
END_EVENT_TABLE()
/********************************************************************************************
-> CaptureWnd::CaptureWnd()
+> CaptureHandler::CaptureHandler()
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 9/1/95
- Purpose: CaptureWnd constructor
+ Purpose: CaptureHandler constructor
********************************************************************************************/
-CaptureWnd::CaptureWnd()
+CaptureHandler::CaptureHandler(wxWindow* pWindow)
{
-// TRACEUSER("Gerry", _T("CaptureWnd::CaptureWnd"));
- pDisplayDC = NULL;
- BackBitmap = NULL;
- MaskBitmap = NULL;
+// TRACEUSER("Gerry", _T("CaptureHandler::CaptureHandler"));
+ m_pWindow = pWindow;
+ m_bHasCapture = FALSE;
+ m_pDisplayDC = NULL;
+ m_pBackBitmap = NULL;
+ m_pMaskBitmap = NULL;
}
/********************************************************************************************
-> CaptureWnd::~CaptureWnd()
+> CaptureHandler::~CaptureHandler()
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 9/1/95
@@ -173,69 +169,103 @@
********************************************************************************************/
-CaptureWnd::~CaptureWnd()
+CaptureHandler::~CaptureHandler()
{
-// TRACEUSER("Gerry", _T("CaptureWnd::~CaptureWnd"));
-// // Need to clean up all the pointers here...
+// TRACEUSER("Gerry", _T("CaptureHandler::~CaptureHandler"));
+ // Need to clean up all the pointers here...
+
+ if (m_bHasCapture)
+ {
+ if (m_pWindow->PopEventHandler() != this)
+ {
+ TRACEUSER("Gerry", _T("Popped event handler is not this one, expect a crash"));
+ }
+
+ if (m_pWindow->HasCapture())
+ {
+ m_pWindow->ReleaseMouse();
+ if (m_pWindow->HasCapture())
+ {
+ TRACEUSER("Gerry", _T("Still got capture"));
+ }
+ else
+ {
+ TRACEUSER("Gerry", _T("Capture released"));
+ }
+ }
+ else
+ {
+ TRACEUSER("Gerry", _T("Haven't got capture"));
+ }
+ m_bHasCapture = FALSE;
+ }
}
-
/********************************************************************************************
-> BOOL CaptureWnd::Create()
+> BOOL CaptureHandler::StartCapture()
- Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 9/1/95
+ Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 18/05/2006
- Purpose: Create a hidden window to capture all mouse input during drags
+ Purpose: Attaches us to the window and starts mouse capture
********************************************************************************************/
-BOOL CaptureWnd::Create()
+BOOL CaptureHandler::StartCapture()
{
-// TRACEUSER("Gerry", _T("CaptureWnd::Create"));
- BOOL WindowCreated = FALSE;
+ TRACEUSER("Gerry", _T("CaptureHandler::StartCapture"));
+ if (m_pWindow && !m_bHasCapture)
+ {
+ if (m_pWindow->HasCapture())
+ {
+ TRACEUSER("Gerry", _T("Already got capture"));
+ }
- WindowCreated = wxFrame::Create(NULL, wxID_ANY, wxString(_T("")), wxPoint(0, 0), wxSize(20, 20), 0);
- ERROR2IF(!WindowCreated, FALSE, _T("Couldn't create a capture window for the drag manager"));
+ m_pWindow->CaptureMouse();
- // Defer this to OnCreate so it might work
-// CaptureMouse();
+ if (m_pWindow->HasCapture())
+ {
+ TRACEUSER("Gerry", _T("Got capture"));
+ m_bHasCapture = true;
+ m_pWindow->PushEventHandler(this);
+ }
+ }
- Show();
-
- return TRUE;
+ return(TRUE);
}
+
//-------------------------------------------------------------------------------------------
-// Capture Window Message Handlers
+// CaptureHandler Message Handlers
//-------------------------------------------------------------------------------------------
-/*********************************************************************************************
-> void CaptureWnd::OnWindowCreate(wxWindowCreateEvent &event)
+/********************************************************************************************
- Author: Gerry_Iles (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 10/03/06
- Inputs: -
- Outputs: -
- Returns: -
- Purpose: Redraws the colour bar
+> void CaptureHandler::OnLButtonUp(wxMouseEvent& event)
+
+ Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
+ Created: 12/01/95
+ Inputs: MFC
+ Purpose:
Errors: -
+ SeeAlso: -
-**********************************************************************************************/
+********************************************************************************************/
+void CaptureHandler::OnLButtonUp(wxMouseEvent& event)
+{
+ TRACEUSER("Gerry", _T("CaptureHandler::OnLButtonUp"));
+ DragManagerOp::EndDrag(1);// 1 == left click for now
-void CaptureWnd::OnWindowCreate(wxWindowCreateEvent &event)
-{
-// TRACEUSER("Gerry", _T("CaptureWnd::OnWindowCreate"));
- CaptureMouse();
- event.Skip();
+ // Don't call Skip as the window wont be expecting the button up
+// event.Skip();
}
/********************************************************************************************
-> void CaptureWnd::OnLButtonUp(wxMouseEvent& event)
+> void CaptureHandler::OnRButtonUp(wxMouseEvent& event)
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 12/01/95
@@ -245,16 +275,19 @@
SeeAlso: -
********************************************************************************************/
-void CaptureWnd::OnLButtonUp(wxMouseEvent& event)
+void CaptureHandler::OnRButtonUp(wxMouseEvent& event)
{
- TRACEUSER("Gerry", _T("CaptureWnd::OnLButtonUp"));
- DragManagerOp::EndDrag(1);// 1 == left click for now
- event.Skip();
+ TRACEUSER("Gerry", _T("CaptureHandler::OnRButtonUp"));
+ DragManagerOp::EndDrag(-1);// -1 == Right click for now
+
+ // Don't call Skip as the window wont be expecting the button up
+// event.Skip();
}
+
/********************************************************************************************
-> void CaptureWnd::SetUpSolidDrag(CPoint StartPos)
+> void CaptureHandler::SetUpSolidDrag(CPoint StartPos)
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 12/01/95
@@ -265,48 +298,47 @@
// ********************************************************************************************/
-BOOL CaptureWnd::SetUpSolidDrag(wxPoint StartPos)
+BOOL CaptureHandler::SetUpSolidDrag(wxPoint StartPos)
{
TRACEUSER("Gerry", _T("SetUpSolidDrag(%d, %d)"), StartPos.x, StartPos.y);
ERROR2IF(DragManagerOp::CurrentManager == NULL ||
DragManagerOp::CurrentManager->CurrentDragInfo == NULL,
FALSE,
- _T("CaptureWnd::SetUpSolidDrag - The current drag manager is invalid"));
+ _T("CaptureHandler::SetUpSolidDrag - The current drag manager is invalid"));
if (!DragManagerOp::CurrentManager->CurrentDragInfo->DoesSolidDrag)
return TRUE;
- if (DragManagerOp::CurrentManager->RedrawInProgress || pDisplayDC != NULL)
+ if (DragManagerOp::CurrentManager->RedrawInProgress || m_pDisplayDC != NULL)
return FALSE;
// get a couple of draggy bits
wxPoint SolidDragOffset = DragManagerOp::CurrentManager->CurrentDragInfo->SolidDragOffset;
wxSize DSize = DragManagerOp::CurrentManager->CurrentDragInfo->SolidDragSize;
- pDisplayDC = new wxScreenDC();
+ m_pDisplayDC = new wxScreenDC();
wxMemoryDC BackGroundDC;
- BackBitmap = new wxBitmap(DSize.x, DSize.y);
+ m_pBackBitmap = new wxBitmap(DSize.x, DSize.y);
- if (pDisplayDC==NULL || BackBitmap == NULL)
+ if (m_pDisplayDC==NULL || m_pBackBitmap == NULL)
{
return FALSE;
}
// Offset the drag from the pointer
- StartPos += SolidDragOffset;
+ wxPoint ClientPos = StartPos + SolidDragOffset;
// select bitmap into the dc
- BackGroundDC.SelectObject(*BackBitmap);
-
-#ifndef DRAG_MAINFRAME
- StartPos = ScreenToClient(StartPos);
-#endif
+ BackGroundDC.SelectObject(*m_pBackBitmap);
+
+ ClientPos = m_pWindow->ScreenToClient(ClientPos);
+
// init drag rect
- DragRect = wxRect(StartPos.x, StartPos.y, DSize.x, DSize.y);
+ m_DragRect = wxRect(ClientPos.x, ClientPos.y, DSize.x, DSize.y);
// blit the screen into the bitmap
- BackGroundDC.Blit(0,0,DSize.x,DSize.y,pDisplayDC,DragRect.x,DragRect.y);
+ BackGroundDC.Blit(0,0,DSize.x,DSize.y,m_pDisplayDC,m_DragRect.x,m_DragRect.y);
BackGroundDC.SelectObject(wxNullBitmap);
@@ -391,43 +423,42 @@
if (pTransparentMask)
delete pTransparentMask;
- MaskBitmap=new wxBitmap(MaskImage, 1);
- if (MaskBitmap)
+ m_pMaskBitmap = new wxBitmap(MaskImage, 1);
+ if (m_pMaskBitmap)
{
// Now combine the DragMask with the transparency mask.
if (DragMask)
{
-
wxMemoryDC MaskDC;
- MaskDC.SelectObject(*MaskBitmap);
-
+ MaskDC.SelectObject(*m_pMaskBitmap);
+
// This needs to create a wxBitmap from DragMask
// and OR it into the MaskDC
-
+
CWxBitmap* pMaskBmp = (CWxBitmap*)DragMask->ActualBitmap;
RGBQUAD* Palette = (RGBQUAD *) (pMaskBmp->BMInfo->bmiColors);
-
+
// set the first colours to black and white
Palette[0].rgbRed = Palette[0].rgbBlue = Palette[0].rgbGreen = 0;
Palette[1].rgbRed = Palette[1].rgbBlue = Palette[1].rgbGreen = 255;
-
+
// set the reserved bytes to zero
Palette[0].rgbReserved = Palette[1].rgbReserved = 0;
-
+
UINT32 bpp=pMaskBmp->GetBPP();
-
+
wxMemoryDC MemDC;
wxBitmap MemBitmap(DSize.x, DSize.y, bpp);
MemDC.SelectObject(MemBitmap);
-
+
if (bpp>8)
bpp=32;
-
+
LPBYTE MemBBits;
LPBITMAPINFO MemBInfo = AllocDIB(DSize.x, DSize.y, bpp, &MemBBits);
+
+ GRenderRegion::StaticPlotBitmap(&MemDC, DIB_RGB_COLORS, MemBInfo, MemBBits, 0, 0, DSize.x, DSize.y, m_pMaskBitmap->GetPalette(), 0, 0);
- GRenderRegion::StaticPlotBitmap(&MemDC, DIB_RGB_COLORS, MemBInfo, MemBBits, 0, 0, DSize.x, DSize.y, MaskBitmap->GetPalette(), 0, 0);
-
// Now OR the Mask Bitmap into the MaskDC, so that
// it 'masks' the transparency mask.
MaskDC.Blit(0, 0, DSize.x, DSize.y, &MemDC, 0, 0, wxOR);
@@ -440,9 +471,8 @@
}
}
else
- MaskBitmap = NULL;
+ m_pMaskBitmap = NULL;
- StartPos += wxPoint(-SolidDragOffset.x, -SolidDragOffset.y);
DrawSolidDrag(StartPos);
return TRUE;
@@ -452,7 +482,7 @@
/********************************************************************************************
-> BOOL CaptureWnd::CleanUpSolidDrag()
+> BOOL CaptureHandler::CleanUpSolidDrag()
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 12/01/95
@@ -465,11 +495,11 @@
whenever someone is redrawing underneath us, and we thus need to remove the
drag stuff while they redraw.
Errors: -
- SeeAlso: CaptureWnd::CleanUpSolidDragInScreenArea
+ SeeAlso: CaptureHandler::CleanUpSolidDragInScreenArea
********************************************************************************************/
-BOOL CaptureWnd::CleanUpSolidDrag()
+BOOL CaptureHandler::CleanUpSolidDrag()
{
TRACEUSER("Gerry", _T("CleanUpSolidDrag"));
@@ -480,45 +510,45 @@
!DragManagerOp::CurrentManager->CurrentDragInfo->DoesSolidDrag)
return TRUE;
- if (pDisplayDC == NULL)
+ if (m_pDisplayDC == NULL)
return FALSE;
- if (BackBitmap)
+ if (m_pBackBitmap)
{
wxMemoryDC BackGroundDC;
// select bitmap into the dc
- BackGroundDC.SelectObject(*BackBitmap);
+ BackGroundDC.SelectObject(*m_pBackBitmap);
// remove the last drag draw (only if we drew something)
if (!DragManagerOp::CurrentManager->DragPending)
{
- pDisplayDC->Blit(DragRect.x,DragRect.y,DragRect.width, DragRect.height,&BackGroundDC,0,0);
+ m_pDisplayDC->Blit(m_DragRect.x,m_DragRect.y,m_DragRect.width, m_DragRect.height,&BackGroundDC,0,0);
}
// clean up and delete the DC's
BackGroundDC.SelectObject(wxNullBitmap);
}
- if (pDisplayDC)
+ if (m_pDisplayDC)
{
- delete pDisplayDC;
- pDisplayDC = NULL;
+ delete m_pDisplayDC;
+ m_pDisplayDC = NULL;
}
- if (BackBitmap)
+ if (m_pBackBitmap)
{
- delete BackBitmap;
- BackBitmap = NULL;
+ delete m_pBackBitmap;
+ m_pBackBitmap = NULL;
}
- if (MaskBitmap)
+ if (m_pMaskBitmap)
{
- delete MaskBitmap;
- MaskBitmap = NULL;
+ delete m_pMaskBitmap;
+ m_pMaskBitmap = NULL;
}
- DragRect = wxRect(0, 0, 0, 0);
+ m_DragRect = wxRect(0, 0, 0, 0);
return TRUE;
}
@@ -527,7 +557,7 @@
/********************************************************************************************
-> BOOL CaptureWnd::CleanUpSolidDragInScreenArea(const wxRect& Area)
+> BOOL CaptureHandler::CleanUpSolidDragInScreenArea(const wxRect& Area)
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 8/5/95
@@ -543,11 +573,11 @@
This can drastically reduce flicker when things are background redrawing
on other parts of the screen.
- SeeAlso: CaptureWnd::CleanUpSolidDrag
+ SeeAlso: CaptureHandler::CleanUpSolidDrag
********************************************************************************************/
-BOOL CaptureWnd::CleanUpSolidDragInScreenArea(const wxRect& Area)
+BOOL CaptureHandler::CleanUpSolidDragInScreenArea(const wxRect& Area)
{
// TRACEUSER("Gerry", _T("CleanUpSolidDragInScreenArea"));
@@ -556,11 +586,11 @@
return(FALSE);
// No solid stuff has yet been drawn, so no need to do anything
- if (DragManagerOp::CurrentManager->DragPending || DragRect.IsEmpty())
+ if (DragManagerOp::CurrentManager->DragPending || m_DragRect.IsEmpty())
return(FALSE);
wxRect Isect(Area);
- if (!Isect.Intersect(DragRect).IsEmpty())
+ if (!Isect.Intersect(m_DragRect).IsEmpty())
{
CleanUpSolidDrag();
return(TRUE);
@@ -573,7 +603,7 @@
/********************************************************************************************
-> void CaptureWnd::OnMouseMove(wxMouseEvent& event)
+> void CaptureHandler::OnMouseMove(wxMouseEvent& event)
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 12/01/95
@@ -584,9 +614,9 @@
********************************************************************************************/
-void CaptureWnd::OnMouseMove(wxMouseEvent& event)
+void CaptureHandler::OnMouseMove(wxMouseEvent& event)
{
-// TRACEUSER("Gerry", _T("CaptureWnd::OnMouseMove"));
+// TRACEUSER("Gerry", _T("CaptureHandler::OnMouseMove"));
// Abort if the system has been disabled (for an error box)
if (CCamApp::IsDisabled())
{
@@ -597,11 +627,7 @@
if (!DragManagerOp::CurrentManager->RedrawInProgress)
{
wxPoint point = event.GetPosition();
-#ifdef DRAG_MAINFRAME
- point = GetMainFrame()->ClientToScreen(point);
-#else
- point = ClientToScreen(point);
-#endif
+ point = m_pWindow->ClientToScreen(point);
DrawSolidDrag(point);
}
}
@@ -610,7 +636,7 @@
/********************************************************************************************
-> void CaptureWnd::DrawSolidDrag(wxPoint point)
+> void CaptureHandler::DrawSolidDrag(wxPoint point)
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 12/01/95
@@ -623,14 +649,14 @@
********************************************************************************************/
-BOOL CaptureWnd::DrawSolidDrag(wxPoint point)
+BOOL CaptureHandler::DrawSolidDrag(wxPoint point)
{
// TRACEUSER("Gerry", _T("DrawSolidDrag(%d, %d)"), point.x, point.y);
ERROR2IF(DragManagerOp::CurrentManager == NULL ||
DragManagerOp::CurrentManager->CurrentDragInfo == NULL,
FALSE,
- "No current drag in CaptureWnd::DrawSolidDrag!");
+ "No current drag in CaptureHandler::DrawSolidDrag!");
// not interested ? ...
if(DragManagerOp::CurrentManager->DragPending)
@@ -643,7 +669,7 @@
GetDragTransparency();
// If the Drag Info says it wants to be transparent,
// then call the transparent drag routine.
- if (DragTransparency > 0 || MaskBitmap != NULL)
+ if (DragTransparency > 0 || m_pMaskBitmap != NULL)
{
if (DrawTransparentDrag(point, DragTransparency))
return TRUE;
@@ -665,7 +691,7 @@
wxMemoryDC BackDC;
// select bitmap into the dc
- BackDC.SelectObject(*BackBitmap);
+ BackDC.SelectObject(*m_pBackBitmap);
// this one is just temp
wxMemoryDC ScratchDC;
@@ -675,15 +701,15 @@
ScratchDC.SelectObject(ScratchBit);
// make copy of last rect
- wxRect OldRect(DragRect);
+ wxRect OldRect(m_DragRect);
// set new drag draw bounds
- DragRect = wxRect(point.x, point.y, DSize.x, DSize.y);
+ m_DragRect = wxRect(point.x, point.y, DSize.x, DSize.y);
// Copy screen to new background
- ScratchDC.Blit(0,0,DSize.x,DSize.y,pDisplayDC,DragRect.x,DragRect.y);
+ ScratchDC.Blit(0,0,DSize.x,DSize.y,m_pDisplayDC,m_DragRect.x,m_DragRect.y);
- wxPoint Change = OldRect.GetPosition() - DragRect.GetPosition();
+ wxPoint Change = OldRect.GetPosition() - m_DragRect.GetPosition();
// Replace part of new bkg with old background
if (!OldRect.IsEmpty())
@@ -691,7 +717,7 @@
// Copy image to screen
DragManagerOp::CurrentManager->CurrentDragInfo->
- OnDrawSolidDrag(DragRect.GetPosition(), pDisplayDC);
+ OnDrawSolidDrag(m_DragRect.GetPosition(), m_pDisplayDC);
// Copy part of image to old background
DragManagerOp::CurrentManager->CurrentDragInfo->
@@ -699,7 +725,7 @@
// Copy old background to screen
if (!OldRect.IsEmpty())
- pDisplayDC->Blit(OldRect.x,OldRect.y,DSize.x,DSize.y,&BackDC,0,0);
+ m_pDisplayDC->Blit(OldRect.x,OldRect.y,DSize.x,DSize.y,&BackDC,0,0);
// copy new background into old for next time round
BackDC.Blit(0,0,DSize.x,DSize.y,&ScratchDC,0,0);
@@ -715,7 +741,7 @@
/********************************************************************************************
-> void CaptureWnd::DrawTransparentDrag(wxPoint point)
+> void CaptureHandler::DrawTransparentDrag(wxPoint point)
Author: Will_Cowling (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 19/03/95
@@ -728,7 +754,7 @@
********************************************************************************************/
-BOOL CaptureWnd::DrawTransparentDrag(wxPoint point, INT32 Transparency)
+BOOL CaptureHandler::DrawTransparentDrag(wxPoint point, INT32 Transparency)
{
// TRACEUSER("Gerry", _T("DrawTransparentDrag(%d, %d, %d)"), point.x, point.y, Transparency);
@@ -743,7 +769,7 @@
wxMemoryDC BackDC;
// select bitmap into the dc
- BackDC.SelectObject(*BackBitmap);
+ BackDC.SelectObject(*m_pBackBitmap);
// this one is just temp
wxMemoryDC ScratchDC;
@@ -758,15 +784,15 @@
ScratchDC.SelectObject(ScratchBit);
// make copy of last rect
- wxRect OldRect = DragRect;
+ wxRect OldRect = m_DragRect;
// set new drag draw bounds
- DragRect = wxRect(point.x,point.y,DSize.x,DSize.y);
+ m_DragRect = wxRect(point.x,point.y,DSize.x,DSize.y);
// Copy screen to new background
- ScratchDC.Blit(0,0,DSize.x,DSize.y,pDisplayDC,DragRect.x,DragRect.y);
+ ScratchDC.Blit(0,0,DSize.x,DSize.y,m_pDisplayDC,m_DragRect.x,m_DragRect.y);
- wxPoint Change = OldRect.GetPosition() - DragRect.GetPosition();
+ wxPoint Change = OldRect.GetPosition() - m_DragRect.GetPosition();
// Replace part of new bkg with old background
if (!OldRect.IsEmpty())
@@ -782,7 +808,7 @@
// TempDC.SetBkColor(RGB(0,0,0));
// TempDC.SetTextColor(RGB(255,255,255));
- MaskDC.SelectObject(*MaskBitmap);
+ MaskDC.SelectObject(*m_pMaskBitmap);
TempDC.Blit(0, 0, DSize.x, DSize.y, &MaskDC, 0, 0, wxAND_INVERT);
@@ -800,11 +826,11 @@
BackDC.Blit(-Change.x,-Change.y, DSize.x, DSize.y, &OffScreenDC, 0,0);
// Copy image to screen
- pDisplayDC->Blit(DragRect.x, DragRect.y, DSize.x, DSize.y, &OffScreenDC, 0, 0);
+ m_pDisplayDC->Blit(m_DragRect.x, m_DragRect.y, DSize.x, DSize.y, &OffScreenDC, 0, 0);
// Copy old background to screen
if(!OldRect.IsEmpty())
- pDisplayDC->Blit(OldRect.x, OldRect.y, DSize.x, DSize.y, &BackDC, 0, 0);
+ m_pDisplayDC->Blit(OldRect.x, OldRect.y, DSize.x, DSize.y, &BackDC, 0, 0);
// copy new background into old for next time round
BackDC.Blit(0, 0, DSize.x, DSize.y, &ScratchDC, 0, 0);
@@ -819,28 +845,7 @@
return TRUE;
}
-/********************************************************************************************
-> void CaptureWnd::OnRButtonUp(wxMouseEvent& event)
-
- Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
- Created: 12/01/95
- Inputs: MFC
- Purpose:
- Errors: -
- SeeAlso: -
-
-********************************************************************************************/
-void CaptureWnd::OnRButtonUp(wxMouseEvent& event)
-{
-// TRACEUSER("Gerry", _T("CaptureWnd::OnRButtonUp"));
- DragManagerOp::EndDrag(-1);// -1 == Right click for now
- event.Skip();
-}
-
-
-
-
//------------------------------------------------------------------------------------------
// Drag ManagerOp
//------------------------------------------------------------------------------------------
@@ -848,7 +853,7 @@
// ----------------- STATICS
DragManagerOp *DragManagerOp::CurrentManager = NULL;
-CaptureWnd *DragManagerOp::TheCaptureWindow = NULL;
+CaptureHandler *DragManagerOp::TheCaptureHandler = NULL;
// Drag delay and distance. These are not the suggested OLE-2 default values, because
// those values are mindbogglingly dumb (2 pixels, which makes it dead easy to accidentally
@@ -996,21 +1001,21 @@
/********************************************************************************************
-> static CaptureWnd * DragManagerOp::GetDragCaptureWnd()
+> static CaptureHandler * DragManagerOp::GetDragCaptureHandler()
Author: Chris_Snook (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 9/1/95
- Purpose: return a CWnd * for the Capture Window
+ Purpose: return the capture handler
********************************************************************************************/
-CaptureWnd *DragManagerOp::GetDragCaptureWnd()
+CaptureHandler *DragManagerOp::GetDragCaptureHandler()
{
if( CurrentManager == NULL )
return NULL;
- return TheCaptureWindow;
+ return TheCaptureHandler;
}
/********************************************************************************************
@@ -1037,7 +1042,7 @@
/********************************************************************************************
-> static void DragManagerOp::StartDrag(DragInformation *Descriptor)
+> static void DragManagerOp::StartDrag(DragInformation *Descriptor, CWindowID DragWindow)
Author: Jason_Williams (Xara Group Ltd) <camelotdev@xxxxxxxx>
Created: 9/1/95
@@ -1045,6 +1050,9 @@
Inputs: Descriptor - A DragInformation object describing the current drag.
NOTE WELL that this is given to the DragManager, who is then responsible
for deleting it when the drag completes. DO NOT DELETE IT!
+ DragWindow - The window that is starting the drag.
+ NOTE: For correct operation under wxGTK this must be the window that
+ received the button down event that started this drag
Purpose: Starts a global-drag off
This will create a new DragManagerOp object, set up the drag, and
@@ -1054,7 +1062,7 @@
********************************************************************************************/
-void DragManagerOp::StartDrag(DragInformation *Descriptor)
+void DragManagerOp::StartDrag(DragInformation *Descriptor, CWindowID DragWindow)
{
if (Descriptor == NULL)
{
@@ -1075,54 +1083,57 @@
pNewManager->CurrentMousePos = wxGetMousePosition();
pNewManager->InitialMousePos = pNewManager->LastMousePos = pNewManager->CurrentMousePos;
- EndDrag(-1);
+ EndDrag(-1);
}
return;
}
- TheCaptureWindow = new CaptureWnd();
-
- if (pNewManager != NULL && TheCaptureWindow != NULL)
+ if (pNewManager != NULL)
{
- DragPending = TRUE;
-
- // Remember where the mouse is at the start of the drag
- pNewManager->CurrentMousePos = wxGetMousePosition();
- pNewManager->InitialMousePos = pNewManager->LastMousePos = pNewManager->CurrentMousePos;
+ // Attach the CaptureHandler to the correct window
+ wxWindow* pWindow = (wxWindow*)DragWindow;
+ if (pWindow == NULL)
+ pWindow = GetMainFrame();
- // Request that all interested parties attach DragTargets now
- BROADCAST_TO_ALL(DragMessage(DragMessage::DRAGSTARTED, pNewManager, Descriptor));
+ TheCaptureHandler = new CaptureHandler(pWindow);
+ if (TheCaptureHandler != NULL)
+ {
+ DragPending = TRUE;
+
+ // Remember where the mouse is at the start of the drag
+ pNewManager->CurrentMousePos = wxGetMousePosition();
+ pNewManager->InitialMousePos = pNewManager->LastMousePos = pNewManager->CurrentMousePos;
- // views don't receive messages so we'll have to do this the hard way..
- // App->Document->View...
- GetApplication()->CreateDragTargets(Descriptor);
-
- // Send an Initialise event to all registered targets
+ // Request that all interested parties attach DragTargets now
+ BROADCAST_TO_ALL(DragMessage(DragMessage::DRAGSTARTED, pNewManager, Descriptor));
+
+ // views don't receive messages so we'll have to do this the hard way..
+ // App->Document->View...
+ GetApplication()->CreateDragTargets(Descriptor);
+
+ // Send an Initialise event to all registered targets
#ifdef _DEBUG
- if (pNewManager->Targets.IsEmpty())
- TRACE( _T("DragManagerOp::StartDrag - No drag targets specified for this drag!"));
+ if (pNewManager->Targets.IsEmpty())
+ TRACE( _T("DragManagerOp::StartDrag - No drag targets specified for this drag!"));
#endif
- pNewManager->ProcessEvent(DRAGEVENT_INITIALISE);
-
- // Create a hidden window to capture mouse events
-#ifdef DRAG_MAINFRAME
- GetMainFrame()->StartDragManagerDrag(TheCaptureWindow);
-#else
- TheCaptureWindow->Create();
-#endif
+ pNewManager->ProcessEvent(DRAGEVENT_INITIALISE);
- // Register for idle events
- GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_HIGH, pNewManager);
+ // Start the mouse capture
+ TheCaptureHandler->StartCapture();
- // get drag start time
- DragStartTimer.Sample();
+ // Register for idle events
+ GetApplication()->RegisterIdleProcessor(IDLEPRIORITY_HIGH, pNewManager);
- // we will use this rect to test whether we have started a drag
- StillClickRect = wxRect( pNewManager->InitialMousePos.x - DragMinDist,
- pNewManager->InitialMousePos.y - DragMinDist,
- DragMinDist * 2,
- DragMinDist * 2);
- SetDragActive(TRUE);
+ // get drag start time
+ DragStartTimer.Sample();
+
+ // we will use this rect to test whether we have started a drag
+ StillClickRect = wxRect( pNewManager->InitialMousePos.x - DragMinDist,
+ pNewManager->InitialMousePos.y - DragMinDist,
+ DragMinDist * 2,
+ DragMinDist * 2);
+ SetDragActive(TRUE);
+ }
}
GetMainFrame()->SetFocus();
}
@@ -1146,14 +1157,9 @@
return;
// clean up
- if (TheCaptureWindow != NULL)
+ if (TheCaptureHandler != NULL)
{
-// If you get a nasty crash in, or otherwise need to debug, the dropping code then
-// you might want to kill the capture here or the debugger wont work very well and
-// you'll need to kill the process
-// GetMainFrame()->EndDragManagerDrag(TheCaptureWindow);
-
- TheCaptureWindow->CleanUpSolidDrag();
+ TheCaptureHandler->CleanUpSolidDrag();
}
if(DragPending) // not a drag - user intended a click
@@ -1210,8 +1216,8 @@
CurrentManager->LastMousePos = CurrentManager->CurrentMousePos;
CurrentManager->CurrentMousePos = wxGetMousePosition();
- if (TheCaptureWindow != NULL)
- TheCaptureWindow->CleanUpSolidDrag();
+ if (TheCaptureHandler != NULL)
+ TheCaptureHandler->CleanUpSolidDrag();
CurrentManager->ProcessEvent(DRAGEVENT_ABORT);
@@ -1302,6 +1308,8 @@
CurrentDragTarget = NULL;
BOOL OverTarget = FALSE;
+// TRACEUSER("Gerry", _T("ProcessEvent = (%d, %d)"), WinoilMousePos.x, WinoilMousePos.y);
+
while (Ptr != NULL)
{
// Copy the mouse position, as each iteration of the loop corrupts it
@@ -1329,18 +1337,23 @@
// We want to do the following. But it doesn't work because GetRect() is relative to the
// parent window when TargetWindow is not a TLW. What we need is (consistently) screen
// coordinates
- // wxRect TargetRect = TargetWindow->GetRect();
- wxSize ClientSize = TargetWindow->GetClientSize();
- wxRect TargetRect (TargetWindow->ClientToScreen(wxPoint(0,0)),
- TargetWindow->ClientToScreen(wxPoint(ClientSize.GetWidth(),
- ClientSize.GetHeight())));
+// TRACEUSER("Gerry", _T("KernelTargetWindow = %s"), TargetWindow->GetClassInfo()->GetClassName());
+ wxRect TargetRect = TargetWindow->GetRect();
+// TRACEUSER("Gerry", _T("TargetRect = (%d, %d) [%d, %d]"), TargetRect.x, TargetRect.y, TargetRect.width, TargetRect.height);
+ if (TargetWindow->GetParent() && !TargetWindow->IsTopLevel())
+ {
+ TargetWindow->GetParent()->ClientToScreen(&TargetRect.x, &TargetRect.y);
+// TRACEUSER("Gerry", _T("TargetRect = (%d, %d) [%d, %d]"), TargetRect.x, TargetRect.y, TargetRect.width, TargetRect.height);
+ }
+// TRACEUSER("Gerry", _T("Point is %sinside"), TargetRect.Inside(WinoilMousePos) ? _T("") : _T("not "));
+
if (BroadcastToAll || Ptr->WantsAllEvents() ||
TargetRect.Inside(WinoilMousePos))
{
// Determine if the pointer is over the target window, or any of its children
- wxWindow* WindowUnderPoint = ::wxChildWindowFromPoint(WinoilMousePos, FALSE, -1);
+ wxWindow* WindowUnderPoint = wxChildWindowFromPoint(WinoilMousePos, false, -1);
BOOL AreOverTargetWnd = (WindowUnderPoint == TargetWindow);
if (!AreOverTargetWnd)
@@ -1368,6 +1381,8 @@
GoAhead = FALSE;
}
+// TRACEUSER("Gerry", _T("%s"), GoAhead ? _T("Process") : _T("Skipping"));
+
if (GoAhead &&
Ptr->ProcessEvent(Event, CurrentDragInfo, &KernelMousePos, CurrentKeypress))
{
@@ -1383,7 +1398,17 @@
wxWindow* TargetWindow;
wxRect TargetRect;
Ptr->GetTargetAreaInfo(&TargetWindow, &TargetRect);
-
+#if FALSE
+ if (TargetWindow)
+ {
+ TRACEUSER("Gerry", _T("OilTargetWindow = %s"), TargetWindow->GetClassInfo()->GetClassName());
+ TRACEUSER("Gerry", _T("TargetRect = (%d, %d) [%d, %d]"), TargetRect.x, TargetRect.y, TargetRect.width, TargetRect.height);
+ }
+ else
+ {
+ TRACEUSER("Gerry", _T("OilTargetWindow = <NONE>"));
+ }
+#endif
wxPoint ClientPoint; // This will be screen coords, or will end up as
ClientPoint.x = WinoilMousePos.x; // client coords if we have a window...
ClientPoint.y = WinoilMousePos.y;
@@ -1400,17 +1425,27 @@
// Don't give the event to oil targets unless the pointer is over the
// window (ie dont pass on events to overlapped windows) unless we want
// to broadcast to all, or this target really wants to know!
-
- wxWindow* WindowUnderPoint = ::wxChildWindowFromPoint(WinoilMousePos, FALSE, -1);
+
+ wxWindow* WindowUnderPoint = ::wxChildWindowFromPoint(WinoilMousePos, false, -1);
+// TRACEUSER("Gerry", _T("WindowUnderPoint = 0x%08x (%s)"), WindowUnderPoint, WindowUnderPoint ? WindowUnderPoint->GetClassInfo()->GetClassName() : _T("null"));
+ if (WindowUnderPoint)
+ {
+// TRACEUSER("Gerry", _T("Title = %s"), WindowUnderPoint->GetTitle().c_str());
+ }
+
BOOL AreOverTargetWnd = (WindowUnderPoint == TargetWindow);
+// TRACEUSER("Gerry", _T("Point is %sover target window"), AreOverTargetWnd ? _T("") : _T("not "));
if (!AreOverTargetWnd)
{
// We're not immediately over the background of the window, but may be over
// a child-window of our window!
- wxWindow* ChildWindowUnderPoint = ::wxChildWindowFromPoint(TargetWindow, WinoilMousePos);
+ wxWindow* ChildWindowUnderPoint = ::wxChildWindowFromPoint(TargetWindow, WinoilMousePos, false, -1);
+// TRACEUSER("Gerry", _T("ChildFromPoint = 0x%08x (%s)"), ChildWindowUnderPoint, ChildWindowUnderPoint ? ChildWindowUnderPoint->GetClassInfo()->GetClassName() : _T("null"));
AreOverTargetWnd = (ChildWindowUnderPoint != NULL &&
ChildWindowUnderPoint == WindowUnderPoint);
+
+// TRACEUSER("Gerry", _T("Point is %sover child of target window"), AreOverTargetWnd ? _T("") : _T("not "));
}
if (!BroadcastToAll && !Ptr->WantsAllEvents() && !AreOverTargetWnd)
@@ -1421,7 +1456,9 @@
else
GoAhead = FALSE;
}
-
+
+// TRACEUSER("Gerry", _T("%s"), GoAhead ? _T("Process") : _T("Skipping"));
+
// we are in a target area, or this is a broadcast-to-all, so send the event
if (GoAhead)
{
@@ -1483,23 +1520,21 @@
// thing yet.
if (DragPending)
{
- // We start a drag if DragDelay milliseconds have elapsed
+ // We start a drag if DragDelay milliseconds have elapsed
// or the pointer has left DragStartRect
- if (!DragStartTimer.Elapsed(DragDelay) &&
- StillClickRect.Inside(CurrentMousePos))
+ if (!DragStartTimer.Elapsed(DragDelay) &&
+ StillClickRect.Inside(CurrentMousePos))
{
// The drag is still pending
return(FALSE); // Done nothing, so let low-priority handlers have a go
}
- DragPending = FALSE;
+ DragPending = FALSE;
JustStartedDrag = TRUE; // Flag that we have "just turned on" the drag
- TheCaptureWindow->SetUpSolidDrag(CurrentMousePos);
+ TheCaptureHandler->SetUpSolidDrag(CurrentMousePos);
}
-
-
// Determine what event type to send around...
DragEventType Event = DRAGEVENT_MOUSEIDLE;
if (LastMousePos == CurrentMousePos)
@@ -1669,19 +1704,16 @@
void DragManagerOp::CleanUpAfterDrag(void)
{
+ TRACEUSER("Gerry", _T("DragManagerOp::CleanUpAfterDrag"));
+
GetApplication()->RemoveIdleProcessor(IDLEPRIORITY_HIGH, this);
- if (TheCaptureWindow != NULL)
+ if (TheCaptureHandler != NULL)
{
-#ifdef DRAG_MAINFRAME
- GetMainFrame()->EndDragManagerDrag(TheCaptureWindow);
- delete TheCaptureWindow;
-#else
- if (TheCaptureWindow->HasCapture())
- TheCaptureWindow->ReleaseMouse();
- TheCaptureWindow->Destroy();
-#endif
- TheCaptureWindow = NULL;
+ TRACEUSER("Gerry", _T("Deleting TheCaptureHandler"));
+ // Simply delete the CaptureHandler and it will detach itself
+ delete TheCaptureHandler;
+ TheCaptureHandler = NULL;
}
if (CurrentDragInfo != NULL)
@@ -1848,7 +1880,7 @@
DragManagerOp::CurrentManager->CurrentDragInfo &&
DragManagerOp::CurrentManager->CurrentDragInfo->DoesSolidDrag)
{
- DragManagerOp::CurrentManager->TheCaptureWindow->CleanUpSolidDrag();
+ DragManagerOp::CurrentManager->TheCaptureHandler->CleanUpSolidDrag();
}
}
@@ -1924,7 +1956,7 @@
// to get it's solid drag stuff out of the way
pGadget->ClientToScreen(&ScreenRect.x, &ScreenRect.y);
- RedrawInProgress = DragManagerOp::CurrentManager->TheCaptureWindow->
+ RedrawInProgress = DragManagerOp::CurrentManager->TheCaptureHandler->
CleanUpSolidDragInScreenArea(ScreenRect);
}
else
@@ -1933,7 +1965,7 @@
else
{
// We failed to get the window area, so we'll have to clean up just in case
- DragManagerOp::CurrentManager->TheCaptureWindow->CleanUpSolidDrag();
+ DragManagerOp::CurrentManager->TheCaptureHandler->CleanUpSolidDrag();
RedrawInProgress = TRUE;
}
}
@@ -1963,6 +1995,6 @@
DragManagerOp::CurrentManager->CurrentDragInfo->DoesSolidDrag)
{
wxPoint LastMousePos = DragManagerOp::CurrentManager->GetDragMousePos();
- DragManagerOp::CurrentManager->TheCaptureWindow->SetUpSolidDrag(LastMousePos);
+ DragManagerOp::CurrentManager->TheCaptureHandler->SetUpSolidDrag(LastMousePos);
}
}
Xara