[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : luke
Repository : xara
Revision   : 957
Date       : Fri May  5 10:03:19 BST 2006

Changed paths:
   M /Trunk/XaraLX/wxOil/camelot.cpp
   M /Trunk/XaraLX/wxOil/camelot.h
   M /Trunk/XaraLX/wxOil/camview.cpp
   M /Trunk/XaraLX/wxOil/camview.h
   M /Trunk/XaraLX/wxOil/dlgevt.cpp
   M /Trunk/XaraLX/wxOil/dlgevt.h

Focus handling


Diff:
Index: Trunk/XaraLX/wxOil/dlgevt.cpp
===================================================================
--- Trunk/XaraLX/wxOil/dlgevt.cpp	(revision 956)
+++ Trunk/XaraLX/wxOil/dlgevt.cpp	(revision 957)
@@ -99,6 +99,7 @@
 
 #include "camtypes.h"
 
+#include "camelot.h"
 #include "dlgevt.h"
 #include "dlgmgr.h"
 #include "camframe.h"
@@ -145,6 +146,7 @@
 	EVT_CLOSE	(DialogEventHandler::CloseEvent)
 	EVT_WINDOW_DESTROY	(DialogEventHandler::WindowDestroyEvent)
 	EVT_MOUSE_EVENTS (DialogEventHandler::MouseEvent)
+	EVT_CHILD_FOCUS( DialogEventHandler::OnSetFocus )
 	EVT_CAMDIALOG_DEFERREDMSG (wxID_ANY, DialogEventHandler::CamDialogEvent)
 	EVT_CAMDIALOG_GRIMREAPER (wxID_ANY, DialogEventHandler::GrimReaperEvent)
 	EVT_CAMDIALOG_REDRAW (wxID_ANY, DialogEventHandler::CamDialogEvent)
@@ -470,8 +472,58 @@
 	}
 }
 
