GdkEvent *WXUNUSED(event),
const wxChar *name )
{
- // to enable logging of the focus events replace 0 with 1
-#if 0
+/*
static bool s_done = FALSE;
if ( !s_done )
{
wxLog::AddTraceMask("focus");
s_done = TRUE;
}
-#endif
wxLogTrace(_T("FOCUS NOW AT: %s"), name);
+*/
return FALSE;
}
if (g_blockEventsOnDrag) return FALSE;
/*
- printf( "OnKeyPress from " );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( ".\n" );
+ printf( "KeyDown-ScanCode is: %d.\n", gdk_event->keyval );
+ if (gdk_event->state & GDK_SHIFT_MASK)
+ printf( "ShiftDown.\n" );
+ else
+ printf( "ShiftUp.\n" );
+ if (gdk_event->state & GDK_CONTROL_MASK)
+ printf( "ControlDown.\n" );
+ else
+ printf( "ControlUp.\n" );
+ printf( "\n" );
*/
long key_code = 0;
switch (gdk_event->keyval)
{
+ case GDK_Shift_L:
+ case GDK_Shift_R: key_code = WXK_SHIFT; break;
+ case GDK_Control_L:
+ case GDK_Control_R: key_code = WXK_CONTROL; break;
+ case GDK_Menu: key_code = WXK_MENU; break;
+ case GDK_Help: key_code = WXK_HELP; break;
case GDK_BackSpace: key_code = WXK_BACK; break;
case GDK_ISO_Left_Tab:
case GDK_KP_Tab:
}
}
- if (!key_code) return FALSE;
+ int x = 0;
+ int y = 0;
+ GdkModifierType state;
+ if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
wxKeyEvent event( wxEVT_KEY_DOWN );
+ event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_keyCode = key_code;
- event.m_x = 0;
- event.m_y = 0;
+ event.m_scanCode = gdk_event->keyval;
+ event.m_x = x;
+ event.m_y = y;
event.SetEventObject( win );
bool ret = win->GetEventHandler()->ProcessEvent( event );
if (g_blockEventsOnDrag) return FALSE;
/*
- printf( "OnKeyRelease from " );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- printf( win->GetClassInfo()->GetClassName() );
- printf( ".\n" );
+ printf( "KeyUp-ScanCode is: %d.\n", gdk_event->keyval );
+ if (gdk_event->state & GDK_SHIFT_MASK)
+ printf( "ShiftDown.\n" );
+ else
+ printf( "ShiftUp.\n" );
+ if (gdk_event->state & GDK_CONTROL_MASK)
+ printf( "ControlDown.\n" );
+ else
+ printf( "ControlUp.\n" );
+ printf( "\n" );
*/
long key_code = 0;
switch (gdk_event->keyval)
{
+ case GDK_Shift_L:
+ case GDK_Shift_R: key_code = WXK_SHIFT; break;
+ case GDK_Control_L:
+ case GDK_Control_R: key_code = WXK_CONTROL; break;
+ case GDK_Menu: key_code = WXK_MENU; break;
+ case GDK_Help: key_code = WXK_HELP; break;
case GDK_BackSpace: key_code = WXK_BACK; break;
case GDK_ISO_Left_Tab:
case GDK_KP_Tab:
}
}
- if (!key_code) return FALSE;
+ int x = 0;
+ int y = 0;
+ GdkModifierType state;
+ if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
wxKeyEvent event( wxEVT_KEY_UP );
+ event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK);
event.m_keyCode = key_code;
- event.m_x = 0;
- event.m_y = 0;
+ event.m_scanCode = gdk_event->keyval;
+ event.m_x = x;
+ event.m_y = y;
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
wxPrintf( win->GetClassInfo()->GetClassName() );
wxPrintf( _T(".\n") );
*/
-
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
}
wxMouseEvent event( event_type );
+ event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
}
wxMouseEvent event( event_type );
+ event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
*/
wxMouseEvent event( wxEVT_MOTION );
+ event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK);
event.m_altDown = (gdk_event->state & GDK_MOD1_MASK);
gdk_window_set_cursor( widget->window, win->GetCursor().GetCursor() );
wxMouseEvent event( wxEVT_ENTER_WINDOW );
+ event.SetTimestamp( gdk_event->time );
event.SetEventObject( win );
int x = 0;
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
wxMouseEvent event( wxEVT_LEAVE_WINDOW );
+ event.SetTimestamp( gdk_event->time );
event.SetEventObject( win );
int x = 0;
been realized, so we do this directly after realization */
static gint
-gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+gtk_window_realized_callback( GtkWidget * WXUNUSED(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_delayedFont)
+ win->SetFont( win->GetFont() );
- if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
- {
- wxColour bg( win->m_backgroundColour );
- win->m_backgroundColour = wxNullColour;
- win->SetBackgroundColour( bg );
- }
+ if (win->m_delayedBackgroundColour)
+ win->SetBackgroundColour( win->GetBackgroundColour() );
- if (win->m_foregroundColour != *wxBLACK)
- {
- wxColour fg( win->m_foregroundColour );
- win->m_foregroundColour = wxNullColour;
- win->SetForegroundColour( fg );
- }
+ if (win->m_delayedForegroundColour)
+ win->SetForegroundColour( win->GetForegroundColour() );
- wxCursor cursor( win->m_cursor );
- win->m_cursor = wxNullCursor;
- win->SetCursor( cursor );
+ win->SetCursor( win->GetCursor() );
return FALSE;
}
m_width = 0;
m_height = 0;
- m_font = *wxSWISS_FONT;
- m_windowName = "noname";
-
m_sizeSet = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
+ m_isBeingDeleted = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
wxWindow::~wxWindow()
{
+ m_isBeingDeleted = TRUE;
m_hasVMT = FALSE;
if (m_widget)
{
wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- if ( !wxWindowBase::Show(show) )
+ if (!wxWindowBase::Show(show))
+ {
+ // nothing to do
return FALSE;
+ }
if (show)
gtk_widget_show( m_widget );
{
wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- if ( !wxWindowBase::Enable(enable) )
+ if (!wxWindowBase::Enable(enable))
+ {
+ // nothing to do
return FALSE;
+ }
gtk_widget_set_sensitive( m_widget, enable );
if ( m_wxwindow )
{
wxCHECK_MSG( (m_widget != NULL), FALSE, _T("invalid window") );
- if ( wxWindowBase::SetCursor(cursor) )
+ if (!wxWindowBase::SetCursor(cursor))
{
- if (!m_widget->window) return TRUE;
+ // don't leave if the GTK widget has just
+ // been realized
+ if (!m_delayedCursor) return FALSE;
+ }
+
+ GtkWidget *connect_widget = GetConnectWidget();
+ if (!connect_widget->window)
+ {
+ // indicate that a new style has been set
+ // but it couldn't get applied as the
+ // widget hasn't been realized yet.
+ m_delayedCursor = TRUE;
+
+ // pretend we have done something
+ return TRUE;
+ }
if ((m_widget) && (m_widget->window))
gdk_window_set_cursor( m_widget->window, GetCursor().GetCursor() );
if ((m_wxwindow) && (m_wxwindow->window))
gdk_window_set_cursor( m_wxwindow->window, GetCursor().GetCursor() );
- // cursor was set
- return TRUE;
- }
- else
- {
- // cursor hasn't been changed
- return FALSE;
- }
+ // cursor was set
+ return TRUE;
}
void wxWindow::WarpPointer( int WXUNUSED(x), int WXUNUSED(y) )
{
wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- if (!colour.Ok()) return FALSE;
- if (m_backgroundColour == colour) return FALSE;
-
+ if (!wxWindowBase::SetBackgroundColour(colour))
+ {
+ // don't leave if the GTK widget has just
+ // been realized
+ if (!m_delayedBackgroundColour) return FALSE;
+ }
+
GtkWidget *connect_widget = GetConnectWidget();
- if (!connect_widget->window) return TRUE;
+ if (!connect_widget->window)
+ {
+ // indicate that a new style has been set
+ // but it couldn't get applied as the
+ // widget hasn't been realized yet.
+ m_delayedBackgroundColour = TRUE;
+
+ // pretend we have done something
+ return TRUE;
+ }
if (m_wxwindow && m_wxwindow->window)
{
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if ( sysbg == m_backgroundColour )
+ if (sysbg == m_backgroundColour)
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
{
wxCHECK_MSG( m_widget != NULL, FALSE, _T("invalid window") );
- if (!colour.Ok()) return FALSE;
- if (m_backgroundColour == colour) return FALSE;
-
+ if (!wxWindowBase::SetForegroundColour(colour))
+ {
+ // don't leave if the GTK widget has just
+ // been realized
+ if (!m_delayedForegroundColour) return FALSE;
+ }
+
GtkWidget *connect_widget = GetConnectWidget();
- if (!connect_widget->window) return TRUE;
+ if (!connect_widget->window)
+ {
+ // indicate that a new style has been set
+ // but it couldn't get applied as the
+ // widget hasn't been realized yet.
+ m_delayedForegroundColour = TRUE;
+
+ // pretend we have done something
+ return TRUE;
+ }
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
- if ( sysbg == m_foregroundColour )
+ if (sysbg == m_foregroundColour)
{
m_backgroundColour = wxNullColour;
ApplyWidgetStyle();
static gint gs_pop_x = 0;
static gint gs_pop_y = 0;
-static void pop_pos_callback( GtkMenu *menu, gint *x, gint *y, wxWindow *win )
+static void pop_pos_callback( GtkMenu * WXUNUSED(menu),
+ gint *x, gint *y,
+ wxWindow *win )
{
win->ClientToScreen( &gs_pop_x, &gs_pop_y );
*x = gs_pop_x;
{
wxCHECK_MSG( m_widget != NULL, FALSE, _T( "invalid window") );
- if (!font.Ok()) return FALSE;
- if (m_font == font) return FALSE;
-
+ if (!wxWindowBase::SetFont(font))
+ {
+ // don't leave if the GTK widget has just
+ // been realized
+ if (!m_delayedFont) return FALSE;
+ }
+
GtkWidget *connect_widget = GetConnectWidget();
- if (!connect_widget->window) return TRUE;
+ if (!connect_widget->window)
+ {
+ // indicate that a new style has been set
+ // but it couldn't get applied as the
+ // widget hasn't been realized yet.
+ m_delayedFont = TRUE;
+
+ // pretend we have done something
+ return TRUE;
+ }
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
if ( sysbg == m_backgroundColour )
m_vAdjust->page_size = fthumb;
}
- if (m_wxwindow->window)
- {
- if (orient == wxHORIZONTAL)
- gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
- else
- gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
-
- gtk_widget_set_usize( m_widget, m_width, m_height );
- }
+ if (orient == wxHORIZONTAL)
+ gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
+ else
+ gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
}
void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) )
m_vAdjust->value = fpos;
}
- if (!m_isScrolling)
+ if (!m_isScrolling) /* prevent recursion */
{
if (m_wxwindow->window)
{