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:
Mattia Barbon
2003-04-09 16:44:27 +00:00
parent 507db85d59
commit aae0472bf3
16 changed files with 80 additions and 1486 deletions

View File

@@ -616,7 +616,6 @@ window.mm Cocoa
gsockmot.c Motif Socket gsockmot.c Motif Socket
accel.cpp Motif accel.cpp Motif
app.cpp Motif app.cpp Motif
bitmap.cpp Motif
bmpbuttn.cpp Motif bmpbuttn.cpp Motif
bmpmotif.cpp Motif bmpmotif.cpp Motif
button.cpp Motif button.cpp Motif
@@ -672,7 +671,7 @@ window.cpp Motif
gsockx11.c X11 Socket gsockx11.c X11 Socket
nanox.c X11 nanox.c X11
app.cpp X11 app.cpp X11
bitmap.cpp X11 bitmap.cpp X11 Motif
brush.cpp X11 Motif brush.cpp X11 Motif
clipbrd.cpp X11 clipbrd.cpp X11
colour.cpp X11 colour.cpp X11
@@ -1236,7 +1235,6 @@ window.h CocoaH
accel.h MotifH accel.h MotifH
app.h MotifH app.h MotifH
bitmap.h MotifH
bmpbuttn.h MotifH bmpbuttn.h MotifH
bmpmotif.h MotifH bmpmotif.h MotifH
button.h MotifH button.h MotifH
@@ -1291,7 +1289,7 @@ toplevel.h MotifH
window.h MotifH window.h MotifH
app.h X11H app.h X11H
bitmap.h X11H bitmap.h X11H Motif
brush.h X11H Motif brush.h X11H Motif
clipbrd.h X11H clipbrd.h X11H
colour.h X11H colour.h X11H

View File

@@ -167,7 +167,7 @@ protected:
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/bitmap.h" #include "wx/msw/bitmap.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/bitmap.h" #include "wx/x11/bitmap.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk/bitmap.h" #include "wx/gtk/bitmap.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)

View File

@@ -18,6 +18,8 @@
class WXDLLEXPORT wxFont; class WXDLLEXPORT wxFont;
class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxSize; class WXDLLEXPORT wxSize;
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxColour;
#include "wx/x11/privx.h" #include "wx/x11/privx.h"
@@ -57,6 +59,13 @@ extern void wxDeleteWindowFromTable(Widget w);
extern wxWindow *wxGetWindowFromTable(Widget w); extern wxWindow *wxGetWindowFromTable(Widget w);
extern bool wxAddWindowToTable(Widget w, wxWindow *win); 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 // key events related functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -95,7 +104,7 @@ extern XColor itemColors[5] ;
#define wxBOTS_INDEX 4 #define wxBOTS_INDEX 4
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// utility classes // XmString/wxString conversion utilities
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxXmStringToString( const XmString& xmString ); wxString wxXmStringToString( const XmString& xmString );

View File

@@ -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)); (void)new wxBitmapButton(panel, ID_BITMAP_BTN, bitmap, wxPoint(100, 20));
#ifdef __WXMSW__ #if defined(__WXMSW__) || defined(__WXMOTIF__)
// test for masked bitmap display // test for masked bitmap display
bitmap = wxBitmap(_T("test2.bmp"), wxBITMAP_TYPE_BMP); bitmap = wxBitmap(_T("test2.bmp"), wxBITMAP_TYPE_BMP);
if (bitmap.Ok()) if (bitmap.Ok())

File diff suppressed because it is too large Load Diff

View File

@@ -177,7 +177,7 @@ void wxBitmapButton::DoSetBitmap()
m_bmpNormal = newBitmap; m_bmpNormal = newBitmap;
m_bitmapCache.SetBitmap( m_bmpNormal ); m_bitmapCache.SetBitmap( m_bmpNormal );
pixmap = (Pixmap) m_bmpNormal.GetPixmap(); pixmap = (Pixmap) m_bmpNormal.GetDrawable();
} }
else else
{ {
@@ -201,7 +201,7 @@ void wxBitmapButton::DoSetBitmap()
wxCreateMaskedBitmap(m_bmpDisabledOriginal, col); wxCreateMaskedBitmap(m_bmpDisabledOriginal, col);
m_bmpDisabled = newBitmap; m_bmpDisabled = newBitmap;
insensPixmap = (Pixmap) m_bmpDisabled.GetPixmap(); insensPixmap = (Pixmap) m_bmpDisabled.GetDrawable();
} }
else else
insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget); insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
@@ -226,7 +226,7 @@ void wxBitmapButton::DoSetBitmap()
wxCreateMaskedBitmap(m_bmpSelectedOriginal, col); wxCreateMaskedBitmap(m_bmpSelectedOriginal, col);
m_bmpSelected = newBitmap; m_bmpSelected = newBitmap;
armPixmap = (Pixmap) m_bmpSelected.GetPixmap(); armPixmap = (Pixmap) m_bmpSelected.GetDrawable();
} }
else else
armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget); armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);

