*/
+//-----------------------------------------------------------------------------
+// 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
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
extern bool g_blockEventsOnDrag;
extern bool g_blockEventsOnScroll;
+extern bool g_isIdle;
static bool g_capturing = FALSE;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
the last click here */
static guint32 gs_timeLastClick = 0;
+//-----------------------------------------------------------------------------
+// idle system
+//-----------------------------------------------------------------------------
+
+extern void wxapp_install_idle_handler();
+extern bool g_isIdle;
+
#if (GTK_MINOR_VERSION > 0)
//-----------------------------------------------------------------------------
int dw = 0;
int dh = 0;
-
+
if (win->m_hasScrolling)
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget);
/*
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
-
- we use this instead: range.slider_width = 11 + 2*2pts edge
+
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
dw += scroll_class->scrollbar_spacing;
}
}
-
+
int dx = 0;
int dy = 0;
if (GTK_WIDGET_NO_WINDOW (widget))
dx += widget->allocation.x;
dy += widget->allocation.y;
}
-
+
if (win->m_windowStyle & wxRAISED_BORDER)
{
- gtk_draw_shadow( widget->style,
+ gtk_draw_shadow( widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
dx, dy,
win->m_width-dw, win->m_height-dh );
return;
- }
-
+ }
+
if (win->m_windowStyle & wxSUNKEN_BORDER)
{
- gtk_draw_shadow( widget->style,
+ gtk_draw_shadow( widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_IN,
- dx, dy,
+ dx, dy,
win->m_width-dw, win->m_height-dh );
return;
}
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_updateRegion.Union( gdk_event->area.x,
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
wxPrintf( win->GetClassInfo()->GetClassName() );
wxPrintf( _T(".\n") );
*/
-
+
long key_code = 0;
switch (gdk_event->keyval)
{
}
// win is a control: tab can be propagated up
- if ( (!ret) &&
+ if ( (!ret) &&
((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) &&
((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) );
- /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
+ /* 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) &&
+ 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.
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
/*
wxPrintf( _T("1) OnButtonPress from ") );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
wxPrintf( win->GetClassInfo()->GetClassName() );
wxPrintf( _T(".\n") );
*/
-
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" );
return TRUE;
}
-
+
return FALSE;
}
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
-
+
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_out_event" );
return TRUE;
}
-
+
return FALSE;
}
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
-
+
if (widget->window != gdk_event->window) return FALSE;
if ((widget->window) && (win->m_cursor.Ok()))
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
return TRUE;
}
-
+
return FALSE;
}
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (widget->window != gdk_event->window) return FALSE;
-
+
if (widget->window)
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
return TRUE;
}
-
+
return FALSE;
}
static void gtk_window_vscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_hscroll_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (g_blockEventsOnDrag) return;
/*
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
// don't test here as we can release the mouse while being over
// a different window then the slider
//
GdkEventButton *WXUNUSED(gdk_event),
wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
// don't test here as we can release the mouse while being over
// a different window then the slider
/* we cannot set colours, fonts and cursors before the widget has
been realized, so we do this directly after realization */
-static gint
+static gint
gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
{
+ if (g_isIdle) wxapp_install_idle_handler();
+
if (win->m_font != *wxSWISS_FONT)
{
wxFont font( win->m_font );
win->m_font = wxNullFont;
win->SetFont( font );
}
-
+
if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
{
wxColour bg( win->m_backgroundColour );
win->m_backgroundColour = wxNullColour;
win->SetBackgroundColour( bg );
}
-
+
if (win->m_foregroundColour != *wxBLACK)
{
wxColour fg( win->m_foregroundColour );
win->m_foregroundColour = wxNullColour;
win->SetForegroundColour( fg );
}
-
+
wxCursor cursor( win->m_cursor );
win->m_cursor = wxNullCursor;
win->SetCursor( cursor );
-
+
return FALSE;
}
-
+
//-----------------------------------------------------------------------------
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
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);
+#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 );
scroll_class->scrollbar_spacing = 0;
m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
m_wxwindow = gtk_myfixed_new();
- 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_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
m_acceptsFocus = TRUE;
}
-
+
/* grab the actual focus */
- gtk_widget_grab_focus( m_wxwindow );
+// gtk_widget_grab_focus( m_wxwindow );
+
+ gtk_widget_show( m_wxwindow );
+
#if (GTK_MINOR_VERSION == 0)
// shut the viewport up
DestroyChildren();
if (m_parent) m_parent->RemoveChild( this );
-
+
if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
if (m_scrollGC) gdk_gc_unref( m_scrollGC );
delete m_constraints;
m_constraints = (wxLayoutConstraints *) NULL;
}
-
+
if (m_windowSizer)
{
delete m_windowSizer;
void wxWindow::PostCreation()
{
wxASSERT_MSG( (m_widget != NULL), _T("invalid window") );
-
+
if (m_wxwindow)
{
/* these get reported to wxWindows -> wxPaintEvent */
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
-
+
#if (GTK_MINOR_VERSION > 0)
/* these are called when the "sunken" or "raised" borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
been realized, so we do this directly after realization */
gtk_signal_connect( GTK_OBJECT(connect_widget), "realize",
GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
-
+
m_hasVMT = TRUE;
}
{
/* the default button has a border around it */
int border = 5;
-
+
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x-border, m_y-border );
gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
if ((old_width != m_width) || (old_height != m_height))
- gtk_widget_set_usize( m_widget, m_width, m_height );
+ {
+/*
+ GtkAllocation alloc;
+ alloc.x = m_x;
+ alloc.y = m_y;
+ alloc.width = m_width;
+ alloc.height = m_height;
+ gtk_widget_size_allocate( m_widget, &alloc );
+*/
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+ }
}
}
/*
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
-
- we use this instead: range.slider_width = 11 + 2*2pts edge
+
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
/*
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
-
- we use this instead: range.slider_width = 11 + 2*2pts edge
+
+ we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
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();
}
void wxWindow::SetValidator( const wxValidator& validator )
{
if (m_windowValidator) delete m_windowValidator;
- m_windowValidator = validator.Clone();
+ m_windowValidator = (wxValidator*)validator.Clone();
if (m_windowValidator) m_windowValidator->SetWindow(this);
}
GtkWidget *connect_widget = GetConnectWidget();
if (!connect_widget->window) return;
-
+
if (m_wxwindow && m_wxwindow->window)
{
/* wxMSW doesn't clear the window here. I don't do that
- either to provide compatibility. call Clear() to do
+ either to provide compatibility. call Clear() to do
the job. */
-
+
m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_wxwindow->window ) );
gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
}
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
-
+
if (sysbg.Red() == colour.Red() &&
sysbg.Green() == colour.Green() &&
sysbg.Blue() == colour.Blue())
void wxWindow::SetFont( const wxFont &font )
{
wxCHECK_RET( m_widget != NULL, _T("invalid window") );
-
+
if (m_font == font) return;
-
+
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
+ if (!m_widget->window) return;
+
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
if (sysbg.Red() == m_backgroundColour.Red() &&
sysbg.Green() == m_backgroundColour.Green() &&
GetSizer()->LayoutPhase1(&noChanges);
GetSizer()->LayoutPhase2(&noChanges);
GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
+
return TRUE;
}
else