wxString dir;
m_list->GetDir( dir );
m_static->SetLabel( dir );
+
+ m_text->SetFocus();
}
void wxFileDialog::OnNew( wxCommandEvent &WXUNUSED(event) )
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
-extern wxCursor g_globalCursor;
+extern bool g_blockEventsOnDrag;
+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
//-----------------------------------------------------------------------------
// "clicked"
gdk_window_set_cursor( event_window, cursor.GetCursor() );
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
-extern bool g_blockEventsOnScroll;
-extern wxCursor g_globalCursor;
+extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
static bool g_hasDoubleClicked = FALSE;
}
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnDrag;
+extern wxWindowGTK *g_delayedFocus;
//-----------------------------------------------------------------------------
// "clicked"
}
node = node->Next();
}
-
}
void wxRadioBox::SetSelection( int n )
(void)GetEventHandler()->ProcessEvent( event );
}
+
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ g_delayedFocus = NULL;
+ SetFocus();
+ }
+ }
}
#endif // wxUSE_RADIOBOX
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
-extern wxCursor g_globalCursor;
+extern bool g_blockEventsOnDrag;
+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
//-----------------------------------------------------------------------------
// "clicked"
gdk_window_set_cursor( win, cursor.GetCursor() );
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
// ----------------------------------------------------------------------------
// helpers
gdk_window_set_cursor( window, cursor.GetCursor() );
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
extern bool g_isIdle;
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
-// void gtk_togglebutton_clicked_callback(GtkWidget *widget, wxToggleButton *cb)
-// Callback function given to gtk.
static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
{
if (g_isIdle)
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
-extern int g_openDialogs;
-
-// ----------------------------------------------------------------------------
-// event tables
-// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// data
// ----------------------------------------------------------------------------
-extern wxList wxPendingDelete;
+extern wxList wxPendingDelete;
+
+extern int g_openDialogs;
+extern wxWindowGTK *g_delayedFocus;
// ----------------------------------------------------------------------------
// debug
#endif
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// GTK callbacks
-// ----------------------------------------------------------------------------
-
//-----------------------------------------------------------------------------
// "focus" from m_window
//-----------------------------------------------------------------------------
return FALSE;
}
+//-----------------------------------------------------------------------------
+// local code
+//-----------------------------------------------------------------------------
+
+static wxWindow* wxGetTopLevelParent(wxWindow *win)
+{
+ wxWindow *p = win;
+ while (p && !p->IsTopLevel())
+ p = p->GetParent();
+ return p;
+}
+
//-----------------------------------------------------------------------------
// "realize" from m_widget
//-----------------------------------------------------------------------------
win->SetIcons( iconsOld );
}
- // we set the focus to the child that accepts the focus. this
- // doesn't really have to be done in "realize" but why not?
+ // We need to set the focus to some child. Either, this
+ // has been done already or will be done in the next
+ // idle cycle, or we will set it ourselves.
+
+ if (g_delayedFocus)
+ {
+ if (wxGetTopLevelParent(g_delayedFocus))
+ return;
+ else
+ g_delayedFocus = NULL;
+ }
+
+ wxWindow *currentFocus = wxWindow::FindFocus();
+ if (currentFocus)
+ {
+ // I am not sure if this ever can happen,
+ // since the TLW is just about to get
+ // created and its children probably don't
+ // have any focus.
+ if (wxGetTopLevelParent(currentFocus) == win)
+ return;
+ }
+
+ // We set the focus to the child that accepts the focus.
wxWindowList::Node *node = win->GetChildren().GetFirst();
while (node)
{
child->SetFocus();
break;
}
-
+
node = node->GetNext();
}
}
// the last window which had the focus - this is normally never NULL (except
// if we never had focus at all) as even when g_focusWindow is NULL it still
// keeps its previous value
-static wxWindowGTK *g_focusWindowLast = (wxWindowGTK *)NULL;
+static wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL;
// the frame that is currently active (i.e. its child has focus). It is
// used to generate wxActivateEvents
-static wxWindowGTK *g_activeFrame = (wxWindowGTK *)NULL;
+static wxWindowGTK *g_activeFrame = (wxWindowGTK*) NULL;
static bool g_activeFrameLostFocus = FALSE;
+// If a window get the focus set but has not been realized
+// yet, defer setting the focus to idle time.
+wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
+
// if we detect that the app has got/lost the focus, we set this variable to
// either TRUE or FALSE and an activate event will be sent during the next
// OnIdle() call and it is reset to -1: this value means that we shouldn't
if (g_isIdle)
wxapp_install_idle_handler();
-/*
- if (win->GetName() == wxT("panel"))
+#if 0
+ if (win->GetName())
{
wxPrintf( wxT("OnExpose from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
(int)gdk_event->area.width,
(int)gdk_event->area.height );
}
-*/
+#endif
#ifndef __WXUNIVERSAL__
GtkPizza *pizza = GTK_PIZZA (widget);
return;
}
-/*
- if (win->GetName() == wxT("panel"))
+#if 0
+ if (win->GetName())
{
wxPrintf( wxT("OnDraw from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
(int)rect->width,
(int)rect->height );
}
-*/
+#endif
#ifndef __WXUNIVERSAL__
GtkPizza *pizza = GTK_PIZZA (widget);
g_focusWindow = win;
#if 0
- wxLogDebug( wxT("OnSetFocus from %s\n"), win->GetName().c_str() );
+ printf( "OnSetFocus 2 from %s\n", win->GetName().c_str() );
#endif
- // notify the parent keeping track of focus for the kbd navigation
- // purposes that we got it
+ // Notify the parent keeping track of focus for the kbd navigation
+ // purposes that we got it.
wxChildFocusEvent eventFocus(win);
(void)win->GetEventHandler()->ProcessEvent(eventFocus);
}
#endif // wxUSE_CARET
+ g_activeFrameLostFocus = FALSE;
+
wxWindowGTK *active = wxGetTopLevelParent(win);
if ( active != g_activeFrame )
{
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
event.SetEventObject(g_activeFrame);
g_activeFrame->GetEventHandler()->ProcessEvent(event);
+
+ // Don't send focus events in addition to activate
+ // if (win == g_activeFrame)
+ // return TRUE;
}
- g_activeFrameLostFocus = FALSE;
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
return TRUE;
}
-
return FALSE;
}
}
g_activeFrameLostFocus = FALSE;
}
+
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
-#if 0
- wxPrintf( "SetFocus from " );
- if (GetClassInfo() && GetClassInfo()->GetClassName())
- wxPrintf( GetClassInfo()->GetClassName() );
- wxPrintf( ".\n" );
-#endif
-
if (m_wxwindow)
{
if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow))
{
if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) )
{
- gtk_widget_grab_focus (m_widget);
+ if (!GTK_WIDGET_REALIZED(m_widget))
+ g_delayedFocus = this;
+ else
+ gtk_widget_grab_focus (m_widget);
}
else if (GTK_IS_CONTAINER(m_widget))
{
}
m_clipPaintRegion = TRUE;
-
+
// if (!m_clearRegion.IsEmpty()) // always send an erase event
{
wxWindowDC dc( (wxWindow*)this );
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
-
+
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget))
{
{
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
- if (!m_widget->window) return;
-
if (m_wxwindow && m_wxwindow->window)
{
- gdk_window_clear( m_wxwindow->window );
+ m_clearRegion.Clear();
+ wxSize size( GetClientSize() );
+ m_clearRegion.Union( 0,0,size.x,size.y );
+
+ // Better do this in idle?
+ Update();
}
}
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
-extern wxCursor g_globalCursor;
+extern bool g_blockEventsOnDrag;
+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
//-----------------------------------------------------------------------------
// "clicked"
gdk_window_set_cursor( event_window, cursor.GetCursor() );
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
-extern bool g_blockEventsOnScroll;
-extern wxCursor g_globalCursor;
+extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
static bool g_hasDoubleClicked = FALSE;
}
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnDrag;
+extern wxWindowGTK *g_delayedFocus;
//-----------------------------------------------------------------------------
// "clicked"
}
node = node->Next();
}
-
}
void wxRadioBox::SetSelection( int n )
(void)GetEventHandler()->ProcessEvent( event );
}
+
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ g_delayedFocus = NULL;
+ SetFocus();
+ }
+ }
}
#endif // wxUSE_RADIOBOX
// data
//-----------------------------------------------------------------------------
-extern bool g_blockEventsOnDrag;
-extern wxCursor g_globalCursor;
+extern bool g_blockEventsOnDrag;
+extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
//-----------------------------------------------------------------------------
// "clicked"
gdk_window_set_cursor( win, cursor.GetCursor() );
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
// ----------------------------------------------------------------------------
// helpers
gdk_window_set_cursor( window, cursor.GetCursor() );
}
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
+
UpdateWindowUI();
}
extern bool g_isIdle;
extern bool g_blockEventsOnDrag;
extern wxCursor g_globalCursor;
+extern wxWindowGTK *g_delayedFocus;
-// void gtk_togglebutton_clicked_callback(GtkWidget *widget, wxToggleButton *cb)
-// Callback function given to gtk.
static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb)
{
if (g_isIdle)
extern void wxapp_install_idle_handler();
extern bool g_isIdle;
-extern int g_openDialogs;
-
-// ----------------------------------------------------------------------------
-// event tables
-// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// data
// ----------------------------------------------------------------------------
-extern wxList wxPendingDelete;
+extern wxList wxPendingDelete;
+
+extern int g_openDialogs;
+extern wxWindowGTK *g_delayedFocus;
// ----------------------------------------------------------------------------
// debug
#endif
-// ============================================================================
-// implementation
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// GTK callbacks
-// ----------------------------------------------------------------------------
-
//-----------------------------------------------------------------------------
// "focus" from m_window
//-----------------------------------------------------------------------------
return FALSE;
}
+//-----------------------------------------------------------------------------
+// local code
+//-----------------------------------------------------------------------------
+
+static wxWindow* wxGetTopLevelParent(wxWindow *win)
+{
+ wxWindow *p = win;
+ while (p && !p->IsTopLevel())
+ p = p->GetParent();
+ return p;
+}
+
//-----------------------------------------------------------------------------
// "realize" from m_widget
//-----------------------------------------------------------------------------
win->SetIcons( iconsOld );
}
- // we set the focus to the child that accepts the focus. this
- // doesn't really have to be done in "realize" but why not?
+ // We need to set the focus to some child. Either, this
+ // has been done already or will be done in the next
+ // idle cycle, or we will set it ourselves.
+
+ if (g_delayedFocus)
+ {
+ if (wxGetTopLevelParent(g_delayedFocus))
+ return;
+ else
+ g_delayedFocus = NULL;
+ }
+
+ wxWindow *currentFocus = wxWindow::FindFocus();
+ if (currentFocus)
+ {
+ // I am not sure if this ever can happen,
+ // since the TLW is just about to get
+ // created and its children probably don't
+ // have any focus.
+ if (wxGetTopLevelParent(currentFocus) == win)
+ return;
+ }
+
+ // We set the focus to the child that accepts the focus.
wxWindowList::Node *node = win->GetChildren().GetFirst();
while (node)
{
child->SetFocus();
break;
}
-
+
node = node->GetNext();
}
}
// the last window which had the focus - this is normally never NULL (except
// if we never had focus at all) as even when g_focusWindow is NULL it still
// keeps its previous value
-static wxWindowGTK *g_focusWindowLast = (wxWindowGTK *)NULL;
+static wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL;
// the frame that is currently active (i.e. its child has focus). It is
// used to generate wxActivateEvents
-static wxWindowGTK *g_activeFrame = (wxWindowGTK *)NULL;
+static wxWindowGTK *g_activeFrame = (wxWindowGTK*) NULL;
static bool g_activeFrameLostFocus = FALSE;
+// If a window get the focus set but has not been realized
+// yet, defer setting the focus to idle time.
+wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL;
+
// if we detect that the app has got/lost the focus, we set this variable to
// either TRUE or FALSE and an activate event will be sent during the next
// OnIdle() call and it is reset to -1: this value means that we shouldn't
if (g_isIdle)
wxapp_install_idle_handler();
-/*
- if (win->GetName() == wxT("panel"))
+#if 0
+ if (win->GetName())
{
wxPrintf( wxT("OnExpose from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
(int)gdk_event->area.width,
(int)gdk_event->area.height );
}
-*/
+#endif
#ifndef __WXUNIVERSAL__
GtkPizza *pizza = GTK_PIZZA (widget);
return;
}
-/*
- if (win->GetName() == wxT("panel"))
+#if 0
+ if (win->GetName())
{
wxPrintf( wxT("OnDraw from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
(int)rect->width,
(int)rect->height );
}
-*/
+#endif
#ifndef __WXUNIVERSAL__
GtkPizza *pizza = GTK_PIZZA (widget);
g_focusWindow = win;
#if 0
- wxLogDebug( wxT("OnSetFocus from %s\n"), win->GetName().c_str() );
+ printf( "OnSetFocus 2 from %s\n", win->GetName().c_str() );
#endif
- // notify the parent keeping track of focus for the kbd navigation
- // purposes that we got it
+ // Notify the parent keeping track of focus for the kbd navigation
+ // purposes that we got it.
wxChildFocusEvent eventFocus(win);
(void)win->GetEventHandler()->ProcessEvent(eventFocus);
}
#endif // wxUSE_CARET
+ g_activeFrameLostFocus = FALSE;
+
wxWindowGTK *active = wxGetTopLevelParent(win);
if ( active != g_activeFrame )
{
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId());
event.SetEventObject(g_activeFrame);
g_activeFrame->GetEventHandler()->ProcessEvent(event);
+
+ // Don't send focus events in addition to activate
+ // if (win == g_activeFrame)
+ // return TRUE;
}
- g_activeFrameLostFocus = FALSE;
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
return TRUE;
}
-
return FALSE;
}
}
g_activeFrameLostFocus = FALSE;
}
+
+ if (g_delayedFocus == this)
+ {
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_grab_focus( m_widget );
+ g_delayedFocus = NULL;
+ }
+ }
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
-#if 0
- wxPrintf( "SetFocus from " );
- if (GetClassInfo() && GetClassInfo()->GetClassName())
- wxPrintf( GetClassInfo()->GetClassName() );
- wxPrintf( ".\n" );
-#endif
-
if (m_wxwindow)
{
if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow))
{
if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) )
{
- gtk_widget_grab_focus (m_widget);
+ if (!GTK_WIDGET_REALIZED(m_widget))
+ g_delayedFocus = this;
+ else
+ gtk_widget_grab_focus (m_widget);
}
else if (GTK_IS_CONTAINER(m_widget))
{
}
m_clipPaintRegion = TRUE;
-
+
// if (!m_clearRegion.IsEmpty()) // always send an erase event
{
wxWindowDC dc( (wxWindow*)this );
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
-
+
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget))
{
{
wxCHECK_RET( m_widget != NULL, wxT("invalid window") );
- if (!m_widget->window) return;
-
if (m_wxwindow && m_wxwindow->window)
{
- gdk_window_clear( m_wxwindow->window );
+ m_clearRegion.Clear();
+ wxSize size( GetClientSize() );
+ m_clearRegion.Union( 0,0,size.x,size.y );
+
+ // Better do this in idle?
+ Update();
}
}