#define _WX_CONTAINR_H_
// use native tab traversal logic under GTK+ 2 (doesn't work yet)
-#if 0 // def __WXGTK20__
+#ifdef __WXGTK20__
#define wxHAS_NATIVE_TAB_TRAVERSAL
#endif
virtual bool IsRetained() const;
virtual void SetFocus();
- virtual bool AcceptsFocus() const;
virtual bool Reparent( wxWindowBase *newParent );
protected:
// Override GTKWidgetNeedsMnemonic and return true if your
- // needs to set its mnemonic widget, such as for a
+ // needs to set its mnemonic widget, such as for a
// GtkLabel for wxStaticText, then do the actual
// setting of the widget inside GTKWidgetDoSetMnemonic
virtual bool GTKWidgetNeedsMnemonic() const;
// the layouting functions have to be called later on
// (i.e. in idle time, implemented in OnInternalIdle() ).
void GtkUpdateSize() { m_sizeSet = false; }
-
-
+
+
// Called when a window should delay showing itself
// until idle time. This partly mimmicks defered
// sizing under MSW.
void GtkShowOnIdle() { m_showOnIdle = true; }
-
+
// This is called from the various OnInternalIdle methods
bool GtkShowFromOnIdle();
bool m_hasVMT:1;
bool m_sizeSet:1;
bool m_resizing:1;
- bool m_acceptsFocus:1; // true if not static
bool m_hasFocus:1; // true if == FindFocus()
bool m_isScrolling:1; // dragging scrollbar thumb?
bool m_clipPaintRegion:1; // true after ScrollWindow()
// background style until OnIdle
bool m_mouseButtonDown:1;
bool m_blockScrollEvent:1;
-
+
bool m_showOnIdle:1; // postpone showing the window until idle
// C++ has no virtual methods in the constrcutor of any class but we need
const wxString& name)
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!base_type::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
const wxString &name )
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
long style, const wxValidator& validator, const wxString &name )
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
const wxString &name )
{
m_needParent = true;
- m_acceptsFocus = true;
m_blockEvent = false;
if (!PreCreation( parent, pos, size ) ||
long style, const wxValidator& validator, const wxString &name )
{
m_needParent = true;
-#if (GTK_MINOR_VERSION > 0)
- m_acceptsFocus = true;
-#endif
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
if (!gtk_check_version(2,4,0))
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style, validator, name))
pos, size, style, val, name);
m_needParent = true;
- m_acceptsFocus = true;
m_bIgnoreNextChange = false;
if ( !PreCreation( parent, pos, size ) ||
{
m_ignoreNextUpdate = false;
m_needParent = true;
- m_acceptsFocus = true;
m_prevSelection = 0;
if (!PreCreation( parent, pos, size ) ||
Init();
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator ))
// if you find a problem here, fix it also in wxDirButton !
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
// if you find a problem here, fix it also in wxFileButton !
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
if (!gtk_check_version(2,4,0))
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!wxControl::CreateBase(parent, id, pos, size, style, validator, name))
CheckParams(label, url, style);
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
const wxString &name )
{
m_needParent = true;
- m_acceptsFocus = true;
m_blockEvent = false;
if (!PreCreation( parent, pos, size ) ||
}
}
-//-----------------------------------------------------------------------------
-// "key_press_event"
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static gboolean
-gtk_notebook_key_press_callback( GtkWidget *widget,
- GdkEventKey *gdk_event,
- wxNotebook *notebook )
-{
- // don't need to install idle handler, its done from "event" signal
-
- if (!notebook->m_hasVMT) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
-
- /* win is a control: tab can be propagated up */
- if ((gdk_event->keyval == GDK_Left) || (gdk_event->keyval == GDK_Right))
- {
- int page;
- int nMax = notebook->GetPageCount();
- if ( nMax-- ) // decrement it to get the last valid index
- {
- int nSel = notebook->GetSelection();
-
- // change selection wrapping if it becomes invalid
- page = (gdk_event->keyval != GDK_Left) ? nSel == nMax ? 0
- : nSel + 1
- : nSel == 0 ? nMax
- : nSel - 1;
- }
- else // notebook is empty, no next page
- {
- return FALSE;
- }
-
- gtk_notebook_set_current_page( GTK_NOTEBOOK(widget), page );
-
- return TRUE;
- }
-
- /* win is a control: tab can be propagated up */
- if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
- {
- int sel = notebook->GetSelection();
- if (sel == -1)
- return TRUE;
- wxGtkNotebookPage *nb_page = notebook->GetNotebookPage(sel);
- wxCHECK_MSG( nb_page, FALSE, _T("invalid selection in wxNotebook") );
-
- wxNavigationKeyEvent event;
- event.SetEventObject( notebook );
- /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
- event.SetDirection( (gdk_event->keyval == GDK_Tab) );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
- event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ||
- (gdk_event->keyval == GDK_Left) || (gdk_event->keyval == GDK_Right) );
- event.SetCurrentFocus( notebook );
-
- wxNotebookPage *client = notebook->GetPage(sel);
- if ( !client->GetEventHandler()->ProcessEvent( event ) )
- {
- client->SetFocus();
- }
-
- return TRUE;
- }
-
- return FALSE;
-}
-}
-
//-----------------------------------------------------------------------------
// InsertChild callback for wxNotebook
//-----------------------------------------------------------------------------
long style, const wxString& name )
{
m_needParent = true;
- m_acceptsFocus = true;
m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook;
if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
if (m_windowStyle & wxBK_BOTTOM)
gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM );
- g_signal_connect (m_widget, "key_press_event",
- G_CALLBACK (gtk_notebook_key_press_callback), this);
-
PostCreation(size);
g_signal_connect (m_widget, "realize",
}
}
-//-----------------------------------------------------------------------------
-// "focus" from m_window
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
-{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- /* This disables GTK's tab traversal */
- return TRUE;
-}
-}
-
//-----------------------------------------------------------------------------
// "delete_event"
//-----------------------------------------------------------------------------
g_signal_connect (m_widget, "realize",
G_CALLBACK (gtk_dialog_realized_callback), this);
- // disable native tab traversal
- g_signal_connect (m_widget, "focus",
- G_CALLBACK (gtk_dialog_focus_callback), this);
-
m_time = gtk_get_current_event_time();
g_signal_connect (m_widget, "button_press_event",
void wxRadioBox::Init()
{
m_needParent = true;
- m_acceptsFocus = true;
m_hasFocus =
m_lostFocus = false;
const wxValidator& validator,
const wxString& name )
{
- m_acceptsFocus = TRUE;
m_needParent = TRUE;
m_blockEvent = FALSE;
long style, const wxValidator& validator, const wxString& name )
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
const wxPoint& pos, const wxSize& size,
long style, const wxValidator& validator, const wxString& name )
{
- m_acceptsFocus = true;
m_needParent = true;
if (!PreCreation( parent, pos, size ) ||
const wxString& name)
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
const wxString &name )
{
m_needParent = true;
- m_acceptsFocus = true;
if (!PreCreation( parent, pos, size ) ||
!CreateBase( parent, id, pos, size, style, validator, name ))
const wxString &name)
{
m_needParent = true;
- m_acceptsFocus = true;
m_blockEvent = false;
const wxString &name)
{
m_needParent = true;
- m_acceptsFocus = true;
m_blockEvent = false;
}
}
-//-----------------------------------------------------------------------------
-// "focus" from m_window
-//-----------------------------------------------------------------------------
-
-extern "C" {
-static gboolean gtk_frame_focus_callback( GtkWidget *WXUNUSED(widget),
- GtkDirectionType WXUNUSED(d),
- wxWindow *WXUNUSED(win) )
-{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- // This disables GTK's tab traversal
- return TRUE;
-}
-}
-
//-----------------------------------------------------------------------------
// "size_allocate"
//-----------------------------------------------------------------------------
g_signal_connect (m_widget, "configure_event",
G_CALLBACK (gtk_frame_configure_callback), this);
- // disable native tab traversal
- g_signal_connect (m_widget, "focus",
- G_CALLBACK (gtk_frame_focus_callback), this);
-
// activation
g_signal_connect_after (m_widget, "focus_in_event",
G_CALLBACK (gtk_frame_focus_in_callback), this);
static void
gtk_pizza_init (GtkPizza *pizza)
{
+ GTK_WIDGET_SET_FLAGS (pizza, GTK_CAN_FOCUS);
GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW);
pizza->children = NULL;
}
}
- // win is a control: tab can be propagated up
- if ( !ret &&
- ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
-// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here - the control may
-// have this style, yet choose not to process this particular TAB in which
-// case TAB must still work as a navigational character
-// JS: enabling again to make consistent with other platforms
-// (with wxTE_PROCESS_TAB you have to call Navigate to get default
-// navigation behaviour)
-#if wxUSE_TEXTCTRL
- (! (win->HasFlag(wxTE_PROCESS_TAB) && win->IsKindOf(CLASSINFO(wxTextCtrl)) )) &&
-#endif
- win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
- {
- wxNavigationKeyEvent new_event;
- new_event.SetEventObject( win->GetParent() );
- // GDK reports GDK_ISO_Left_Tab for SHIFT-TAB
- new_event.SetDirection( (gdk_event->keyval == GDK_Tab) );
- // 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->GetParent()->GetEventHandler()->ProcessEvent( new_event );
- }
-
return ret;
}
}
return FALSE;
}
+static gboolean
+wx_window_focus_callback(GtkWidget *widget,
+ GtkDirectionType direction,
+ wxWindowGTK *win)
+{
+ // the default handler for focus signal in GtkPizza (or, rather, in
+ // GtkScrolledWindow from which GtkPizza inherits this behaviour) sets
+ // focus to the window itself even if it doesn't accept focus, i.e. has no
+ // GTK_CAN_FOCUS in its style -- work around this by forcibly preventing
+ // the signal from reaching gtk_scrolled_window_focus() if we don't have
+ // any children which might accept focus (we know we don't accept the focus
+ // ourselves as this signal is only connected in this case)
+ if ( win->GetChildren().empty() )
+ g_signal_stop_emission_by_name(widget, "focus");
+
+ // we didn't change the focus
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// "enter_notify_event"
//-----------------------------------------------------------------------------
m_insertCallback = (wxInsertChildFunction) NULL;
- m_acceptsFocus = false;
m_hasFocus = false;
m_clipPaintRegion = false;
m_insertCallback = wxInsertChildInWindow;
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
- GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget);
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
- GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
- m_acceptsFocus = true;
-
// connect various scroll-related events
for ( int dir = 0; dir < ScrollDir_Max; dir++ )
{
}
}
+ if ( !AcceptsFocusFromKeyboard() )
+ {
+ GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+ if ( m_wxwindow )
+ GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
+
+ g_signal_connect(m_widget, "focus",
+ G_CALLBACK(wx_window_focus_callback), this);
+ }
+
// connect to the various key and mouse handlers
GtkWidget *connect_widget = GetConnectWidget();
}
}
-bool wxWindowGTK::AcceptsFocus() const
-{
- return m_acceptsFocus && wxWindowBase::AcceptsFocus();
-}
-
bool wxWindowGTK::Reparent( wxWindowBase *newParentBase )
{
wxCHECK_MSG( (m_widget != NULL), false, wxT("invalid window") );