panel = new wxPanel(m_notebook);
m_choice = new wxChoice( panel, ID_CHOICE, wxPoint(10,10), wxSize(120,-1), 5, choices );
+ m_choice->SetBackgroundColour( "red" );
(void)new wxButton( panel, ID_CHOICE_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_CHOICE_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_CHOICE_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
PostCreation();
- gtk_widget_realize( m_widgetLabel );
- gtk_widget_realize( m_widgetCheckbox );
-
SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
SetFont( parent->GetFont() );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() );
gtk_menu_append( GTK_MENU(menu), item );
- gtk_widget_realize( item );
- gtk_widget_realize( GTK_BIN(item)->child );
-
gtk_widget_show( item );
gtk_signal_connect( GTK_OBJECT( item ), "activate",
gtk_menu_append( GTK_MENU(menu), menu_item );
- gtk_widget_realize( menu_item );
- gtk_widget_realize( GTK_BIN(menu_item)->child );
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( menu_item );
+ gtk_widget_realize( GTK_BIN(menu_item)->child );
- if (m_widgetStyle) ApplyWidgetStyle();
+ if (m_widgetStyle) ApplyWidgetStyle();
+ }
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
gtk_container_add( GTK_CONTAINER(list), list_item );
- gtk_widget_realize( list_item );
- gtk_widget_realize( GTK_BIN(list_item)->child );
-
gtk_widget_show( list_item );
gtk_signal_connect( GTK_OBJECT(list_item), "select",
if (!value.IsNull()) SetValue( value );
- gtk_widget_realize( GTK_COMBO(m_widget)->list );
- gtk_widget_realize( GTK_COMBO(m_widget)->entry );
- gtk_widget_realize( GTK_COMBO(m_widget)->button );
-
if (style & wxCB_READONLY)
gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(m_widget)->entry ), FALSE );
gtk_container_add( GTK_CONTAINER(list), list_item );
- if (m_widgetStyle) ApplyWidgetStyle();
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( list_item );
+ gtk_widget_realize( GTK_BIN(list_item)->child );
+
+ if (m_widgetStyle) ApplyWidgetStyle();
+ }
gtk_widget_show( list_item );
}
long *descent, long *externalLeading,
wxFont *theFont, bool WXUNUSED(use16) )
{
- wxCHECK_RET( Ok(), _T("invalid window dc") );
-
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
long wxWindowDC::GetCharWidth()
{
- wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-
GdkFont *font = m_font.GetInternalFont( m_scaleY );
return long(gdk_string_width( font, "H" ) / m_scaleX);
}
long wxWindowDC::GetCharHeight()
{
- wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-
GdkFont *font = m_font.GetInternalFont( m_scaleY );
return long((font->ascent + font->descent) / m_scaleY);
}
void wxWindowDC::SetFont( const wxFont &font )
{
- wxCHECK_RET( Ok(), _T("invalid window dc") );
-
m_font = font;
}
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized,
+ so we do this directly after realization */
+
+static gint
+gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+ /* all this is for Motif Window Manager "hints" and is supposed to be
+ recognized by other WM as well. not tested. */
+ long decor = (long) GDK_DECOR_ALL;
+ long func = (long) GDK_FUNC_ALL;
+
+ if ((win->m_windowStyle & wxCAPTION) == 0)
+ decor |= GDK_DECOR_TITLE;
+/* if ((win->m_windowStyle & wxMINIMIZE) == 0)
+ func |= GDK_FUNC_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+ func |= GDK_FUNC_MAXIMIZE; */
+ if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+ decor |= GDK_DECOR_MENU;
+ if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MAXIMIZE;
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ func |= GDK_FUNC_RESIZE;
+
+ gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+
+ /* GTK's shrinking/growing policy */
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ else
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// wxDialog
//-----------------------------------------------------------------------------
PostCreation();
- gtk_widget_realize( m_widget );
-
- /* all this is for Motif Window Manager "hints" and is supposed to be
- recognized by other WM as well. not tested. */
- long decor = (long) GDK_DECOR_ALL;
- long func = (long) GDK_FUNC_ALL;
+ /* we cannot set MWM hints before the widget has
+ been realized, so we do this directly after realization */
+ gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+ GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
- if ((m_windowStyle & wxCAPTION) == 0)
- decor |= GDK_DECOR_TITLE;
-/* if ((m_windowStyle & wxMINIMIZE) == 0)
- func |= GDK_FUNC_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE) == 0)
- func |= GDK_FUNC_MAXIMIZE; */
- if ((m_windowStyle & wxSYSTEM_MENU) == 0)
- decor |= GDK_DECOR_MENU;
- if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MAXIMIZE;
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- func |= GDK_FUNC_RESIZE;
-
- gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-
- /* GTK's shrinking/growing policy */
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
- else
- gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
+ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized,
+ so we do this directly after realization */
+
+static gint
+gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+ /* all this is for Motif Window Manager "hints" and is supposed to be
+ recognized by other WM as well. not tested. */
+ long decor = (long) GDK_DECOR_ALL;
+ long func = (long) GDK_FUNC_ALL;
+
+ if ((win->m_windowStyle & wxCAPTION) == 0)
+ decor |= GDK_DECOR_TITLE;
+/* if ((win->m_windowStyle & wxMINIMIZE) == 0)
+ func |= GDK_FUNC_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+ func |= GDK_FUNC_MAXIMIZE; */
+ if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+ decor |= GDK_DECOR_MENU;
+ if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MAXIMIZE;
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ func |= GDK_FUNC_RESIZE;
+
+ gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+
+ /* GTK's shrinking/growing policy */
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ else
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// InsertChild for wxFrame
//-----------------------------------------------------------------------------
gtk_widget_show( m_mainWidget );
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
- gtk_widget_realize( m_mainWidget );
/* m_wxwindow only represents the client area without toolbar and menubar */
m_wxwindow = gtk_myfixed_new();
PostCreation();
- gtk_widget_realize( m_widget );
+ /* we cannot set MWM hints before the widget has
+ been realized, so we do this directly after realization */
+ gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+ GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
- /* all this is for Motif Window Manager "hints" and is supposed to be
- recognized by other WM as well. not tested. */
- long decor = (long) GDK_DECOR_ALL;
- long func = (long) GDK_FUNC_ALL;
-
- if ((m_windowStyle & wxCAPTION) == 0)
- decor |= GDK_DECOR_TITLE;
-/* if ((m_windowStyle & wxMINIMIZE) == 0)
- func |= GDK_FUNC_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE) == 0)
- func |= GDK_FUNC_MAXIMIZE; */
- if ((m_windowStyle & wxSYSTEM_MENU) == 0)
- decor |= GDK_DECOR_MENU;
- if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MAXIMIZE;
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- func |= GDK_FUNC_RESIZE;
-
- gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-
- /* GTK's shrinking/growing policy */
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
- else
- gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
PostCreation();
- gtk_widget_realize( GTK_WIDGET(m_list) );
-
SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
SetFont( parent->GetFont() );
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
- if (m_widgetStyle) ApplyWidgetStyle();
-
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
ConnectWidget( list_item );
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( list_item );
+ gtk_widget_realize( GTK_BIN(list_item)->child );
+
+ if (m_widgetStyle) ApplyWidgetStyle();
+
#if wxUSE_DRAG_AND_DROP
#ifndef NEW_GTK_DND_CODE
- if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
+ if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
#endif
#endif
#if wxUSE_TOOLTIPS
- if (m_toolTip) m_toolTip->Apply( this );
+ if (m_toolTip) m_toolTip->Apply( this );
#endif
+ }
}
void wxListBox::Append( const wxString &item )
(win->m_width == alloc->width) &&
(win->m_height == alloc->height))
{
- return;
+// return;
}
-
+
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
if (win->GetAutoLayout()) win->Layout();
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot set colours, fonts and cursors before the widget has
+ been realized, so we do this directly after realization */
+
+static gint
+gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+ if (win->m_font != *wxSWISS_FONT)
+ {
+ wxFont font( win->m_font );
+ win->m_font = wxNullFont;
+ win->SetFont( font );
+ }
+
+ if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
+ {
+ wxColour bg( win->m_backgroundColour );
+ win->m_backgroundColour = wxNullColour;
+ win->SetBackgroundColour( bg );
+ }
+
+ if (win->m_foregroundColour != *wxBLACK)
+ {
+ wxColour fg( win->m_foregroundColour );
+ win->m_foregroundColour = wxNullColour;
+ win->SetForegroundColour( fg );
+ }
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
ConnectWidget( GetConnectWidget() );
- /* we force the creation of wxFrame and wxDialog in the respective code */
- if (m_parent) gtk_widget_realize( m_widget );
-
- if (m_wxwindow) gtk_widget_realize( m_wxwindow );
-
- SetCursor( *wxSTANDARD_CURSOR );
-
+/* we cannot set colours, fonts and cursors before the widget has
+ been realized, so we do this directly after realization */
+
+ gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+ GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
+
m_hasVMT = TRUE;
}
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
if (m_widget) gdk_window_raise( m_widget->window );
}
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
if (m_widget) gdk_window_lower( m_widget->window );
}
*m_cursor = *wxSTANDARD_CURSOR;
}
- if ((m_widget) && (m_widget->window))
- gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
+ if (!m_widget->window) return;
+
+ gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
if ((m_wxwindow) && (m_wxwindow->window))
gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() );
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
{
wxCHECK_RET( m_widget != NULL, _T("invalid window") );
+ if (!m_widget->window) return;
+
if (m_wxwindow && m_wxwindow->window)
{
gdk_window_clear( m_wxwindow->window );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
+ if (!m_widget->window) return;
+
if (m_wxwindow && m_wxwindow->window)
{
/* wxMSW doesn't clear the window here. I don't do that
m_foregroundColour = colour;
if (!m_foregroundColour.Ok()) return;
+ if (!m_widget->window) return;
+
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
if (sysbg.Red() == colour.Red() &&
sysbg.Green() == colour.Green() &&
wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
+ if (!m_widget->window) return;
+
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
gdk_pointer_grab( connect_widget->window, FALSE,
wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
+ if (!m_widget->window) return;
+
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
PostCreation();
- gtk_widget_realize( m_widgetLabel );
- gtk_widget_realize( m_widgetCheckbox );
-
SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
SetFont( parent->GetFont() );
GtkWidget *item = gtk_menu_item_new_with_label( choices[i].mbc_str() );
gtk_menu_append( GTK_MENU(menu), item );
- gtk_widget_realize( item );
- gtk_widget_realize( GTK_BIN(item)->child );
-
gtk_widget_show( item );
gtk_signal_connect( GTK_OBJECT( item ), "activate",
gtk_menu_append( GTK_MENU(menu), menu_item );
- gtk_widget_realize( menu_item );
- gtk_widget_realize( GTK_BIN(menu_item)->child );
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( menu_item );
+ gtk_widget_realize( GTK_BIN(menu_item)->child );
- if (m_widgetStyle) ApplyWidgetStyle();
+ if (m_widgetStyle) ApplyWidgetStyle();
+ }
gtk_signal_connect( GTK_OBJECT( menu_item ), "activate",
GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this );
gtk_container_add( GTK_CONTAINER(list), list_item );
- gtk_widget_realize( list_item );
- gtk_widget_realize( GTK_BIN(list_item)->child );
-
gtk_widget_show( list_item );
gtk_signal_connect( GTK_OBJECT(list_item), "select",
if (!value.IsNull()) SetValue( value );
- gtk_widget_realize( GTK_COMBO(m_widget)->list );
- gtk_widget_realize( GTK_COMBO(m_widget)->entry );
- gtk_widget_realize( GTK_COMBO(m_widget)->button );
-
if (style & wxCB_READONLY)
gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(m_widget)->entry ), FALSE );
gtk_container_add( GTK_CONTAINER(list), list_item );
- if (m_widgetStyle) ApplyWidgetStyle();
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( list_item );
+ gtk_widget_realize( GTK_BIN(list_item)->child );
+
+ if (m_widgetStyle) ApplyWidgetStyle();
+ }
gtk_widget_show( list_item );
}
long *descent, long *externalLeading,
wxFont *theFont, bool WXUNUSED(use16) )
{
- wxCHECK_RET( Ok(), _T("invalid window dc") );
-
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
long wxWindowDC::GetCharWidth()
{
- wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-
GdkFont *font = m_font.GetInternalFont( m_scaleY );
return long(gdk_string_width( font, "H" ) / m_scaleX);
}
long wxWindowDC::GetCharHeight()
{
- wxCHECK_MSG( Ok(), 0, _T("invalid window dc") );
-
GdkFont *font = m_font.GetInternalFont( m_scaleY );
return long((font->ascent + font->descent) / m_scaleY);
}
void wxWindowDC::SetFont( const wxFont &font )
{
- wxCHECK_RET( Ok(), _T("invalid window dc") );
-
m_font = font;
}
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized,
+ so we do this directly after realization */
+
+static gint
+gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+ /* all this is for Motif Window Manager "hints" and is supposed to be
+ recognized by other WM as well. not tested. */
+ long decor = (long) GDK_DECOR_ALL;
+ long func = (long) GDK_FUNC_ALL;
+
+ if ((win->m_windowStyle & wxCAPTION) == 0)
+ decor |= GDK_DECOR_TITLE;
+/* if ((win->m_windowStyle & wxMINIMIZE) == 0)
+ func |= GDK_FUNC_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+ func |= GDK_FUNC_MAXIMIZE; */
+ if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+ decor |= GDK_DECOR_MENU;
+ if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MAXIMIZE;
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ func |= GDK_FUNC_RESIZE;
+
+ gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+
+ /* GTK's shrinking/growing policy */
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ else
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// wxDialog
//-----------------------------------------------------------------------------
PostCreation();
- gtk_widget_realize( m_widget );
-
- /* all this is for Motif Window Manager "hints" and is supposed to be
- recognized by other WM as well. not tested. */
- long decor = (long) GDK_DECOR_ALL;
- long func = (long) GDK_FUNC_ALL;
+ /* we cannot set MWM hints before the widget has
+ been realized, so we do this directly after realization */
+ gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+ GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this );
- if ((m_windowStyle & wxCAPTION) == 0)
- decor |= GDK_DECOR_TITLE;
-/* if ((m_windowStyle & wxMINIMIZE) == 0)
- func |= GDK_FUNC_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE) == 0)
- func |= GDK_FUNC_MAXIMIZE; */
- if ((m_windowStyle & wxSYSTEM_MENU) == 0)
- decor |= GDK_DECOR_MENU;
- if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MAXIMIZE;
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- func |= GDK_FUNC_RESIZE;
-
- gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-
- /* GTK's shrinking/growing policy */
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
- else
- gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
+ /* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot MWM hints before the widget has been realized,
+ so we do this directly after realization */
+
+static gint
+gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+ /* all this is for Motif Window Manager "hints" and is supposed to be
+ recognized by other WM as well. not tested. */
+ long decor = (long) GDK_DECOR_ALL;
+ long func = (long) GDK_FUNC_ALL;
+
+ if ((win->m_windowStyle & wxCAPTION) == 0)
+ decor |= GDK_DECOR_TITLE;
+/* if ((win->m_windowStyle & wxMINIMIZE) == 0)
+ func |= GDK_FUNC_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE) == 0)
+ func |= GDK_FUNC_MAXIMIZE; */
+ if ((win->m_windowStyle & wxSYSTEM_MENU) == 0)
+ decor |= GDK_DECOR_MENU;
+ if ((win->m_windowStyle & wxMINIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MINIMIZE;
+ if ((win->m_windowStyle & wxMAXIMIZE_BOX) == 0)
+ decor |= GDK_DECOR_MAXIMIZE;
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ func |= GDK_FUNC_RESIZE;
+
+ gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor);
+ gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func);
+
+ /* GTK's shrinking/growing policy */
+ if ((win->m_windowStyle & wxRESIZE_BORDER) == 0)
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1);
+ else
+ gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1);
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// InsertChild for wxFrame
//-----------------------------------------------------------------------------
gtk_widget_show( m_mainWidget );
GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget );
- gtk_widget_realize( m_mainWidget );
/* m_wxwindow only represents the client area without toolbar and menubar */
m_wxwindow = gtk_myfixed_new();
PostCreation();
- gtk_widget_realize( m_widget );
+ /* we cannot set MWM hints before the widget has
+ been realized, so we do this directly after realization */
+ gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+ GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this );
- /* all this is for Motif Window Manager "hints" and is supposed to be
- recognized by other WM as well. not tested. */
- long decor = (long) GDK_DECOR_ALL;
- long func = (long) GDK_FUNC_ALL;
-
- if ((m_windowStyle & wxCAPTION) == 0)
- decor |= GDK_DECOR_TITLE;
-/* if ((m_windowStyle & wxMINIMIZE) == 0)
- func |= GDK_FUNC_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE) == 0)
- func |= GDK_FUNC_MAXIMIZE; */
- if ((m_windowStyle & wxSYSTEM_MENU) == 0)
- decor |= GDK_DECOR_MENU;
- if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MINIMIZE;
- if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
- decor |= GDK_DECOR_MAXIMIZE;
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- func |= GDK_FUNC_RESIZE;
-
- gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
- gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
-
- /* GTK's shrinking/growing policy */
- if ((m_windowStyle & wxRESIZE_BORDER) == 0)
- gtk_window_set_policy(GTK_WINDOW(m_widget), 0, 0, 1);
- else
- gtk_window_set_policy(GTK_WINDOW(m_widget), 1, 1, 1);
-
/* the user resized the frame by dragging etc. */
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
PostCreation();
- gtk_widget_realize( GTK_WIDGET(m_list) );
-
SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
SetFont( parent->GetFont() );
gtk_signal_connect( GTK_OBJECT(list_item), "deselect",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
- if (m_widgetStyle) ApplyWidgetStyle();
-
gtk_signal_connect( GTK_OBJECT(list_item),
"button_press_event",
(GtkSignalFunc)gtk_listbox_button_press_callback,
ConnectWidget( list_item );
+ if (GTK_WIDGET_REALIZED(m_widget))
+ {
+ gtk_widget_realize( list_item );
+ gtk_widget_realize( GTK_BIN(list_item)->child );
+
+ if (m_widgetStyle) ApplyWidgetStyle();
+
#if wxUSE_DRAG_AND_DROP
#ifndef NEW_GTK_DND_CODE
- if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
+ if (m_dropTarget) m_dropTarget->RegisterWidget( list_item );
#endif
#endif
#if wxUSE_TOOLTIPS
- if (m_toolTip) m_toolTip->Apply( this );
+ if (m_toolTip) m_toolTip->Apply( this );
#endif
+ }
}
void wxListBox::Append( const wxString &item )
(win->m_width == alloc->width) &&
(win->m_height == alloc->height))
{
- return;
+// return;
}
-
+
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
if (win->GetAutoLayout()) win->Layout();
return FALSE;
}
+//-----------------------------------------------------------------------------
+// "realize" from m_widget
+//-----------------------------------------------------------------------------
+
+/* we cannot set colours, fonts and cursors before the widget has
+ been realized, so we do this directly after realization */
+
+static gint
+gtk_window_realized_callback( GtkWidget *widget, wxWindow *win )
+{
+ if (win->m_font != *wxSWISS_FONT)
+ {
+ wxFont font( win->m_font );
+ win->m_font = wxNullFont;
+ win->SetFont( font );
+ }
+
+ if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ))
+ {
+ wxColour bg( win->m_backgroundColour );
+ win->m_backgroundColour = wxNullColour;
+ win->SetBackgroundColour( bg );
+ }
+
+ if (win->m_foregroundColour != *wxBLACK)
+ {
+ wxColour fg( win->m_foregroundColour );
+ win->m_foregroundColour = wxNullColour;
+ win->SetForegroundColour( fg );
+ }
+
+ return FALSE;
+}
+
//-----------------------------------------------------------------------------
// InsertChild for wxWindow.
//-----------------------------------------------------------------------------
ConnectWidget( GetConnectWidget() );
- /* we force the creation of wxFrame and wxDialog in the respective code */
- if (m_parent) gtk_widget_realize( m_widget );
-
- if (m_wxwindow) gtk_widget_realize( m_wxwindow );
-
- SetCursor( *wxSTANDARD_CURSOR );
-
+/* we cannot set colours, fonts and cursors before the widget has
+ been realized, so we do this directly after realization */
+
+ gtk_signal_connect( GTK_OBJECT(m_widget), "realize",
+ GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this );
+
m_hasVMT = TRUE;
}
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
if (m_widget) gdk_window_raise( m_widget->window );
}
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
if (m_widget) gdk_window_lower( m_widget->window );
}
*m_cursor = *wxSTANDARD_CURSOR;
}
- if ((m_widget) && (m_widget->window))
- gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
+ if (!m_widget->window) return;
+
+ gdk_window_set_cursor( m_widget->window, m_cursor->GetCursor() );
if ((m_wxwindow) && (m_wxwindow->window))
gdk_window_set_cursor( m_wxwindow->window, m_cursor->GetCursor() );
{
wxCHECK_RET( (m_widget != NULL), _T("invalid window") );
+ if (!m_widget->window) return;
+
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
{
wxCHECK_RET( m_widget != NULL, _T("invalid window") );
+ if (!m_widget->window) return;
+
if (m_wxwindow && m_wxwindow->window)
{
gdk_window_clear( m_wxwindow->window );
m_backgroundColour = colour;
if (!m_backgroundColour.Ok()) return;
+ if (!m_widget->window) return;
+
if (m_wxwindow && m_wxwindow->window)
{
/* wxMSW doesn't clear the window here. I don't do that
m_foregroundColour = colour;
if (!m_foregroundColour.Ok()) return;
+ if (!m_widget->window) return;
+
wxColour sysbg = wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE );
if (sysbg.Red() == colour.Red() &&
sysbg.Green() == colour.Green() &&
wxCHECK_RET( g_capturing == FALSE, _T("CaptureMouse called twice") );
+ if (!m_widget->window) return;
+
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
gdk_pointer_grab( connect_widget->window, FALSE,
wxCHECK_RET( g_capturing == TRUE, _T("ReleaseMouse called twice") );
+ if (!m_widget->window) return;
+
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );