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.
*/
#endif // GTK_MINOR_VERSION > 0
-
-//-----------------------------------------------------------------------------
-// "size_allocate"
-//-----------------------------------------------------------------------------
-
-static void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
-{
- if (g_isIdle)
- wxapp_install_idle_handler();
-
- if (!win->m_hasVMT)
- return;
-
- if (win->m_sizeSet)
- return;
-
- win->m_sizeSet = TRUE;
-
-/*
- wxPrintf( "OnSize from " );
- if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
- wxPrintf( win->GetClassInfo()->GetClassName() );
- wxPrintf( " %d %d %d %d\n", (int)alloc->x,
- (int)alloc->y,
- (int)alloc->width,
- (int)alloc->height );
-*/
-
- wxSizeEvent event( win->GetSize(), win->GetId() );
- event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( event );
-}
-
//-----------------------------------------------------------------------------
// key event conversion routines
//-----------------------------------------------------------------------------
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();
}
}
m_isBeingDeleted = FALSE;
m_noExpose = FALSE;
-
+ m_nativeSizeEvent = FALSE;
+
m_hasScrolling = FALSE;
m_isScrolling = FALSE;
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
- if (!m_isFrame)
- {
- /* frames have their own callback */
- gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
- GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this );
- }
-
if (m_wxwindow)
{
if (!m_noExpose)
m_y = y;
m_width = width;
m_height = height;
-
- m_sizeSet = FALSE;
}
else
{
- int old_width = m_width;
- int old_height = m_height;
-
GtkMyFixed *myfixed = GTK_MYFIXED(m_parent->m_wxwindow);
if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)
m_y-border,
m_width+2*border,
m_height+border+bottom_border );
-
- if ((old_width != m_width) ||
- (old_height != m_height))
- {
- m_sizeSet = FALSE;
- }
}
-
+
/*
- wxSizeEvent event( wxSize(m_width,m_height), GetId() );
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent( event );
+ 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 );
*/
+
+ 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 (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) );