1. wxMotif toolbar works; the toggle buttons have the same width as the other

ones and not twice as big
2. wxMotif::wxBitmap(from XPM) ctor now takes either "char **" or "const char
   **", as in wxGTK
3. added an X error handler to wxMotif (debug only)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4995 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-12-16 19:36:05 +00:00
parent 1eb6f40e2a
commit e838cc1468
10 changed files with 126 additions and 139 deletions

View File

@@ -64,8 +64,8 @@ public:
wxBitmap(); wxBitmap();
wxBitmap( int width, int height, int depth = -1 ); wxBitmap( int width, int height, int depth = -1 );
wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 );
wxBitmap( const char **bits ); wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
wxBitmap( char **bits ); wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
wxBitmap( const wxBitmap& bmp ); wxBitmap( const wxBitmap& bmp );
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM );
~wxBitmap(); ~wxBitmap();
@@ -99,6 +99,9 @@ public:
GdkPixmap *GetPixmap() const; GdkPixmap *GetPixmap() const;
GdkBitmap *GetBitmap() const; GdkBitmap *GetBitmap() const;
protected:
bool CreateFromXpm(const char **bits);
private: private:
DECLARE_DYNAMIC_CLASS(wxBitmap) DECLARE_DYNAMIC_CLASS(wxBitmap)
}; };

View File

@@ -64,8 +64,8 @@ public:
wxBitmap(); wxBitmap();
wxBitmap( int width, int height, int depth = -1 ); wxBitmap( int width, int height, int depth = -1 );
wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 );
wxBitmap( const char **bits ); wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); }
wxBitmap( char **bits ); wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); }
wxBitmap( const wxBitmap& bmp ); wxBitmap( const wxBitmap& bmp );
wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM );
~wxBitmap(); ~wxBitmap();
@@ -99,6 +99,9 @@ public:
GdkPixmap *GetPixmap() const; GdkPixmap *GetPixmap() const;
GdkBitmap *GetBitmap() const; GdkBitmap *GetBitmap() const;
protected:
bool CreateFromXpm(const char **bits);
private: private:
DECLARE_DYNAMIC_CLASS(wxBitmap) DECLARE_DYNAMIC_CLASS(wxBitmap)
}; };

View File

@@ -140,8 +140,12 @@ public:
// Initialize with raw XBM data // Initialize with raw XBM data
wxBitmap(const char bits[], int width, int height, int depth = 1); wxBitmap(const char bits[], int width, int height, int depth = 1);
// Initialize with XPM data // from XPM
wxBitmap(char **data, wxControl* control = NULL); wxBitmap(const char **data) { (void)CreateFromXpm(data); }
wxBitmap(char **data) { (void)CreateFromXpm((const char **)data); }
// Initialize with XPM data -- deprecated
wxBitmap(char **data, wxControl* control);
// Load a file or resource // Load a file or resource
wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM); wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM);
@@ -201,6 +205,9 @@ public:
protected: protected:
static wxList sm_handlers; static wxList sm_handlers;
protected:
bool CreateFromXpm(const char **bits);
}; };
// Creates a bitmap with transparent areas drawn in // Creates a bitmap with transparent areas drawn in

View File

@@ -217,13 +217,6 @@ void MyFrame::RecreateToolbar()
wxBitmap toolBarBitmaps[8]; wxBitmap toolBarBitmaps[8];
toolBarBitmaps[0] = wxBITMAP(new); toolBarBitmaps[0] = wxBITMAP(new);
#if 0
toolBar->AddTool(wxID_NEW, toolBarBitmaps[0], wxNullBitmap, FALSE, -1, -1,
(wxObject *) NULL, "New file");
toolBar->Realize();
return;
#endif
toolBarBitmaps[1] = wxBITMAP(open); toolBarBitmaps[1] = wxBITMAP(open);
if ( !m_smallToolbar ) if ( !m_smallToolbar )
{ {

View File

@@ -245,9 +245,9 @@ wxBitmap::wxBitmap( int width, int height, int depth )
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
} }
wxBitmap::wxBitmap( const char **bits ) bool wxBitmap::CreateFromXpm( const char **bits )
{ {
wxCHECK_RET( bits != NULL, wxT("invalid bitmap data") ) wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
@@ -256,6 +256,8 @@ wxBitmap::wxBitmap( const char **bits )
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") );
if (mask) if (mask)
{ {
M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask = new wxMask();
@@ -266,31 +268,8 @@ wxBitmap::wxBitmap( const char **bits )
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap( char **bits ) return TRUE;
{
wxCHECK_RET( bits != NULL, wxT("invalid bitmap data") )
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
wxCHECK_RET( M_BMPDATA->m_pixmap, wxT("couldn't create pixmap") );
if (mask)
{
M_BMPDATA->m_mask = new wxMask();
M_BMPDATA->m_mask->m_bitmap = mask;
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
} }
wxBitmap::wxBitmap( const wxBitmap& bmp ) wxBitmap::wxBitmap( const wxBitmap& bmp )

View File

@@ -245,9 +245,9 @@ wxBitmap::wxBitmap( int width, int height, int depth )
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
} }
wxBitmap::wxBitmap( const char **bits ) bool wxBitmap::CreateFromXpm( const char **bits )
{ {
wxCHECK_RET( bits != NULL, wxT("invalid bitmap data") ) wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") )
m_refData = new wxBitmapRefData(); m_refData = new wxBitmapRefData();
@@ -256,6 +256,8 @@ wxBitmap::wxBitmap( const char **bits )
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
wxCHECK_MSG( M_BMPDATA->m_pixmap, FALSE, wxT("couldn't create pixmap") );
if (mask) if (mask)
{ {
M_BMPDATA->m_mask = new wxMask(); M_BMPDATA->m_mask = new wxMask();
@@ -266,31 +268,8 @@ wxBitmap::wxBitmap( const char **bits )
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap( char **bits ) return TRUE;
{
wxCHECK_RET( bits != NULL, wxT("invalid bitmap data") )
m_refData = new wxBitmapRefData();
GdkBitmap *mask = (GdkBitmap*) NULL;
GdkWindow *parent = (GdkWindow*) &gdk_root_parent;
M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits );
wxCHECK_RET( M_BMPDATA->m_pixmap, wxT("couldn't create pixmap") );
if (mask)
{
M_BMPDATA->m_mask = new wxMask();
M_BMPDATA->m_mask->m_bitmap = mask;
}
gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) );
M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ?
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
} }
wxBitmap::wxBitmap( const wxBitmap& bmp ) wxBitmap::wxBitmap( const wxBitmap& bmp )

View File

@@ -68,6 +68,18 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
#ifdef __WXDEBUG__
typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
XErrorHandlerFunc gs_pfnXErrorHandler = 0;
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
{
// just forward to the default handler for now
return gs_pfnXErrorHandler(dpy, xevent);
}
#endif // __WXDEBUG__
long wxApp::sm_lastMessageTime = 0; long wxApp::sm_lastMessageTime = 0;
bool wxApp::Initialize() bool wxApp::Initialize()
@@ -575,6 +587,11 @@ bool wxApp::OnInitGui()
} }
m_initialDisplay = (WXDisplay*) dpy; m_initialDisplay = (WXDisplay*) dpy;
#ifdef __WXDEBUG__
// install the X error handler
gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler);
#endif // __WXDEBUG__
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(), wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
applicationShellWidgetClass,dpy, applicationShellWidgetClass,dpy,
NULL,0) ; NULL,0) ;

