Chnages to focus code with debug code

added wxSL_LABELS


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2297 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1999-04-28 08:29:22 +00:00
parent c05cbb7f5e
commit 2e563988fb
8 changed files with 218 additions and 18 deletions

View File

@ -46,6 +46,16 @@ extern bool g_isIdle;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "size_allocate" // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -216,6 +226,21 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
win->SetIcon( icon ); win->SetIcon( icon );
} }
/* we set the focus to the child that accepts the focus. this
doesn't really have to be done in "realize" but why not? */
wxNode *node = win->m_children.First();
while (node)
{
wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus())
{
child->SetFocus();
break;
}
node = node->Next();
}
return FALSE; return FALSE;
} }
@ -336,6 +361,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, _T("wxFrame::m_widget"), name );
#endif
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
@ -348,17 +377,22 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
#ifdef __WXDEBUG__
debug_focus_in( m_mainWidget, _T("wxFrame::m_mainWidget"), name );
#endif
/* m_wxwindow only represents the client area without toolbar and menubar */ /* m_wxwindow only represents the client area without toolbar and menubar */
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
/* we allow the frame to get the focus as otherwise no #ifdef __WXDEBUG__
key events will get sent to it. the point with this is debug_focus_in( m_wxwindow, _T("wxFrame::m_wxwindow"), name );
that the menu's key accelerators work by interceting #endif
key events here */
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* we donm't allow the frame to get the focus as otherwise
gtk_widget_grab_focus( m_wxwindow ); the frame will grabit at arbitrary fcous changes. */
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );

View File

@ -36,6 +36,16 @@ extern bool g_isIdle;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxNotebookPage // wxNotebookPage
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -246,6 +256,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
m_widget = gtk_notebook_new(); m_widget = gtk_notebook_new();
#ifdef __WXDEBUG__
debug_focus_in( m_widget, _T("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 (

View File

@ -101,11 +101,14 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
m_oldPos = 0.0; m_oldPos = 0.0;
if (style & wxSL_VERTICAL == wxSL_VERTICAL) if (style & wxSL_VERTICAL)
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
else else
m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
if (style & wxSL_LABELS)
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
else
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );

View File

@ -121,6 +121,39 @@
*/ */
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event),
const wxChar *name )
{
wxPrintf( _T("FOCUS NOW AT: ") );
wxPrintf( name );
wxPrintf( _T("\n") );
return FALSE;
}
void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window )
{
wxString tmp = name;
tmp += _T(" FROM ");
tmp += window;
wxChar *s = new wxChar[tmp.Length()+1];
wxStrcpy( s, tmp );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1542,8 +1575,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, _T("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, _T("wxWindow::hsrcollbar"), name );
debug_focus_in( s_window->vscrollbar, _T("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;
@ -1558,6 +1600,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, _T("wxWindow::m_wxwindow"), name );
#endif
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
#if (GTK_MINOR_VERSION > 0) #if (GTK_MINOR_VERSION > 0)
@ -1606,7 +1652,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
} }
/* grab the actual focus */ /* grab the actual focus */
gtk_widget_grab_focus( m_wxwindow ); // gtk_widget_grab_focus( m_wxwindow );
#if (GTK_MINOR_VERSION == 0) #if (GTK_MINOR_VERSION == 0)
// shut the viewport up // shut the viewport up
@ -2284,6 +2330,9 @@ void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSE
void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
{ {
/* this is commented because it also is commented
in wxMSW. before I get even more questions about
this. */
// if (GetAutoLayout()) Layout(); // if (GetAutoLayout()) Layout();
} }

View File

@ -46,6 +46,16 @@ extern bool g_isIdle;
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// "size_allocate" // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -216,6 +226,21 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
win->SetIcon( icon ); win->SetIcon( icon );
} }
/* we set the focus to the child that accepts the focus. this
doesn't really have to be done in "realize" but why not? */
wxNode *node = win->m_children.First();
while (node)
{
wxWindow *child = (wxWindow*) node->Data();
if (child->AcceptsFocus())
{
child->SetFocus();
break;
}
node = node->Next();
}
return FALSE; return FALSE;
} }
@ -336,6 +361,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, _T("wxFrame::m_widget"), name );
#endif
gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() ); gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
@ -348,17 +377,22 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
#ifdef __WXDEBUG__
debug_focus_in( m_mainWidget, _T("wxFrame::m_mainWidget"), name );
#endif
/* m_wxwindow only represents the client area without toolbar and menubar */ /* m_wxwindow only represents the client area without toolbar and menubar */
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow );
/* we allow the frame to get the focus as otherwise no #ifdef __WXDEBUG__
key events will get sent to it. the point with this is debug_focus_in( m_wxwindow, _T("wxFrame::m_wxwindow"), name );
that the menu's key accelerators work by interceting #endif
key events here */
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); /* we donm't allow the frame to get the focus as otherwise
gtk_widget_grab_focus( m_wxwindow ); the frame will grabit at arbitrary fcous changes. */
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );

View File

@ -36,6 +36,16 @@ extern bool g_isIdle;
extern bool g_blockEventsOnDrag; extern bool g_blockEventsOnDrag;
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
extern void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window );
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxNotebookPage // wxNotebookPage
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -246,6 +256,10 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
m_widget = gtk_notebook_new(); m_widget = gtk_notebook_new();
#ifdef __WXDEBUG__
debug_focus_in( m_widget, _T("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 (

View File

@ -101,11 +101,14 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
m_oldPos = 0.0; m_oldPos = 0.0;
if (style & wxSL_VERTICAL == wxSL_VERTICAL) if (style & wxSL_VERTICAL)
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
else else
m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
if (style & wxSL_LABELS)
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
else
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );

View File

@ -121,6 +121,39 @@
*/ */
//-----------------------------------------------------------------------------
// debug
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event),
const wxChar *name )
{
wxPrintf( _T("FOCUS NOW AT: ") );
wxPrintf( name );
wxPrintf( _T("\n") );
return FALSE;
}
void debug_focus_in( GtkWidget* widget, const wxChar* name, const wxChar *window )
{
wxString tmp = name;
tmp += _T(" FROM ");
tmp += window;
wxChar *s = new wxChar[tmp.Length()+1];
wxStrcpy( s, tmp );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// data // data
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -1542,8 +1575,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, _T("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, _T("wxWindow::hsrcollbar"), name );
debug_focus_in( s_window->vscrollbar, _T("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;
@ -1558,6 +1600,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, _T("wxWindow::m_wxwindow"), name );
#endif
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
#if (GTK_MINOR_VERSION > 0) #if (GTK_MINOR_VERSION > 0)
@ -1606,7 +1652,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
} }
/* grab the actual focus */ /* grab the actual focus */
gtk_widget_grab_focus( m_wxwindow ); // gtk_widget_grab_focus( m_wxwindow );
#if (GTK_MINOR_VERSION == 0) #if (GTK_MINOR_VERSION == 0)
// shut the viewport up // shut the viewport up
@ -2284,6 +2330,9 @@ void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSE
void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) ) void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
{ {
/* this is commented because it also is commented
in wxMSW. before I get even more questions about
this. */
// if (GetAutoLayout()) Layout(); // if (GetAutoLayout()) Layout();
} }