I've put live into Vadim's wxNavigationKeyEvent idea

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1212 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-12-17 08:40:34 +00:00
parent 105e45b9d0
commit b292e2f512
42 changed files with 1038 additions and 624 deletions

View File

@@ -624,6 +624,8 @@ class wxListCtrl: public wxControl
else return wxColour(); } else return wxColour(); }
bool PopupMenu( wxMenu *menu, int x, int y ) bool PopupMenu( wxMenu *menu, int x, int y )
{ return m_mainWin->PopupMenu( menu, x, y ); } { return m_mainWin->PopupMenu( menu, x, y ); }
void SetFocus()
{ m_mainWin->SetFocus(); }
// implementation // implementation

View File

@@ -20,7 +20,7 @@
WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr; WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr;
// Dialog boxes
class WXDLLEXPORT wxPanel: public wxWindow class WXDLLEXPORT wxPanel: public wxWindow
{ {
public: public:
@@ -56,17 +56,12 @@ public:
// to the dialog via validators. // to the dialog via validators.
virtual void InitDialog(); virtual void InitDialog();
// overriden base class virtuals
virtual void SetFocus();
// callbacks
// Responds to colour changes // Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event); void OnSysColourChanged(wxSysColourChangedEvent& event);
// Process a keyboard navigation message (Tab traversal) // Process a keyboard navigation message (Tab traversal)
void OnNavigationKey(wxNavigationKeyEvent& event); void OnNavigationKey(wxNavigationKeyEvent& event);
protected:
bool SetFocusToNextChild(wxNode *nodeCurrent = (wxNode *) NULL, bool bForward = TRUE);
DECLARE_DYNAMIC_CLASS(wxPanel) DECLARE_DYNAMIC_CLASS(wxPanel)
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()

View File

@@ -7,7 +7,6 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKCONTROLH__ #ifndef __GTKCONTROLH__
#define __GTKCONTROLH__ #define __GTKCONTROLH__
@@ -50,6 +49,7 @@ public:
protected: protected:
wxString m_label; wxString m_label;
char m_chAccel; // enabled to avoid breaking binary compatibility later on char m_chAccel; // enabled to avoid breaking binary compatibility later on
}; };
#endif // __GTKCONTROLH__ #endif // __GTKCONTROLH__

View File

@@ -146,7 +146,7 @@ public:
// don't delete it yourself). If bSelect, this page becomes active. // don't delete it yourself). If bSelect, this page becomes active.
bool AddPage(wxWindow *pPage, bool AddPage(wxWindow *pPage,
const wxString& strText, const wxString& strText,
bool bSelect = FALSE, bool select = FALSE,
int imageId = -1); int imageId = -1);
// @@@@ VZ: I don't know how to implement InsertPage() // @@@@ VZ: I don't know how to implement InsertPage()

View File

@@ -80,6 +80,7 @@ class wxRadioBox: public wxControl
void SetNumberOfRowsOrCols( int n ); void SetNumberOfRowsOrCols( int n );
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
void SetFocus();
// implementation // implementation

View File

@@ -88,6 +88,16 @@ private:
wxString m_data; wxString m_data;
}; };
//-----------------------------------------------------------------------------
// (debug)
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
void debug_focus_in( GtkWidget* widget, const char* name, const char* window );
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindow // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -151,9 +161,11 @@ public:
virtual void MakeModal( bool modal ); virtual void MakeModal( bool modal );
virtual bool IsEnabled() const { return m_isEnabled; } virtual bool IsEnabled() const { return m_isEnabled; }
inline bool Enabled() const { return IsEnabled(); } inline bool Enabled() const { return IsEnabled(); }
virtual void SetFocus();
virtual bool OnClose(); virtual bool OnClose();
virtual void SetFocus();
static wxWindow *FindFocus();
virtual void AddChild( wxWindow *child ); virtual void AddChild( wxWindow *child );
wxList& GetChildren() { return m_children; } wxList& GetChildren() { return m_children; }
@@ -331,6 +343,7 @@ public:
GdkGC *m_scrollGC; GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle; GtkStyle *m_widgetStyle;
bool m_isStaticBox; bool m_isStaticBox;
bool m_acceptsFocus;
wxInsertChildFunction m_insertCallback; wxInsertChildFunction m_insertCallback;

View File

@@ -7,7 +7,6 @@
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef __GTKCONTROLH__ #ifndef __GTKCONTROLH__
#define __GTKCONTROLH__ #define __GTKCONTROLH__
@@ -50,6 +49,7 @@ public:
protected: protected:
wxString m_label; wxString m_label;
char m_chAccel; // enabled to avoid breaking binary compatibility later on char m_chAccel; // enabled to avoid breaking binary compatibility later on
}; };
#endif // __GTKCONTROLH__ #endif // __GTKCONTROLH__

View File

@@ -146,7 +146,7 @@ public:
// don't delete it yourself). If bSelect, this page becomes active. // don't delete it yourself). If bSelect, this page becomes active.
bool AddPage(wxWindow *pPage, bool AddPage(wxWindow *pPage,
const wxString& strText, const wxString& strText,
bool bSelect = FALSE, bool select = FALSE,
int imageId = -1); int imageId = -1);
// @@@@ VZ: I don't know how to implement InsertPage() // @@@@ VZ: I don't know how to implement InsertPage()

View File

@@ -80,6 +80,7 @@ class wxRadioBox: public wxControl
void SetNumberOfRowsOrCols( int n ); void SetNumberOfRowsOrCols( int n );
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
void SetFocus();
// implementation // implementation

View File

