app.cpp Motif
bitmap.cpp Motif
bmpbuttn.cpp Motif
+bmpmotif.cpp Motif
button.cpp Motif
checkbox.cpp Motif
checklst.cpp Motif
app.h MotifH
bitmap.h MotifH
bmpbuttn.h MotifH
+bmpmotif.h MotifH
button.h MotifH
checkbox.h MotifH
checklst.h MotifH
int m_height;
int m_depth;
bool m_ok;
- int m_numColors;
+ // XXX int m_numColors;
wxPalette m_bitmapPalette;
- int m_quality;
+ // XXX int m_quality;
wxMask * m_bitmapMask; // Optional mask
public:
WXPixmap m_pixmap;
WXDisplay* m_display;
- bool m_freePixmap;
+ // XXX bool m_freePixmap;
+#if 0
unsigned long* m_freeColors;
long m_freeColorsCount;
-
+#endif
+
+#if 0
// These 5 variables are for wxControl
WXPixmap m_insensPixmap ;
WXPixmap m_labelPixmap ;
WXPixmap m_armPixmap ;
+#endif
+#if 0
WXImage* m_image ;
WXImage* m_insensImage ;
+#endif
};
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
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); }
+ // XXX 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);
+ // XXX void SetQuality(int q);
void SetOk(bool isOk);
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
public:
WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; }
WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; }
+#if 0
virtual WXPixmap GetLabelPixmap(WXWidget w) ;
virtual WXPixmap GetArmPixmap(WXWidget w) ;
virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ;
+#endif
void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; }
protected:
#pragma interface "bmpbuttn.h"
#endif
+#include "wx/motif/bmpmotif.h"
+
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
#define wxDEFAULT_BUTTON_MARGIN 4
// to reflect button background colour
wxBitmap m_bmpSelectedOriginal;
wxBitmap m_bmpDisabledOriginal;
-
+
+ wxBitmapCache m_bitmapCache;
+
WXPixmap m_insensPixmap;
};
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: bmpmotif.h
+// Purpose: Motif-specific bitmap routines
+// Author: Julian Smart, originally in bitmap.h
+// Modified by:
+// Created: 25/03/2003
+// RCS-ID: $Id$
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_BMPMOTIF_H_
+#define _WX_BMPMOTIF_H_
+
+#ifdef __GNUG__
+#pragma interface "bmpmotif.h"
+#endif
+
+#include "wx/defs.h"
+#include "wx/bitmap.h"
+
+class WXDLLEXPORT wxBitmapCache
+{
+public:
+ wxBitmapCache()
+ {
+ m_labelPixmap = (WXPixmap)NULL;
+ m_armPixmap = (WXPixmap)NULL;
+ m_insensPixmap = (WXPixmap)NULL;
+ m_image = (WXImage)NULL;
+ m_display = (WXDisplay*)NULL;
+ SetColoursChanged();
+ }
+
+ ~wxBitmapCache();
+
+ void SetColoursChanged();
+ void SetBitmap( const wxBitmap& bitmap );
+
+ WXPixmap GetLabelPixmap( WXWidget w );
+ WXPixmap GetInsensPixmap( WXWidget w = (WXWidget)NULL );
+ WXPixmap GetArmPixmap( WXWidget w );
+private:
+ void InvalidateCache();
+ void CreateImageIfNeeded( WXWidget w );
+
+ struct
+ {
+ bool label : 1;
+ bool arm : 1;
+ bool insens : 1;
+ } m_recalcPixmaps;
+ wxBitmap m_bitmap;
+ WXDisplay* m_display;
+ WXPixmap m_labelPixmap, m_armPixmap, m_insensPixmap;
+ WXImage m_image;
+};
+
+#endif // _WX_BMPMOTIF_H_
#pragma interface "statbmp.h"
#endif
-#include "wx/control.h"
+#include "wx/motif/bmpmotif.h"
#include "wx/icon.h"
WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr;
protected:
wxBitmap m_messageBitmap;
wxBitmap m_messageBitmapOriginal;
+ wxBitmapCache m_bitmapCache;
};
#endif
toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[0], _T("New file"));
toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[1], _T("Open file"));
- // neither the generic nor Motif native toolbars really support this
-#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
+ // the generic toolbar doesn't really support this
+#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
// adding a combo to a vertical toolbar is not very smart
if ( m_horzToolbar )
{
#pragma message enable nosimpint
#endif
-#include "wx/motif/private.h"
+// #include "wx/motif/private.h"
#if wxHAVE_LIB_XPM
#include <X11/xpm.h>
m_width = 0;
m_height = 0;
m_depth = 0;
- m_quality = 0;
- m_numColors = 0;
+ // XXX m_quality = 0;
+ // m_numColors = 0;
m_bitmapMask = NULL;
m_pixmap = (WXPixmap) 0;
m_display = (WXDisplay*) 0;
- m_freePixmap = TRUE; //TODO: necessary?
+ // m_freePixmap = TRUE; //TODO: necessary?
+#if 0
m_freeColors = (unsigned long*) 0;
m_freeColorsCount = 0;
+#endif
// These 5 variables are for wxControl
+#if 0
m_insensPixmap = (WXPixmap) 0;
m_labelPixmap = (WXPixmap) 0;
m_armPixmap = (WXPixmap) 0;
+#endif
+#if 0
m_image = (WXImage*) 0;
m_insensImage = (WXImage*) 0;
+#endif
}
wxBitmapRefData::~wxBitmapRefData()
{
+#if 0
if (m_labelPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_labelPixmap);
if (m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_insensPixmap);
+#endif
+#if 0
if (m_image)
{
XmUninstallImage ((XImage*) m_image);
XtFree ((char *) (XImage*) m_image);
}
+#endif
+#if 0
if (m_insensImage)
{
XmUninstallImage ((XImage*) m_insensImage);
delete[] ((XImage*) m_insensImage)->data;
XtFree ((char *) (XImage*) m_insensImage);
}
- if (m_pixmap && m_freePixmap)
+#endif
+ if (m_pixmap /* && m_freePixmap */)
XFreePixmap ((Display*) m_display, (Pixmap) m_pixmap);
+#if 0
if (m_freeColors)
{
int screen = DefaultScreen((Display*) m_display);
XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L);
delete m_freeColors;
};
+#endif
if (m_bitmapMask)
delete m_bitmapMask;
M_BITMAPDATA->m_width = w;
M_BITMAPDATA->m_height = h;
M_BITMAPDATA->m_depth = d;
- M_BITMAPDATA->m_freePixmap = TRUE;
+ // M_BITMAPDATA->m_freePixmap = TRUE;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPDATA->m_depth = d;
}
+#if 0
+
+// XXX
void wxBitmap::SetQuality(int q)
{
if (!M_BITMAPDATA)
M_BITMAPDATA->m_quality = q;
}
+#endif
+
void wxBitmap::SetOk(bool isOk)
{
if (!M_BITMAPDATA)
int WXUNUSED(desiredWidth),
int WXUNUSED(desiredHeight))
{
- M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
+ // M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
int hotX, hotY;
unsigned int w, h;
M_BITMAPHANDLERDATA->m_width = width;
M_BITMAPHANDLERDATA->m_height = height;
M_BITMAPHANDLERDATA->m_depth = 1;
- M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
+ // M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) XCreateBitmapFromData (dpy, RootWindow (dpy, DefaultScreen (dpy)), (char*) data, width, height);
M_BITMAPHANDLERDATA->m_ok = (M_BITMAPHANDLERDATA->m_pixmap != (WXPixmap) 0) ;
+#if 0
// code for wxControl. TODO: can we avoid doing this until we need it?
// E.g. have CreateButtonPixmaps which is called on demand.
XImage* image = (XImage *) XtMalloc (sizeof (XImage));
M_BITMAPHANDLERDATA->m_image = (WXImage*) image;
M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage;
+#endif
+
+
return TRUE;
}
M_BITMAPHANDLERDATA->m_depth = depthRet;
- M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
+ // M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_width = width;
M_BITMAPHANDLERDATA->m_height = height;
M_BITMAPHANDLERDATA->m_depth = 1;
- M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
+ // M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
xpmAttr.valuemask |= XpmColorSymbols; // add flag
}
- Pixmap pixmap;
+ Pixmap pixmap = 0;
Pixmap mask = 0;
int ErrorStatus = XpmCreatePixmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)),
(char**) data, &pixmap, &mask, &xpmAttr);
M_BITMAPHANDLERDATA->m_depth = depthRet;
- M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
+ // M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
#endif // wxHAVE_LIB_XPM
}
+#if 0
WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
{
if (!M_BITMAPDATA)
return (WXPixmap)NULL;
- if (M_BITMAPDATA->m_image == (WXPixmap) 0)
+ // if (M_BITMAPDATA->m_image == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
+#if 0
Display *dpy = (Display*) M_BITMAPDATA->m_display;
#ifdef FOO
M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
return M_BITMAPDATA->m_labelPixmap;
+#endif
}
WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
{
- if (M_BITMAPDATA->m_image == (WXPixmap) 0)
+ // if (M_BITMAPDATA->m_image == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
+#if 0
Display *dpy = (Display*) M_BITMAPDATA->m_display;
#ifdef FOO
// See GetLabelPixmap () comment
M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
return M_BITMAPDATA->m_armPixmap;
+#endif
}
WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
return M_BITMAPDATA->m_pixmap;
}
- if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
+ // if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
+#if 0
#ifdef FOO
See GetLabelPixmap () comment
// Must be destroyed, because colours can have been changed!
M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
return M_BITMAPDATA->m_insensPixmap;
+#endif
}
+#endif
// We may need this sometime...
wxSearchColor::~wxSearchColor( void )
{
- if ( color ) delete color;
- if ( entry ) delete entry;
+ if ( color ) delete[] color;
+ if ( entry ) delete[] entry;
}
int wxSearchColor::SearchColor( int r, int g, int b )
vinfo_template.depth = bpp;
int nitem = 0;
- vi = XGetVisualInfo( dpy, VisualIDMask|VisualDepthMask, &vinfo_template, &nitem );
+ vi = XGetVisualInfo( dpy, VisualIDMask|VisualDepthMask,
+ &vinfo_template, &nitem );
wxCHECK_MSG( vi, FALSE, wxT("no visual") );
- XFree( vi );
-
if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15;
if (bpp < 8) bpp = 8;
else if ((vi->green_mask > vi->blue_mask) && (vi->blue_mask > vi->red_mask)) b_o = GBR;
}
+ XFree( vi );
+
int r_mask = image.GetMaskRed();
int g_mask = image.GetMaskGreen();
int b_mask = image.GetMaskBlue();
// Implemented in button.cpp
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr);
-Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
+// Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
wxBitmap newBitmap =
wxCreateMaskedBitmap(m_bmpNormalOriginal, col);
m_bmpNormal = newBitmap;
+ m_bitmapCache.SetBitmap( m_bmpNormal );
pixmap = (Pixmap) m_bmpNormal.GetPixmap();
}
else
- pixmap = (Pixmap) m_bmpNormal.GetLabelPixmap(m_mainWidget);
+ {
+ m_bitmapCache.SetBitmap( m_bmpNormal );
+ pixmap = (Pixmap) m_bitmapCache.GetLabelPixmap(m_mainWidget);
+ }
if (m_bmpDisabledOriginal.Ok())
{
insensPixmap = (Pixmap) m_bmpDisabled.GetPixmap();
}
else
- insensPixmap = (Pixmap) m_bmpNormal.GetInsensPixmap(m_mainWidget);
+ insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
}
else
- insensPixmap = (Pixmap) m_bmpNormal.GetInsensPixmap(m_mainWidget);
+ insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
// Now make the bitmap representing the armed state
if (m_bmpSelectedOriginal.Ok())
armPixmap = (Pixmap) m_bmpSelected.GetPixmap();
}
else
- armPixmap = (Pixmap) m_bmpNormal.GetArmPixmap(m_mainWidget);
+ armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
}
else
- armPixmap = (Pixmap) m_bmpNormal.GetArmPixmap(m_mainWidget);
+ armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
+#if 0
// <- the Get...Pixmap()-functions return the same pixmap!
if (insensPixmap == pixmap)
{
XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap);
m_insensPixmap = (WXPixmap) insensPixmap;
}
+#endif
XtVaSetValues ((Widget) m_mainWidget,
XmNlabelPixmap, pixmap,
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: bitmap.cpp
+// Purpose: wxBitmap
+// Author: Julian Smart, originally in bitmap.cpp
+// Modified by:
+// Created: 25/03/2003
+// RCS-ID: $Id$
+// Copyright: (c) Julian Smart
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation "bmpmotif.h"
+#endif
+
+#ifdef __VMS
+#define XtParent XTPARENT
+#endif
+
+#include "wx/defs.h"
+#include "wx/motif/bmpmotif.h"
+
+#ifdef __VMS__
+#pragma message disable nosimpint
+#endif
+#include <Xm/Xm.h>
+#ifdef __VMS__
+#pragma message enable nosimpint
+#endif
+
+#include "wx/motif/private.h"
+
+#if wxHAVE_LIB_XPM
+ #include <X11/xpm.h>
+#endif
+#include <math.h>
+
+Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
+
+wxBitmapCache::~wxBitmapCache()
+{
+ if( m_display )
+ {
+ Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
+
+ if( m_labelPixmap )
+ XmDestroyPixmap( screen, (Pixmap)m_labelPixmap );
+
+ if( m_armPixmap )
+ XmDestroyPixmap( screen, (Pixmap)m_armPixmap );
+
+ if( m_insensPixmap )
+ XmDestroyPixmap( screen, (Pixmap)m_insensPixmap );
+
+ }
+
+ if( m_image )
+ {
+ XmUninstallImage( (XImage*)m_image );
+ XtFree( (char*)(XImage*)m_image );
+ }
+}
+
+void wxBitmapCache::SetBitmap( const wxBitmap& bitmap )
+{
+ if( m_bitmap != bitmap )
+ {
+ InvalidateCache();
+ m_bitmap = bitmap;
+
+ if( m_image )
+ {
+ XmUninstallImage( (XImage*)m_image );
+ XtFree( (char*)(XImage*)m_image );
+ m_image = (WXImage*)NULL;
+ }
+ }
+}
+
+void wxBitmapCache::InvalidateCache()
+{
+ m_recalcPixmaps.label = true;
+ m_recalcPixmaps.arm = true;
+ m_recalcPixmaps.insens = true;
+}
+
+void wxBitmapCache::SetColoursChanged()
+{
+ InvalidateCache();
+}
+
+void wxBitmapCache::CreateImageIfNeeded( WXWidget w )
+{
+ if( m_image )
+ return;
+
+ m_display = w ?
+ (WXDisplay*)XtDisplay( (Widget)w ) :
+ (WXDisplay*)wxGetDisplay();
+
+ XImage *ximage = XGetImage( (Display*)m_display,
+ (Drawable)m_bitmap.GetPixmap(),
+ 0, 0,
+ m_bitmap.GetWidth(), m_bitmap.GetHeight(),
+ AllPlanes, ZPixmap );
+
+ m_image = (WXImage*)ximage;
+
+ if( m_image )
+ {
+ char tmp[128];
+ sprintf( tmp, "Im%x", (unsigned int)ximage );
+ XmInstallImage( ximage, tmp );
+ }
+}
+
+WXPixmap wxBitmapCache::GetLabelPixmap( WXWidget w )
+{
+ if( m_labelPixmap && !m_recalcPixmaps.label )
+ return m_labelPixmap;
+
+ CreateImageIfNeeded( w );
+
+ Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
+
+ if( m_labelPixmap )
+ XmDestroyPixmap( screen, (Pixmap)m_labelPixmap );
+
+ if( !m_image )
+ return (WXPixmap)NULL;
+
+ char tmp[128];
+ sprintf( tmp, "Im%x", (unsigned int)m_image );
+
+ Pixel fg, bg;
+ Widget widget = (Widget)w;
+
+ while( XmIsGadget( widget ) )
+ widget = XtParent( widget );
+ XtVaGetValues( widget,
+ XmNbackground, &bg,
+ XmNforeground, &fg,
+ NULL );
+
+ m_labelPixmap = (WXPixmap)XmGetPixmap( screen, tmp, fg, bg );
+
+ m_recalcPixmaps.label = !m_labelPixmap;
+ return m_labelPixmap;
+}
+
+WXPixmap wxBitmapCache::GetArmPixmap( WXWidget w )
+{
+ if( m_armPixmap && !m_recalcPixmaps.arm )
+ return m_armPixmap;
+
+ CreateImageIfNeeded( w );
+
+ Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
+
+ if( m_armPixmap )
+ XmDestroyPixmap( screen, (Pixmap)m_armPixmap );
+
+ if( !m_image )
+ return (WXPixmap)NULL;
+
+ char tmp[128];
+ sprintf( tmp, "Im%x", (unsigned int)m_image );
+
+ Pixel fg, bg;
+ Widget widget = (Widget) w;
+
+ XtVaGetValues( widget, XmNarmColor, &bg, NULL );
+ while( XmIsGadget( widget ) )
+ widget = XtParent( widget );
+ XtVaGetValues( widget, XmNforeground, &fg, NULL );
+
+ m_armPixmap = (WXPixmap)XmGetPixmap( screen, tmp, fg, bg );
+
+ m_recalcPixmaps.arm = !m_armPixmap;
+ return m_armPixmap;
+}
+
+WXPixmap wxBitmapCache::GetInsensPixmap( WXWidget w )
+{
+ if( m_insensPixmap && !m_recalcPixmaps.insens )
+ return m_insensPixmap;
+
+ CreateImageIfNeeded( w );
+
+ Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
+
+ if( m_insensPixmap )
+ XmDestroyPixmap( screen, (Pixmap)m_insensPixmap );
+
+ if( !m_image )
+ return (WXPixmap)NULL;
+
+ m_insensPixmap =
+ (WXPixmap)XCreateInsensitivePixmap( (Display*)m_display,
+ (Pixmap)m_bitmap.GetPixmap() );
+
+ m_recalcPixmaps.insens = !m_insensPixmap;
+ return m_insensPixmap;
+}
motif/app.cpp \
motif/bitmap.cpp \
motif/bmpbuttn.cpp \
+ motif/bmpmotif.cpp \
motif/button.cpp \
motif/checkbox.cpp \
motif/checklst.cpp \
ctrlsub.h \
cursor.h \
dataobj.h \
- date.h \
datetime.h \
datetime.inl \
datstrm.h \
tglbtn.h \
thread.h \
thrimpl.cpp \
- time.h \
timer.h \
tipdlg.h \
tipwin.h \
motif/app.h \
motif/bitmap.h \
motif/bmpbuttn.h \
+ motif/bmpmotif.h \
motif/button.h \
motif/checkbox.h \
motif/checklst.h \
app.o \
bitmap.o \
bmpbuttn.o \
+ bmpmotif.o \
button.o \
checkbox.o \
checklst.o \
tw = cw;
}
- tb->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
+ tb->SetSize(0, 0, -1, -1, wxSIZE_NO_ADJUSTMENTS);
}
}
#endif // wxUSE_TOOLBAR
pixmap = (Pixmap) m_messageBitmap.GetPixmap();
}
else
- pixmap = (Pixmap) m_messageBitmap.GetLabelPixmap(widget);
+ {
+ m_bitmapCache.SetBitmap( m_messageBitmap );
+ pixmap = (Pixmap)m_bitmapCache.GetLabelPixmap(widget);
+ }
XtVaSetValues (widget,
XmNlabelPixmap, pixmap,
wxWindow::ChangeBackgroundColour();
// must recalculate the background colour
+ m_bitmapCache.SetColoursChanged();
DoSetBitmap();
}
void wxStaticBitmap::ChangeForegroundColour()
{
+ m_bitmapCache.SetColoursChanged();
wxWindow::ChangeForegroundColour();
}
#endif
#include "wx/motif/private.h"
+#include "wx/motif/bmpmotif.h"
// ----------------------------------------------------------------------------
// wxWin macros
void SetWidget(Widget widget) { m_widget = widget; }
Widget GetButtonWidget() const { return m_widget; }
- void SetPixmap(Pixmap pixmap) { m_pixmap = pixmap; }
- Pixmap GetPixmap() const { return m_pixmap; }
+ Pixmap GetArmPixmap()
+ {
+ m_bitmapCache.SetBitmap( GetNormalBitmap() );
+ return (Pixmap)m_bitmapCache.GetArmPixmap( (WXWidget)m_widget );
+ }
+ Pixmap GetInsensPixmap()
+ {
+ m_bitmapCache.SetBitmap( GetNormalBitmap() );
+ return (Pixmap)m_bitmapCache.GetInsensPixmap( (WXWidget)m_widget );
+ }
protected:
void Init();
Widget m_widget;
- Pixmap m_pixmap;
+ wxBitmapCache m_bitmapCache;
};
// ----------------------------------------------------------------------------
void wxToolBarTool::Init()
{
m_widget = (Widget)0;
- m_pixmap = (Pixmap)0;
}
wxToolBarTool::~wxToolBarTool()
{
if ( m_widget )
XtDestroyWidget(m_widget);
- // note: do not delete m_pixmap here because it will be deleted
- // by the base class when the bitmap is destroyed.
}
// ----------------------------------------------------------------------------
Widget button;
Pixmap pixmap, insensPixmap;
- wxBitmap bmp;
+ wxBitmap bmp, insensBmp;
wxToolBarToolsList::Node *node = m_tools.GetFirst();
while ( node )
// Allow a control to specify a y[x]-offset by setting
// its initial position, but still don't allow it to
// position itself above the top[left] margin.
- int controlY = (pos.y > 0) ? currentY + pos.y : currentY;
- int controlX = (pos.x > 0) ? currentX + pos.x : currentX;
+ int controlY = (pos.y > 0) ? pos.y : currentY;
+ int controlX = (pos.x > 0) ? pos.x : currentX;
control->Move( isVertical ? controlX : currentX,
isVertical ? currentY : controlY );
if ( isVertical )
break;
}
case wxTOOL_STYLE_SEPARATOR:
- // skip separators for vertical toolbars
- if( isVertical ) break;
- currentX += separatorSize;
+ // skip separators for vertical toolbars
+ if( !isVertical )
+ {
+ currentX += separatorSize;
+ }
break;
case wxTOOL_STYLE_BUTTON:
button = (Widget) 0;
- if ( tool->CanBeToggled() )
+ if ( tool->CanBeToggled() && !tool->GetButtonWidget() )
{
button = XtVaCreateWidget("toggleButton",
xmToggleButtonWidgetClass, (Widget) m_mainWidget,
XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP,
NULL);
- XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
- (XtPointer) this);
+ XtAddCallback ((Widget) button,
+ XmNvalueChangedCallback,
+ (XtCallbackProc) wxToolButtonCallback,
+ (XtPointer) this);
XtVaSetValues ((Widget) button,
- XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
- NULL);
+ XmNselectColor,
+ m_backgroundColour.AllocColour
+ (XtDisplay((Widget) button)),
+ NULL);
}
- else
+ else if( !tool->GetButtonWidget() )
{
button = XtVaCreateWidget("button",
xmPushButtonWidgetClass, (Widget) m_mainWidget,
XmNlabelType, XmPIXMAP,
NULL);
XtAddCallback (button,
- XmNactivateCallback, (XtCallbackProc) wxToolButtonCallback,
- (XtPointer) this);
+ XmNactivateCallback,
+ (XtCallbackProc) wxToolButtonCallback,
+ (XtPointer) this);
}
- DoChangeBackgroundColour((WXWidget) button, m_backgroundColour, TRUE);
+ if( !tool->GetButtonWidget() )
+ {
+ DoChangeBackgroundColour((WXWidget) button,
+ m_backgroundColour, TRUE);
- tool->SetWidget(button);
+ tool->SetWidget(button);
+ }
+ else
+ {
+ button = (Widget)tool->GetButtonWidget();
+ XtVaSetValues( button,
+ XmNx, currentX, XmNy, currentY,
+ NULL );
+ }
// For each button, if there is a mask, we must create
// a new wxBitmap that has the correct background colour
// for the button. Otherwise the background will just be
// e.g. black if a transparent XPM has been loaded.
bmp = tool->GetNormalBitmap();
- if ( bmp.GetMask() )
+ insensBmp = tool->GetDisabledBitmap();
+ if ( bmp.GetMask() || insensBmp.GetMask() )
{
int backgroundPixel;
XtVaGetValues(button, XmNbackground, &backgroundPixel,
- NULL);
+ NULL);
wxColour col;
col.SetPixel(backgroundPixel);
- bmp = wxCreateMaskedBitmap(bmp, col);
- tool->SetNormalBitmap(bmp);
+ if( bmp.GetMask() )
+ {
+ bmp = wxCreateMaskedBitmap(bmp, col);
+ tool->SetNormalBitmap(bmp);
+ }
+
+ if( insensBmp.GetMask() )
+ {
+ insensBmp = wxCreateMaskedBitmap(insensBmp, col);
+ tool->SetDisabledBitmap(insensBmp);
+ }
}
// Create a selected/toggled bitmap. If there isn't a 2nd
int backgroundPixel;
if ( tool->CanBeToggled() )
XtVaGetValues(button, XmNselectColor, &backgroundPixel,
- NULL);
+ NULL);
else
XtVaGetValues(button, XmNarmColor, &backgroundPixel,
- NULL);
+ NULL);
wxColour col;
col.SetPixel(backgroundPixel);
- // FIXME: we use disabled bitmap as the bitmap for the toggled
- // state, we probably need a GetToggledBitmap() instead
- wxBitmap bmpToggled = tool->GetDisabledBitmap();
- if ( bmpToggled.Ok() && bmpToggled.GetMask())
- {
- // Use what's there
- wxBitmap newBitmap = wxCreateMaskedBitmap(bmpToggled, col);
- tool->SetDisabledBitmap(newBitmap);
- }
- else
- {
- // Use unselected bitmap
- if ( bmp.GetMask() )
- {
- wxBitmap newBitmap = wxCreateMaskedBitmap(bmp, col);
- tool->SetDisabledBitmap(newBitmap);
- }
- else
- tool->SetDisabledBitmap(bmp);
- }
-
- // FIXME: and here we should use GetDisabledBitmap()...
pixmap = (Pixmap) bmp.GetPixmap();
- insensPixmap = (Pixmap) bmp.GetInsensPixmap();
+ {
+ wxBitmap tmp = tool->GetDisabledBitmap();
+ insensPixmap = tmp.Ok() ?
+ (Pixmap)tmp.GetPixmap() :
+ tool->GetInsensPixmap();
+ }
+
if (tool->CanBeToggled())
{
// Toggle button
- Pixmap pixmap2 = (Pixmap) 0;
- Pixmap insensPixmap2 = (Pixmap) 0;
-
- // If there's a bitmap for the toggled state, use it,
- // otherwise generate one.
- //
- // FIXME: see above
- if ( bmpToggled.Ok() )
- {
- pixmap2 = (Pixmap) bmpToggled.GetPixmap();
- insensPixmap2 = (Pixmap) bmpToggled.GetInsensPixmap();
- }
- else
- {
- pixmap2 = (Pixmap) bmp.GetArmPixmap(button);
- insensPixmap2 = XCreateInsensitivePixmap((Display*) wxGetDisplay(), pixmap2);
- }
-
- tool->SetPixmap(pixmap2);
+ Pixmap pixmap2 = tool->GetArmPixmap();
+ Pixmap insensPixmap2 = tool->GetInsensPixmap();
XtVaSetValues (button,
XmNfillOnSelect, True,
}
else
{
- Pixmap pixmap2 = (Pixmap) 0;
-
- // If there's a bitmap for the armed state, use it,
- // otherwise generate one.
- if ( bmpToggled.Ok() )
- {
- pixmap2 = (Pixmap) bmpToggled.GetPixmap();
- }
- else
- {
- pixmap2 = (Pixmap) bmp.GetArmPixmap(button);
-
- }
-
- tool->SetPixmap(pixmap2);
+ Pixmap pixmap2 = tool->GetArmPixmap();
// Normal button
XtVaSetValues(button,
}
SetSize( -1, -1,
- isVertical ? buttonWidth + 2 * marginX : currentX,
- isVertical ? currentY : buttonHeight + 2*marginY );
+ isVertical ? buttonWidth + 2 * marginX : -1,
+ isVertical ? -1 : buttonHeight + 2*marginY );
return TRUE;
}
return TRUE;
}
-bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
+bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
{
tool->Detach();
+ bool isVertical = GetWindowStyle() & wxTB_VERTICAL;
+ const int separatorSize = GetToolSeparation(); // 8;
+ int packing = GetToolPacking();
+ int offset = 0;
+
+ for( wxToolBarToolsList::Node *node = m_tools.GetFirst();
+ node; node = node->GetNext() )
+ {
+ wxToolBarTool *t = (wxToolBarTool*)node->GetData();
+
+ if( t == tool )
+ {
+ switch ( t->GetStyle() )
+ {
+ case wxTOOL_STYLE_CONTROL:
+ {
+ wxSize size = t->GetControl()->GetSize();
+ offset = isVertical ? size.y : size.x;
+ offset += packing;
+ break;
+ }
+ case wxTOOL_STYLE_SEPARATOR:
+ offset = isVertical ? 0 : separatorSize;
+ break;
+ case wxTOOL_STYLE_BUTTON:
+ {
+ Widget w = t->GetButtonWidget();
+ Dimension width, height;
+
+ XtVaGetValues( w,
+ XmNwidth, &width,
+ XmNheight, &height,
+ NULL );
+
+ offset = isVertical ? height : width;
+ offset += packing;
+ break;
+ }
+ }
+ }
+ else if( offset )
+ {
+ switch ( t->GetStyle() )
+ {
+ case wxTOOL_STYLE_CONTROL:
+ {
+ wxPoint pos = t->GetControl()->GetPosition();
+
+ if( isVertical )
+ pos.y -= offset;
+ else
+ pos.x -= offset;
+
+ t->GetControl()->Move( pos );
+ break;
+ }
+ case wxTOOL_STYLE_SEPARATOR:
+ break;
+ case wxTOOL_STYLE_BUTTON:
+ {
+ Dimension x, y;
+ XtVaGetValues( t->GetButtonWidget(),
+ XmNx, &x,
+ XmNy, &y,
+ NULL );
+
+ if( isVertical )
+ y -= offset;
+ else
+ x -= offset;
+
+ XtVaSetValues( t->GetButtonWidget(),
+ XmNx, x,
+ XmNy, y,
+ NULL );
+ break;
+ }
+ }
+ }
+ }
+
return TRUE;
}
int old_width, old_height;
GetSize(&old_width, &old_height);
- wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
-
// Correct width and height if needed.
if ( width == -1 || height == -1 )
{
- int tmp_width, tmp_height;
- GetSize(&tmp_width, &tmp_height);
+ wxSize defaultSize = GetSize();
if ( width == -1 )
- width = tmp_width;
+ width = defaultSize.x;
if ( height == -1 )
- height = tmp_height;
+ height = defaultSize.y;
}
+
+ wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
// We must refresh the frame size when the toolbar changes size
// otherwise the toolbar can be shown incorrectly