+ delete wxTheToolBarTimer;
+ wxTheToolBarTimer = NULL;
+}
+
+bool wxToolBar::Realize()
+{
+ if ( m_tools.GetCount() == 0 )
+ {
+ // nothing to do
+ return true;
+ }
+
+ bool isVertical = GetWindowStyle() & wxTB_VERTICAL;
+
+ // 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, buttonWidth = 0;
+
+ Widget button;
+ Pixmap pixmap, insensPixmap;
+ wxBitmap bmp, insensBmp;
+
+ wxToolBarToolsList::compatibility_iterator 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();
+ // Allow a control to specify a y[x]-offset by setting
+ // its initial position, but still don't allow it to
+ // position itself above the top[left] margin.
+ int controlY = (pos.y > 0) ? pos.y : currentY;
+ int controlX = (pos.x > 0) ? pos.x : currentX;
+ control->Move( isVertical ? controlX : currentX,
+ isVertical ? currentY : controlY );
+ if ( isVertical )
+ currentY += sz.y + packing;
+ else
+ currentX += sz.x + packing;
+
+ break;
+ }
+ case wxTOOL_STYLE_SEPARATOR:
+ // skip separators for vertical toolbars
+ if( !isVertical )
+ {
+ currentX += separatorSize;
+ }
+ break;
+
+ case wxTOOL_STYLE_BUTTON:
+ button = (Widget) 0;
+
+ 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 );
+ }
+
+ // 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();
+ insensBmp = tool->GetDisabledBitmap();
+ if ( bmp.GetMask() || insensBmp.GetMask() )
+ {
+ WXPixel backgroundPixel;
+ XtVaGetValues(button, XmNbackground, &backgroundPixel,
+ NULL);
+
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ if( bmp.Ok() && bmp.GetMask() )
+ {
+ bmp = wxCreateMaskedBitmap(bmp, col);
+ tool->SetNormalBitmap(bmp);
+ }
+
+ if( insensBmp.Ok() && insensBmp.GetMask() )
+ {
+ insensBmp = wxCreateMaskedBitmap(insensBmp, col);
+ tool->SetDisabledBitmap(insensBmp);
+ }
+ }
+
+ // Create a selected/toggled bitmap. If there isn't a 2nd
+ // bitmap, we need to create it (with a darker, selected
+ // background)
+ WXPixel backgroundPixel;
+ if ( tool->CanBeToggled() )
+ XtVaGetValues(button, XmNselectColor, &backgroundPixel,
+ NULL);
+ else
+ XtVaGetValues(button, XmNarmColor, &backgroundPixel,
+ NULL);
+ wxColour col;
+ col.SetPixel(backgroundPixel);
+
+ pixmap = (Pixmap) bmp.GetDrawable();
+ {
+ wxBitmap tmp = tool->GetDisabledBitmap();
+
+ insensPixmap = tmp.Ok() ?
+ (Pixmap)tmp.GetDrawable() :
+ tool->GetInsensPixmap();
+ }
+
+ if (tool->CanBeToggled())
+ {
+ // Toggle button
+ Pixmap pixmap2 = tool->GetArmPixmap();
+ Pixmap insensPixmap2 = tool->GetInsensPixmap();
+
+ XtVaSetValues (button,
+ XmNfillOnSelect, True,
+ XmNlabelPixmap, pixmap,
+ XmNselectPixmap, pixmap2,
+ XmNlabelInsensitivePixmap, insensPixmap,
+ XmNselectInsensitivePixmap, insensPixmap2,
+ XmNlabelType, XmPIXMAP,
+ NULL);
+ }
+ else
+ {
+ Pixmap pixmap2 = tool->GetArmPixmap();
+
+ // 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);
+
+ break;
+ }
+
+ node = node->GetNext();
+ }
+
+ SetSize( -1, -1,
+ isVertical ? buttonWidth + 2 * marginX : -1,
+ isVertical ? -1 : buttonHeight + 2*marginY );
+
+ return true;
+}
+
+wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
+ wxCoord WXUNUSED(y)) const
+{
+ wxFAIL_MSG( wxT("TODO") );
+
+ return NULL;
+}
+
+bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
+{
+ tool->Attach(this);
+
+ return true;