1. wxTextCtrl::SetBackgroundColour() now works

2. wxListBox::SetBackgroundColour() now does something, although still not
   what I'd like
3. wxColour() now has a ctor from "const char *" to allow calls like
   SetBackgroundColour("green");
4. controls sample modified to use colors


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@872 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-10-19 14:18:56 +00:00
parent be6bf94bf0
commit 68dda78574
21 changed files with 303 additions and 243 deletions

View File

@@ -39,25 +39,24 @@ class wxColour;
class wxColour: public wxGDIObject class wxColour: public wxGDIObject
{ {
DECLARE_DYNAMIC_CLASS(wxColour)
public: public:
wxColour(void); wxColour();
wxColour( char red, char green, char blue ); wxColour( char red, char green, char blue );
wxColour( const wxString &colourName ); wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
wxColour( const wxColour& col ); wxColour( const wxColour& col );
wxColour( const wxColour* col ); wxColour( const wxColour* col );
~wxColour(void); ~wxColour();
wxColour& operator = ( const wxColour& col ); wxColour& operator = ( const wxColour& col );
wxColour& operator = ( const wxString& colourName ); wxColour& operator = ( const wxString& colourName );
bool operator == ( const wxColour& col ); bool operator == ( const wxColour& col );
bool operator != ( const wxColour& col ); bool operator != ( const wxColour& col );
void Set( const unsigned char red, const unsigned char green, const unsigned char blue ); void Set( const unsigned char red, const unsigned char green, const unsigned char blue );
unsigned char Red(void) const; unsigned char Red() const;
unsigned char Green(void) const; unsigned char Green() const;
unsigned char Blue(void) const; unsigned char Blue() const;
bool Ok(void) const; bool Ok() const;
private: private:
public: public:
@@ -68,10 +67,15 @@ class wxColour: public wxGDIObject
friend wxWindow; friend wxWindow;
void CalcPixel( GdkColormap *cmap ); void CalcPixel( GdkColormap *cmap );
int GetPixel(void); int GetPixel() const;
GdkColor *GetColor(void); GdkColor *GetColor() const;
// no data :-) protected:
// helper functions
void InitFromName(const wxString& colourName);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
}; };
#endif // __GTKCOLOURH__ #endif // __GTKCOLOURH__

View File

@@ -85,6 +85,7 @@ class wxListBox: public wxControl
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void SetDropTarget( wxDropTarget *dropTarget ); void SetDropTarget( wxDropTarget *dropTarget );
virtual void SetBackgroundColour(const wxColour &colour);
// implementation // implementation

View File

@@ -102,6 +102,7 @@ class wxTextCtrl: public wxControl, public streambuf
wxTextCtrl& operator<<(const char c); wxTextCtrl& operator<<(const char c);
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
virtual void SetBackgroundColour(const wxColour &colour);
// implementation // implementation

View File

@@ -315,6 +315,12 @@ public:
virtual void GetClientSizeConstraint(int *w, int *h) const ; virtual void GetClientSizeConstraint(int *w, int *h) const ;
virtual void GetPositionConstraint(int *x, int *y) 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() DECLARE_EVENT_TABLE()
}; };

View File

@@ -39,25 +39,24 @@ class wxColour;
class wxColour: public wxGDIObject class wxColour: public wxGDIObject
{ {
DECLARE_DYNAMIC_CLASS(wxColour)
public: public:
wxColour(void); wxColour();
wxColour( char red, char green, char blue ); wxColour( char red, char green, char blue );
wxColour( const wxString &colourName ); wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
wxColour( const wxColour& col ); wxColour( const wxColour& col );
wxColour( const wxColour* col ); wxColour( const wxColour* col );
~wxColour(void); ~wxColour();
wxColour& operator = ( const wxColour& col ); wxColour& operator = ( const wxColour& col );
wxColour& operator = ( const wxString& colourName ); wxColour& operator = ( const wxString& colourName );
bool operator == ( const wxColour& col ); bool operator == ( const wxColour& col );
bool operator != ( const wxColour& col ); bool operator != ( const wxColour& col );
void Set( const unsigned char red, const unsigned char green, const unsigned char blue ); void Set( const unsigned char red, const unsigned char green, const unsigned char blue );
unsigned char Red(void) const; unsigned char Red() const;
unsigned char Green(void) const; unsigned char Green() const;
unsigned char Blue(void) const; unsigned char Blue() const;
bool Ok(void) const; bool Ok() const;
private: private:
public: public:
@@ -68,10 +67,15 @@ class wxColour: public wxGDIObject
friend wxWindow; friend wxWindow;
void CalcPixel( GdkColormap *cmap ); void CalcPixel( GdkColormap *cmap );
int GetPixel(void); int GetPixel() const;
GdkColor *GetColor(void); GdkColor *GetColor() const;
// no data :-) protected:
// helper functions
void InitFromName(const wxString& colourName);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
}; };
#endif // __GTKCOLOURH__ #endif // __GTKCOLOURH__

View File

@@ -85,6 +85,7 @@ class wxListBox: public wxControl
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
void SetDropTarget( wxDropTarget *dropTarget ); void SetDropTarget( wxDropTarget *dropTarget );
virtual void SetBackgroundColour(const wxColour &colour);
// implementation // implementation

View File

@@ -102,6 +102,7 @@ class wxTextCtrl: public wxControl, public streambuf
wxTextCtrl& operator<<(const char c); wxTextCtrl& operator<<(const char c);
void SetFont( const wxFont &font ); void SetFont( const wxFont &font );
virtual void SetBackgroundColour(const wxColour &colour);
// implementation // implementation

View File

@@ -315,6 +315,12 @@ public:
virtual void GetClientSizeConstraint(int *w, int *h) const ; virtual void GetClientSizeConstraint(int *w, int *h) const ;
virtual void GetPositionConstraint(int *x, int *y) 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() DECLARE_EVENT_TABLE()
}; };

View File