View File

@@ -99,7 +99,7 @@ void wxBitmapCache::CreateImageIfNeeded( WXWidget w )
(WXDisplay*)wxGetDisplay(); (WXDisplay*)wxGetDisplay();
XImage *ximage = XGetImage( (Display*)m_display, XImage *ximage = XGetImage( (Display*)m_display,
(Drawable)m_bitmap.GetPixmap(), (Drawable)m_bitmap.GetDrawable(),
0, 0, 0, 0,
m_bitmap.GetWidth(), m_bitmap.GetHeight(), m_bitmap.GetWidth(), m_bitmap.GetHeight(),
AllPlanes, ZPixmap ); AllPlanes, ZPixmap );
@@ -197,7 +197,7 @@ WXPixmap wxBitmapCache::GetInsensPixmap( WXWidget w )
m_insensPixmap = m_insensPixmap =
(WXPixmap)XCreateInsensitivePixmap( (Display*)m_display, (WXPixmap)XCreateInsensitivePixmap( (Display*)m_display,
(Pixmap)m_bitmap.GetPixmap() ); (Pixmap)m_bitmap.GetDrawable() );
m_recalcPixmaps.insens = !m_insensPixmap; m_recalcPixmaps.insens = !m_insensPixmap;
return m_insensPixmap; return m_insensPixmap;

View File

@@ -826,7 +826,7 @@ void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
SetPen (m_pen); SetPen (m_pen);
int width, height; int width, height;
Pixmap iconPixmap = (Pixmap) icon.GetPixmap(); Pixmap iconPixmap = (Pixmap) icon.GetDrawable();
width = icon.GetWidth(); width = icon.GetWidth();
height = icon.GetHeight(); height = icon.GetHeight();
if (icon.GetDisplay() == m_display) if (icon.GetDisplay() == m_display)
@@ -941,7 +941,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxImage image = bitmap.ConvertToImage(); wxImage image = bitmap.ConvertToImage();
if (!image.Ok()) if (!image.Ok())
{ {
sourcePixmap = (Pixmap) bitmap.GetPixmap(); sourcePixmap = (Pixmap) bitmap.GetDrawable();
} }
else else
{ {
@@ -950,7 +950,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
image = image.Scale(scaledW, scaledH); image = image.Scale(scaledW, scaledH);
scaledBitmap = new wxBitmap(image); scaledBitmap = new wxBitmap(image);
sourcePixmap = (Pixmap) scaledBitmap->GetPixmap(); sourcePixmap = (Pixmap) scaledBitmap->GetDrawable();
} }
} }
else else
@@ -982,9 +982,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
{ {
wxMemoryDC *memDC = (wxMemoryDC *)source; wxMemoryDC *memDC = (wxMemoryDC *)source;
wxBitmap& sel = memDC->GetBitmap(); 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)); 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; wxMemoryDC *memDC = (wxMemoryDC *)source;
wxBitmap& sel = memDC->GetBitmap(); 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)); 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() else if (m_currentStipple.Ok()
&& ((m_currentStipple != oldStipple) || !GetOptimization())) && ((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()) 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()) if ((m_currentFill != oldFill) || !GetOptimization())
@@ -2017,18 +2017,18 @@ void wxWindowDC::SetBrush( const wxBrush &brush )
if (m_currentStipple.GetDepth() == 1) if (m_currentStipple.GetDepth() == 1)
{ {
XSetStipple ((Display*) m_display, (GC) m_gc, XSetStipple ((Display*) m_display, (GC) m_gc,
(Pixmap) m_currentStipple.GetPixmap()); (Pixmap) m_currentStipple.GetDrawable());
if (m_window && m_window->GetBackingPixmap()) if (m_window && m_window->GetBackingPixmap())
XSetStipple ((Display*) m_display,(GC) m_gcBacking, XSetStipple ((Display*) m_display,(GC) m_gcBacking,
(Pixmap) m_currentStipple.GetPixmap()); (Pixmap) m_currentStipple.GetDrawable());
} }
else else
{ {
XSetTile ((Display*) m_display, (GC) m_gc, XSetTile ((Display*) m_display, (GC) m_gc,
(Pixmap) m_currentStipple.GetPixmap()); (Pixmap) m_currentStipple.GetDrawable());
if (m_window && m_window->GetBackingPixmap()) if (m_window && m_window->GetBackingPixmap())
XSetTile ((Display*) m_display,(GC) m_gcBacking, XSetTile ((Display*) m_display,(GC) m_gcBacking,
(Pixmap) m_currentStipple.GetPixmap()); (Pixmap) m_currentStipple.GetDrawable());
} }
} }

