+ XtVaSetValues ((Widget) button,
+ XmNselectColor, m_backgroundColour.AllocColour(XtDisplay((Widget) button)),
+ NULL);
+ }
+ else
+ {
+ button = XtVaCreateWidget("button",
+ xmPushButtonWidgetClass, (Widget) m_mainWidget,
+ XmNx, currentX, XmNy, currentY,
+ XmNpushButtonEnabled, True,
+ XmNmultiClick, XmMULTICLICK_KEEP,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ XtAddCallback (button,
+ XmNactivateCallback, (XtCallbackProc) wxToolButtonCallback,
+ (XtPointer) this);
+ }
+
+ DoChangeBackgroundColour((WXWidget) button, m_backgroundColour, TRUE);
+
+ tool->SetWidget(button);
+
+ // 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->GetBitmap1();
+ if ( bmp.GetMask() )
+ {
+ int backgroundPixel;
+ XtVaGetValues(button, XmNbackground, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ bmp = wxCreateMaskedBitmap(bmp, col);
+
+ tool->SetBitmap1(bmp);
+ }
+
+ // Create a selected/toggled bitmap. If there isn't a 2nd
+ // bitmap, we need to create it (with a darker, selected
+ // background)
+ int backgroundPixel;
+ if ( tool->CanBeToggled() )
+ XtVaGetValues(button, XmNselectColor, &backgroundPixel,
+ NULL);
+ else
+ XtVaGetValues(button, XmNarmColor, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ if (tool->GetBitmap2().Ok() && tool->GetBitmap2().GetMask())
+ {
+ // Use what's there
+ wxBitmap newBitmap = wxCreateMaskedBitmap(tool->GetBitmap2(), col);
+ tool->SetBitmap2(newBitmap);
+ }
+ else
+ {
+ // Use unselected bitmap
+ if ( bmp.GetMask() )
+ {
+ wxBitmap newBitmap = wxCreateMaskedBitmap(bmp, col);
+ tool->SetBitmap2(newBitmap);
+ }
+ else
+ tool->SetBitmap2(bmp);
+ }
+
+ pixmap = (Pixmap) bmp.GetPixmap();
+ insensPixmap = (Pixmap) bmp.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.
+ if (tool->GetBitmap2().Ok())
+ {
+ wxBitmap bmp2 = tool->GetBitmap2();
+ pixmap2 = (Pixmap) bmp2.GetPixmap();
+ insensPixmap2 = (Pixmap) bmp2.GetInsensPixmap();
+ }
+ else
+ {
+ pixmap2 = (Pixmap) bmp.GetArmPixmap(button);
+ insensPixmap2 = XCreateInsensitivePixmap((Display*) wxGetDisplay(), pixmap2);
+ }
+
+ tool->SetPixmap(pixmap2);
+
+ XtVaSetValues (button,
+ XmNfillOnSelect, True,
+ XmNlabelPixmap, pixmap,
+ XmNselectPixmap, pixmap2,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNselectInsensitivePixmap, insensPixmap2,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ }
+ else
+ {
+ Pixmap pixmap2 = (Pixmap) 0;
+
+ // If there's a bitmap for the armed state, use it,
+ // otherwise generate one.
+ if (tool->GetBitmap2().Ok())
+ {
+ pixmap2 = (Pixmap) tool->GetBitmap2().GetPixmap();
+ }
+ else
+ {
+ pixmap2 = (Pixmap) bmp.GetArmPixmap(button);
+
+ }
+
+ tool->SetPixmap(pixmap2);
+
+ // Normal button
+ XtVaSetValues(button,
+ XmNlabelPixmap, pixmap,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNarmPixmap, pixmap2,
+ NULL);
+ }
+
+ XtManageChild(button);
+
+ {
+ Dimension width, height;
+ XtVaGetValues(button,
+ XmNwidth, &width,
+ XmNheight, & height,
+ NULL);
+ currentX += width + packing;
+ buttonHeight = wxMax(buttonHeight, height);
+ }
+
+ XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
+ False, wxToolButtonPopupCallback, (XtPointer) this);
+
+ currentSpacing = 0;
+ break;
+ }
+
+ node = node->GetNext();
+ }
+
+ SetSize(-1, -1, currentX, buttonHeight + 2*marginY);
+
+ return TRUE;