@@ -19,17 +19,18 @@
// Colour // Colour
class WXDLLEXPORT wxColour: public wxObject class WXDLLEXPORT wxColour: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxColour)
public: public:
wxColour(void); wxColour();
wxColour(const unsigned char r, const unsigned char g, const unsigned char b); wxColour(const unsigned char r, const unsigned char g, const unsigned char b);
wxColour(unsigned long colRGB) { Set(colRGB); } wxColour(unsigned long colRGB) { Set(colRGB); }
wxColour(const wxColour& col); wxColour(const wxColour& col);
wxColour(const wxString& col); wxColour(const wxString& col) { InitFromName(col); }
~wxColour(void) ; wxColour(const char *col) { InitFromName(col); }
~wxColour();
wxColour& operator =(const wxColour& src) ; wxColour& operator =(const wxColour& src) ;
wxColour& operator =(const wxString& src) ; wxColour& operator =(const wxString& src) ;
inline int Ok(void) const { return (m_isInit) ; } inline int Ok() const { return (m_isInit) ; }
void Set(unsigned char r, unsigned char g, unsigned char b); void Set(unsigned char r, unsigned char g, unsigned char b);
void Set(unsigned long colRGB) void Set(unsigned long colRGB)
@@ -46,23 +47,30 @@ public:
void Get(unsigned char *r, unsigned char *g, unsigned char *b) const; void Get(unsigned char *r, unsigned char *g, unsigned char *b) const;
#endif #endif
inline unsigned char Red(void) const { return m_red; } inline unsigned char Red() const { return m_red; }
inline unsigned char Green(void) const { return m_green; } inline unsigned char Green() const { return m_green; }
inline unsigned char Blue(void) const { return m_blue; } inline unsigned char Blue() const { return m_blue; }
inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); } inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); } inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
WXCOLORREF GetPixel(void) const { return m_pixel; }; WXCOLORREF GetPixel() const { return m_pixel; };
private: private:
bool m_isInit; bool m_isInit;
unsigned char m_red; unsigned char m_red;
unsigned char m_blue; unsigned char m_blue;
unsigned char m_green; unsigned char m_green;
// helper func
void InitFromName(const wxString& colourName);
public: public:
WXCOLORREF m_pixel ; WXCOLORREF m_pixel ;
private:
DECLARE_DYNAMIC_CLASS(wxColour)
}; };
#define wxColor wxColour #define wxColor wxColour

View File

@@ -209,6 +209,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) ) wxPanel( frame, -1, wxPoint(x, y), wxSize(w, h) )
{ {
m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE ); m_text = new wxTextCtrl( this, -1, "This is the log window.\n", wxPoint(0,50), wxSize(100,50), wxTE_MULTILINE );
m_text->SetBackgroundColour("yellow");
m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) ); m_notebook = new wxNotebook( this, ID_NOTEBOOK, wxPoint(0,0), wxSize(200,150) );
@@ -233,13 +234,10 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
wxASSERT( WXSIZEOF(aIconNames) == Image_Max ); // keep in sync wxASSERT( WXSIZEOF(aIconNames) == Image_Max ); // keep in sync
// fill the image list // TODO should find the dir from path to program
#ifdef __WXMSW__
wxString strIconDir = "icons/"; wxString strIconDir = "icons/";
#else
wxString strIconDir = "../icons/";
#endif
// fill the image list
wxImageList *imagelist = new wxImageList(32, 32); wxImageList *imagelist = new wxImageList(32, 32);
for ( size_t n = 0; n < Image_Max; n++ ) for ( size_t n = 0; n < Image_Max; n++ )
{ {
@@ -250,9 +248,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
wxPanel *panel = new wxPanel(m_notebook); wxPanel *panel = new wxPanel(m_notebook);
m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 4, choices ); m_listbox = new wxListBox( panel, ID_LISTBOX, wxPoint(10,10), wxSize(120,70), 4, choices );
m_listbox->SetBackgroundColour("red");
(void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_SEL_STR, "Select 'This'", wxPoint(340,30), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) ); wxButton *btn = new wxButton( panel, ID_LISTBOX_CLEAR, "Clear", wxPoint(180,80), wxSize(140,30) );
btn->SetBackgroundColour("green");
(void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_APPEND, "Append 'Hi!'", wxPoint(340,80), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_DELETE, "Delete selected item", wxPoint(180,130), wxSize(140,30) );
(void)new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) ); (void)new wxButton( panel, ID_LISTBOX_FONT, "Set Italic font", wxPoint(340,130), wxSize(140,30) );

View File