View File

@@ -105,7 +105,7 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display)) if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
{ {
m_pixmap = m_bitmap.GetPixmap(); m_pixmap = m_bitmap.GetDrawable();
Display* display = (Display*) m_display; Display* display = (Display*) m_display;
XGCValues gcvalues; XGCValues gcvalues;

View File

@@ -27,7 +27,6 @@ OBJECTS = \
xmcombo.obj,\ xmcombo.obj,\
accel.obj,\ accel.obj,\
app.obj,\ app.obj,\
bitmap.obj,\
bmpbuttn.obj,\ bmpbuttn.obj,\
bmpmotif.obj,\ bmpmotif.obj,\
button.obj,\ button.obj,\
@@ -83,7 +82,6 @@ OBJECTS = \
SOURCES = \ SOURCES = \
accel.cpp,\ accel.cpp,\
app.cpp,\ app.cpp,\
bitmap.cpp,\
bmpbuttn.cpp,\ bmpbuttn.cpp,\
bmpmotif.cpp, bmpmotif.cpp,
button.cpp,\ button.cpp,\
@@ -148,7 +146,6 @@ xmcombo.obj : [.xmcombo]xmcombo.c
accel.obj : accel.cpp accel.obj : accel.cpp
app.obj : app.cpp app.obj : app.cpp
bitmap.obj : bitmap.cpp
bmpbuttn.obj : bmpbuttn.cpp bmpbuttn.obj : bmpbuttn.cpp
bmpmotif.obj : bmpmotif.cpp bmpmotif.obj : bmpmotif.cpp
button.obj : button.cpp button.obj : button.cpp

View File

@@ -178,7 +178,6 @@ ALL_SOURCES = \
common/zstream.cpp \ common/zstream.cpp \
motif/accel.cpp \ motif/accel.cpp \
motif/app.cpp \ motif/app.cpp \
motif/bitmap.cpp \
motif/bmpbuttn.cpp \ motif/bmpbuttn.cpp \
motif/bmpmotif.cpp \ motif/bmpmotif.cpp \
motif/button.cpp \ motif/button.cpp \
@@ -231,6 +230,7 @@ ALL_SOURCES = \
motif/toplevel.cpp \ motif/toplevel.cpp \
motif/utils.cpp \ motif/utils.cpp \
motif/window.cpp \ motif/window.cpp \
x11/bitmap.cpp \
x11/brush.cpp \ x11/brush.cpp \
x11/pen.cpp \ x11/pen.cpp \
x11/utilsx.cpp \ x11/utilsx.cpp \
@@ -507,7 +507,6 @@ ALL_HEADERS = \
zstream.h \ zstream.h \
motif/accel.h \ motif/accel.h \
motif/app.h \ motif/app.h \
motif/bitmap.h \
motif/bmpbuttn.h \ motif/bmpbuttn.h \
motif/bmpmotif.h \ motif/bmpmotif.h \
motif/button.h \ motif/button.h \
@@ -623,6 +622,7 @@ ALL_HEADERS = \
protocol/ftp.h \ protocol/ftp.h \
protocol/http.h \ protocol/http.h \
protocol/protocol.h \ protocol/protocol.h \
x11/bitmap.h \
x11/brush.h \ x11/brush.h \
x11/pen.h x11/pen.h
@@ -809,7 +809,6 @@ GUIOBJS = \
xmcombo.o \ xmcombo.o \
accel.o \ accel.o \
app.o \ app.o \
bitmap.o \
bmpbuttn.o \ bmpbuttn.o \
bmpmotif.o \ bmpmotif.o \
button.o \ button.o \
@@ -862,6 +861,7 @@ GUIOBJS = \
toplevel.o \ toplevel.o \
utils.o \ utils.o \
window.o \ window.o \
bitmap.o \
brush.o \ brush.o \
pen.o \ pen.o \
utilsx.o utilsx.o

View File

@@ -505,10 +505,12 @@ void wxFrame::DoSetIcon(const wxIcon& icon)
if (!m_frameShell) if (!m_frameShell)
return; return;
if (!icon.Ok() || !icon.GetPixmap()) if (!icon.Ok() || !icon.GetDrawable())
return; return;
XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL); XtVaSetValues((Widget) m_frameShell,
XtNiconPixmap, icon.GetDrawable(),
NULL);
} }
void wxFrame::SetIcon(const wxIcon& icon) void wxFrame::SetIcon(const wxIcon& icon)

