Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: binaries/data/tools/atlas/toolbar/save.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
|
|
|
71 | 71 | |
72 | 72 | ToolButtonBar::ToolButtonBar(ToolManager& toolManager, wxWindow* parent, SectionLayout* sectionLayout, int baseID, long style) |
73 | 73 | : wxToolBar(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style) |
74 | | , m_ToolManager(toolManager), m_SectionLayout(sectionLayout), m_Id(baseID), m_Size(-1) |
| 74 | , m_ToolManager(toolManager), m_SectionLayout(sectionLayout), m_Id(baseID), m_Size(-1), m_IdAction(baseID) |
75 | 75 | { |
76 | 76 | /* "msw.remap: If 1 (the default), wxToolBar bitmap colours will be remapped |
77 | 77 | to the current theme's values. Set this to 0 to disable this functionality, |
… |
… |
|
79 | 79 | wxSystemOptions::SetOption(wxT("msw.remap"), 0); // (has global effect) |
80 | 80 | } |
81 | 81 | |
| 82 | void ToolButtonBar::AddToolAction(const wxString& shortLabel, const wxString& longLabel, |
| 83 | const wxString& iconPNGFilename, fnAction action) |
| 84 | { |
| 85 | wxFileName iconPath(_T("tools/atlas/toolbar/")); |
| 86 | iconPath.MakeAbsolute(Datafile::GetDataDirectory()); |
| 87 | iconPath.SetFullName(iconPNGFilename); |
| 88 | wxFFileInputStream fstr(iconPath.GetFullPath()); |
| 89 | if (!fstr.Ok()) |
| 90 | { |
| 91 | wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath().c_str()); |
| 92 | return; |
| 93 | } |
| 94 | wxImage img(fstr, wxBITMAP_TYPE_PNG); |
| 95 | if (!img.Ok()) |
| 96 | { |
| 97 | wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath().c_str()); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | if (m_Size == -1) |
| 102 | { |
| 103 | m_Size = img.GetWidth(); |
| 104 | SetToolBitmapSize(wxSize(m_Size, m_Size)); |
| 105 | } |
| 106 | |
| 107 | if (img.GetWidth() != m_Size || img.GetHeight() != m_Size) |
| 108 | img = img.Scale(m_Size, m_Size); |
| 109 | |
| 110 | AddTool(1000 + m_IdAction, wxBitmap(img), shortLabel, longLabel); |
| 111 | m_ButtonsActions[m_IdAction] = ButtonAction(action); |
| 112 | |
| 113 | ++m_IdAction; |
| 114 | } |
82 | 115 | void ToolButtonBar::AddToolButton(const wxString& shortLabel, const wxString& longLabel, |
83 | 116 | const wxString& iconPNGFilename, const wxString& toolName, |
84 | 117 | const wxString& sectionPage) |
… |
… |
|
86 | 119 | wxFileName iconPath (_T("tools/atlas/toolbar/")); |
87 | 120 | iconPath.MakeAbsolute(Datafile::GetDataDirectory()); |
88 | 121 | iconPath.SetFullName(iconPNGFilename); |
89 | | wxFFileInputStream fstr (iconPath.GetFullPath()); |
90 | | if (! fstr.Ok()) |
| 122 | wxFFileInputStream fstr(iconPath.GetFullPath()); |
| 123 | if (!fstr.Ok()) |
91 | 124 | { |
92 | 125 | wxLogError(_("Failed to open toolbar icon file '%s'"), iconPath.GetFullPath().c_str()); |
93 | 126 | return; |
94 | 127 | } |
95 | | wxImage img (fstr, wxBITMAP_TYPE_PNG); |
96 | | if (! img.Ok()) |
| 128 | wxImage img(fstr, wxBITMAP_TYPE_PNG); |
| 129 | if (!img.Ok()) |
97 | 130 | { |
98 | 131 | wxLogError(_("Failed to load toolbar icon image '%s'"), iconPath.GetFullPath().c_str()); |
99 | 132 | return; |
… |
… |
|
118 | 151 | |
119 | 152 | void ToolButtonBar::OnTool(wxCommandEvent& evt) |
120 | 153 | { |
121 | | std::map<int, Button>::iterator it = m_Buttons.find(evt.GetId()); |
122 | | wxCHECK_RET(it != m_Buttons.end(), _T("Invalid toolbar button")); |
123 | | m_ToolManager.SetCurrentTool(it->second.name); |
124 | | if (! it->second.sectionPage.IsEmpty()) |
125 | | m_SectionLayout->SelectPage(it->second.sectionPage); |
126 | | } |
| 154 | int action = evt.GetId(); |
| 155 | if(action >= 1000) |
| 156 | { |
| 157 | //is an action |
| 158 | action-=1000; |
| 159 | |
| 160 | std::map<int, ButtonAction>::iterator it = m_ButtonsActions.find(action); |
| 161 | wxCHECK_RET(it != m_ButtonsActions.end(), _T("Invalid toolbar button")); |
| 162 | it->second.m_function(); |
| 163 | } |
| 164 | else |
| 165 | { |
| 166 | std::map<int, Button>::iterator it = m_Buttons.find(action); |
| 167 | wxCHECK_RET(it != m_Buttons.end(), _T("Invalid toolbar button")); |
| 168 | m_ToolManager.SetCurrentTool(it->second.name); |
| 169 | if (! it->second.sectionPage.IsEmpty()) |
| 170 | m_SectionLayout->SelectPage(it->second.sectionPage); |
| 171 | } |
| 172 | } |
| 173 | No newline at end of file |