@@ -27,9 +27,9 @@ class wxColourRefData: public wxObjectRefData
{ {
public: public:
wxColourRefData(void); wxColourRefData();
~wxColourRefData(void); ~wxColourRefData();
void FreeColour(void); void FreeColour();
GdkColor m_color; GdkColor m_color;
GdkColormap *m_colormap; GdkColormap *m_colormap;
@@ -38,7 +38,7 @@ class wxColourRefData: public wxObjectRefData
friend wxColour; friend wxColour;
}; };
wxColourRefData::wxColourRefData(void) wxColourRefData::wxColourRefData()
{ {
m_color.red = 0; m_color.red = 0;
m_color.green = 0; m_color.green = 0;
@@ -48,12 +48,12 @@ wxColourRefData::wxColourRefData(void)
m_hasPixel = FALSE; m_hasPixel = FALSE;
} }
wxColourRefData::~wxColourRefData(void) wxColourRefData::~wxColourRefData()
{ {
FreeColour(); FreeColour();
} }
void wxColourRefData::FreeColour(void) void wxColourRefData::FreeColour()
{ {
// if (m_hasPixel) gdk_colors_free( m_colormap, &m_color, 1, 0 ); // if (m_hasPixel) gdk_colors_free( m_colormap, &m_color, 1, 0 );
} }
@@ -66,7 +66,7 @@ void wxColourRefData::FreeColour(void)
IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject)
wxColour::wxColour(void) wxColour::wxColour()
{ {
} }
@@ -79,7 +79,7 @@ wxColour::wxColour( char red, char green, char blue )
M_COLDATA->m_color.pixel = 0; M_COLDATA->m_color.pixel = 0;
} }
wxColour::wxColour( const wxString &colourName ) void wxColour::InitFromName( const wxString &colourName )
{ {
wxNode *node = (wxNode *) NULL; wxNode *node = (wxNode *) NULL;
if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) )
@@ -110,7 +110,7 @@ wxColour::wxColour( const wxColour* col )
if (col) Ref( *col ); if (col) Ref( *col );
} }
wxColour::~wxColour(void) wxColour::~wxColour()
{ {
} }
@@ -163,7 +163,7 @@ void wxColour::Set( const unsigned char red, const unsigned char green, const un
M_COLDATA->m_color.pixel = 0; M_COLDATA->m_color.pixel = 0;
} }
unsigned char wxColour::Red(void) const unsigned char wxColour::Red() const
{ {
if (!Ok()) if (!Ok())
{ {
@@ -174,7 +174,7 @@ unsigned char wxColour::Red(void) const
return (unsigned char)(M_COLDATA->m_color.red >> SHIFT); return (unsigned char)(M_COLDATA->m_color.red >> SHIFT);
} }
unsigned char wxColour::Green(void) const unsigned char wxColour::Green() const
{ {
if (!Ok()) if (!Ok())
{ {
@@ -185,7 +185,7 @@ unsigned char wxColour::Green(void) const
return (unsigned char)(M_COLDATA->m_color.green >> SHIFT); return (unsigned char)(M_COLDATA->m_color.green >> SHIFT);
} }
unsigned char wxColour::Blue(void) const unsigned char wxColour::Blue() const
{ {
if (!Ok()) if (!Ok())
{ {
@@ -196,7 +196,7 @@ unsigned char wxColour::Blue(void) const
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
} }
bool wxColour::Ok(void) const bool wxColour::Ok() const
{ {
return (m_refData != NULL); return (m_refData != NULL);
} }
@@ -225,14 +225,14 @@ void wxColour::CalcPixel( GdkColormap *cmap )
M_COLDATA->m_colormap = cmap; M_COLDATA->m_colormap = cmap;
} }
int wxColour::GetPixel(void) int wxColour::GetPixel() const
{ {
if (!Ok()) return 0; if (!Ok()) return 0;
return M_COLDATA->m_color.pixel; return M_COLDATA->m_color.pixel;
} }
GdkColor *wxColour::GetColor(void) GdkColor *wxColour::GetColor() const
{ {
if (!Ok()) return (GdkColor *) NULL; if (!Ok()) return (GdkColor *) NULL;

View File

@@ -445,4 +445,10 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
return FALSE; return FALSE;
} }
void wxListBox::SetBackgroundColour(const wxColour &colour)
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
SetBackgroundColourHelper( colour, GTK_WIDGET(m_list)->window );
}

View File

@@ -115,7 +115,8 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
m_widget = gtk_handle_box_new(); m_widget = gtk_handle_box_new();
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS ) ); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL,
GTK_TOOLBAR_ICONS ) );
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
@@ -184,18 +185,18 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
GdkPixmap *pixmap = bitmap.GetPixmap(); GdkPixmap *pixmap = bitmap.GetPixmap();
GdkBitmap *mask = (GdkBitmap *)NULL; GdkBitmap *mask = (GdkBitmap *)NULL;
if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap(); if ( bitmap.GetMask() )
mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_pixmap_new( pixmap, mask ); tool_pixmap = gtk_pixmap_new( pixmap, mask );
} }
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 ); gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
#if 0
GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON
: GTK_TOOLBAR_CHILD_BUTTON; : GTK_TOOLBAR_CHILD_BUTTON;
tool->m_item = gtk_toolbar_append_element GtkWidget *item = gtk_toolbar_append_element
( (
GTK_TOOLBAR(m_toolbar), GTK_TOOLBAR(m_toolbar),
ctype, ctype,
@@ -208,22 +209,18 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
(gpointer)tool (gpointer)tool
); );
// VZ: we don't want GDK_NO_EXPOSE events because for some reason our
// toolbar buttons get them (it doesn't happen in a standalone GTK+ program
// for unknown reasons) and it prevents tooltips from appearing.
gtk_widget_set_events( GTK_WIDGET(item),
gtk_widget_get_events( GTK_WIDGET(item) ) &
~GDK_EXPOSURE_MASK);
tool->m_item = item;
gtk_signal_connect( GTK_OBJECT(tool->m_item), gtk_signal_connect( GTK_OBJECT(tool->m_item),
"enter_notify_event", "enter_notify_event",
GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback), GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),
(gpointer)tool ); (gpointer)tool );
#else
tool->m_item = gtk_toolbar_append_item
(
GTK_TOOLBAR(m_toolbar),
(const char *)NULL,
helpString1,
"",
tool_pixmap,
(GtkSignalFunc)gtk_toolbar_callback,
(gpointer)tool
);
#endif
m_tools.Append( tool ); m_tools.Append( tool );

View File

@@ -464,4 +464,12 @@ void wxTextCtrl::SetFont( const wxFont &font )
gtk_widget_set_style( m_text, style ); 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 );
}

View File

