Updates to memcheck

Corrected and beautified memory (output)
  Fixed a few memory leaks
  Fixed resizing in in wxRadioBox
  Added many wxFAIL and wxASSERT
  Corrected other wxFAIL (removed from ..::Ok())
  Added wxBrush::Set..() functions
  Added CopyOnWrite support in GDI objects (Unshare)
  Disabled all occurences of WXDEBUG_NEW
  made clean, recompiled with mem_chcking on


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@728 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-09-11 09:05:26 +00:00
parent 384b4373c7
commit e55ad60e19
46 changed files with 1087 additions and 379 deletions

View File

@@ -24,24 +24,13 @@ class wxAccelRefData: public wxObjectRefData
public:
wxAccelRefData(void);
~wxAccelRefData(void);
wxList m_accels;
};
wxAccelRefData::wxAccelRefData(void)
{
}
wxAccelRefData::~wxAccelRefData(void)
{
wxNode *node = m_accels.First();
while (node)
{
wxAcceleratorEntry *entry = (wxAcceleratorEntry *)node->Data();
delete entry;
node = node->Next();
}
m_accels.DeleteContents( TRUE );
}
//-----------------------------------------------------------------------------
@@ -52,7 +41,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable,wxObject)
wxAcceleratorTable::wxAcceleratorTable()
{
m_refData = new wxAccelRefData();
}
wxAcceleratorTable::wxAcceleratorTable( int n, wxAcceleratorEntry entries[] )
@@ -64,7 +52,7 @@ wxAcceleratorTable::wxAcceleratorTable( int n, wxAcceleratorEntry entries[] )
int keycode = entries[i].GetKeyCode();
int command = entries[i].GetCommand();
if ((keycode >= (int)'A') && (keycode <= (int)'Z')) keycode = (int)tolower( (char)keycode );
M_ACCELDATA->m_accels.Append( (wxObject*) new wxAcceleratorEntry( flag, keycode, command ) );
M_ACCELDATA->m_accels.Append( new wxAcceleratorEntry( flag, keycode, command ) );
}
}
@@ -79,6 +67,8 @@ bool wxAcceleratorTable::Ok() const
int wxAcceleratorTable::GetCommand( wxKeyEvent &event )
{
if (!Ok()) return -1;
wxNode *node = M_ACCELDATA->m_accels.First();
while (node)
{

View File

@@ -293,8 +293,6 @@ void wxApp::CommonCleanUp(void)
wxCleanUpResourceSystem();
wxSystemSettings::Done();
wxClassInfo::CleanUpClasses();
}
wxLog *wxApp::CreateLogTarget()
@@ -314,11 +312,7 @@ int wxEntry( int argc, char *argv[] )
#if (WXDEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT
#if !defined(_WINDLL)
streambuf* sBuf = new wxDebugStreamBuf;
#else
streambuf* sBuf = NULL;
#endif
ostream* oStr = new ostream(sBuf) ;
wxDebugContext::SetStream(oStr, sBuf);
@@ -348,6 +342,12 @@ int wxEntry( int argc, char *argv[] )
wxTheApp->argc = argc;
wxTheApp->argv = argv;
char name[200];
strcpy( name, argv[0] );
strcpy( name, wxFileNameFromPath(name) );
wxStripExtension( name );
wxTheApp->SetAppName( name );
gtk_set_locale();
gtk_init( &argc, &argv );
@@ -386,11 +386,15 @@ int wxEntry( int argc, char *argv[] )
wxDELETE(wxTheApp);
wxLog *oldLog = wxLog::SetActiveTarget( NULL );
if (oldLog) delete oldLog;
wxClassInfo::CleanUpClasses();
delete[] wxBuffer;
#if (WXDEBUG && USE_MEMORY_TRACING) || USE_DEBUG_CONTEXT
// At this point we want to check if there are any memory
// blocks that aren't part of the wxDebugContext itself,
// as a special case. Then when dumping we need to ignore
// wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft() > 0)
{
wxTrace("There were memory leaks.\n");
@@ -398,6 +402,7 @@ int wxEntry( int argc, char *argv[] )
wxDebugContext::PrintStatistics();
}
wxDebugContext::SetStream(NULL, NULL);
#endif
return retValue;

View File

@@ -228,25 +228,39 @@ bool wxBitmap::operator != ( const wxBitmap& bmp )
bool wxBitmap::Ok(void) const
{
wxASSERT_MSG( m_refData != NULL, "invalid bitmap" );
return (m_refData != NULL);
}
int wxBitmap::GetHeight(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return -1;
}
return M_BMPDATA->m_height;
}
int wxBitmap::GetWidth(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return -1;
}
return M_BMPDATA->m_width;
}
int wxBitmap::GetDepth(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return -1;
}
return M_BMPDATA->m_bpp;
}
@@ -279,14 +293,22 @@ void wxBitmap::SetDepth( int depth )
wxMask *wxBitmap::GetMask(void) const
{
if (!Ok()) return (wxMask *) NULL;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return (wxMask *) NULL;
}
return M_BMPDATA->m_mask;
}
void wxBitmap::SetMask( wxMask *mask )
{
if (!Ok()) return;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
@@ -295,11 +317,19 @@ void wxBitmap::SetMask( wxMask *mask )
void wxBitmap::Resize( int height, int width )
{
if (!Ok()) return;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
#ifdef USE_GDK_IMLIB
if (M_BMPDATA->m_bitmap) return; // not supported for bitmaps
if (M_BMPDATA->m_bitmap)
{
wxFAIL_MSG( "wxBitmap::Resize not supported for mono-bitmaps" );
return;
}
if (!M_BMPDATA->m_image) RecreateImage();
@@ -324,9 +354,19 @@ void wxBitmap::Resize( int height, int width )
bool wxBitmap::SaveFile( const wxString &name, int WXUNUSED(type),
wxPalette *WXUNUSED(palette) )
{
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return FALSE;
}
#ifdef USE_GDK_IMLIB
if (!Ok()) return FALSE;
if (M_BMPDATA->m_bitmap)
{
wxFAIL_MSG( "wxBitmap::SaveFile not supported for mono-bitmaps" );
return FALSE;
}
if (!M_BMPDATA->m_image) RecreateImage();
@@ -380,7 +420,11 @@ wxPalette *wxBitmap::GetPalette(void) const
GdkPixmap *wxBitmap::GetPixmap(void) const
{
if (!Ok()) return (GdkPixmap *) NULL;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return (GdkPixmap *) NULL;
}
// if (!M_BMPDATA->m_image) RecreateImage();
@@ -389,14 +433,22 @@ GdkPixmap *wxBitmap::GetPixmap(void) const
GdkBitmap *wxBitmap::GetBitmap(void) const
{
if (!Ok()) return (GdkBitmap *) NULL;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return (GdkBitmap *) NULL;
}
return M_BMPDATA->m_bitmap;
}
void wxBitmap::DestroyImage(void)
{
if (!Ok()) return;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
if (M_BMPDATA->m_image)
{
@@ -407,7 +459,11 @@ void wxBitmap::DestroyImage(void)
void wxBitmap::RecreateImage(void)
{
if (!Ok()) return;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
#ifdef USE_GDK_IMLIB
@@ -458,7 +514,11 @@ void wxBitmap::RecreateImage(void)
void wxBitmap::Render(void)
{
if (!Ok()) return;
if (!Ok())
{
wxFAIL_MSG( "invalid bitmap" );
return;
}
#ifdef USE_GDK_IMLIB

View File

@@ -23,7 +23,8 @@ class wxBrushRefData: public wxObjectRefData
public:
wxBrushRefData(void);
wxBrushRefData( const wxBrushRefData& data );
int m_style;
wxBitmap m_stipple;
wxColour m_colour;
@@ -34,6 +35,13 @@ wxBrushRefData::wxBrushRefData(void)
m_style = 0;
}
wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
}
//-----------------------------------------------------------------------------
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
@@ -116,17 +124,78 @@ bool wxBrush::Ok(void) const
int wxBrush::GetStyle(void) const
{
if (m_refData == NULL)
{
wxFAIL_MSG( "invalid brush" );
return 0;
}
return M_BRUSHDATA->m_style;
}
wxColour &wxBrush::GetColour(void) const
{
if (m_refData == NULL)
{
wxFAIL_MSG( "invalid brush" );
return wxNullColour;
}
return M_BRUSHDATA->m_colour;
}
wxBitmap *wxBrush::GetStipple(void) const
{
if (m_refData == NULL)
{
wxFAIL_MSG( "invalid brush" );
return &wxNullBitmap;
}
return &M_BRUSHDATA->m_stipple;
}
void wxBrush::SetColour( const wxColour& col )
{
Unshare();
M_BRUSHDATA->m_colour = col;
}
void wxBrush::SetColour( const wxString& col )
{
Unshare();
M_BRUSHDATA->m_colour = col;
}
void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
{
Unshare();
M_BRUSHDATA->m_colour.Set( r, g, b );
}
void wxBrush::SetStyle( int style )
{
Unshare();
M_BRUSHDATA->m_style = style;
}
void wxBrush::SetStipple( const wxBitmap& stipple )
{
Unshare();
M_BRUSHDATA->m_stipple = stipple;
}
void wxBrush::Unshare(void)
{
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
wxBrushRefData* ref = new wxBrushRefData( *(wxBrushRefData*)m_refData );
UnRef();
m_refData = ref;
}
}

View File

@@ -165,25 +165,40 @@ void wxColour::Set( const unsigned char red, const unsigned char green, const un
unsigned char wxColour::Red(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid colour" );
return 0;
}
return (unsigned char)(M_COLDATA->m_color.red >> SHIFT);
}
unsigned char wxColour::Green(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid colour" );
return 0;
}
return (unsigned char)(M_COLDATA->m_color.green >> SHIFT);
}
unsigned char wxColour::Blue(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid colour" );
return 0;
}
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
}
bool wxColour::Ok(void) const
{
return (m_refData);
return (m_refData != NULL);
}
void wxColour::CalcPixel( GdkColormap *cmap )