@@ -88,6 +88,16 @@ private:
wxString m_data; wxString m_data;
}; };
//-----------------------------------------------------------------------------
// (debug)
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
void debug_focus_in( GtkWidget* widget, const char* name, const char* window );
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxWindow // wxWindow
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -151,9 +161,11 @@ public:
virtual void MakeModal( bool modal ); virtual void MakeModal( bool modal );
virtual bool IsEnabled() const { return m_isEnabled; } virtual bool IsEnabled() const { return m_isEnabled; }
inline bool Enabled() const { return IsEnabled(); } inline bool Enabled() const { return IsEnabled(); }
virtual void SetFocus();
virtual bool OnClose(); virtual bool OnClose();
virtual void SetFocus();
static wxWindow *FindFocus();
virtual void AddChild( wxWindow *child ); virtual void AddChild( wxWindow *child );
wxList& GetChildren() { return m_children; } wxList& GetChildren() { return m_children; }
@@ -331,6 +343,7 @@ public:
GdkGC *m_scrollGC; GdkGC *m_scrollGC;
GtkStyle *m_widgetStyle; GtkStyle *m_widgetStyle;
bool m_isStaticBox; bool m_isStaticBox;
bool m_acceptsFocus;
wxInsertChildFunction m_insertCallback; wxInsertChildFunction m_insertCallback;

View File

@@ -24,9 +24,15 @@
#include "wx/wx.h" #include "wx/wx.h"
#endif #endif
#ifdef __WXMSW__
#include "wx/ownerdrw.h" #include "wx/ownerdrw.h"
#endif
#include "wx/menuitem.h" #include "wx/menuitem.h"
#include "wx/msw/checklst.h" #include "wx/checklst.h"
#ifdef __WXGTK__
#include "mondrian.xpm"
#endif
// Define a new application type // Define a new application type
class CheckListBoxApp: public wxApp class CheckListBoxApp: public wxApp
@@ -89,7 +95,7 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame, char *title, int x, int y,
: wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h)) : wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
{ {
// set the icon // set the icon
SetIcon(wxIcon("mondrian")); SetIcon(wxICON(mondrian));
// Make a menubar // Make a menubar
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
@@ -127,9 +133,11 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame, char *title, int x, int y,
delete [] astrChoices; delete [] astrChoices;
#ifdef __WXMSW__
for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 ) { for ( ui = 0; ui < WXSIZEOF(aszChoices); ui += 2 ) {
m_pListBox->GetItem(ui)->SetBackgroundColour(wxColor(200, 200, 200)); m_pListBox->GetItem(ui)->SetBackgroundColour(wxColor(200, 200, 200));
} }
#endif
m_pListBox->Check(2); m_pListBox->Check(2);
@@ -163,7 +171,7 @@ void CheckListBoxFrame::OnListboxSelect(wxCommandEvent& event)
wxString strSelection; wxString strSelection;
unsigned int nSel = event.GetSelection(); unsigned int nSel = event.GetSelection();
strSelection.sprintf("item %d selected (%schecked)", nSel, strSelection.sprintf("item %d selected (%schecked)", nSel,
m_pListBox->IsChecked(nSel) ? "" : "not "); m_pListBox->IsChecked((int)nSel) ? "" : "not ");
SetStatusText(strSelection); SetStatusText(strSelection);
} }

View File

