From 58dea4b0673c76bdd3ef5624f65fa341b7d5f7b0 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 25 Apr 1999 01:00:34 +0000 Subject: [PATCH] Fixed a layout bug in MyFixed More things done after realization wxListCtrl is grey now. Why? git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2278 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/image/image.cpp | 3 --- samples/toolbar/test.cpp | 4 ++-- samples/toolbar/test.h | 2 +- src/generic/listctrl.cpp | 8 ++++++++ src/gtk/dialog.cpp | 12 ++++++++++-- src/gtk/frame.cpp | 16 +++++++++++++--- src/gtk/notebook.cpp | 2 +- src/gtk/win_gtk.c | 25 ++++++++++++++----------- src/gtk/window.cpp | 11 +++++------ src/gtk1/dialog.cpp | 12 ++++++++++-- src/gtk1/frame.cpp | 16 +++++++++++++--- src/gtk1/notebook.cpp | 2 +- src/gtk1/win_gtk.c | 25 ++++++++++++++----------- src/gtk1/window.cpp | 11 +++++------ 14 files changed, 97 insertions(+), 52 deletions(-) diff --git a/samples/image/image.cpp b/samples/image/image.cpp index 0f1b6cf0aa..2b923cb1fb 100644 --- a/samples/image/image.cpp +++ b/samples/image/image.cpp @@ -144,9 +144,6 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) dc.DrawText( "Loaded image", 30, 10 ); if (my_square && my_square->Ok()) dc.DrawBitmap( *my_square, 30, 30 ); - wxBitmap bm( 1200, 1, 1 ); - dc.DrawBitmap( bm, 10, 10 ); - dc.DrawText( "Drawn directly", 150, 10 ); dc.SetBrush( wxBrush( "orange", wxSOLID ) ); dc.SetPen( *wxWHITE_PEN ); diff --git a/samples/toolbar/test.cpp b/samples/toolbar/test.cpp index 889c478a13..94445a5544 100644 --- a/samples/toolbar/test.cpp +++ b/samples/toolbar/test.cpp @@ -191,7 +191,7 @@ void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) void MyFrame::OnToolLeftClick(wxCommandEvent& event) { wxString str; - str.Printf("Clicked on tool %d", event.GetId()); + str.Printf( _T("Clicked on tool %d"), event.GetId()); SetStatusText(str); } @@ -200,7 +200,7 @@ void MyFrame::OnToolEnter(wxCommandEvent& event) if (event.GetSelection() > -1) { wxString str; - str.Printf("This is tool number %d", event.GetSelection()); + str.Printf(_T("This is tool number %d"), event.GetSelection()); SetStatusText(str); } else diff --git a/samples/toolbar/test.h b/samples/toolbar/test.h index 63da855c34..81ad6c421b 100644 --- a/samples/toolbar/test.h +++ b/samples/toolbar/test.h @@ -22,7 +22,7 @@ class MyTimer : public wxTimer public: MyTimer(wxFrame *frame) { m_frame = frame; } - virtual void Notify() { wxLogStatus(m_frame, "Timer arrived!"); } + virtual void Notify() { wxLogStatus(m_frame, _T("Timer arrived!") ); } private: wxFrame *m_frame; diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 5b7d3480f4..33010c968d 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2335,6 +2335,8 @@ bool wxListCtrl::Create( wxWindow *parent, wxWindowID id, else m_headerWin = (wxListHeaderWindow *) NULL; + SetBackgroundColour( *wxWHITE ); + return ret; } @@ -2795,6 +2797,8 @@ void wxListCtrl::OnIdle( wxIdleEvent &WXUNUSED(event) ) void wxListCtrl::SetBackgroundColour( const wxColour &colour ) { + wxWindow::SetBackgroundColour( colour ); + if (m_mainWin) { m_mainWin->SetBackgroundColour( colour ); @@ -2809,6 +2813,8 @@ void wxListCtrl::SetBackgroundColour( const wxColour &colour ) void wxListCtrl::SetForegroundColour( const wxColour &colour ) { + wxWindow::SetForegroundColour( colour ); + if (m_mainWin) { m_mainWin->SetForegroundColour( colour ); @@ -2823,6 +2829,8 @@ void wxListCtrl::SetForegroundColour( const wxColour &colour ) void wxListCtrl::SetFont( const wxFont &font ) { + wxWindow::SetFont( font ); + if (m_mainWin) { m_mainWin->SetFont( font ); diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 427557a8c6..ee8da61ef8 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -86,11 +86,11 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent // "realize" from m_widget //----------------------------------------------------------------------------- -/* we cannot MWM hints before the widget has been realized, +/* we cannot MWM hints and icons before the widget has been realized, so we do this directly after realization */ static gint -gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win ) +gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) { /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ @@ -121,6 +121,14 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); + /* reset the icon */ + if (win->m_icon != wxNullIcon) + { + wxIcon icon( win->m_icon ); + win->m_icon = wxNullIcon; + win->SetIcon( icon ); + } + return FALSE; } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index edef46b4ee..bf4f14a3c2 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -150,11 +150,11 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC // "realize" from m_widget //----------------------------------------------------------------------------- -/* we cannot MWM hints before the widget has been realized, +/* we cannot MWM hints and icons before the widget has been realized, so we do this directly after realization */ static gint -gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win ) +gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) { /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ @@ -185,6 +185,14 @@ gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); + /* reset the icon */ + if (win->m_icon != wxNullIcon) + { + wxIcon icon( win->m_icon ); + win->m_icon = wxNullIcon; + win->SetIcon( icon ); + } + return FALSE; } @@ -334,7 +342,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, PostCreation(); - /* we cannot set MWM hints before the widget has + /* we cannot set MWM hints and icons 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 ); @@ -927,6 +935,8 @@ void wxFrame::SetIcon( const wxIcon &icon ) m_icon = icon; if (!icon.Ok()) return; + if (!m_widget->window) return; + wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; if (mask) bm = mask->GetBitmap(); diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index eb13d01f46..a7b6bd091d 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -109,7 +109,7 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* (win->m_width == alloc->width) && (win->m_height == alloc->height)) { -// return; + return; } win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index c199d05b9b..11cae307e1 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -319,18 +319,21 @@ gtk_myfixed_realize (GtkWidget *widget) attributes.window_type = GDK_WINDOW_CHILD; #if (GTK_MINOR_VERSION > 0) + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + if (myfixed->shadow_type != GTK_SHADOW_NONE) - { - attributes.x = 2; - attributes.y = 2; - } - else - { - attributes.x = 0; - attributes.y = 0; - } - attributes.width = MAX (1, (gint)widget->allocation.width - attributes.x * 2 ); - attributes.height = MAX (1, (gint)widget->allocation.height - attributes.y * 2 ); + { + attributes.x += 2; + attributes.y += 2; + attributes.width -= 4; + attributes.height -= 4; + } + + if (attributes.width < 2) attributes.width = 2; + if (attributes.height < 2) attributes.height = 2; #else attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 2c6b88d560..86fc0bed68 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1314,14 +1314,14 @@ gtk_window_realized_callback( GtkWidget *widget, wxWindow *win ) if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE )) { wxColour bg( win->m_backgroundColour ); - win->m_backgroundColour = wxNullColour; + win->SetBackgroundColour( wxNullColour ); win->SetBackgroundColour( bg ); } if (win->m_foregroundColour != *wxBLACK) { wxColour fg( win->m_foregroundColour ); - win->m_foregroundColour = wxNullColour; + win->SetForegroundColour( wxNullColour ); win->SetForegroundColour( fg ); } @@ -1489,9 +1489,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) ); m_wxwindow = gtk_myfixed_new(); + gtk_widget_show( m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - + #if (GTK_MINOR_VERSION > 0) GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow); @@ -1589,8 +1590,6 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, 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 ); (m_parent->m_insertCallback)( m_parent, this ); @@ -3095,7 +3094,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, m_vAdjust->page_size = fthumb; } - if (m_wxwindow->window) + if (m_wxwindow) { if (orient == wxHORIZONTAL) gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 427557a8c6..ee8da61ef8 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -86,11 +86,11 @@ static gint gtk_dialog_configure_callback( GtkWidget *WXUNUSED(widget), GdkEvent // "realize" from m_widget //----------------------------------------------------------------------------- -/* we cannot MWM hints before the widget has been realized, +/* we cannot MWM hints and icons before the widget has been realized, so we do this directly after realization */ static gint -gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win ) +gtk_dialog_realized_callback( GtkWidget *widget, wxDialog *win ) { /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ @@ -121,6 +121,14 @@ gtk_dialog_realized_callback( GtkWidget *widget, wxWindow *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); + /* reset the icon */ + if (win->m_icon != wxNullIcon) + { + wxIcon icon( win->m_icon ); + win->m_icon = wxNullIcon; + win->SetIcon( icon ); + } + return FALSE; } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index edef46b4ee..bf4f14a3c2 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -150,11 +150,11 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC // "realize" from m_widget //----------------------------------------------------------------------------- -/* we cannot MWM hints before the widget has been realized, +/* we cannot MWM hints and icons before the widget has been realized, so we do this directly after realization */ static gint -gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win ) +gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win ) { /* all this is for Motif Window Manager "hints" and is supposed to be recognized by other WM as well. not tested. */ @@ -185,6 +185,14 @@ gtk_frame_realized_callback( GtkWidget *widget, wxWindow *win ) else gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); + /* reset the icon */ + if (win->m_icon != wxNullIcon) + { + wxIcon icon( win->m_icon ); + win->m_icon = wxNullIcon; + win->SetIcon( icon ); + } + return FALSE; } @@ -334,7 +342,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, PostCreation(); - /* we cannot set MWM hints before the widget has + /* we cannot set MWM hints and icons 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 ); @@ -927,6 +935,8 @@ void wxFrame::SetIcon( const wxIcon &icon ) m_icon = icon; if (!icon.Ok()) return; + if (!m_widget->window) return; + wxMask *mask = icon.GetMask(); GdkBitmap *bm = (GdkBitmap *) NULL; if (mask) bm = mask->GetBitmap(); diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index eb13d01f46..a7b6bd091d 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -109,7 +109,7 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* (win->m_width == alloc->width) && (win->m_height == alloc->height)) { -// return; + return; } win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index c199d05b9b..11cae307e1 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -319,18 +319,21 @@ gtk_myfixed_realize (GtkWidget *widget) attributes.window_type = GDK_WINDOW_CHILD; #if (GTK_MINOR_VERSION > 0) + attributes.x = widget->allocation.x; + attributes.y = widget->allocation.y; + attributes.width = widget->allocation.width; + attributes.height = widget->allocation.height; + if (myfixed->shadow_type != GTK_SHADOW_NONE) - { - attributes.x = 2; - attributes.y = 2; - } - else - { - attributes.x = 0; - attributes.y = 0; - } - attributes.width = MAX (1, (gint)widget->allocation.width - attributes.x * 2 ); - attributes.height = MAX (1, (gint)widget->allocation.height - attributes.y * 2 ); + { + attributes.x += 2; + attributes.y += 2; + attributes.width -= 4; + attributes.height -= 4; + } + + if (attributes.width < 2) attributes.width = 2; + if (attributes.height < 2) attributes.height = 2; #else attributes.x = widget->allocation.x; attributes.y = widget->allocation.y; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 2c6b88d560..86fc0bed68 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1314,14 +1314,14 @@ gtk_window_realized_callback( GtkWidget *widget, wxWindow *win ) if (win->m_backgroundColour != wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE )) { wxColour bg( win->m_backgroundColour ); - win->m_backgroundColour = wxNullColour; + win->SetBackgroundColour( wxNullColour ); win->SetBackgroundColour( bg ); } if (win->m_foregroundColour != *wxBLACK) { wxColour fg( win->m_foregroundColour ); - win->m_foregroundColour = wxNullColour; + win->SetForegroundColour( wxNullColour ); win->SetForegroundColour( fg ); } @@ -1489,9 +1489,10 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(s_window->vscrollbar) ); m_wxwindow = gtk_myfixed_new(); + gtk_widget_show( m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - + #if (GTK_MINOR_VERSION > 0) GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow); @@ -1589,8 +1590,6 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, 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 ); (m_parent->m_insertCallback)( m_parent, this ); @@ -3095,7 +3094,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, m_vAdjust->page_size = fthumb; } - if (m_wxwindow->window) + if (m_wxwindow) { if (orient == wxHORIZONTAL) gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); -- 2.45.2