Partially applied patch [ 531199 ] new EVT_MOVING and EVT_SIZING
Changed to reuse wxMoveEvent, wxSizeEvent Only applied the Mac part as a TODO comment git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20816 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -247,6 +247,8 @@ BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE(wxEVT_INIT_DIALOG, 438)
|
||||
DECLARE_EVENT_TYPE(wxEVT_IDLE, 439)
|
||||
DECLARE_EVENT_TYPE(wxEVT_UPDATE_UI, 440)
|
||||
DECLARE_EVENT_TYPE(wxEVT_SIZING, 441)
|
||||
DECLARE_EVENT_TYPE(wxEVT_MOVING, 4442)
|
||||
|
||||
// Generic command events
|
||||
// Note: a click is a higher-level event than button down/up
|
||||
@@ -932,15 +934,21 @@ public:
|
||||
{ }
|
||||
wxSizeEvent(const wxSizeEvent & event)
|
||||
: wxEvent(event),
|
||||
m_size(event.m_size)
|
||||
m_size(event.m_size), m_rect(event.m_rect)
|
||||
{ }
|
||||
wxSizeEvent(const wxRect& rect, int id = 0)
|
||||
: m_rect(rect), m_size(rect.GetSize())
|
||||
{ m_eventType = wxEVT_SIZING; m_id = id; }
|
||||
|
||||
wxSize GetSize() const { return m_size; }
|
||||
wxRect GetRect() const { return m_rect; }
|
||||
void SetRect(wxRect rect) { m_rect = rect; }
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxSizeEvent(*this); }
|
||||
|
||||
public:
|
||||
wxSize m_size;
|
||||
wxRect m_rect; // Used for wxEVT_SIZING
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSizeEvent)
|
||||
@@ -966,12 +974,18 @@ public:
|
||||
: wxEvent(event),
|
||||
m_pos(event.m_pos)
|
||||
{ }
|
||||
wxMoveEvent(const wxRect& rect, int id = 0)
|
||||
: m_pos(rect.GetPosition()), m_rect(rect)
|
||||
{ m_eventType = wxEVT_MOVING; m_id = id; }
|
||||
|
||||
wxPoint GetPosition() const { return m_pos; }
|
||||
wxRect GetRect() const { return m_rect; }
|
||||
void SetRect(wxRect rect) { m_rect = rect; }
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxMoveEvent(*this); }
|
||||
|
||||
wxPoint m_pos;
|
||||
wxRect m_rect;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxMoveEvent)
|
||||
@@ -2198,7 +2212,9 @@ typedef void (wxEvtHandler::*wxMouseCaptureChangedEventFunction)(wxMouseCaptureC
|
||||
|
||||
// Miscellaneous
|
||||
#define EVT_SIZE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SIZE, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) & func, (wxObject *) NULL ),
|
||||
#define EVT_SIZING(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_SIZING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxSizeEventFunction) & func, (wxObject *) NULL ),
|
||||
#define EVT_MOVE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MOVE, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMoveEventFunction) & func, (wxObject *) NULL ),
|
||||
#define EVT_MOVING(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MOVING, -1, -1, (wxObjectEventFunction) (wxEventFunction) (wxMoveEventFunction) & func, (wxObject *) NULL ),
|
||||
#define EVT_CLOSE(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CLOSE_WINDOW, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
|
||||
#define EVT_END_SESSION(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_END_SESSION, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
|
||||
#define EVT_QUERY_END_SESSION(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_QUERY_END_SESSION, wxID_ANY, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCloseEventFunction) & func, (wxObject *) NULL ),
|
||||
|
@@ -323,6 +323,7 @@ public:
|
||||
bool HandleMinimize();
|
||||
bool HandleMaximize();
|
||||
bool HandleSize(int x, int y, WXUINT flag);
|
||||
bool HandleSizing(wxRect& rect);
|
||||
bool HandleGetMinMaxInfo(void *mmInfo);
|
||||
|
||||
bool HandleShow(bool show, int status);
|
||||
@@ -478,6 +479,7 @@ private:
|
||||
|
||||
// the (non-virtual) handlers for the events
|
||||
bool HandleMove(int x, int y);
|
||||
bool HandleMoving(wxRect& rect);
|
||||
bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
|
||||
|
||||
#ifdef __WIN95__
|
||||
|
@@ -204,7 +204,9 @@ DEFINE_EVENT_TYPE(wxEVT_SCROLLWIN_THUMBRELEASE)
|
||||
|
||||
// System events
|
||||
DEFINE_EVENT_TYPE(wxEVT_SIZE)
|
||||
DEFINE_EVENT_TYPE(wxEVT_SIZING)
|
||||
DEFINE_EVENT_TYPE(wxEVT_MOVE)
|
||||
DEFINE_EVENT_TYPE(wxEVT_MOVING)
|
||||
DEFINE_EVENT_TYPE(wxEVT_CLOSE_WINDOW)
|
||||
DEFINE_EVENT_TYPE(wxEVT_END_SESSION)
|
||||
DEFINE_EVENT_TYPE(wxEVT_QUERY_END_SESSION)
|
||||
|
@@ -349,6 +349,64 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
|
||||
|
||||
// Patch 531199 defined a window event handler, as follows.
|
||||
// TODO: merge the moving/sizing event handling with the event
|
||||
// handler above.
|
||||
#if 0
|
||||
static pascal OSStatus
|
||||
WindowHandler( EventHandlerCallRef inHandler, EventRef inEvent, void* userData )
|
||||
{
|
||||
Rect bounds;
|
||||
SInt16 height, width;
|
||||
UInt32 attributes;
|
||||
OSStatus result = eventNotHandledErr;
|
||||
|
||||
GetEventParameter( inEvent, kEventParamAttributes, typeUInt32, NULL, sizeof( UInt32 ), NULL, &attributes );
|
||||
|
||||
if ((attributes & (kWindowBoundsChangeSizeChanged | kWindowBoundsChangeOriginChanged)) != 0)
|
||||
{
|
||||
// Extract the current bounds. This is the paramter you get to modify to
|
||||
// alter the window position or size during a window resizing.
|
||||
GetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof( bounds ), NULL, &bounds );
|
||||
|
||||
wxRect rect;
|
||||
rect.SetLeft(bounds.left);
|
||||
rect.SetTop(bounds.top);
|
||||
rect.SetRight(bounds.right);
|
||||
rect.SetBottom(bounds.bottom);
|
||||
|
||||
bool rc;
|
||||
wxWindowMac *pWindow = (wxWindowMac*)userData;
|
||||
if ((attributes & kWindowBoundsChangeSizeChanged) != 0) {
|
||||
wxSizeEvent event(rect, pWindow->GetId());
|
||||
event.SetEventObject(pWindow);
|
||||
rc = pWindow->GetEventHandler()->ProcessEvent(event);
|
||||
rect = event.GetRect();
|
||||
}
|
||||
else {
|
||||
wxMoveEvent event(rect, pWindow->GetId());
|
||||
event.SetEventObject(pWindow);
|
||||
rc = pWindow->GetEventHandler()->ProcessEvent(event);
|
||||
rect = event.GetRect();
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
bounds.left = rect.GetLeft();
|
||||
bounds.top = rect.GetTop();
|
||||
bounds.right = rect.GetRight();
|
||||
bounds.bottom = rect.GetBottom();
|
||||
}
|
||||
|
||||
// Set the current bounds parameter to our adjusted bounds. Return
|
||||
// noErr to indicate we handled this event.
|
||||
SetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, sizeof( bounds ), &bounds );
|
||||
result = noErr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
// WindowHandler
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -629,6 +687,17 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
||||
InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
|
||||
InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler));
|
||||
|
||||
// Patch 531199 also defined a window event handler, as follows:
|
||||
#if 0
|
||||
// install a window event handler to send wxEVT_MOVING and wxEVT_SIZING events
|
||||
EventTypeSpec events[] = { { kEventClassWindow, kEventWindowBoundsChanging } };
|
||||
EventHandlerUPP handlerProc = NewEventHandlerUPP( WindowHandler );
|
||||
EventHandlerRef eventHandlerRef;
|
||||
InstallWindowEventHandler( m_macWindowData->m_macWindow, handlerProc, GetEventTypeCount(events),
|
||||
events, (void*)this, &eventHandlerRef);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
m_macFocus = NULL ;
|
||||
|
||||
|
@@ -349,6 +349,64 @@ pascal OSStatus wxMacWindowEventHandler( EventHandlerCallRef handler , EventRef
|
||||
|
||||
DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacWindowEventHandler )
|
||||
|
||||
// Patch 531199 defined a window event handler, as follows.
|
||||
// TODO: merge the moving/sizing event handling with the event
|
||||
// handler above.
|
||||
#if 0
|
||||
static pascal OSStatus
|
||||
WindowHandler( EventHandlerCallRef inHandler, EventRef inEvent, void* userData )
|
||||
{
|
||||
Rect bounds;
|
||||
SInt16 height, width;
|
||||
UInt32 attributes;
|
||||
OSStatus result = eventNotHandledErr;
|
||||
|
||||
GetEventParameter( inEvent, kEventParamAttributes, typeUInt32, NULL, sizeof( UInt32 ), NULL, &attributes );
|
||||
|
||||
if ((attributes & (kWindowBoundsChangeSizeChanged | kWindowBoundsChangeOriginChanged)) != 0)
|
||||
{
|
||||
// Extract the current bounds. This is the paramter you get to modify to
|
||||
// alter the window position or size during a window resizing.
|
||||
GetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof( bounds ), NULL, &bounds );
|
||||
|
||||
wxRect rect;
|
||||
rect.SetLeft(bounds.left);
|
||||
rect.SetTop(bounds.top);
|
||||
rect.SetRight(bounds.right);
|
||||
rect.SetBottom(bounds.bottom);
|
||||
|
||||
bool rc;
|
||||
wxWindowMac *pWindow = (wxWindowMac*)userData;
|
||||
if ((attributes & kWindowBoundsChangeSizeChanged) != 0) {
|
||||
wxSizeEvent event(rect, pWindow->GetId());
|
||||
event.SetEventObject(pWindow);
|
||||
rc = pWindow->GetEventHandler()->ProcessEvent(event);
|
||||
rect = event.GetRect();
|
||||
}
|
||||
else {
|
||||
wxMoveEvent event(rect, pWindow->GetId());
|
||||
event.SetEventObject(pWindow);
|
||||
rc = pWindow->GetEventHandler()->ProcessEvent(event);
|
||||
rect = event.GetRect();
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
bounds.left = rect.GetLeft();
|
||||
bounds.top = rect.GetTop();
|
||||
bounds.right = rect.GetRight();
|
||||
bounds.bottom = rect.GetBottom();
|
||||
}
|
||||
|
||||
// Set the current bounds parameter to our adjusted bounds. Return
|
||||
// noErr to indicate we handled this event.
|
||||
SetEventParameter( inEvent, kEventParamCurrentBounds, typeQDRectangle, sizeof( bounds ), &bounds );
|
||||
result = noErr;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
// WindowHandler
|
||||
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -629,6 +687,17 @@ void wxTopLevelWindowMac::MacCreateRealWindow( const wxString& title,
|
||||
InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ;
|
||||
InstallWindowEventHandler(MAC_WXHWND(m_macWindow), GetwxMacWindowEventHandlerUPP(),
|
||||
GetEventTypeCount(eventList), eventList, this, &((EventHandlerRef)m_macEventHandler));
|
||||
|
||||
// Patch 531199 also defined a window event handler, as follows:
|
||||
#if 0
|
||||
// install a window event handler to send wxEVT_MOVING and wxEVT_SIZING events
|
||||
EventTypeSpec events[] = { { kEventClassWindow, kEventWindowBoundsChanging } };
|
||||
EventHandlerUPP handlerProc = NewEventHandlerUPP( WindowHandler );
|
||||
EventHandlerRef eventHandlerRef;
|
||||
InstallWindowEventHandler( m_macWindowData->m_macWindow, handlerProc, GetEventTypeCount(events),
|
||||
events, (void*)this, &eventHandlerRef);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
m_macFocus = NULL ;
|
||||
|
||||
|
@@ -2188,6 +2188,24 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
|
||||
processed = HandleMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
break;
|
||||
|
||||
case WM_MOVING:
|
||||
{
|
||||
LPRECT pRect = (LPRECT)lParam;
|
||||
wxRect rc;
|
||||
rc.SetLeft(pRect->left);
|
||||
rc.SetTop(pRect->top);
|
||||
rc.SetRight(pRect->right);
|
||||
rc.SetBottom(pRect->bottom);
|
||||
processed = HandleMoving(rc);
|
||||
if (processed) {
|
||||
pRect->left = rc.GetLeft();
|
||||
pRect->top = rc.GetTop();
|
||||
pRect->right = rc.GetRight();
|
||||
pRect->bottom = rc.GetBottom();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
switch ( wParam )
|
||||
{
|
||||
@@ -2216,6 +2234,24 @@ long wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZING:
|
||||
{
|
||||
LPRECT pRect = (LPRECT)lParam;
|
||||
wxRect rc;
|
||||
rc.SetLeft(pRect->left);
|
||||
rc.SetTop(pRect->top);
|
||||
rc.SetRight(pRect->right);
|
||||
rc.SetBottom(pRect->bottom);
|
||||
processed = HandleSizing(rc);
|
||||
if (processed) {
|
||||
pRect->left = rc.GetLeft();
|
||||
pRect->top = rc.GetTop();
|
||||
pRect->right = rc.GetRight();
|
||||
pRect->bottom = rc.GetBottom();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef __WXMICROWIN__
|
||||
case WM_ACTIVATEAPP:
|
||||
wxTheApp->SetActive(wParam != 0, FindFocus());
|
||||
@@ -3818,6 +3854,17 @@ bool wxWindowMSW::HandleMove(int x, int y)
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
bool wxWindowMSW::HandleMoving(wxRect& rect)
|
||||
{
|
||||
wxMoveEvent event(rect, m_windowId);
|
||||
event.SetEventObject(this);
|
||||
|
||||
bool rc = GetEventHandler()->ProcessEvent(event);
|
||||
if (rc)
|
||||
rect = event.GetRect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h),
|
||||
WXUINT WXUNUSED(flag))
|
||||
{
|
||||
@@ -3830,6 +3877,17 @@ bool wxWindowMSW::HandleSize(int WXUNUSED(w), int WXUNUSED(h),
|
||||
return GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
bool wxWindowMSW::HandleSizing(wxRect& rect)
|
||||
{
|
||||
wxSizeEvent event(rect, m_windowId);
|
||||
event.SetEventObject(this);
|
||||
|
||||
bool rc = GetEventHandler()->ProcessEvent(event);
|
||||
if (rc)
|
||||
rect = event.GetRect();
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool wxWindowMSW::HandleGetMinMaxInfo(void *mmInfo)
|
||||
{
|
||||
MINMAXINFO *info = (MINMAXINFO *)mmInfo;
|
||||
|
Reference in New Issue
Block a user