wxMaxima
Loading...
Searching...
No Matches
ToolBar.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2008-2009 Ziga Lenarcic <zigalenarcic@users.sourceforge.net>
5// (C) 2012-2013 Doug Ilijev <doug.ilijev@gmail.com>
6// (C) 2015-2016 Gunter Königsmann <wxMaxima@physikbuch.de>
7//
8// This program is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 2 of the License, or
11// (at your option) any later version.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18//
19// You should have received a copy of the GNU General Public License
20// along with this program; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// SPDX-License-Identifier: GPL-2.0+
24
29#include <memory>
30#include <wx/wx.h>
31#include <wx/aui/aui.h>
32#include <wx/choice.h>
33#include "precomp.h"
34#include "cells/AnimationCell.h"
35#include "cells/GroupCell.h"
36
37#ifndef _WXMAXIMA_TOOLBAR_H
38#define _WXMAXIMA_TOOLBAR_H
39
40class ToolBar : public wxAuiToolBar
41{
42public:
43 explicit ToolBar(wxWindow *parent);
47 {
51 };
52
53 enum popupitems
54 {
55 undo_redo,
56 copy_paste,
57 open_save,
58 print,
59 options,
60 shownew,
61 search,
62 help,
63 selectAll
64 };
65
66 virtual ~ToolBar();
67
70 {
71 if (!m_needsInformation)
72 {
73 SetToolBitmap(tb_follow, m_needsInformationIcon);
74 m_needsInformation = true;
75 }
76 }
77
80 {
81 if (m_needsInformation)
82 {
83 SetToolBitmap(tb_follow, m_followIcon);
84 m_needsInformation = false;
85 }
86 }
87
88 void AnimationButtonState(AnimationStartStopState state);
89
92 enum Event
93 {
94 plot_slider_id = 5500,
95 tb_interrupt,
96 tb_follow,
97 tb_eval,
98 tb_eval_all,
99 tb_evaltillhere,
100 tb_evaluate_rest,
101 tb_animation_startStop,
102 tb_animation_start,
103 tb_animation_stop,
104 tb_hideCode,
105 tb_changeStyle,
106 menu_restart_id
107 };
108
110 wxSlider *m_plotSlider = NULL;
111
112 wxBitmap m_undoIcon;
113 wxBitmap m_redoIcon;
114 wxBitmap m_followIcon;
115 wxBitmap m_needsInformationIcon;
116 wxBitmap m_PlayButton;
117 wxBitmap m_StopButton;
118
119 void CanUndo(bool value)
120 {
121 if (value != m_canUndo_old)
122 {
123 EnableTool(wxID_UNDO, value);
124 m_canUndo_old = value;
125 }
126 }
127
128 void CanRedo(bool value)
129 {
130 if (value != m_canRedo_old)
131 {
132 EnableTool(wxID_UNDO, value);
133 m_canRedo_old = value;
134 }
135 }
136
137 void CanCopy(bool value)
138 {
139 if (value != m_canCopy_old)
140 {
141 EnableTool(wxID_COPY, value);
142 m_canCopy_old = value;
143 }
144 }
145
146 void CanCut(bool value)
147 {
148 if (value != m_canCut_old)
149 {
150 EnableTool(wxID_CUT, value);
151 m_canCut_old = value;
152 }
153 }
154
155 void CanSave(bool value)
156 {
157 if (value != m_canSave_old)
158 {
159 EnableTool(wxID_SAVE, value);
160 m_canSave_old = value;
161 }
162 }
163
164 void CanPrint(bool value)
165 {
166 if (value != m_canPrint_old)
167 {
168 EnableTool(wxID_PRINT, value);
169 m_canPrint_old = value;
170 }
171 }
172
173 void CanEvalTillHere(bool value)
174 {
175 if (value != m_canEvalTillHere_old)
176 {
177 EnableTool(tb_evaltillhere, value);
178 EnableTool(tb_evaluate_rest, value);
179 m_canEvalTillHere_old = value;
180 }
181 }
182
183 void CanEvalThisCell(bool value)
184 {
185 if (value != m_canEvalThisCell_old)
186 {
187 EnableTool(tb_eval, value);
188 m_canEvalThisCell_old = value;
189 }
190 }
191
192 void WorksheetEmpty(bool value)
193 {
194 if (value != m_worksheetEmpty_old)
195 {
196 EnableTool(tb_eval_all, !value);
197 m_worksheetEmpty_old = value;
198 }
199 }
200
202 void UpdateSlider(AnimationCell *cell);
203
204 int GetIdealHeight(){
205 return m_needsInformationIcon.GetSize().y;
206 }
207
209 void AddTools();
210
214 void SetCellStyle(GroupType style);
216 void UnsetCellStyle(){SetCellStyle(GC_TYPE_INVALID);}
218 void SetDefaultCellStyle(GroupType style) { m_defaultCellStyle = style; }
220 void SetDefaultCellStyle();
222 void UpdateBitmaps();
223
224
225 wxBitmap GetCopyBitmap(wxSize siz);
226 wxBitmap GetPasteBitmap(wxSize siz);
227 wxBitmap GetEvalAllBitmap(wxSize siz);
228 wxBitmap GetEvalBitmap(wxSize siz);
229 wxBitmap GetNewBitmap(wxSize siz);
230 wxBitmap GetOpenBitmap(wxSize siz);
231 wxBitmap GetSaveBitmap(wxSize siz);
232 wxBitmap GetPrintBitmap(wxSize siz);
233 wxBitmap GetPreferencesBitmap(wxSize siz);
234 wxBitmap GetCutBitmap(wxSize siz);
235 wxBitmap GetUndoBitmap(wxSize siz);
236 wxBitmap GetRedoBitmap(wxSize siz);
237 wxBitmap GetSelectAllBitmap(wxSize siz);
238 wxBitmap GetFindBitmap(wxSize siz);
239 wxBitmap GetRestartBitmap(wxSize siz);
240 wxBitmap GetInterruptBitmap(wxSize siz);
241 wxBitmap GetEvalTillHereBitmap(wxSize siz);
242 wxBitmap GetHelpBitmap(wxSize siz);
243 wxBitmap GetEvalRestBitmap(wxSize siz);
244 wxBitmap GetHideCodeBitmap(wxSize siz);
245
246 wxSize GetOptimalBitmapSize();
247 wxSize GetPPI();
248 bool ShowUndoRedo(){bool show = false; wxConfig::Get()->Read("Toolbar/showUndoRedo", &show);
249 return show;}
250 void ShowUndoRedo(bool show){wxConfig::Get()->Write("Toolbar/showUndoRedo", show);}
251
252 bool ShowCopyPaste(){bool show = true; wxConfig::Get()->Read("Toolbar/showCopyPaste", &show);
253 return show;}
254 void ShowCopyPaste(bool show){wxConfig::Get()->Write("Toolbar/showCopyPaste", show);}
255
256 bool ShowOpenSave(){bool show = true; wxConfig::Get()->Read("Toolbar/showOpenSave", &show);
257 return show;}
258 void ShowOpenSave(bool show){wxConfig::Get()->Write("Toolbar/showOpenSave", show);}
259
260 bool ShowNew(){bool show = true; wxConfig::Get()->Read("Toolbar/showNew", &show);
261 return show;}
262 void ShowNew(bool show){wxConfig::Get()->Write("Toolbar/showNew", show);}
263
264 bool ShowSearch(){bool show = true; wxConfig::Get()->Read("Toolbar/showSearch", &show);
265 return show;}
266 void ShowSearch(bool show){wxConfig::Get()->Write("Toolbar/showSearch", show);}
267
268 bool ShowHelp(){bool show = true; wxConfig::Get()->Read("Toolbar/showHelp", &show);
269 return show;}
270 void ShowHelp(bool show){wxConfig::Get()->Write("Toolbar/showHelp", show);}
271
272 bool ShowPrint(){bool show = true; wxConfig::Get()->Read("Toolbar/showPrint", &show);
273 return show;}
274 void ShowPrint(bool show){wxConfig::Get()->Write("Toolbar/showPrint", show);}
275
276 bool ShowOptions(){bool show = true; wxConfig::Get()->Read("Toolbar/showOptions", &show);
277 return show;}
278 void ShowOptions(bool show){wxConfig::Get()->Write("Toolbar/showOptions", show);}
279
280 bool ShowSelectAll(){bool show = true; wxConfig::Get()->Read("Toolbar/showSelectAll", &show);
281 return show;}
282 void ShowSelectAll(bool show){wxConfig::Get()->Write("Toolbar/showSelectAll", show);}
283
284protected:
285 void OnSize(wxSizeEvent &event);
286 void OnMouseRightDown(wxMouseEvent &event);
287 void OnMenu(wxMenuEvent &event);
288private:
290 wxSize m_ppi;
292 GroupType m_defaultCellStyle = GC_TYPE_CODE;
294 wxChoice *m_textStyle = NULL;
296 std::size_t m_animationDisplayedIndex = 0;
298 std::size_t m_animationMaxIndex;
299 bool m_canRedo_old = true;
300 bool m_canUndo_old = true;
301 bool m_canCopy_old = true;
302 bool m_canCut_old = true;
303 bool m_canSave_old = true;
304 bool m_canPrint_old = true;
305 bool m_canEvalTillHere_old = true;
306 bool m_canEvalThisCell_old = true;
307 std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
308 bool m_worksheetEmpty_old = false;
309 AnimationStartStopState m_AnimationStartStopState = Inactive;
311 bool m_needsInformation = false;
312};
313
314#endif
This file declares the class AnimationCell.
This file defines the class GroupCell that bundles input and output in the worksheet.
GroupType
All types a GroupCell can be of.
Definition: GroupCell.h:42
Definition: AnimationCell.h:46
Definition: ToolBar.h:41
void AddTools()
Remove all ools and then add all tools that are requested/fit in the toolbar/...
Definition: ToolBar.cpp:169
void ShowUserInputBitmap()
Show that user input is needed for maxima to continue.
Definition: ToolBar.h:69
void SetCellStyle(GroupType style)
Set the cell style to show for the current cell.
Definition: ToolBar.cpp:523
wxSlider * m_plotSlider
The slider for animations.
Definition: ToolBar.h:110
void UpdateBitmaps()
Update the bitmaps on ppi changes.
Definition: ToolBar.cpp:352
void UpdateSlider(AnimationCell *cell)
Updates the slider to match the Slide Show cell.
Definition: ToolBar.cpp:123
AnimationStartStopState
All states the "start/stop animation" toolbar button can be in.
Definition: ToolBar.h:47
@ Stopped
The animation is stopped.
Definition: ToolBar.h:49
@ Inactive
No animation is currently running.
Definition: ToolBar.h:50
@ Running
The animation is running.
Definition: ToolBar.h:48
void SetDefaultCellStyle(GroupType style)
Set the default cell style for new cells.
Definition: ToolBar.h:218
void ShowFollowBitmap()
Stop showing that user input is needed for maxima to continue.
Definition: ToolBar.h:79
void UnsetCellStyle()
Called if there is no cell to show the style for.
Definition: ToolBar.h:216
Event
A list of all events the Toolbar can receive.
Definition: ToolBar.h:93
GroupType GetCellType()
Get the cell style for new cells.
Definition: ToolBar.cpp:498
void SetDefaultCellStyle()
The current style is the new style for new cells.
Definition: ToolBar.cpp:467