git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4593
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
If the m_wxwindow field is set, then all input to this widget is inter-
cepted and sent to the wxWindows class. If not, all input to the widget
that gets pointed to by m_widget gets intercepted and sent to the class.
If the m_wxwindow field is set, then all input to this widget is inter-
cepted and sent to the wxWindows class. If not, all input to the widget
that gets pointed to by m_widget gets intercepted and sent to the class.
The design of scrolling in wxWindows is markedly different from that offered
by the GTK itself and therefore we cannot simply take it as it is. In GTK,
clicking on a scrollbar belonging to scrolled window will inevitably move
The design of scrolling in wxWindows is markedly different from that offered
by the GTK itself and therefore we cannot simply take it as it is. In GTK,
clicking on a scrollbar belonging to scrolled window will inevitably move
memorizes how much it has been scrolled but that wxWindows forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the pizza->xoffset and pizza->yoffset values.
memorizes how much it has been scrolled but that wxWindows forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the pizza->xoffset and pizza->yoffset values.
Singularily the most broken code in GTK is the code that is supposes to
inform subwindows (child windows) about new positions. Very often, duplicate
events are sent without changes in size or position, equally often no
Singularily the most broken code in GTK is the code that is supposes to
inform subwindows (child windows) about new positions. Very often, duplicate
events are sent without changes in size or position, equally often no
If someone at some point of time feels the immense desire to have a look at,
change or attempt to optimse the Refresh() logic, this person will need an
intimate understanding of what a "draw" and what an "expose" events are and
what there are used for, in particular when used in connection with GTK's
own windowless widgets. Beware.
If someone at some point of time feels the immense desire to have a look at,
change or attempt to optimse the Refresh() logic, this person will need an
intimate understanding of what a "draw" and what an "expose" events are and
what there are used for, in particular when used in connection with GTK's
own windowless widgets. Beware.
Cursors, too, have been a constant source of pleasure. The main difficulty
is that a GdkWindow inherits a cursor if the programmer sets a new cursor
for the parent. To prevent this from doing too much harm, I use idle time
Cursors, too, have been a constant source of pleasure. The main difficulty
is that a GdkWindow inherits a cursor if the programmer sets a new cursor
for the parent. To prevent this from doing too much harm, I use idle time
and ending with the youngest generation (speaking of parent and child windows).
Also don't forget that cursors (like much else) are connected to GdkWindows,
not GtkWidgets and that the "window" field of a GtkWidget might very well
and ending with the youngest generation (speaking of parent and child windows).
Also don't forget that cursors (like much else) are connected to GdkWindows,
not GtkWidgets and that the "window" field of a GtkWidget might very well
- point to the GdkWindow of the parent widget (-> "window less widget") and
+ point to the GdkWindow of the parent widget (-> "window less widget") and
that the two obviously have very different meanings.
*/
that the two obviously have very different meanings.
*/
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
- wxWindow *g_focusWindow = (wxWindow*) NULL;
+static wxWindow *g_focusWindow = (wxWindow*) 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
+// send any activate events at all
+static int g_sendActivateEvent = -1;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
win->m_width-dw, win->m_height-dh );
return;
}
win->m_width-dw, win->m_height-dh );
return;
}
if (win->HasFlag(wxSIMPLE_BORDER))
{
GdkGC *gc;
gc = gdk_gc_new( widget->window );
gdk_gc_set_foreground( gc, &widget->style->black );
if (win->HasFlag(wxSIMPLE_BORDER))
{
GdkGC *gc;
gc = gdk_gc_new( widget->window );
gdk_gc_set_foreground( gc, &widget->style->black );
- gdk_draw_rectangle( widget->window, gc, FALSE,
+ gdk_draw_rectangle( widget->window, gc, FALSE,
dx, dy,
win->m_width-dw-1, win->m_height-dh-1 );
gdk_gc_unref( gc );
dx, dy,
win->m_width-dw-1, win->m_height-dh-1 );
gdk_gc_unref( gc );
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
(int)rect->width,
(int)rect->height );
*/
(int)rect->width,
(int)rect->height );
*/
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
bool ret = FALSE;
if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
bool ret = FALSE;
long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
/* sending unknown key events doesn't really make sense */
if (key_code == 0) return FALSE;
long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
/* sending unknown key events doesn't really make sense */
if (key_code == 0) return FALSE;
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not in an accelerator table. */
key_code = map_to_wx_keysym( gdk_event->keyval );
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not in an accelerator table. */
key_code = map_to_wx_keysym( gdk_event->keyval );
if ( (!ret) &&
(key_code != 0))
{
if ( (!ret) &&
(key_code != 0))
{
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
node = node->Next();
if (!child->IsShown())
continue;
node = node->Next();
if (!child->IsShown())
continue;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
+ switch ( g_sendActivateEvent )
+ {
+ case -1:
+ // we've got focus from outside, synthtize wxActivateEvent
+ g_sendActivateEvent = 1;
+ break;
+
+ case 0:
+ // another our window just lost focus, it was already ours before
+ // - don't send any wxActivateEvent
+ g_sendActivateEvent = -1;
+ break;
+ }
+
{
panel->SetLastFocus(win);
}
{
panel->SetLastFocus(win);
}
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
+ // if the focus goes out of our app alltogether, OnIdle() will send
+ // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
+ // g_sendActivateEvent to -1
+ g_sendActivateEvent = 0;
+
+ g_focusWindow = (wxWindow *)NULL;
+
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
float diff = adjust->value - win->m_oldVerticalPos;
if (fabs(diff) < 0.2) return;
float diff = adjust->value - win->m_oldVerticalPos;
if (fabs(diff) < 0.2) return;
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxVERTICAL );
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxVERTICAL );
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow);
child->m_x += pizza->xoffset;
child->m_y += pizza->yoffset;
GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow);
child->m_x += pizza->xoffset;
child->m_y += pizza->yoffset;
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
m_noExpose = FALSE;
m_nativeSizeEvent = FALSE;
m_noExpose = FALSE;
m_nativeSizeEvent = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_isRadioButton = FALSE;
m_isFrame = FALSE;
m_acceptsFocus = FALSE;
m_isRadioButton = FALSE;
m_isFrame = FALSE;
m_acceptsFocus = FALSE;
m_cursor = *wxSTANDARD_CURSOR;
}
m_cursor = *wxSTANDARD_CURSOR;
}
m_y = (int)pos.y;
/* some reasonable defaults */
m_y = (int)pos.y;
/* some reasonable defaults */
if (m_y < 10) m_y = 10;
}
}
if (m_y < 10) m_y = 10;
}
}
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
}
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",
#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",
else
{
GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow);
else
{
GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow);
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
{
if (x != -1) m_x = x + pizza->xoffset;
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
{
if (x != -1) m_x = x + pizza->xoffset;
m_width+2*border,
m_height+border+bottom_border );
}
m_width+2*border,
m_height+border+bottom_border );
}
/*
wxPrintf( "OnSize sent from " );
if (GetClassInfo() && GetClassInfo()->GetClassName())
/*
wxPrintf( "OnSize sent from " );
if (GetClassInfo() && GetClassInfo()->GetClassName())
void wxWindow::OnInternalIdle()
{
void wxWindow::OnInternalIdle()
{
+ if ( g_sendActivateEvent != -1 )
+ {
+ bool activate = g_sendActivateEvent != 0;
+
+ // do it only once
+ g_sendActivateEvent = -1;
+
+ wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId());
+ event.SetEventObject(this);
+
+ (void)GetEventHandler()->ProcessEvent(event);
+ }
+
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
if (m_wxwindow)
{
GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window;
if (m_wxwindow)
{
GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window;
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
/* we provide this function ourselves as it is
missing in GDK (top of this file) */
/* we provide this function ourselves as it is
missing in GDK (top of this file) */
GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (window)
gdk_window_warp_pointer( window, x, y );
}
if (window)
gdk_window_warp_pointer( window, x, y );
}
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
gtk_pizza_set_clear( pizza, old_clear );
}
else
gtk_pizza_set_clear( pizza, old_clear );
}
else
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
gtk_widget_draw( m_wxwindow, &gdk_rect );
gtk_widget_draw( m_wxwindow, &gdk_rect );
gtk_pizza_set_clear( pizza, old_clear );
}
else
gtk_pizza_set_clear( pizza, old_clear );
}
else
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (!window)
{
// indicate that a new style has been set
if (!window)
{
// indicate that a new style has been set
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (!window)
{
// indicate that a new style has been set
if (!window)
{
// indicate that a new style has been set
gs_pop_y = y;
bool is_waiting = TRUE;
gs_pop_y = y;
bool is_waiting = TRUE;
gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide",
GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting );
gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide",
GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting );
0, // button used to activate it
gs_timeLastClick // the time of activation
);
0, // button used to activate it
gs_timeLastClick // the time of activation
);
while (is_waiting)
{
while (gtk_events_pending())
while (is_waiting)
{
while (gtk_events_pending())
bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
{
bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_PIZZA(m_wxwindow)->bin_window);
return (window == GTK_PIZZA(m_wxwindow)->bin_window);
return (window == m_widget->window);
}
return (window == m_widget->window);
}
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (!window) return;
gdk_pointer_grab( window, FALSE,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
if (!window) return;
gdk_pointer_grab( window, FALSE,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL,
m_cursor.GetCursor(),
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL,
m_cursor.GetCursor(),
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
If the m_wxwindow field is set, then all input to this widget is inter-
cepted and sent to the wxWindows class. If not, all input to the widget
that gets pointed to by m_widget gets intercepted and sent to the class.
If the m_wxwindow field is set, then all input to this widget is inter-
cepted and sent to the wxWindows class. If not, all input to the widget
that gets pointed to by m_widget gets intercepted and sent to the class.
The design of scrolling in wxWindows is markedly different from that offered
by the GTK itself and therefore we cannot simply take it as it is. In GTK,
clicking on a scrollbar belonging to scrolled window will inevitably move
The design of scrolling in wxWindows is markedly different from that offered
by the GTK itself and therefore we cannot simply take it as it is. In GTK,
clicking on a scrollbar belonging to scrolled window will inevitably move
memorizes how much it has been scrolled but that wxWindows forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the pizza->xoffset and pizza->yoffset values.
memorizes how much it has been scrolled but that wxWindows forgets this
so that the two coordinates systems have to be kept in synch. This is done
in various places using the pizza->xoffset and pizza->yoffset values.
Singularily the most broken code in GTK is the code that is supposes to
inform subwindows (child windows) about new positions. Very often, duplicate
events are sent without changes in size or position, equally often no
Singularily the most broken code in GTK is the code that is supposes to
inform subwindows (child windows) about new positions. Very often, duplicate
events are sent without changes in size or position, equally often no
If someone at some point of time feels the immense desire to have a look at,
change or attempt to optimse the Refresh() logic, this person will need an
intimate understanding of what a "draw" and what an "expose" events are and
what there are used for, in particular when used in connection with GTK's
own windowless widgets. Beware.
If someone at some point of time feels the immense desire to have a look at,
change or attempt to optimse the Refresh() logic, this person will need an
intimate understanding of what a "draw" and what an "expose" events are and
what there are used for, in particular when used in connection with GTK's
own windowless widgets. Beware.
Cursors, too, have been a constant source of pleasure. The main difficulty
is that a GdkWindow inherits a cursor if the programmer sets a new cursor
for the parent. To prevent this from doing too much harm, I use idle time
Cursors, too, have been a constant source of pleasure. The main difficulty
is that a GdkWindow inherits a cursor if the programmer sets a new cursor
for the parent. To prevent this from doing too much harm, I use idle time
and ending with the youngest generation (speaking of parent and child windows).
Also don't forget that cursors (like much else) are connected to GdkWindows,
not GtkWidgets and that the "window" field of a GtkWidget might very well
and ending with the youngest generation (speaking of parent and child windows).
Also don't forget that cursors (like much else) are connected to GdkWindows,
not GtkWidgets and that the "window" field of a GtkWidget might very well
- point to the GdkWindow of the parent widget (-> "window less widget") and
+ point to the GdkWindow of the parent widget (-> "window less widget") and
that the two obviously have very different meanings.
*/
that the two obviously have very different meanings.
*/
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
- wxWindow *g_focusWindow = (wxWindow*) NULL;
+static wxWindow *g_focusWindow = (wxWindow*) 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
+// send any activate events at all
+static int g_sendActivateEvent = -1;
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
win->m_width-dw, win->m_height-dh );
return;
}
win->m_width-dw, win->m_height-dh );
return;
}
if (win->HasFlag(wxSIMPLE_BORDER))
{
GdkGC *gc;
gc = gdk_gc_new( widget->window );
gdk_gc_set_foreground( gc, &widget->style->black );
if (win->HasFlag(wxSIMPLE_BORDER))
{
GdkGC *gc;
gc = gdk_gc_new( widget->window );
gdk_gc_set_foreground( gc, &widget->style->black );
- gdk_draw_rectangle( widget->window, gc, FALSE,
+ gdk_draw_rectangle( widget->window, gc, FALSE,
dx, dy,
win->m_width-dw-1, win->m_height-dh-1 );
gdk_gc_unref( gc );
dx, dy,
win->m_width-dw-1, win->m_height-dh-1 );
gdk_gc_unref( gc );
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
(int)rect->width,
(int)rect->height );
*/
(int)rect->width,
(int)rect->height );
*/
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
bool ret = FALSE;
if (gdk_event->window) gdk_window_get_pointer(gdk_event->window, &x, &y, &state);
bool ret = FALSE;
long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
/* sending unknown key events doesn't really make sense */
if (key_code == 0) return FALSE;
long key_code = map_to_unmodified_wx_keysym( gdk_event->keyval );
/* sending unknown key events doesn't really make sense */
if (key_code == 0) return FALSE;
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not in an accelerator table. */
key_code = map_to_wx_keysym( gdk_event->keyval );
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
will only be sent if it is not in an accelerator table. */
key_code = map_to_wx_keysym( gdk_event->keyval );
if ( (!ret) &&
(key_code != 0))
{
if ( (!ret) &&
(key_code != 0))
{
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
node = node->Next();
if (!child->IsShown())
continue;
node = node->Next();
if (!child->IsShown())
continue;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
+ switch ( g_sendActivateEvent )
+ {
+ case -1:
+ // we've got focus from outside, synthtize wxActivateEvent
+ g_sendActivateEvent = 1;
+ break;
+
+ case 0:
+ // another our window just lost focus, it was already ours before
+ // - don't send any wxActivateEvent
+ g_sendActivateEvent = -1;
+ break;
+ }
+
{
panel->SetLastFocus(win);
}
{
panel->SetLastFocus(win);
}
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (!win->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
+ // if the focus goes out of our app alltogether, OnIdle() will send
+ // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset
+ // g_sendActivateEvent to -1
+ g_sendActivateEvent = 0;
+
+ g_focusWindow = (wxWindow *)NULL;
+
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) return;
float diff = adjust->value - win->m_oldVerticalPos;
if (fabs(diff) < 0.2) return;
float diff = adjust->value - win->m_oldVerticalPos;
if (fabs(diff) < 0.2) return;
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
win->m_oldVerticalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->vscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxVERTICAL );
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxVERTICAL );
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
float diff = adjust->value - win->m_oldHorizontalPos;
if (fabs(diff) < 0.2) return;
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
win->m_oldHorizontalPos = adjust->value;
GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
GtkRange *range = GTK_RANGE( scrolledWindow->hscrollbar );
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
wxEventType command = wxEVT_SCROLLWIN_THUMBTRACK;
if (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLLWIN_LINEUP;
else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD) command = wxEVT_SCROLLWIN_LINEDOWN;
else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD) command = wxEVT_SCROLLWIN_PAGEDOWN;
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
int value = (int)(adjust->value+0.5);
wxScrollWinEvent event( command, value, wxHORIZONTAL );
GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow);
child->m_x += pizza->xoffset;
child->m_y += pizza->yoffset;
GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow);
child->m_x += pizza->xoffset;
child->m_y += pizza->yoffset;
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
m_noExpose = FALSE;
m_nativeSizeEvent = FALSE;
m_noExpose = FALSE;
m_nativeSizeEvent = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_isRadioButton = FALSE;
m_isFrame = FALSE;
m_acceptsFocus = FALSE;
m_isRadioButton = FALSE;
m_isFrame = FALSE;
m_acceptsFocus = FALSE;
m_cursor = *wxSTANDARD_CURSOR;
}
m_cursor = *wxSTANDARD_CURSOR;
}
m_y = (int)pos.y;
/* some reasonable defaults */
m_y = (int)pos.y;
/* some reasonable defaults */
if (m_y < 10) m_y = 10;
}
}
if (m_y < 10) m_y = 10;
}
}
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
}
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",
#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",
else
{
GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow);
else
{
GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow);
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
{
if (x != -1) m_x = x + pizza->xoffset;
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
{
if (x != -1) m_x = x + pizza->xoffset;
m_width+2*border,
m_height+border+bottom_border );
}
m_width+2*border,
m_height+border+bottom_border );
}
/*
wxPrintf( "OnSize sent from " );
if (GetClassInfo() && GetClassInfo()->GetClassName())
/*
wxPrintf( "OnSize sent from " );
if (GetClassInfo() && GetClassInfo()->GetClassName())
void wxWindow::OnInternalIdle()
{
void wxWindow::OnInternalIdle()
{
+ if ( g_sendActivateEvent != -1 )
+ {
+ bool activate = g_sendActivateEvent != 0;
+
+ // do it only once
+ g_sendActivateEvent = -1;
+
+ wxActivateEvent event(wxEVT_ACTIVATE, activate, GetId());
+ event.SetEventObject(this);
+
+ (void)GetEventHandler()->ProcessEvent(event);
+ }
+
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
wxCursor cursor = m_cursor;
if (g_globalCursor.Ok()) cursor = g_globalCursor;
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
as setting the cursor in a parent window also effects the
windows above so that checking for the current cursor is
not possible. */
if (m_wxwindow)
{
GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window;
if (m_wxwindow)
{
GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window;
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
/* we provide this function ourselves as it is
missing in GDK (top of this file) */
/* we provide this function ourselves as it is
missing in GDK (top of this file) */
GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
GdkWindow *window = (GdkWindow*) NULL;
if (m_wxwindow)
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (window)
gdk_window_warp_pointer( window, x, y );
}
if (window)
gdk_window_warp_pointer( window, x, y );
}
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
gtk_pizza_set_clear( pizza, old_clear );
}
else
gtk_pizza_set_clear( pizza, old_clear );
}
else
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
gboolean old_clear = pizza->clear_on_draw;
gtk_pizza_set_clear( pizza, FALSE );
gtk_widget_draw( m_wxwindow, &gdk_rect );
gtk_widget_draw( m_wxwindow, &gdk_rect );
gtk_pizza_set_clear( pizza, old_clear );
}
else
gtk_pizza_set_clear( pizza, old_clear );
}
else
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (!window)
{
// indicate that a new style has been set
if (!window)
{
// indicate that a new style has been set
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (!window)
{
// indicate that a new style has been set
if (!window)
{
// indicate that a new style has been set
gs_pop_y = y;
bool is_waiting = TRUE;
gs_pop_y = y;
bool is_waiting = TRUE;
gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide",
GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting );
gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide",
GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting );
0, // button used to activate it
gs_timeLastClick // the time of activation
);
0, // button used to activate it
gs_timeLastClick // the time of activation
);
while (is_waiting)
{
while (gtk_events_pending())
while (is_waiting)
{
while (gtk_events_pending())
bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
{
bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
{
return (window == GTK_PIZZA(m_wxwindow)->bin_window);
return (window == GTK_PIZZA(m_wxwindow)->bin_window);
return (window == m_widget->window);
}
return (window == m_widget->window);
}
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
if (!window) return;
gdk_pointer_grab( window, FALSE,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
if (!window) return;
gdk_pointer_grab( window, FALSE,
(GdkEventMask)
(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL,
m_cursor.GetCursor(),
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL,
m_cursor.GetCursor(),
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;