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.
-
+
II)
-
+
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.
-
- III)
-
+
+ III)
+
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
GTK).
IV)
-
+
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.
-
+
V)
-
+
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
- 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.
*/
extern bool g_blockEventsOnScroll;
extern wxCursor g_globalCursor;
static wxWindow *g_captureWindow = (wxWindow*) NULL;
- wxWindow *g_focusWindow = (wxWindow*) NULL;
+extern 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 */
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 );
- 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 );
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
-
+
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
(int)rect->width,
(int)rect->height );
*/
-
+
wxEraseEvent eevent( win->GetId() );
eevent.SetEventObject( win );
win->GetEventHandler()->ProcessEvent(eevent);
-
+
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;
-
+
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 );
-
+
if ( (!ret) &&
(key_code != 0))
{
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
-
+
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->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
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;
+ }
+
g_focusWindow = win;
/*
{
panel->SetLastFocus(win);
}
-
+
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
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())
if (g_blockEventsOnDrag) return;
if (!win->m_hasVMT) 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 );
-
+
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 );
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 );
-
+
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 );
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,
m_hasVMT = FALSE;
m_needParent = TRUE;
m_isBeingDeleted = FALSE;
-
+
m_noExpose = FALSE;
m_nativeSizeEvent = FALSE;
-
+
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
m_isRadioButton = FALSE;
m_isFrame = FALSE;
m_acceptsFocus = FALSE;
-
+
m_cursor = *wxSTANDARD_CURSOR;
}
m_y = (int)pos.y;
/* some reasonable defaults */
- if (!parent)
+ if (!parent)
{
if (m_x == -1)
{
if (m_y < 10) m_y = 10;
}
}
-
+
return TRUE;
}
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",
else
{
GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow);
-
+
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
{
if (x != -1) m_x = x + pizza->xoffset;
m_width+2*border,
m_height+border+bottom_border );
}
-
+
/*
wxPrintf( "OnSize sent from " );
if (GetClassInfo() && GetClassInfo()->GetClassName())
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;
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;
/* reverse: prevent GTK from deleting the widget arbitrarily */
gtk_widget_unref( m_widget );
-
+
return TRUE;
}
/* 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;
-
+
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 );
-
+
gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
-
+
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 );
-
+
gtk_widget_draw( m_wxwindow, &gdk_rect );
-
+
gtk_pizza_set_clear( pizza, old_clear );
}
else
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
-
+
if (!window)
{
// indicate that a new style has been set
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
-
+
if (!window)
{
// indicate that a new style has been set
if (m_foregroundColour.Ok())
{
- m_foregroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
+ m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) );
style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor();
style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor();
style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor();
if (m_backgroundColour.Ok())
{
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
+ m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) );
style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
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 );
0, // button used to activate it
gs_timeLastClick // the time of activation
);
-
+
while (is_waiting)
{
while (gtk_events_pending())
bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
{
- if (m_wxwindow)
+ if (m_wxwindow)
return (window == GTK_PIZZA(m_wxwindow)->bin_window);
-
+
return (window == m_widget->window);
}
if (!wxWindowBase::SetFont(font))
{
- // don't leave if the GTK widget has just
- // been realized
- if (!m_delayedFont) return FALSE;
- }
-
- GdkWindow *window = (GdkWindow*) NULL;
- if (m_wxwindow)
- window = GTK_PIZZA(m_wxwindow)->bin_window;
- else
- window = GetConnectWidget()->window;
-
- if (!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;
+ return FALSE;
}
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
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 |
- GDK_POINTER_MOTION_HINT_MASK |
+ GDK_POINTER_MOTION_HINT_MASK |
GDK_POINTER_MOTION_MASK),
(GdkWindow *) NULL,
m_cursor.GetCursor(),
window = GTK_PIZZA(m_wxwindow)->bin_window;
else
window = GetConnectWidget()->window;
-
+
if (!window)
return;