View File

@@ -168,6 +168,13 @@ wxBitmap::wxBitmap(char **data, wxControl* control)
sg_Control = (wxControl*) NULL; sg_Control = (wxControl*) NULL;
} }
bool wxBitmap::CreateFromXpm(const char **bits)
{
wxCHECK_MSG( bits, FALSE, _T("NULL pointer in wxBitmap::CreateFromXpm") );
return Create(bits, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
bool wxBitmap::Create(int w, int h, int d) bool wxBitmap::Create(int w, int h, int d)
{ {
UnRef(); UnRef();
@@ -860,7 +867,8 @@ WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
Display *dpy = (Display*) M_BITMAPDATA->m_display; Display *dpy = (Display*) M_BITMAPDATA->m_display;
#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!
if (M_BITMAPDATA->m_armPixmap) if (M_BITMAPDATA->m_armPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_armPixmap); XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_armPixmap);
@@ -961,8 +969,7 @@ Pixmap
XCreateInsensitivePixmap( Display *display, Pixmap pixmap ) XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
{ {
static static char stipple_data[] =
char stipple_data[] =
{ {
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,

View File

@@ -282,7 +282,12 @@ bool wxToolBar::Realize()
button = XtVaCreateWidget("toggleButton", button = XtVaCreateWidget("toggleButton",
xmToggleButtonWidgetClass, (Widget) m_mainWidget, xmToggleButtonWidgetClass, (Widget) m_mainWidget,
XmNx, currentX, XmNy, currentY, XmNx, currentX, XmNy, currentY,
// XmNpushButtonEnabled, True, XmNindicatorOn, False,
XmNshadowThickness, 2,
XmNborderWidth, 0,
XmNspacing, 0,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNmultiClick, XmMULTICLICK_KEEP, XmNmultiClick, XmMULTICLICK_KEEP,
XmNlabelType, XmPIXMAP, XmNlabelType, XmPIXMAP,
NULL); NULL);
@@ -325,9 +330,9 @@ bool wxToolBar::Realize()
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(bmp, col); bmp = wxCreateMaskedBitmap(bmp, col);
tool->SetBitmap1(newBitmap); tool->SetBitmap1(bmp);
} }
// Create a selected/toggled bitmap. If there isn't a 2nd // Create a selected/toggled bitmap. If there isn't a 2nd
@@ -388,12 +393,6 @@ bool wxToolBar::Realize()
tool->SetPixmap(pixmap2); tool->SetPixmap(pixmap2);
XtVaSetValues (button, XtVaSetValues (button,
XmNindicatorOn, False,
XmNshadowThickness, 2,
// XmNborderWidth, 0,
// XmNspacing, 0,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNfillOnSelect, True, XmNfillOnSelect, True,
XmNlabelPixmap, pixmap, XmNlabelPixmap, pixmap,
XmNselectPixmap, pixmap2, XmNselectPixmap, pixmap2,

View File

@@ -1718,7 +1718,7 @@ bool wxAddWindowToTable(Widget w, wxWindow *win)
wxWidgetHashTable->Put((long) w, win); wxWidgetHashTable->Put((long) w, win);
wxLogDebug("Widget 0x%08x <-> window %p (%s)", wxLogTrace("widget", "Widget 0x%08x <-> window %p (%s)",
w, win, win->GetClassInfo()->GetClassName()); w, win, win->GetClassInfo()->GetClassName());
return TRUE; return TRUE;