@@ -2301,7 +2301,7 @@ bool wxListCtrl::Create( wxWindow *parent, wxWindowID id,
m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, s ); m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, s );
if (GetWindowStyleFlag() & wxLC_REPORT) if (GetWindowStyleFlag() & wxLC_REPORT)
m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, wxPoint(0,0), wxSize(size.x,23) ); m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, wxPoint(0,0), wxSize(size.x,23), wxTAB_TRAVERSAL );
else else
m_headerWin = (wxListHeaderWindow *) NULL; m_headerWin = (wxListHeaderWindow *) NULL;
@@ -2355,7 +2355,7 @@ void wxListCtrl::SetWindowStyleFlag( long flag )
// m_mainWin->SetSize( 0, 24, width, height-24 ); // m_mainWin->SetSize( 0, 24, width, height-24 );
if (!m_headerWin) if (!m_headerWin)
{ {
m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, wxPoint(0,0), wxSize(width,23) ); m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin, wxPoint(0,0), wxSize(width,23), wxTAB_TRAVERSAL );
} }
else else
{ {

View File

@@ -48,7 +48,8 @@ bool wxPanel::Create(wxWindow *parent, wxWindowID id,
{ {
bool ret = wxWindow::Create(parent, id, pos, size, style, name); bool ret = wxWindow::Create(parent, id, pos, size, style, name);
if ( ret ) { if ( ret )
{
#ifndef __WXGTK__ #ifndef __WXGTK__
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
@@ -65,11 +66,6 @@ void wxPanel::InitDialog(void)
GetEventHandler()->ProcessEvent(event); GetEventHandler()->ProcessEvent(event);
} }
void wxPanel::SetFocus()
{
SetFocusToNextChild();
}
// Responds to colour changes, and passes event on to children. // Responds to colour changes, and passes event on to children.
void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event) void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event)
{ {
@@ -82,95 +78,66 @@ void wxPanel::OnSysColourChanged(wxSysColourChangedEvent& event)
void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event ) void wxPanel::OnNavigationKey( wxNavigationKeyEvent& event )
{ {
// don't process these ones here if (m_children.GetCount() < 2)
if ( event.IsWindowChange() ) { {
event.Skip();
return;
}
// don't process these ones here
if (event.IsWindowChange())
{
event.Skip(); event.Skip();
return; return;
} }
// first of all, find the window which currently has the focus
wxNode *node = GetChildren().First();
wxWindow *winFocus = event.GetCurrentFocus(); wxWindow *winFocus = event.GetCurrentFocus();
if (!winFocus) winFocus = wxWindow::FindFocus();
// @@@ no FindFocus() in wxGTK if (!winFocus)
#ifndef __WXGTK__ {
if ( winFocus == NULL ) event.Skip();
winFocus = wxWindow::FindFocus(); return;
#endif }
while ( node != NULL ) { wxNode *start_node = m_children.Find( winFocus );
if ( node->Data() == winFocus ) if (!start_node) start_node = m_children.First();
break;
wxNode *node = event.GetDirection() ? start_node->Next() : start_node->Previous();
while (node != start_node)
{
if (!node)
{
/*
if (GetParent() != NULL)
{
wxNavigationKeyEvent new_event;
new_event.SetDirection( event.GetDirection() );
new_event.SetWindowChange(FALSE);
new_event.SetCurrentFocus( this );
if (GetParent()->GetEventHandler()->ProcessEvent(new_event))
{
return;
}
}
*/
node = event.GetDirection() ? m_children.First() : m_children.Last();
}
wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus())
{
child->SetFocus();
return;
}
node = node->Next(); node = node->Next();
} }
if ( !SetFocusToNextChild(node, event.GetDirection()) )
event.Skip(); event.Skip();
} }
// set focus to the next child which accepts it (or first/last if node == NULL)
bool wxPanel::SetFocusToNextChild(wxNode *node, bool bForward)
{
// @@ using typed list would be better...
#define WIN(node) ((wxWindow *)(node->Data()))
bool bFound = FALSE; // have we found a window we will set focus to?
wxList *children = & GetChildren();
if ( node == NULL ) {
// we've never had focus before
node = bForward ? children->First() : children->Last();
if ( node == NULL ) {
// no children
return FALSE;
}
bFound = WIN(node)->AcceptsFocus();
}
#if 0 // to restore when it will really work (now it's triggered all the time)
else {
// just to be sure it's the right one
wxASSERT( WIN(node)->AcceptsFocus() );
}
#endif // 0
// find the next child which accepts focus
bool bParentWantsIt = TRUE;
while ( !bFound ) {
node = bForward ? node->Next() : node->Previous();
if ( node == NULL ) {
if ( !bParentWantsIt ) {
// we've already been here which means that we've done a whole
// cycle without success - get out from the infinite loop
return FALSE;
}
// ask parent if he doesn't want to advance focus to the next panel
if ( GetParent() != NULL ) {
wxNavigationKeyEvent event;
event.SetDirection(bForward);
event.SetWindowChange(FALSE);
event.SetCurrentFocus(this);
if ( GetParent()->ProcessEvent(event) )
return TRUE;
}
// a sentinel to avoid infinite loops
bParentWantsIt = FALSE;
// wrap around
node = bForward ? children->First() : children->Last();
}
bFound = WIN(node)->AcceptsFocus();
}
WIN(node)->SetFocus();
#undef WIN
return TRUE;
}

View File

@@ -84,7 +84,7 @@ bool wxStatusBar::Create(wxWindow *parent, wxWindowID id,
m_borderX = wxTHICK_LINE_BORDER; m_borderX = wxTHICK_LINE_BORDER;
m_borderY = wxTHICK_LINE_BORDER; m_borderY = wxTHICK_LINE_BORDER;
bool success = wxWindow::Create(parent, id, pos, size, style, name); bool success = wxWindow::Create(parent, id, pos, size, style | wxTAB_TRAVERSAL, name);
// Don't wish this to be found as a child // Don't wish this to be found as a child
parent->GetChildren().DeleteObject(this); parent->GetChildren().DeleteObject(this);

View File

@@ -102,6 +102,7 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
wxSize newSize = size; wxSize newSize = size;

View File

@@ -60,6 +60,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
{ {
m_clientData = (wxClientData*) NULL; m_clientData = (wxClientData*) NULL;
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
wxSize newSize = size; wxSize newSize = size;

View File

@@ -57,6 +57,7 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -63,6 +63,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -38,15 +38,15 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) )
void wxControl::SetLabel( const wxString &label ) void wxControl::SetLabel( const wxString &label )
{ {
m_label = ""; m_label = "";
for ( const char *pc = label; *pc != '\0'; pc++ ) { for ( const char *pc = label; *pc != '\0'; pc++ )
if ( *pc == '&' ) { {
if ( *pc == '&' )
{
pc++; // skip it pc++; // skip it
#if 0 // it would be unused anyhow for now - kbd interface not done yet #if 0 // it would be unused anyhow for now - kbd interface not done yet
if ( *pc != '&' ) if ( *pc != '&' ) m_chAccel = *pc;
m_chAccel = *pc;
#endif #endif
} }
m_label << *pc; m_label << *pc;
} }
} }
@@ -57,4 +57,3 @@ wxString wxControl::GetLabel(void) const
} }

View File

@@ -142,6 +142,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
m_widget = gtk_window_new( win_type ); m_widget = gtk_window_new( win_type );
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxFrame::m_widget", name );
#endif
if ((size.x != -1) && (size.y != -1)) if ((size.x != -1) && (size.y != -1))
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if ((pos.x != -1) && (pos.y != -1)) if ((pos.x != -1) && (pos.y != -1))
@@ -159,6 +163,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, "wxFrame::m_wxwindow", name );
#endif
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",

View File

@@ -130,6 +130,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@@ -155,6 +156,25 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) ); gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
#endif #endif
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxListBox::m_widget", name );
debug_focus_in( GTK_WIDGET(m_list), "wxListBox::m_list", name );
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
#ifdef NEW_GTK_SCROLL_CODE
GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
#else
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
#endif
debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
#endif
gtk_widget_show( GTK_WIDGET(m_list) ); gtk_widget_show( GTK_WIDGET(m_list) );
wxSize newSize = size; wxSize newSize = size;
@@ -180,6 +200,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
list_item = gtk_list_item_new_with_label( choices[i] ); list_item = gtk_list_item_new_with_label( choices[i] );
} }
#ifdef __WXDEBUG__
debug_focus_in( list_item, "wxListBox::list_item", name );
#endif
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
gtk_signal_connect( GTK_OBJECT(list_item), "select", gtk_signal_connect( GTK_OBJECT(list_item), "select",

View File

@@ -17,6 +17,13 @@
#include "wx/imaglist.h" #include "wx/imaglist.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxNotebookPage // wxNotebookPage
@@ -103,6 +110,37 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
if (win->GetAutoLayout()) win->Layout(); if (win->GetAutoLayout()) win->Layout();
} }
//-----------------------------------------------------------------------------
// "key_press_event"
//-----------------------------------------------------------------------------
static gint
gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
{
if (g_blockEventsOnDrag) return FALSE;
if (!notebook->HasVMT()) return FALSE;
if (gdk_event->keyval != GDK_Down) return FALSE;
if (notebook != notebook->FindFocus()) return FALSE;
if (notebook->m_pages.GetCount() == 0) return FALSE;
wxNode *node = notebook->m_pages.Nth( notebook->GetSelection() );
if (!node) return FALSE;
wxNotebookPage *page = (wxNotebookPage*) node->Data();
// don't let others the key event
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
page->m_client->SetFocus();
return TRUE;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// InsertChild callback for wxNotebook // InsertChild callback for wxNotebook
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -128,11 +166,7 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
if (!page->m_page) wxASSERT_MSG( page->m_page, "Notebook page creation error" );
{
wxLogFatalError( "Notebook page creation error" );
return;
}
parent->m_pages.Append( page ); parent->m_pages.Append( page );
} }
@@ -177,12 +211,17 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook; m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_notebook_new(); m_widget = gtk_notebook_new();
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxNotebook::m_widget", name );
#endif
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_idHandler = gtk_signal_connect ( m_idHandler = gtk_signal_connect (
@@ -194,6 +233,9 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@@ -238,12 +280,13 @@ int wxNotebook::GetPageCount() const
// count only the pages which were already added to the notebook for MSW // count only the pages which were already added to the notebook for MSW
// compatibility (and, in fact, this behaviour makes more sense anyhow // compatibility (and, in fact, this behaviour makes more sense anyhow
// because only the added pages are shown) // because only the added pages are shown)
int n = 0; int n = 0;
for ( wxNode *node = m_pages.First(); node; node = node->Next() ) for ( wxNode *node = m_pages.First(); node; node = node->Next() )
{ {
wxNotebookPage *page = (wxNotebookPage*)node->Data(); wxNotebookPage *page = (wxNotebookPage*)node->Data();
if ( page->WasAdded() )
n++; if (page->WasAdded()) n++;
} }
return n; return n;
@@ -291,7 +334,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
node = node->Next(); node = node->Next();
} }
wxLogDebug( "Notebook page %d not found!", page ); wxFAIL_MSG( "Notebook page not found!" );
return (wxNotebookPage *) NULL; return (wxNotebookPage *) NULL;
} }
@@ -437,7 +480,7 @@ bool wxNotebook::RemovePage( int page )
} }
bool wxNotebook::AddPage(wxWindow* win, const wxString& text, bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
bool bSelect, int imageId) bool select, int imageId)
{ {
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" ); wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
@@ -491,7 +534,7 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
gtk_widget_show((GtkWidget *)page->m_label); gtk_widget_show((GtkWidget *)page->m_label);
if (bSelect) SetSelection(GetPageCount()); if (select) SetSelection( GetPageCount()-1 );
return TRUE; return TRUE;
} }

