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

@ -23,7 +23,7 @@ Consistent keyboard interface and focus behaviour
Add support Set colour/baclgroundcolour in GTK widgets
Correct tab navigation (seems to be a GTK feature)
Finish DnD (postponed as GTK 1.2 will have new DnD)
Finish DnD
Add Clipboard
Help system (not sure about this one)
Show accelerator in menus
@ -36,7 +36,6 @@ Finish wxTextCtrl
Finish native wxTreeCtrl
Implement wxPalette
Implement wxDirDialog
Implement CopyOnWrite (unshare) for GDI objects
Support cooperation between Qt and wxWindows
Fix toolbar tips
TrueType support (just kidding)

60
configure vendored
View File

@ -5832,10 +5832,6 @@ fi
cat >> confdefs.h <<\EOF
#define __WXGTK__ 1
EOF
TOOLKIT=GTK
TOOLKIT_DEF=__WXGTK__
MAKEINCLUDE=../gtk.inc
@ -5843,7 +5839,7 @@ fi
if test "$USE_QT" = 1; then
echo $ac_n "checking for Qt includes""... $ac_c" 1>&6
echo "configure:5847: checking for Qt includes" >&5
echo "configure:5843: checking for Qt includes" >&5
ac_find_includes=
for ac_dir in $SEARCH_INCLUDE;
@ -5857,7 +5853,7 @@ for ac_dir in $SEARCH_INCLUDE;
if test "$ac_find_includes" != "" ; then
echo "$ac_t""found $ac_find_includes" 1>&6
echo $ac_n "checking for Qt library""... $ac_c" 1>&6
echo "configure:5861: checking for Qt library" >&5
echo "configure:5857: checking for Qt library" >&5
ac_find_libraries=
for ac_dir in $SEARCH_LIB;
@ -5900,10 +5896,6 @@ for ac_dir in $SEARCH_LIB;
{ echo "configure: error: no" 1>&2; exit 1; }
fi
GUI_TK_LINK="-lXext -lX11 -lqt -lm"
cat >> confdefs.h <<\EOF
#define __WXQT__ 1
EOF
TOOLKIT=QT
TOOLKIT_DEF=__WXQT__
MAKEINCLUDE=../qt.inc
@ -5911,7 +5903,7 @@ fi
if test "$USE_MOTIF" = 1; then
echo $ac_n "checking for Motif/Lesstif includes""... $ac_c" 1>&6
echo "configure:5915: checking for Motif/Lesstif includes" >&5
echo "configure:5907: checking for Motif/Lesstif includes" >&5
ac_find_includes=
for ac_dir in $SEARCH_INCLUDE;
@ -5925,7 +5917,7 @@ for ac_dir in $SEARCH_INCLUDE;
if test "$ac_find_includes" != "" ; then
echo "$ac_t""found $ac_find_includes" 1>&6
echo $ac_n "checking for Motif or Lesstif library""... $ac_c" 1>&6
echo "configure:5929: checking for Motif or Lesstif library" >&5
echo "configure:5921: checking for Motif or Lesstif library" >&5
ac_find_libraries=
for ac_dir in $SEARCH_LIB;
@ -5968,10 +5960,6 @@ for ac_dir in $SEARCH_LIB;
{ echo "configure: error: no" 1>&2; exit 1; }
fi
GUI_TK_LINK="-lXext -lXt -lX11 -lXm -lm"
cat >> confdefs.h <<\EOF
#define __WXMOTIF__ 1
EOF
TOOLKIT=MOTIF
TOOLKIT_DEF=__WXMOTIF__
MAKEINCLUDE=../motif.inc
@ -6011,7 +5999,11 @@ if test "$USE_MEM_TRACING" = 1 ; then
#define USE_MEMORY_TRACING $USE_MEM_TRACING
EOF
fi
cat >> confdefs.h <<EOF
#define USE_GLOBAL_MEMORY_OPERATORS $USE_MEM_TRACING
EOF
fi
EXTRA_LINK=
if test "$USE_DMALLOC" = 1 ; then
@ -6354,7 +6346,7 @@ fi
echo $ac_n "checking for main in -ldl""... $ac_c" 1>&6
echo "configure:6358: checking for main in -ldl" >&5
echo "configure:6350: checking for main in -ldl" >&5
ac_lib_var=`echo dl'_'main | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -6362,14 +6354,14 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldl $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6366 "configure"
#line 6358 "configure"
#include "confdefs.h"
int main() {
main()
; return 0; }
EOF
if { (eval echo configure:6373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6365: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -6409,7 +6401,7 @@ if test "$USE_THREADS" = "1"; then
echo $ac_n "checking for pthread_create in -lpthread-0.7""... $ac_c" 1>&6
echo "configure:6413: checking for pthread_create in -lpthread-0.7" >&5
echo "configure:6405: checking for pthread_create in -lpthread-0.7" >&5
ac_lib_var=`echo pthread-0.7'_'pthread_create | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -6417,7 +6409,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread-0.7 $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6421 "configure"
#line 6413 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -6428,7 +6420,7 @@ int main() {
pthread_create()
; return 0; }
EOF
if { (eval echo configure:6432: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -6452,17 +6444,17 @@ else
ac_safe=`echo "sys/prctl.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for sys/prctl.h""... $ac_c" 1>&6
echo "configure:6456: checking for sys/prctl.h" >&5
echo "configure:6448: checking for sys/prctl.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 6461 "configure"
#line 6453 "configure"
#include "confdefs.h"
#include <sys/prctl.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:6466: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:6458: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@ -6488,7 +6480,7 @@ fi
echo $ac_n "checking for pthread_setcanceltype in -lpthread""... $ac_c" 1>&6
echo "configure:6492: checking for pthread_setcanceltype in -lpthread" >&5
echo "configure:6484: checking for pthread_setcanceltype in -lpthread" >&5
ac_lib_var=`echo pthread'_'pthread_setcanceltype | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -6496,7 +6488,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthread $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6500 "configure"
#line 6492 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -6507,7 +6499,7 @@ int main() {
pthread_setcanceltype()
; return 0; }
EOF
if { (eval echo configure:6511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6503: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -6534,7 +6526,7 @@ fi
fi
echo $ac_n "checking for pthread_setcanceltype in -lpthreads""... $ac_c" 1>&6
echo "configure:6538: checking for pthread_setcanceltype in -lpthreads" >&5
echo "configure:6530: checking for pthread_setcanceltype in -lpthreads" >&5
ac_lib_var=`echo pthreads'_'pthread_setcanceltype | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -6542,7 +6534,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lpthreads $LIBS"
cat > conftest.$ac_ext <<EOF
#line 6546 "configure"
#line 6538 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -6553,7 +6545,7 @@ int main() {
pthread_setcanceltype()
; return 0; }
EOF
if { (eval echo configure:6557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
if { (eval echo configure:6549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -6597,7 +6589,7 @@ OPENGL_LINK=
if test "$USE_OPENGL" = 1; then
echo $ac_n "checking for OpenGL includes""... $ac_c" 1>&6
echo "configure:6601: checking for OpenGL includes" >&5
echo "configure:6593: checking for OpenGL includes" >&5
ac_find_includes=
for ac_dir in $SEARCH_INCLUDE;
@ -6612,7 +6604,7 @@ for ac_dir in $SEARCH_INCLUDE;
OPENGL_INCLUDE="-I$ac_find_includes"
echo "$ac_t""found $ac_find_includes" 1>&6
echo $ac_n "checking for OpenGL library""... $ac_c" 1>&6
echo "configure:6616: checking for OpenGL library" >&5
echo "configure:6608: checking for OpenGL library" >&5
ac_find_libraries=
for ac_dir in $SEARCH_LIB;

View File

@ -976,7 +976,6 @@ if test "$USE_GTK" = 1; then
GUI_TK_INCLUDE="$GTK_CFLAGS"
GUI_TK_LIBRARY="$GTK_LIBS"
], AC_MSG_ERROR(Are gtk-config and the GTK in path and up-to-date?))
AC_DEFINE(__WXGTK__)
TOOLKIT=GTK
TOOLKIT_DEF=__WXGTK__
MAKEINCLUDE=../gtk.inc
@ -1002,7 +1001,6 @@ if test "$USE_QT" = 1; then
AC_MSG_ERROR(no)
fi
GUI_TK_LINK="-lXext -lX11 -lqt -lm"
AC_DEFINE(__WXQT__)
TOOLKIT=QT
TOOLKIT_DEF=__WXQT__
MAKEINCLUDE=../qt.inc
@ -1028,7 +1026,6 @@ if test "$USE_MOTIF" = 1; then
AC_MSG_ERROR(no)
fi
GUI_TK_LINK="-lXext -lXt -lX11 -lXm -lm"
AC_DEFINE(__WXMOTIF__)
TOOLKIT=MOTIF
TOOLKIT_DEF=__WXMOTIF__
MAKEINCLUDE=../motif.inc
@ -1065,7 +1062,7 @@ fi
if test "$USE_MEM_TRACING" = 1 ; then
AC_DEFINE_UNQUOTED(USE_MEMORY_TRACING,$USE_MEM_TRACING)
dnl AC_DEFINE_UNQUOTED(USE_GLOBAL_MEMORY_OPERATORS,$USE_MEM_TRACING)
AC_DEFINE_UNQUOTED(USE_GLOBAL_MEMORY_OPERATORS,$USE_MEM_TRACING)
fi
EXTRA_LINK=

View File

@ -52,7 +52,7 @@ extern wxAcceleratorTable wxNullAcceleratorTable;
// wxAcceleratorEntry
//-----------------------------------------------------------------------------
class wxAcceleratorEntry
class wxAcceleratorEntry: public wxObject
{
public:

View File

@ -54,6 +54,15 @@ class wxBrush: public wxGDIObject
wxColour &GetColour(void) const;
wxBitmap *GetStipple(void) const;
void SetColour( const wxColour& col );
void SetColour( const wxString& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
void SetStipple( const wxBitmap& stipple );
void Unshare(void);
// no data :-)
};

View File

@ -62,6 +62,8 @@ class wxPen: public wxGDIObject
int GetWidth(void) const;
bool Ok(void) const;
void Unshare(void);
// no data :-)
};

View File

@ -52,7 +52,7 @@ extern wxAcceleratorTable wxNullAcceleratorTable;
// wxAcceleratorEntry
//-----------------------------------------------------------------------------
class wxAcceleratorEntry
class wxAcceleratorEntry: public wxObject
{
public:

View File

@ -54,6 +54,15 @@ class wxBrush: public wxGDIObject
wxColour &GetColour(void) const;
wxBitmap *GetStipple(void) const;
void SetColour( const wxColour& col );
void SetColour( const wxString& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
void SetStipple( const wxBitmap& stipple );
void Unshare(void);
// no data :-)
};

View File

@ -62,6 +62,8 @@ class wxPen: public wxGDIObject
int GetWidth(void) const;
bool Ok(void) const;
void Unshare(void);
// no data :-)
};

View File

@ -41,6 +41,8 @@ class WXDLLEXPORT wxHashTable: public wxObject
wxHashTable(int the_key_type = wxKEY_INTEGER, int size = 1000);
~wxHashTable(void);
void Destroy(void); // Robert Roebling
bool Create(int the_key_type = wxKEY_INTEGER, int size = 1000);
// Note that there are 2 forms of Put, Get.

View File

@ -35,11 +35,12 @@
#include "wx/string.h"
#ifndef WXDEBUG_NEW
#define WXDEBUG_NEW new(__FILE__,__LINE__)
#endif
#if WXDEBUG
// #ifndef WXDEBUG_NEW
// #define WXDEBUG_NEW new(__FILE__,__LINE__)
// #endif
void * wxDebugAlloc(size_t size, char * fileName, int lineNum, bool isObject, bool isVect = FALSE);
void wxDebugFree(void * buf, bool isVect = FALSE);
@ -61,8 +62,6 @@ void * operator new[] (size_t size, char * fileName, int lineNum);
void operator delete[] (void * buf);
#endif
#define new WXDEBUG_NEW
#endif
#endif
@ -270,7 +269,7 @@ inline void wxTraceLevel(int WXUNUSED(level), const char *WXUNUSED(fmt)) {}
#define WXTRACE TRUE ? (void)0 : wxTrace
#define WXTRACELEVEL TRUE ? (void)0 : wxTraceLevel
#define WXDEBUG_NEW new
// #define WXDEBUG_NEW new
#endif // WXDEBUG

View File

@ -17,6 +17,7 @@
#endif
#include "wx/defs.h"
#include "wx/memory.h"
class WXDLLEXPORT wxObject;
@ -232,10 +233,10 @@ private:
};
#if WXDEBUG && USE_GLOBAL_MEMORY_OPERATORS
#ifndef WXDEBUG_NEW
#define WXDEBUG_NEW new(__FILE__,__LINE__)
#endif
#define new WXDEBUG_NEW
//#ifndef WXDEBUG_NEW
//#define WXDEBUG_NEW new(__FILE__,__LINE__)
//#endif
#define new new(__FILE__,__LINE__)
#endif
#endif

View File

@ -167,9 +167,9 @@ int WXDLLEXPORT wxFindMenuItemId(wxFrame *frame, const wxString& menuString, con
// Can't export a class derived from a non-export class
#if !defined(_WINDLL) && !defined(WXUSINGDLL)
#ifdef new
#undef new
#endif
// #ifdef new
// #undef new
// #endif
class WXDLLEXPORT wxDebugStreamBuf: public streambuf
{
@ -182,9 +182,9 @@ class WXDLLEXPORT wxDebugStreamBuf: public streambuf
int sync(void);
};
#if WXDEBUG && USE_GLOBAL_MEMORY_OPERATORS
#define new WXDEBUG_NEW
#endif
// #if WXDEBUG && USE_GLOBAL_MEMORY_OPERATORS
// #define new WXDEBUG_NEW
// #endif
#endif

View File

@ -192,7 +192,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
// associate drop targets with 2 text controls
m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
//m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
wxLayoutConstraints *c;

View File

@ -35,8 +35,6 @@
#error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK)
#endif
// #define new WXDEBUG_NEW
// Define a new application type
class MyApp: public wxApp
{ public:
@ -85,10 +83,9 @@ bool MyApp::OnInit(void)
wxDebugContext::SetCheckpoint();
wxDebugContext::SetFile("debug.log");
wxString *thing = new wxString; // WXDEBUG_NEW wxString;
wxString *thing = new wxString;
wxDate* date = new wxDate;
// Proves that defining 'new' to be 'WXDEBUG_NEW' doesn't mess up
// non-object allocation
char *ordinaryNonObject = new char[1000];

View File

@ -17,9 +17,6 @@
#endif
/* define the system to compile */
#undef __WXGTK__
#undef __WXMOTIF__
#undef __WXQT__
#undef __UNIX__
#undef __LINUX__
#undef __SGI__
@ -265,11 +262,6 @@
* Disable it, If this causes problems (e.g. link errors)
*/
#undef USE_GLOBAL_MEMORY_OPERATORS
/*
* If WXDEBUG && USE_MEMORY_TRACING && USE_GLOBAL_MEMORY_OPERATORS
* used to debug the memory allocation of wxWindows Xt port code
*/
#define USE_INTERNAL_MEMORY_TRACING 0
/*
* Matthews garbage collection (used for MrEd?)
*/

View File

@ -568,7 +568,6 @@ void wxBrushList::RemoveBrush (wxBrush * brush)
wxFontList::~wxFontList ()
{
#ifdef __WXMSW__
wxNode *node = First ();
while (node)
{
@ -582,7 +581,6 @@ wxFontList::~wxFontList ()
delete font;
node = next;
}
#endif
}
void wxFontList::AddFont (wxFont * font)

View File

@ -48,11 +48,18 @@ wxHashTable::wxHashTable (int the_key_type, int size)
wxHashTable::~wxHashTable (void)
{
Destroy();
}
void wxHashTable::Destroy(void)
{
if (!hash_table) return;
int i;
for (i = 0; i < n; i++)
if (hash_table[i])
delete hash_table[i];
delete[] hash_table;
hash_table = NULL;
}
bool wxHashTable::Create(int the_key_type, int size)

View File

@ -66,11 +66,9 @@
#include "wx/memory.h"
/*
#ifdef new
#undef new
#endif
*/
// wxDebugContext wxTheDebugContext;
/*
@ -651,11 +649,17 @@ bool wxDebugContext::Dump(void)
{
appNameStr = wxTheApp->GetAppName();
appName = (char*) (const char*) appNameStr;
wxTrace("Memory dump of %s at %s:\n", appName, WXSTRINGCAST wxNow() );
wxTrace("----- Memory dump of %s at %s -----\n", appName, WXSTRINGCAST wxNow() );
}
else
{
wxTrace( "----- Memory dump -----\n" );
}
}
TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL));
wxTrace( "\n\n" );
return TRUE;
#else
return FALSE;
@ -693,6 +697,22 @@ bool wxDebugContext::PrintStatistics(bool detailed)
if (!HasStream())
return FALSE;
if (TRUE)
{
char* appName = "application";
wxString appNameStr("");
if (wxTheApp)
{
appNameStr = wxTheApp->GetAppName();
appName = (char*) (const char*) appNameStr;
wxTrace("----- Memory statistics of %s at %s -----\n", appName, WXSTRINGCAST wxNow() );
}
else
{
wxTrace( "----- Memory statistics -----\n" );
}
}
bool currentMode = GetDebugMode();
SetDebugMode(FALSE);
@ -760,6 +780,7 @@ bool wxDebugContext::PrintStatistics(bool detailed)
wxTrace("Number of object items: %ld\n", noObjectNodes);
wxTrace("Number of non-object items: %ld\n", noNonObjectNodes);
wxTrace("Total allocated size: %ld\n", totalSize);
wxTrace("\n\n");
return TRUE;
#else
@ -780,7 +801,7 @@ bool wxDebugContext::PrintClasses(void)
{
appNameStr = wxTheApp->GetAppName();
appName = (char*) (const char*) appNameStr;
wxTrace("Classes in %s:\n\n", appName);
wxTrace("----- Classes in %s -----\n", appName);
}
}
@ -806,10 +827,10 @@ bool wxDebugContext::PrintClasses(void)
else
wxTrace("\n");
}
node = node->Next();
node = wxClassInfo::sm_classTable->Next();
n ++;
}
wxTrace("\nThere are %d classes derived from wxObject.\n", n);
wxTrace("\nThere are %d classes derived from wxObject.\n\n\n", n);
return TRUE;
}

View File

@ -220,7 +220,6 @@ void wxClassInfo::InitializeClasses(void)
}
}
// Clean up hash table
void wxClassInfo::CleanUpClasses(void)
{
delete wxClassInfo::sm_classTable;

View File

@ -910,10 +910,10 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id,
wxListMainWindow::~wxListMainWindow( void )
{
// if (m_hilightColour) delete m_hilightColour;
// if (m_hilightBrush) delete m_hilightBrush;
// if (m_myFont) delete m_myFont;
if (m_hilightBrush) delete m_hilightBrush;
delete m_renameTimer;
// if (m_hilightColour) delete m_hilightColour;
// if (m_myFont) delete m_myFont;
// delete m_text;
}

View File

@ -381,6 +381,8 @@ wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id,
wxTreeCtrl::~wxTreeCtrl()
{
if (m_hilightBrush) delete m_hilightBrush;
if (m_anchor) delete m_anchor;
}
bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,

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,6 +23,7 @@ class wxBrushRefData: public wxObjectRefData
public:
wxBrushRefData(void);
wxBrushRefData( const wxBrushRefData& data );
int m_style;
wxBitmap m_stipple;
@ -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
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_joinStyle;
}
int wxPen::GetStyle(void) const
{
if (!m_refData)
return 0;
else
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_style;
}
int wxPen::GetWidth(void) const
{
if (!m_refData)
return 0;
else
{
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;
}
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
@ -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 );
}
@ -1678,16 +1742,16 @@ void wxWindow::PushEventHandler(wxEvtHandler *handler)
wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
{
if ( GetEventHandler() )
if (GetEventHandler())
{
wxEvtHandler *handlerA = GetEventHandler();
wxEvtHandler *handlerB = handlerA->GetNextHandler();
handlerA->SetNextHandler((wxEvtHandler *) NULL);
SetEventHandler(handlerB);
if ( deleteHandler )
if (deleteHandler)
{
delete handlerA;
return (wxEvtHandler *) NULL;
return (wxEvtHandler*) NULL;
}
else
return handlerA;
@ -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,33 +2332,12 @@ 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;
GetClientSize( &cw, &ch );

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,6 +23,7 @@ class wxBrushRefData: public wxObjectRefData
public:
wxBrushRefData(void);
wxBrushRefData( const wxBrushRefData& data );
int m_style;
wxBitmap m_stipple;
@ -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
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_joinStyle;
}
int wxPen::GetStyle(void) const
{
if (!m_refData)
return 0;
else
{
wxFAIL_MSG( "invalid pen" );
return -1;
}
return M_PENDATA->m_style;
}
int wxPen::GetWidth(void) const
{
if (!m_refData)
return 0;
else
{
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;
}
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
@ -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 );
}
@ -1678,16 +1742,16 @@ void wxWindow::PushEventHandler(wxEvtHandler *handler)
wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
{
if ( GetEventHandler() )
if (GetEventHandler())
{
wxEvtHandler *handlerA = GetEventHandler();
wxEvtHandler *handlerB = handlerA->GetNextHandler();
handlerA->SetNextHandler((wxEvtHandler *) NULL);
SetEventHandler(handlerB);
if ( deleteHandler )
if (deleteHandler)
{
delete handlerA;
return (wxEvtHandler *) NULL;
return (wxEvtHandler*) NULL;
}
else
return handlerA;
@ -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,33 +2332,12 @@ 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;
GetClientSize( &cw, &ch );

View File

@ -33,10 +33,8 @@ wxDirInfo::wxDirInfo( const wxString &path )
if (m_path == "/home")
{
m_name = "My Home";
m_path += "/";
wxString str;
wxGetHomeDir( & str );
m_path = str;
m_path = "";
wxGetHomeDir( &m_path );
}
else
if (m_path == "/proc") m_name = "Info Filesystem";
@ -97,7 +95,7 @@ wxDirCtrl::wxDirCtrl(wxWindow *parent, const wxWindowID id, const wxString &WXUN
item.m_children = 1;
m_rootId = InsertItem( 0, item );
SetDropTarget( new wxFileDropTarget() );
// SetDropTarget( new wxFileDropTarget() );
};
void wxDirCtrl::OnExpandItem( const wxTreeEvent &event )

View File

@ -241,7 +241,7 @@ wxFileCtrl::wxFileCtrl( wxWindow *win, const wxWindowID id, const wxString &dirN
m_dragStartY = 0;
m_dragCount = 0;
SetDropTarget( new wxFileDropTarget() );
// SetDropTarget( new wxFileDropTarget() );
};
void wxFileCtrl::ChangeToListMode()

View File

@ -155,10 +155,9 @@ MyFrame::MyFrame(void) :
m_leftFile = (wxFileCtrl *) NULL;
m_dir = new wxDirCtrl( m_splitter, ID_DIRCTRL, "/", wxPoint(10,45), wxSize(200,330) );
wxString homepath( "/home" );
wxString str;
wxGetHomeDir( & str );
homepath = str;
wxString homepath;
wxGetHomeDir( &homepath );
m_rightFile = new wxFileCtrl( m_splitter, ID_FILECTRL, homepath, wxPoint(220,5), wxSize(200,330) );
m_leftFile = new wxFileCtrl( m_splitter, ID_FILECTRL, homepath, wxPoint(0,5), wxSize(200,330) );

View File

@ -42,7 +42,6 @@ while test $# -gt 0; do
if test @includedir@ != /usr/include ; then
includes=-I@includedir@
fi
includes="$includes -I@includedir@/wx/@host@"
echo $includes -D@TOOLKIT_DEF@ @GUI_TK_INCLUDE@
;;
--libs)