// Name: window.cpp
// Purpose:
// Author: Robert Roebling
-// Id: $id$
+// Id: $Id$
// Copyright: (c) 1998 Robert Roebling, Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
if (gdk_event->count > 0) return;
/*
- printf( "OnExpose from " );
+ printf( "OnExpose from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" );
// "drop_data_available_event"
//-----------------------------------------------------------------------------
-static void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win )
+static void gtk_window_drop_callback( GtkWidget *widget, GdkEventDropDataAvailable *event, wxWindow *win )
{
if (!win->HasVMT()) return;
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
+ win->GetDropTarget()->m_size = event->data_numbytes;
win->GetDropTarget()->Drop( event, x, y );
}
m_isEnabled = TRUE;
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
- m_hasOwnStyle = FALSE;
m_scrollGC = (GdkGC*) NULL;
+ m_widgetStyle = (GtkStyle*) NULL;
}
bool wxWindow::Create( wxWindow *parent, wxWindowID id,
DestroyChildren();
+ if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
+
if (m_scrollGC) gdk_gc_unref( m_scrollGC );
if (m_wxwindow) gtk_widget_destroy( m_wxwindow );
m_cursor = new wxCursor( wxCURSOR_ARROW );
m_font = *wxSWISS_FONT;
// m_backgroundColour = wxWHITE;
- m_foregroundColour = wxBLACK;
+// m_foregroundColour = wxBLACK;
m_windowStyle = style;
m_windowName = name;
m_constraints = (wxLayoutConstraints *) NULL;
m_pDropTarget = (wxDropTarget *) NULL;
m_resizing = FALSE;
m_windowValidator = (wxValidator *) NULL;
- m_hasOwnStyle = FALSE;
m_scrollGC = (GdkGC*) NULL;
+ m_widgetStyle = (GtkStyle*) NULL;
}
void wxWindow::PostCreation()
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
}
- else
- {
- GtkStyle *style = gtk_widget_get_style( m_widget );
- if (!m_hasOwnStyle)
- {
- m_hasOwnStyle = TRUE;
- style = gtk_style_copy( style );
- }
-
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
- style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
- style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
-
- gtk_widget_set_style( m_widget, style );
- }
+
+ ApplyWidgetStyle();
}
wxColour wxWindow::GetForegroundColour() const
void wxWindow::SetForegroundColour( const wxColour &colour )
{
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
+
m_foregroundColour = colour;
+ if (!m_foregroundColour.Ok()) return;
+
+ ApplyWidgetStyle();
+}
+
+GtkStyle *wxWindow::GetWidgetStyle()
+{
+ if (m_widgetStyle) gtk_style_unref( m_widgetStyle );
+
+ m_widgetStyle =
+ gtk_style_copy(
+ gtk_widget_get_style( m_widget ) );
+
+ return m_widgetStyle;
+}
+
+void wxWindow::SetWidgetStyle()
+{
+ GtkStyle *style = GetWidgetStyle();
+
+ gdk_font_unref( style->font );
+ style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+
+ if (m_foregroundColour.Ok())
+ {
+ m_foregroundColour.CalcPixel( gdk_window_get_colormap( m_widget->window ) );
+ 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 ) );
+ style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+ style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor();
+ style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor();
+ style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+ style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor();
+ }
+}
+
+void wxWindow::ApplyWidgetStyle()
+{
}
bool wxWindow::Validate()
void wxWindow::InitDialog()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
wxInitDialogEvent event(GetId());
event.SetEventObject( this );
bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
+ wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" );
+
SetInvokingWindow( menu, this );
gtk_menu_popup(
GTK_MENU(menu->m_menu),
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
GtkWidget *dnd_widget = GetConnectWidget();
void wxWindow::SetFont( const wxFont &font )
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
m_font = *wxSWISS_FONT;
-
- GtkStyle *style = gtk_widget_get_style( m_widget );
- if (!m_hasOwnStyle)
- {
- m_hasOwnStyle = TRUE;
- style = gtk_style_copy( style );
- }
-
- gdk_font_unref( style->font );
- style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
-
- gtk_widget_set_style( m_widget, style );
+
+ ApplyWidgetStyle();
}
wxFont *wxWindow::GetFont()
void wxWindow::CaptureMouse()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- wxASSERT_MSG( (g_capturing == FALSE), "CaptureMouse called twice" );
+ wxCHECK_RET( g_capturing == FALSE, "CaptureMouse called twice" );
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
void wxWindow::ReleaseMouse()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_RET( m_widget != NULL, "invalid window" );
- wxASSERT_MSG( (g_capturing == TRUE), "ReleaseMouse called twice" );
+ wxCHECK_RET( g_capturing == TRUE, "ReleaseMouse called twice" );
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );