Minor Motif changes, made scrollsub sample work somehow.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,7 +25,9 @@
|
||||
// global data
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
Atom g_textAtom = 0;
|
||||
Atom g_textAtom = 0;
|
||||
Atom g_pngAtom = 0;
|
||||
Atom g_fileAtom = 0;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDataFormat
|
||||
@@ -33,134 +35,108 @@ Atom g_textAtom = 0;
|
||||
|
||||
wxDataFormat::wxDataFormat()
|
||||
{
|
||||
// do *not* call PrepareFormats() from here for 2 reasons:
|
||||
//
|
||||
// 1. we will have time to do it later because some other Set function
|
||||
// must be called before we really need them
|
||||
//
|
||||
// 2. doing so prevents us from declaring global wxDataFormats because
|
||||
// calling PrepareFormats (and thus gdk_atom_intern) before GDK is
|
||||
// initialised will result in a crash
|
||||
m_type = wxDF_INVALID;
|
||||
m_hasAtom = FALSE;
|
||||
m_atom = (Atom) 0;
|
||||
m_format = (Atom) 0;
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( wxDataFormatId type )
|
||||
{
|
||||
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
PrepareFormats();
|
||||
SetType( type );
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( const wxChar *id )
|
||||
{
|
||||
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
PrepareFormats();
|
||||
SetId( id );
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( const wxString &id )
|
||||
{
|
||||
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
PrepareFormats();
|
||||
SetId( id );
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( const wxDataFormat &format )
|
||||
wxDataFormat::wxDataFormat( NativeFormat format )
|
||||
{
|
||||
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
m_type = format.GetType();
|
||||
m_id = format.GetId();
|
||||
m_hasAtom = TRUE;
|
||||
m_atom = ((wxDataFormat &)format).GetAtom(); // const_cast
|
||||
}
|
||||
|
||||
wxDataFormat::wxDataFormat( const Atom atom )
|
||||
{
|
||||
if (!g_textAtom) g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
m_hasAtom = TRUE;
|
||||
|
||||
m_atom = atom;
|
||||
|
||||
if (m_atom == g_textAtom)
|
||||
{
|
||||
m_type = wxDF_TEXT;
|
||||
} else
|
||||
/*
|
||||
if (m_atom == GDK_TARGET_BITMAP)
|
||||
{
|
||||
m_type = wxDF_BITMAP;
|
||||
} else
|
||||
*/
|
||||
{
|
||||
m_type = wxDF_PRIVATE;
|
||||
m_id = XGetAtomName( (Display*) wxGetDisplay(), m_atom );
|
||||
|
||||
if (m_id == wxT("file:ALL"))
|
||||
{
|
||||
m_type = wxDF_FILENAME;
|
||||
}
|
||||
}
|
||||
PrepareFormats();
|
||||
SetId( format );
|
||||
}
|
||||
|
||||
void wxDataFormat::SetType( wxDataFormatId type )
|
||||
{
|
||||
PrepareFormats();
|
||||
m_type = type;
|
||||
|
||||
if (m_type == wxDF_TEXT)
|
||||
{
|
||||
m_id = wxT("STRING");
|
||||
}
|
||||
m_format = g_textAtom;
|
||||
else
|
||||
if (m_type == wxDF_BITMAP)
|
||||
{
|
||||
m_id = wxT("BITMAP");
|
||||
}
|
||||
m_format = g_pngAtom;
|
||||
else
|
||||
if (m_type == wxDF_FILENAME)
|
||||
{
|
||||
m_id = wxT("file:ALL");
|
||||
}
|
||||
m_format = g_fileAtom;
|
||||
else
|
||||
{
|
||||
wxFAIL_MSG( wxT("invalid dataformat") );
|
||||
}
|
||||
}
|
||||
|
||||
m_hasAtom = FALSE;
|
||||
wxDataFormatId wxDataFormat::GetType() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
wxString wxDataFormat::GetId() const
|
||||
{
|
||||
char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format);
|
||||
wxString ret( t ); // this will convert from ascii to Unicode
|
||||
if (t)
|
||||
XFree( t );
|
||||
return ret;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId( NativeFormat format )
|
||||
{
|
||||
PrepareFormats();
|
||||
m_format = format;
|
||||
|
||||
if (m_format == g_textAtom)
|
||||
m_type = wxDF_TEXT;
|
||||
else
|
||||
if (m_format == g_pngAtom)
|
||||
m_type = wxDF_BITMAP;
|
||||
else
|
||||
if (m_format == g_fileAtom)
|
||||
m_type = wxDF_FILENAME;
|
||||
else
|
||||
m_type = wxDF_PRIVATE;
|
||||
}
|
||||
|
||||
void wxDataFormat::SetId( const wxChar *id )
|
||||
{
|
||||
PrepareFormats();
|
||||
m_type = wxDF_PRIVATE;
|
||||
m_id = id;
|
||||
m_hasAtom = FALSE;
|
||||
wxString tmp( id );
|
||||
m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
|
||||
}
|
||||
|
||||
Atom wxDataFormat::GetAtom()
|
||||
void wxDataFormat::PrepareFormats()
|
||||
{
|
||||
if (!m_hasAtom)
|
||||
{
|
||||
m_hasAtom = TRUE;
|
||||
|
||||
if (m_type == wxDF_TEXT)
|
||||
{
|
||||
m_atom = g_textAtom;
|
||||
}
|
||||
else
|
||||
/*
|
||||
if (m_type == wxDF_BITMAP)
|
||||
{
|
||||
m_atom = GDK_TARGET_BITMAP;
|
||||
}
|
||||
else
|
||||
*/
|
||||
if (m_type == wxDF_PRIVATE)
|
||||
{
|
||||
m_atom = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST m_id.mbc_str(), FALSE );
|
||||
}
|
||||
else
|
||||
if (m_type == wxDF_FILENAME)
|
||||
{
|
||||
m_atom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_hasAtom = FALSE;
|
||||
m_atom = (Atom) 0;
|
||||
}
|
||||
}
|
||||
|
||||
return m_atom;
|
||||
if (!g_textAtom)
|
||||
g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
|
||||
if (!g_pngAtom)
|
||||
g_pngAtom = XInternAtom( (Display*) wxGetDisplay(), "image/png", FALSE );
|
||||
if (!g_fileAtom)
|
||||
g_fileAtom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE );
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user