Use the wxBitmap implementation from wxX11
in wxMotif; solves various bugs related to wxMask handling (and effectively adds a lot of wxMask functionality previously missing). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20101 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -616,7 +616,6 @@ window.mm Cocoa
|
||||
gsockmot.c Motif Socket
|
||||
accel.cpp Motif
|
||||
app.cpp Motif
|
||||
bitmap.cpp Motif
|
||||
bmpbuttn.cpp Motif
|
||||
bmpmotif.cpp Motif
|
||||
button.cpp Motif
|
||||
@@ -672,7 +671,7 @@ window.cpp Motif
|
||||
gsockx11.c X11 Socket
|
||||
nanox.c X11
|
||||
app.cpp X11
|
||||
bitmap.cpp X11
|
||||
bitmap.cpp X11 Motif
|
||||
brush.cpp X11 Motif
|
||||
clipbrd.cpp X11
|
||||
colour.cpp X11
|
||||
@@ -1236,7 +1235,6 @@ window.h CocoaH
|
||||
|
||||
accel.h MotifH
|
||||
app.h MotifH
|
||||
bitmap.h MotifH
|
||||
bmpbuttn.h MotifH
|
||||
bmpmotif.h MotifH
|
||||
button.h MotifH
|
||||
@@ -1291,7 +1289,7 @@ toplevel.h MotifH
|
||||
window.h MotifH
|
||||
|
||||
app.h X11H
|
||||
bitmap.h X11H
|
||||
bitmap.h X11H Motif
|
||||
brush.h X11H Motif
|
||||
clipbrd.h X11H
|
||||
colour.h X11H
|
||||
|
@@ -167,7 +167,7 @@ protected:
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/bitmap.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/bitmap.h"
|
||||
#include "wx/x11/bitmap.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/bitmap.h"
|
||||
#elif defined(__WXX11__)
|
||||
|
@@ -18,6 +18,8 @@
|
||||
class WXDLLEXPORT wxFont;
|
||||
class WXDLLEXPORT wxWindow;
|
||||
class WXDLLEXPORT wxSize;
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
class WXDLLEXPORT wxColour;
|
||||
|
||||
#include "wx/x11/privx.h"
|
||||
|
||||
@@ -57,6 +59,13 @@ extern void wxDeleteWindowFromTable(Widget w);
|
||||
extern wxWindow *wxGetWindowFromTable(Widget w);
|
||||
extern bool wxAddWindowToTable(Widget w, wxWindow *win);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmap related functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Creates a bitmap with transparent areas drawn in the given colour.
|
||||
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour);
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// key events related functions
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -95,7 +104,7 @@ extern XColor itemColors[5] ;
|
||||
#define wxBOTS_INDEX 4
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// utility classes
|
||||
// XmString/wxString conversion utilities
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxString wxXmStringToString( const XmString& xmString );
|
||||
|
@@ -812,7 +812,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
|
||||
(void)new wxBitmapButton(panel, ID_BITMAP_BTN, bitmap, wxPoint(100, 20));
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#if defined(__WXMSW__) || defined(__WXMOTIF__)
|
||||
// test for masked bitmap display
|
||||
bitmap = wxBitmap(_T("test2.bmp"), wxBITMAP_TYPE_BMP);
|
||||
if (bitmap.Ok())
|
||||
|
1445
src/motif/bitmap.cpp
1445
src/motif/bitmap.cpp
File diff suppressed because it is too large
Load Diff
@@ -177,7 +177,7 @@ void wxBitmapButton::DoSetBitmap()
|
||||
m_bmpNormal = newBitmap;
|
||||
m_bitmapCache.SetBitmap( m_bmpNormal );
|
||||
|
||||
pixmap = (Pixmap) m_bmpNormal.GetPixmap();
|
||||
pixmap = (Pixmap) m_bmpNormal.GetDrawable();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -201,7 +201,7 @@ void wxBitmapButton::DoSetBitmap()
|
||||
wxCreateMaskedBitmap(m_bmpDisabledOriginal, col);
|
||||
m_bmpDisabled = newBitmap;
|
||||
|
||||
insensPixmap = (Pixmap) m_bmpDisabled.GetPixmap();
|
||||
insensPixmap = (Pixmap) m_bmpDisabled.GetDrawable();
|
||||
}
|
||||
else
|
||||
insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
|
||||
@@ -226,7 +226,7 @@ void wxBitmapButton::DoSetBitmap()
|
||||
wxCreateMaskedBitmap(m_bmpSelectedOriginal, col);
|
||||
m_bmpSelected = newBitmap;
|
||||
|
||||
armPixmap = (Pixmap) m_bmpSelected.GetPixmap();
|
||||
armPixmap = (Pixmap) m_bmpSelected.GetDrawable();
|
||||
}
|
||||
else
|
||||
armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
|
||||
|
@@ -99,7 +99,7 @@ void wxBitmapCache::CreateImageIfNeeded( WXWidget w )
|
||||
(WXDisplay*)wxGetDisplay();
|
||||
|
||||
XImage *ximage = XGetImage( (Display*)m_display,
|
||||
(Drawable)m_bitmap.GetPixmap(),
|
||||
(Drawable)m_bitmap.GetDrawable(),
|
||||
0, 0,
|
||||
m_bitmap.GetWidth(), m_bitmap.GetHeight(),
|
||||
AllPlanes, ZPixmap );
|
||||
@@ -197,7 +197,7 @@ WXPixmap wxBitmapCache::GetInsensPixmap( WXWidget w )
|
||||
|
||||
m_insensPixmap =
|
||||
(WXPixmap)XCreateInsensitivePixmap( (Display*)m_display,
|
||||
(Pixmap)m_bitmap.GetPixmap() );
|
||||
(Pixmap)m_bitmap.GetDrawable() );
|
||||
|
||||
m_recalcPixmaps.insens = !m_insensPixmap;
|
||||
return m_insensPixmap;
|
||||
|
@@ -826,7 +826,7 @@ void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
|
||||
SetPen (m_pen);
|
||||
|
||||
int width, height;
|
||||
Pixmap iconPixmap = (Pixmap) icon.GetPixmap();
|
||||
Pixmap iconPixmap = (Pixmap) icon.GetDrawable();
|
||||
width = icon.GetWidth();
|
||||
height = icon.GetHeight();
|
||||
if (icon.GetDisplay() == m_display)
|
||||
@@ -941,7 +941,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
|
||||
wxImage image = bitmap.ConvertToImage();
|
||||
if (!image.Ok())
|
||||
{
|
||||
sourcePixmap = (Pixmap) bitmap.GetPixmap();
|
||||
sourcePixmap = (Pixmap) bitmap.GetDrawable();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -950,7 +950,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
|
||||
|
||||
image = image.Scale(scaledW, scaledH);
|
||||
scaledBitmap = new wxBitmap(image);
|
||||
sourcePixmap = (Pixmap) scaledBitmap->GetPixmap();
|
||||
sourcePixmap = (Pixmap) scaledBitmap->GetDrawable();
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -982,9 +982,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
|
||||
{
|
||||
wxMemoryDC *memDC = (wxMemoryDC *)source;
|
||||
wxBitmap& sel = memDC->GetBitmap();
|
||||
if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
|
||||
if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetBitmap() )
|
||||
{
|
||||
XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
|
||||
XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetBitmap());
|
||||
XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
|
||||
}
|
||||
}
|
||||
@@ -1033,9 +1033,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
|
||||
{
|
||||
wxMemoryDC *memDC = (wxMemoryDC *)source;
|
||||
wxBitmap& sel = memDC->GetBitmap();
|
||||
if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
|
||||
if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetBitmap() )
|
||||
{
|
||||
XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
|
||||
XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetBitmap());
|
||||
XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
|
||||
}
|
||||
}
|
||||
@@ -1843,10 +1843,10 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
||||
else if (m_currentStipple.Ok()
|
||||
&& ((m_currentStipple != oldStipple) || !GetOptimization()))
|
||||
{
|
||||
XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
|
||||
XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetDrawable());
|
||||
|
||||
if (m_window && m_window->GetBackingPixmap())
|
||||
XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
|
||||
XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetDrawable());
|
||||
}
|
||||
|
||||
if ((m_currentFill != oldFill) || !GetOptimization())
|
||||
@@ -2017,18 +2017,18 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
|
||||
if (m_currentStipple.GetDepth() == 1)
|
||||
{
|
||||
XSetStipple ((Display*) m_display, (GC) m_gc,
|
||||
(Pixmap) m_currentStipple.GetPixmap());
|
||||
(Pixmap) m_currentStipple.GetDrawable());
|
||||
if (m_window && m_window->GetBackingPixmap())
|
||||
XSetStipple ((Display*) m_display,(GC) m_gcBacking,
|
||||
(Pixmap) m_currentStipple.GetPixmap());
|
||||
(Pixmap) m_currentStipple.GetDrawable());
|
||||
}
|
||||
else
|
||||
{
|
||||
XSetTile ((Display*) m_display, (GC) m_gc,
|
||||
(Pixmap) m_currentStipple.GetPixmap());
|
||||
(Pixmap) m_currentStipple.GetDrawable());
|
||||
if (m_window && m_window->GetBackingPixmap())
|
||||
XSetTile ((Display*) m_display,(GC) m_gcBacking,
|
||||
(Pixmap) m_currentStipple.GetPixmap());
|
||||
(Pixmap) m_currentStipple.GetDrawable());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -105,7 +105,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
|
||||
if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
|
||||
{
|
||||
m_pixmap = m_bitmap.GetPixmap();
|
||||
m_pixmap = m_bitmap.GetDrawable();
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
XGCValues gcvalues;
|
||||
|
@@ -27,7 +27,6 @@ OBJECTS = \
|
||||
xmcombo.obj,\
|
||||
accel.obj,\
|
||||
app.obj,\
|
||||
bitmap.obj,\
|
||||
bmpbuttn.obj,\
|
||||
bmpmotif.obj,\
|
||||
button.obj,\
|
||||
@@ -83,7 +82,6 @@ OBJECTS = \
|
||||
SOURCES = \
|
||||
accel.cpp,\
|
||||
app.cpp,\
|
||||
bitmap.cpp,\
|
||||
bmpbuttn.cpp,\
|
||||
bmpmotif.cpp,
|
||||
button.cpp,\
|
||||
@@ -148,7 +146,6 @@ xmcombo.obj : [.xmcombo]xmcombo.c
|
||||
|
||||
accel.obj : accel.cpp
|
||||
app.obj : app.cpp
|
||||
bitmap.obj : bitmap.cpp
|
||||
bmpbuttn.obj : bmpbuttn.cpp
|
||||
bmpmotif.obj : bmpmotif.cpp
|
||||
button.obj : button.cpp
|
||||
|
@@ -178,7 +178,6 @@ ALL_SOURCES = \
|
||||
common/zstream.cpp \
|
||||
motif/accel.cpp \
|
||||
motif/app.cpp \
|
||||
motif/bitmap.cpp \
|
||||
motif/bmpbuttn.cpp \
|
||||
motif/bmpmotif.cpp \
|
||||
motif/button.cpp \
|
||||
@@ -231,6 +230,7 @@ ALL_SOURCES = \
|
||||
motif/toplevel.cpp \
|
||||
motif/utils.cpp \
|
||||
motif/window.cpp \
|
||||
x11/bitmap.cpp \
|
||||
x11/brush.cpp \
|
||||
x11/pen.cpp \
|
||||
x11/utilsx.cpp \
|
||||
@@ -507,7 +507,6 @@ ALL_HEADERS = \
|
||||
zstream.h \
|
||||
motif/accel.h \
|
||||
motif/app.h \
|
||||
motif/bitmap.h \
|
||||
motif/bmpbuttn.h \
|
||||
motif/bmpmotif.h \
|
||||
motif/button.h \
|
||||
@@ -623,6 +622,7 @@ ALL_HEADERS = \
|
||||
protocol/ftp.h \
|
||||
protocol/http.h \
|
||||
protocol/protocol.h \
|
||||
x11/bitmap.h \
|
||||
x11/brush.h \
|
||||
x11/pen.h
|
||||
|
||||
@@ -809,7 +809,6 @@ GUIOBJS = \
|
||||
xmcombo.o \
|
||||
accel.o \
|
||||
app.o \
|
||||
bitmap.o \
|
||||
bmpbuttn.o \
|
||||
bmpmotif.o \
|
||||
button.o \
|
||||
@@ -862,6 +861,7 @@ GUIOBJS = \
|
||||
toplevel.o \
|
||||
utils.o \
|
||||
window.o \
|
||||
bitmap.o \
|
||||
brush.o \
|
||||
pen.o \
|
||||
utilsx.o
|
||||
|
@@ -505,10 +505,12 @@ void wxFrame::DoSetIcon(const wxIcon& icon)
|
||||
if (!m_frameShell)
|
||||
return;
|
||||
|
||||
if (!icon.Ok() || !icon.GetPixmap())
|
||||
if (!icon.Ok() || !icon.GetDrawable())
|
||||
return;
|
||||
|
||||
XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL);
|
||||
XtVaSetValues((Widget) m_frameShell,
|
||||
XtNiconPixmap, icon.GetDrawable(),
|
||||
NULL);
|
||||
}
|
||||
|
||||
void wxFrame::SetIcon(const wxIcon& icon)
|
||||
|
@@ -121,7 +121,7 @@ void wxStaticBitmap::DoSetBitmap()
|
||||
wxBitmap newBitmap = wxCreateMaskedBitmap(m_messageBitmapOriginal, col);
|
||||
m_messageBitmap = newBitmap;
|
||||
|
||||
pixmap = (Pixmap) m_messageBitmap.GetPixmap();
|
||||
pixmap = (Pixmap) m_messageBitmap.GetDrawable();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -389,13 +389,13 @@ bool wxToolBar::Realize()
|
||||
wxColour col;
|
||||
col.SetPixel(backgroundPixel);
|
||||
|
||||
if( bmp.GetMask() )
|
||||
if( bmp.Ok() && bmp.GetMask() )
|
||||
{
|
||||
bmp = wxCreateMaskedBitmap(bmp, col);
|
||||
tool->SetNormalBitmap(bmp);
|
||||
}
|
||||
|
||||
if( insensBmp.GetMask() )
|
||||
if( insensBmp.Ok() && insensBmp.GetMask() )
|
||||
{
|
||||
insensBmp = wxCreateMaskedBitmap(insensBmp, col);
|
||||
tool->SetDisabledBitmap(insensBmp);
|
||||
@@ -415,12 +415,12 @@ bool wxToolBar::Realize()
|
||||
wxColour col;
|
||||
col.SetPixel(backgroundPixel);
|
||||
|
||||
pixmap = (Pixmap) bmp.GetPixmap();
|
||||
pixmap = (Pixmap) bmp.GetDrawable();
|
||||
{
|
||||
wxBitmap tmp = tool->GetDisabledBitmap();
|
||||
|
||||
insensPixmap = tmp.Ok() ?
|
||||
(Pixmap)tmp.GetPixmap() :
|
||||
(Pixmap)tmp.GetDrawable() :
|
||||
tool->GetInsensPixmap();
|
||||
}
|
||||
|
||||
|
@@ -1235,3 +1235,30 @@ XmString wxStringToXmString( const char* str )
|
||||
{
|
||||
return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxBitmap utility functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Creates a bitmap with transparent areas drawn in
|
||||
// the given colour.
|
||||
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour)
|
||||
{
|
||||
wxBitmap newBitmap(bitmap.GetWidth(),
|
||||
bitmap.GetHeight(),
|
||||
bitmap.GetDepth());
|
||||
wxMemoryDC destDC;
|
||||
wxMemoryDC srcDC;
|
||||
|
||||
srcDC.SelectObject(bitmap);
|
||||
destDC.SelectObject(newBitmap);
|
||||
|
||||
wxBrush brush(colour, wxSOLID);
|
||||
// destDC.SetOptimization(FALSE);
|
||||
destDC.SetBackground(brush);
|
||||
destDC.Clear();
|
||||
destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(),
|
||||
&srcDC, 0, 0, wxCOPY, TRUE);
|
||||
|
||||
return newBitmap;
|
||||
}
|
||||
|
@@ -24,12 +24,16 @@ CXX_DEFINE =
|
||||
cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c
|
||||
|
||||
OBJECTS = \
|
||||
bitmap.obj,\
|
||||
brush.obj,\
|
||||
pen.obj
|
||||
pen.obj,\
|
||||
utilsx.obj
|
||||
|
||||
SOURCES = \
|
||||
bitmap.cpp,\
|
||||
brush.cpp,\
|
||||
pen.cpp
|
||||
pen.cpp,\
|
||||
utilsx.cpp
|
||||
|
||||
all : $(SOURCES)
|
||||
$(MMS)$(MMSQUALIFIERS) $(OBJECTS)
|
||||
@@ -37,5 +41,7 @@ all : $(SOURCES)
|
||||
library [--.lib]libwx_motif.olb $(OBJECTS)
|
||||
.endif
|
||||
|
||||
bitmap.obj : bitmap.cpp
|
||||
brush.obj : brush.cpp
|
||||
pen.obj : pen.cpp
|
||||
utilsx.obj : utilsx.cpp
|
||||
|
Reference in New Issue
Block a user