#include "wx/menu.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
+#include "wx/settings.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h"
*/
-//-----------------------------------------------------------------------------
-// cond comp
-//-----------------------------------------------------------------------------
+//-------------------------------------------------------------------------
+// conditional compilation
+//-------------------------------------------------------------------------
#if (GTK_MINOR_VERSION == 1)
-#if (GTK_MICRO_VERSION >= 3)
-#define NEW_GTK_DND_CODE
+#if (GTK_MICRO_VERSION >= 5)
+#define NEW_GTK_SCROLL_CODE
#endif
#endif
extern wxList wxPendingDelete;
extern wxList wxTopLevelWindows;
extern bool g_blockEventsOnDrag;
+extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE;
// hack: we need something to pass to gtk_menu_popup, so we store the time of
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
{
if (!win->HasVMT()) return;
- if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( gdk_event->area.x,
gdk_event->area.y,
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
{
if (!win->HasVMT()) return;
- if (g_blockEventsOnDrag) return;
win->m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height );
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
+ if (g_blockEventsOnScroll) return TRUE;
if (win->m_wxwindow)
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
+ if (g_blockEventsOnScroll) return TRUE;
if (!win->HasVMT()) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
-
+ if (g_blockEventsOnScroll) return TRUE;
+
if (!win->HasVMT()) return TRUE;
/*
float line_step = win->m_vAdjust->step_increment;
float page_step = win->m_vAdjust->page_increment;
- if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
- else command = wxEVT_SCROLL_THUMBTRACK;
+ if (win->m_isScrolling)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else
+ {
+ if (fabs(win->m_vAdjust->value-win->m_vAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->m_vAdjust->value-win->m_vAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
+ else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
+ else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+ }
int value = (int)(win->m_vAdjust->value+0.5);
float line_step = win->m_hAdjust->step_increment;
float page_step = win->m_hAdjust->page_increment;
-
- if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
- else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
- else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
- else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
- else command = wxEVT_SCROLL_THUMBTRACK;
+
+ if (win->m_isScrolling)
+ {
+ command = wxEVT_SCROLL_THUMBTRACK;
+ }
+ else
+ {
+ if (fabs(win->m_hAdjust->value-win->m_hAdjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
+ else if (fabs(win->m_hAdjust->value-win->m_hAdjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
+ else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
+ else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
+ else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
+ else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
+ else command = wxEVT_SCROLL_THUMBTRACK;
+ }
int value = (int)(win->m_hAdjust->value+0.5);
// "button_press_event" from scrollbar
//-----------------------------------------------------------------------------
-static gint gtk_scrollbar_button_press_callback( GtkRange *widget, GdkEventButton *gdk_event, wxWindow *win )
+static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
+ GdkEventButton *WXUNUSED(gdk_event),
+ wxWindow *win )
{
- if (gdk_event->window != widget->slider) return FALSE;
-
+// if (gdk_event->window != widget->slider) return FALSE;
+
win->m_isScrolling = TRUE;
+ g_blockEventsOnScroll = TRUE;
return FALSE;
}
// "button_release_event" from scrollbar
//-----------------------------------------------------------------------------
-static gint gtk_scrollbar_button_release_callback( GtkRange *widget, GdkEventButton *gdk_event, wxWindow *win )
+static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
+ GdkEventButton *WXUNUSED(gdk_event),
+ wxWindow *win )
{
- if (gdk_event->window != widget->slider) return FALSE;
+
+// don't test here as we can reelase the mouse while being over
+// a different window then the slider
+//
+// if (gdk_event->window != widget->slider) return FALSE;
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(win->m_widget);
gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
win->m_isScrolling = FALSE;
+ g_blockEventsOnScroll = FALSE;
return FALSE;
}
-
-#ifdef NEW_GTK_DND_CODE
-
-#else
-
-//-----------------------------------------------------------------------------
-// "drop_data_available_event"
-//-----------------------------------------------------------------------------
-
-static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailable *event, wxWindow *win )
-{
- if (!win->HasVMT()) return;
-
- if (win->GetDropTarget())
- {
- int x = 0;
- int y = 0;
- gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
-
- printf( "Drop data is of type %s.\n", event->data_type );
-
- win->GetDropTarget()->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes );
- }
-
-/*
- g_free (event->dropdataavailable.data);
- g_free (event->dropdataavailable.data_type);
-*/
-}
-
-#endif
- // NEW_GTK_DND_CODE
-
//-----------------------------------------------------------------------------
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
- m_hasScrolling = TRUE;
+ GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
- (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
- (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
- (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
- (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
-
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0;
m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->hscrollbar) );
m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) );
- gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
- (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this );
- gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
- (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
-
- gtk_signal_connect( GTK_OBJECT(m_hAdjust), "changed",
- (GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this );
- gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
- (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
+ m_wxwindow = gtk_myfixed_new();
+#ifdef NEW_GTK_SCROLL_CODE
+ gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow );
+ GtkViewport *viewport = GTK_VIEWPORT(s_window->child);
+#else
+ gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
+#endif
if (m_windowStyle & wxRAISED_BORDER)
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
- m_wxwindow = gtk_myfixed_new();
-
- GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
-
if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL)
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
else
GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
- gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
-
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
m_hAdjust->page_size = 5.0;
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
+ // these handlers block mouse events to any window during scrolling
+ // such as motion events and prevent GTK and wxWindows from fighting
+ // over where the slider should be
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_press_event",
+ (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->vscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
+ (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
+
+ // these handers het notified when screen updates are required either when
+ // scrolling or when the window size (and therefore scrollbar configuration)
+ // has changed
+
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed",
+ (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this );
+ gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed",
+ (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this );
+
+ gtk_signal_connect( GTK_OBJECT(m_hAdjust), "changed",
+ (GtkSignalFunc) gtk_window_hscroll_change_callback, (gpointer) this );
+ gtk_signal_connect(GTK_OBJECT(m_vAdjust), "changed",
+ (GtkSignalFunc) gtk_window_vscroll_change_callback, (gpointer) this );
+
gtk_widget_show( m_wxwindow );
if (m_parent) m_parent->AddChild( this );
if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
if (m_widget) gtk_widget_destroy( m_widget );
-
+
if (m_cursor) delete m_cursor;
DeleteRelatedConstraints();
m_eventHandler = this;
- m_windowId = id;
+ m_windowId = id == -1 ? wxNewId() : id;
m_sizeSet = FALSE;
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
- // Don't do anything for children of wxNotebook
- if (m_parent->m_wxwindow == NULL) return;
-
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
- int old_width = m_width;
- int old_height = m_height;
-
- if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
- {
- if (x != -1) m_x = x;
- if (y != -1) m_y = y;
- if (width != -1) m_width = width;
- if (height != -1) m_height = height;
- }
- else
+ if (m_parent->m_wxwindow == NULL) // i.e. wxNotebook
{
+ // don't set the size for children of wxNotebook, just take the values.
m_x = x;
m_y = y;
m_width = width;
- m_height = height;
+ m_height = height;
}
-
- if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
+ else
{
- if (width == -1) m_width = 80;
- }
+ int old_width = m_width;
+ int old_height = m_height;
+
+ if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
+ {
+ if (x != -1) m_x = x;
+ if (y != -1) m_y = y;
+ if (width != -1) m_width = width;
+ if (height != -1) m_height = height;
+ }
+ else
+ {
+ m_x = x;
+ m_y = y;
+ m_width = width;
+ m_height = height;
+ }
- if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
- {
- if (height == -1) m_height = 26;
- }
+ if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
+ {
+ if (width == -1) m_width = 80;
+ }
+
+ if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
+ {
+ if (height == -1) m_height = 26;
+ }
- if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
- if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
- if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
- if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+ if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
+ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
+ if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
+ if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
- wxPoint pt( m_parent->GetClientAreaOrigin() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
+ wxPoint pt( m_parent->GetClientAreaOrigin() );
+ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
- if ((old_width != m_width) || (old_height != m_height))
- gtk_widget_set_usize( m_widget, m_width, m_height );
+ if ((old_width != m_width) || (old_height != m_height))
+ gtk_widget_set_usize( m_widget, m_width, m_height );
+ }
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
- ProcessEvent( event );
+ GetEventHandler()->ProcessEvent( event );
m_resizing = FALSE;
}
if (!m_hasScrolling)
{
-/*
- do we have sunken dialogs ?
-
GtkStyleClass *window_class = m_wxwindow->style->klass;
- dw += 2 * window_class->xthickness;
- dh += 2 * window_class->ythickness;
-*/
+ if ((m_windowStyle & wxRAISED_BORDER) ||
+ (m_windowStyle & wxSUNKEN_BORDER))
+ {
+ dw += 2 * window_class->xthickness;
+ dh += 2 * window_class->ythickness;
+ }
}
else
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkWidget *viewport = scroll_window->child;
+#else
GtkWidget *viewport = scroll_window->viewport;
+#endif
+
GtkStyleClass *viewport_class = viewport->style->klass;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
dh += 2 * viewport_class->ythickness;
}
- if (GTK_WIDGET_VISIBLE(vscrollbar))
+ if (scroll_window->vscrollbar_visible)
{
dw += vscrollbar->allocation.width;
dw += scroll_class->scrollbar_spacing;
}
- if (GTK_WIDGET_VISIBLE(hscrollbar))
+ if (scroll_window->hscrollbar_visible)
{
dh += hscrollbar->allocation.height;
dw += scroll_class->scrollbar_spacing;
if (!m_hasScrolling)
{
-/*
- do we have sunken dialogs ?
-
GtkStyleClass *window_class = m_wxwindow->style->klass;
- dw += 2 * window_class->xthickness;
- dh += 2 * window_class->ythickness;
-*/
+ if ((m_windowStyle & wxRAISED_BORDER) ||
+ (m_windowStyle & wxSUNKEN_BORDER))
+ {
+ dw += 2 * window_class->xthickness;
+ dh += 2 * window_class->ythickness;
+ }
}
else
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
+#ifdef NEW_GTK_SCROLL_CODE
+ GtkWidget *viewport = scroll_window->child;
+#else
GtkWidget *viewport = scroll_window->viewport;
- GtkStyleClass *viewport_class = viewport->style->klass;
+#endif
- GtkWidget *hscrollbar = scroll_window->hscrollbar;
- GtkWidget *vscrollbar = scroll_window->vscrollbar;
+ GtkStyleClass *viewport_class = viewport->style->klass;
if ((m_windowStyle & wxRAISED_BORDER) ||
(m_windowStyle & wxSUNKEN_BORDER))
dh += 2 * viewport_class->ythickness;
}
- if (GTK_WIDGET_VISIBLE(vscrollbar))
+ if (scroll_window->vscrollbar_visible)
{
// dw += vscrollbar->allocation.width;
dw += 15; // range.slider_width = 11 + 2*2pts edge
dw += scroll_class->scrollbar_spacing;
}
- if (GTK_WIDGET_VISIBLE(hscrollbar))
+ if (scroll_window->hscrollbar_visible)
{
// dh += hscrollbar->allocation.height;
dh += 15;
void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
{
- //if (GetAutoLayout()) Layout();
+// if (GetAutoLayout()) Layout();
}
bool wxWindow::Show( bool show )
int wxWindow::GetCharWidth() const
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (!m_font.Ok())
- {
- wxFAIL_MSG( "invalid font" );
- return -1;
- }
+ if (!m_font.Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return -1;
+ }
- GdkFont *font = m_font.GetInternalFont( 1.0 );
- return gdk_string_width( font, "H" );
+ GdkFont *font = m_font.GetInternalFont( 1.0 );
+ return gdk_string_width( font, "H" );
}
void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- wxFont fontToUse = m_font;
- if (theFont) fontToUse = *theFont;
+ wxFont fontToUse = m_font;
+ if (theFont) fontToUse = *theFont;
- if (!fontToUse.Ok())
- {
- wxFAIL_MSG( "invalid font" );
- return;
- }
- wxASSERT_MSG( (m_font.Ok()), "invalid font" );
+ if (!fontToUse.Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return;
+ }
+ wxASSERT_MSG( (m_font.Ok()), "invalid font" );
- GdkFont *font = fontToUse.GetInternalFont( 1.0 );
- if (x) (*x) = gdk_string_width( font, string );
- if (y) (*y) = font->ascent + font->descent;
- if (descent) (*descent) = font->descent;
- if (externalLeading) (*externalLeading) = 0; // ??
+ GdkFont *font = fontToUse.GetInternalFont( 1.0 );
+ if (x) (*x) = gdk_string_width( font, string );
+ if (y) (*y) = font->ascent + font->descent;
+ if (descent) (*descent) = font->descent;
+ if (externalLeading) (*externalLeading) = 0; // ??
}
void wxWindow::MakeModal( bool modal )
void wxWindow::SetFocus()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- GtkWidget *connect_widget = GetConnectWidget();
- if (connect_widget)
- {
- if (GTK_WIDGET_CAN_FOCUS(connect_widget) && !GTK_WIDGET_HAS_FOCUS (connect_widget) )
+ GtkWidget *connect_widget = GetConnectWidget();
+ if (connect_widget)
{
- gtk_widget_grab_focus (connect_widget);
+ if (GTK_WIDGET_CAN_FOCUS(connect_widget) && !GTK_WIDGET_HAS_FOCUS (connect_widget) )
+ {
+ gtk_widget_grab_focus (connect_widget);
+ }
}
- }
}
bool wxWindow::OnClose()
{
- return TRUE;
+ return TRUE;
}
void wxWindow::AddChild( wxWindow *child )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- wxASSERT_MSG( (child != NULL), "invalid child" );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (child != NULL), "invalid child" );
- m_children.Append( child );
+ m_children.Append( child );
}
wxList *wxWindow::GetChildren()
{
- return (&m_children);
+ return (&m_children);
+}
+
+wxWindow *wxWindow::ReParent( wxWindow *newParent )
+{
+ wxWindow *oldParent = GetParent();
+
+ if (oldParent) oldParent->RemoveChild( this );
+
+ gtk_widget_unparent( m_widget );
+
+ if (newParent)
+ {
+ newParent->AddChild( this );
+ (newParent->m_insertCallback)( newParent, this );
+ }
+
+ return oldParent;
}
void wxWindow::RemoveChild( wxWindow *child )
{
- if (GetChildren()) GetChildren()->DeleteObject( child );
- child->m_parent = (wxWindow *) NULL;
+ if (GetChildren()) GetChildren()->DeleteObject( child );
+ child->m_parent = (wxWindow *) NULL;
}
void wxWindow::SetReturnCode( int retCode )
{
- m_retCode = retCode;
+ m_retCode = retCode;
}
int wxWindow::GetReturnCode()
{
- return m_retCode;
+ return m_retCode;
}
void wxWindow::Raise()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (m_widget) gdk_window_raise( m_widget->window );
+ if (m_widget) gdk_window_raise( m_widget->window );
}
void wxWindow::Lower()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (m_widget) gdk_window_lower( m_widget->window );
+ if (m_widget) gdk_window_lower( m_widget->window );
}
wxEvtHandler *wxWindow::GetEventHandler()
{
- return m_eventHandler;
+ return m_eventHandler;
}
void wxWindow::SetEventHandler( wxEvtHandler *handler )
{
- m_eventHandler = handler;
+ m_eventHandler = handler;
}
void wxWindow::PushEventHandler(wxEvtHandler *handler)
{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
+ handler->SetNextHandler(GetEventHandler());
+ SetEventHandler(handler);
}
wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
{
- if (GetEventHandler())
- {
- wxEvtHandler *handlerA = GetEventHandler();
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler((wxEvtHandler *) NULL);
- SetEventHandler(handlerB);
- if (deleteHandler)
+ if (GetEventHandler())
{
- delete handlerA;
- return (wxEvtHandler*) NULL;
- }
- else
- return handlerA;
- }
- else
- return (wxEvtHandler *) NULL;
+ wxEvtHandler *handlerA = GetEventHandler();
+ wxEvtHandler *handlerB = handlerA->GetNextHandler();
+ handlerA->SetNextHandler((wxEvtHandler *) NULL);
+ SetEventHandler(handlerB);
+ if (deleteHandler)
+ {
+ delete handlerA;
+ return (wxEvtHandler*) NULL;
+ }
+ else
+ return handlerA;
+ }
+ else
+ return (wxEvtHandler *) NULL;
}
wxValidator *wxWindow::GetValidator()
{
- return m_windowValidator;
+ return m_windowValidator;
}
void wxWindow::SetValidator( const wxValidator& validator )
void wxWindow::Clear()
{
- wxCHECK_RET( m_widget != NULL, "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
+ if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
wxColour wxWindow::GetBackgroundColour() const
{
- return m_backgroundColour;
+ return m_backgroundColour;
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_widget != NULL, "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- m_backgroundColour = colour;
- if (!m_backgroundColour.Ok()) return;
+ if (m_backgroundColour == colour) return;
+
+ if (!m_backgroundColour.Ok())
+ if (wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) == colour) return;
- if (m_wxwindow)
- {
- GdkWindow *window = m_wxwindow->window;
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
- gdk_window_set_background( window, m_backgroundColour.GetColor() );
- gdk_window_clear( window );
- }
+ m_backgroundColour = colour;
+ if (!m_backgroundColour.Ok()) return;
- ApplyWidgetStyle();
+ if (m_wxwindow)
+ {
+ GdkWindow *window = m_wxwindow->window;
+ m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
+ gdk_window_set_background( window, m_backgroundColour.GetColor() );
+ gdk_window_clear( window );
+ }
+
+ ApplyWidgetStyle();
}
wxColour wxWindow::GetForegroundColour() const
{
- return m_foregroundColour;
+ return m_foregroundColour;
}
void wxWindow::SetForegroundColour( const wxColour &colour )
{
- wxCHECK_RET( m_widget != NULL, "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- m_foregroundColour = colour;
- if (!m_foregroundColour.Ok()) return;
+ if (m_foregroundColour == colour) return;
- ApplyWidgetStyle();
+ m_foregroundColour = colour;
+ if (!m_foregroundColour.Ok()) return;
+
+ ApplyWidgetStyle();
}
GtkStyle *wxWindow::GetWidgetStyle()
GtkWidget *dnd_widget = GetConnectWidget();
- DisconnectDnDWidget( dnd_widget );
+ if (m_dropTarget) m_dropTarget->UnregisterWidget( dnd_widget );
if (m_dropTarget) delete m_dropTarget;
m_dropTarget = dropTarget;
- ConnectDnDWidget( dnd_widget );
+ if (m_dropTarget) m_dropTarget->RegisterWidget( dnd_widget );
}
wxDropTarget *wxWindow::GetDropTarget() const
return m_dropTarget;
}
-void wxWindow::ConnectDnDWidget( GtkWidget *widget )
-{
- if (!m_dropTarget) return;
-
- m_dropTarget->RegisterWidget( widget );
-
-#ifdef NEW_GTK_DND_CODE
-
-#else
-
- gtk_signal_connect( GTK_OBJECT(widget), "drop_data_available_event",
- GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
-
-#endif
-
-}
-
-void wxWindow::DisconnectDnDWidget( GtkWidget *widget )
-{
- if (!m_dropTarget) return;
-
-#ifdef NEW_GTK_DND_CODE
-
-#else
-
- gtk_signal_disconnect_by_func( GTK_OBJECT(widget),
- GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
-
- m_dropTarget->UnregisterWidget( widget );
-
-#endif
-
-}
-
GtkWidget* wxWindow::GetConnectWidget()
{
GtkWidget *connect_widget = m_widget;
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return;
+
+ m_hasScrolling = TRUE;
if (orient == wxHORIZONTAL)
{