View File

@@ -179,25 +179,27 @@ bool wxFont::operator != ( const wxFont& font )
bool wxFont::Ok() const
{
if (!m_refData)
{
wxFAIL_MSG( "invalid font" );
return FALSE;
}
else
return TRUE;
return (m_refData != NULL);
}
int wxFont::GetPointSize(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return 0;
}
return M_FONTDATA->m_pointSize;
}
wxString wxFont::GetFaceString(void) const
{
if (!Ok()) return "";
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return "";
}
wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId );
return s;
@@ -205,7 +207,11 @@ wxString wxFont::GetFaceString(void) const
wxString wxFont::GetFaceName(void) const
{
if (!Ok()) return "";
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return "";
}
wxString s = wxTheFontNameDirectory->GetFontName( M_FONTDATA->m_fontId );
return s;
@@ -213,14 +219,22 @@ wxString wxFont::GetFaceName(void) const
int wxFont::GetFamily(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return 0;
}
return M_FONTDATA->m_family;
}
wxString wxFont::GetFamilyString(void) const
{
if (!Ok()) return "wxDEFAULT";
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return "wxDEFAULT";
}
switch (M_FONTDATA->m_family)
{
@@ -238,21 +252,33 @@ wxString wxFont::GetFamilyString(void) const
int wxFont::GetFontId(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return 0;
}
return M_FONTDATA->m_fontId; // stub
}
int wxFont::GetStyle(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return 0;
}
return M_FONTDATA->m_style;
}
wxString wxFont::GetStyleString(void) const
{
if (!Ok()) return "wxDEFAULT";
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return "wxDEFAULT";
}
switch (M_FONTDATA->m_style)
{
@@ -267,14 +293,22 @@ wxString wxFont::GetStyleString(void) const
int wxFont::GetWeight(void) const
{
if (!Ok()) return 0;
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return 0;
}
return M_FONTDATA->m_weight;
}
wxString wxFont::GetWeightString(void) const
{
if (!Ok()) return "wxDEFAULT";
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return "wxDEFAULT";
}
switch (M_FONTDATA->m_weight)
{
@@ -289,7 +323,11 @@ wxString wxFont::GetWeightString(void) const
bool wxFont::GetUnderlined(void) const
{
if (!Ok()) return FALSE;
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return FALSE;
}
return M_FONTDATA->m_underlined;
}
@@ -305,6 +343,12 @@ static GdkFont *wxLoadQueryNearestFont(int point_size, int fontid,
GdkFont *wxFont::GetInternalFont(float scale) const
{
if (!Ok())
{
wxFAIL_MSG( "invalid font" );
return (GdkFont*) NULL;
}
if (M_FONTDATA->m_byXFontName) return M_FONTDATA->m_font;
long int_scale = long(scale * 100.0 + 0.5); // key for fontlist

View File

@@ -190,6 +190,8 @@ wxFrame::~wxFrame()
bool wxFrame::Show( bool show )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (show)
{
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
@@ -201,20 +203,23 @@ bool wxFrame::Show( bool show )
void wxFrame::Enable( bool enable )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!m_mainWindow) return;
wxWindow::Enable( enable );
gtk_widget_set_sensitive( m_mainWindow, enable );
}
void wxFrame::OnCloseWindow( wxCloseEvent &event )
{
if ( GetEventHandler()->OnClose() || event.GetForce())
{
this->Destroy();
}
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
}
bool wxFrame::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
@@ -229,6 +234,8 @@ void wxFrame::ImplementSetPosition(void)
void wxFrame::Centre( int direction )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition();
@@ -236,6 +243,8 @@ void wxFrame::Centre( int direction )
void wxFrame::GetClientSize( int *width, int *height ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxWindow::GetClientSize( width, height );
if (height)
{
@@ -252,6 +261,8 @@ void wxFrame::GetClientSize( int *width, int *height ) const
void wxFrame::SetClientSize( int const width, int const height )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
int h = height;
if (m_frameMenuBar) h += wxMENU_HEIGHT;
if (m_frameStatusBar) h += wxSTATUS_HEIGHT;
@@ -342,6 +353,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if ( GetAutoLayout() )
Layout();
else {
@@ -378,6 +391,12 @@ void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
void wxFrame::AddChild( wxWindow *child )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
wxASSERT_MSG( (child != NULL), "invalid child" );
wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
// wxFrame and wxDialog as children aren't placed into the parents
if (IS_KIND_OF(child,wxMDIChildFrame)) wxFAIL_MSG( "wxFrame::AddChild error.\n" );
@@ -424,6 +443,10 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
void wxFrame::SetMenuBar( wxMenuBar *menuBar )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxASSERT_MSG( (m_wxwindow != NULL), "invalid frame" );
wxASSERT_MSG( (m_mainWindow != NULL), "invalid frame" );
m_frameMenuBar = menuBar;
if (m_frameMenuBar)
@@ -452,6 +475,8 @@ wxMenuBar *wxFrame::GetMenuBar(void) const
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxCHECK_MSG( m_frameToolBar == NULL, FALSE, "recreating toolbar in wxFrame" );
m_addPrivateChild = TRUE;
@@ -473,6 +498,8 @@ wxToolBar *wxFrame::GetToolBar(void) const
wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxCHECK_MSG( m_frameStatusBar == NULL, FALSE, "recreating status bar in wxFrame" );
m_frameStatusBar = OnCreateStatusBar( number, style, id, name );
@@ -503,6 +530,8 @@ wxStatusBar *wxFrame::OnCreateStatusBar( int number, long style, wxWindowID id,
void wxFrame::SetStatusText(const wxString& text, int number)
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
m_frameStatusBar->SetStatusText(text, number);
@@ -510,6 +539,8 @@ void wxFrame::SetStatusText(const wxString& text, int number)
void wxFrame::SetStatusWidths(int n, const int widths_field[] )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
m_frameStatusBar->SetStatusWidths(n, widths_field);
@@ -522,6 +553,8 @@ wxStatusBar *wxFrame::GetStatusBar(void) const
void wxFrame::SetTitle( const wxString &title )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
m_title = title;
if (m_title.IsNull()) m_title = "";
gtk_window_set_title( GTK_WINDOW(m_widget), title );
@@ -529,6 +562,8 @@ void wxFrame::SetTitle( const wxString &title )
void wxFrame::SetIcon( const wxIcon &icon )
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
m_icon = icon;
if (!icon.Ok()) return;

View File

@@ -40,6 +40,15 @@ wxPenRefData::wxPenRefData(void)
m_capStyle = wxCAP_ROUND;
}
wxPenRefData::wxPenRefData( const wxPenRefData& data )
{
m_style = data.m_style;
m_width = data.m_width;
m_joinStyle = data.m_joinStyle;
m_capStyle = data.m_capStyle;
m_colour = data.m_colour;
}
//-----------------------------------------------------------------------------
#define M_PENDATA ((wxPenRefData *)m_refData)
@@ -109,99 +118,117 @@ bool wxPen::operator != ( const wxPen& pen )
void wxPen::SetColour( const wxColour &colour )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_colour = colour;
}
void wxPen::SetColour( const wxString &colourName )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_colour = colourName;
}
void wxPen::SetColour( int red, int green, int blue )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_colour.Set( red, green, blue );
}
void wxPen::SetCap( int capStyle )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_capStyle = capStyle;
}
void wxPen::SetJoin( int joinStyle )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_joinStyle = joinStyle;
}
void wxPen::SetStyle( int style )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_style = style;
}
void wxPen::SetWidth( int width )
{
if (!m_refData)
m_refData = new wxPenRefData();
Unshare();
M_PENDATA->m_width = width;
}
int wxPen::GetCap(void) const
{
if (!m_refData)
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_capStyle;
}
int wxPen::GetJoin(void) const
{
if (!m_refData)
return 0;
else
return M_PENDATA->m_joinStyle;
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_joinStyle;
}
int wxPen::GetStyle(void) const
{
if (!m_refData)
return 0;
else
return M_PENDATA->m_style;
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_style;
}
int wxPen::GetWidth(void) const
{
if (!m_refData)
return 0;
else
return M_PENDATA->m_width;
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_width;
}
wxColour &wxPen::GetColour(void) const
{
if (!m_refData)
{
wxFAIL_MSG( "invalid pen" );
return wxNullColour;
else
return M_PENDATA->m_colour;
}
return M_PENDATA->m_colour;
}
bool wxPen::Ok(void) const
{
return (m_refData);
return (m_refData != NULL);
}
void wxPen::Unshare(void)
{
if (!m_refData)
{
m_refData = new wxPenRefData();
}
else
{
wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData );
UnRef();
m_refData = ref;
}
}

