]> git.saurik.com Git - wxWidgets.git/commitdiff
Fixed a layout bug in MyFixed
authorRobert Roebling <robert@roebling.de>
Sun, 25 Apr 1999 01:00:34 +0000 (01:00 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 25 Apr 1999 01:00:34 +0000 (01:00 +0000)
  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

14 files changed:
samples/image/image.cpp
samples/toolbar/test.cpp
samples/toolbar/test.h
src/generic/listctrl.cpp
src/gtk/dialog.cpp
src/gtk/frame.cpp
src/gtk/notebook.cpp
src/gtk/win_gtk.c
src/gtk/window.cpp
src/gtk1/dialog.cpp
src/gtk1/frame.cpp
src/gtk1/notebook.cpp
src/gtk1/win_gtk.c
src/gtk1/window.cpp

index 0f1b6cf0aaa98c744bada36be2bc063c7358b31b..2b923cb1fb7921441731da745df1681824d9461c 100644 (file)
@@ -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 );
index 889c478a13418478cbd4b657fb8dcdad13dba792..94445a55440d6ed8540ce23d3b354f2de365780c 100644 (file)
@@ -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
index 63da855c3468e90a868e90fca6146136fca73bb3..81ad6c421b60fde86fbc6287ed13a7826ab3b8e2 100644 (file)
@@ -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;
index 5b7d3480f4fe4cf41ffb879481f8fc3d4a00bcc6..33010c968de626e9a10b4382f8b274f6903b56a4 100644 (file)
@@ -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 );
index 427557a8c6d79e93e2d54e191134a6e4fcfc2cbb..ee8da61ef8e0dafc8793f443e006caf01e699423 100644 (file)
@@ -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;
 }
     
index edef46b4ee8139a755a7ad4f056988dde6396350..bf4f14a3c2030601710d1f93d296f04908bde991 100644 (file)
@@ -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();
index eb13d01f4646f2f0562ee20ba90dacd0bc683fe5..a7b6bd091d9085200ed6668b51ec21c380480636 100644 (file)
@@ -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 );
index c199d05b9b188cb67ad10ef60193262de91cba5e..11cae307e183a1e9d726675055d6c60d4b5ecbd1 100644 (file)
@@ -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;
index 2c6b88d560f54793866b99880f0d73fe5cd147ce..86fc0bed68fc56882d7899bb3c41e18be94b975d 100644 (file)
@@ -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" );
index 427557a8c6d79e93e2d54e191134a6e4fcfc2cbb..ee8da61ef8e0dafc8793f443e006caf01e699423 100644 (file)
@@ -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;
 }
     
index edef46b4ee8139a755a7ad4f056988dde6396350..bf4f14a3c2030601710d1f93d296f04908bde991 100644 (file)
@@ -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();
index eb13d01f4646f2f0562ee20ba90dacd0bc683fe5..a7b6bd091d9085200ed6668b51ec21c380480636 100644 (file)
@@ -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 );
index c199d05b9b188cb67ad10ef60193262de91cba5e..11cae307e183a1e9d726675055d6c60d4b5ecbd1 100644 (file)
@@ -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;
index 2c6b88d560f54793866b99880f0d73fe5cd147ce..86fc0bed68fc56882d7899bb3c41e18be94b975d 100644 (file)
@@ -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" );