wxX11:
Lots of wxBitmap et al work. Adapted wxIcon, wxCursor to this. Split wxApp init things up so that the X11 display is available sooner. Changed initial display code accordingly. Corrected wxDC::DrawBitmap. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14170 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -91,12 +91,15 @@ public:
|
|||||||
|
|
||||||
WXWindow GetTopLevelWidget() const { return m_topLevelWidget; }
|
WXWindow GetTopLevelWidget() const { return m_topLevelWidget; }
|
||||||
WXColormap GetMainColormap(WXDisplay* display);
|
WXColormap GetMainColormap(WXDisplay* display);
|
||||||
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
|
|
||||||
long GetMaxRequestSize() const { return m_maxRequestSize; }
|
long GetMaxRequestSize() const { return m_maxRequestSize; }
|
||||||
|
|
||||||
// This handler is called when a property change event occurs
|
// This handler is called when a property change event occurs
|
||||||
virtual void HandlePropertyChange(WXEvent *event);
|
virtual void HandlePropertyChange(WXEvent *event);
|
||||||
|
|
||||||
|
// We need this before create the app
|
||||||
|
static WXDisplay* GetDisplay() { return ms_display; }
|
||||||
|
static WXDisplay* ms_display;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static long sm_lastMessageTime;
|
static long sm_lastMessageTime;
|
||||||
int m_nCmdShow;
|
int m_nCmdShow;
|
||||||
@@ -106,7 +109,6 @@ protected:
|
|||||||
|
|
||||||
WXWindow m_topLevelWidget;
|
WXWindow m_topLevelWidget;
|
||||||
WXColormap m_mainColormap;
|
WXColormap m_mainColormap;
|
||||||
WXDisplay* m_initialDisplay;
|
|
||||||
long m_maxRequestSize;
|
long m_maxRequestSize;
|
||||||
wxEventLoop* m_mainLoop;
|
wxEventLoop* m_mainLoop;
|
||||||
|
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: bitmap.h
|
// Name: bitmap.h
|
||||||
// Purpose: wxBitmap class
|
// Purpose: wxBitmap class
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart, Robert Roebling
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 17/09/98
|
// Created: 17/09/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart, Robert Roebling
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -16,203 +16,117 @@
|
|||||||
#pragma interface "bitmap.h"
|
#pragma interface "bitmap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/defs.h"
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/object.h"
|
||||||
|
#include "wx/string.h"
|
||||||
#include "wx/palette.h"
|
#include "wx/palette.h"
|
||||||
|
#include "wx/gdiobj.h"
|
||||||
|
|
||||||
// Bitmap
|
//-----------------------------------------------------------------------------
|
||||||
class WXDLLEXPORT wxDC;
|
// classes
|
||||||
class WXDLLEXPORT wxControl;
|
//-----------------------------------------------------------------------------
|
||||||
class WXDLLEXPORT wxBitmap;
|
|
||||||
class WXDLLEXPORT wxBitmapHandler;
|
|
||||||
class WXDLLEXPORT wxIcon;
|
|
||||||
class WXDLLEXPORT wxCursor;
|
|
||||||
class WXDLLEXPORT wxImage;
|
|
||||||
|
|
||||||
// A mask is a mono bitmap used for drawing bitmaps
|
class wxMask;
|
||||||
// transparently.
|
class wxBitmap;
|
||||||
class WXDLLEXPORT wxMask: public wxObject
|
class wxImage;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxMask
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxMask: public wxObject
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMask)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxMask();
|
wxMask();
|
||||||
|
wxMask( const wxBitmap& bitmap, const wxColour& colour );
|
||||||
// Construct a mask from a bitmap and a colour indicating
|
wxMask( const wxBitmap& bitmap, int paletteIndex );
|
||||||
// the transparent area
|
wxMask( const wxBitmap& bitmap );
|
||||||
wxMask(const wxBitmap& bitmap, const wxColour& colour);
|
|
||||||
|
|
||||||
// Construct a mask from a bitmap and a palette index indicating
|
|
||||||
// the transparent area
|
|
||||||
wxMask(const wxBitmap& bitmap, int paletteIndex);
|
|
||||||
|
|
||||||
// Construct a mask from a mono bitmap (copies the bitmap).
|
|
||||||
wxMask(const wxBitmap& bitmap);
|
|
||||||
|
|
||||||
~wxMask();
|
~wxMask();
|
||||||
|
|
||||||
|
bool Create( const wxBitmap& bitmap, const wxColour& colour );
|
||||||
|
bool Create( const wxBitmap& bitmap, int paletteIndex );
|
||||||
|
bool Create( const wxBitmap& bitmap );
|
||||||
|
|
||||||
|
// implementation
|
||||||
|
WXPixmap GetBitmap() const { return m_bitmap; }
|
||||||
|
void SetBitmap( WXPixmap bitmap ) { m_bitmap = bitmap; }
|
||||||
|
|
||||||
bool Create(const wxBitmap& bitmap, const wxColour& colour);
|
WXDisplay *GetDisplay() const { return m_display; }
|
||||||
bool Create(const wxBitmap& bitmap, int paletteIndex);
|
void SetDisplay( WXDisplay *display ) { m_display = display; }
|
||||||
bool Create(const wxBitmap& bitmap);
|
|
||||||
|
|
||||||
WXPixmap GetPixmap() const { return m_pixmap; }
|
private:
|
||||||
void SetPixmap(WXPixmap pixmap) { m_pixmap = pixmap; }
|
WXPixmap m_bitmap;
|
||||||
|
WXDisplay *m_display;
|
||||||
protected:
|
|
||||||
WXPixmap m_pixmap;
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxMask)
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxBitmap
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxBitmap: public wxGDIObject
|
||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
|
||||||
friend class WXDLLEXPORT wxIcon;
|
|
||||||
friend class WXDLLEXPORT wxCursor;
|
|
||||||
public:
|
public:
|
||||||
wxBitmapRefData();
|
wxBitmap();
|
||||||
~wxBitmapRefData();
|
wxBitmap( int width, int height, int depth = -1 );
|
||||||
|
wxBitmap( const char bits[], int width, int height, int depth = 1 );
|
||||||
public:
|
wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
|
||||||
int m_width;
|
wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
|
||||||
int m_height;
|
wxBitmap( const wxBitmap& bmp );
|
||||||
int m_depth;
|
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM );
|
||||||
bool m_ok;
|
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
|
||||||
int m_numColors;
|
|
||||||
wxPalette m_bitmapPalette;
|
|
||||||
int m_quality;
|
|
||||||
|
|
||||||
wxMask * m_bitmapMask; // Optional mask
|
|
||||||
|
|
||||||
// Motif implementation
|
|
||||||
public:
|
|
||||||
WXPixmap m_pixmap;
|
|
||||||
WXDisplay* m_display;
|
|
||||||
bool m_freePixmap;
|
|
||||||
unsigned long* m_freeColors;
|
|
||||||
long m_freeColorsCount;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmapHandler: public wxObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
|
|
||||||
public:
|
|
||||||
wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; };
|
|
||||||
|
|
||||||
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
|
|
||||||
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth, int desiredHeight);
|
|
||||||
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
|
|
||||||
|
|
||||||
void SetName(const wxString& name) { m_name = name; }
|
|
||||||
void SetExtension(const wxString& ext) { m_extension = ext; }
|
|
||||||
void SetType(long type) { m_type = type; }
|
|
||||||
wxString GetName() const { return m_name; }
|
|
||||||
wxString GetExtension() const { return m_extension; }
|
|
||||||
long GetType() const { return m_type; }
|
|
||||||
protected:
|
|
||||||
wxString m_name;
|
|
||||||
wxString m_extension;
|
|
||||||
long m_type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBitmap: public wxGDIObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
|
||||||
|
|
||||||
friend class WXDLLEXPORT wxBitmapHandler;
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxBitmap(); // Platform-specific
|
|
||||||
|
|
||||||
// Copy constructors
|
|
||||||
wxBitmap(const wxBitmap& bitmap)
|
|
||||||
{ Ref(bitmap); }
|
|
||||||
|
|
||||||
// Initialize with raw XBM data
|
|
||||||
wxBitmap(const char bits[], int width, int height, int depth = 1);
|
|
||||||
|
|
||||||
// from XPM
|
|
||||||
wxBitmap(const char **data) { (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); }
|
|
||||||
wxBitmap(char **data) { (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); }
|
|
||||||
|
|
||||||
// Load a file or resource
|
|
||||||
wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM);
|
|
||||||
|
|
||||||
// Constructor for generalised creation from data
|
|
||||||
wxBitmap(void *data, long type, int width, int height, int depth = 1);
|
|
||||||
|
|
||||||
// If depth is omitted, will create a bitmap compatible with the display
|
|
||||||
wxBitmap(int width, int height, int depth = -1);
|
|
||||||
|
|
||||||
// Convert from wxImage:
|
|
||||||
wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); }
|
|
||||||
|
|
||||||
~wxBitmap();
|
~wxBitmap();
|
||||||
|
wxBitmap& operator = ( const wxBitmap& bmp );
|
||||||
|
bool operator == ( const wxBitmap& bmp ) const;
|
||||||
|
bool operator != ( const wxBitmap& bmp ) const;
|
||||||
|
bool Ok() const;
|
||||||
|
|
||||||
|
bool Create(int width, int height, int depth = -1);
|
||||||
|
|
||||||
virtual bool Create(int width, int height, int depth = -1);
|
int GetHeight() const;
|
||||||
virtual bool Create(void *data, long type, int width, int height, int depth = 1);
|
int GetWidth() const;
|
||||||
|
int GetDepth() const;
|
||||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
|
||||||
|
|
||||||
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_XPM);
|
|
||||||
virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
|
|
||||||
|
|
||||||
wxImage ConvertToImage() const;
|
wxImage ConvertToImage() const;
|
||||||
|
|
||||||
bool CopyFromIcon(const wxIcon& icon);
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||||
|
virtual bool CopyFromIcon(const wxIcon& icon);
|
||||||
bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); }
|
|
||||||
int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
|
|
||||||
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
|
|
||||||
int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
|
|
||||||
int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
|
|
||||||
void SetWidth(int w);
|
|
||||||
void SetHeight(int h);
|
|
||||||
void SetDepth(int d);
|
|
||||||
void SetQuality(int q);
|
|
||||||
void SetOk(bool isOk);
|
|
||||||
|
|
||||||
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
|
|
||||||
void SetPalette(const wxPalette& palette);
|
|
||||||
|
|
||||||
wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); }
|
|
||||||
void SetMask(wxMask *mask) ;
|
|
||||||
|
|
||||||
wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
|
|
||||||
bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
|
|
||||||
bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
|
|
||||||
|
|
||||||
// Format handling
|
|
||||||
static wxList& GetHandlers() { return sm_handlers; }
|
|
||||||
static void AddHandler(wxBitmapHandler *handler);
|
|
||||||
static void InsertHandler(wxBitmapHandler *handler);
|
|
||||||
static bool RemoveHandler(const wxString& name);
|
|
||||||
static wxBitmapHandler *FindHandler(const wxString& name);
|
|
||||||
static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
|
|
||||||
static wxBitmapHandler *FindHandler(long bitmapType);
|
|
||||||
|
|
||||||
static void InitStandardHandlers();
|
|
||||||
static void CleanUpHandlers();
|
|
||||||
|
|
||||||
// Motif implementation
|
|
||||||
public:
|
|
||||||
WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; }
|
|
||||||
WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; }
|
|
||||||
void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
static wxList sm_handlers;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Creates a bitmap with transparent areas drawn in
|
wxMask *GetMask() const;
|
||||||
// the given colour.
|
void SetMask( wxMask *mask );
|
||||||
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour);
|
|
||||||
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||||
|
|
||||||
|
bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL );
|
||||||
|
bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM );
|
||||||
|
|
||||||
|
wxPalette *GetPalette() const;
|
||||||
|
wxPalette *GetColourMap() const
|
||||||
|
{ return GetPalette(); };
|
||||||
|
|
||||||
|
// implementation
|
||||||
|
// --------------
|
||||||
|
|
||||||
|
void SetHeight( int height );
|
||||||
|
void SetWidth( int width );
|
||||||
|
void SetDepth( int depth );
|
||||||
|
void SetPixmap( WXPixmap pixmap );
|
||||||
|
void SetBitmap( WXPixmap bitmap );
|
||||||
|
|
||||||
|
WXPixmap GetPixmap() const;
|
||||||
|
WXPixmap GetBitmap() const;
|
||||||
|
|
||||||
|
WXDisplay *GetDisplay() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool CreateFromXpm(const char **bits);
|
||||||
|
bool CreateFromImage(const wxImage& image, int depth);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxBitmap)
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_BITMAP_H_
|
// _WX_BITMAP_H_
|
||||||
|
@@ -18,67 +18,41 @@
|
|||||||
|
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
/* Cursor for one display, so we can choose the correct one for
|
#if wxUSE_IMAGE
|
||||||
* the current display.
|
#include "wx/image.h"
|
||||||
*/
|
#endif
|
||||||
class wxXCursor : public wxObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxXCursor)
|
|
||||||
|
|
||||||
public:
|
|
||||||
WXDisplay* m_display;
|
|
||||||
WXCursor m_cursor;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
|
//-----------------------------------------------------------------------------
|
||||||
{
|
// wxCursor
|
||||||
friend class WXDLLEXPORT wxBitmap;
|
//-----------------------------------------------------------------------------
|
||||||
friend class WXDLLEXPORT wxCursor;
|
|
||||||
public:
|
|
||||||
wxCursorRefData();
|
|
||||||
~wxCursorRefData();
|
|
||||||
|
|
||||||
wxList m_cursors; // wxXCursor objects, one per display
|
|
||||||
wxStockCursor m_cursorId; // wxWindows standard cursor id
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
|
class wxCursor: public wxObject
|
||||||
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
|
|
||||||
|
|
||||||
// Cursor
|
|
||||||
class WXDLLEXPORT wxCursor: public wxBitmap
|
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxCursor)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
wxCursor();
|
wxCursor();
|
||||||
|
wxCursor( int cursorId );
|
||||||
// Copy constructors
|
wxCursor( const wxCursor &cursor );
|
||||||
wxCursor(const wxCursor& cursor) { Ref(cursor); }
|
#if wxUSE_IMAGE
|
||||||
|
wxCursor( const wxImage & image );
|
||||||
wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1,
|
#endif
|
||||||
const char maskBits[] = NULL);
|
wxCursor( const char bits[], int width, int height,
|
||||||
|
int hotSpotX=-1, int hotSpotY=-1,
|
||||||
wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM,
|
const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0 );
|
||||||
int hotSpotX = 0, int hotSpotY = 0);
|
|
||||||
|
|
||||||
wxCursor(wxStockCursor id);
|
|
||||||
~wxCursor();
|
~wxCursor();
|
||||||
|
wxCursor& operator = ( const wxCursor& cursor );
|
||||||
virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); }
|
bool operator == ( const wxCursor& cursor ) const;
|
||||||
|
bool operator != ( const wxCursor& cursor ) const;
|
||||||
wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
|
bool Ok() const;
|
||||||
bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
|
|
||||||
bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
|
// implementation
|
||||||
|
|
||||||
// Motif-specific.
|
WXCursor GetCursor() const;
|
||||||
// Create/get a cursor for the current display
|
|
||||||
WXCursor GetXCursor(WXDisplay* display) ;
|
private:
|
||||||
// Make a cursor from standard id
|
DECLARE_DYNAMIC_CLASS(wxCursor)
|
||||||
WXCursor MakeCursor(WXDisplay* display, wxStockCursor id);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_CURSOR_H_
|
// _WX_CURSOR_H_
|
||||||
|
@@ -18,42 +18,39 @@
|
|||||||
|
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
#define M_ICONDATA ((wxBitmapRefData *)m_refData)
|
//-----------------------------------------------------------------------------
|
||||||
#define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
|
// wxIcon
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
// Icon
|
class wxIcon: public wxBitmap
|
||||||
class WXDLLEXPORT wxIcon: public wxBitmap
|
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxIcon)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxIcon();
|
wxIcon();
|
||||||
|
wxIcon( const wxIcon& icon);
|
||||||
// Copy constructors
|
wxIcon( const char **bits, int width=-1, int height=-1 );
|
||||||
inline wxIcon(const wxIcon& icon) { Ref(icon); }
|
|
||||||
|
|
||||||
// Initialize with XBM data
|
|
||||||
wxIcon(const char bits[], int width, int height);
|
|
||||||
|
|
||||||
// Initialize with XPM data
|
|
||||||
wxIcon(const char **data);
|
|
||||||
wxIcon(char **data);
|
|
||||||
|
|
||||||
wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_XPM,
|
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
|
||||||
~wxIcon();
|
|
||||||
|
|
||||||
bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_XPM,
|
|
||||||
int desiredWidth = -1, int desiredHeight = -1);
|
|
||||||
|
|
||||||
inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
|
|
||||||
inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; }
|
|
||||||
inline bool operator != (const wxIcon& icon) const { return m_refData != icon.m_refData; }
|
|
||||||
|
|
||||||
virtual bool Ok() const { return ((m_refData != NULL) && (M_ICONDATA->m_ok)); }
|
|
||||||
|
|
||||||
bool CopyFromBitmap(const wxBitmap& bitmap);
|
// For compatibility with wxMSW where desired size is sometimes required to
|
||||||
|
// distinguish between multiple icons in a resource.
|
||||||
|
wxIcon( const wxString& filename, int type = wxBITMAP_TYPE_XPM,
|
||||||
|
int WXUNUSED(desiredWidth)=-1, int WXUNUSED(desiredHeight)=-1 ) :
|
||||||
|
wxBitmap(filename, type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
wxIcon( char **bits, int width=-1, int height=-1 );
|
||||||
|
|
||||||
|
wxIcon& operator = (const wxIcon& icon);
|
||||||
|
inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; }
|
||||||
|
inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; }
|
||||||
|
|
||||||
|
// create from bitmap (which should have a mask unless it's monochrome):
|
||||||
|
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
|
||||||
|
// ctors, assignment operators...), but it's ok to have such function
|
||||||
|
void CopyFromBitmap(const wxBitmap& bmp);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxIcon)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_ICON_H_
|
// _WX_ICON_H_
|
||||||
|
@@ -43,7 +43,7 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// the application icon
|
// the application icon
|
||||||
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__)
|
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
|
||||||
#include "mondrian.xpm"
|
#include "mondrian.xpm"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -602,9 +602,7 @@ void wxApp::CleanUp()
|
|||||||
wxCleanUpResourceSystem();
|
wxCleanUpResourceSystem();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (wxTheColourDatabase)
|
delete wxTheColourDatabase;
|
||||||
delete wxTheColourDatabase;
|
|
||||||
|
|
||||||
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
||||||
|
|
||||||
wxDeleteStockObjects();
|
wxDeleteStockObjects();
|
||||||
@@ -614,17 +612,16 @@ void wxApp::CleanUp()
|
|||||||
delete wxTheApp;
|
delete wxTheApp;
|
||||||
wxTheApp = (wxApp*) NULL;
|
wxTheApp = (wxApp*) NULL;
|
||||||
|
|
||||||
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
delete[] wxBuffer;
|
||||||
// create a module for that as it's part of the core.
|
wxBuffer = NULL;
|
||||||
|
|
||||||
|
wxClassInfo::CleanUpClasses();
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
delete wxPendingEvents;
|
delete wxPendingEvents;
|
||||||
delete wxPendingEventsLocker;
|
delete wxPendingEventsLocker;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete[] wxBuffer;
|
|
||||||
|
|
||||||
wxClassInfo::CleanUpClasses();
|
|
||||||
|
|
||||||
// check for memory leaks
|
// check for memory leaks
|
||||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||||
|
@@ -300,6 +300,8 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
|
|
||||||
bool wxBitmap::CreateFromXpm( const char **bits )
|
bool wxBitmap::CreateFromXpm( const char **bits )
|
||||||
{
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
||||||
|
|
||||||
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
||||||
@@ -327,6 +329,8 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
|
|
||||||
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
||||||
{
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
||||||
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
|
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
@@ -510,7 +514,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
if (bpp > 8)
|
if (bpp > 8)
|
||||||
{
|
{
|
||||||
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||||
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RBG;
|
||||||
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||||
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||||
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||||
|
@@ -602,9 +602,7 @@ void wxApp::CleanUp()
|
|||||||
wxCleanUpResourceSystem();
|
wxCleanUpResourceSystem();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (wxTheColourDatabase)
|
delete wxTheColourDatabase;
|
||||||
delete wxTheColourDatabase;
|
|
||||||
|
|
||||||
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
wxTheColourDatabase = (wxColourDatabase*) NULL;
|
||||||
|
|
||||||
wxDeleteStockObjects();
|
wxDeleteStockObjects();
|
||||||
@@ -614,17 +612,16 @@ void wxApp::CleanUp()
|
|||||||
delete wxTheApp;
|
delete wxTheApp;
|
||||||
wxTheApp = (wxApp*) NULL;
|
wxTheApp = (wxApp*) NULL;
|
||||||
|
|
||||||
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
delete[] wxBuffer;
|
||||||
// create a module for that as it's part of the core.
|
wxBuffer = NULL;
|
||||||
|
|
||||||
|
wxClassInfo::CleanUpClasses();
|
||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
delete wxPendingEvents;
|
delete wxPendingEvents;
|
||||||
delete wxPendingEventsLocker;
|
delete wxPendingEventsLocker;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete[] wxBuffer;
|
|
||||||
|
|
||||||
wxClassInfo::CleanUpClasses();
|
|
||||||
|
|
||||||
// check for memory leaks
|
// check for memory leaks
|
||||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||||
|
@@ -300,6 +300,8 @@ bool wxBitmap::Create( int width, int height, int depth )
|
|||||||
|
|
||||||
bool wxBitmap::CreateFromXpm( const char **bits )
|
bool wxBitmap::CreateFromXpm( const char **bits )
|
||||||
{
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
|
||||||
|
|
||||||
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
GdkVisual *visual = wxTheApp->GetGdkVisual();
|
||||||
@@ -327,6 +329,8 @@ bool wxBitmap::CreateFromXpm( const char **bits )
|
|||||||
|
|
||||||
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
||||||
{
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
||||||
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
|
wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") )
|
||||||
|
|
||||||
@@ -510,7 +514,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
if (bpp > 8)
|
if (bpp > 8)
|
||||||
{
|
{
|
||||||
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB;
|
||||||
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RGB;
|
else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RBG;
|
||||||
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG;
|
||||||
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR;
|
||||||
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB;
|
||||||
|
103
src/x11/app.cpp
103
src/x11/app.cpp
@@ -79,6 +79,7 @@ static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
|
|||||||
#endif // __WXDEBUG__
|
#endif // __WXDEBUG__
|
||||||
|
|
||||||
long wxApp::sm_lastMessageTime = 0;
|
long wxApp::sm_lastMessageTime = 0;
|
||||||
|
WXDisplay *wxApp::ms_display = NULL;
|
||||||
|
|
||||||
bool wxApp::Initialize()
|
bool wxApp::Initialize()
|
||||||
{
|
{
|
||||||
@@ -102,8 +103,6 @@ bool wxApp::Initialize()
|
|||||||
wxInitializeResourceSystem();
|
wxInitializeResourceSystem();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxBitmap::InitStandardHandlers();
|
|
||||||
|
|
||||||
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
|
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
|
||||||
|
|
||||||
wxModule::RegisterModules();
|
wxModule::RegisterModules();
|
||||||
@@ -123,27 +122,21 @@ void wxApp::CleanUp()
|
|||||||
wxCleanUpResourceSystem();
|
wxCleanUpResourceSystem();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxDeleteStockObjects() ;
|
|
||||||
|
|
||||||
// Destroy all GDI lists, etc.
|
|
||||||
|
|
||||||
wxDeleteStockLists();
|
|
||||||
|
|
||||||
delete wxTheColourDatabase;
|
delete wxTheColourDatabase;
|
||||||
wxTheColourDatabase = NULL;
|
wxTheColourDatabase = NULL;
|
||||||
|
|
||||||
wxBitmap::CleanUpHandlers();
|
wxDeleteStockObjects();
|
||||||
|
|
||||||
|
wxDeleteStockLists();
|
||||||
|
|
||||||
|
delete wxTheApp;
|
||||||
|
wxTheApp = NULL;
|
||||||
|
|
||||||
delete[] wxBuffer;
|
delete[] wxBuffer;
|
||||||
wxBuffer = NULL;
|
wxBuffer = NULL;
|
||||||
|
|
||||||
wxClassInfo::CleanUpClasses();
|
wxClassInfo::CleanUpClasses();
|
||||||
|
|
||||||
delete wxTheApp;
|
|
||||||
wxTheApp = NULL;
|
|
||||||
|
|
||||||
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
|
||||||
// create a module for that as it's part of the core.
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
delete wxPendingEvents;
|
delete wxPendingEvents;
|
||||||
delete wxPendingEventsLocker;
|
delete wxPendingEventsLocker;
|
||||||
@@ -168,6 +161,46 @@ void wxApp::CleanUp()
|
|||||||
delete wxLog::SetActiveTarget(NULL);
|
delete wxLog::SetActiveTarget(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NB: argc and argv may be changed here, pass by reference!
|
||||||
|
int wxEntryStart( int& argc, char *argv[] )
|
||||||
|
{
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
// install the X error handler
|
||||||
|
gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
|
||||||
|
#endif // __WXDEBUG__
|
||||||
|
|
||||||
|
Display* xdisplay = XOpenDisplay(NULL);
|
||||||
|
|
||||||
|
if (!xdisplay)
|
||||||
|
{
|
||||||
|
wxLogError( _("wxWindows could not open display. Exiting.") );
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxApp::ms_display = (WXDisplay*) xdisplay;
|
||||||
|
|
||||||
|
XSelectInput( xdisplay, XDefaultRootWindow(xdisplay), PropertyChangeMask);
|
||||||
|
|
||||||
|
// wxSetDetectableAutoRepeat( TRUE );
|
||||||
|
|
||||||
|
if (!wxApp::Initialize())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int wxEntryInitGui()
|
||||||
|
{
|
||||||
|
int retValue = 0;
|
||||||
|
|
||||||
|
if ( !wxTheApp->OnInitGui() )
|
||||||
|
retValue = -1;
|
||||||
|
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int wxEntry( int argc, char *argv[] )
|
int wxEntry( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||||
@@ -179,9 +212,9 @@ int wxEntry( int argc, char *argv[] )
|
|||||||
// checked, but this is a reasonable compromise.
|
// checked, but this is a reasonable compromise.
|
||||||
wxDebugContext::SetCheckpoint();
|
wxDebugContext::SetCheckpoint();
|
||||||
#endif
|
#endif
|
||||||
|
int err = wxEntryStart(argc, argv);
|
||||||
if (!wxApp::Initialize())
|
if (err)
|
||||||
return FALSE;
|
return err;
|
||||||
|
|
||||||
if (!wxTheApp)
|
if (!wxTheApp)
|
||||||
{
|
{
|
||||||
@@ -206,14 +239,18 @@ int wxEntry( int argc, char *argv[] )
|
|||||||
wxTheApp->argc = argc;
|
wxTheApp->argc = argc;
|
||||||
wxTheApp->argv = argv;
|
wxTheApp->argv = argv;
|
||||||
|
|
||||||
// GUI-specific initialization, such as creating an app context.
|
int retValue;
|
||||||
wxTheApp->OnInitGui();
|
retValue = wxEntryInitGui();
|
||||||
|
|
||||||
// Here frames insert themselves automatically into wxTopLevelWindows by
|
// Here frames insert themselves automatically into wxTopLevelWindows by
|
||||||
// getting created in OnInit().
|
// getting created in OnInit().
|
||||||
|
if ( retValue == 0 )
|
||||||
|
{
|
||||||
|
if ( !wxTheApp->OnInit() )
|
||||||
|
retValue = -1;
|
||||||
|
}
|
||||||
|
|
||||||
int retValue = 0;
|
if ( retValue == 0 )
|
||||||
if (wxTheApp->OnInit())
|
|
||||||
{
|
{
|
||||||
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
|
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
|
||||||
}
|
}
|
||||||
@@ -257,7 +294,6 @@ wxApp::wxApp()
|
|||||||
m_mainColormap = (WXColormap) NULL;
|
m_mainColormap = (WXColormap) NULL;
|
||||||
m_topLevelWidget = (WXWindow) NULL;
|
m_topLevelWidget = (WXWindow) NULL;
|
||||||
m_maxRequestSize = 0;
|
m_maxRequestSize = 0;
|
||||||
m_initialDisplay = (WXDisplay*) 0;
|
|
||||||
m_mainLoop = NULL;
|
m_mainLoop = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,30 +657,13 @@ bool wxApp::OnInitGui()
|
|||||||
// now we don't want to try popping up a dialog
|
// now we don't want to try popping up a dialog
|
||||||
// for error messages.
|
// for error messages.
|
||||||
delete wxLog::SetActiveTarget(new wxLogStderr);
|
delete wxLog::SetActiveTarget(new wxLogStderr);
|
||||||
|
|
||||||
if (!wxAppBase::OnInitGui())
|
if (!wxAppBase::OnInitGui())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// TODO: parse argv and get display to pass to XOpenDisplay
|
|
||||||
Display* dpy = XOpenDisplay(NULL);
|
|
||||||
m_initialDisplay = (WXDisplay*) dpy;
|
|
||||||
|
|
||||||
if (!dpy) {
|
GetMainColormap( wxApp::GetDisplay() );
|
||||||
wxString className(wxTheApp->GetClassName());
|
m_maxRequestSize = XMaxRequestSize( (Display*) wxApp::GetDisplay() );
|
||||||
wxLogError(_("wxWindows could not open display for '%s': exiting."),
|
|
||||||
(const char*) className);
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
XSelectInput((Display*) m_initialDisplay,
|
|
||||||
XDefaultRootWindow((Display*) m_initialDisplay),
|
|
||||||
PropertyChangeMask);
|
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
|
||||||
// install the X error handler
|
|
||||||
gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler);
|
|
||||||
#endif // __WXDEBUG__
|
|
||||||
|
|
||||||
GetMainColormap(dpy);
|
|
||||||
m_maxRequestSize = XMaxRequestSize((Display*) dpy);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
1922
src/x11/bitmap.cpp
1922
src/x11/bitmap.cpp
File diff suppressed because it is too large
Load Diff
@@ -19,422 +19,204 @@
|
|||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
|
|
||||||
#ifdef __VMS__
|
|
||||||
#pragma message disable nosimpint
|
|
||||||
#endif
|
|
||||||
#ifdef __VMS__
|
|
||||||
#pragma message enable nosimpint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
#include <X11/cursorfont.h>
|
#include <X11/cursorfont.h>
|
||||||
#include <X11/Xutil.h>
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
//-----------------------------------------------------------------------------
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject)
|
// wxCursor
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxCursorRefData: public wxObjectRefData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
wxCursorRefData();
|
||||||
|
~wxCursorRefData();
|
||||||
|
|
||||||
|
WXCursor m_cursor;
|
||||||
|
WXDisplay *m_display;
|
||||||
|
};
|
||||||
|
|
||||||
wxCursorRefData::wxCursorRefData()
|
wxCursorRefData::wxCursorRefData()
|
||||||
{
|
{
|
||||||
m_width = 32; m_height = 32;
|
m_cursor = NULL;
|
||||||
m_cursorId = wxCURSOR_NONE;
|
m_display = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursorRefData::~wxCursorRefData()
|
wxCursorRefData::~wxCursorRefData()
|
||||||
{
|
{
|
||||||
wxNode* node = m_cursors.First();
|
if (m_cursor)
|
||||||
while (node)
|
XFreeCursor( (Display*) m_display, (Cursor) m_cursor );
|
||||||
{
|
|
||||||
wxXCursor* c = (wxXCursor*) node->Data();
|
|
||||||
// TODO: how to delete cursor?
|
|
||||||
// XDestroyCursor((Display*) c->m_display, (Cursor) c->m_cursor); // ??
|
|
||||||
delete c;
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject)
|
||||||
|
|
||||||
wxCursor::wxCursor()
|
wxCursor::wxCursor()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::wxCursor(const char bits[], int width, int height,
|
wxCursor::wxCursor( int cursorId )
|
||||||
int hotSpotX, int hotSpotY, const char maskBits[])
|
|
||||||
{
|
{
|
||||||
m_refData = new wxCursorRefData;
|
m_refData = new wxCursorRefData();
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
M_CURSORDATA->m_display = wxGlobalDisplay();
|
||||||
int screen_num = DefaultScreen (dpy);
|
wxASSERT_MSG( M_CURSORDATA->m_display, wxT("No display") );
|
||||||
|
|
||||||
Pixmap pixmap = XCreatePixmapFromBitmapData (dpy,
|
int x_cur = XC_left_ptr;
|
||||||
RootWindow (dpy, DefaultScreen(dpy)),
|
switch (cursorId)
|
||||||
(char*) bits, width, height,
|
|
||||||
1 , 0 , 1);
|
|
||||||
|
|
||||||
Pixmap mask_pixmap = None;
|
|
||||||
if (maskBits != NULL)
|
|
||||||
{
|
{
|
||||||
mask_pixmap = XCreatePixmapFromBitmapData (dpy,
|
case wxCURSOR_DEFAULT: x_cur = XC_left_ptr; break;
|
||||||
RootWindow (dpy, DefaultScreen(dpy)),
|
case wxCURSOR_HAND: x_cur = XC_hand1; break;
|
||||||
(char*) maskBits, width, height,
|
case wxCURSOR_CROSS: x_cur = XC_crosshair; break;
|
||||||
1 , 0 , 1);
|
case wxCURSOR_SIZEWE: x_cur = XC_sb_h_double_arrow; break;
|
||||||
|
case wxCURSOR_SIZENS: x_cur = XC_sb_v_double_arrow; break;
|
||||||
|
case wxCURSOR_ARROWWAIT:
|
||||||
|
case wxCURSOR_WAIT:
|
||||||
|
case wxCURSOR_WATCH: x_cur = XC_watch; break;
|
||||||
|
case wxCURSOR_SIZING: x_cur = XC_sizing; break;
|
||||||
|
case wxCURSOR_SPRAYCAN: x_cur = XC_spraycan; break;
|
||||||
|
case wxCURSOR_IBEAM: x_cur = XC_xterm; break;
|
||||||
|
case wxCURSOR_PENCIL: x_cur = XC_pencil; break;
|
||||||
|
case wxCURSOR_NO_ENTRY: x_cur = XC_pirate; break;
|
||||||
|
case wxCURSOR_SIZENWSE:
|
||||||
|
case wxCURSOR_SIZENESW: x_cur = XC_fleur; break;
|
||||||
|
case wxCURSOR_QUESTION_ARROW: x_cur = XC_question_arrow; break;
|
||||||
|
case wxCURSOR_PAINT_BRUSH: x_cur = XC_spraycan; break;
|
||||||
|
case wxCURSOR_MAGNIFIER: x_cur = XC_plus; break;
|
||||||
|
case wxCURSOR_CHAR: x_cur = XC_xterm; break;
|
||||||
|
case wxCURSOR_LEFT_BUTTON: x_cur = XC_leftbutton; break;
|
||||||
|
case wxCURSOR_MIDDLE_BUTTON: x_cur = XC_middlebutton; break;
|
||||||
|
case wxCURSOR_RIGHT_BUTTON: x_cur = XC_rightbutton; break;
|
||||||
|
case wxCURSOR_BULLSEYE: x_cur = XC_target; break;
|
||||||
|
|
||||||
|
case wxCURSOR_POINT_LEFT: x_cur = XC_sb_left_arrow; break;
|
||||||
|
case wxCURSOR_POINT_RIGHT: x_cur = XC_sb_right_arrow; break;
|
||||||
|
/*
|
||||||
|
case wxCURSOR_DOUBLE_ARROW: x_cur = XC_double_arrow; break;
|
||||||
|
case wxCURSOR_CROSS_REVERSE: x_cur = XC_cross_reverse; break;
|
||||||
|
case wxCURSOR_BASED_ARROW_UP: x_cur = XC_based_arrow_up; break;
|
||||||
|
case wxCURSOR_BASED_ARROW_DOWN: x_cur = XC_based_arrow_down; break;
|
||||||
|
*/
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("unsupported cursor type"));
|
||||||
|
// will use the standard one
|
||||||
}
|
}
|
||||||
|
|
||||||
XColor foreground_color;
|
M_CURSORDATA->m_cursor = (WXCursor) XCreateFontCursor( (Display*) M_CURSORDATA->m_display, x_cur );
|
||||||
XColor background_color;
|
|
||||||
foreground_color.pixel = BlackPixel(dpy, screen_num);
|
|
||||||
background_color.pixel = WhitePixel(dpy, screen_num);
|
|
||||||
Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
|
|
||||||
XQueryColor(dpy, cmap, &foreground_color);
|
|
||||||
XQueryColor(dpy, cmap, &background_color);
|
|
||||||
|
|
||||||
Cursor cursor = XCreatePixmapCursor (dpy,
|
|
||||||
pixmap,
|
|
||||||
mask_pixmap,
|
|
||||||
&foreground_color,
|
|
||||||
&background_color,
|
|
||||||
hotSpotX ,
|
|
||||||
hotSpotY);
|
|
||||||
|
|
||||||
XFreePixmap( dpy, pixmap );
|
|
||||||
if (mask_pixmap != None)
|
|
||||||
{
|
|
||||||
XFreePixmap( dpy, mask_pixmap );
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor)
|
|
||||||
{
|
|
||||||
wxXCursor *c = new wxXCursor;
|
|
||||||
|
|
||||||
c->m_cursor = (WXCursor) cursor;
|
|
||||||
c->m_display = (WXDisplay*) dpy;
|
|
||||||
M_CURSORDATA->m_cursors.Append(c);
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
|
wxCursor::wxCursor(const char bits[], int width, int height,
|
||||||
|
int hotSpotX, int hotSpotY,
|
||||||
|
const char maskBits[], wxColour *fg, wxColour *bg)
|
||||||
{
|
{
|
||||||
// Must be an XBM file
|
wxFAIL_MSG( "wxCursor creation from bits not yet implemented" );
|
||||||
if (flags != wxBITMAP_TYPE_XBM)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_refData = new wxCursorRefData;
|
|
||||||
|
|
||||||
int hotX = -1, hotY = -1;
|
|
||||||
unsigned int w, h;
|
|
||||||
Pixmap pixmap;
|
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
|
||||||
int screen_num = DefaultScreen (dpy);
|
|
||||||
|
|
||||||
int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)),
|
|
||||||
(char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
|
|
||||||
|
|
||||||
M_BITMAPDATA->m_width = w;
|
|
||||||
M_BITMAPDATA->m_height = h;
|
|
||||||
M_BITMAPDATA->m_depth = 1;
|
|
||||||
|
|
||||||
if ((value == BitmapFileInvalid) ||
|
|
||||||
(value == BitmapOpenFailed) ||
|
|
||||||
(value == BitmapNoMemory))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XColor foreground_color;
|
|
||||||
XColor background_color;
|
|
||||||
foreground_color.pixel = BlackPixel(dpy, screen_num);
|
|
||||||
background_color.pixel = WhitePixel(dpy, screen_num);
|
|
||||||
Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
|
|
||||||
XQueryColor(dpy, cmap, &foreground_color);
|
|
||||||
XQueryColor(dpy, cmap, &background_color);
|
|
||||||
|
|
||||||
// TODO: how do we determine whether hotX, hotY were read correctly?
|
|
||||||
if (hotX < 0 || hotY < 0)
|
|
||||||
{
|
|
||||||
hotX = hotSpotX;
|
|
||||||
hotY = hotSpotY;
|
|
||||||
}
|
|
||||||
if (hotX < 0 || hotY < 0)
|
|
||||||
{
|
|
||||||
hotX = 0;
|
|
||||||
hotY = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Pixmap mask_pixmap = None;
|
|
||||||
Cursor cursor = XCreatePixmapCursor (dpy,
|
|
||||||
pixmap,
|
|
||||||
mask_pixmap,
|
|
||||||
&foreground_color,
|
|
||||||
&background_color,
|
|
||||||
hotX,
|
|
||||||
hotY);
|
|
||||||
|
|
||||||
XFreePixmap( dpy, pixmap );
|
|
||||||
if (cursor)
|
|
||||||
{
|
|
||||||
wxXCursor *c = new wxXCursor;
|
|
||||||
|
|
||||||
c->m_cursor = (WXCursor) cursor;
|
|
||||||
c->m_display = (WXDisplay*) dpy;
|
|
||||||
M_CURSORDATA->m_cursors.Append(c);
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursors by stock number
|
|
||||||
wxCursor::wxCursor(wxStockCursor id)
|
wxCursor::wxCursor( const wxCursor &cursor )
|
||||||
{
|
{
|
||||||
m_refData = new wxCursorRefData;
|
Ref( cursor );
|
||||||
M_CURSORDATA->m_cursorId = id;
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
|
|
||||||
WXDisplay* display = wxGetDisplay();
|
|
||||||
if (!display)
|
|
||||||
return;
|
|
||||||
|
|
||||||
WXCursor cursor = GetXCursor(display);
|
|
||||||
if (cursor)
|
|
||||||
{
|
|
||||||
wxXCursor* c = new wxXCursor;
|
|
||||||
c->m_cursor = cursor;
|
|
||||||
c->m_display = wxGetDisplay();
|
|
||||||
M_CURSORDATA->m_cursors.Append(c);
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE
|
||||||
|
wxCursor::wxCursor( const wxImage & image )
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( "wxCursor creation from wxImage not yet implemented" );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
wxCursor::~wxCursor()
|
wxCursor::~wxCursor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Motif-specific: create/get a cursor for the current display
|
wxCursor& wxCursor::operator = ( const wxCursor& cursor )
|
||||||
WXCursor wxCursor::GetXCursor(WXDisplay* display)
|
|
||||||
{
|
{
|
||||||
if (!M_CURSORDATA)
|
if (*this == cursor)
|
||||||
return (WXCursor) 0;
|
return (*this);
|
||||||
wxNode* node = M_CURSORDATA->m_cursors.First();
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
wxXCursor* c = (wxXCursor*) node->Data();
|
|
||||||
if (c->m_display == display)
|
|
||||||
return c->m_cursor;
|
|
||||||
node = node->Next();
|
|
||||||
}
|
|
||||||
|
|
||||||
// No cursor for this display, so let's see if we're an id-type cursor.
|
Ref( cursor );
|
||||||
|
|
||||||
if (M_CURSORDATA->m_cursorId != wxCURSOR_NONE)
|
return *this;
|
||||||
{
|
|
||||||
WXCursor cursor = MakeCursor(display, M_CURSORDATA->m_cursorId);
|
|
||||||
if (cursor)
|
|
||||||
{
|
|
||||||
wxXCursor* c = new wxXCursor;
|
|
||||||
c->m_cursor = cursor;
|
|
||||||
c->m_display = display;
|
|
||||||
M_CURSORDATA->m_cursors.Append(c);
|
|
||||||
return cursor;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return (WXCursor) 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not an id-type cursor, so we don't know how to create it.
|
|
||||||
return (WXCursor) 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a cursor from standard id
|
bool wxCursor::operator == ( const wxCursor& cursor ) const
|
||||||
WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id)
|
|
||||||
{
|
{
|
||||||
Display* dpy = (Display*) display;
|
return m_refData == cursor.m_refData;
|
||||||
Cursor cursor = (Cursor) 0;
|
|
||||||
|
|
||||||
switch (id)
|
|
||||||
{
|
|
||||||
case wxCURSOR_WAIT:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_watch);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_CROSS:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_crosshair);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_CHAR:
|
|
||||||
{
|
|
||||||
// Nothing
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_HAND:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_hand1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_BULLSEYE:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_target);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_PENCIL:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_pencil);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_MAGNIFIER:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_sizing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_IBEAM:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_xterm);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_NO_ENTRY:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_pirate);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_LEFT_BUTTON:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_leftbutton);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_RIGHT_BUTTON:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_rightbutton);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_MIDDLE_BUTTON:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_middlebutton);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_QUESTION_ARROW:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_question_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_SIZING:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_sizing);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_WATCH:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_watch);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_SPRAYCAN:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_spraycan);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_PAINT_BRUSH:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_spraycan);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_SIZENWSE:
|
|
||||||
case wxCURSOR_SIZENESW:
|
|
||||||
{
|
|
||||||
// Not available in X
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_crosshair);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_SIZEWE:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_sb_h_double_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_SIZENS:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_sb_v_double_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_POINT_LEFT:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_sb_left_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_POINT_RIGHT:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_sb_right_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// (JD Huggins) added more stock cursors for X
|
|
||||||
// X-only cursors BEGIN
|
|
||||||
case wxCURSOR_CROSS_REVERSE:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor(dpy, XC_cross_reverse);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_DOUBLE_ARROW:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor(dpy, XC_double_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_BASED_ARROW_UP:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor(dpy, XC_based_arrow_up);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_BASED_ARROW_DOWN:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor(dpy, XC_based_arrow_down);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
case wxCURSOR_ARROW:
|
|
||||||
{
|
|
||||||
cursor = XCreateFontCursor (dpy, XC_top_left_arrow);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case wxCURSOR_BLANK:
|
|
||||||
{
|
|
||||||
GC gc;
|
|
||||||
XGCValues gcv;
|
|
||||||
Pixmap empty_pixmap;
|
|
||||||
XColor blank_color;
|
|
||||||
|
|
||||||
empty_pixmap = XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
|
|
||||||
16, 16, 1);
|
|
||||||
gcv.function = GXxor;
|
|
||||||
gc = XCreateGC (dpy,
|
|
||||||
empty_pixmap,
|
|
||||||
GCFunction,
|
|
||||||
&gcv);
|
|
||||||
XCopyArea (dpy,
|
|
||||||
empty_pixmap,
|
|
||||||
empty_pixmap,
|
|
||||||
gc,
|
|
||||||
0, 0,
|
|
||||||
16, 16,
|
|
||||||
0, 0);
|
|
||||||
XFreeGC (dpy, gc);
|
|
||||||
cursor = XCreatePixmapCursor (dpy,
|
|
||||||
empty_pixmap,
|
|
||||||
empty_pixmap,
|
|
||||||
&blank_color,
|
|
||||||
&blank_color,
|
|
||||||
8, 8);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (WXCursor) cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global cursor setting
|
bool wxCursor::operator != ( const wxCursor& cursor ) const
|
||||||
void wxSetCursor(const wxCursor& WXUNUSED(cursor))
|
|
||||||
{
|
{
|
||||||
// Nothing to do for Motif (no global cursor)
|
return m_refData != cursor.m_refData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxCursor::Ok() const
|
||||||
|
{
|
||||||
|
return (m_refData != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
WXCursor wxCursor::GetCursor() const
|
||||||
|
{
|
||||||
|
return M_CURSORDATA->m_cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// busy cursor routines
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/* extern */ wxCursor g_globalCursor;
|
||||||
|
|
||||||
|
static wxCursor gs_savedCursor;
|
||||||
|
static int gs_busyCount = 0;
|
||||||
|
|
||||||
|
const wxCursor &wxBusyCursor::GetStoredCursor()
|
||||||
|
{
|
||||||
|
return gs_savedCursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxCursor wxBusyCursor::GetBusyCursor()
|
||||||
|
{
|
||||||
|
return wxCursor(wxCURSOR_WATCH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxEndBusyCursor()
|
||||||
|
{
|
||||||
|
if (--gs_busyCount > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxSetCursor( gs_savedCursor );
|
||||||
|
gs_savedCursor = wxNullCursor;
|
||||||
|
|
||||||
|
if (wxTheApp)
|
||||||
|
wxTheApp->SendIdleEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) )
|
||||||
|
{
|
||||||
|
if (gs_busyCount++ > 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wxASSERT_MSG( !gs_savedCursor.Ok(),
|
||||||
|
wxT("forgot to call wxEndBusyCursor, will leak memory") );
|
||||||
|
|
||||||
|
gs_savedCursor = g_globalCursor;
|
||||||
|
|
||||||
|
wxSetCursor( wxCursor(wxCURSOR_WATCH) );
|
||||||
|
|
||||||
|
if (wxTheApp)
|
||||||
|
wxTheApp->SendIdleEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxIsBusy()
|
||||||
|
{
|
||||||
|
return gs_busyCount > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxSetCursor( const wxCursor& cursor )
|
||||||
|
{
|
||||||
|
g_globalCursor = cursor;
|
||||||
|
}
|
||||||
|
@@ -848,7 +848,6 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
|
|||||||
|
|
||||||
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
|
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
|
||||||
|
|
||||||
#if 0
|
|
||||||
bool is_mono = (bitmap.GetBitmap() != NULL);
|
bool is_mono = (bitmap.GetBitmap() != NULL);
|
||||||
|
|
||||||
/* scale/translate size and position */
|
/* scale/translate size and position */
|
||||||
@@ -881,9 +880,11 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
|
|||||||
{
|
{
|
||||||
wxImage image( bitmap );
|
wxImage image( bitmap );
|
||||||
image.Rescale( ww, hh );
|
image.Rescale( ww, hh );
|
||||||
|
#if 0
|
||||||
if (is_mono)
|
if (is_mono)
|
||||||
use_bitmap = image.ConvertToMonoBitmap(255,255,255);
|
use_bitmap = image.ConvertToMonoBitmap(255,255,255);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
use_bitmap = image.ConvertToBitmap();
|
use_bitmap = image.ConvertToBitmap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -892,12 +893,13 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* apply mask if any */
|
/* apply mask if any */
|
||||||
GdkBitmap *mask = (GdkBitmap *) NULL;
|
WXPixmap mask = NULL;
|
||||||
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
|
if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap();
|
||||||
|
{
|
||||||
if (useMask && mask)
|
if (useMask && mask)
|
||||||
{
|
{
|
||||||
GdkBitmap *new_mask = (GdkBitmap*) NULL;
|
WXPixmap new_mask = NULL;
|
||||||
|
#if 0
|
||||||
if (!m_currentClippingRegion.IsNull())
|
if (!m_currentClippingRegion.IsNull())
|
||||||
{
|
{
|
||||||
GdkColor col;
|
GdkColor col;
|
||||||
@@ -917,53 +919,56 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
|
|||||||
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
|
gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh );
|
||||||
gdk_gc_unref( gc );
|
gdk_gc_unref( gc );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (is_mono)
|
if (is_mono)
|
||||||
{
|
{
|
||||||
if (new_mask)
|
if (new_mask)
|
||||||
gdk_gc_set_clip_mask( m_textGC, new_mask );
|
XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) new_mask );
|
||||||
else
|
else
|
||||||
gdk_gc_set_clip_mask( m_textGC, mask );
|
XSetClipMask( (Display*) m_display, (GC) m_textGC, (Pixmap) mask );
|
||||||
gdk_gc_set_clip_origin( m_textGC, xx, yy );
|
XSetClipOrigin( (Display*) m_display, (GC) m_textGC, xx, yy );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (new_mask)
|
if (new_mask)
|
||||||
gdk_gc_set_clip_mask( m_penGC, new_mask );
|
XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) new_mask );
|
||||||
else
|
else
|
||||||
gdk_gc_set_clip_mask( m_penGC, mask );
|
XSetClipMask( (Display*) m_display, (GC) m_penGC, (Pixmap) mask );
|
||||||
gdk_gc_set_clip_origin( m_penGC, xx, yy );
|
XSetClipOrigin( (Display*) m_display, (GC) m_penGC, xx, yy );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (new_mask)
|
if (new_mask)
|
||||||
gdk_bitmap_unref( new_mask );
|
XFreePixmap( (Display*) m_display, (Pixmap) new_mask );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
|
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
|
||||||
drawing a mono-bitmap (XBitmap) we use the current text GC */
|
drawing a mono-bitmap (XBitmap) we use the current text GC */
|
||||||
if (is_mono)
|
if (is_mono)
|
||||||
gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
|
XCopyPlane( (Display*) m_display, (Pixmap) use_bitmap.GetBitmap(), (Window) m_window,
|
||||||
|
(GC) m_textGC, 0, 0, w, h, xx, yy, 1 );
|
||||||
else
|
else
|
||||||
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
|
XCopyArea( (Display*) m_display, (Pixmap) use_bitmap.GetPixmap(), (Window) m_window,
|
||||||
|
(GC) m_penGC, 0, 0, w, h, xx, yy );
|
||||||
|
|
||||||
/* remove mask again if any */
|
/* remove mask again if any */
|
||||||
if (useMask && mask)
|
if (useMask && mask)
|
||||||
{
|
{
|
||||||
if (is_mono)
|
if (is_mono)
|
||||||
{
|
{
|
||||||
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
|
XSetClipMask( (Display*) m_display, (GC) m_textGC, None );
|
||||||
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
|
XSetClipOrigin( (Display*) m_display, (GC) m_textGC, 0, 0 );
|
||||||
if (!m_currentClippingRegion.IsNull())
|
if (!m_currentClippingRegion.IsNull())
|
||||||
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
|
XSetRegion( (Display*) m_display, (GC) m_textGC, (Region) m_currentClippingRegion.GetX11Region() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
|
XSetClipMask( (Display*) m_display, (GC) m_penGC, None );
|
||||||
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
|
XSetClipOrigin( (Display*) m_display, (GC) m_penGC, 0, 0 );
|
||||||
if (!m_currentClippingRegion.IsNull())
|
if (!m_currentClippingRegion.IsNull())
|
||||||
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
|
XSetRegion( (Display*) m_display, (GC) m_penGC, (Region) m_currentClippingRegion.GetX11Region() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
|
||||||
@@ -996,7 +1001,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
|
|||||||
{
|
{
|
||||||
xsrcMask = xsrc; ysrcMask = ysrc;
|
xsrcMask = xsrc; ysrcMask = ysrc;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (srcDC->m_isMemDC)
|
if (srcDC->m_isMemDC)
|
||||||
{
|
{
|
||||||
@@ -1232,13 +1237,6 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
|||||||
x = XLOG2DEV(x);
|
x = XLOG2DEV(x);
|
||||||
y = YLOG2DEV(y);
|
y = YLOG2DEV(y);
|
||||||
|
|
||||||
XCharStruct overall_return;
|
|
||||||
int direction = 0;
|
|
||||||
int slen = text.Length();
|
|
||||||
int ascent = 0;
|
|
||||||
int descent = 0;
|
|
||||||
(void)XTextExtents((XFontStruct*) xfont, (char*) (const char*) text, slen, &direction,
|
|
||||||
&ascent, &descent, &overall_return);
|
|
||||||
#if 0
|
#if 0
|
||||||
wxCoord width = gdk_string_width( font, text.mbc_str() );
|
wxCoord width = gdk_string_width( font, text.mbc_str() );
|
||||||
wxCoord height = font->ascent + font->descent;
|
wxCoord height = font->ascent + font->descent;
|
||||||
@@ -1255,8 +1253,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
|||||||
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
if ((xfont->min_byte1 == 0) && (xfont->max_byte1 == 0))
|
||||||
{
|
{
|
||||||
XDrawString( (Display*) m_display, (Window) m_window,
|
XDrawString( (Display*) m_display, (Window) m_window,
|
||||||
(GC) m_textGC, x, y + ascent, text.c_str(), text.Len() );
|
(GC) m_textGC, x, y + xfont->ascent, text.c_str(), text.Len() );
|
||||||
wxLogDebug("Drawing text %s at %d, %d", text.c_str(), x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -1930,6 +1927,13 @@ wxClientDC::wxClientDC( wxWindow *win )
|
|||||||
: wxWindowDC( win )
|
: wxWindowDC( win )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( win, _T("NULL window in wxClientDC::wxClientDC") );
|
wxCHECK_RET( win, _T("NULL window in wxClientDC::wxClientDC") );
|
||||||
|
|
||||||
|
#ifdef __WXUNIVERSAL__
|
||||||
|
wxPoint ptOrigin = win->GetClientAreaOrigin();
|
||||||
|
SetDeviceOrigin(ptOrigin.x, ptOrigin.y);
|
||||||
|
wxSize size = win->GetClientSize();
|
||||||
|
SetClippingRegion(wxPoint(0, 0), size);
|
||||||
|
#endif // __WXUNIVERSAL__
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxClientDC::DoGetSize(int *width, int *height) const
|
void wxClientDC::DoGetSize(int *width, int *height) const
|
||||||
|
@@ -16,72 +16,42 @@
|
|||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/window.h"
|
#include "wx/window.h"
|
||||||
|
|
||||||
#ifdef __VMS__
|
|
||||||
#pragma message disable nosimpint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __VMS__
|
|
||||||
#pragma message enable nosimpint
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxIcon
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
/*
|
IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap)
|
||||||
* Icons
|
|
||||||
*/
|
|
||||||
|
|
||||||
wxIcon::wxIcon()
|
wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
|
||||||
|
wxBitmap( bits )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create from XBM data
|
wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) :
|
||||||
wxIcon::wxIcon(const char bits[], int width, int height)
|
wxBitmap( bits )
|
||||||
{
|
|
||||||
(void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create from XPM data
|
|
||||||
wxIcon::wxIcon(char **data)
|
|
||||||
{
|
|
||||||
(void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::wxIcon(const char **data)
|
|
||||||
{
|
|
||||||
(void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::wxIcon(const wxString& icon_file, long flags,
|
|
||||||
int desiredWidth, int desiredHeight)
|
|
||||||
|
|
||||||
{
|
|
||||||
LoadFile(icon_file, flags, desiredWidth, desiredHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIcon::~wxIcon()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxIcon::LoadFile(const wxString& filename, long type,
|
wxIcon::wxIcon() : wxBitmap()
|
||||||
int desiredWidth, int desiredHeight)
|
|
||||||
{
|
{
|
||||||
UnRef();
|
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData;
|
|
||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
|
||||||
|
|
||||||
if ( handler )
|
|
||||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxIcon::CopyFromBitmap(const wxBitmap& bitmap)
|
wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap()
|
||||||
{
|
{
|
||||||
wxIcon* icon = (wxIcon*) (& bitmap);
|
Ref(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxIcon& wxIcon::operator = ( const wxIcon& icon )
|
||||||
|
{
|
||||||
|
if (*this == icon) return (*this);
|
||||||
|
Ref(icon);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxIcon::CopyFromBitmap(const wxBitmap& bmp)
|
||||||
|
{
|
||||||
|
wxIcon *icon = (wxIcon*)(&bmp);
|
||||||
*this = *icon;
|
*this = *icon;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
@@ -257,7 +257,7 @@ void wxTopLevelWindowX11::SetIcon(const wxIcon& icon)
|
|||||||
if (icon.GetMask())
|
if (icon.GetMask())
|
||||||
{
|
{
|
||||||
wmHints->flags |= IconMaskHint;
|
wmHints->flags |= IconMaskHint;
|
||||||
wmHints->icon_mask = (Pixmap) icon.GetMask()->GetPixmap();
|
wmHints->icon_mask = (Pixmap) icon.GetMask()->GetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetWMHints(wxGlobalDisplay(), (Window) GetMainWindow(), wmHints);
|
XSetWMHints(wxGlobalDisplay(), (Window) GetMainWindow(), wmHints);
|
||||||
|
@@ -530,85 +530,6 @@ wxSetDefaultResources (const Widget w, const char **resourceSpec, const char *na
|
|||||||
|
|
||||||
#endif // wxUSE_RESOURCES
|
#endif // wxUSE_RESOURCES
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// busy cursor stuff
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static int wxBusyCursorCount = 0;
|
|
||||||
|
|
||||||
// Helper function
|
|
||||||
static void
|
|
||||||
wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
|
|
||||||
{
|
|
||||||
Display *display = (Display*) win->GetXDisplay();
|
|
||||||
|
|
||||||
Window xwin = (Window) win->GetXWindow();
|
|
||||||
if (!xwin)
|
|
||||||
return;
|
|
||||||
|
|
||||||
XSetWindowAttributes attrs;
|
|
||||||
|
|
||||||
if (cursor)
|
|
||||||
{
|
|
||||||
attrs.cursor = (Cursor) cursor->GetXCursor(display);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Restore old cursor
|
|
||||||
if (win->GetCursor().Ok())
|
|
||||||
attrs.cursor = (Cursor) win->GetCursor().GetXCursor(display);
|
|
||||||
else
|
|
||||||
attrs.cursor = None;
|
|
||||||
}
|
|
||||||
if (xwin)
|
|
||||||
XChangeWindowAttributes (display, xwin, CWCursor, &attrs);
|
|
||||||
|
|
||||||
XFlush (display);
|
|
||||||
|
|
||||||
for(wxNode *node = win->GetChildren().First (); node; node = node->Next())
|
|
||||||
{
|
|
||||||
wxWindow *child = (wxWindow *) node->Data ();
|
|
||||||
wxXSetBusyCursor (child, cursor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the cursor to the busy cursor for all windows
|
|
||||||
void wxBeginBusyCursor(wxCursor *cursor)
|
|
||||||
{
|
|
||||||
wxBusyCursorCount++;
|
|
||||||
if (wxBusyCursorCount == 1)
|
|
||||||
{
|
|
||||||
for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next())
|
|
||||||
{
|
|
||||||
wxWindow *win = (wxWindow *) node->Data ();
|
|
||||||
wxXSetBusyCursor (win, cursor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore cursor to normal
|
|
||||||
void wxEndBusyCursor()
|
|
||||||
{
|
|
||||||
if (wxBusyCursorCount == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wxBusyCursorCount--;
|
|
||||||
if (wxBusyCursorCount == 0)
|
|
||||||
{
|
|
||||||
for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next())
|
|
||||||
{
|
|
||||||
wxWindow *win = (wxWindow *) node->Data ();
|
|
||||||
wxXSetBusyCursor (win, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TRUE if we're between the above two calls
|
|
||||||
bool wxIsBusy()
|
|
||||||
{
|
|
||||||
return (wxBusyCursorCount > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// display info
|
// display info
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -682,10 +603,8 @@ WXDisplay *wxGetDisplay()
|
|||||||
{
|
{
|
||||||
if (gs_currentDisplay)
|
if (gs_currentDisplay)
|
||||||
return gs_currentDisplay;
|
return gs_currentDisplay;
|
||||||
else if (wxTheApp)
|
|
||||||
return wxTheApp->GetInitialDisplay();
|
|
||||||
else
|
else
|
||||||
return (WXDisplay*) NULL;
|
return wxApp::GetDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSetDisplay(const wxString& display_name)
|
bool wxSetDisplay(const wxString& display_name)
|
||||||
|
@@ -430,11 +430,10 @@ bool wxWindowX11::SetCursor(const wxCursor& cursor)
|
|||||||
else
|
else
|
||||||
cursor2 = wxSTANDARD_CURSOR;
|
cursor2 = wxSTANDARD_CURSOR;
|
||||||
|
|
||||||
WXDisplay *dpy = GetXDisplay();
|
WXCursor x_cursor = cursor2->GetCursor();
|
||||||
WXCursor x_cursor = cursor2->GetXCursor(dpy);
|
|
||||||
|
|
||||||
Window win = (Window) GetMainWindow();
|
Window win = (Window) GetMainWindow();
|
||||||
XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
|
XDefineCursor((Display*) wxGlobalDisplay(), win, (Cursor) x_cursor);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user