View File

@@ -71,6 +71,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@@ -282,6 +283,27 @@ int wxRadioBox::FindString( const wxString &s ) const
return -1; return -1;
} }
void wxRadioBox::SetFocus()
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
if (m_boxes.GetCount() == 0) return;
wxNode *node = m_boxes.First();
while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
gtk_widget_grab_focus( GTK_WIDGET(button) );
return;
}
node = node->Next();
}
}
void wxRadioBox::SetSelection( int n ) void wxRadioBox::SetSelection( int n )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );

View File

@@ -53,6 +53,7 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
const wxPoint& pos, const wxSize& size, long style, const wxPoint& pos, const wxSize& size, long style,
const wxValidator& validator, const wxString& name ) const wxValidator& validator, const wxString& name )
{ {
m_acceptsFocus = TRUE;
m_needParent = TRUE; m_needParent = TRUE;
wxSize newSize = size; wxSize newSize = size;

View File

@@ -116,6 +116,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator, const wxString& name ) long style, const wxValidator& validator, const wxString& name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -79,6 +79,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator, const wxString& name ) long style, const wxValidator& validator, const wxString& name )
{ {
m_acceptsFocus = TRUE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -20,6 +20,14 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "changed" // "changed"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -48,7 +56,6 @@ gtk_text_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* WXUNUSED(all
win->CalculateScrollbar(); win->CalculateScrollbar();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxTextCtrl // wxTextCtrl
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -81,6 +88,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
int style, const wxValidator& validator, const wxString &name ) int style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@@ -153,8 +161,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
// we want to be notified about text changes // we want to be notified about text changes
gtk_signal_connect( GTK_OBJECT(m_text), "changed", gtk_signal_connect( GTK_OBJECT(m_text), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
(gpointer)this);
if (!value.IsNull()) if (!value.IsNull())
{ {
@@ -608,15 +615,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
event.SetEventObject(this); event.SetEventObject(this);
if (GetEventHandler()->ProcessEvent(event)) return; if (GetEventHandler()->ProcessEvent(event)) return;
} }
else if (key_event.KeyCode() == WXK_TAB)
{
wxNavigationKeyEvent event;
event.SetDirection( key_event.m_shiftDown );
event.SetWindowChange(FALSE);
event.SetEventObject(this);
if (GetEventHandler()->ProcessEvent(event)) return;
}
key_event.Skip(); key_event.Skip();
} }

