void SetFont( const wxFont &font );
void OnSize( wxSizeEvent &event );
+ void SetBackgroundColour( const wxColour &colour );
// implementation
GdkGC *m_textGC;
GdkGC *m_bgGC;
GdkColormap *m_cmap;
- bool m_isDrawable;
+ bool m_isMemDC;
void SetUpDC(void);
GdkWindow *GetWindow(void);
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 );
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()
};
void SetFont( const wxFont &font );
void OnSize( wxSizeEvent &event );
+ void SetBackgroundColour( const wxColour &colour );
// implementation
GdkGC *m_textGC;
GdkGC *m_bgGC;
GdkColormap *m_cmap;
- bool m_isDrawable;
+ bool m_isMemDC;
void SetUpDC(void);
GdkWindow *GetWindow(void);
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 );
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()
};
#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
//----------------------------------------------------------------------
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"
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);
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 );
(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;
+ }
+}
+
m_textGC = (GdkGC *) NULL;
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
+ m_isMemDC = FALSE;
}
wxPaintDC::wxPaintDC( wxWindow *window )
else
m_cmap = gtk_widget_get_colormap( window->m_widget );
- m_isDrawable = TRUE;
+ m_isMemDC = FALSE;
SetUpDC();
}
{
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)
{
{
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)
{
{
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);
{
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);
{
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) );
{
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;
{
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;
{
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];
{
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];
{
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);
{
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);
{
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);
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);
{
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();
{
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 );
{
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 );
}
SetUpDC();
- m_isDrawable = FALSE;
+ m_isMemDC = TRUE;
}
else
{
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)
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 );
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();
void wxListBox::Delete( int n )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
GList *child = g_list_nth( m_list->children, n );
if (!child)
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)
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());
int wxListBox::GetSelection(void) const
{
+ wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+
GList *child = m_list->children;
int count = 0;
while (child)
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;
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)
{
wxString wxListBox::GetStringSelection(void) const
{
+ wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
+
GList *selection = m_list->selection;
if (selection)
{
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; }
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)
{
void wxListBox::SetClientData( int n, char *clientData )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
wxNode *node = m_clientData.Nth( n );
if (node)
{
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
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)
{
void wxListBox::SetStringSelection( const wxString &string, bool select )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
SetSelection( FindString(string), select );
}
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
GList *child = m_list->children;
while (child)
{
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)
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;
}
}
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;
}
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;
+ }
}
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 );
}
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;
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 );
}
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
bool wxWindow::Validate()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
bool wxWindow::TransferDataToWindow()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
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 );
(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;
+ }
+}
+
m_textGC = (GdkGC *) NULL;
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
+ m_isMemDC = FALSE;
}
wxPaintDC::wxPaintDC( wxWindow *window )
else
m_cmap = gtk_widget_get_colormap( window->m_widget );
- m_isDrawable = TRUE;
+ m_isMemDC = FALSE;
SetUpDC();
}
{
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)
{
{
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)
{
{
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);
{
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);
{
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) );
{
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;
{
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;
{
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];
{
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];
{
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);
{
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);
{
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);
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);
{
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();
{
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 );
{
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 );
}
SetUpDC();
- m_isDrawable = FALSE;
+ m_isMemDC = TRUE;
}
else
{
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)
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 );
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();
void wxListBox::Delete( int n )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
GList *child = g_list_nth( m_list->children, n );
if (!child)
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)
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());
int wxListBox::GetSelection(void) const
{
+ wxCHECK_MSG( m_list != NULL, -1, "invalid list ctrl" );
+
GList *child = m_list->children;
int count = 0;
while (child)
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;
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)
{
wxString wxListBox::GetStringSelection(void) const
{
+ wxCHECK_MSG( m_list != NULL, "", "invalid list ctrl" );
+
GList *selection = m_list->selection;
if (selection)
{
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; }
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)
{
void wxListBox::SetClientData( int n, char *clientData )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
wxNode *node = m_clientData.Nth( n );
if (node)
{
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
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)
{
void wxListBox::SetStringSelection( const wxString &string, bool select )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
SetSelection( FindString(string), select );
}
void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
{
+ wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
+
GList *child = m_list->children;
while (child)
{
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)
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;
}
}
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;
}
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;
+ }
}
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 );
}
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;
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 );
}
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
bool wxWindow::Validate()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
bool wxWindow::TransferDataToWindow()
{
- wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+ wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
wxNode *node = GetChildren()->First();
while (node)