+ delete wxTheToolBarTimer;
+ wxTheToolBarTimer = NULL;
+}
+
+bool wxToolBar::Realize()
+{
+ if ( m_tools.GetCount() == 0 )
+ {
+ // nothing to do
+ return TRUE;
+ }
+
+ // Separator spacing
+ const int separatorSize = GetToolSeparation(); // 8;
+ wxSize margins = GetToolMargins();
+ int packing = GetToolPacking();
+ int marginX = margins.x;
+ int marginY = margins.y;
+
+ int currentX = marginX;
+ int currentY = marginY;
+
+ int buttonHeight = 0;
+
+ int currentSpacing = 0;
+
+ Widget button;
+ Pixmap pixmap, insensPixmap;
+ wxBitmap bmp;
+
+ wxToolBarToolsList::Node *node = m_tools.GetFirst();
+ while ( node )
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
+
+ switch ( tool->GetStyle() )
+ {
+ case wxTOOL_STYLE_CONTROL:
+ {
+ wxControl* control = tool->GetControl();
+ wxSize sz = control->GetSize();
+ wxPoint pos = control->GetPosition();
+ control->Move(currentX, pos.y);
+ currentX += sz.x + packing;
+
+ break;
+ }
+ case wxTOOL_STYLE_SEPARATOR:
+ currentX += separatorSize;
+ break;
+
+ case wxTOOL_STYLE_BUTTON:
+ button = (Widget) 0;
+
+ if ( tool->CanBeToggled() )
+ {
+ 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
+ {
+ 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->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);
+ 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;
+}
+
+wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
+ wxCoord WXUNUSED(y)) const
+{
+ wxFAIL_MSG( _T("TODO") );
+
+ return (wxToolBarToolBase *)NULL;