View File

@@ -121,7 +121,7 @@ void wxStaticBitmap::DoSetBitmap()
wxBitmap newBitmap = wxCreateMaskedBitmap(m_messageBitmapOriginal, col); wxBitmap newBitmap = wxCreateMaskedBitmap(m_messageBitmapOriginal, col);
m_messageBitmap = newBitmap; m_messageBitmap = newBitmap;
pixmap = (Pixmap) m_messageBitmap.GetPixmap(); pixmap = (Pixmap) m_messageBitmap.GetDrawable();
} }
else else
{ {

View File

@@ -389,13 +389,13 @@ bool wxToolBar::Realize()
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
if( bmp.GetMask() ) if( bmp.Ok() && bmp.GetMask() )
{ {
bmp = wxCreateMaskedBitmap(bmp, col); bmp = wxCreateMaskedBitmap(bmp, col);
tool->SetNormalBitmap(bmp); tool->SetNormalBitmap(bmp);
} }
if( insensBmp.GetMask() ) if( insensBmp.Ok() && insensBmp.GetMask() )
{ {
insensBmp = wxCreateMaskedBitmap(insensBmp, col); insensBmp = wxCreateMaskedBitmap(insensBmp, col);
tool->SetDisabledBitmap(insensBmp); tool->SetDisabledBitmap(insensBmp);
@@ -415,12 +415,12 @@ bool wxToolBar::Realize()
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
pixmap = (Pixmap) bmp.GetPixmap(); pixmap = (Pixmap) bmp.GetDrawable();
{ {
wxBitmap tmp = tool->GetDisabledBitmap(); wxBitmap tmp = tool->GetDisabledBitmap();
insensPixmap = tmp.Ok() ? insensPixmap = tmp.Ok() ?
(Pixmap)tmp.GetPixmap() : (Pixmap)tmp.GetDrawable() :
tool->GetInsensPixmap(); tool->GetInsensPixmap();
} }

View File

@@ -1235,3 +1235,30 @@ XmString wxStringToXmString( const char* str )
{ {
return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET); 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;
}

View File

@@ -24,12 +24,16 @@ CXX_DEFINE =
cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c
OBJECTS = \ OBJECTS = \
bitmap.obj,\
brush.obj,\ brush.obj,\
pen.obj pen.obj,\
utilsx.obj
SOURCES = \ SOURCES = \
bitmap.cpp,\
brush.cpp,\ brush.cpp,\
pen.cpp pen.cpp,\
utilsx.cpp
all : $(SOURCES) all : $(SOURCES)
$(MMS)$(MMSQUALIFIERS) $(OBJECTS) $(MMS)$(MMSQUALIFIERS) $(OBJECTS)
@@ -37,5 +41,7 @@ all : $(SOURCES)
library [--.lib]libwx_motif.olb $(OBJECTS) library [--.lib]libwx_motif.olb $(OBJECTS)
.endif .endif
bitmap.obj : bitmap.cpp
brush.obj : brush.cpp brush.obj : brush.cpp
pen.obj : pen.cpp pen.obj : pen.cpp
utilsx.obj : utilsx.cpp