Added CTRL-TAB navigation to notebook
Added ESC -> Cancel convresion Added greying out of tooltips (I had some spare minutes) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1683 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -153,6 +153,7 @@ public:
|
|||||||
// get the panel which represents the given page
|
// get the panel which represents the given page
|
||||||
wxWindow *GetPage(int nPage) const;
|
wxWindow *GetPage(int nPage) const;
|
||||||
|
|
||||||
|
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
@@ -171,6 +172,7 @@ public:
|
|||||||
size_t m_idHandler; // the change page handler id
|
size_t m_idHandler; // the change page handler id
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -153,6 +153,7 @@ public:
|
|||||||
// get the panel which represents the given page
|
// get the panel which represents the given page
|
||||||
wxWindow *GetPage(int nPage) const;
|
wxWindow *GetPage(int nPage) const;
|
||||||
|
|
||||||
|
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
|
|
||||||
@@ -171,6 +172,7 @@ public:
|
|||||||
size_t m_idHandler; // the change page handler id
|
size_t m_idHandler; // the change page handler id
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||||
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -141,6 +141,8 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
|
|||||||
toolBar->AddSeparator();
|
toolBar->AddSeparator();
|
||||||
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help");
|
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help");
|
||||||
|
|
||||||
|
toolBar->EnableTool( wxID_PRINT, FALSE );
|
||||||
|
|
||||||
toolBar->Realize();
|
toolBar->Realize();
|
||||||
|
|
||||||
// Can delete the bitmaps since they're reference counted
|
// Can delete the bitmaps since they're reference counted
|
||||||
|
@@ -128,6 +128,10 @@ gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNo
|
|||||||
|
|
||||||
if (!notebook->HasVMT()) return FALSE;
|
if (!notebook->HasVMT()) return FALSE;
|
||||||
|
|
||||||
|
/* this code makes jumping down from the handles of the notebooks
|
||||||
|
to the actual items in the visible notebook page possible with
|
||||||
|
the down-arrow key */
|
||||||
|
|
||||||
if (gdk_event->keyval != GDK_Down) return FALSE;
|
if (gdk_event->keyval != GDK_Down) return FALSE;
|
||||||
|
|
||||||
if (notebook != notebook->FindFocus()) return FALSE;
|
if (notebook != notebook->FindFocus()) return FALSE;
|
||||||
@@ -184,6 +188,10 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
|
||||||
|
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
void wxNotebook::Init()
|
void wxNotebook::Init()
|
||||||
{
|
{
|
||||||
m_imageList = (wxImageList *) NULL;
|
m_imageList = (wxImageList *) NULL;
|
||||||
@@ -381,7 +389,7 @@ void wxNotebook::AdvanceSelection( bool bForward )
|
|||||||
if (bForward)
|
if (bForward)
|
||||||
SetSelection( sel == max ? 0 : sel + 1 );
|
SetSelection( sel == max ? 0 : sel + 1 );
|
||||||
else
|
else
|
||||||
SetSelection( sel == 0 ? max : sel - 1 );
|
SetSelection( sel == 0 ? max-1 : sel - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNotebook::SetImageList( wxImageList* imageList )
|
void wxNotebook::SetImageList( wxImageList* imageList )
|
||||||
@@ -624,6 +632,14 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||||
|
{
|
||||||
|
if (event.IsWindowChange())
|
||||||
|
AdvanceSelection( event.GetDirection() );
|
||||||
|
else
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
wxWindow *wxNotebook::GetPage( int page ) const
|
wxWindow *wxNotebook::GetPage( int page ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
|
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
|
||||||
|
@@ -79,7 +79,36 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
{
|
{
|
||||||
if (g_blockEventsOnDrag) return TRUE;
|
if (g_blockEventsOnDrag) return TRUE;
|
||||||
|
|
||||||
tool->m_owner->OnMouseEnter( tool->m_index );
|
/* we grey-out the tip text of disabled tool */
|
||||||
|
|
||||||
|
wxToolBar *tb = tool->m_owner;
|
||||||
|
|
||||||
|
if (tool->m_enabled)
|
||||||
|
{
|
||||||
|
if (tb->m_fg->red != 0)
|
||||||
|
{
|
||||||
|
tb->m_fg->red = 0;
|
||||||
|
tb->m_fg->green = 0;
|
||||||
|
tb->m_fg->blue = 0;
|
||||||
|
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
|
||||||
|
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tb->m_fg->red == 0)
|
||||||
|
{
|
||||||
|
tb->m_fg->red = 33000;
|
||||||
|
tb->m_fg->green = 33000;
|
||||||
|
tb->m_fg->blue = 33000;
|
||||||
|
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
|
||||||
|
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* emit the event */
|
||||||
|
|
||||||
|
tb->OnMouseEnter( tool->m_index );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -301,8 +330,12 @@ void wxToolBar::EnableTool(int toolIndex, bool enable)
|
|||||||
{
|
{
|
||||||
tool->m_enabled = enable;
|
tool->m_enabled = enable;
|
||||||
|
|
||||||
|
/* we don't disable the tools for now as the bitmaps don't get
|
||||||
|
greyed anyway and this also disables tooltips
|
||||||
|
|
||||||
if (tool->m_item)
|
if (tool->m_item)
|
||||||
gtk_widget_set_sensitive( tool->m_item, enable );
|
gtk_widget_set_sensitive( tool->m_item, enable );
|
||||||
|
*/
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -355,13 +355,25 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
|||||||
((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
|
((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent new_event;
|
wxNavigationKeyEvent new_event;
|
||||||
|
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
||||||
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
||||||
new_event.SetWindowChange( FALSE );
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
|
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
|
||||||
new_event.SetCurrentFocus( win );
|
new_event.SetCurrentFocus( win );
|
||||||
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (!ret) &&
|
||||||
|
(gdk_event->keyval == GDK_Escape) )
|
||||||
|
{
|
||||||
|
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
||||||
|
new_event.SetEventObject( win );
|
||||||
|
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Damn, I forgot why this didn't work, but it didn't work.
|
||||||
|
|
||||||
// win is a panel: up can be propagated to the panel
|
// win is a panel: up can be propagated to the panel
|
||||||
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
|
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
|
||||||
(gdk_event->keyval == GDK_Up))
|
(gdk_event->keyval == GDK_Up))
|
||||||
@@ -501,7 +513,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
|
|||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@@ -128,6 +128,10 @@ gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNo
|
|||||||
|
|
||||||
if (!notebook->HasVMT()) return FALSE;
|
if (!notebook->HasVMT()) return FALSE;
|
||||||
|
|
||||||
|
/* this code makes jumping down from the handles of the notebooks
|
||||||
|
to the actual items in the visible notebook page possible with
|
||||||
|
the down-arrow key */
|
||||||
|
|
||||||
if (gdk_event->keyval != GDK_Down) return FALSE;
|
if (gdk_event->keyval != GDK_Down) return FALSE;
|
||||||
|
|
||||||
if (notebook != notebook->FindFocus()) return FALSE;
|
if (notebook != notebook->FindFocus()) return FALSE;
|
||||||
@@ -184,6 +188,10 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
|
||||||
|
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
void wxNotebook::Init()
|
void wxNotebook::Init()
|
||||||
{
|
{
|
||||||
m_imageList = (wxImageList *) NULL;
|
m_imageList = (wxImageList *) NULL;
|
||||||
@@ -381,7 +389,7 @@ void wxNotebook::AdvanceSelection( bool bForward )
|
|||||||
if (bForward)
|
if (bForward)
|
||||||
SetSelection( sel == max ? 0 : sel + 1 );
|
SetSelection( sel == max ? 0 : sel + 1 );
|
||||||
else
|
else
|
||||||
SetSelection( sel == 0 ? max : sel - 1 );
|
SetSelection( sel == 0 ? max-1 : sel - 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNotebook::SetImageList( wxImageList* imageList )
|
void wxNotebook::SetImageList( wxImageList* imageList )
|
||||||
@@ -624,6 +632,14 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||||
|
{
|
||||||
|
if (event.IsWindowChange())
|
||||||
|
AdvanceSelection( event.GetDirection() );
|
||||||
|
else
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
wxWindow *wxNotebook::GetPage( int page ) const
|
wxWindow *wxNotebook::GetPage( int page ) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
|
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
|
||||||
|
@@ -79,7 +79,36 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
{
|
{
|
||||||
if (g_blockEventsOnDrag) return TRUE;
|
if (g_blockEventsOnDrag) return TRUE;
|
||||||
|
|
||||||
tool->m_owner->OnMouseEnter( tool->m_index );
|
/* we grey-out the tip text of disabled tool */
|
||||||
|
|
||||||
|
wxToolBar *tb = tool->m_owner;
|
||||||
|
|
||||||
|
if (tool->m_enabled)
|
||||||
|
{
|
||||||
|
if (tb->m_fg->red != 0)
|
||||||
|
{
|
||||||
|
tb->m_fg->red = 0;
|
||||||
|
tb->m_fg->green = 0;
|
||||||
|
tb->m_fg->blue = 0;
|
||||||
|
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
|
||||||
|
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (tb->m_fg->red == 0)
|
||||||
|
{
|
||||||
|
tb->m_fg->red = 33000;
|
||||||
|
tb->m_fg->green = 33000;
|
||||||
|
tb->m_fg->blue = 33000;
|
||||||
|
gdk_color_alloc( gtk_widget_get_colormap( GTK_WIDGET(tb->m_toolbar) ), tb->m_fg );
|
||||||
|
gtk_tooltips_set_colors( GTK_TOOLBAR(tb->m_toolbar)->tooltips, tb->m_bg, tb->m_fg );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* emit the event */
|
||||||
|
|
||||||
|
tb->OnMouseEnter( tool->m_index );
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -301,8 +330,12 @@ void wxToolBar::EnableTool(int toolIndex, bool enable)
|
|||||||
{
|
{
|
||||||
tool->m_enabled = enable;
|
tool->m_enabled = enable;
|
||||||
|
|
||||||
|
/* we don't disable the tools for now as the bitmaps don't get
|
||||||
|
greyed anyway and this also disables tooltips
|
||||||
|
|
||||||
if (tool->m_item)
|
if (tool->m_item)
|
||||||
gtk_widget_set_sensitive( tool->m_item, enable );
|
gtk_widget_set_sensitive( tool->m_item, enable );
|
||||||
|
*/
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -355,13 +355,25 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
|||||||
((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
|
((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
|
||||||
{
|
{
|
||||||
wxNavigationKeyEvent new_event;
|
wxNavigationKeyEvent new_event;
|
||||||
|
/* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
|
||||||
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
|
||||||
new_event.SetWindowChange( FALSE );
|
/* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
|
||||||
|
new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) );
|
||||||
new_event.SetCurrentFocus( win );
|
new_event.SetCurrentFocus( win );
|
||||||
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( (!ret) &&
|
||||||
|
(gdk_event->keyval == GDK_Escape) )
|
||||||
|
{
|
||||||
|
wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
|
||||||
|
new_event.SetEventObject( win );
|
||||||
|
ret = win->GetEventHandler()->ProcessEvent( new_event );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Damn, I forgot why this didn't work, but it didn't work.
|
||||||
|
|
||||||
// win is a panel: up can be propagated to the panel
|
// win is a panel: up can be propagated to the panel
|
||||||
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
|
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
|
||||||
(gdk_event->keyval == GDK_Up))
|
(gdk_event->keyval == GDK_Up))
|
||||||
@@ -501,7 +513,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
|
|||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
|
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user