SetBackground for ListBox and others

Removed the old and famous wxSplitter bug


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@896 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-10-21 22:21:09 +00:00
parent 0d57be4594
commit fc54776e31
19 changed files with 334 additions and 112 deletions

View 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;
}
}

View 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 );
}

View File

@@ -66,7 +66,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
SetUpDC();
m_isDrawable = FALSE;
m_isMemDC = TRUE;
}
else
{

View 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;
}
}

View 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 );
}

View 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)

View 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;
}
}

View 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 );
}

View File

@@ -66,7 +66,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
SetUpDC();
m_isDrawable = FALSE;
m_isMemDC = TRUE;
}
else
{

View 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;
}
}

View 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 );
}

View 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)