@@ -1021,7 +1021,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
return TRUE; return TRUE;
} }
wxWindow::~wxWindow(void) wxWindow::~wxWindow()
{ {
m_hasVMT = FALSE; m_hasVMT = FALSE;
@@ -1113,7 +1113,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_hasOwnStyle = FALSE; m_hasOwnStyle = FALSE;
} }
void wxWindow::PostCreation(void) void wxWindow::PostCreation()
{ {
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );
@@ -1168,7 +1168,7 @@ void wxWindow::ConnectWidget( GtkWidget *widget )
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
} }
bool wxWindow::HasVMT(void) bool wxWindow::HasVMT()
{ {
return m_hasVMT; return m_hasVMT;
} }
@@ -1184,7 +1184,7 @@ bool wxWindow::Close( bool force )
return GetEventHandler()->ProcessEvent(event); return GetEventHandler()->ProcessEvent(event);
} }
bool wxWindow::Destroy(void) bool wxWindow::Destroy()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1193,7 +1193,7 @@ bool wxWindow::Destroy(void)
return TRUE; return TRUE;
} }
bool wxWindow::DestroyChildren(void) bool wxWindow::DestroyChildren()
{ {
if (GetChildren()) if (GetChildren())
{ {
@@ -1216,7 +1216,7 @@ void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
// are we to set fonts here ? // are we to set fonts here ?
} }
void wxWindow::ImplementSetSize(void) void wxWindow::ImplementSetSize()
{ {
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
@@ -1225,7 +1225,7 @@ void wxWindow::ImplementSetSize(void)
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
} }
void wxWindow::ImplementSetPosition(void) void wxWindow::ImplementSetPosition()
{ {
if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog)) if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog))
{ {
@@ -1523,7 +1523,7 @@ void wxWindow::Centre( int direction )
} }
} }
void wxWindow::Fit(void) void wxWindow::Fit()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1582,7 +1582,7 @@ void wxWindow::Enable( bool enable )
if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable ); if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
} }
int wxWindow::GetCharHeight(void) const int wxWindow::GetCharHeight() const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1596,7 +1596,7 @@ int wxWindow::GetCharHeight(void) const
return font->ascent + font->descent; return font->ascent + font->descent;
} }
int wxWindow::GetCharWidth(void) const int wxWindow::GetCharWidth() const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1650,7 +1650,7 @@ void wxWindow::MakeModal( bool modal )
} }
} }
void wxWindow::SetFocus(void) void wxWindow::SetFocus()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1664,7 +1664,7 @@ void wxWindow::SetFocus(void)
} }
} }
bool wxWindow::OnClose(void) bool wxWindow::OnClose()
{ {
return TRUE; return TRUE;
} }
@@ -1740,7 +1740,7 @@ void wxWindow::AddChild( wxWindow *child )
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
} }
wxList *wxWindow::GetChildren(void) wxList *wxWindow::GetChildren()
{ {
return (&m_children); return (&m_children);
} }
@@ -1757,26 +1757,26 @@ void wxWindow::SetReturnCode( int retCode )
m_retCode = retCode; m_retCode = retCode;
} }
int wxWindow::GetReturnCode(void) int wxWindow::GetReturnCode()
{ {
return m_retCode; return m_retCode;
} }
void wxWindow::Raise(void) void wxWindow::Raise()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_raise( m_widget->window ); if (m_widget) gdk_window_raise( m_widget->window );
} }
void wxWindow::Lower(void) void wxWindow::Lower()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_lower( m_widget->window ); if (m_widget) gdk_window_lower( m_widget->window );
} }
wxEvtHandler *wxWindow::GetEventHandler(void) wxEvtHandler *wxWindow::GetEventHandler()
{ {
return m_eventHandler; return m_eventHandler;
} }
@@ -1812,7 +1812,7 @@ wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
return (wxEvtHandler *) NULL; return (wxEvtHandler *) NULL;
} }
wxValidator *wxWindow::GetValidator(void) wxValidator *wxWindow::GetValidator()
{ {
return m_windowValidator; return m_windowValidator;
} }
@@ -1824,7 +1824,7 @@ void wxWindow::SetValidator( const wxValidator& validator )
if (m_windowValidator) m_windowValidator->SetWindow(this); if (m_windowValidator) m_windowValidator->SetWindow(this);
} }
bool wxWindow::IsBeingDeleted(void) bool wxWindow::IsBeingDeleted()
{ {
return FALSE; return FALSE;
} }
@@ -1834,7 +1834,7 @@ void wxWindow::SetId( wxWindowID id )
m_windowId = id; m_windowId = id;
} }
wxWindowID wxWindow::GetId(void) wxWindowID wxWindow::GetId()
{ {
return m_windowId; return m_windowId;
} }
@@ -1937,33 +1937,36 @@ bool wxWindow::IsExposed( const wxRect& rect ) const
return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion ); return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion );
} }
void wxWindow::Clear(void) void wxWindow::Clear()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window ); if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
} }
wxColour wxWindow::GetBackgroundColour(void) const wxColour wxWindow::GetBackgroundColour() const
{ {
return m_backgroundColour; return m_backgroundColour;
} }
void wxWindow::SetBackgroundColourHelper(const wxColour& colour,
GdkWindow *window)
{
m_backgroundColour = colour;
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 ) void wxWindow::SetBackgroundColour( const wxColour &colour )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( m_widget != NULL, "invalid window" );
m_backgroundColour = colour; GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
if (m_wxwindow) SetBackgroundColourHelper( colour, widget->window );
{
m_backgroundColour.CalcPixel( m_wxwindow->style->colormap );
gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
gdk_window_clear( m_wxwindow->window );
}
// do something ?
} }
wxColour wxWindow::GetForegroundColour(void) const wxColour wxWindow::GetForegroundColour() const
{ {
return m_foregroundColour; return m_foregroundColour;
} }
@@ -1973,7 +1976,7 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
m_foregroundColour = colour; m_foregroundColour = colour;
} }
bool wxWindow::Validate(void) bool wxWindow::Validate()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1988,7 +1991,7 @@ bool wxWindow::Validate(void)
return TRUE; return TRUE;
} }
bool wxWindow::TransferDataToWindow(void) bool wxWindow::TransferDataToWindow()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2007,7 +2010,7 @@ bool wxWindow::TransferDataToWindow(void)
return TRUE; return TRUE;
} }
bool wxWindow::TransferDataFromWindow(void) bool wxWindow::TransferDataFromWindow()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2032,7 +2035,7 @@ void wxWindow::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
TransferDataToWindow(); TransferDataToWindow();
} }
void wxWindow::InitDialog(void) void wxWindow::InitDialog()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2110,7 +2113,7 @@ void wxWindow::DisconnectDnDWidget( GtkWidget *widget )
m_pDropTarget->UnregisterWidget( widget ); m_pDropTarget->UnregisterWidget( widget );
} }
GtkWidget* wxWindow::GetConnectWidget(void) GtkWidget* wxWindow::GetConnectWidget()
{ {
GtkWidget *connect_widget = m_widget; GtkWidget *connect_widget = m_widget;
if (m_wxwindow) connect_widget = m_wxwindow; if (m_wxwindow) connect_widget = m_wxwindow;
@@ -2150,7 +2153,7 @@ void wxWindow::SetFont( const wxFont &font )
gtk_widget_set_style( m_widget, style ); gtk_widget_set_style( m_widget, style );
} }
wxFont *wxWindow::GetFont(void) wxFont *wxWindow::GetFont()
{ {
return &m_font; return &m_font;
} }
@@ -2160,12 +2163,12 @@ void wxWindow::SetWindowStyleFlag( long flag )
m_windowStyle = flag; m_windowStyle = flag;
} }
long wxWindow::GetWindowStyleFlag(void) const long wxWindow::GetWindowStyleFlag() const
{ {
return m_windowStyle; return m_windowStyle;
} }
void wxWindow::CaptureMouse(void) void wxWindow::CaptureMouse()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2182,7 +2185,7 @@ void wxWindow::CaptureMouse(void)
g_capturing = TRUE; g_capturing = TRUE;
} }
void wxWindow::ReleaseMouse(void) void wxWindow::ReleaseMouse()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2198,12 +2201,12 @@ void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
{ {
} }
wxString wxWindow::GetTitle(void) const wxString wxWindow::GetTitle() const
{ {
return (wxString&)m_windowName; return (wxString&)m_windowName;
} }
wxString wxWindow::GetLabel(void) const wxString wxWindow::GetLabel() const
{ {
return GetTitle(); return GetTitle();
} }
@@ -2213,17 +2216,17 @@ void wxWindow::SetName( const wxString &name )
m_windowName = name; m_windowName = name;
} }
wxString wxWindow::GetName(void) const wxString wxWindow::GetName() const
{ {
return (wxString&)m_windowName; return (wxString&)m_windowName;
} }
bool wxWindow::IsShown(void) const bool wxWindow::IsShown() const
{ {
return m_isShown; return m_isShown;
} }
bool wxWindow::IsRetained(void) bool wxWindow::IsRetained()
{ {
return FALSE; return FALSE;
} }
@@ -2442,7 +2445,7 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
// Layout // Layout
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
wxLayoutConstraints *wxWindow::GetConstraints(void) const wxLayoutConstraints *wxWindow::GetConstraints() const
{ {
return m_constraints; return m_constraints;
} }
@@ -2484,12 +2487,12 @@ void wxWindow::SetAutoLayout( bool autoLayout )
m_autoLayout = autoLayout; m_autoLayout = autoLayout;
} }
bool wxWindow::GetAutoLayout(void) const bool wxWindow::GetAutoLayout() const
{ {
return m_autoLayout; return m_autoLayout;
} }
wxSizer *wxWindow::GetSizer(void) const wxSizer *wxWindow::GetSizer() const
{ {
return m_windowSizer; return m_windowSizer;
} }
@@ -2499,7 +2502,7 @@ void wxWindow::SetSizerParent( wxWindow *win )
m_sizerParent = win; m_sizerParent = win;
} }
wxWindow *wxWindow::GetSizerParent(void) const wxWindow *wxWindow::GetSizerParent() const
{ {
return m_sizerParent; return m_sizerParent;
} }
@@ -2547,7 +2550,7 @@ void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
} }
// Reset any constraints that mention this window // Reset any constraints that mention this window
void wxWindow::DeleteRelatedConstraints(void) void wxWindow::DeleteRelatedConstraints()
{ {
if (m_constraintsInvolvedIn) if (m_constraintsInvolvedIn)
{ {
@@ -2589,7 +2592,7 @@ void wxWindow::SetSizer(wxSizer *sizer)
* New version * New version
*/ */
bool wxWindow::Layout(void) bool wxWindow::Layout()
{ {
if (GetConstraints()) if (GetConstraints())
{ {
@@ -2689,7 +2692,7 @@ bool wxWindow::DoPhase(int phase)
return TRUE; return TRUE;
} }
void wxWindow::ResetConstraints(void) void wxWindow::ResetConstraints()
{ {
wxLayoutConstraints *constr = GetConstraints(); wxLayoutConstraints *constr = GetConstraints();
if (constr) if (constr)

View File

@@ -27,9 +27,9 @@ class wxColourRefData: public wxObjectRefData
{ {
public: public:
wxColourRefData(void); wxColourRefData();
~wxColourRefData(void); ~wxColourRefData();
void FreeColour(void); void FreeColour();
GdkColor m_color; GdkColor m_color;
GdkColormap *m_colormap; GdkColormap *m_colormap;
@@ -38,7 +38,7 @@ class wxColourRefData: public wxObjectRefData
friend wxColour; friend wxColour;
}; };
wxColourRefData::wxColourRefData(void) wxColourRefData::wxColourRefData()
{ {
m_color.red = 0; m_color.red = 0;
m_color.green = 0; m_color.green = 0;
@@ -48,12 +48,12 @@ wxColourRefData::wxColourRefData(void)
m_hasPixel = FALSE; m_hasPixel = FALSE;
} }
wxColourRefData::~wxColourRefData(void) wxColourRefData::~wxColourRefData()
{ {
FreeColour(); FreeColour();
} }
void wxColourRefData::FreeColour(void) void wxColourRefData::FreeColour()
{ {
// if (m_hasPixel) gdk_colors_free( m_colormap, &m_color, 1, 0 ); // if (m_hasPixel) gdk_colors_free( m_colormap, &m_color, 1, 0 );
} }
@@ -66,7 +66,7 @@ void wxColourRefData::FreeColour(void)
IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject)
wxColour::wxColour(void) wxColour::wxColour()
{ {
} }
@@ -79,7 +79,7 @@ wxColour::wxColour( char red, char green, char blue )
M_COLDATA->m_color.pixel = 0; M_COLDATA->m_color.pixel = 0;
} }
wxColour::wxColour( const wxString &colourName ) void wxColour::InitFromName( const wxString &colourName )
{ {
wxNode *node = (wxNode *) NULL; wxNode *node = (wxNode *) NULL;
if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) )
@@ -110,7 +110,7 @@ wxColour::wxColour( const wxColour* col )
if (col) Ref( *col ); if (col) Ref( *col );
} }
wxColour::~wxColour(void) wxColour::~wxColour()
{ {
} }
@@ -163,7 +163,7 @@ void wxColour::Set( const unsigned char red, const unsigned char green, const un
M_COLDATA->m_color.pixel = 0; M_COLDATA->m_color.pixel = 0;
} }
unsigned char wxColour::Red(void) const unsigned char wxColour::Red() const
{ {
if (!Ok()) if (!Ok())
{ {
@@ -174,7 +174,7 @@ unsigned char wxColour::Red(void) const
return (unsigned char)(M_COLDATA->m_color.red >> SHIFT); return (unsigned char)(M_COLDATA->m_color.red >> SHIFT);
} }
unsigned char wxColour::Green(void) const unsigned char wxColour::Green() const
{ {
if (!Ok()) if (!Ok())
{ {
@@ -185,7 +185,7 @@ unsigned char wxColour::Green(void) const
return (unsigned char)(M_COLDATA->m_color.green >> SHIFT); return (unsigned char)(M_COLDATA->m_color.green >> SHIFT);
} }
unsigned char wxColour::Blue(void) const unsigned char wxColour::Blue() const
{ {
if (!Ok()) if (!Ok())
{ {
@@ -196,7 +196,7 @@ unsigned char wxColour::Blue(void) const
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
} }
bool wxColour::Ok(void) const bool wxColour::Ok() const
{ {
return (m_refData != NULL); return (m_refData != NULL);
} }
@@ -225,14 +225,14 @@ void wxColour::CalcPixel( GdkColormap *cmap )
M_COLDATA->m_colormap = cmap; M_COLDATA->m_colormap = cmap;
} }
int wxColour::GetPixel(void) int wxColour::GetPixel() const
{ {
if (!Ok()) return 0; if (!Ok()) return 0;
return M_COLDATA->m_color.pixel; return M_COLDATA->m_color.pixel;
} }
GdkColor *wxColour::GetColor(void) GdkColor *wxColour::GetColor() const
{ {
if (!Ok()) return (GdkColor *) NULL; if (!Ok()) return (GdkColor *) NULL;

View File

@@ -445,4 +445,10 @@ bool wxListBox::IsOwnGtkWindow( GdkWindow *window )
return FALSE; return FALSE;
} }
void wxListBox::SetBackgroundColour(const wxColour &colour)
{
wxCHECK_RET( m_list != NULL, "invalid list ctrl" );
SetBackgroundColourHelper( colour, GTK_WIDGET(m_list)->window );
}

View File

@@ -115,7 +115,8 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
m_widget = gtk_handle_box_new(); m_widget = gtk_handle_box_new();
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS ) ); m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL,
GTK_TOOLBAR_ICONS ) );
gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE );
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) );
@@ -184,18 +185,18 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
GdkPixmap *pixmap = bitmap.GetPixmap(); GdkPixmap *pixmap = bitmap.GetPixmap();
GdkBitmap *mask = (GdkBitmap *)NULL; GdkBitmap *mask = (GdkBitmap *)NULL;
if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap(); if ( bitmap.GetMask() )
mask = bitmap.GetMask()->GetBitmap();
tool_pixmap = gtk_pixmap_new( pixmap, mask ); tool_pixmap = gtk_pixmap_new( pixmap, mask );
} }
gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 ); gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 );
#if 0
GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON GtkToolbarChildType ctype = toggle ? GTK_TOOLBAR_CHILD_TOGGLEBUTTON
: GTK_TOOLBAR_CHILD_BUTTON; : GTK_TOOLBAR_CHILD_BUTTON;
tool->m_item = gtk_toolbar_append_element GtkWidget *item = gtk_toolbar_append_element
( (
GTK_TOOLBAR(m_toolbar), GTK_TOOLBAR(m_toolbar),
ctype, ctype,
@@ -208,22 +209,18 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
(gpointer)tool (gpointer)tool
); );
// VZ: we don't want GDK_NO_EXPOSE events because for some reason our
// toolbar buttons get them (it doesn't happen in a standalone GTK+ program
// for unknown reasons) and it prevents tooltips from appearing.
gtk_widget_set_events( GTK_WIDGET(item),
gtk_widget_get_events( GTK_WIDGET(item) ) &
~GDK_EXPOSURE_MASK);
tool->m_item = item;
gtk_signal_connect( GTK_OBJECT(tool->m_item), gtk_signal_connect( GTK_OBJECT(tool->m_item),
"enter_notify_event", "enter_notify_event",
GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback), GTK_SIGNAL_FUNC(gtk_toolbar_enter_callback),
(gpointer)tool ); (gpointer)tool );
#else
tool->m_item = gtk_toolbar_append_item
(
GTK_TOOLBAR(m_toolbar),
(const char *)NULL,
helpString1,
"",
tool_pixmap,
(GtkSignalFunc)gtk_toolbar_callback,
(gpointer)tool
);
#endif
m_tools.Append( tool ); m_tools.Append( tool );

