Removed some old cruft from wxBitmap, moved wxMotif- and
wxControl-specific functionality (GetXXXPixmap) into a separate class, and fixed the implementation. Adapted wxStaticBitmap, wxBitmapButton and wxToolBar to the new situation. Various fixes to wxToolBar: Realize does not create buttons multiple times anymore, use the disabled bitmap as the disabled bitmap, not as the toggled bitmap for toggle buttons (!), reposition buttons/controls when a tool is removed/deleted. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19836 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -622,6 +622,7 @@ accel.cpp Motif
|
|||||||
app.cpp Motif
|
app.cpp Motif
|
||||||
bitmap.cpp Motif
|
bitmap.cpp Motif
|
||||||
bmpbuttn.cpp Motif
|
bmpbuttn.cpp Motif
|
||||||
|
bmpmotif.cpp Motif
|
||||||
button.cpp Motif
|
button.cpp Motif
|
||||||
checkbox.cpp Motif
|
checkbox.cpp Motif
|
||||||
checklst.cpp Motif
|
checklst.cpp Motif
|
||||||
@@ -1249,6 +1250,7 @@ accel.h MotifH
|
|||||||
app.h MotifH
|
app.h MotifH
|
||||||
bitmap.h MotifH
|
bitmap.h MotifH
|
||||||
bmpbuttn.h MotifH
|
bmpbuttn.h MotifH
|
||||||
|
bmpmotif.h MotifH
|
||||||
button.h MotifH
|
button.h MotifH
|
||||||
checkbox.h MotifH
|
checkbox.h MotifH
|
||||||
checklst.h MotifH
|
checklst.h MotifH
|
||||||
|
@@ -76,9 +76,9 @@ public:
|
|||||||
int m_height;
|
int m_height;
|
||||||
int m_depth;
|
int m_depth;
|
||||||
bool m_ok;
|
bool m_ok;
|
||||||
int m_numColors;
|
// XXX int m_numColors;
|
||||||
wxPalette m_bitmapPalette;
|
wxPalette m_bitmapPalette;
|
||||||
int m_quality;
|
// XXX int m_quality;
|
||||||
|
|
||||||
wxMask * m_bitmapMask; // Optional mask
|
wxMask * m_bitmapMask; // Optional mask
|
||||||
|
|
||||||
@@ -86,16 +86,22 @@ public:
|
|||||||
public:
|
public:
|
||||||
WXPixmap m_pixmap;
|
WXPixmap m_pixmap;
|
||||||
WXDisplay* m_display;
|
WXDisplay* m_display;
|
||||||
bool m_freePixmap;
|
// XXX bool m_freePixmap;
|
||||||
|
#if 0
|
||||||
unsigned long* m_freeColors;
|
unsigned long* m_freeColors;
|
||||||
long m_freeColorsCount;
|
long m_freeColorsCount;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
// These 5 variables are for wxControl
|
// These 5 variables are for wxControl
|
||||||
WXPixmap m_insensPixmap ;
|
WXPixmap m_insensPixmap ;
|
||||||
WXPixmap m_labelPixmap ;
|
WXPixmap m_labelPixmap ;
|
||||||
WXPixmap m_armPixmap ;
|
WXPixmap m_armPixmap ;
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
WXImage* m_image ;
|
WXImage* m_image ;
|
||||||
WXImage* m_insensImage ;
|
WXImage* m_insensImage ;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
|
||||||
@@ -186,11 +192,11 @@ public:
|
|||||||
int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
|
int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
|
||||||
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
|
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
|
||||||
int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 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 SetWidth(int w);
|
||||||
void SetHeight(int h);
|
void SetHeight(int h);
|
||||||
void SetDepth(int d);
|
void SetDepth(int d);
|
||||||
void SetQuality(int q);
|
// XXX void SetQuality(int q);
|
||||||
void SetOk(bool isOk);
|
void SetOk(bool isOk);
|
||||||
|
|
||||||
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
|
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
|
||||||
@@ -210,9 +216,11 @@ public:
|
|||||||
public:
|
public:
|
||||||
WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; }
|
WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; }
|
||||||
WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; }
|
WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; }
|
||||||
|
#if 0
|
||||||
virtual WXPixmap GetLabelPixmap(WXWidget w) ;
|
virtual WXPixmap GetLabelPixmap(WXWidget w) ;
|
||||||
virtual WXPixmap GetArmPixmap(WXWidget w) ;
|
virtual WXPixmap GetArmPixmap(WXWidget w) ;
|
||||||
virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ;
|
virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ;
|
||||||
|
#endif
|
||||||
void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; }
|
void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#pragma interface "bmpbuttn.h"
|
#pragma interface "bmpbuttn.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/motif/bmpmotif.h"
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
|
WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
|
||||||
|
|
||||||
#define wxDEFAULT_BUTTON_MARGIN 4
|
#define wxDEFAULT_BUTTON_MARGIN 4
|
||||||
@@ -68,6 +70,8 @@ protected:
|
|||||||
wxBitmap m_bmpSelectedOriginal;
|
wxBitmap m_bmpSelectedOriginal;
|
||||||
wxBitmap m_bmpDisabledOriginal;
|
wxBitmap m_bmpDisabledOriginal;
|
||||||
|
|
||||||
|
wxBitmapCache m_bitmapCache;
|
||||||
|
|
||||||
WXPixmap m_insensPixmap;
|
WXPixmap m_insensPixmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
59
include/wx/motif/bmpmotif.h
Normal file
59
include/wx/motif/bmpmotif.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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_
|
@@ -16,7 +16,7 @@
|
|||||||
#pragma interface "statbmp.h"
|
#pragma interface "statbmp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/control.h"
|
#include "wx/motif/bmpmotif.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr;
|
WXDLLEXPORT_DATA(extern const char*) wxStaticBitmapNameStr;
|
||||||
@@ -82,6 +82,7 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
wxBitmap m_messageBitmap;
|
wxBitmap m_messageBitmap;
|
||||||
wxBitmap m_messageBitmapOriginal;
|
wxBitmap m_messageBitmapOriginal;
|
||||||
|
wxBitmapCache m_bitmapCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -298,8 +298,8 @@ void MyFrame::RecreateToolbar()
|
|||||||
toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[0], _T("New file"));
|
toolBar->AddTool(wxID_NEW, _T("New"), toolBarBitmaps[0], _T("New file"));
|
||||||
toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[1], _T("Open file"));
|
toolBar->AddTool(wxID_OPEN, _T("Open"), toolBarBitmaps[1], _T("Open file"));
|
||||||
|
|
||||||
// neither the generic nor Motif native toolbars really support this
|
// the generic toolbar doesn't really support this
|
||||||
#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXMOTIF__) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
|
#if (wxUSE_TOOLBAR_NATIVE && !USE_GENERIC_TBAR) && !defined(__WXX11__) || defined(__WXUNIVERSAL__)
|
||||||
// adding a combo to a vertical toolbar is not very smart
|
// adding a combo to a vertical toolbar is not very smart
|
||||||
if ( m_horzToolbar )
|
if ( m_horzToolbar )
|
||||||
{
|
{
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
#pragma message enable nosimpint
|
#pragma message enable nosimpint
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/motif/private.h"
|
// #include "wx/motif/private.h"
|
||||||
|
|
||||||
#if wxHAVE_LIB_XPM
|
#if wxHAVE_LIB_XPM
|
||||||
#include <X11/xpm.h>
|
#include <X11/xpm.h>
|
||||||
@@ -53,27 +53,34 @@ wxBitmapRefData::wxBitmapRefData()
|
|||||||
m_width = 0;
|
m_width = 0;
|
||||||
m_height = 0;
|
m_height = 0;
|
||||||
m_depth = 0;
|
m_depth = 0;
|
||||||
m_quality = 0;
|
// XXX m_quality = 0;
|
||||||
m_numColors = 0;
|
// m_numColors = 0;
|
||||||
m_bitmapMask = NULL;
|
m_bitmapMask = NULL;
|
||||||
|
|
||||||
m_pixmap = (WXPixmap) 0;
|
m_pixmap = (WXPixmap) 0;
|
||||||
m_display = (WXDisplay*) 0;
|
m_display = (WXDisplay*) 0;
|
||||||
|
|
||||||
m_freePixmap = TRUE; //TODO: necessary?
|
// m_freePixmap = TRUE; //TODO: necessary?
|
||||||
|
#if 0
|
||||||
m_freeColors = (unsigned long*) 0;
|
m_freeColors = (unsigned long*) 0;
|
||||||
m_freeColorsCount = 0;
|
m_freeColorsCount = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
// These 5 variables are for wxControl
|
// These 5 variables are for wxControl
|
||||||
|
#if 0
|
||||||
m_insensPixmap = (WXPixmap) 0;
|
m_insensPixmap = (WXPixmap) 0;
|
||||||
m_labelPixmap = (WXPixmap) 0;
|
m_labelPixmap = (WXPixmap) 0;
|
||||||
m_armPixmap = (WXPixmap) 0;
|
m_armPixmap = (WXPixmap) 0;
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
m_image = (WXImage*) 0;
|
m_image = (WXImage*) 0;
|
||||||
m_insensImage = (WXImage*) 0;
|
m_insensImage = (WXImage*) 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapRefData::~wxBitmapRefData()
|
wxBitmapRefData::~wxBitmapRefData()
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
if (m_labelPixmap)
|
if (m_labelPixmap)
|
||||||
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_labelPixmap);
|
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_labelPixmap);
|
||||||
|
|
||||||
@@ -82,22 +89,28 @@ wxBitmapRefData::~wxBitmapRefData()
|
|||||||
|
|
||||||
if (m_insensPixmap)
|
if (m_insensPixmap)
|
||||||
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_insensPixmap);
|
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_insensPixmap);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (m_image)
|
if (m_image)
|
||||||
{
|
{
|
||||||
XmUninstallImage ((XImage*) m_image);
|
XmUninstallImage ((XImage*) m_image);
|
||||||
XtFree ((char *) (XImage*) m_image);
|
XtFree ((char *) (XImage*) m_image);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (m_insensImage)
|
if (m_insensImage)
|
||||||
{
|
{
|
||||||
XmUninstallImage ((XImage*) m_insensImage);
|
XmUninstallImage ((XImage*) m_insensImage);
|
||||||
delete[] ((XImage*) m_insensImage)->data;
|
delete[] ((XImage*) m_insensImage)->data;
|
||||||
XtFree ((char *) (XImage*) m_insensImage);
|
XtFree ((char *) (XImage*) m_insensImage);
|
||||||
}
|
}
|
||||||
if (m_pixmap && m_freePixmap)
|
#endif
|
||||||
|
if (m_pixmap /* && m_freePixmap */)
|
||||||
XFreePixmap ((Display*) m_display, (Pixmap) m_pixmap);
|
XFreePixmap ((Display*) m_display, (Pixmap) m_pixmap);
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (m_freeColors)
|
if (m_freeColors)
|
||||||
{
|
{
|
||||||
int screen = DefaultScreen((Display*) m_display);
|
int screen = DefaultScreen((Display*) m_display);
|
||||||
@@ -107,6 +120,7 @@ wxBitmapRefData::~wxBitmapRefData()
|
|||||||
XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L);
|
XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L);
|
||||||
delete m_freeColors;
|
delete m_freeColors;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_bitmapMask)
|
if (m_bitmapMask)
|
||||||
delete m_bitmapMask;
|
delete m_bitmapMask;
|
||||||
@@ -184,7 +198,7 @@ bool wxBitmap::Create(int w, int h, int d)
|
|||||||
M_BITMAPDATA->m_width = w;
|
M_BITMAPDATA->m_width = w;
|
||||||
M_BITMAPDATA->m_height = h;
|
M_BITMAPDATA->m_height = h;
|
||||||
M_BITMAPDATA->m_depth = d;
|
M_BITMAPDATA->m_depth = d;
|
||||||
M_BITMAPDATA->m_freePixmap = TRUE;
|
// M_BITMAPDATA->m_freePixmap = TRUE;
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
Display *dpy = (Display*) wxGetDisplay();
|
||||||
|
|
||||||
@@ -276,6 +290,9 @@ void wxBitmap::SetDepth(int d)
|
|||||||
M_BITMAPDATA->m_depth = d;
|
M_BITMAPDATA->m_depth = d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
|
// XXX
|
||||||
void wxBitmap::SetQuality(int q)
|
void wxBitmap::SetQuality(int q)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
if (!M_BITMAPDATA)
|
||||||
@@ -284,6 +301,8 @@ void wxBitmap::SetQuality(int q)
|
|||||||
M_BITMAPDATA->m_quality = q;
|
M_BITMAPDATA->m_quality = q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void wxBitmap::SetOk(bool isOk)
|
void wxBitmap::SetOk(bool isOk)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
if (!M_BITMAPDATA)
|
||||||
@@ -419,7 +438,7 @@ bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name,
|
|||||||
int WXUNUSED(desiredWidth),
|
int WXUNUSED(desiredWidth),
|
||||||
int WXUNUSED(desiredHeight))
|
int WXUNUSED(desiredHeight))
|
||||||
{
|
{
|
||||||
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
// M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
||||||
|
|
||||||
int hotX, hotY;
|
int hotX, hotY;
|
||||||
unsigned int w, h;
|
unsigned int w, h;
|
||||||
@@ -471,7 +490,7 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
M_BITMAPHANDLERDATA->m_width = width;
|
M_BITMAPHANDLERDATA->m_width = width;
|
||||||
M_BITMAPHANDLERDATA->m_height = height;
|
M_BITMAPHANDLERDATA->m_height = height;
|
||||||
M_BITMAPHANDLERDATA->m_depth = 1;
|
M_BITMAPHANDLERDATA->m_depth = 1;
|
||||||
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
// M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
Display *dpy = (Display*) wxGetDisplay();
|
||||||
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
|
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
|
||||||
@@ -479,6 +498,7 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) XCreateBitmapFromData (dpy, RootWindow (dpy, DefaultScreen (dpy)), (char*) data, width, height);
|
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) ;
|
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?
|
// code for wxControl. TODO: can we avoid doing this until we need it?
|
||||||
// E.g. have CreateButtonPixmaps which is called on demand.
|
// E.g. have CreateButtonPixmaps which is called on demand.
|
||||||
XImage* image = (XImage *) XtMalloc (sizeof (XImage));
|
XImage* image = (XImage *) XtMalloc (sizeof (XImage));
|
||||||
@@ -529,6 +549,9 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_image = (WXImage*) image;
|
M_BITMAPHANDLERDATA->m_image = (WXImage*) image;
|
||||||
M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage;
|
M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -604,7 +627,7 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name,
|
|||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = depthRet;
|
M_BITMAPHANDLERDATA->m_depth = depthRet;
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
|
// M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
|
||||||
|
|
||||||
XpmFreeAttributes(&xpmAttr);
|
XpmFreeAttributes(&xpmAttr);
|
||||||
|
|
||||||
@@ -662,7 +685,7 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
M_BITMAPHANDLERDATA->m_width = width;
|
M_BITMAPHANDLERDATA->m_width = width;
|
||||||
M_BITMAPHANDLERDATA->m_height = height;
|
M_BITMAPHANDLERDATA->m_height = height;
|
||||||
M_BITMAPHANDLERDATA->m_depth = 1;
|
M_BITMAPHANDLERDATA->m_depth = 1;
|
||||||
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
// M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
|
||||||
|
|
||||||
Display *dpy = (Display*) wxGetDisplay();
|
Display *dpy = (Display*) wxGetDisplay();
|
||||||
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
|
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
|
||||||
@@ -686,7 +709,7 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
xpmAttr.valuemask |= XpmColorSymbols; // add flag
|
xpmAttr.valuemask |= XpmColorSymbols; // add flag
|
||||||
}
|
}
|
||||||
|
|
||||||
Pixmap pixmap;
|
Pixmap pixmap = 0;
|
||||||
Pixmap mask = 0;
|
Pixmap mask = 0;
|
||||||
int ErrorStatus = XpmCreatePixmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)),
|
int ErrorStatus = XpmCreatePixmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)),
|
||||||
(char**) data, &pixmap, &mask, &xpmAttr);
|
(char**) data, &pixmap, &mask, &xpmAttr);
|
||||||
@@ -715,7 +738,7 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data,
|
|||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = depthRet;
|
M_BITMAPHANDLERDATA->m_depth = depthRet;
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
|
// M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
|
||||||
XpmFreeAttributes(&xpmAttr);
|
XpmFreeAttributes(&xpmAttr);
|
||||||
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
||||||
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
|
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
|
||||||
@@ -749,13 +772,15 @@ void wxBitmap::InitStandardHandlers()
|
|||||||
#endif // wxHAVE_LIB_XPM
|
#endif // wxHAVE_LIB_XPM
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
|
WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
|
||||||
{
|
{
|
||||||
if (!M_BITMAPDATA)
|
if (!M_BITMAPDATA)
|
||||||
return (WXPixmap)NULL;
|
return (WXPixmap)NULL;
|
||||||
if (M_BITMAPDATA->m_image == (WXPixmap) 0)
|
// if (M_BITMAPDATA->m_image == (WXPixmap) 0)
|
||||||
return M_BITMAPDATA->m_pixmap;
|
return M_BITMAPDATA->m_pixmap;
|
||||||
|
|
||||||
|
#if 0
|
||||||
Display *dpy = (Display*) M_BITMAPDATA->m_display;
|
Display *dpy = (Display*) M_BITMAPDATA->m_display;
|
||||||
|
|
||||||
#ifdef FOO
|
#ifdef FOO
|
||||||
@@ -794,13 +819,15 @@ WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
|
|||||||
M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
|
M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
|
||||||
|
|
||||||
return M_BITMAPDATA->m_labelPixmap;
|
return M_BITMAPDATA->m_labelPixmap;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
|
WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
|
||||||
{
|
{
|
||||||
if (M_BITMAPDATA->m_image == (WXPixmap) 0)
|
// if (M_BITMAPDATA->m_image == (WXPixmap) 0)
|
||||||
return M_BITMAPDATA->m_pixmap;
|
return M_BITMAPDATA->m_pixmap;
|
||||||
|
|
||||||
|
#if 0
|
||||||
Display *dpy = (Display*) M_BITMAPDATA->m_display;
|
Display *dpy = (Display*) M_BITMAPDATA->m_display;
|
||||||
#ifdef FOO
|
#ifdef FOO
|
||||||
// See GetLabelPixmap () comment
|
// See GetLabelPixmap () comment
|
||||||
@@ -824,6 +851,7 @@ WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
|
|||||||
M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
|
M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
|
||||||
|
|
||||||
return M_BITMAPDATA->m_armPixmap;
|
return M_BITMAPDATA->m_armPixmap;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
|
WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
|
||||||
@@ -844,9 +872,10 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
|
|||||||
return M_BITMAPDATA->m_pixmap;
|
return M_BITMAPDATA->m_pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
|
// if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
|
||||||
return M_BITMAPDATA->m_pixmap;
|
return M_BITMAPDATA->m_pixmap;
|
||||||
|
|
||||||
|
#if 0
|
||||||
#ifdef FOO
|
#ifdef FOO
|
||||||
See GetLabelPixmap () comment
|
See GetLabelPixmap () comment
|
||||||
// Must be destroyed, because colours can have been changed!
|
// Must be destroyed, because colours can have been changed!
|
||||||
@@ -867,7 +896,9 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
|
|||||||
M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
|
M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
|
||||||
|
|
||||||
return M_BITMAPDATA->m_insensPixmap;
|
return M_BITMAPDATA->m_insensPixmap;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// We may need this sometime...
|
// We may need this sometime...
|
||||||
|
|
||||||
@@ -1075,8 +1106,8 @@ wxSearchColor::wxSearchColor( int size_, XColor *colors_ )
|
|||||||
|
|
||||||
wxSearchColor::~wxSearchColor( void )
|
wxSearchColor::~wxSearchColor( void )
|
||||||
{
|
{
|
||||||
if ( color ) delete color;
|
if ( color ) delete[] color;
|
||||||
if ( entry ) delete entry;
|
if ( entry ) delete[] entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxSearchColor::SearchColor( int r, int g, int b )
|
int wxSearchColor::SearchColor( int r, int g, int b )
|
||||||
@@ -1208,12 +1239,11 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
vinfo_template.depth = bpp;
|
vinfo_template.depth = bpp;
|
||||||
int nitem = 0;
|
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") );
|
wxCHECK_MSG( vi, FALSE, wxT("no visual") );
|
||||||
|
|
||||||
XFree( vi );
|
|
||||||
|
|
||||||
if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15;
|
if ((bpp == 16) && (vi->red_mask != 0xf800)) bpp = 15;
|
||||||
if (bpp < 8) bpp = 8;
|
if (bpp < 8) bpp = 8;
|
||||||
|
|
||||||
@@ -1232,6 +1262,8 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
else if ((vi->green_mask > vi->blue_mask) && (vi->blue_mask > vi->red_mask)) b_o = GBR;
|
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 r_mask = image.GetMaskRed();
|
||||||
int g_mask = image.GetMaskGreen();
|
int g_mask = image.GetMaskGreen();
|
||||||
int b_mask = image.GetMaskBlue();
|
int b_mask = image.GetMaskBlue();
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
// Implemented in button.cpp
|
// Implemented in button.cpp
|
||||||
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr);
|
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)
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||||
|
|
||||||
@@ -175,11 +175,15 @@ void wxBitmapButton::DoSetBitmap()
|
|||||||
wxBitmap newBitmap =
|
wxBitmap newBitmap =
|
||||||
wxCreateMaskedBitmap(m_bmpNormalOriginal, col);
|
wxCreateMaskedBitmap(m_bmpNormalOriginal, col);
|
||||||
m_bmpNormal = newBitmap;
|
m_bmpNormal = newBitmap;
|
||||||
|
m_bitmapCache.SetBitmap( m_bmpNormal );
|
||||||
|
|
||||||
pixmap = (Pixmap) m_bmpNormal.GetPixmap();
|
pixmap = (Pixmap) m_bmpNormal.GetPixmap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pixmap = (Pixmap) m_bmpNormal.GetLabelPixmap(m_mainWidget);
|
{
|
||||||
|
m_bitmapCache.SetBitmap( m_bmpNormal );
|
||||||
|
pixmap = (Pixmap) m_bitmapCache.GetLabelPixmap(m_mainWidget);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_bmpDisabledOriginal.Ok())
|
if (m_bmpDisabledOriginal.Ok())
|
||||||
{
|
{
|
||||||
@@ -200,10 +204,10 @@ void wxBitmapButton::DoSetBitmap()
|
|||||||
insensPixmap = (Pixmap) m_bmpDisabled.GetPixmap();
|
insensPixmap = (Pixmap) m_bmpDisabled.GetPixmap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
insensPixmap = (Pixmap) m_bmpNormal.GetInsensPixmap(m_mainWidget);
|
insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
insensPixmap = (Pixmap) m_bmpNormal.GetInsensPixmap(m_mainWidget);
|
insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
|
||||||
|
|
||||||
// Now make the bitmap representing the armed state
|
// Now make the bitmap representing the armed state
|
||||||
if (m_bmpSelectedOriginal.Ok())
|
if (m_bmpSelectedOriginal.Ok())
|
||||||
@@ -225,11 +229,12 @@ void wxBitmapButton::DoSetBitmap()
|
|||||||
armPixmap = (Pixmap) m_bmpSelected.GetPixmap();
|
armPixmap = (Pixmap) m_bmpSelected.GetPixmap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
armPixmap = (Pixmap) m_bmpNormal.GetArmPixmap(m_mainWidget);
|
armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
|
||||||
}
|
}
|
||||||
else
|
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!
|
// <- the Get...Pixmap()-functions return the same pixmap!
|
||||||
if (insensPixmap == pixmap)
|
if (insensPixmap == pixmap)
|
||||||
{
|
{
|
||||||
@@ -237,6 +242,7 @@ void wxBitmapButton::DoSetBitmap()
|
|||||||
XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap);
|
XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap);
|
||||||
m_insensPixmap = (WXPixmap) insensPixmap;
|
m_insensPixmap = (WXPixmap) insensPixmap;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
XtVaSetValues ((Widget) m_mainWidget,
|
XtVaSetValues ((Widget) m_mainWidget,
|
||||||
XmNlabelPixmap, pixmap,
|
XmNlabelPixmap, pixmap,
|
||||||
|
204
src/motif/bmpmotif.cpp
Normal file
204
src/motif/bmpmotif.cpp
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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;
|
||||||
|
}
|
@@ -184,6 +184,7 @@ ALL_SOURCES = \
|
|||||||
motif/app.cpp \
|
motif/app.cpp \
|
||||||
motif/bitmap.cpp \
|
motif/bitmap.cpp \
|
||||||
motif/bmpbuttn.cpp \
|
motif/bmpbuttn.cpp \
|
||||||
|
motif/bmpmotif.cpp \
|
||||||
motif/button.cpp \
|
motif/button.cpp \
|
||||||
motif/checkbox.cpp \
|
motif/checkbox.cpp \
|
||||||
motif/checklst.cpp \
|
motif/checklst.cpp \
|
||||||
@@ -305,7 +306,6 @@ ALL_HEADERS = \
|
|||||||
ctrlsub.h \
|
ctrlsub.h \
|
||||||
cursor.h \
|
cursor.h \
|
||||||
dataobj.h \
|
dataobj.h \
|
||||||
date.h \
|
|
||||||
datetime.h \
|
datetime.h \
|
||||||
datetime.inl \
|
datetime.inl \
|
||||||
datstrm.h \
|
datstrm.h \
|
||||||
@@ -479,7 +479,6 @@ ALL_HEADERS = \
|
|||||||
tglbtn.h \
|
tglbtn.h \
|
||||||
thread.h \
|
thread.h \
|
||||||
thrimpl.cpp \
|
thrimpl.cpp \
|
||||||
time.h \
|
|
||||||
timer.h \
|
timer.h \
|
||||||
tipdlg.h \
|
tipdlg.h \
|
||||||
tipwin.h \
|
tipwin.h \
|
||||||
@@ -519,6 +518,7 @@ ALL_HEADERS = \
|
|||||||
motif/app.h \
|
motif/app.h \
|
||||||
motif/bitmap.h \
|
motif/bitmap.h \
|
||||||
motif/bmpbuttn.h \
|
motif/bmpbuttn.h \
|
||||||
|
motif/bmpmotif.h \
|
||||||
motif/button.h \
|
motif/button.h \
|
||||||
motif/checkbox.h \
|
motif/checkbox.h \
|
||||||
motif/checklst.h \
|
motif/checklst.h \
|
||||||
@@ -828,6 +828,7 @@ GUIOBJS = \
|
|||||||
app.o \
|
app.o \
|
||||||
bitmap.o \
|
bitmap.o \
|
||||||
bmpbuttn.o \
|
bmpbuttn.o \
|
||||||
|
bmpmotif.o \
|
||||||
button.o \
|
button.o \
|
||||||
checkbox.o \
|
checkbox.o \
|
||||||
checklst.o \
|
checklst.o \
|
||||||
|
@@ -660,7 +660,7 @@ void wxFrame::PositionToolBar()
|
|||||||
tw = cw;
|
tw = cw;
|
||||||
}
|
}
|
||||||
|
|
||||||
tb->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS);
|
tb->SetSize(0, 0, -1, -1, wxSIZE_NO_ADJUSTMENTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // wxUSE_TOOLBAR
|
#endif // wxUSE_TOOLBAR
|
||||||
|
@@ -124,7 +124,10 @@ void wxStaticBitmap::DoSetBitmap()
|
|||||||
pixmap = (Pixmap) m_messageBitmap.GetPixmap();
|
pixmap = (Pixmap) m_messageBitmap.GetPixmap();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pixmap = (Pixmap) m_messageBitmap.GetLabelPixmap(widget);
|
{
|
||||||
|
m_bitmapCache.SetBitmap( m_messageBitmap );
|
||||||
|
pixmap = (Pixmap)m_bitmapCache.GetLabelPixmap(widget);
|
||||||
|
}
|
||||||
|
|
||||||
XtVaSetValues (widget,
|
XtVaSetValues (widget,
|
||||||
XmNlabelPixmap, pixmap,
|
XmNlabelPixmap, pixmap,
|
||||||
@@ -164,11 +167,13 @@ void wxStaticBitmap::ChangeBackgroundColour()
|
|||||||
wxWindow::ChangeBackgroundColour();
|
wxWindow::ChangeBackgroundColour();
|
||||||
|
|
||||||
// must recalculate the background colour
|
// must recalculate the background colour
|
||||||
|
m_bitmapCache.SetColoursChanged();
|
||||||
DoSetBitmap();
|
DoSetBitmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::ChangeForegroundColour()
|
void wxStaticBitmap::ChangeForegroundColour()
|
||||||
{
|
{
|
||||||
|
m_bitmapCache.SetColoursChanged();
|
||||||
wxWindow::ChangeForegroundColour();
|
wxWindow::ChangeForegroundColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/motif/private.h"
|
#include "wx/motif/private.h"
|
||||||
|
#include "wx/motif/bmpmotif.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxWin macros
|
// wxWin macros
|
||||||
@@ -108,14 +109,22 @@ public:
|
|||||||
void SetWidget(Widget widget) { m_widget = widget; }
|
void SetWidget(Widget widget) { m_widget = widget; }
|
||||||
Widget GetButtonWidget() const { return m_widget; }
|
Widget GetButtonWidget() const { return m_widget; }
|
||||||
|
|
||||||
void SetPixmap(Pixmap pixmap) { m_pixmap = pixmap; }
|
Pixmap GetArmPixmap()
|
||||||
Pixmap GetPixmap() const { return m_pixmap; }
|
{
|
||||||
|
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:
|
protected:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
Widget m_widget;
|
Widget m_widget;
|
||||||
Pixmap m_pixmap;
|
wxBitmapCache m_bitmapCache;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -158,15 +167,12 @@ wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control)
|
|||||||
void wxToolBarTool::Init()
|
void wxToolBarTool::Init()
|
||||||
{
|
{
|
||||||
m_widget = (Widget)0;
|
m_widget = (Widget)0;
|
||||||
m_pixmap = (Pixmap)0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxToolBarTool::~wxToolBarTool()
|
wxToolBarTool::~wxToolBarTool()
|
||||||
{
|
{
|
||||||
if ( m_widget )
|
if ( m_widget )
|
||||||
XtDestroyWidget(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.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -274,7 +280,7 @@ bool wxToolBar::Realize()
|
|||||||
|
|
||||||
Widget button;
|
Widget button;
|
||||||
Pixmap pixmap, insensPixmap;
|
Pixmap pixmap, insensPixmap;
|
||||||
wxBitmap bmp;
|
wxBitmap bmp, insensBmp;
|
||||||
|
|
||||||
wxToolBarToolsList::Node *node = m_tools.GetFirst();
|
wxToolBarToolsList::Node *node = m_tools.GetFirst();
|
||||||
while ( node )
|
while ( node )
|
||||||
@@ -291,8 +297,8 @@ bool wxToolBar::Realize()
|
|||||||
// Allow a control to specify a y[x]-offset by setting
|
// Allow a control to specify a y[x]-offset by setting
|
||||||
// its initial position, but still don't allow it to
|
// its initial position, but still don't allow it to
|
||||||
// position itself above the top[left] margin.
|
// position itself above the top[left] margin.
|
||||||
int controlY = (pos.y > 0) ? currentY + pos.y : currentY;
|
int controlY = (pos.y > 0) ? pos.y : currentY;
|
||||||
int controlX = (pos.x > 0) ? currentX + pos.x : currentX;
|
int controlX = (pos.x > 0) ? pos.x : currentX;
|
||||||
control->Move( isVertical ? controlX : currentX,
|
control->Move( isVertical ? controlX : currentX,
|
||||||
isVertical ? currentY : controlY );
|
isVertical ? currentY : controlY );
|
||||||
if ( isVertical )
|
if ( isVertical )
|
||||||
@@ -304,14 +310,16 @@ bool wxToolBar::Realize()
|
|||||||
}
|
}
|
||||||
case wxTOOL_STYLE_SEPARATOR:
|
case wxTOOL_STYLE_SEPARATOR:
|
||||||
// skip separators for vertical toolbars
|
// skip separators for vertical toolbars
|
||||||
if( isVertical ) break;
|
if( !isVertical )
|
||||||
|
{
|
||||||
currentX += separatorSize;
|
currentX += separatorSize;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxTOOL_STYLE_BUTTON:
|
case wxTOOL_STYLE_BUTTON:
|
||||||
button = (Widget) 0;
|
button = (Widget) 0;
|
||||||
|
|
||||||
if ( tool->CanBeToggled() )
|
if ( tool->CanBeToggled() && !tool->GetButtonWidget() )
|
||||||
{
|
{
|
||||||
button = XtVaCreateWidget("toggleButton",
|
button = XtVaCreateWidget("toggleButton",
|
||||||
xmToggleButtonWidgetClass, (Widget) m_mainWidget,
|
xmToggleButtonWidgetClass, (Widget) m_mainWidget,
|
||||||
@@ -325,14 +333,18 @@ bool wxToolBar::Realize()
|
|||||||
XmNmultiClick, XmMULTICLICK_KEEP,
|
XmNmultiClick, XmMULTICLICK_KEEP,
|
||||||
XmNlabelType, XmPIXMAP,
|
XmNlabelType, XmPIXMAP,
|
||||||
NULL);
|
NULL);
|
||||||
XtAddCallback ((Widget) button, XmNvalueChangedCallback, (XtCallbackProc) wxToolButtonCallback,
|
XtAddCallback ((Widget) button,
|
||||||
|
XmNvalueChangedCallback,
|
||||||
|
(XtCallbackProc) wxToolButtonCallback,
|
||||||
(XtPointer) this);
|
(XtPointer) this);
|
||||||
|
|
||||||
XtVaSetValues ((Widget) button,
|
XtVaSetValues ((Widget) button,
|
||||||
XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
|
XmNselectColor,
|
||||||
|
m_backgroundColour.AllocColour
|
||||||
|
(XtDisplay((Widget) button)),
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
else
|
else if( !tool->GetButtonWidget() )
|
||||||
{
|
{
|
||||||
button = XtVaCreateWidget("button",
|
button = XtVaCreateWidget("button",
|
||||||
xmPushButtonWidgetClass, (Widget) m_mainWidget,
|
xmPushButtonWidgetClass, (Widget) m_mainWidget,
|
||||||
@@ -342,20 +354,33 @@ bool wxToolBar::Realize()
|
|||||||
XmNlabelType, XmPIXMAP,
|
XmNlabelType, XmPIXMAP,
|
||||||
NULL);
|
NULL);
|
||||||
XtAddCallback (button,
|
XtAddCallback (button,
|
||||||
XmNactivateCallback, (XtCallbackProc) wxToolButtonCallback,
|
XmNactivateCallback,
|
||||||
|
(XtCallbackProc) wxToolButtonCallback,
|
||||||
(XtPointer) this);
|
(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
|
// For each button, if there is a mask, we must create
|
||||||
// a new wxBitmap that has the correct background colour
|
// a new wxBitmap that has the correct background colour
|
||||||
// for the button. Otherwise the background will just be
|
// for the button. Otherwise the background will just be
|
||||||
// e.g. black if a transparent XPM has been loaded.
|
// e.g. black if a transparent XPM has been loaded.
|
||||||
bmp = tool->GetNormalBitmap();
|
bmp = tool->GetNormalBitmap();
|
||||||
if ( bmp.GetMask() )
|
insensBmp = tool->GetDisabledBitmap();
|
||||||
|
if ( bmp.GetMask() || insensBmp.GetMask() )
|
||||||
{
|
{
|
||||||
int backgroundPixel;
|
int backgroundPixel;
|
||||||
XtVaGetValues(button, XmNbackground, &backgroundPixel,
|
XtVaGetValues(button, XmNbackground, &backgroundPixel,
|
||||||
@@ -363,11 +388,20 @@ bool wxToolBar::Realize()
|
|||||||
|
|
||||||
wxColour col;
|
wxColour col;
|
||||||
col.SetPixel(backgroundPixel);
|
col.SetPixel(backgroundPixel);
|
||||||
bmp = wxCreateMaskedBitmap(bmp, col);
|
|
||||||
|
|
||||||
|
if( bmp.GetMask() )
|
||||||
|
{
|
||||||
|
bmp = wxCreateMaskedBitmap(bmp, col);
|
||||||
tool->SetNormalBitmap(bmp);
|
tool->SetNormalBitmap(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( insensBmp.GetMask() )
|
||||||
|
{
|
||||||
|
insensBmp = wxCreateMaskedBitmap(insensBmp, col);
|
||||||
|
tool->SetDisabledBitmap(insensBmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create a selected/toggled bitmap. If there isn't a 2nd
|
// Create a selected/toggled bitmap. If there isn't a 2nd
|
||||||
// bitmap, we need to create it (with a darker, selected
|
// bitmap, we need to create it (with a darker, selected
|
||||||
// background)
|
// background)
|
||||||
@@ -381,53 +415,20 @@ bool wxToolBar::Realize()
|
|||||||
wxColour col;
|
wxColour col;
|
||||||
col.SetPixel(backgroundPixel);
|
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();
|
pixmap = (Pixmap) bmp.GetPixmap();
|
||||||
insensPixmap = (Pixmap) bmp.GetInsensPixmap();
|
{
|
||||||
|
wxBitmap tmp = tool->GetDisabledBitmap();
|
||||||
|
|
||||||
|
insensPixmap = tmp.Ok() ?
|
||||||
|
(Pixmap)tmp.GetPixmap() :
|
||||||
|
tool->GetInsensPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
if (tool->CanBeToggled())
|
if (tool->CanBeToggled())
|
||||||
{
|
{
|
||||||
// Toggle button
|
// Toggle button
|
||||||
Pixmap pixmap2 = (Pixmap) 0;
|
Pixmap pixmap2 = tool->GetArmPixmap();
|
||||||
Pixmap insensPixmap2 = (Pixmap) 0;
|
Pixmap insensPixmap2 = tool->GetInsensPixmap();
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
XtVaSetValues (button,
|
XtVaSetValues (button,
|
||||||
XmNfillOnSelect, True,
|
XmNfillOnSelect, True,
|
||||||
@@ -440,21 +441,7 @@ bool wxToolBar::Realize()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Pixmap pixmap2 = (Pixmap) 0;
|
Pixmap pixmap2 = tool->GetArmPixmap();
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Normal button
|
// Normal button
|
||||||
XtVaSetValues(button,
|
XtVaSetValues(button,
|
||||||
@@ -491,8 +478,8 @@ bool wxToolBar::Realize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetSize( -1, -1,
|
SetSize( -1, -1,
|
||||||
isVertical ? buttonWidth + 2 * marginX : currentX,
|
isVertical ? buttonWidth + 2 * marginX : -1,
|
||||||
isVertical ? currentY : buttonHeight + 2*marginY );
|
isVertical ? -1 : buttonHeight + 2*marginY );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -512,10 +499,91 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
|
bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
|
||||||
{
|
{
|
||||||
tool->Detach();
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,20 +612,19 @@ void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
int old_width, old_height;
|
int old_width, old_height;
|
||||||
GetSize(&old_width, &old_height);
|
GetSize(&old_width, &old_height);
|
||||||
|
|
||||||
wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
|
|
||||||
|
|
||||||
// Correct width and height if needed.
|
// Correct width and height if needed.
|
||||||
if ( width == -1 || height == -1 )
|
if ( width == -1 || height == -1 )
|
||||||
{
|
{
|
||||||
int tmp_width, tmp_height;
|
wxSize defaultSize = GetSize();
|
||||||
GetSize(&tmp_width, &tmp_height);
|
|
||||||
|
|
||||||
if ( width == -1 )
|
if ( width == -1 )
|
||||||
width = tmp_width;
|
width = defaultSize.x;
|
||||||
if ( height == -1 )
|
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
|
// We must refresh the frame size when the toolbar changes size
|
||||||
// otherwise the toolbar can be shown incorrectly
|
// otherwise the toolbar can be shown incorrectly
|
||||||
if ( old_width != width || old_height != height )
|
if ( old_width != width || old_height != height )
|
||||||
|
Reference in New Issue
Block a user