// Name: window.cpp
// Purpose:
// Author: Robert Roebling
-// Created: 01/02/97
-// Id:
-// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
+// 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,
m_wxwindow = gtk_myfixed_new();
- if (m_wxwindow) GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
+ 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 );
gtk_widget_show( m_wxwindow );
PostCreation();
-
+
Show( TRUE );
return TRUE;
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 );
if (m_widget) gtk_widget_destroy( m_widget );
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()
if (m_widget && m_parent) gtk_widget_realize( m_widget );
- if (m_wxwindow)
- {
- gtk_widget_realize( m_wxwindow );
- gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE );
- }
+ if (m_wxwindow) gtk_widget_realize( m_wxwindow );
SetCursor( *wxSTANDARD_CURSOR );
return m_backgroundColour;
}
-void wxWindow::SetBackgroundColourHelper( GdkWindow *window )
-{
- if (!m_backgroundColour.Ok()) return;
-
- m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
- gdk_window_set_background( window, m_backgroundColour.GetColor() );
- gdk_window_clear( window );
-}
-
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
wxCHECK_RET( m_widget != NULL, "invalid window" );
m_backgroundColour = colour;
+ if (!m_backgroundColour.Ok()) 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 );
+ }
- GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
- SetBackgroundColourHelper( widget->window );
+ 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 = (GtkStyle*) NULL;
- if (!m_hasOwnStyle)
- {
- m_hasOwnStyle = TRUE;
- style = gtk_style_copy( gtk_widget_get_style( m_widget ) );
- }
- else
- {
- style = gtk_widget_get_style( m_widget );
- }
-
- 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 );
int d_y = 0;
if (dx > 0) d_x = dx;
if (dy > 0) d_y = dy;
- gdk_window_copy_area( m_wxwindow->window, m_wxwindow->style->fg_gc[0], d_x, d_y,
+
+ if (!m_scrollGC)
+ {
+ m_scrollGC = gdk_gc_new( m_wxwindow->window );
+ gdk_gc_set_exposures( m_scrollGC, TRUE );
+ }
+
+ gdk_window_copy_area( m_wxwindow->window, m_scrollGC, d_x, d_y,
m_wxwindow->window, s_x, s_y, w, h );
wxRect rect;