]> git.saurik.com Git - wxWidgets.git/commitdiff
SetBackground for ListBox and others
authorRobert Roebling <robert@roebling.de>
Wed, 21 Oct 1998 22:21:09 +0000 (22:21 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 21 Oct 1998 22:21:09 +0000 (22:21 +0000)
  Removed the old and famous wxSplitter bug

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@896 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

19 files changed:
include/wx/gtk/combobox.h
include/wx/gtk/dcclient.h
include/wx/gtk/window.h
include/wx/gtk1/combobox.h
include/wx/gtk1/dcclient.h
include/wx/gtk1/window.h
samples/controls/controls.cpp
src/gtk/combobox.cpp
src/gtk/dcclient.cpp
src/gtk/dcmemory.cpp
src/gtk/listbox.cpp
src/gtk/textctrl.cpp
src/gtk/window.cpp
src/gtk1/combobox.cpp
src/gtk1/dcclient.cpp
src/gtk1/dcmemory.cpp
src/gtk1/listbox.cpp
src/gtk1/textctrl.cpp
src/gtk1/window.cpp

index c7d7b7064bcd59f92a585d3062e4bcd60aed18bf..12c632e48020505a1d4f4a01329c8b0934777214 100644 (file)
@@ -95,6 +95,7 @@ class wxComboBox: public wxControl
   
   void SetFont( const wxFont &font );
   void OnSize( wxSizeEvent &event );
+  void SetBackgroundColour( const wxColour &colour );
   
   // implementation
 
index d9c316aa34a7550dc9f561719bde9ef2f8f0271e..be532ec577b65224e72ae2187f21f91ea37160a5 100644 (file)
@@ -100,7 +100,7 @@ class wxPaintDC: public wxDC
     GdkGC        *m_textGC;
     GdkGC        *m_bgGC;
     GdkColormap  *m_cmap;
-    bool          m_isDrawable;
+    bool          m_isMemDC;
     
     void SetUpDC(void);
     GdkWindow *GetWindow(void);
index e7438063b8e15a68e1af26cc82393691b9979723..50556991dcef5719f02f0dfd7010dde250a64eb7 100644 (file)
@@ -236,6 +236,8 @@ public:
   void ConnectWidget( GtkWidget *widget );
   void ConnectDnDWidget( GtkWidget *widget );
   void DisconnectDnDWidget( GtkWidget *widget );
+  
+  void SetBackgroundColourHelper( GdkWindow *window );
 
   void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
     const wxSize &size, long style, const wxString &name );
@@ -315,11 +317,6 @@ public:
   virtual void GetClientSizeConstraint(int *w, int *h) const ;
   virtual void GetPositionConstraint(int *x, int *y) const ;
 
-protected:
-  // set background colour for arbitrary window (useful because some windows
-  // don't work with m_wxwindow, e.g. wxTextCtrl)
-  void SetBackgroundColourHelper( const wxColour &colour, GdkWindow *window );
-
 private:
   DECLARE_EVENT_TABLE()
 };
index c7d7b7064bcd59f92a585d3062e4bcd60aed18bf..12c632e48020505a1d4f4a01329c8b0934777214 100644 (file)
@@ -95,6 +95,7 @@ class wxComboBox: public wxControl
   
   void SetFont( const wxFont &font );
   void OnSize( wxSizeEvent &event );
+  void SetBackgroundColour( const wxColour &colour );
   
   // implementation
 
index d9c316aa34a7550dc9f561719bde9ef2f8f0271e..be532ec577b65224e72ae2187f21f91ea37160a5 100644 (file)
@@ -100,7 +100,7 @@ class wxPaintDC: public wxDC
     GdkGC        *m_textGC;
     GdkGC        *m_bgGC;
     GdkColormap  *m_cmap;
-    bool          m_isDrawable;
+    bool          m_isMemDC;
     
     void SetUpDC(void);
     GdkWindow *GetWindow(void);
index e7438063b8e15a68e1af26cc82393691b9979723..50556991dcef5719f02f0dfd7010dde250a64eb7 100644 (file)
@@ -236,6 +236,8 @@ public:
   void ConnectWidget( GtkWidget *widget );
   void ConnectDnDWidget( GtkWidget *widget );
   void DisconnectDnDWidget( GtkWidget *widget );
+  
+  void SetBackgroundColourHelper( GdkWindow *window );
 
   void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
     const wxSize &size, long style, const wxString &name );
@@ -315,11 +317,6 @@ public:
   virtual void GetClientSizeConstraint(int *w, int *h) const ;
   virtual void GetPositionConstraint(int *x, int *y) const ;
 
-protected:
-  // set background colour for arbitrary window (useful because some windows
-  // don't work with m_wxwindow, e.g. wxTextCtrl)
-  void SetBackgroundColourHelper( const wxColour &colour, GdkWindow *window );
-
 private:
   DECLARE_EVENT_TABLE()
 };
