2
* This file is part of wxSmithAui plugin for Code::Blocks Studio
3
* Copyright (C) 2008-2009 César Fernández Domínguez
5
* wxSmithAui is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* wxSmithAui is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with wxSmithAui. If not, see <http://www.gnu.org/licenses/>.
19
#include "wxsAuiToolBarItemBase.h"
21
#if wxCHECK_VERSION(2,8,9)
23
#include "wxSmithAuiToolBar.h"
24
#include "../wxAuiManager/wxsAuiManager.h"
25
#include <wxwidgets/wxsparent.h>
26
#include <wx/window.h>
30
class wxSmithWindow : public wxWindow
33
wxSmithWindow(wxWindow *parent,
34
const wxPoint& pos = wxDefaultPosition,
35
const wxSize& size = wxDefaultSize)
36
: wxWindow(parent,-1,pos,size)
41
virtual bool IsShown() const { return true; }
45
wxObject* wxsAuiToolBarItemBase::OnBuildPreview(wxWindow* Parent,long Flags)
47
wxSmithAuiToolBar* ParentToolBar = wxDynamicCast(Parent,wxSmithAuiToolBar);
48
if ( !ParentToolBar ) return NULL;
50
wxRect ItemRect = ParentToolBar->GetToolRect(m_ItemId);
51
wxPoint ItemPosition = ItemRect.GetPosition();
52
wxSize ItemSize = ItemRect.GetSize();
55
if ( GetClassName() == _T("wxAuiToolBarSpacer") )
57
int Margin = Parent->ClientToScreen(ItemPosition).y - Parent->GetParent()->ClientToScreen(ParentToolBar->GetPosition()).y;
58
ItemSize.y = ParentToolBar->GetClientSize().y - 2*Margin;
60
if ( m_HasGripper == wxLEFT ) ItemPosition.x += m_GripperSize;
61
if ( m_HasGripper == wxTOP ) ItemPosition.y += m_GripperSize;
63
return new wxSmithWindow(Parent,ItemPosition,ItemSize);
66
bool wxsAuiToolBarItemBase::OnCanAddToParent(wxsParent* Parent,bool ShowMessage)
68
if ( Parent->GetClassName() != _T("wxAuiToolBar") )
72
wxMessageBox(_("wxAuiToolBarItems can only be added to an wxAuiToolBar."));
80
#endif // wxCHECK_VERSION(2,8,9)