#define wxINT16_SWAP_ALWAYS(val) \
((wxInt16) ( \
- (((wxInt16) (val) & (wxInt16) 0x00ffU) << 8) | \
- (((wxInt16) (val) & (wxInt16) 0xff00U) >> 8)))
+ (((wxUint16) (val) & (wxUint16) 0x00ffU) << 8) | \
+ (((wxUint16) (val) & (wxUint16) 0xff00U) >> 8)))
#define wxUINT32_SWAP_ALWAYS(val) \
((wxUint32) ( \
#define wxINT32_SWAP_ALWAYS(val) \
((wxInt32) ( \
- (((wxInt32) (val) & (wxInt32) 0x000000ffU) << 24) | \
- (((wxInt32) (val) & (wxInt32) 0x0000ff00U) << 8) | \
- (((wxInt32) (val) & (wxInt32) 0x00ff0000U) >> 8) | \
- (((wxInt32) (val) & (wxInt32) 0xff000000U) >> 24)))
+ (((wxUint32) (val) & (wxUint32) 0x000000ffU) << 24) | \
+ (((wxUint32) (val) & (wxUint32) 0x0000ff00U) << 8) | \
+ (((wxUint32) (val) & (wxUint32) 0x00ff0000U) >> 8) | \
+ (((wxUint32) (val) & (wxUint32) 0xff000000U) >> 24)))
// machine specific byte swapping
#ifdef WORDS_BIGENDIAN
- #define wxUINT16_SWAP_FROM_LE(val) wxUINT16_SWAP_ALWAYS(val)
- #define wxINT16_SWAP_FROM_LE(val) wxINT16_SWAP_ALWAYS(val)
- #define wxUINT16_SWAP_FROM_BE(val) (val)
- #define wxINT16_SWAP_FROM_BE(val) (val)
- #define wxUINT32_SWAP_FROM_LE(val) wxUINT32_SWAP_ALWAYS(val)
- #define wxINT32_SWAP_FROM_LE(val) wxINT32_SWAP_ALWAYS(val)
- #define wxUINT32_SWAP_FROM_BE(val) (val)
- #define wxINT32_SWAP_FROM_BE(val) (val)
+ #define wxUINT16_SWAP_ON_BE(val) wxUINT16_SWAP_ALWAYS(val)
+ #define wxINT16_SWAP_ON_BE(val) wxINT16_SWAP_ALWAYS(val)
+ #define wxUINT16_SWAP_ON_LE(val) (val)
+ #define wxINT16_SWAP_ON_LE(val) (val)
+ #define wxUINT32_SWAP_ON_BE(val) wxUINT32_SWAP_ALWAYS(val)
+ #define wxINT32_SWAP_ON_BE(val) wxINT32_SWAP_ALWAYS(val)
+ #define wxUINT32_SWAP_ON_LE(val) (val)
+ #define wxINT32_SWAP_ON_LE(val) (val)
#else
- #define wxUINT16_SWAP_FROM_BE(val) wxUINT16_SWAP_ALWAYS(val)
- #define wxINT16_SWAP_FROM_BE(val) wxINT16_SWAP_ALWAYS(val)
- #define wxUINT16_SWAP_FROM_LE(val) (val)
- #define wxINT16_SWAP_FROM_LE(val) (val)
- #define wxUINT32_SWAP_FROM_BE(val) wxUINT32_SWAP_ALWAYS(val)
- #define wxINT32_SWAP_FROM_BE(val) wxINT32_SWAP_ALWAYS(val)
- #define wxUINT32_SWAP_FROM_LE(val) (val)
- #define wxINT32_SWAP_FROM_LE(val) (val)
+ #define wxUINT16_SWAP_ON_LE(val) wxUINT16_SWAP_ALWAYS(val)
+ #define wxINT16_SWAP_ON_LE(val) wxINT16_SWAP_ALWAYS(val)
+ #define wxUINT16_SWAP_ON_BE(val) (val)
+ #define wxINT16_SWAP_ON_BE(val) (val)
+ #define wxUINT32_SWAP_ON_LE(val) wxUINT32_SWAP_ALWAYS(val)
+ #define wxINT32_SWAP_ON_LE(val) wxINT32_SWAP_ALWAYS(val)
+ #define wxUINT32_SWAP_ON_BE(val) (val)
+ #define wxINT32_SWAP_ON_BE(val) (val)
#endif
// ----------------------------------------------------------------------------
// clears wxTheClipboard and the system's clipboard if possible
virtual void Clear();
+
+ /// X11 has two clipboards which get selected by this call. Empty on MSW.
+ inline void UsePrimarySelection( bool WXUNUSED(primary) ) { }
+
};
// The global clipboard object
// parts in wxUSE_DRAG_AND_DROP.
#if wxUSE_CLIPBOARD && wxUSE_DRAG_AND_DROP
+
+ // On X11, we want to get the data from the primary selection instead
+ // of the normal clipboard (which isn't normal under X11 at all). This
+ // call has no effect under MSW.
+ wxTheClipboard->UsePrimarySelection();
+
if (!wxTheClipboard->Open())
{
*m_log << "Error opening the clipboard.\n";
-
return;
}
else
EVT_MENU(TYPES_DATE, MyApp::DoDateDemo)
EVT_MENU(TYPES_TIME, MyApp::DoTimeDemo)
EVT_MENU(TYPES_VARIANT, MyApp::DoVariantDemo)
+ EVT_MENU(TYPES_BYTEORDER, MyApp::DoByteOrderDemo)
END_EVENT_TABLE()
bool MyApp::OnInit(void)
file_menu->Append(TYPES_DATE, "&Date test");
file_menu->Append(TYPES_TIME, "&Time test");
file_menu->Append(TYPES_VARIANT, "&Variant test");
+ file_menu->Append(TYPES_BYTEORDER, "&Byteorder test");
file_menu->AppendSeparator();
file_menu->Append(TYPES_QUIT, "E&xit");
wxMenuBar *menu_bar = new wxMenuBar;
return TRUE;
}
+void MyApp::DoByteOrderDemo(wxCommandEvent& WXUNUSED(event))
+{
+ wxTextCtrl& textCtrl = * GetTextCtrl();
+
+ textCtrl.Clear();
+ textCtrl << "\nTest byte order macros:\n\n";
+
+ if (wxBYTE_ORDER == wxLITTLE_ENDIAN)
+ textCtrl << "This is a little endian system.\n\n";
+ else
+ textCtrl << "This is a big endian system.\n\n";
+
+ wxString text;
+
+ wxInt32 var = 0xF1F2F3F4;
+ text = "";
+ text.Printf( "Value of wxInt32 is now: %#x.\n\n", var );
+ textCtrl.WriteText( text );
+
+ text = "";
+ text.Printf( "Value of swapped wxInt32 is: %#x.\n\n", wxINT32_SWAP_ALWAYS( var ) );
+ textCtrl.WriteText( text );
+
+ text = "";
+ text.Printf( "Value of wxInt32 swapped on little endian is: %#x.\n\n", wxINT32_SWAP_ON_LE( var ) );
+ textCtrl.WriteText( text );
+
+ text = "";
+ text.Printf( "Value of wxInt32 swapped on big endian is: %#x.\n\n", wxINT32_SWAP_ON_BE( var ) );
+ textCtrl.WriteText( text );
+}
+
void MyApp::DoTimeDemo(wxCommandEvent& WXUNUSED(event))
{
wxTextCtrl& textCtrl = * GetTextCtrl();
textCtrl.Clear();
- cout << "\nTest class wxTime" << endl;
+ textCtrl << "\nTest class wxTime:\n";
wxTime now;
textCtrl << "It is now " << (wxString) now << "\n";
}
void DoDateDemo(wxCommandEvent& event);
void DoTimeDemo(wxCommandEvent& event);
void DoVariantDemo(wxCommandEvent& event);
+ void DoByteOrderDemo(wxCommandEvent& event);
wxTextCtrl* GetTextCtrl() const { return m_textCtrl; }
#define TYPES_DATE 103
#define TYPES_TIME 104
#define TYPES_VARIANT 105
+#define TYPES_BYTEORDER 106
#endif
// _WX_TYPETEST_H_
stream.Read( &bbuf, 2 );
stream.Read( dbuf, 4 * 4 );
- wxInt32 size = wxINT32_SWAP_FROM_LE( dbuf[0] );
- wxInt32 offset = wxINT32_SWAP_FROM_LE( dbuf[2] );
+ wxInt32 size = wxINT32_SWAP_ON_BE( dbuf[0] );
+ wxInt32 offset = wxINT32_SWAP_ON_BE( dbuf[2] );
stream.Read(dbuf, 4 * 2);
- int width = (int)wxINT32_SWAP_FROM_LE( dbuf[0] );
- int height = (int)wxINT32_SWAP_FROM_LE( dbuf[1] );
+ int width = (int)wxINT32_SWAP_ON_BE( dbuf[0] );
+ int height = (int)wxINT32_SWAP_ON_BE( dbuf[1] );
if (width > 32767)
{
wxLogError( _T("Image width > 32767 pixels for file.") );
stream.Read( &aWord, 2 );
/*
TODO
- int planes = (int)wxUINT16_SWAP_FROM_LE( aWord );
+ int planes = (int)wxUINT16_SWAP_ON_BE( aWord );
*/
stream.Read( &aWord, 2 );
- int bpp = (int)wxUINT16_SWAP_FROM_LE( aWord );
+ int bpp = (int)wxUINT16_SWAP_ON_BE( aWord );
if (bpp != 1 && bpp != 4 && bpp != 8 && bpp != 16 && bpp != 24 && bpp != 32)
{
wxLogError( _T("unknown bitdepth in file.") );
}
stream.Read( dbuf, 4 * 4 );
- int comp = (int)wxINT32_SWAP_FROM_LE( dbuf[0] );
+ int comp = (int)wxINT32_SWAP_ON_BE( dbuf[0] );
if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS)
{
wxLogError( _T("unknown encoding in Windows BMP file.") );
}
stream.Read( dbuf, 4 * 2 );
- int ncolors = (int)wxINT32_SWAP_FROM_LE( dbuf[0] );
+ int ncolors = (int)wxINT32_SWAP_ON_BE( dbuf[0] );
if (ncolors == 0)
ncolors = 1 << bpp;
/* some more sanity checks */
{
int bit = 0;
stream.Read( dbuf, 4 * 3 );
- bmask = wxINT32_SWAP_FROM_LE( dbuf[0] );
- gmask = wxINT32_SWAP_FROM_LE( dbuf[1] );
- rmask = wxINT32_SWAP_FROM_LE( dbuf[2] );
+ bmask = wxINT32_SWAP_ON_BE( dbuf[0] );
+ gmask = wxINT32_SWAP_ON_BE( dbuf[1] );
+ rmask = wxINT32_SWAP_ON_BE( dbuf[2] );
/* find shift amount.. ugly, but i can't think of a better way */
for (bit = 0; bit < bpp; bit++)
{
{
unsigned char temp;
stream.Read( &aWord, 2 );
- aWord = wxUINT16_SWAP_FROM_LE( aWord );
+ aWord = wxUINT16_SWAP_ON_BE( aWord );
linepos += 2;
temp = (aWord & rmask) >> rshift;
ptr[poffset] = temp;
{
unsigned char temp;
stream.Read( &aDword, 4 );
- aDword = wxINT32_SWAP_FROM_LE( aDword );
+ aDword = wxINT32_SWAP_ON_BE( aDword );
linepos += 4;
temp = (aDword & rmask) >> rshift;
ptr[poffset] = temp;
for (unsigned int i=0; i<selection_data->length/sizeof(GdkAtom); i++)
{
-/* char *name = gdk_atom_name (atoms[i]);
+/* char *name = gdk_atom_name (atoms[i]);
if (name) printf( "Format available: %s.\n", name ); */
if (atoms[i] == clipboard->m_targetRequested)
m_formatSupported = FALSE;
m_targetRequested = 0;
+
+ m_usePrimary = FALSE;
}
wxClipboard::~wxClipboard()
wxCHECK_MSG( !m_open, FALSE, _T("clipboard already open") );
m_open = TRUE;
- UsePrimarySelection(FALSE);
return TRUE;
}
(gpointer) NULL );
#endif
-// printf( "vorher.\n" );
/* Tell the world we offer clipboard data */
if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
}
m_ownsClipboard = TRUE;
-// printf( "nachher.\n" );
-
- return TRUE;
-
if (!gtk_selection_owner_set( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME ))
for (unsigned int i=0; i<selection_data->length/sizeof(GdkAtom); i++)
{
-/* char *name = gdk_atom_name (atoms[i]);
+/* char *name = gdk_atom_name (atoms[i]);
if (name) printf( "Format available: %s.\n", name ); */
if (atoms[i] == clipboard->m_targetRequested)
m_formatSupported = FALSE;
m_targetRequested = 0;
+
+ m_usePrimary = FALSE;
}
wxClipboard::~wxClipboard()
wxCHECK_MSG( !m_open, FALSE, _T("clipboard already open") );
m_open = TRUE;
- UsePrimarySelection(FALSE);
return TRUE;
}
(gpointer) NULL );
#endif
-// printf( "vorher.\n" );
/* Tell the world we offer clipboard data */
if (!gtk_selection_owner_set( m_clipboardWidget,
g_clipboardAtom,
}
m_ownsClipboard = TRUE;
-// printf( "nachher.\n" );
-
- return TRUE;
-
if (!gtk_selection_owner_set( m_clipboardWidget,
GDK_SELECTION_PRIMARY,
GDK_CURRENT_TIME ))