some more information about what the wxWindow, which is the base class
for all other window classes, does seems required as well.
+ I)
+
What does wxWindow do? It contains the common interface for the following
jobs of its descendants:
5) A multitude of helper or extra methods for special purposes, such as
Drag'n'Drop, managing validators etc.
+ 6) Display a border (sunken, raised, simple or none).
+
Normally one might expect, that one wxWindows window would always correspond
to one GTK widget. Under GTK, there is no such allround widget that has all
the functionality. Moreover, the GTK defines a client area as a different
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
+ the window. In wxWindows, the scrollbar will only emit an event, send this
+ to (normally) a wxScrolledWindow and that class will call ScrollWindow()
+ which actually moves the window and its subchildren. Note that GtkMyFixed
+ 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 myfixed->xoffset and myfixed->yoffset values.
+
+ 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
+ events are sent at all (All this is due to a bug in the GtkContainer code
+ which got fixed in GTK 1.2.6). For that reason, wxGTK completely ignores
+ GTK's own system and it simply waits for size events for toplevel windows
+ and then iterates down the respective size events to all window. This has
+ the disadvantage, that windows might get size events before the GTK widget
+ actually has the reported size. This doesn't normally pose any problem, but
+ the OpenGl drawing routines rely on correct behaviour. Therefore, I have
+ added the m_nativeSizeEvents flag, which is true only for the OpenGL canvas,
+ i.e. the wxGLCanvas will emit a size event, when (and not before) the X11
+ window that is used for OpenGl output really has that size (as reported by
+ 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
+ to set the cursor over and over again, starting from the toplevel windows
+ 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
+ that the two obviously have very different meanings.
*/
}
//-----------------------------------------------------------------------------
-// "draw" of m_wxwindow
+// "draw" of m_widget
//-----------------------------------------------------------------------------
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win )
(int)gdk_event->area.height );
*/
+ wxEraseEvent eevent( win->GetId() );
+ eevent.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent(eevent);
+
wxPaintEvent event( win->GetId() );
event.SetEventObject( win );
win->GetEventHandler()->ProcessEvent( event );
(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 );
GdkModifierType state;
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;
- bool ret = FALSE;
-
wxKeyEvent event( wxEVT_KEY_DOWN );
event.SetTimestamp( gdk_event->time );
event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK);
event.SetEventObject( win );
ret = win->GetEventHandler()->ProcessEvent( event );
- key_code = map_to_wx_keysym( gdk_event->keyval );
-
#if wxUSE_ACCEL
if (!ret)
{
}
}
#endif // wxUSE_ACCEL
+
/* wxMSW doesn't send char events with Alt pressed */
/* Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
- will only be sent if it is not a menu accelerator. */
- if ((key_code != 0) && ! ret )
+ 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))
{
wxKeyEvent event2( wxEVT_CHAR );
event2.SetTimestamp( gdk_event->time );
event2.m_x = x;
event2.m_y = y;
event2.SetEventObject( win );
- ret = (ret || win->GetEventHandler()->ProcessEvent( event2 ));
+ ret = win->GetEventHandler()->ProcessEvent( event2 );
}
/* win is a control: tab can be propagated up */
#if (GTK_MINOR_VERSION > 0)
/* pressing F10 will activate the menu bar of the top frame */
+/*
if ( (!ret) &&
(gdk_event->keyval == GDK_F10) )
{
wxNode *node = menubar->GetMenus().First();
if (node)
{
- // doesn't work correctly
- // wxMenu *firstMenu = (wxMenu*) node->Data();
- // gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
- // ret = TRUE;
+ wxMenu *firstMenu = (wxMenu*) node->Data();
+ gtk_menu_item_select( GTK_MENU_ITEM(firstMenu->m_owner) );
+ ret = TRUE;
break;
}
}
ancestor = ancestor->GetParent();
}
}
+*/
#endif
/*
}
}
-/*
- wxPrintf( wxT("2) OnButtonPress from ") );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( wxT(".\n") );
-*/
-
wxEventType event_type = wxEVT_LEFT_DOWN;
if (gdk_event->button == 1)
if (!g_captureWindow)
{
+ int x = event.m_x;
+ int y = event.m_y;
+ if (win->m_wxwindow)
+ {
+ GtkMyFixed *myfixed = GTK_MYFIXED(win->m_wxwindow);
+ x += myfixed->xoffset;
+ y += myfixed->yoffset;
+ }
+
wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
+
+ node = node->Next();
+ if (!child->IsShown())
+ continue;
if (child->m_isStaticBox)
{
// wxStaticBox is transparent in the box itself
- int x = event.m_x;
- int y = event.m_y;
int xx1 = child->m_x;
int yy1 = child->m_y;
int xx2 = child->m_x + child->m_width;
else
{
if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ (child->m_x <= x) &&
+ (child->m_y <= y) &&
+ (child->m_x+child->m_width >= x) &&
+ (child->m_y+child->m_height >= y))
{
win = child;
event.m_x -= child->m_x;
break;
}
}
- node = node->Next();
}
}
gs_timeLastClick = gdk_event->time;
+/*
+ wxPrintf( wxT("2) OnButtonPress from ") );
+ if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
+ wxPrintf( win->GetClassInfo()->GetClassName() );
+ wxPrintf( wxT(".\n") );
+*/
+
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
if (!g_captureWindow)
{
+ int x = event.m_x;
+ int y = event.m_y;
+ if (win->m_wxwindow)
+ {
+ GtkMyFixed *myfixed = GTK_MYFIXED(win->m_wxwindow);
+ x += myfixed->xoffset;
+ y += myfixed->yoffset;
+ }
+
wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
+ node = node->Next();
+ if (!child->IsShown())
+ continue;
+
if (child->m_isStaticBox)
{
// wxStaticBox is transparent in the box itself
- int x = event.m_x;
- int y = event.m_y;
int xx1 = child->m_x;
int yy1 = child->m_y;
int xx2 = child->m_x + child->m_width;
else
{
if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ (child->m_x <= x) &&
+ (child->m_y <= y) &&
+ (child->m_x+child->m_width >= x) &&
+ (child->m_y+child->m_height >= y))
{
win = child;
event.m_x -= child->m_x;
break;
}
}
- node = node->Next();
}
}
if (!g_captureWindow)
{
+ int x = event.m_x;
+ int y = event.m_y;
+ if (win->m_wxwindow)
+ {
+ GtkMyFixed *myfixed = GTK_MYFIXED(win->m_wxwindow);
+ x += myfixed->xoffset;
+ y += myfixed->yoffset;
+ }
+
wxNode *node = win->GetChildren().First();
while (node)
{
wxWindow *child = (wxWindow*)node->Data();
+ node = node->Next();
+ if (!child->IsShown())
+ continue;
+
if (child->m_isStaticBox)
{
// wxStaticBox is transparent in the box itself
- int x = event.m_x;
- int y = event.m_y;
int xx1 = child->m_x;
int yy1 = child->m_y;
int xx2 = child->m_x + child->m_width;
else
{
if ((child->m_wxwindow == (GtkWidget*) NULL) &&
- (child->m_x <= event.m_x) &&
- (child->m_y <= event.m_y) &&
- (child->m_x+child->m_width >= event.m_x) &&
- (child->m_y+child->m_height >= event.m_y))
+ (child->m_x <= x) &&
+ (child->m_y <= y) &&
+ (child->m_x+child->m_width >= x) &&
+ (child->m_y+child->m_height >= y))
{
win = child;
event.m_x -= child->m_x;
break;
}
}
- node = node->Next();
}
}
static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
{
+ /* the window might have been scrolled already, do we
+ have to adapt the position */
+ GtkMyFixed *myfixed = GTK_MYFIXED(parent->m_wxwindow);
+ child->m_x += myfixed->xoffset;
+ child->m_y += myfixed->yoffset;
+
gtk_myfixed_put( GTK_MYFIXED(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_oldVerticalPos = 0.0;
m_resizing = FALSE;
- m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
m_insertCallback = (wxInsertChildFunction) NULL;
m_isStaticBox = FALSE;
m_isRadioButton = FALSE;
+ m_isFrame = FALSE;
m_acceptsFocus = FALSE;
m_cursor = *wxSTANDARD_CURSOR;
m_widgetStyle = (GtkStyle*) NULL;
}
- if (m_scrollGC)
- {
- gdk_gc_unref( m_scrollGC );
- m_scrollGC = (GdkGC*) NULL;
- }
-
if (m_wxwindow)
{
gtk_widget_destroy( m_wxwindow );
if (m_wxwindow)
{
- /* these get reported to wxWindows -> wxPaintEvent */
- gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
- GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
+ if (!m_noExpose)
+ {
+ /* these get reported to wxWindows -> wxPaintEvent */
+ gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
+ GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
- 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 */
}
else
{
+ GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow);
+
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
{
- if (x != -1) m_x = x;
- if (y != -1) m_y = y;
+ if (x != -1) m_x = x + myfixed->xoffset;
+ if (y != -1) m_y = y + myfixed->yoffset;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
- m_x = x;
- m_y = y;
+ m_x = x + myfixed->xoffset;
+ m_y = y + myfixed->yoffset;
m_width = width;
m_height = height;
}
bottom_border = 5;
}
- /* this is the result of hours of debugging: the following code
- means that if we have a m_wxwindow and we set the size of
- m_widget, m_widget (which is a GtkScrolledWindow) does NOT
- automatically propagate its size down to its m_wxwindow,
- which is its client area. therefore, we have to tell the
- client area directly that it has to resize itself.
- this will lead to that m_widget (GtkScrolledWindow) will
- calculate how much size it needs for scrollbars etc and
- it will then call XXX_size_allocate of its child, which
- is m_wxwindow. m_wxwindow in turn will do the same with its
- children and so on. problems can arise if this happens
- before all the children have been realized as some widgets
- stupidy need to be realized during XXX_size_allocate (e.g.
- GtkNotebook) and they will segv if called otherwise. this
- emergency is tested in gtk_myfixed_size_allocate. Normally
- this shouldn't be needed and only gtk_widget_queue_resize()
- should be enough to provoke a resize at the next appropriate
- moment, but this seems to fail, e.g. when a wxNotebook contains
- a wxSplitterWindow: the splitter window's children won't
- show up properly resized then. */
-
gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow),
m_widget,
m_x-border,
m_width+2*border,
m_height+border+bottom_border );
}
+
+/*
+ wxPrintf( "OnSize sent from " );
+ if (GetClassInfo() && GetClassInfo()->GetClassName())
+ wxPrintf( GetClassInfo()->GetClassName() );
+ wxPrintf( " %d %d %d %d\n", (int)m_x, (int)m_y, (int)m_width, (int)m_height );
+*/
- m_sizeSet = TRUE;
-
- wxSizeEvent event( wxSize(m_width,m_height), GetId() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ if (!m_nativeSizeEvent)
+ {
+ wxSizeEvent event( wxSize(m_width,m_height), GetId() );
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent( event );
+ }
m_resizing = FALSE;
}
if (cursor.Ok())
{
- /* I now set the cursor the anew in every OnInternalIdle call
+ /* I now set the cursor anew in every OnInternalIdle call
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_MYFIXED(m_wxwindow)->bin_window;
{
wxCHECK_RET( (m_widget != NULL), wxT("invalid window") );
- if (x) (*x) = m_x;
- if (y) (*y) = m_y;
+ int dx = 0;
+ int dy = 0;
+ if (m_parent && m_parent->m_wxwindow)
+ {
+ GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow);
+ dx = myfixed->xoffset;
+ dy = myfixed->yoffset;
+ }
+
+ if (x) (*x) = m_x - dx;
+ if (y) (*y) = m_y - dy;
}
void wxWindow::DoClientToScreen( int *x, int *y ) const
if (oldParent)
{
- gtk_container_remove( GTK_CONTAINER(oldParent->m_wxwindow), m_widget );
+ gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget );
}
wxASSERT( GTK_IS_WIDGET(m_widget) );
}
}
+ /* there is no GTK equivalent of "draw only, don't clear" so we
+ invent our own in the GtkMyFixed widget */
+
if (!rect)
{
if (m_wxwindow)
{
- /* call the callback directly for preventing GTK from
- clearing the background */
- int w = 0;
- int h = 0;
- GetClientSize( &w, &h );
+ GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
+ gboolean old_clear = myfixed->clear_on_draw;
+ gtk_my_fixed_set_clear( myfixed, FALSE );
+
+ gtk_widget_draw( m_wxwindow, (GdkRectangle*) NULL );
- GetUpdateRegion().Union( 0, 0, w, h );
- wxPaintEvent event( GetId() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
- GetUpdateRegion().Clear();
+ gtk_my_fixed_set_clear( myfixed, old_clear );
}
else
- {
gtk_widget_draw( m_widget, (GdkRectangle*) NULL );
- }
}
else
{
+ GdkRectangle gdk_rect;
+ gdk_rect.x = rect->x;
+ gdk_rect.y = rect->y;
+ gdk_rect.width = rect->width;
+ gdk_rect.height = rect->height;
if (m_wxwindow)
{
- /* call the callback directly for preventing GTK from
- clearing the background */
- GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height );
- wxPaintEvent event( GetId() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
- GetUpdateRegion().Clear();
+ GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
+ gboolean old_clear = myfixed->clear_on_draw;
+ gtk_my_fixed_set_clear( myfixed, FALSE );
+
+ gtk_widget_draw( m_wxwindow, &gdk_rect );
+
+ gtk_my_fixed_set_clear( myfixed, old_clear );
}
else
- {
- GdkRectangle gdk_rect;
- gdk_rect.x = rect->x;
- gdk_rect.y = rect->y;
- gdk_rect.width = rect->width;
- gdk_rect.height = rect->height;
-
gtk_widget_draw( m_widget, &gdk_rect );
- }
}
}
(GtkMenuPositionFunc) pop_pos_callback,
(gpointer) this, // client data
0, // button used to activate it
- 0 //gs_timeLastClick // the time of activation
+ gs_timeLastClick // the time of activation
);
while (is_waiting)