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 GetEvalAllBitmap(wxSize siz);
226 wxBitmap GetEvalBitmap(wxSize siz);
227 wxBitmap GetPreferencesBitmap(wxSize siz);
228 wxBitmap GetSelectAllBitmap(wxSize siz);
229 wxBitmap GetRestartBitmap(wxSize siz);
230 wxBitmap GetInterruptBitmap(wxSize siz);
231 wxBitmap GetEvalTillHereBitmap(wxSize siz);
232 wxBitmap GetEvalRestBitmap(wxSize siz);
233 wxBitmap GetHideCodeBitmap(wxSize siz);
234
235 wxSize GetOptimalBitmapSize();
236 wxSize GetPPI();
237 bool ShowUndoRedo(){bool show = false; wxConfig::Get()->Read("Toolbar/showUndoRedo", &show);
238 return show;}
239 void ShowUndoRedo(bool show){wxConfig::Get()->Write("Toolbar/showUndoRedo", show);}
240
241 bool ShowCopyPaste(){bool show = true; wxConfig::Get()->Read("Toolbar/showCopyPaste", &show);
242 return show;}
243 void ShowCopyPaste(bool show){wxConfig::Get()->Write("Toolbar/showCopyPaste", show);}
244
245 bool ShowOpenSave(){bool show = true; wxConfig::Get()->Read("Toolbar/showOpenSave", &show);
246 return show;}
247 void ShowOpenSave(bool show){wxConfig::Get()->Write("Toolbar/showOpenSave", show);}
248
249 bool ShowNew(){bool show = true; wxConfig::Get()->Read("Toolbar/showNew", &show);
250 return show;}
251 void ShowNew(bool show){wxConfig::Get()->Write("Toolbar/showNew", show);}
252
253 bool ShowSearch(){bool show = true; wxConfig::Get()->Read("Toolbar/showSearch", &show);
254 return show;}
255 void ShowSearch(bool show){wxConfig::Get()->Write("Toolbar/showSearch", show);}
256
257 bool ShowHelp(){bool show = true; wxConfig::Get()->Read("Toolbar/showHelp", &show);
258 return show;}
259 void ShowHelp(bool show){wxConfig::Get()->Write("Toolbar/showHelp", show);}
260
261 bool ShowPrint(){bool show = true; wxConfig::Get()->Read("Toolbar/showPrint", &show);
262 return show;}
263 void ShowPrint(bool show){wxConfig::Get()->Write("Toolbar/showPrint", show);}
264
265 bool ShowOptions(){bool show = true; wxConfig::Get()->Read("Toolbar/showOptions", &show);
266 return show;}
267 void ShowOptions(bool show){wxConfig::Get()->Write("Toolbar/showOptions", show);}
268
269 bool ShowSelectAll(){bool show = true; wxConfig::Get()->Read("Toolbar/showSelectAll", &show);
270 return show;}
271 void ShowSelectAll(bool show){wxConfig::Get()->Write("Toolbar/showSelectAll", show);}
272
273protected:
274 void OnSize(wxSizeEvent &event);
275 void OnMouseRightDown(wxMouseEvent &event);
276 void OnMenu(wxMenuEvent &event);
277private:
279 wxSize m_ppi;
281 GroupType m_defaultCellStyle = GC_TYPE_CODE;
283 wxChoice *m_textStyle = NULL;
285 std::size_t m_animationDisplayedIndex = 0;
287 std::size_t m_animationMaxIndex;
288 bool m_canRedo_old = true;
289 bool m_canUndo_old = true;
290 bool m_canCopy_old = true;
291 bool m_canCut_old = true;
292 bool m_canSave_old = true;
293 bool m_canPrint_old = true;
294 bool m_canEvalTillHere_old = true;
295 bool m_canEvalThisCell_old = true;
296 std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
297 bool m_worksheetEmpty_old = false;
298 AnimationStartStopState m_AnimationStartStopState = Inactive;
300 bool m_needsInformation = false;
301};
302
303#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:155
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:460
wxSlider * m_plotSlider
The slider for animations.
Definition: ToolBar.h:110
void UpdateBitmaps()
Update the bitmaps on ppi changes.
Definition: ToolBar.cpp:334
void UpdateSlider(AnimationCell *cell)
Updates the slider to match the Slide Show cell.
Definition: ToolBar.cpp:109
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:435
void SetDefaultCellStyle()
The current style is the new style for new cells.
Definition: ToolBar.cpp:404