- wxColour col;
- col.SetPixel(backgroundPixel);
-
- wxMemoryDC destDC;
- wxMemoryDC srcDC;
- srcDC.SelectObject(tool->m_bitmap1);
- destDC.SelectObject(newBitmap);
-
- wxBrush brush(col, wxSOLID);
- destDC.SetOptimization(FALSE);
- destDC.SetBackground(brush);
- destDC.Clear();
- destDC.Blit(0, 0, tool->m_bitmap1.GetWidth(), tool->m_bitmap1.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
-
- tool->m_bitmap1 = newBitmap;
- }
- if (tool->m_bitmap2.Ok() && tool->m_bitmap2.GetMask())
- {
- wxBitmap newBitmap(tool->m_bitmap2.GetWidth(),
- tool->m_bitmap2.GetHeight(),
- tool->m_bitmap2.GetDepth());
- int backgroundPixel;
- XtVaGetValues(button, XmNbackground, &backgroundPixel,
- NULL);
+ if ( tool->CanBeToggled() && !tool->GetButtonWidget() )
+ {
+ button = XtVaCreateWidget("toggleButton",
+ xmToggleButtonWidgetClass, (Widget) m_mainWidget,
+ XmNx, currentX, XmNy, currentY,
+ XmNindicatorOn, False,
+ XmNshadowThickness, 2,
+ XmNborderWidth, 0,
+ XmNspacing, 0,
+ XmNmarginWidth, 0,
+ XmNmarginHeight, 0,
+ XmNmultiClick, XmMULTICLICK_KEEP,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ XtAddCallback ((Widget) button,
+ XmNvalueChangedCallback,
+ (XtCallbackProc) wxToolButtonCallback,
+ (XtPointer) this);
+
+ XtVaSetValues ((Widget) button,
+ XmNselectColor,
+ m_backgroundColour.AllocColour
+ (XtDisplay((Widget) button)),
+ NULL);
+ }
+ else if( !tool->GetButtonWidget() )
+ {
+ 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);
+ }
+
+ if( !tool->GetButtonWidget() )
+ {
+ wxDoChangeBackgroundColour((WXWidget) button,
+ m_backgroundColour, true);
+
+ tool->SetWidget(button);
+ }
+ else
+ {
+ button = (Widget)tool->GetButtonWidget();
+ XtVaSetValues( button,
+ XmNx, currentX, XmNy, currentY,
+ NULL );
+ }