From 329e276aa0f06aef6e1dcde5c197088f4695d449 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 22 Mar 2002 19:14:33 +0000 Subject: [PATCH] added wxBitmap::CopyFromIcon and wxIcon::CopyFromBitmap to wxMotif git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14726 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/motif/bitmap.h | 3 +++ include/wx/motif/icon.h | 5 +++++ src/motif/bitmap.cpp | 6 ++++++ src/motif/icon.cpp | 6 ++++++ 4 files changed, 20 insertions(+) diff --git a/include/wx/motif/bitmap.h b/include/wx/motif/bitmap.h index 23f8bcd9be..943f34cae1 100644 --- a/include/wx/motif/bitmap.h +++ b/include/wx/motif/bitmap.h @@ -171,6 +171,9 @@ public: virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL); wxImage ConvertToImage() const; + + // 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); } diff --git a/include/wx/motif/icon.h b/include/wx/motif/icon.h index 4ddc46c336..365e581757 100644 --- a/include/wx/motif/icon.h +++ b/include/wx/motif/icon.h @@ -45,6 +45,11 @@ public: bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_XPM, int desiredWidth = -1, int desiredHeight = -1); + + // 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); 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; } diff --git a/src/motif/bitmap.cpp b/src/motif/bitmap.cpp index dc6bb3bb82..4747f9ab1d 100644 --- a/src/motif/bitmap.cpp +++ b/src/motif/bitmap.cpp @@ -167,6 +167,12 @@ bool wxBitmap::CreateFromXpm(const char **bits) return Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); } +bool wxBitmap::CopyFromIcon(const wxIcon& icon) +{ + *this = icon; + return TRUE; +} + bool wxBitmap::Create(int w, int h, int d) { UnRef(); diff --git a/src/motif/icon.cpp b/src/motif/icon.cpp index 96905576b3..a31a6f0646 100644 --- a/src/motif/icon.cpp +++ b/src/motif/icon.cpp @@ -61,6 +61,12 @@ wxIcon::wxIcon(const wxString& icon_file, long flags, LoadFile(icon_file, flags, desiredWidth, desiredHeight); } +void wxIcon::CopyFromBitmap(const wxBitmap& bmp) +{ + wxIcon *icon = (wxIcon*)(&bmp); + *this = *icon; +} + wxIcon::~wxIcon() { } -- 2.45.2