View File

@@ -120,6 +120,41 @@
#endif #endif
#endif #endif
//-----------------------------------------------------------------------------
// (debug)
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event),
const char *name )
{
printf( "FOCUS NOW AT: " );
printf( name );
printf( "\n" );
return FALSE;
}
void debug_focus_in( GtkWidget* widget, const char* name, const char *window )
{
return;
wxString tmp = name;
tmp += " FROM ";
tmp += window;
char *s = new char[tmp.Length()+1];
strcpy( s, WXSTRINGCAST tmp );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -129,6 +164,7 @@ extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE; static bool g_capturing = FALSE;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
// hack: we need something to pass to gtk_menu_popup, so we store the time of // hack: we need something to pass to gtk_menu_popup, so we store the time of
// the last click here // the last click here
@@ -181,7 +217,7 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "key_press_event" // "key_press_event" from any window
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
@@ -304,9 +340,39 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
} }
} }
// win is a control: tab can be propagated up
if ((!ret) && (gdk_event->keyval == GDK_Tab))
{
wxNavigationKeyEvent new_event;
new_event.SetDirection( !(gdk_event->state & GDK_SHIFT_MASK) );
new_event.SetWindowChange( FALSE );
new_event.SetCurrentFocus( win );
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
/*
// win is a panel: up can be propagated to the panel
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
(gdk_event->keyval == GDK_Up))
{
win->m_parent->SetFocus();
ret = TRUE;
}
// win is a panel: left/right can be propagated to the panel
if ((!ret) && (win->m_wxwindow) &&
((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) ||
(gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down)))
{
wxNavigationKeyEvent new_event;
new_event.SetDirection( (gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Down) );
new_event.SetCurrentFocus( win );
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
*/
if (ret) if (ret)
{ {
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
} }
@@ -658,6 +724,9 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{ {
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
g_focusWindow = win;
if (win->m_wxwindow) if (win->m_wxwindow)
{ {
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
@@ -729,10 +798,13 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{ {
if (widget->window != gdk_event->window) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
if (widget->window != gdk_event->window) return TRUE;
if (!win->HasVMT()) return TRUE; if (!win->HasVMT()) return TRUE;
/* /*
@@ -742,9 +814,6 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
printf( ".\n" ); printf( ".\n" );
*/ */
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
wxMouseEvent event( wxEVT_ENTER_WINDOW ); wxMouseEvent event( wxEVT_ENTER_WINDOW );
event.SetEventObject( win ); event.SetEventObject( win );
@@ -777,10 +846,13 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{ {
if (widget->window != gdk_event->window) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
if (widget->window != gdk_event->window) return TRUE;
if (!win->HasVMT()) return TRUE; if (!win->HasVMT()) return TRUE;
/* /*
@@ -790,9 +862,6 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
printf( ".\n" ); printf( ".\n" );
*/ */
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
wxMouseEvent event( wxEVT_LEAVE_WINDOW ); wxMouseEvent event( wxEVT_LEAVE_WINDOW );
event.SetEventObject( win ); event.SetEventObject( win );
@@ -1104,6 +1173,7 @@ wxWindow::wxWindow()
m_clientData = NULL; m_clientData = NULL;
m_isStaticBox = FALSE; m_isStaticBox = FALSE;
m_acceptsFocus = FALSE;
} }
wxWindow::wxWindow( wxWindow *parent, wxWindowID id, wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@@ -1127,8 +1197,17 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxWindow::m_widget", name );
#endif
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget); GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
#ifdef __WXDEBUG__
debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
#endif
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0; scroll_class->scrollbar_spacing = 0;
@@ -1142,6 +1221,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, "wxWindow::m_wxwindow", name );
#endif
#ifdef NEW_GTK_SCROLL_CODE #ifdef NEW_GTK_SCROLL_CODE
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow ); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow );
GtkViewport *viewport = GTK_VIEWPORT(s_window->child); GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
@@ -1150,6 +1233,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport); GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
#endif #endif
#ifdef __WXDEBUG__
debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
#endif
if (m_windowStyle & wxRAISED_BORDER) if (m_windowStyle & wxRAISED_BORDER)
{ {
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT ); gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT );
@@ -1163,10 +1250,16 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE ); gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
} }
if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL) if ((m_windowStyle & wxTAB_TRAVERSAL) != 0)
{
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = FALSE;
}
else else
{
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
}
// shut the viewport up // shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ); gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
@@ -1906,11 +1999,28 @@ void wxWindow::SetFocus()
GtkWidget *connect_widget = GetConnectWidget(); GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget) if (connect_widget)
{ {
if (GTK_WIDGET_CAN_FOCUS(connect_widget) && !GTK_WIDGET_HAS_FOCUS (connect_widget) ) if (GTK_WIDGET_CAN_FOCUS(connect_widget) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
{ {
gtk_widget_grab_focus (connect_widget); gtk_widget_grab_focus (connect_widget);
} }
else if (GTK_IS_CONTAINER(connect_widget))
{
gtk_container_focus( GTK_CONTAINER(connect_widget), GTK_DIR_TAB_FORWARD );
} }
else
{
}
}
}
wxWindow *wxWindow::FindFocus()
{
return g_focusWindow;
}
bool wxWindow::AcceptsFocus() const
{
return IsEnabled() && IsShown() && m_acceptsFocus;
} }
bool wxWindow::OnClose() bool wxWindow::OnClose()
@@ -3164,11 +3274,6 @@ void wxWindow::GetPositionConstraint(int *x, int *y) const
GetPosition(x, y); GetPosition(x, y);
} }
bool wxWindow::AcceptsFocus() const
{
return IsEnabled() && IsShown();
}
void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) ) void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) )
{ {
UpdateWindowUI(); UpdateWindowUI();

View File

@@ -102,6 +102,7 @@ bool wxBitmapButton::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
wxSize newSize = size; wxSize newSize = size;

View File

@@ -60,6 +60,7 @@ bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label,
{ {
m_clientData = (wxClientData*) NULL; m_clientData = (wxClientData*) NULL;
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
wxSize newSize = size; wxSize newSize = size;

View File

@@ -57,6 +57,7 @@ bool wxCheckBox::Create( wxWindow *parent, wxWindowID id, const wxString &label
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -63,6 +63,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -38,15 +38,15 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) )
void wxControl::SetLabel( const wxString &label ) void wxControl::SetLabel( const wxString &label )
{ {
m_label = ""; m_label = "";
for ( const char *pc = label; *pc != '\0'; pc++ ) { for ( const char *pc = label; *pc != '\0'; pc++ )
if ( *pc == '&' ) { {
if ( *pc == '&' )
{
pc++; // skip it pc++; // skip it
#if 0 // it would be unused anyhow for now - kbd interface not done yet #if 0 // it would be unused anyhow for now - kbd interface not done yet
if ( *pc != '&' ) if ( *pc != '&' ) m_chAccel = *pc;
m_chAccel = *pc;
#endif #endif
} }
m_label << *pc; m_label << *pc;
} }
} }
@@ -57,4 +57,3 @@ wxString wxControl::GetLabel(void) const
} }

View File

@@ -142,6 +142,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
m_widget = gtk_window_new( win_type ); m_widget = gtk_window_new( win_type );
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxFrame::m_widget", name );
#endif
if ((size.x != -1) && (size.y != -1)) if ((size.x != -1) && (size.y != -1))
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if ((pos.x != -1) && (pos.y != -1)) if ((pos.x != -1) && (pos.y != -1))
@@ -159,6 +163,10 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, "wxFrame::m_wxwindow", name );
#endif
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",