index c08ec582d9d71a04d4257238bc722eb13edf5e89..82d5215fcd92b2e736f1b7df313475d2bb0ec5b4 100644 (file)
 
 #ifdef __WXGTK__
 #include "mondrian.xpm"
+#include "icons/choice.xpm"
+#include "icons/combo.xpm"
+#include "icons/list.xpm"
+#include "icons/radio.xpm"
+#include "icons/text.xpm"
 #endif
 
 //----------------------------------------------------------------------
@@ -227,6 +232,8 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
     Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Max
   };
   
+  // fill the image list
+#ifdef __WXMSW__
   const char *aIconNames[] =
   {
     "list.xpm", "choice.xpm", "combo.xpm", "text.xpm", "radio.xpm"
@@ -234,15 +241,22 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
   
   wxASSERT( WXSIZEOF(aIconNames) == Image_Max ); // keep in sync
 
-  // TODO should find the dir from path to program
-  wxString strIconDir = "icons/"; 
-
-  // fill the image list
+  wxString strIconDir = "icons/";
+  
   wxImageList *imagelist = new wxImageList(32, 32);
   for ( size_t n = 0; n < Image_Max; n++ ) 
   {
     imagelist->Add(wxBitmap(strIconDir + aIconNames[n]));
   }
+#else
+  wxImageList *imagelist = new wxImageList(32, 32);
+  
+  imagelist-> Add( wxBitmap( list_xpm ));
+  imagelist-> Add( wxBitmap( choice_xpm ));
+  imagelist-> Add( wxBitmap( combo_xpm ));
+  imagelist-> Add( wxBitmap( text_xpm ));
+  imagelist-> Add( wxBitmap( radio_xpm ));
+#endif
 
   m_notebook->SetImageList(imagelist);
 
index 9db6be50b81f11be78716737abbaad44208478f9..efe78a6f3fd71b09532178028072839355bfc3a0 100644 (file)
@@ -130,6 +130,12 @@ void wxComboBox::Append( const wxString &item, char *clientData )
         gtk_widget_get_style( m_widget ) ) ); 
   }
   
+  if (m_backgroundColour != wxNullColour)
+  {
+    GtkBin *bin = GTK_BIN( list_item );
+    SetBackgroundColourHelper( bin->child->window );
+  }
+  
   gtk_signal_connect( GTK_OBJECT(list_item), "select", 
     GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
   
@@ -426,3 +432,18 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
            (window == GTK_COMBO(m_widget)->button->window ) );
 }
 
+void wxComboBox::SetBackgroundColour( const wxColour &colour )
+{
+  wxWindow::SetBackgroundColour( colour );
+  
+  GtkWidget *list = GTK_COMBO(m_widget)->list;
+  
+  GList *child = GTK_LIST(list)->children;
+  while (child)
+  {
+    GtkBin *bin = (GtkBin*) child->data;
+    SetBackgroundColourHelper( bin->child->window );
+    child = child->next;
+  }
+}
+
index 84d0cebf07aecfdb9e36265829d18f9ff460f9f2..17cd0074333090febd5463b143a92abecc0e7db9 100644 (file)
@@ -92,6 +92,7 @@ wxPaintDC::wxPaintDC(void)
   m_textGC = (GdkGC *) NULL;
   m_bgGC = (GdkGC *) NULL;
   m_cmap = (GdkColormap *) NULL;
+  m_isMemDC = FALSE;
 }
 
 wxPaintDC::wxPaintDC( wxWindow *window )
@@ -112,7 +113,7 @@ wxPaintDC::wxPaintDC( wxWindow *window )
   else
     m_cmap = gtk_widget_get_colormap( window->m_widget );
     
-  m_isDrawable = TRUE;
+  m_isMemDC = FALSE;
         
   SetUpDC();
 }
