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
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)
- cat >> confdefs.h <<\EOF
-#define __WXGTK__ 1
-EOF
-
TOOLKIT=GTK
TOOLKIT_DEF=__WXGTK__
MAKEINCLUDE=../gtk.inc
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;
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;
{ 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
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;
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;
{ 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
#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
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
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
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
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
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
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*
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
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
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
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
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
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
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;
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;
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
AC_MSG_ERROR(no)
fi
GUI_TK_LINK="-lXext -lX11 -lqt -lm"
- AC_DEFINE(__WXQT__)
TOOLKIT=QT
TOOLKIT_DEF=__WXQT__
MAKEINCLUDE=../qt.inc
AC_MSG_ERROR(no)
fi
GUI_TK_LINK="-lXext -lXt -lX11 -lXm -lm"
- AC_DEFINE(__WXMOTIF__)
TOOLKIT=MOTIF
TOOLKIT_DEF=__WXMOTIF__
MAKEINCLUDE=../motif.inc
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=
// wxAcceleratorEntry
//-----------------------------------------------------------------------------
-class wxAcceleratorEntry
+class wxAcceleratorEntry: public wxObject
{
public:
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 :-)
};
int GetWidth(void) const;
bool Ok(void) const;
+ void Unshare(void);
+
// no data :-)
};
// wxAcceleratorEntry
//-----------------------------------------------------------------------------
-class wxAcceleratorEntry
+class wxAcceleratorEntry: public wxObject
{
public:
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 :-)
};
int GetWidth(void) const;
bool Ok(void) const;
+ void Unshare(void);
+
// no data :-)
};
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);
#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);
void operator delete[] (void * buf);
#endif
-#define new WXDEBUG_NEW
-
#endif
#endif
#define WXTRACE TRUE ? (void)0 : wxTrace
#define WXTRACELEVEL TRUE ? (void)0 : wxTraceLevel
-#define WXDEBUG_NEW new
+// #define WXDEBUG_NEW new
#endif // WXDEBUG
#endif
#include "wx/defs.h"
+#include "wx/memory.h"
class WXDLLEXPORT wxObject;
};
#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
// 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
{
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
// 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;
#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:
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];
#endif
/* define the system to compile */
-#undef __WXGTK__
-#undef __WXMOTIF__
-#undef __WXQT__
#undef __UNIX__
#undef __LINUX__
#undef __SGI__
* 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?)
*/
wxFontList::~wxFontList ()
{
-#ifdef __WXMSW__
wxNode *node = First ();
while (node)
{
delete font;
node = next;
}
-#endif
}
void wxFontList::AddFont (wxFont * font)
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)
#include "wx/memory.h"
-/*
#ifdef new
#undef new
#endif
-*/
// wxDebugContext wxTheDebugContext;
/*
{
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
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);
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
{
appNameStr = wxTheApp->GetAppName();
appName = (char*) (const char*) appNameStr;
- wxTrace("Classes in %s:\n\n", appName);
+ wxTrace("----- Classes in %s -----\n", appName);
}
}
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;
}
}
}
-// Clean up hash table
void wxClassInfo::CleanUpClasses(void)
{
delete wxClassInfo::sm_classTable;
wxListMainWindow::~wxListMainWindow( void )
{
+ if (m_hilightBrush) delete m_hilightBrush;
+ delete m_renameTimer;
// if (m_hilightColour) delete m_hilightColour;
-// if (m_hilightBrush) delete m_hilightBrush;
// if (m_myFont) delete m_myFont;
- delete m_renameTimer;
// delete m_text;
}
wxTreeCtrl::~wxTreeCtrl()
{
+ if (m_hilightBrush) delete m_hilightBrush;
+ if (m_anchor) delete m_anchor;
}
bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
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 );
}
//-----------------------------------------------------------------------------
wxAcceleratorTable::wxAcceleratorTable()
{
- m_refData = new wxAccelRefData();
}
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 ) );
}
}
int wxAcceleratorTable::GetCommand( wxKeyEvent &event )
{
+ if (!Ok()) return -1;
+
wxNode *node = M_ACCELDATA->m_accels.First();
while (node)
{
wxCleanUpResourceSystem();
wxSystemSettings::Done();
-
- wxClassInfo::CleanUpClasses();
}
wxLog *wxApp::CreateLogTarget()
#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);
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 );
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");
wxDebugContext::PrintStatistics();
}
wxDebugContext::SetStream(NULL, NULL);
+
#endif
return retValue;
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;
}
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;
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();
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();
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();
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)
{
void wxBitmap::RecreateImage(void)
{
- if (!Ok()) return;
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
#ifdef USE_GDK_IMLIB
void wxBitmap::Render(void)
{
- if (!Ok()) return;
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
#ifdef USE_GDK_IMLIB
public:
wxBrushRefData(void);
-
+ wxBrushRefData( const wxBrushRefData& data );
+
int m_style;
wxBitmap m_stipple;
wxColour m_colour;
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)
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;
+ }
+}
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 )
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;
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;
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)
{
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)
{
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)
{
bool wxFont::GetUnderlined(void) const
{
- if (!Ok()) return FALSE;
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return FALSE;
+ }
return M_FONTDATA->m_underlined;
}
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
bool wxFrame::Show( bool show )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
if (show)
{
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
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);
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();
void wxFrame::GetClientSize( int *width, int *height ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
wxWindow::GetClientSize( width, height );
if (height)
{
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;
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
if ( GetAutoLayout() )
Layout();
else {
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" );
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)
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;
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 );
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);
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);
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 );
void wxFrame::SetIcon( const wxIcon &icon )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
m_icon = icon;
if (!icon.Ok()) return;
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)
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;
+ }
}
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();
}
}
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);
bool wxWindow::Destroy(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_hasVMT = FALSE;
delete this;
return TRUE;
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;
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 );
void wxWindow::GetClientSize( int *width, int *height ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (!m_wxwindow)
{
if (width) (*width) = m_width;
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;
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;
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;
void wxWindow::Fit(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
int maxX = 0;
int maxY = 0;
wxNode *node = GetChildren()->First();
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;
bool wxWindow::Show( bool show )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (show)
gtk_widget_show( m_widget );
else
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 );
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" );
}
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;
void wxWindow::SetFocus(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget)
{
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
void wxWindow::RemoveChild( wxWindow *child )
{
if (GetChildren())
- GetChildren()->DeleteObject( child );
+ GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
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 );
}
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)
void wxWindow::SetCursor( const wxCursor &cursor )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_cursor == NULL)
{
wxFAIL_MSG( "wxWindow::SetCursor m_cursor == NULL" );
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
void wxWindow::Clear(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_backgroundColour = colour;
if (m_wxwindow)
{
bool wxWindow::Validate(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
bool wxWindow::TransferDataToWindow(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
bool wxWindow::TransferDataFromWindow(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
void wxWindow::InitDialog(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxInitDialogEvent event(GetId());
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
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;
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GtkWidget *dnd_widget = GetConnectWidget();
DisconnectDnDWidget( dnd_widget );
void wxWindow::SetFont( const wxFont &font )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (((wxFont*)&font)->Ok())
m_font = font;
else
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,
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 );
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)
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)
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)
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)
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)
void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{
- 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;
- }
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-// printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
- 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...
-*/
+ if (!m_wxwindow) return;
int cw = 0;
int ch = 0;
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 );
}
//-----------------------------------------------------------------------------
wxAcceleratorTable::wxAcceleratorTable()
{
- m_refData = new wxAccelRefData();
}
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 ) );
}
}
int wxAcceleratorTable::GetCommand( wxKeyEvent &event )
{
+ if (!Ok()) return -1;
+
wxNode *node = M_ACCELDATA->m_accels.First();
while (node)
{
wxCleanUpResourceSystem();
wxSystemSettings::Done();
-
- wxClassInfo::CleanUpClasses();
}
wxLog *wxApp::CreateLogTarget()
#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);
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 );
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");
wxDebugContext::PrintStatistics();
}
wxDebugContext::SetStream(NULL, NULL);
+
#endif
return retValue;
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;
}
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;
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();
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();
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();
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)
{
void wxBitmap::RecreateImage(void)
{
- if (!Ok()) return;
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
#ifdef USE_GDK_IMLIB
void wxBitmap::Render(void)
{
- if (!Ok()) return;
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
#ifdef USE_GDK_IMLIB
public:
wxBrushRefData(void);
-
+ wxBrushRefData( const wxBrushRefData& data );
+
int m_style;
wxBitmap m_stipple;
wxColour m_colour;
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)
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;
+ }
+}
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 )
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;
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;
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)
{
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)
{
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)
{
bool wxFont::GetUnderlined(void) const
{
- if (!Ok()) return FALSE;
+ if (!Ok())
+ {
+ wxFAIL_MSG( "invalid font" );
+ return FALSE;
+ }
return M_FONTDATA->m_underlined;
}
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
bool wxFrame::Show( bool show )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
if (show)
{
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
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);
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();
void wxFrame::GetClientSize( int *width, int *height ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
wxWindow::GetClientSize( width, height );
if (height)
{
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;
void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
if ( GetAutoLayout() )
Layout();
else {
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" );
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)
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;
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 );
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);
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);
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 );
void wxFrame::SetIcon( const wxIcon &icon )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
+
m_icon = icon;
if (!icon.Ok()) return;
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)
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;
+ }
}
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();
}
}
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);
bool wxWindow::Destroy(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_hasVMT = FALSE;
delete this;
return TRUE;
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;
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 );
void wxWindow::GetClientSize( int *width, int *height ) const
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (!m_wxwindow)
{
if (width) (*width) = m_width;
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;
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;
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;
void wxWindow::Fit(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
int maxX = 0;
int maxY = 0;
wxNode *node = GetChildren()->First();
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;
bool wxWindow::Show( bool show )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (show)
gtk_widget_show( m_widget );
else
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 );
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" );
}
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;
void wxWindow::SetFocus(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GtkWidget *connect_widget = GetConnectWidget();
if (connect_widget)
{
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
void wxWindow::RemoveChild( wxWindow *child )
{
if (GetChildren())
- GetChildren()->DeleteObject( child );
+ GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}
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 );
}
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)
void wxWindow::SetCursor( const wxCursor &cursor )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_cursor == NULL)
{
wxFAIL_MSG( "wxWindow::SetCursor m_cursor == NULL" );
void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (eraseBackground && m_wxwindow && m_wxwindow->window)
{
if (rect)
void wxWindow::Clear(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (m_wxwindow && m_wxwindow->window) gdk_window_clear( m_wxwindow->window );
}
void wxWindow::SetBackgroundColour( const wxColour &colour )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
m_backgroundColour = colour;
if (m_wxwindow)
{
bool wxWindow::Validate(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
bool wxWindow::TransferDataToWindow(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
bool wxWindow::TransferDataFromWindow(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxNode *node = GetChildren()->First();
while (node)
{
void wxWindow::InitDialog(void)
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
wxInitDialogEvent event(GetId());
event.SetEventObject( this );
GetEventHandler()->ProcessEvent(event);
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;
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
GtkWidget *dnd_widget = GetConnectWidget();
DisconnectDnDWidget( dnd_widget );
void wxWindow::SetFont( const wxFont &font )
{
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
+
if (((wxFont*)&font)->Ok())
m_font = font;
else
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,
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 );
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)
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)
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)
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)
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)
void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
{
- 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;
- }
+ wxASSERT_MSG( (m_widget != NULL), "invalid window" );
-// printf( "X: %d Y: %d \n", (int)m_drawingOffsetX, (int)m_drawingOffsetY );
+ wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" );
- 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...
-*/
+ if (!m_wxwindow) return;
int cw = 0;
int ch = 0;
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";
item.m_children = 1;
m_rootId = InsertItem( 0, item );
- SetDropTarget( new wxFileDropTarget() );
+// SetDropTarget( new wxFileDropTarget() );
};
void wxDirCtrl::OnExpandItem( const wxTreeEvent &event )
m_dragStartY = 0;
m_dragCount = 0;
- SetDropTarget( new wxFileDropTarget() );
+// SetDropTarget( new wxFileDropTarget() );
};
void wxFileCtrl::ChangeToListMode()
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) );
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)