View File

@@ -130,6 +130,7 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator, const wxString &name ) long style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@@ -155,6 +156,25 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) ); gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
#endif #endif
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxListBox::m_widget", name );
debug_focus_in( GTK_WIDGET(m_list), "wxListBox::m_list", name );
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
#ifdef NEW_GTK_SCROLL_CODE
GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
#else
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
#endif
debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
#endif
gtk_widget_show( GTK_WIDGET(m_list) ); gtk_widget_show( GTK_WIDGET(m_list) );
wxSize newSize = size; wxSize newSize = size;
@@ -180,6 +200,10 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
list_item = gtk_list_item_new_with_label( choices[i] ); list_item = gtk_list_item_new_with_label( choices[i] );
} }
#ifdef __WXDEBUG__
debug_focus_in( list_item, "wxListBox::list_item", name );
#endif
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
gtk_signal_connect( GTK_OBJECT(list_item), "select", gtk_signal_connect( GTK_OBJECT(list_item), "select",

View File

@@ -17,6 +17,13 @@
#include "wx/imaglist.h" #include "wx/imaglist.h"
#include "wx/intl.h" #include "wx/intl.h"
#include "wx/log.h" #include "wx/log.h"
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxNotebookPage // wxNotebookPage
@@ -103,6 +110,37 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
if (win->GetAutoLayout()) win->Layout(); if (win->GetAutoLayout()) win->Layout();
} }
//-----------------------------------------------------------------------------
// "key_press_event"
//-----------------------------------------------------------------------------
static gint
gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *notebook )
{
if (g_blockEventsOnDrag) return FALSE;
if (!notebook->HasVMT()) return FALSE;
if (gdk_event->keyval != GDK_Down) return FALSE;
if (notebook != notebook->FindFocus()) return FALSE;
if (notebook->m_pages.GetCount() == 0) return FALSE;
wxNode *node = notebook->m_pages.Nth( notebook->GetSelection() );
if (!node) return FALSE;
wxNotebookPage *page = (wxNotebookPage*) node->Data();
// don't let others the key event
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
page->m_client->SetFocus();
return TRUE;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// InsertChild callback for wxNotebook // InsertChild callback for wxNotebook
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -128,11 +166,7 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
if (!page->m_page) wxASSERT_MSG( page->m_page, "Notebook page creation error" );
{
wxLogFatalError( "Notebook page creation error" );
return;
}
parent->m_pages.Append( page ); parent->m_pages.Append( page );
} }
@@ -177,12 +211,17 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
long style, const wxString& name ) long style, const wxString& name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook; m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_notebook_new(); m_widget = gtk_notebook_new();
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxNotebook::m_widget", name );
#endif
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_idHandler = gtk_signal_connect ( m_idHandler = gtk_signal_connect (
@@ -194,6 +233,9 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
(m_parent->m_insertCallback)( m_parent, this ); (m_parent->m_insertCallback)( m_parent, this );
gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event",
GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this );
PostCreation(); PostCreation();
Show( TRUE ); Show( TRUE );
@@ -238,12 +280,13 @@ int wxNotebook::GetPageCount() const
// count only the pages which were already added to the notebook for MSW // count only the pages which were already added to the notebook for MSW
// compatibility (and, in fact, this behaviour makes more sense anyhow // compatibility (and, in fact, this behaviour makes more sense anyhow
// because only the added pages are shown) // because only the added pages are shown)
int n = 0; int n = 0;
for ( wxNode *node = m_pages.First(); node; node = node->Next() ) for ( wxNode *node = m_pages.First(); node; node = node->Next() )
{ {
wxNotebookPage *page = (wxNotebookPage*)node->Data(); wxNotebookPage *page = (wxNotebookPage*)node->Data();
if ( page->WasAdded() )
n++; if (page->WasAdded()) n++;
} }
return n; return n;
@@ -291,7 +334,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
node = node->Next(); node = node->Next();
} }
wxLogDebug( "Notebook page %d not found!", page ); wxFAIL_MSG( "Notebook page not found!" );
return (wxNotebookPage *) NULL; return (wxNotebookPage *) NULL;
} }
@@ -437,7 +480,7 @@ bool wxNotebook::RemovePage( int page )
} }
bool wxNotebook::AddPage(wxWindow* win, const wxString& text, bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
bool bSelect, int imageId) bool select, int imageId)
{ {
wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" ); wxCHECK_MSG( m_widget != NULL, FALSE, "invalid notebook" );
@@ -491,7 +534,7 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
gtk_widget_show((GtkWidget *)page->m_label); gtk_widget_show((GtkWidget *)page->m_label);
if (bSelect) SetSelection(GetPageCount()); if (select) SetSelection( GetPageCount()-1 );
return TRUE; return TRUE;
} }