@@ -137,9 +138,7 @@ void wxPaintDC::DrawLine( long x1, long y1, long x2, long y2 )
 {
   if (!Ok()) return;
   
-  // FIXME: is this right? Causes a segfault on my system and doesn't
-  // seem right: wxPaintDC does not inherit from wxMemoryDC
-  //   if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() != wxTRANSPARENT)
   {
@@ -152,9 +151,7 @@ void wxPaintDC::CrossHair( long x, long y )
 {
   if (!Ok()) return;
   
-  // FIXME: is this right? Causes a segfault on my system and doesn't
-  // seem right: wxPaintDC does not inherit from wxMemoryDC
-  // if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() != wxTRANSPARENT)
   {
@@ -174,7 +171,7 @@ void wxPaintDC::DrawArc( long x1, long y1, long x2, long y2, double xc, double y
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx1 = XLOG2DEV(x1); 
   long yy1 = YLOG2DEV(y1);
@@ -224,7 +221,7 @@ void wxPaintDC::DrawEllipticArc( long x, long y, long width, long height, double
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx = XLOG2DEV(x);    
   long yy = YLOG2DEV(y);
@@ -248,7 +245,7 @@ void wxPaintDC::DrawPoint( long x, long y )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() != wxTRANSPARENT)
     gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
@@ -258,7 +255,7 @@ void wxPaintDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() == wxTRANSPARENT) return;
   
@@ -276,7 +273,7 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() == wxTRANSPARENT) return;
   
@@ -298,7 +295,7 @@ void wxPaintDC::DrawPolygon( int n, wxPoint points[], long xoffset, long yoffset
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
    if (!n) return;    // Nothing to draw
    GdkPoint *gdkpoints = new GdkPoint[n+1];
@@ -325,7 +322,7 @@ void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, long yoffset, int WXUN
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
    int n = lines->Number();
    GdkPoint *gdkpoints = new GdkPoint[n];
@@ -359,7 +356,7 @@ void wxPaintDC::DrawRectangle( long x, long y, long width, long height )
 {
   if (!Ok()) return;
 
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx = XLOG2DEV(x);
   long yy = YLOG2DEV(y);
@@ -384,7 +381,7 @@ void wxPaintDC::DrawRoundedRectangle( long x, long y, long width, long height, d
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
   
@@ -451,7 +448,7 @@ void wxPaintDC::DrawEllipse( long x, long y, long width, long height )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx = XLOG2DEV(x);    
   long yy = YLOG2DEV(y);
@@ -480,7 +477,7 @@ void wxPaintDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask )
   
   if (!icon.Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   int xx = XLOG2DEV(x);
   int yy = YLOG2DEV(y);
@@ -509,10 +506,9 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
 {
   if (!Ok()) return FALSE;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
-  // CMB 20/5/98: add blitting of bitmaps
-  if (source->IsKindOf(CLASSINFO(wxMemoryDC)))
+  if (m_isMemDC)
   {
     wxMemoryDC* srcDC = (wxMemoryDC*)source;
     GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
@@ -551,7 +547,7 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us
 {
   if (!Ok()) return;
 
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   GdkFont *font = m_font.GetInternalFont( m_scaleY );
 
@@ -622,9 +618,9 @@ void wxPaintDC::Clear(void)
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
-  if (m_isDrawable)
+  if (!m_isMemDC)
   {
     gdk_window_clear( m_window );
   }
index 84a6e144e70bfb92379361cd8c31a3c86a0b57f2..aa8ab7a2696159c8aa3f38a2ffb2a95433213c3b 100644 (file)
@@ -66,7 +66,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
     
     SetUpDC();
     
-    m_isDrawable = FALSE;
+    m_isMemDC = TRUE;
   }
   else
   {
index b8c301884b36de3978e6a940f036c0b2c4d8d4e1..7742d96c55a2113e0a426424f65467ab5cff7d8f 100644 (file)
@@ -136,6 +136,8 @@ void wxListBox::Append( const wxString &item )
 
 void wxListBox::Append( const wxString &item, char *clientData )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   GtkWidget *list_item = gtk_list_item_new_with_label( item );
 
   if (m_hasOwnStyle)
@@ -143,9 +145,13 @@ void wxListBox::Append( const wxString &item, char *clientData )
     GtkBin *bin = GTK_BIN( list_item );
     gtk_widget_set_style( bin->child,
       gtk_style_ref(
-        gtk_widget_get_style( m_widget ) ) );
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
+       
+    gtk_widget_set_style( GTK_WIDGET(bin),
+      gtk_style_ref(
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
   }
-
+  
   gtk_signal_connect( GTK_OBJECT(list_item), "select",
     GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
 
@@ -162,11 +168,12 @@ void wxListBox::Append( const wxString &item, char *clientData )
   ConnectWidget( list_item );
 
   ConnectDnDWidget( list_item );
-
 }
 
 void wxListBox::Clear(void)
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   gtk_list_clear_items( m_list, 0, Number() );
 
   m_clientData.Clear();
@@ -174,6 +181,8 @@ void wxListBox::Clear(void)
 
 void wxListBox::Delete( int n )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   GList *child = g_list_nth( m_list->children, n );
 
   if (!child)
@@ -197,11 +206,15 @@ void wxListBox::Delete( int n )
 
 void wxListBox::Deselect( int n )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   gtk_list_unselect_item( m_list, n );
 }
 
 int wxListBox::FindString( const wxString &item ) const
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   int count = 0;
   while (child)
@@ -222,6 +235,8 @@ int wxListBox::FindString( const wxString &item ) const
 
 char *wxListBox::GetClientData( int n ) const
 {
+  wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid list ctrl" );
+  
   wxNode *node = m_clientData.Nth( n );
   if (node) return ((char*)node->Data());
 
@@ -231,6 +246,8 @@ char *wxListBox::GetClientData( int n ) const
 
 int wxListBox::GetSelection(void) const
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   int count = 0;
   while (child)
@@ -244,6 +261,8 @@ int wxListBox::GetSelection(void) const
 
 int wxListBox::GetSelections(wxArrayInt& aSelections) const
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   // get the number of selected items first
   GList *child = m_list->children;
   int count = 0;
@@ -271,6 +290,8 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
 
 wxString wxListBox::GetString( int n ) const
 {
+  wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
+  
   GList *child = g_list_nth( m_list->children, n );
   if (child)
   {
@@ -284,6 +305,8 @@ wxString wxListBox::GetString( int n ) const
 
 wxString wxListBox::GetStringSelection(void) const
 {
+  wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
+  
   GList *selection = m_list->selection;
   if (selection)
   {
@@ -297,6 +320,8 @@ wxString wxListBox::GetStringSelection(void) const
 
 int wxListBox::Number(void)
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   int count = 0;
   while (child) { count++; child = child->next; }
@@ -305,6 +330,8 @@ int wxListBox::Number(void)
 
 bool wxListBox::Selected( int n )
 {
+  wxCHECK_MSG( m_list != NULL, FALSE, "invalid list ctrl" );
+  
   GList *target = g_list_nth( m_list->children, n );
   if (target)
   {
@@ -326,6 +353,8 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
 
 void wxListBox::SetClientData( int n, char *clientData )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   wxNode *node = m_clientData.Nth( n );
   if (node)
   {
@@ -349,6 +378,8 @@ void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
 
 void wxListBox::SetSelection( int n, bool select )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   if (select)
     gtk_list_select_item( m_list, n );
   else
@@ -357,6 +388,8 @@ void wxListBox::SetSelection( int n, bool select )
 
 void wxListBox::SetString( int n, const wxString &string )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   GList *child = g_list_nth( m_list->children, n );
   if (child)
   {
@@ -372,6 +405,8 @@ void wxListBox::SetString( int n, const wxString &string )
 
 void wxListBox::SetStringSelection( const wxString &string, bool select )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   SetSelection( FindString(string), select );
 }
 
@@ -393,6 +428,8 @@ int wxListBox::GetIndex( GtkWidget *item ) const
 
 void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   while (child)
   {
@@ -417,7 +454,29 @@ GtkWidget *wxListBox::GetConnectWidget(void)
 
 void wxListBox::SetFont( const wxFont &font )
 {
-  wxWindow::SetFont( font );
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
+  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( GTK_WIDGET(m_list) ) );
+  }
+  else
+  {
+    style = gtk_widget_get_style( GTK_WIDGET(m_list) );
+  }
+
+  gdk_font_unref( style->font );
+  style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+
+  gtk_widget_set_style( GTK_WIDGET(m_list), style );
+  
 
   GList *child = m_list->children;
   while (child)
@@ -425,7 +484,7 @@ void wxListBox::SetFont( const wxFont &font )
     GtkBin *bin = (GtkBin*) child->data;
     gtk_widget_set_style( bin->child,
       gtk_style_ref(
-        gtk_widget_get_style( m_widget ) ) );
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
     child = child->next;
   }
 }
@@ -437,7 +496,7 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
   GList *child = m_list->children;
   while (child)
   {
-    GtkBin *bin = (GtkBin*) child->data;
+    GtkBin *bin = GTK_BIN( child->data );
     if (bin->child->window == window) return TRUE;
     child = child->next;
   }
@@ -445,10 +504,39 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
   return FALSE;
 }
 
-void wxListBox::SetBackgroundColour(const wxColour &colour)
+void wxListBox::SetBackgroundColour( const wxColour &colour )
 {
   wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
 
-  SetBackgroundColourHelper( colour, GTK_WIDGET(m_list)->window );
+  m_backgroundColour = colour;
+  if (!m_backgroundColour.Ok()) return;
+  
+  SetBackgroundColourHelper( GTK_WIDGET(m_list)->window );
+
+  GtkStyle *style = (GtkStyle*) NULL;
+  if (!m_hasOwnStyle)
+  {
+    m_hasOwnStyle = TRUE;
+    style = gtk_style_copy( gtk_widget_get_style( GTK_WIDGET(m_list) ) );
+  }
+  else
+  {
+    style = gtk_widget_get_style( GTK_WIDGET(m_list) );
+  }
+
+  style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+  style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+
+  gtk_widget_set_style( GTK_WIDGET(m_list), style );
+
+  GList *child = m_list->children;
+  while (child)
+  {
+    GtkWidget *item = GTK_WIDGET(child->data);
+    gtk_widget_set_style( item,
+      gtk_style_ref(
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
+    child = child->next;
+  }
 }
 
index ed3763b0799842d93c4469389ff374593ca3fafc..08c6712364515071cafd5f311b44c16283636294 100644 (file)
@@ -464,12 +464,11 @@ void wxTextCtrl::SetFont( const wxFont &font )
   gtk_widget_set_style( m_text, style );
 }
 
-// as our GTK widget is m_text and not m_widget, we have to override
-// SetBackgroundColour() to make it work
 void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
 {
   wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
-  // NB: the GtkEntry and GtkText classes have text_area at the same offset
-  SetBackgroundColourHelper( colour, GTK_TEXT(m_text)->text_area );
+  
+  m_backgroundColour = colour;
+  
+  SetBackgroundColourHelper( GTK_TEXT(m_text)->text_area );
 }
index 54f342377a6d4eb17121511ec25038616864edf1..1e6c3b6b9208c62452c874d27b8a4346a38a7dfa 100644 (file)
@@ -1096,7 +1096,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
   if (m_cursor == NULL)
     m_cursor = new wxCursor( wxCURSOR_ARROW );
   m_font = *wxSWISS_FONT;
-  m_backgroundColour = wxWHITE;
+//  m_backgroundColour = wxWHITE;
   m_foregroundColour = wxBLACK;
   m_windowStyle = style;
   m_windowName = name;
@@ -1939,7 +1939,7 @@ bool wxWindow::IsExposed( const wxRect& rect ) const
 
 void wxWindow::Clear()
 {
-  wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+  wxCHECK_RET( m_widget != NULL, "invalid window" );
 
   if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
 }
@@ -1949,21 +1949,23 @@ wxColour wxWindow::GetBackgroundColour() const
   return m_backgroundColour;
 }
 
-void wxWindow::SetBackgroundColourHelper(const wxColour& colour,
-                                         GdkWindow *window)
+void wxWindow::SetBackgroundColourHelper( GdkWindow *window )
 {
-  m_backgroundColour = colour;
-  m_backgroundColour.CalcPixel( gdk_window_get_colormap(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 )
 {
-  wxASSERT_MSG( m_widget != NULL, "invalid window" );
+  wxCHECK_RET( m_widget != NULL, "invalid window" );
 
+  m_backgroundColour = colour;
+  
   GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
-  SetBackgroundColourHelper( colour, widget->window );
+  SetBackgroundColourHelper( widget->window );
 }
 
 wxColour wxWindow::GetForegroundColour() const
@@ -1978,7 +1980,7 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
 
 bool wxWindow::Validate()
 {
-  wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+  wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
 
   wxNode *node = GetChildren()->First();
   while (node)
@@ -1993,7 +1995,7 @@ bool wxWindow::Validate()
 
 bool wxWindow::TransferDataToWindow()
 {
-  wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+  wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
 
   wxNode *node = GetChildren()->First();
   while (node)
index 9db6be50b81f11be78716737abbaad44208478f9..efe78a6f3fd71b09532178028072839355bfc3a0 100644 (file)
@@ -130,6 +130,12 @@ void wxComboBox::Append( const wxString &item, char *clientData )
         gtk_widget_get_style( m_widget ) ) ); 
   }
   
+  if (m_backgroundColour != wxNullColour)
+  {
+    GtkBin *bin = GTK_BIN( list_item );
+    SetBackgroundColourHelper( bin->child->window );
+  }
+  
   gtk_signal_connect( GTK_OBJECT(list_item), "select", 
     GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
   
@@ -426,3 +432,18 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
            (window == GTK_COMBO(m_widget)->button->window ) );
 }
 
+void wxComboBox::SetBackgroundColour( const wxColour &colour )
+{
+  wxWindow::SetBackgroundColour( colour );
+  
+  GtkWidget *list = GTK_COMBO(m_widget)->list;
+  
+  GList *child = GTK_LIST(list)->children;
+  while (child)
+  {
+    GtkBin *bin = (GtkBin*) child->data;
+    SetBackgroundColourHelper( bin->child->window );
+    child = child->next;
+  }
+}
+
index 84d0cebf07aecfdb9e36265829d18f9ff460f9f2..17cd0074333090febd5463b143a92abecc0e7db9 100644 (file)
@@ -92,6 +92,7 @@ wxPaintDC::wxPaintDC(void)
   m_textGC = (GdkGC *) NULL;
   m_bgGC = (GdkGC *) NULL;
   m_cmap = (GdkColormap *) NULL;
+  m_isMemDC = FALSE;
 }
 
 wxPaintDC::wxPaintDC( wxWindow *window )
@@ -112,7 +113,7 @@ wxPaintDC::wxPaintDC( wxWindow *window )
   else
     m_cmap = gtk_widget_get_colormap( window->m_widget );
     
-  m_isDrawable = TRUE;
+  m_isMemDC = FALSE;
         
   SetUpDC();
 }
@@ -137,9 +138,7 @@ void wxPaintDC::DrawLine( long x1, long y1, long x2, long y2 )
 {
   if (!Ok()) return;
   
-  // FIXME: is this right? Causes a segfault on my system and doesn't
-  // seem right: wxPaintDC does not inherit from wxMemoryDC
-  //   if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() != wxTRANSPARENT)
   {
@@ -152,9 +151,7 @@ void wxPaintDC::CrossHair( long x, long y )
 {
   if (!Ok()) return;
   
-  // FIXME: is this right? Causes a segfault on my system and doesn't
-  // seem right: wxPaintDC does not inherit from wxMemoryDC
-  // if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() != wxTRANSPARENT)
   {
@@ -174,7 +171,7 @@ void wxPaintDC::DrawArc( long x1, long y1, long x2, long y2, double xc, double y
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx1 = XLOG2DEV(x1); 
   long yy1 = YLOG2DEV(y1);
@@ -224,7 +221,7 @@ void wxPaintDC::DrawEllipticArc( long x, long y, long width, long height, double
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx = XLOG2DEV(x);    
   long yy = YLOG2DEV(y);
@@ -248,7 +245,7 @@ void wxPaintDC::DrawPoint( long x, long y )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() != wxTRANSPARENT)
     gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) );
@@ -258,7 +255,7 @@ void wxPaintDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() == wxTRANSPARENT) return;
   
@@ -276,7 +273,7 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (m_pen.GetStyle() == wxTRANSPARENT) return;
   
@@ -298,7 +295,7 @@ void wxPaintDC::DrawPolygon( int n, wxPoint points[], long xoffset, long yoffset
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
    if (!n) return;    // Nothing to draw
    GdkPoint *gdkpoints = new GdkPoint[n+1];
@@ -325,7 +322,7 @@ void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, long yoffset, int WXUN
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
    int n = lines->Number();
    GdkPoint *gdkpoints = new GdkPoint[n];
@@ -359,7 +356,7 @@ void wxPaintDC::DrawRectangle( long x, long y, long width, long height )
 {
   if (!Ok()) return;
 
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx = XLOG2DEV(x);
   long yy = YLOG2DEV(y);
@@ -384,7 +381,7 @@ void wxPaintDC::DrawRoundedRectangle( long x, long y, long width, long height, d
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
   
@@ -451,7 +448,7 @@ void wxPaintDC::DrawEllipse( long x, long y, long width, long height )
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   long xx = XLOG2DEV(x);    
   long yy = YLOG2DEV(y);
@@ -480,7 +477,7 @@ void wxPaintDC::DrawIcon( const wxIcon &icon, long x, long y, bool useMask )
   
   if (!icon.Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   int xx = XLOG2DEV(x);
   int yy = YLOG2DEV(y);
@@ -509,10 +506,9 @@ bool wxPaintDC::Blit( long xdest, long ydest, long width, long height,
 {
   if (!Ok()) return FALSE;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
-  // CMB 20/5/98: add blitting of bitmaps
-  if (source->IsKindOf(CLASSINFO(wxMemoryDC)))
+  if (m_isMemDC)
   {
     wxMemoryDC* srcDC = (wxMemoryDC*)source;
     GdkBitmap* bmap = srcDC->m_selected.GetBitmap();
@@ -551,7 +547,7 @@ void wxPaintDC::DrawText( const wxString &text, long x, long y, bool WXUNUSED(us
 {
   if (!Ok()) return;
 
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
   GdkFont *font = m_font.GetInternalFont( m_scaleY );
 
@@ -622,9 +618,9 @@ void wxPaintDC::Clear(void)
 {
   if (!Ok()) return;
   
-  if (!m_isDrawable) ((wxMemoryDC*)this)->m_selected.DestroyImage();
+  if (m_isMemDC) ((wxMemoryDC*)this)->m_selected.DestroyImage();
   
-  if (m_isDrawable)
+  if (!m_isMemDC)
   {
     gdk_window_clear( m_window );
   }
index 84a6e144e70bfb92379361cd8c31a3c86a0b57f2..aa8ab7a2696159c8aa3f38a2ffb2a95433213c3b 100644 (file)
@@ -66,7 +66,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
     
     SetUpDC();
     
-    m_isDrawable = FALSE;
+    m_isMemDC = TRUE;
   }
   else
   {
index b8c301884b36de3978e6a940f036c0b2c4d8d4e1..7742d96c55a2113e0a426424f65467ab5cff7d8f 100644 (file)
@@ -136,6 +136,8 @@ void wxListBox::Append( const wxString &item )
 
 void wxListBox::Append( const wxString &item, char *clientData )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   GtkWidget *list_item = gtk_list_item_new_with_label( item );
 
   if (m_hasOwnStyle)
@@ -143,9 +145,13 @@ void wxListBox::Append( const wxString &item, char *clientData )
     GtkBin *bin = GTK_BIN( list_item );
     gtk_widget_set_style( bin->child,
       gtk_style_ref(
-        gtk_widget_get_style( m_widget ) ) );
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
+       
+    gtk_widget_set_style( GTK_WIDGET(bin),
+      gtk_style_ref(
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
   }
-
+  
   gtk_signal_connect( GTK_OBJECT(list_item), "select",
     GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
 
@@ -162,11 +168,12 @@ void wxListBox::Append( const wxString &item, char *clientData )
   ConnectWidget( list_item );
 
   ConnectDnDWidget( list_item );
-
 }
 
 void wxListBox::Clear(void)
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   gtk_list_clear_items( m_list, 0, Number() );
 
   m_clientData.Clear();
@@ -174,6 +181,8 @@ void wxListBox::Clear(void)
 
 void wxListBox::Delete( int n )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   GList *child = g_list_nth( m_list->children, n );
 
   if (!child)
@@ -197,11 +206,15 @@ void wxListBox::Delete( int n )
 
 void wxListBox::Deselect( int n )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
   gtk_list_unselect_item( m_list, n );
 }
 
 int wxListBox::FindString( const wxString &item ) const
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   int count = 0;
   while (child)
@@ -222,6 +235,8 @@ int wxListBox::FindString( const wxString &item ) const
 
 char *wxListBox::GetClientData( int n ) const
 {
+  wxCHECK_MSG( m_list != NULL, (char*) NULL, "invalid list ctrl" );
+  
   wxNode *node = m_clientData.Nth( n );
   if (node) return ((char*)node->Data());
 
@@ -231,6 +246,8 @@ char *wxListBox::GetClientData( int n ) const
 
 int wxListBox::GetSelection(void) const
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   int count = 0;
   while (child)
@@ -244,6 +261,8 @@ int wxListBox::GetSelection(void) const
 
 int wxListBox::GetSelections(wxArrayInt& aSelections) const
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   // get the number of selected items first
   GList *child = m_list->children;
   int count = 0;
@@ -271,6 +290,8 @@ int wxListBox::GetSelections(wxArrayInt& aSelections) const
 
 wxString wxListBox::GetString( int n ) const
 {
+  wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
+  
   GList *child = g_list_nth( m_list->children, n );
   if (child)
   {
@@ -284,6 +305,8 @@ wxString wxListBox::GetString( int n ) const
 
 wxString wxListBox::GetStringSelection(void) const
 {
+  wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
+  
   GList *selection = m_list->selection;
   if (selection)
   {
@@ -297,6 +320,8 @@ wxString wxListBox::GetStringSelection(void) const
 
 int wxListBox::Number(void)
 {
+  wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   int count = 0;
   while (child) { count++; child = child->next; }
@@ -305,6 +330,8 @@ int wxListBox::Number(void)
 
 bool wxListBox::Selected( int n )
 {
+  wxCHECK_MSG( m_list != NULL, FALSE, "invalid list ctrl" );
+  
   GList *target = g_list_nth( m_list->children, n );
   if (target)
   {
@@ -326,6 +353,8 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
 
 void wxListBox::SetClientData( int n, char *clientData )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   wxNode *node = m_clientData.Nth( n );
   if (node)
   {
@@ -349,6 +378,8 @@ void wxListBox::SetFirstItem( const wxString &WXUNUSED(item) )
 
 void wxListBox::SetSelection( int n, bool select )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   if (select)
     gtk_list_select_item( m_list, n );
   else
@@ -357,6 +388,8 @@ void wxListBox::SetSelection( int n, bool select )
 
 void wxListBox::SetString( int n, const wxString &string )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   GList *child = g_list_nth( m_list->children, n );
   if (child)
   {
@@ -372,6 +405,8 @@ void wxListBox::SetString( int n, const wxString &string )
 
 void wxListBox::SetStringSelection( const wxString &string, bool select )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   SetSelection( FindString(string), select );
 }
 
@@ -393,6 +428,8 @@ int wxListBox::GetIndex( GtkWidget *item ) const
 
 void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
 {
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
   GList *child = m_list->children;
   while (child)
   {
@@ -417,7 +454,29 @@ GtkWidget *wxListBox::GetConnectWidget(void)
 
 void wxListBox::SetFont( const wxFont &font )
 {
-  wxWindow::SetFont( font );
+  wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+  
+  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( GTK_WIDGET(m_list) ) );
+  }
+  else
+  {
+    style = gtk_widget_get_style( GTK_WIDGET(m_list) );
+  }
+
+  gdk_font_unref( style->font );
+  style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) );
+
+  gtk_widget_set_style( GTK_WIDGET(m_list), style );
+  
 
   GList *child = m_list->children;
   while (child)
@@ -425,7 +484,7 @@ void wxListBox::SetFont( const wxFont &font )
     GtkBin *bin = (GtkBin*) child->data;
     gtk_widget_set_style( bin->child,
       gtk_style_ref(
-        gtk_widget_get_style( m_widget ) ) );
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
     child = child->next;
   }
 }
@@ -437,7 +496,7 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
   GList *child = m_list->children;
   while (child)
   {
-    GtkBin *bin = (GtkBin*) child->data;
+    GtkBin *bin = GTK_BIN( child->data );
     if (bin->child->window == window) return TRUE;
     child = child->next;
   }
@@ -445,10 +504,39 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
   return FALSE;
 }
 
-void wxListBox::SetBackgroundColour(const wxColour &colour)
+void wxListBox::SetBackgroundColour( const wxColour &colour )
 {
   wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
 
-  SetBackgroundColourHelper( colour, GTK_WIDGET(m_list)->window );
+  m_backgroundColour = colour;
+  if (!m_backgroundColour.Ok()) return;
+  
+  SetBackgroundColourHelper( GTK_WIDGET(m_list)->window );
+
+  GtkStyle *style = (GtkStyle*) NULL;
+  if (!m_hasOwnStyle)
+  {
+    m_hasOwnStyle = TRUE;
+    style = gtk_style_copy( gtk_widget_get_style( GTK_WIDGET(m_list) ) );
+  }
+  else
+  {
+    style = gtk_widget_get_style( GTK_WIDGET(m_list) );
+  }
+
+  style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+  style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor();
+
+  gtk_widget_set_style( GTK_WIDGET(m_list), style );
+
+  GList *child = m_list->children;
+  while (child)
+  {
+    GtkWidget *item = GTK_WIDGET(child->data);
+    gtk_widget_set_style( item,
+      gtk_style_ref(
+        gtk_widget_get_style( GTK_WIDGET(m_list) ) ) );
+    child = child->next;
+  }
 }
 
index ed3763b0799842d93c4469389ff374593ca3fafc..08c6712364515071cafd5f311b44c16283636294 100644 (file)
@@ -464,12 +464,11 @@ void wxTextCtrl::SetFont( const wxFont &font )
   gtk_widget_set_style( m_text, style );
 }
 
-// as our GTK widget is m_text and not m_widget, we have to override
-// SetBackgroundColour() to make it work
 void wxTextCtrl::SetBackgroundColour( const wxColour &colour )
 {
   wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
-
-  // NB: the GtkEntry and GtkText classes have text_area at the same offset
-  SetBackgroundColourHelper( colour, GTK_TEXT(m_text)->text_area );
+  
+  m_backgroundColour = colour;
+  
+  SetBackgroundColourHelper( GTK_TEXT(m_text)->text_area );
 }
index 54f342377a6d4eb17121511ec25038616864edf1..1e6c3b6b9208c62452c874d27b8a4346a38a7dfa 100644 (file)
@@ -1096,7 +1096,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
   if (m_cursor == NULL)
     m_cursor = new wxCursor( wxCURSOR_ARROW );
   m_font = *wxSWISS_FONT;
-  m_backgroundColour = wxWHITE;
+//  m_backgroundColour = wxWHITE;
   m_foregroundColour = wxBLACK;
   m_windowStyle = style;
   m_windowName = name;
@@ -1939,7 +1939,7 @@ bool wxWindow::IsExposed( const wxRect& rect ) const
 
 void wxWindow::Clear()
 {
-  wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+  wxCHECK_RET( m_widget != NULL, "invalid window" );
 
   if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
 }
@@ -1949,21 +1949,23 @@ wxColour wxWindow::GetBackgroundColour() const
   return m_backgroundColour;
 }
 
-void wxWindow::SetBackgroundColourHelper(const wxColour& colour,
-                                         GdkWindow *window)
+void wxWindow::SetBackgroundColourHelper( GdkWindow *window )
 {
-  m_backgroundColour = colour;
-  m_backgroundColour.CalcPixel( gdk_window_get_colormap(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 )
 {
-  wxASSERT_MSG( m_widget != NULL, "invalid window" );
+  wxCHECK_RET( m_widget != NULL, "invalid window" );
 
+  m_backgroundColour = colour;
+  
   GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
-  SetBackgroundColourHelper( colour, widget->window );
+  SetBackgroundColourHelper( widget->window );
 }
 
 wxColour wxWindow::GetForegroundColour() const
@@ -1978,7 +1980,7 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
 
 bool wxWindow::Validate()
 {
-  wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+  wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
 
   wxNode *node = GetChildren()->First();
   while (node)
@@ -1993,7 +1995,7 @@ bool wxWindow::Validate()
 
 bool wxWindow::TransferDataToWindow()
 {
-  wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+  wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
 
   wxNode *node = GetChildren()->First();
   while (node)