View File

@@ -464,4 +464,12 @@ void wxTextCtrl::SetFont( const wxFont &font )
gtk_widget_set_style( m_text, style ); 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 );
}

View File

@@ -1021,7 +1021,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
return TRUE; return TRUE;
} }
wxWindow::~wxWindow(void) wxWindow::~wxWindow()
{ {
m_hasVMT = FALSE; m_hasVMT = FALSE;
@@ -1113,7 +1113,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_hasOwnStyle = FALSE; m_hasOwnStyle = FALSE;
} }
void wxWindow::PostCreation(void) void wxWindow::PostCreation()
{ {
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );
@@ -1168,7 +1168,7 @@ void wxWindow::ConnectWidget( GtkWidget *widget )
GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this );
} }
bool wxWindow::HasVMT(void) bool wxWindow::HasVMT()
{ {
return m_hasVMT; return m_hasVMT;
} }
@@ -1184,7 +1184,7 @@ bool wxWindow::Close( bool force )
return GetEventHandler()->ProcessEvent(event); return GetEventHandler()->ProcessEvent(event);
} }
bool wxWindow::Destroy(void) bool wxWindow::Destroy()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1193,7 +1193,7 @@ bool wxWindow::Destroy(void)
return TRUE; return TRUE;
} }
bool wxWindow::DestroyChildren(void) bool wxWindow::DestroyChildren()
{ {
if (GetChildren()) if (GetChildren())
{ {
@@ -1216,7 +1216,7 @@ void wxWindow::PrepareDC( wxDC &WXUNUSED(dc) )
// are we to set fonts here ? // are we to set fonts here ?
} }
void wxWindow::ImplementSetSize(void) void wxWindow::ImplementSetSize()
{ {
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
@@ -1225,7 +1225,7 @@ void wxWindow::ImplementSetSize(void)
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
} }
void wxWindow::ImplementSetPosition(void) void wxWindow::ImplementSetPosition()
{ {
if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog)) if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog))
{ {
@@ -1523,7 +1523,7 @@ void wxWindow::Centre( int direction )
} }
} }
void wxWindow::Fit(void) void wxWindow::Fit()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1582,7 +1582,7 @@ void wxWindow::Enable( bool enable )
if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable ); if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
} }
int wxWindow::GetCharHeight(void) const int wxWindow::GetCharHeight() const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1596,7 +1596,7 @@ int wxWindow::GetCharHeight(void) const
return font->ascent + font->descent; return font->ascent + font->descent;
} }
int wxWindow::GetCharWidth(void) const int wxWindow::GetCharWidth() const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1650,7 +1650,7 @@ void wxWindow::MakeModal( bool modal )
} }
} }
void wxWindow::SetFocus(void) void wxWindow::SetFocus()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1664,7 +1664,7 @@ void wxWindow::SetFocus(void)
} }
} }
bool wxWindow::OnClose(void) bool wxWindow::OnClose()
{ {
return TRUE; return TRUE;
} }
@@ -1740,7 +1740,7 @@ void wxWindow::AddChild( wxWindow *child )
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height ); gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
} }
wxList *wxWindow::GetChildren(void) wxList *wxWindow::GetChildren()
{ {
return (&m_children); return (&m_children);
} }
@@ -1757,26 +1757,26 @@ void wxWindow::SetReturnCode( int retCode )
m_retCode = retCode; m_retCode = retCode;
} }
int wxWindow::GetReturnCode(void) int wxWindow::GetReturnCode()
{ {
return m_retCode; return m_retCode;
} }
void wxWindow::Raise(void) void wxWindow::Raise()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_raise( m_widget->window ); if (m_widget) gdk_window_raise( m_widget->window );
} }
void wxWindow::Lower(void) void wxWindow::Lower()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_lower( m_widget->window ); if (m_widget) gdk_window_lower( m_widget->window );
} }
wxEvtHandler *wxWindow::GetEventHandler(void) wxEvtHandler *wxWindow::GetEventHandler()
{ {
return m_eventHandler; return m_eventHandler;
} }
@@ -1812,7 +1812,7 @@ wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
return (wxEvtHandler *) NULL; return (wxEvtHandler *) NULL;
} }
wxValidator *wxWindow::GetValidator(void) wxValidator *wxWindow::GetValidator()
{ {
return m_windowValidator; return m_windowValidator;
} }
@@ -1824,7 +1824,7 @@ void wxWindow::SetValidator( const wxValidator& validator )
if (m_windowValidator) m_windowValidator->SetWindow(this); if (m_windowValidator) m_windowValidator->SetWindow(this);
} }
bool wxWindow::IsBeingDeleted(void) bool wxWindow::IsBeingDeleted()
{ {
return FALSE; return FALSE;
} }
@@ -1834,7 +1834,7 @@ void wxWindow::SetId( wxWindowID id )
m_windowId = id; m_windowId = id;
} }
wxWindowID wxWindow::GetId(void) wxWindowID wxWindow::GetId()
{ {
return m_windowId; return m_windowId;
} }
@@ -1937,33 +1937,36 @@ bool wxWindow::IsExposed( const wxRect& rect ) const
return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion ); return (m_updateRegion.Contains( rect.x, rect.y, rect.width, rect.height ) != wxOutRegion );
} }
void wxWindow::Clear(void) void wxWindow::Clear()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window ); if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
} }
wxColour wxWindow::GetBackgroundColour(void) const wxColour wxWindow::GetBackgroundColour() const
{ {
return m_backgroundColour; return m_backgroundColour;
} }
void wxWindow::SetBackgroundColourHelper(const wxColour& colour,
GdkWindow *window)
{
m_backgroundColour = colour;
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 ) void wxWindow::SetBackgroundColour( const wxColour &colour )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( m_widget != NULL, "invalid window" );
m_backgroundColour = colour; GtkWidget *widget = m_wxwindow == NULL ? m_widget : m_wxwindow;
if (m_wxwindow) SetBackgroundColourHelper( colour, widget->window );
{
m_backgroundColour.CalcPixel( m_wxwindow->style->colormap );
gdk_window_set_background( m_wxwindow->window, m_backgroundColour.GetColor() );
gdk_window_clear( m_wxwindow->window );
}
// do something ?
} }
wxColour wxWindow::GetForegroundColour(void) const wxColour wxWindow::GetForegroundColour() const
{ {
return m_foregroundColour; return m_foregroundColour;
} }
@@ -1973,7 +1976,7 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
m_foregroundColour = colour; m_foregroundColour = colour;
} }
bool wxWindow::Validate(void) bool wxWindow::Validate()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -1988,7 +1991,7 @@ bool wxWindow::Validate(void)
return TRUE; return TRUE;
} }
bool wxWindow::TransferDataToWindow(void) bool wxWindow::TransferDataToWindow()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2007,7 +2010,7 @@ bool wxWindow::TransferDataToWindow(void)
return TRUE; return TRUE;
} }
bool wxWindow::TransferDataFromWindow(void) bool wxWindow::TransferDataFromWindow()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2032,7 +2035,7 @@ void wxWindow::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
TransferDataToWindow(); TransferDataToWindow();
} }
void wxWindow::InitDialog(void) void wxWindow::InitDialog()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2110,7 +2113,7 @@ void wxWindow::DisconnectDnDWidget( GtkWidget *widget )
m_pDropTarget->UnregisterWidget( widget ); m_pDropTarget->UnregisterWidget( widget );
} }
GtkWidget* wxWindow::GetConnectWidget(void) GtkWidget* wxWindow::GetConnectWidget()
{ {
GtkWidget *connect_widget = m_widget; GtkWidget *connect_widget = m_widget;
if (m_wxwindow) connect_widget = m_wxwindow; if (m_wxwindow) connect_widget = m_wxwindow;
@@ -2150,7 +2153,7 @@ void wxWindow::SetFont( const wxFont &font )
gtk_widget_set_style( m_widget, style ); gtk_widget_set_style( m_widget, style );
} }
wxFont *wxWindow::GetFont(void) wxFont *wxWindow::GetFont()
{ {
return &m_font; return &m_font;
} }
@@ -2160,12 +2163,12 @@ void wxWindow::SetWindowStyleFlag( long flag )
m_windowStyle = flag; m_windowStyle = flag;
} }
long wxWindow::GetWindowStyleFlag(void) const long wxWindow::GetWindowStyleFlag() const
{ {
return m_windowStyle; return m_windowStyle;
} }
void wxWindow::CaptureMouse(void) void wxWindow::CaptureMouse()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2182,7 +2185,7 @@ void wxWindow::CaptureMouse(void)
g_capturing = TRUE; g_capturing = TRUE;
} }
void wxWindow::ReleaseMouse(void) void wxWindow::ReleaseMouse()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
@@ -2198,12 +2201,12 @@ void wxWindow::SetTitle( const wxString &WXUNUSED(title) )
{ {
} }
wxString wxWindow::GetTitle(void) const wxString wxWindow::GetTitle() const
{ {
return (wxString&)m_windowName; return (wxString&)m_windowName;
} }
wxString wxWindow::GetLabel(void) const wxString wxWindow::GetLabel() const
{ {
return GetTitle(); return GetTitle();
} }
@@ -2213,17 +2216,17 @@ void wxWindow::SetName( const wxString &name )
m_windowName = name; m_windowName = name;
} }
wxString wxWindow::GetName(void) const wxString wxWindow::GetName() const
{ {
return (wxString&)m_windowName; return (wxString&)m_windowName;
} }
bool wxWindow::IsShown(void) const bool wxWindow::IsShown() const
{ {
return m_isShown; return m_isShown;
} }
bool wxWindow::IsRetained(void) bool wxWindow::IsRetained()
{ {
return FALSE; return FALSE;
} }
@@ -2442,7 +2445,7 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
// Layout // Layout
//------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------
wxLayoutConstraints *wxWindow::GetConstraints(void) const wxLayoutConstraints *wxWindow::GetConstraints() const
{ {
return m_constraints; return m_constraints;
} }
@@ -2484,12 +2487,12 @@ void wxWindow::SetAutoLayout( bool autoLayout )
m_autoLayout = autoLayout; m_autoLayout = autoLayout;
} }
bool wxWindow::GetAutoLayout(void) const bool wxWindow::GetAutoLayout() const
{ {
return m_autoLayout; return m_autoLayout;
} }
wxSizer *wxWindow::GetSizer(void) const wxSizer *wxWindow::GetSizer() const
{ {
return m_windowSizer; return m_windowSizer;
} }
@@ -2499,7 +2502,7 @@ void wxWindow::SetSizerParent( wxWindow *win )
m_sizerParent = win; m_sizerParent = win;
} }
wxWindow *wxWindow::GetSizerParent(void) const wxWindow *wxWindow::GetSizerParent() const
{ {
return m_sizerParent; return m_sizerParent;
} }
@@ -2547,7 +2550,7 @@ void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
} }
// Reset any constraints that mention this window // Reset any constraints that mention this window
void wxWindow::DeleteRelatedConstraints(void) void wxWindow::DeleteRelatedConstraints()
{ {
if (m_constraintsInvolvedIn) if (m_constraintsInvolvedIn)
{ {
@@ -2589,7 +2592,7 @@ void wxWindow::SetSizer(wxSizer *sizer)
* New version * New version
*/ */
bool wxWindow::Layout(void) bool wxWindow::Layout()
{ {
if (GetConstraints()) if (GetConstraints())
{ {
@@ -2689,7 +2692,7 @@ bool wxWindow::DoPhase(int phase)
return TRUE; return TRUE;
} }
void wxWindow::ResetConstraints(void) void wxWindow::ResetConstraints()
{ {
wxLayoutConstraints *constr = GetConstraints(); wxLayoutConstraints *constr = GetConstraints();
if (constr) if (constr)

View File

@@ -31,7 +31,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
// Colour // Colour
wxColour::wxColour (void) wxColour::wxColour ()
{ {
m_isInit = FALSE; m_isInit = FALSE;
m_pixel = 0; m_pixel = 0;
@@ -66,7 +66,7 @@ wxColour& wxColour::operator =(const wxColour& col)
return *this; return *this;
} }
wxColour::wxColour (const wxString& col) void wxColour::InitFromName(const wxString& col)
{ {
wxColour *the_colour = wxTheColourDatabase->FindColour (col); wxColour *the_colour = wxTheColourDatabase->FindColour (col);
if (the_colour) if (the_colour)
@@ -86,7 +86,7 @@ wxColour::wxColour (const wxString& col)
m_pixel = PALETTERGB (m_red, m_green, m_blue); m_pixel = PALETTERGB (m_red, m_green, m_blue);
} }
wxColour::~wxColour (void) wxColour::~wxColour()
{ {
} }