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:
parent
48b7862630
commit
b98d804b28
@ -153,6 +153,7 @@ public:
|
||||
// get the panel which represents the given page
|
||||
wxWindow *GetPage(int nPage) const;
|
||||
|
||||
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||
|
||||
// implementation
|
||||
|
||||
@ -171,6 +172,7 @@ public:
|
||||
size_t m_idHandler; // the change page handler id
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -153,6 +153,7 @@ public:
|
||||
// get the panel which represents the given page
|
||||
wxWindow *GetPage(int nPage) const;
|
||||
|
||||
void OnNavigationKey(wxNavigationKeyEvent& event);
|
||||
|
||||
// implementation
|
||||
|
||||
@ -171,6 +172,7 @@ public:
|
||||
size_t m_idHandler; // the change page handler id
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxNotebook)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -140,6 +140,8 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
|
||||
currentX += width + 5;
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help");
|
||||
|
||||
toolBar->EnableTool( wxID_PRINT, FALSE );
|
||||
|
||||
toolBar->Realize();
|
||||
|
||||
|
@ -127,6 +127,10 @@ gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNo
|
||||
if (g_blockEventsOnDrag) 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;
|
||||
|
||||
@ -184,6 +188,10 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
|
||||
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
m_imageList = (wxImageList *) NULL;
|
||||
@ -381,7 +389,7 @@ void wxNotebook::AdvanceSelection( bool bForward )
|
||||
if (bForward)
|
||||
SetSelection( sel == max ? 0 : sel + 1 );
|
||||
else
|
||||
SetSelection( sel == 0 ? max : sel - 1 );
|
||||
SetSelection( sel == 0 ? max-1 : sel - 1 );
|
||||
}
|
||||
|
||||
void wxNotebook::SetImageList( wxImageList* imageList )
|
||||
@ -624,6 +632,14 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||
{
|
||||
if (event.IsWindowChange())
|
||||
AdvanceSelection( event.GetDirection() );
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
wxWindow *wxNotebook::GetPage( int page ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
|
||||
|
@ -78,8 +78,37 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
|
||||
{
|
||||
if (g_blockEventsOnDrag) return TRUE;
|
||||
|
||||
/* 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 */
|
||||
|
||||
tool->m_owner->OnMouseEnter( tool->m_index );
|
||||
tb->OnMouseEnter( tool->m_index );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -301,8 +330,12 @@ void wxToolBar::EnableTool(int toolIndex, bool 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)
|
||||
gtk_widget_set_sensitive( tool->m_item, enable );
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -355,13 +355,25 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
||||
((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
|
||||
{
|
||||
wxNavigationKeyEvent new_event;
|
||||
/* GDK reports GDK_ISO_Left_Tab for SHIFT-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 );
|
||||
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
|
||||
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
|
||||
(gdk_event->keyval == GDK_Up))
|
||||
@ -501,7 +513,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
|
||||
|
||||
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;
|
||||
|
@ -127,6 +127,10 @@ gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNo
|
||||
if (g_blockEventsOnDrag) 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;
|
||||
|
||||
@ -184,6 +188,10 @@ static void wxInsertChildInNotebook( wxNotebook* parent, wxWindow* child )
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxNotebook, wxControl)
|
||||
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void wxNotebook::Init()
|
||||
{
|
||||
m_imageList = (wxImageList *) NULL;
|
||||
@ -381,7 +389,7 @@ void wxNotebook::AdvanceSelection( bool bForward )
|
||||
if (bForward)
|
||||
SetSelection( sel == max ? 0 : sel + 1 );
|
||||
else
|
||||
SetSelection( sel == 0 ? max : sel - 1 );
|
||||
SetSelection( sel == 0 ? max-1 : sel - 1 );
|
||||
}
|
||||
|
||||
void wxNotebook::SetImageList( wxImageList* imageList )
|
||||
@ -624,6 +632,14 @@ bool wxNotebook::AddPage(wxWindow* win, const wxString& text,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||
{
|
||||
if (event.IsWindowChange())
|
||||
AdvanceSelection( event.GetDirection() );
|
||||
else
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
wxWindow *wxNotebook::GetPage( int page ) const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, (wxWindow*) NULL, "invalid notebook" );
|
||||
|
@ -78,8 +78,37 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
||||
GdkEventCrossing *WXUNUSED(gdk_event), wxToolBarTool *tool )
|
||||
{
|
||||
if (g_blockEventsOnDrag) return TRUE;
|
||||
|
||||
/* 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 */
|
||||
|
||||
tool->m_owner->OnMouseEnter( tool->m_index );
|
||||
tb->OnMouseEnter( tool->m_index );
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -301,8 +330,12 @@ void wxToolBar::EnableTool(int toolIndex, bool 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)
|
||||
gtk_widget_set_sensitive( tool->m_item, enable );
|
||||
*/
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -355,13 +355,25 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
||||
((win->m_windowStyle & wxTE_PROCESS_TAB) == 0))
|
||||
{
|
||||
wxNavigationKeyEvent new_event;
|
||||
/* GDK reports GDK_ISO_Left_Tab for SHIFT-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 );
|
||||
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
|
||||
if ((!ret) && (win->m_wxwindow) && (win->m_parent) && (win->m_parent->AcceptsFocus()) &&
|
||||
(gdk_event->keyval == GDK_Up))
|
||||
@ -501,7 +513,7 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user