View File

@@ -158,6 +158,10 @@ void wxRadioBox::OnSize( wxSizeEvent &event )
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, x, y );
y += 20;
int w = m_width-10;
if (w < 15) w = 15;
gtk_widget_set_usize( button, w, 20 );
node = node->Next();
}
}

View File

@@ -1123,6 +1123,8 @@ bool wxWindow::HasVMT(void)
bool wxWindow::Close( bool force )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
event.SetEventObject(this);
event.SetForce(force);
@@ -1132,6 +1134,8 @@ bool wxWindow::Close( bool force )
bool wxWindow::Destroy(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
m_hasVMT = FALSE;
delete this;
return TRUE;
@@ -1192,6 +1196,8 @@ void wxWindow::ImplementSetPosition(void)
void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
@@ -1251,12 +1257,16 @@ void wxWindow::Move( int x, int y )
void wxWindow::GetSize( int *width, int *height ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (width) (*width) = m_width;
if (height) (*height) = m_height;
}
void wxWindow::SetClientSize( int width, int height )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (!m_wxwindow)
{
SetSize( width, height );
@@ -1314,6 +1324,8 @@ void wxWindow::SetClientSize( int width, int height )
void wxWindow::GetClientSize( int *width, int *height ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (!m_wxwindow)
{
if (width) (*width) = m_width;
@@ -1375,12 +1387,16 @@ void wxWindow::GetClientSize( int *width, int *height ) const
void wxWindow::GetPosition( int *x, int *y ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (x) (*x) = m_x;
if (y) (*y) = m_y;
}
void wxWindow::ClientToScreen( int *x, int *y )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
@@ -1406,6 +1422,8 @@ void wxWindow::ClientToScreen( int *x, int *y )
void wxWindow::ScreenToClient( int *x, int *y )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
GdkWindow *source = (GdkWindow *) NULL;
if (m_wxwindow)
source = m_wxwindow->window;
@@ -1431,6 +1449,8 @@ void wxWindow::ScreenToClient( int *x, int *y )
void wxWindow::Centre( int direction )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame))
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
@@ -1453,6 +1473,8 @@ void wxWindow::Centre( int direction )
void wxWindow::Fit(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
int maxX = 0;
int maxY = 0;
wxNode *node = GetChildren()->First();
@@ -1474,6 +1496,8 @@ void wxWindow::Fit(void)
void wxWindow::SetSizeHints( int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH) )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
m_minWidth = minW;
m_minHeight = minH;
m_maxWidth = maxW;
@@ -1487,6 +1511,8 @@ void wxWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
bool wxWindow::Show( bool show )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (show)
gtk_widget_show( m_widget );
else
@@ -1497,6 +1523,8 @@ bool wxWindow::Show( bool show )
void wxWindow::Enable( bool enable )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
m_isEnabled = enable;
gtk_widget_set_sensitive( m_widget, enable );
if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
@@ -1504,12 +1532,28 @@ void wxWindow::Enable( bool enable )
int wxWindow::GetCharHeight(void) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (!m_font.Ok())
{
wxFAIL_MSG( "invalid font" );
return -1;
}
GdkFont *font = m_font.GetInternalFont( 1.0 );
return font->ascent + font->descent;
}
int wxWindow::GetCharWidth(void) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (!m_font.Ok())
{
wxFAIL_MSG( "invalid font" );
return -1;
}
GdkFont *font = m_font.GetInternalFont( 1.0 );
return gdk_string_width( font, "H" );
}
@@ -1517,9 +1561,18 @@ int wxWindow::GetCharWidth(void) const
void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxFont fontToUse = m_font;
if (theFont) fontToUse = *theFont;
if (!fontToUse.Ok())
{
wxFAIL_MSG( "invalid font" );
return;
}
wxASSERT_MSG( (m_font.Ok()), "invalid font" );
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
if (x) (*x) = gdk_string_width( font, string );
if (y) (*y) = font->ascent + font->descent;
@@ -1547,6 +1600,8 @@ void wxWindow::MakeModal( bool modal )
void wxWindow::SetFocus(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget)
{
@@ -1564,6 +1619,11 @@ bool wxWindow::OnClose(void)
void wxWindow::AddChild( wxWindow *child )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window need client area" );
wxASSERT_MSG( (child != NULL), "invalid child" );
wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
// Addchild is (often) called before the program
// has left the parents constructor so that no
// virtual tables work yet. The approach below
@@ -1636,7 +1696,7 @@ wxList *wxWindow::GetChildren(void)
void wxWindow::RemoveChild( wxWindow *child )
{
if (GetChildren())
GetChildren()->DeleteObject( child );
GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
@@ -1652,11 +1712,15 @@ int wxWindow::GetReturnCode(void)
void wxWindow::Raise(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_raise( m_widget->window );
}
void wxWindow::Lower(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_widget) gdk_window_lower( m_widget->window );
}
@@ -1672,28 +1736,28 @@ void wxWindow::SetEventHandler( wxEvtHandler *handler )
void wxWindow::PushEventHandler(wxEvtHandler *handler)
{
handler->SetNextHandler(GetEventHandler());
SetEventHandler(handler);
handler->SetNextHandler(GetEventHandler());
SetEventHandler(handler);
}
wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
{
if ( GetEventHandler() )
{
wxEvtHandler *handlerA = GetEventHandler();
wxEvtHandler *handlerB = handlerA->GetNextHandler();
handlerA->SetNextHandler((wxEvtHandler *) NULL);
SetEventHandler(handlerB);
if ( deleteHandler )
{
delete handlerA;
return (wxEvtHandler *) NULL;
}
else
return handlerA;
}
else
return (wxEvtHandler *) NULL;
if (GetEventHandler())
{
wxEvtHandler *handlerA = GetEventHandler();
wxEvtHandler *handlerB = handlerA->GetNextHandler();
handlerA->SetNextHandler((wxEvtHandler *) NULL);
SetEventHandler(handlerB);
if (deleteHandler)
{
delete handlerA;
return (wxEvtHandler*) NULL;
}
else
return handlerA;
}
else
return (wxEvtHandler *) NULL;
}
wxValidator *wxWindow::GetValidator(void)
@@ -1725,6 +1789,8 @@ wxWindowID wxWindow::GetId(void)
void wxWindow::SetCursor( const wxCursor &cursor )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_cursor == NULL)
{
wxFAIL_MSG( "wxWindow::SetCursor m_cursor == NULL" );
@@ -1750,6 +1816,8 @@ void wxWindow::SetCursor( const wxCursor &cursor )
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
@@ -1819,6 +1887,8 @@ bool wxWindow::IsExposed( const wxRect& rect ) const
void wxWindow::Clear(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
@@ -1829,6 +1899,8 @@ wxColour wxWindow::GetBackgroundColour(void) const
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
m_backgroundColour = colour;
if (m_wxwindow)
{
@@ -1851,6 +1923,8 @@ void wxWindow::SetForegroundColour( const wxColour &colour )
bool wxWindow::Validate(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
{
@@ -1864,6 +1938,8 @@ bool wxWindow::Validate(void)
bool wxWindow::TransferDataToWindow(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
{
@@ -1881,6 +1957,8 @@ bool wxWindow::TransferDataToWindow(void)
bool wxWindow::TransferDataFromWindow(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxNode *node = GetChildren()->First();
while (node)
{
@@ -1904,6 +1982,8 @@ void wxWindow::OnInitDialog( wxInitDialogEvent &WXUNUSED(event) )
void wxWindow::InitDialog(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxInitDialogEvent event(GetId());
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
@@ -1924,6 +2004,8 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
SetInvokingWindow( menu, this );
gtk_menu_popup( GTK_MENU(menu->m_menu), (GtkWidget *) NULL, (GtkWidget *) NULL, (GtkMenuPositionFunc) NULL, NULL, 0, 0 );
return TRUE;
@@ -1931,6 +2013,8 @@ bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
GtkWidget *dnd_widget = GetConnectWidget();
DisconnectDnDWidget( dnd_widget );
@@ -1982,6 +2066,8 @@ bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
void wxWindow::SetFont( const wxFont &font )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (((wxFont*)&font)->Ok())
m_font = font;
else
@@ -2021,6 +2107,10 @@ long wxWindow::GetWindowStyleFlag(void) const
void wxWindow::CaptureMouse(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (g_capturing == FALSE), "CaptureMouse called twice" );
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_add( connect_widget );
gdk_pointer_grab ( connect_widget->window, FALSE,
@@ -2034,6 +2124,10 @@ void wxWindow::CaptureMouse(void)
void wxWindow::ReleaseMouse(void)
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (g_capturing == TRUE), "ReleaseMouse called twice" );
GtkWidget *connect_widget = GetConnectWidget();
gtk_grab_remove( connect_widget );
gdk_pointer_ungrab ( GDK_CURRENT_TIME );
@@ -2105,6 +2199,10 @@ wxWindow *wxWindow::FindWindow( const wxString& name )
void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool WXUNUSED(refresh) )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return;
if (orient == wxHORIZONTAL)
@@ -2159,6 +2257,10 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return;
if (orient == wxHORIZONTAL)
@@ -2188,6 +2290,10 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) )
int wxWindow::GetScrollThumb( int orient ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return 0;
if (orient == wxHORIZONTAL)
@@ -2198,6 +2304,10 @@ int wxWindow::GetScrollThumb( int orient ) const
int wxWindow::GetScrollPos( int orient ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return 0;
if (orient == wxHORIZONTAL)
@@ -2208,6 +2318,10 @@ int wxWindow::GetScrollPos( int orient ) const
int wxWindow::GetScrollRange( int orient ) const
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return 0;
if (orient == wxHORIZONTAL)
@@ -2218,32 +2332,11 @@ int wxWindow::GetScrollRange( int orient ) const
void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
if (!m_wxwindow) return;
/*
bool refresh = FALSE;
if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0))
{
m_drawingOffsetX = -16000;
m_drawingOffsetY = -16000;
refresh = TRUE;
}
else
{
m_drawingOffsetX += dx;
m_drawingOffsetY += dy;
}
// printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
if (refresh) Refresh();
The code here is very nifty, but it doesn't work with
overlapping windows...
*/
int cw = 0;
int ch = 0;