+/********************************************************************************************
 
+>	DialogEventHandler::OnSetFocus(wxCamDialogEvent& event)
 
+
+	Author:		Luke_Hart <alex@xxxxxxxxxxx>
+	Created:	02/05/06
+	Inputs:		event - the wxEvent
+	Outputs:	-
+	Returns:	-
+	Purpose:	Passes an event to DialogManager::Event
+	Errors:		-
+	SeeAlso:	-
+
+********************************************************************************************/
+
+
+void DialogEventHandler::OnSetFocus(wxChildFocusEvent &event)
+{
+	// Check if focus is going to an always focus object (may need more tests
+	// as more controls come online). If so just return allowing focus to stay
+	wxWindow*	pWnd = (wxWindow*)event.GetEventObject();
+	if( pWnd->IsKindOf( CLASSINFO(wxTextCtrl) ) ||
+		pWnd->IsKindOf( CLASSINFO(wxComboBox) ) )
+	{
+		return;
+	}
+
+	// Scan down ancestors looking for either wxPanels (always non-modal) and
+	// wxDailogs (can be modal, so we check)
+	while( NULL != pWnd && !pWnd->IsKindOf( CLASSINFO(wxPanel) ) )
+	{
+		// Dialogs may-be modal so check
+		if( pWnd->IsKindOf( CLASSINFO(wxDialog) ) )
+		{
+			if( ((wxDialog*)pWnd)->IsModal() )
+				return;
+
+			// Non-modal dialog so do focus handling
+			break;
+		}
+
+		pWnd = pWnd->GetParent();
+	}
+
+	// Put the focus back into active view
+	TRACEUSER( "jlh92", _T("NO, that control is not allowed focus") );
+	AfxGetApp().GiveActiveCanvasFocus();
+}
+
+
+
 /********************************************************************************************
 
 >	DialogEventHandler::CamDialogEvent(wxCamDialogEvent& event)
Index: Trunk/XaraLX/wxOil/camelot.h
===================================================================
--- Trunk/XaraLX/wxOil/camelot.h	(revision 956)
+++ Trunk/XaraLX/wxOil/camelot.h	(revision 957)
@@ -138,9 +138,6 @@
     void OnIdle		( wxIdleEvent  &event );
 	void OnTimer	( wxTimerEvent &event );
 
-	void OnKeyEvent	( wxKeyEvent &event );
-	void OnChar		( wxKeyEvent &event );
-	
 	void GiveActiveCanvasFocus();
 
 protected:
Index: Trunk/XaraLX/wxOil/camview.h
===================================================================
--- Trunk/XaraLX/wxOil/camview.h	(revision 956)
+++ Trunk/XaraLX/wxOil/camview.h	(revision 957)
@@ -247,6 +247,7 @@
 	void	OnMouseWheel( wxMouseEvent &event );
 	void	OnScroll( wxScrollEvent &event);
 	void	OnDragIdle( wxTimerEvent &event);		// OnTimer(DragIdleID)
+	void	OnKeyEvent( wxKeyEvent& event );
 
 	void	OnSetCursor( wxSetCursorEvent& event );
 
Index: Trunk/XaraLX/wxOil/camview.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camview.cpp	(revision 956)
+++ Trunk/XaraLX/wxOil/camview.cpp	(revision 957)
@@ -107,6 +107,7 @@
 #include "csrstack.h"
 
 #include "rendwnd.h"
+#include "keypress.h"
 #include "docview.h"
 #include "prntview.h"
 #include "osrndrgn.h"
@@ -145,6 +146,9 @@
 	EVT_SIZE(CCamView::OnSize)
 	EVT_SCROLL(CCamView::OnScroll)
 	EVT_TIMER(DragIdleID, CCamView::OnDragIdle)
+
+	EVT_KEY_UP(			CCamView::OnKeyEvent )
+	EVT_KEY_DOWN(		CCamView::OnKeyEvent )
 END_EVENT_TABLE()
 
 /*********************************************************************************************
@@ -2851,7 +2855,37 @@
 	}
 }
 
+
 /*********************************************************************************************
+>	void CCamView::OnKeyEvent(wxKeyEvent& event)
+
+	Author:		Luke_Hart (Xara Group Ltd) <lukeh@xxxxxxxx>
+	Created:	05/05/06
+	Inputs:		wxKeyEvent&		event - The event object
+	Outputs:	-
+	Returns:	-
+	Purpose:	Forward the keypress event to the central key handler
+	Errors:		-
+	Scope:		Protected
+	SeeAlso:	
+**********************************************************************************************/ 
+
+void CCamView::OnKeyEvent( wxKeyEvent &event )
+{
+	// Make sure the kernel knows which view/doc the event applies to, if any.
+	if( NULL != Document::GetSelected() )
+		Document::GetSelected()->SetCurrent();
+	if( NULL != DocView::GetSelected() )
+		DocView::GetSelected()->SetCurrent();
+
+	// Process keyboard messages
+	if( !CCamFrame::GetMainFrame()->IsIconized() && KeyPress::TranslateMessage( &event ) )
+		return;
+	
+	event.Skip();
+}
+
+/*********************************************************************************************
 >	void CCamView::ScrollTo(const WorkCoord& offset)
 
 	Author:		Justin_Flude (Xara Group Ltd) <camelotdev@xxxxxxxx>
Index: Trunk/XaraLX/wxOil/camelot.cpp
===================================================================
--- Trunk/XaraLX/wxOil/camelot.cpp	(revision 956)
+++ Trunk/XaraLX/wxOil/camelot.cpp	(revision 957)
@@ -110,7 +110,6 @@
 //#include "Res/UKEnglish/stringtbl.h"
 #include "kernel.h"
 #include "grndrgn.h"
-#include "keypress.h"
 #include "oilmenus.h"
 
 #if !defined(__WXMSW__)
@@ -196,52 +195,13 @@
 BEGIN_EVENT_TABLE( CCamApp, wxApp )
 	EVT_IDLE( CCamApp::OnIdle )
 //	EVT_TIMER( CAM_TIMER_ID, CCamApp::OnTimer )
-
-	EVT_KEY_UP(			CCamApp::OnKeyEvent )
-	EVT_KEY_DOWN(		CCamApp::OnKeyEvent )
-//	EVT_CHAR(			CCamApp::OnChar )
 END_EVENT_TABLE()
 
 DialogManager			CCamApp::m_DlgMgr;
 bool					CCamApp::s_bIsDisabled = false; // Initially system is not disabled.
 wxString				CCamApp::m_strResourcePath;
 
-void CCamApp::OnKeyEvent( wxKeyEvent &event )
-{
-	// If a control (but not a button) has focus, let it handle the key events
-	// Whilst debugging focus can end-up NULL, so we protect ourselves
-	wxWindow*			pFocusWnd = wxWindow::FindFocus();
-	wxClassInfo*		pClassInfo = NULL != pFocusWnd ? pFocusWnd->GetClassInfo() : NULL;
-	TRACEUSER( "jlh92", _T("Focus = %s
"), pClassInfo?pClassInfo->GetClassName():_T("None") );
-	if(  NULL != pFocusWnd &&
-		 pClassInfo->IsKindOf( CLASSINFO(wxControl) ) &&
-		!pClassInfo->IsKindOf( CLASSINFO(wxButton) ) &&
-		!pClassInfo->IsKindOf( CLASSINFO(wxSlider) ) &&
-		!pClassInfo->IsKindOf( CLASSINFO(wxCamArtControl) ) &&
-		!pClassInfo->IsKindOf( CLASSINFO(wxCamDrawControl) ) ) 
-	{
-		event.Skip();
-		return;
-	}
-	
-	// Make sure the kernel knows which view/doc the event applies to, if any.
-	if( NULL != Document::GetSelected() )
-		Document::GetSelected()->SetCurrent();
-	if( NULL != DocView::GetSelected() )
-		DocView::GetSelected()->SetCurrent();
 
-	// Process keyboard messages
-	if( !CCamFrame::GetMainFrame()->IsIconized() && KeyPress::TranslateMessage( &event ) )
-		return;
-	
-	event.Skip();
-}
-
-void CCamApp::OnChar( wxKeyEvent &event )
-{
-	TRACE( _T("CCamApp::OnCR = %c
"), event.m_keyCode );
-}
-
 /***************************************************************************************************************************/
 
 CCamApp::CCamApp()
@@ -809,7 +769,8 @@
 void CCamApp::GiveActiveCanvasFocus()
 {
 	CCamView* pView = dynamic_cast<CCamView*>( m_docManager->GetCurrentView() );
-	pView->Activate( true );
+	if( NULL != pView )
+		pView->Activate( true );
 }
 
 /***************************************************************************************************************************/
Index: Trunk/XaraLX/wxOil/dlgevt.h
===================================================================
--- Trunk/XaraLX/wxOil/dlgevt.h	(revision 956)
+++ Trunk/XaraLX/wxOil/dlgevt.h	(revision 957)
@@ -141,6 +141,7 @@
 	void CloseEvent(wxCloseEvent &event);
 	void MouseEvent(wxMouseEvent &event);
 	void WindowDestroyEvent(wxWindowDestroyEvent &event);
+	void OnSetFocus(wxChildFocusEvent &event);
 	void CamDialogEvent(wxCamDialogEvent &event);
 
 	void GrimReaperEvent(wxCamDialogEvent &event);


Xara