View File

@@ -71,6 +71,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
{ {
m_alreadySent = FALSE; m_alreadySent = FALSE;
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@@ -282,6 +283,27 @@ int wxRadioBox::FindString( const wxString &s ) const
return -1; return -1;
} }
void wxRadioBox::SetFocus()
{
wxCHECK_RET( m_widget != NULL, "invalid radiobox" );
if (m_boxes.GetCount() == 0) return;
wxNode *node = m_boxes.First();
while (node)
{
GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() );
if (button->active)
{
gtk_widget_grab_focus( GTK_WIDGET(button) );
return;
}
node = node->Next();
}
}
void wxRadioBox::SetSelection( int n ) void wxRadioBox::SetSelection( int n )
{ {
wxCHECK_RET( m_widget != NULL, "invalid radiobox" ); wxCHECK_RET( m_widget != NULL, "invalid radiobox" );

View File

@@ -53,6 +53,7 @@ bool wxRadioButton::Create( wxWindow *parent, wxWindowID id, const wxString& lab
const wxPoint& pos, const wxSize& size, long style, const wxPoint& pos, const wxSize& size, long style,
const wxValidator& validator, const wxString& name ) const wxValidator& validator, const wxString& name )
{ {
m_acceptsFocus = TRUE;
m_needParent = TRUE; m_needParent = TRUE;
wxSize newSize = size; wxSize newSize = size;

View File

@@ -116,6 +116,7 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator, const wxString& name ) long style, const wxValidator& validator, const wxString& name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -79,6 +79,7 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator, const wxString& name ) long style, const wxValidator& validator, const wxString& name )
{ {
m_acceptsFocus = TRUE;
m_needParent = TRUE; m_needParent = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );

View File

@@ -20,6 +20,14 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>
#include "gdk/gdkkeysyms.h"
//-----------------------------------------------------------------------------
// data
//-----------------------------------------------------------------------------
extern bool g_blockEventsOnDrag;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "changed" // "changed"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -48,7 +56,6 @@ gtk_text_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* WXUNUSED(all
win->CalculateScrollbar(); win->CalculateScrollbar();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxTextCtrl // wxTextCtrl
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -81,6 +88,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
int style, const wxValidator& validator, const wxString &name ) int style, const wxValidator& validator, const wxString &name )
{ {
m_needParent = TRUE; m_needParent = TRUE;
m_acceptsFocus = TRUE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
@@ -153,8 +161,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
// we want to be notified about text changes // we want to be notified about text changes
gtk_signal_connect( GTK_OBJECT(m_text), "changed", gtk_signal_connect( GTK_OBJECT(m_text), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
(gpointer)this);
if (!value.IsNull()) if (!value.IsNull())
{ {
@@ -608,15 +615,7 @@ void wxTextCtrl::OnChar( wxKeyEvent &key_event )
event.SetEventObject(this); event.SetEventObject(this);
if (GetEventHandler()->ProcessEvent(event)) return; if (GetEventHandler()->ProcessEvent(event)) return;
} }
else if (key_event.KeyCode() == WXK_TAB)
{
wxNavigationKeyEvent event;
event.SetDirection( key_event.m_shiftDown );
event.SetWindowChange(FALSE);
event.SetEventObject(this);
if (GetEventHandler()->ProcessEvent(event)) return;
}
key_event.Skip(); key_event.Skip();
} }

View File

@@ -120,6 +120,41 @@
#endif #endif
#endif #endif
//-----------------------------------------------------------------------------
// (debug)
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event),
const char *name )
{
printf( "FOCUS NOW AT: " );
printf( name );
printf( "\n" );
return FALSE;
}
void debug_focus_in( GtkWidget* widget, const char* name, const char *window )
{
return;
wxString tmp = name;
tmp += " FROM ";
tmp += window;
char *s = new char[tmp.Length()+1];
strcpy( s, WXSTRINGCAST tmp );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -129,6 +164,7 @@ extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll; extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE; static bool g_capturing = FALSE;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
// hack: we need something to pass to gtk_menu_popup, so we store the time of // hack: we need something to pass to gtk_menu_popup, so we store the time of
// the last click here // the last click here
@@ -181,7 +217,7 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "key_press_event" // "key_press_event" from any window
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win ) static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
@@ -304,9 +340,39 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
} }
} }
// win is a control: tab can be propagated up
if ((!ret) && (gdk_event->keyval == GDK_Tab))
{
wxNavigationKeyEvent new_event;
new_event.SetDirection( !(gdk_event->state & GDK_SHIFT_MASK) );
new_event.SetWindowChange( FALSE );
new_event.SetCurrentFocus( win );
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
/*
// win is a panel: up can be propagated to the panel
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
(gdk_event->keyval == GDK_Up))
{
win->m_parent->SetFocus();
ret = TRUE;
}
// win is a panel: left/right can be propagated to the panel
if ((!ret) && (win->m_wxwindow) &&
((gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Left) ||
(gdk_event->keyval == GDK_Up) || (gdk_event->keyval == GDK_Down)))
{
wxNavigationKeyEvent new_event;
new_event.SetDirection( (gdk_event->keyval == GDK_Right) || (gdk_event->keyval == GDK_Down) );
new_event.SetCurrentFocus( win );
ret = win->GetEventHandler()->ProcessEvent( new_event );
}
*/
if (ret) if (ret)
{ {
if ((gdk_event->keyval >= 0x20) && (gdk_event->keyval <= 0xFF))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
} }
@@ -658,6 +724,9 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win ) static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{ {
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
g_focusWindow = win;
if (win->m_wxwindow) if (win->m_wxwindow)
{ {
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow)) if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
@@ -729,10 +798,13 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{ {
if (widget->window != gdk_event->window) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
if (widget->window != gdk_event->window) return TRUE;
if (!win->HasVMT()) return TRUE; if (!win->HasVMT()) return TRUE;
/* /*
@@ -742,9 +814,6 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
printf( ".\n" ); printf( ".\n" );
*/ */
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
wxMouseEvent event( wxEVT_ENTER_WINDOW ); wxMouseEvent event( wxEVT_ENTER_WINDOW );
event.SetEventObject( win ); event.SetEventObject( win );
@@ -777,10 +846,13 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{ {
if (widget->window != gdk_event->window) return TRUE;
if (g_blockEventsOnDrag) return TRUE; if (g_blockEventsOnDrag) return TRUE;
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
if (widget->window != gdk_event->window) return TRUE;
if (!win->HasVMT()) return TRUE; if (!win->HasVMT()) return TRUE;
/* /*
@@ -790,9 +862,6 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
printf( ".\n" ); printf( ".\n" );
*/ */
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
wxMouseEvent event( wxEVT_LEAVE_WINDOW ); wxMouseEvent event( wxEVT_LEAVE_WINDOW );
event.SetEventObject( win ); event.SetEventObject( win );
@@ -1104,6 +1173,7 @@ wxWindow::wxWindow()
m_clientData = NULL; m_clientData = NULL;
m_isStaticBox = FALSE; m_isStaticBox = FALSE;
m_acceptsFocus = FALSE;
} }
wxWindow::wxWindow( wxWindow *parent, wxWindowID id, wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@@ -1127,8 +1197,17 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxWindow::m_widget", name );
#endif
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget); GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
#ifdef __WXDEBUG__
debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
#endif
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass ); GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0; scroll_class->scrollbar_spacing = 0;
@@ -1142,6 +1221,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, "wxWindow::m_wxwindow", name );
#endif
#ifdef NEW_GTK_SCROLL_CODE #ifdef NEW_GTK_SCROLL_CODE
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow ); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow );
GtkViewport *viewport = GTK_VIEWPORT(s_window->child); GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
@@ -1150,6 +1233,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport); GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
#endif #endif
#ifdef __WXDEBUG__
debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
#endif
if (m_windowStyle & wxRAISED_BORDER) if (m_windowStyle & wxRAISED_BORDER)
{ {
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT ); gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_OUT );
@@ -1163,10 +1250,16 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE ); gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
} }
if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL) if ((m_windowStyle & wxTAB_TRAVERSAL) != 0)
{
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = FALSE;
}
else else
{
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
}
// shut the viewport up // shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) ); gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
@@ -1906,11 +1999,28 @@ void wxWindow::SetFocus()
GtkWidget *connect_widget = GetConnectWidget(); GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget) if (connect_widget)
{ {
if (GTK_WIDGET_CAN_FOCUS(connect_widget) && !GTK_WIDGET_HAS_FOCUS (connect_widget) ) if (GTK_WIDGET_CAN_FOCUS(connect_widget) /*&& !GTK_WIDGET_HAS_FOCUS (connect_widget)*/ )
{ {
gtk_widget_grab_focus (connect_widget); gtk_widget_grab_focus (connect_widget);
} }
else if (GTK_IS_CONTAINER(connect_widget))
{
gtk_container_focus( GTK_CONTAINER(connect_widget), GTK_DIR_TAB_FORWARD );
} }
else
{
}
}
}
wxWindow *wxWindow::FindFocus()
{
return g_focusWindow;
}
bool wxWindow::AcceptsFocus() const
{
return IsEnabled() && IsShown() && m_acceptsFocus;
} }
bool wxWindow::OnClose() bool wxWindow::OnClose()
@@ -3164,11 +3274,6 @@ void wxWindow::GetPositionConstraint(int *x, int *y) const
GetPosition(x, y); GetPosition(x, y);
} }
bool wxWindow::AcceptsFocus() const
{
return IsEnabled() && IsShown();
}
void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) ) void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) )
{ {
UpdateWindowUI(); UpdateWindowUI();