X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ba09d3bb3bfbc9a0c2dfb72e667cb63fd7bce4d6..b836b6ea08c2cc7a22f1d44d88f0ce92ecc8a5a3:/contrib/src/fl/dyntbar.cpp diff --git a/contrib/src/fl/dyntbar.cpp b/contrib/src/fl/dyntbar.cpp index 194271339e..f0f7d0779f 100644 --- a/contrib/src/fl/dyntbar.cpp +++ b/contrib/src/fl/dyntbar.cpp @@ -6,13 +6,9 @@ // Created: ??/10/98 // RCS-ID: $Id$ // Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ - #pragma implementation "dyntbar.h" -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -29,9 +25,9 @@ #include "wx/fl/dyntbar.h" #include "wx/fl/newbmpbtn.h" -IMPLEMENT_DYNAMIC_CLASS(wxDynamicToolBar, wxControl ) +IMPLEMENT_DYNAMIC_CLASS( wxDynamicToolBar, wxObject ) -BEGIN_EVENT_TABLE( wxDynamicToolBar, wxControl ) +BEGIN_EVENT_TABLE( wxDynamicToolBar, wxToolBarBase ) EVT_SIZE ( wxDynamicToolBar::OnSize ) EVT_PAINT( wxDynamicToolBar::OnPaint ) @@ -39,8 +35,13 @@ BEGIN_EVENT_TABLE( wxDynamicToolBar, wxControl ) END_EVENT_TABLE() +/***** Implementation for class wxToolLayoutItem *****/ + +IMPLEMENT_DYNAMIC_CLASS(wxToolLayoutItem, wxObject) + + /***** Implementation for class wxDynToolInfo *****/ - + IMPLEMENT_DYNAMIC_CLASS(wxDynToolInfo, wxToolLayoutItem) /***** Implementation for class wxDynamicToolBar *****/ @@ -53,7 +54,7 @@ wxDynamicToolBar::wxDynamicToolBar() { } -wxDynamicToolBar::wxDynamicToolBar(wxWindow *parent, const wxWindowID id, +wxDynamicToolBar::wxDynamicToolBar(wxWindow *parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, const long style, const int orientation, const int RowsOrColumns, const wxString& name ) @@ -67,27 +68,27 @@ wxDynamicToolBar::wxDynamicToolBar(wxWindow *parent, const wxWindowID id, SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE) ); } -bool wxDynamicToolBar::Create(wxWindow *parent, const wxWindowID id, - const wxPoint& pos, +bool wxDynamicToolBar::Create(wxWindow *parent, const wxWindowID id, + const wxPoint& pos, const wxSize& size, - const long style, - const int orientation, const int RowsOrColumns, + const long style, + const int WXUNUSED(orientation), const int WXUNUSED(RowsOrColumns), const wxString& name) { // cut&pasted from wxtbatsmpl.h if ( ! wxWindow::Create(parent, id, pos, size, style, name) ) - return FALSE; + return false; SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE )); - return TRUE; + return true; } bool wxDynamicToolBar::Realize(void) { // FOR NOW:: nothing - return TRUE; + return true; } wxDynamicToolBar::~wxDynamicToolBar(void) @@ -102,16 +103,16 @@ wxDynamicToolBar::~wxDynamicToolBar(void) } } -void wxDynamicToolBar::AddTool( int toolIndex, - wxWindow* pToolWindow, - const wxSize& size +void wxDynamicToolBar::AddTool( int toolIndex, + wxWindow* pToolWindow, + const wxSize& WXUNUSED(size) ) { wxDynToolInfo* pInfo = new wxDynToolInfo(); pInfo->mpToolWnd = pToolWindow; pInfo->mIndex = toolIndex; - pInfo->mIsSeparator = FALSE; + pInfo->mIsSeparator = false; int x,y; pToolWindow->GetSize( &x, &y ); @@ -123,18 +124,18 @@ void wxDynamicToolBar::AddTool( int toolIndex, mTools.Add( pInfo ); } -void wxDynamicToolBar::AddTool( int toolIndex, +void wxDynamicToolBar::AddTool( int toolIndex, const wxString& imageFileName, - wxBitmapType imageFileType, + wxBitmapType imageFileType, const wxString& labelText, bool alignTextRight, bool isFlat ) { wxNewBitmapButton* pBtn = new wxNewBitmapButton( imageFileName, imageFileType, - labelText, - ( alignTextRight ) - ? NB_ALIGN_TEXT_RIGHT + labelText, + ( alignTextRight ) + ? NB_ALIGN_TEXT_RIGHT : NB_ALIGN_TEXT_BOTTOM, isFlat ); @@ -142,7 +143,7 @@ void wxDynamicToolBar::AddTool( int toolIndex, pBtn->Create( this, toolIndex ); pBtn->Reshape(); - + AddTool( toolIndex, pBtn ); } void wxDynamicToolBar::AddTool( int toolIndex, wxBitmap labelBmp, @@ -152,9 +153,9 @@ void wxDynamicToolBar::AddTool( int toolIndex, wxBitmap labelBmp, wxNewBitmapButton* pBtn = new wxNewBitmapButton( labelBmp, - labelText, - ( alignTextRight ) - ? NB_ALIGN_TEXT_RIGHT + labelText, + ( alignTextRight ) + ? NB_ALIGN_TEXT_RIGHT : NB_ALIGN_TEXT_BOTTOM, isFlat ); @@ -162,17 +163,17 @@ void wxDynamicToolBar::AddTool( int toolIndex, wxBitmap labelBmp, pBtn->Create( this, toolIndex ); pBtn->Reshape(); - + AddTool( toolIndex, pBtn ); } -wxToolBarToolBase* - wxDynamicToolBar::AddTool(const int toolIndex, const wxBitmap& bitmap, - const wxBitmap& pushedBitmap, - const bool toggle, const long xPos, - const long yPos, wxObject *clientData, - const wxString& helpString1, const wxString& helpString2) +wxToolBarToolBase* + wxDynamicToolBar::AddTool(const int toolIndex, const wxBitmap& bitmap, + const wxBitmap& WXUNUSED(pushedBitmap), + const bool WXUNUSED(toggle), const long WXUNUSED(xPos), + const long WXUNUSED(yPos), wxObject *WXUNUSED(clientData), + const wxString& helpString1, const wxString& WXUNUSED(helpString2)) { wxNewBitmapButton* pBmpBtn = new wxNewBitmapButton( bitmap ); @@ -180,6 +181,12 @@ wxToolBarToolBase* pBmpBtn->Reshape(); +#if wxUSE_TOOLTIPS + pBmpBtn->SetToolTip( helpString1 ); +#else + wxUnusedVar( helpString1 ); +#endif // wxUSE_TOOLTIPS + AddTool( toolIndex, pBmpBtn ); return NULL; @@ -203,7 +210,7 @@ void wxDynamicToolBar::RemveTool( int toolIndex ) size_t i; for( i = 0; i != mTools.Count(); ++i ) { - if ( mTools[i]->mIndex == toolIndex ) + if ( mTools[i]->mIndex == toolIndex ) { if ( mTools[i]->mpToolWnd ) { @@ -229,7 +236,7 @@ void wxDynamicToolBar::AddSeparator( wxWindow* pSepartorWnd ) pInfo->mpToolWnd = pSepartorWnd; pInfo->mIndex = -1; - pInfo->mIsSeparator = TRUE; + pInfo->mIsSeparator = true; // Do we draw a separator or is a other object? if ( pSepartorWnd ) @@ -260,12 +267,12 @@ void wxDynamicToolBar::AddSeparator( wxWindow* pSepartorWnd ) mTools.Add( pInfo ); } -void wxDynamicToolBar::OnEraseBackground( wxEraseEvent& event ) +void wxDynamicToolBar::OnEraseBackground( wxEraseEvent& WXUNUSED(event) ) { // FOR NOW:: nothing } -void wxDynamicToolBar::OnSize( wxSizeEvent& event ) +void wxDynamicToolBar::OnSize( wxSizeEvent& WXUNUSED(event) ) { //SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) ); @@ -301,7 +308,7 @@ void wxDynamicToolBar::DrawSeparator( wxDynToolInfo& info, wxDC& dc ) } } -void wxDynamicToolBar::OnPaint( wxPaintEvent& event ) +void wxDynamicToolBar::OnPaint( wxPaintEvent& WXUNUSED(event) ) { // draw separators if any wxPaintDC dc(this); @@ -309,7 +316,7 @@ void wxDynamicToolBar::OnPaint( wxPaintEvent& event ) size_t i; for( i = 0; i != mTools.Count(); ++i ) { - if ( mTools[i]->mIsSeparator ) + if ( mTools[i]->mIsSeparator ) { // check if separator doesn't have it's own window // if so, then draw it using built-in drawing method @@ -324,8 +331,8 @@ void wxDynamicToolBar::OnPaint( wxPaintEvent& event ) void wxDynamicToolBar::SizeToolWindows() { - bool bStateCheckDone = FALSE; - bool bHorzSeparator = FALSE; + bool bStateCheckDone = false; + bool bHorzSeparator = false; int maxWidth = 0; int maxHeight = 0; @@ -334,9 +341,9 @@ void wxDynamicToolBar::SizeToolWindows() { wxDynToolInfo& info = *mTools[i]; - if ( !info.mIsSeparator ) + if ( !info.mIsSeparator ) { - // center real rectangle within the rectangle + // center real rectangle within the rectangle // provided by the layout manager int x = info.mRect.x; @@ -345,36 +352,36 @@ void wxDynamicToolBar::SizeToolWindows() // FOR NOW FOR NOW:: quick & dirty fix if ( info.mpToolWnd->IsKindOf( CLASSINFO( wxChoice ) ) ) { - info.mpToolWnd->SetSize( x, y, - info.mRealSize.x - 3, + info.mpToolWnd->SetSize( x, y, + info.mRealSize.x - 3, info.mRealSize.y); } else { - info.mpToolWnd->SetSize( x, y, - info.mRealSize.x, + info.mpToolWnd->SetSize( x, y, + info.mRealSize.x, info.mRealSize.y ); } } else { - // We performer this code here, so we only execute it when we have + // We performer this code here, so we only execute it when we have // separators and we do it only once (all to do with performance...) if (!bStateCheckDone) { - bStateCheckDone = TRUE; - + bStateCheckDone = true; + size_t j; - wxDynToolInfo *pInfo = NULL; + wxDynToolInfo *pInfo; wxDynToolInfo *pPrevInfo = NULL; int nVertSeparators = 0; for( j = 0; j != mTools.Count(); ++j ) { pInfo = mTools[j]; - + // Count all Vert Separators. - if ( pInfo->mIsSeparator ) + if ( pInfo->mIsSeparator ) nVertSeparators++; // Check if the new row starts with a Separator. @@ -382,8 +389,8 @@ void wxDynamicToolBar::SizeToolWindows() // pPrevInfo->mRect.x >= pInfo->mRect.x && pPrevInfo->mRect.y < pInfo->mRect.y) { - // If the Separator is shown on the next row and it's - // the only object on the row it would mean that the + // If the Separator is shown on the next row and it's + // the only object on the row it would mean that the // Separator should be shown as Horizontal one. if (j+1 != mTools.Count()) { @@ -401,10 +408,10 @@ void wxDynamicToolBar::SizeToolWindows() maxWidth = wxMax(pInfo->mRect.width, maxWidth); maxHeight = wxMax(pInfo->mRect.height, maxHeight); } - + bHorzSeparator = nVertSeparators == 0; } - + // Check if we should draw Horz or Vert... if ( !bHorzSeparator ) { @@ -417,12 +424,12 @@ void wxDynamicToolBar::SizeToolWindows() info.mRect.height = mSepartorSize; } - // Do we need to set a new size to a seperator object? + // Do we need to set a new size to a separator object? if ( info.mpToolWnd ) { info.mpToolWnd->SetSize( info.mRect.x, - info.mRect.y, - info.mRect.width, + info.mRect.y, + info.mRect.width, info.mRect.height); } @@ -443,8 +450,8 @@ bool wxDynamicToolBar::Layout() for( i = 0; i != mTools.Count(); ++i ) { pInfo = mTools[i]; - - if ( pInfo->mIsSeparator ) + + if ( pInfo->mIsSeparator ) { pInfo->mRect.width = mSepartorSize; pInfo->mRect.height = mSepartorSize; @@ -455,7 +462,7 @@ bool wxDynamicToolBar::Layout() GetPreferredDim( wndDim, result ); SizeToolWindows(); - return TRUE; + return true; } void wxDynamicToolBar::GetPreferredDim( const wxSize& givenDim, wxSize& prefDim ) @@ -483,7 +490,7 @@ void wxDynamicToolBar::SetLayout( LayoutManagerBase* pLayout ) Layout(); } -void wxDynamicToolBar::EnableTool(const int toolIndex, const bool enable ) +void wxDynamicToolBar::EnableTool(int toolIndex, bool enable ) { wxDynToolInfo* pInfo = GetToolInfo( toolIndex ); @@ -498,11 +505,11 @@ void wxDynamicToolBar::EnableTool(const int toolIndex, const bool enable ) /***** Implementation for class BagLayout *****/ -void BagLayout::Layout( const wxSize& parentDim, +void BagLayout::Layout( const wxSize& parentDim, wxSize& resultingDim, wxLayoutItemArrayT& items, int horizGap, - int vertGap + int vertGap ) { int maxWidth = 0; @@ -534,7 +541,7 @@ void BagLayout::Layout( const wxSize& parentDim, if ( curX + r.width > parentDim.x ) { - if ( itemsInRow > 0 ) + if ( itemsInRow > 0 ) break; } r.x = curX; @@ -560,39 +567,47 @@ void BagLayout::Layout( const wxSize& parentDim, //////// stuff from 2.1.15 /////////// -wxToolBarToolBase* wxDynamicToolBar::FindToolForPosition( wxCoord x, wxCoord y ) const +wxToolBarToolBase* wxDynamicToolBar::FindToolForPosition( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) const { return NULL; } -bool wxDynamicToolBar::DoInsertTool( size_t pos, wxToolBarToolBase* tool ) +bool wxDynamicToolBar::DoInsertTool( size_t WXUNUSED(pos), wxToolBarToolBase* WXUNUSED(tool) ) { - return TRUE; + return true; } -bool wxDynamicToolBar::DoDeleteTool( size_t pos, wxToolBarToolBase* tool ) +bool wxDynamicToolBar::DoDeleteTool( size_t WXUNUSED(pos), wxToolBarToolBase* WXUNUSED(tool) ) { - return TRUE; + return true; } -void wxDynamicToolBar::DoEnableTool( wxToolBarToolBase* tool, bool enable ) +void wxDynamicToolBar::DoEnableTool( wxToolBarToolBase* WXUNUSED(tool), bool WXUNUSED(enable) ) { } -void wxDynamicToolBar::DoToggleTool( wxToolBarToolBase* tool, bool toggle ) +void wxDynamicToolBar::DoToggleTool( wxToolBarToolBase* WXUNUSED(tool), bool WXUNUSED(toggle) ) { } -void wxDynamicToolBar::DoSetToggle( wxToolBarToolBase* tool, bool toggle ) +void wxDynamicToolBar::DoSetToggle( wxToolBarToolBase* WXUNUSED(tool), bool WXUNUSED(toggle) ) { } -wxToolBarToolBase* wxDynamicToolBar::CreateTool( int id, const wxBitmap& bitmap1, const wxBitmap& bitmap2, bool toggle, wxObject* clientData, const wxString& shortHelpString, const wxString& longHelpString ) +wxToolBarToolBase* wxDynamicToolBar::CreateTool( int WXUNUSED(id), + const wxString& WXUNUSED(label), + const wxBitmap& WXUNUSED(bmpNormal), + const wxBitmap& WXUNUSED(bmpDisabled), + wxItemKind WXUNUSED(kind), + wxObject *WXUNUSED(clientData), + const wxString& WXUNUSED(shortHelp), + const wxString& WXUNUSED(longHelp) + ) { return NULL; } -wxToolBarToolBase* wxDynamicToolBar::CreateTool( wxControl* control ) +wxToolBarToolBase* wxDynamicToolBar::CreateTool( wxControl* WXUNUSED(control) ) { return NULL; }