+ 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->GetNormalBitmap();
+ if ( bmp.GetMask() )
+ {
+ int backgroundPixel;
+ XtVaGetValues(button, XmNbackground, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+ bmp = wxCreateMaskedBitmap(bmp, col);
+
+ tool->SetNormalBitmap(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);
+
+ // 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();
+
+ 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);
+
+ 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 ( bmpToggled.Ok() )
+ {
+ pixmap2 = (Pixmap) bmpToggled.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);
+ if ( isVertical )
+ currentY += height + packing;
+ else
+ currentX += width + packing;
+ buttonHeight = wxMax(buttonHeight, height);
+ buttonWidth = wxMax(buttonWidth, width);
+ }
+
+ XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
+ False, wxToolButtonPopupCallback, (XtPointer) this);
+
+ currentSpacing = 0;
+ break;
+ }
+
+ node = node->GetNext();
+ }
+
+ SetSize( -1, -1,
+ isVertical ? buttonWidth + 2 * marginX : currentX,
+ isVertical ? currentY : buttonHeight + 2*marginY );
+
+ return TRUE;
+}
+
+wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
+ wxCoord WXUNUSED(y)) const
+{
+ wxFAIL_MSG( _T("TODO") );
+
+ return (wxToolBarToolBase *)NULL;