/////////////////////////////////////////////////////////////////////////////
-// Name: motif/toolbar.cpp
+// Name: src/motif/toolbar.cpp
// Purpose: wxToolBar
// Author: Julian Smart
// Modified by: 13.12.99 by VZ during toolbar classes reorganization
// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "toolbar.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// wxWin macros
// ----------------------------------------------------------------------------
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
-#endif
// ----------------------------------------------------------------------------
// private functions
{
if( !wxControl::CreateControl( parent, id, pos, size, style,
wxDefaultValidator, name ) )
- return FALSE;
+ return false;
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_mainWidget = (WXWidget) toolbar;
- ChangeFont(FALSE);
+ ChangeFont(false);
wxPoint rPos = pos;
wxSize rSize = size;
ChangeBackgroundColour();
- return TRUE;
+ return true;
}
wxToolBar::~wxToolBar()
if ( m_tools.GetCount() == 0 )
{
// nothing to do
- return TRUE;
+ return true;
}
bool isVertical = GetWindowStyle() & wxTB_VERTICAL;
int buttonHeight = 0, buttonWidth = 0;
- int currentSpacing = 0;
-
Widget button;
Pixmap pixmap, insensPixmap;
wxBitmap bmp, insensBmp;
if( !tool->GetButtonWidget() )
{
wxDoChangeBackgroundColour((WXWidget) button,
- m_backgroundColour, TRUE);
+ m_backgroundColour, true);
tool->SetWidget(button);
}
(Pixmap)tmp.GetDrawable() :
tool->GetInsensPixmap();
}
-
+
if (tool->CanBeToggled())
{
// Toggle button
XtAddEventHandler (button, EnterWindowMask | LeaveWindowMask,
False, wxToolButtonPopupCallback, (XtPointer) this);
- currentSpacing = 0;
break;
}
isVertical ? buttonWidth + 2 * marginX : -1,
isVertical ? -1 : buttonHeight + 2*marginY );
- return TRUE;
+ return true;
}
wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x),
{
tool->Attach(this);
- return TRUE;
+ return true;
}
-bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
+bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool)
{
tool->Detach();
offset = isVertical ? size.y : size.x;
offset += packing;
break;
- }
+ }
case wxTOOL_STYLE_SEPARATOR:
offset = isVertical ? 0 : separatorSize;
break;
{
case wxTOOL_STYLE_CONTROL:
{
- wxPoint pos = t->GetControl()->GetPosition();
+ wxPoint location = t->GetControl()->GetPosition();
if( isVertical )
- pos.y -= offset;
+ location.y -= offset;
else
- pos.x -= offset;
+ location.x -= offset;
- t->GetControl()->Move( pos );
+ t->GetControl()->Move( location );
break;
}
case wxTOOL_STYLE_SEPARATOR:
NULL );
if( isVertical )
- y -= offset;
+ y = (Dimension)(y - offset);
else
- x -= offset;
+ x = (Dimension)(x - offset);
XtVaSetValues( t->GetButtonWidget(),
XmNx, x,
}
}
- return TRUE;
+ return true;
}
void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable)
{
wxToolBarTool *tool = (wxToolBarTool *)toolBase;
-
- XtSetSensitive(tool->GetButtonWidget(), (Boolean) enable);
+ if (tool->GetButtonWidget()){
+ XtSetSensitive(tool->GetButtonWidget(), (Boolean) enable);
+ } else if (wxTOOL_STYLE_CONTROL == tool->GetStyle()){
+ // Controls (such as wxChoice) do not have button widgets
+ tool->GetControl()->Enable(enable);
+ }
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *toolBase, bool toggle)
}
wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags);
-
+
// We must refresh the frame size when the toolbar changes size
// otherwise the toolbar can be shown incorrectly
if ( old_width != width || old_height != height )
{
- // But before we send the size event check it
+ // But before we send the size event check it
// we have a frame that is not being deleted.
wxFrame *frame = wxDynamicCast(GetParent(), wxFrame);
if ( frame && !frame->IsBeingDeleted() )
wxToolBarTimer::help_popup = (Widget) 0;
// One shot
- wxTheToolBarTimer->Start(delayMilli, TRUE);
+ wxTheToolBarTimer->Start(delayMilli, true);
}
/************************************************************/
// Move the tooltip more or less above the button
int yOffset = 20; // TODO: What should be really?
- y -= yOffset;
+ y = (Position)(y - yOffset);
if (y < yOffset) y = 0;
/************************************************************/