wxMaxima
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 "precomp.h"
30 #include <wx/wx.h>
31 #include <wx/aui/aui.h>
32 #include <wx/choice.h>
33 #include "AnimationCell.h"
34 #include "GroupCell.h"
35 
36 #ifndef _WXMAXIMA_TOOLBAR_H
37 #define _WXMAXIMA_TOOLBAR_H
38 
39 class ToolBar : public wxAuiToolBar
40 {
41 public:
42  explicit ToolBar(wxWindow *parent);
46  {
50  };
51 
52  enum popupitems
53  {
54  copy_paste,
55  open_save,
56  print,
57  options,
58  shownew,
59  search,
60  help,
61  selectAll
62  };
63 
64  wxBitmap GetBitmap(wxString name,
65  unsigned char *data, size_t len, wxSize siz = wxSize(-1,-1));
66 
67  virtual ~ToolBar();
68 
71  {
72  if (!m_needsInformation)
73  {
74  SetToolBitmap(tb_follow, m_needsInformationIcon);
75  m_needsInformation = true;
76  }
77  }
78 
81  {
82  if (m_needsInformation)
83  {
84  SetToolBitmap(tb_follow, m_followIcon);
85  m_needsInformation = false;
86  }
87  }
88 
89  void AnimationButtonState(AnimationStartStopState state);
90 
93  enum Event
94  {
95  plot_slider_id = 5500,
96  tb_interrupt,
97  tb_follow,
98  tb_eval,
99  tb_eval_all,
100  tb_evaltillhere,
101  tb_evaluate_rest,
102  tb_animation_startStop,
103  tb_animation_start,
104  tb_animation_stop,
105  tb_hideCode,
106  tb_changeStyle,
107  menu_restart_id
108  };
109 
111  wxSlider *m_plotSlider;
112 
113  wxBitmap m_followIcon;
114  wxBitmap m_needsInformationIcon;
115  wxBitmap m_PlayButton;
116  wxBitmap m_StopButton;
117 
118  void CanCopy(bool value)
119  {
120  if (value != m_canCopy_old)
121  {
122  EnableTool(wxID_COPY, value);
123  m_canCopy_old = value;
124  }
125  }
126 
127  void CanCut(bool value)
128  {
129  if (value != m_canCut_old)
130  {
131  EnableTool(wxID_CUT, value);
132  m_canCut_old = value;
133  }
134  }
135 
136  void CanSave(bool value)
137  {
138  if (value != m_canSave_old)
139  {
140  EnableTool(wxID_SAVE, value);
141  m_canSave_old = value;
142  }
143  }
144 
145  void CanPrint(bool value)
146  {
147  if (value != m_canPrint_old)
148  {
149  EnableTool(wxID_PRINT, value);
150  m_canPrint_old = value;
151  }
152  }
153 
154  void CanEvalTillHere(bool value)
155  {
156  if (value != m_canEvalTillHere_old)
157  {
158  EnableTool(tb_evaltillhere, value);
159  EnableTool(tb_evaluate_rest, value);
160  m_canEvalTillHere_old = value;
161  }
162  }
163 
164  void CanEvalThisCell(bool value)
165  {
166  if (value != m_canEvalThisCell_old)
167  {
168  EnableTool(tb_eval, value);
169  m_canEvalThisCell_old = value;
170  }
171  }
172 
173  void WorksheetEmpty(bool value)
174  {
175  if (value != m_worksheetEmpty_old)
176  {
177  EnableTool(tb_eval_all, !value);
178  m_worksheetEmpty_old = value;
179  }
180  }
181 
183  void UpdateSlider(AnimationCell *cell);
184 
185  int GetIdealHeight(){
186  return m_needsInformationIcon.GetSize().y;
187  }
188 
190  void AddTools();
191 
195  void SetCellStyle(GroupType style);
197  void UnsetCellStyle(){SetCellStyle(GC_TYPE_INVALID);}
199  void SetDefaultCellStyle(GroupType style) { m_defaultCellStyle = style; }
201  void SetDefaultCellStyle();
203  void UpdateBitmaps();
204 
205  wxBitmap GetEvalAllBitmap(wxSize siz = wxSize(-1, -1));
206  wxBitmap GetEvalBitmap(wxSize siz = wxSize(-1, -1));
207  wxBitmap GetNewBitmap(wxSize siz = wxSize(-1, -1));
208  wxBitmap GetOpenBitmap(wxSize siz = wxSize(-1, -1));
209  wxBitmap GetSaveBitmap(wxSize siz = wxSize(-1, -1));
210  wxBitmap GetPrintBitmap(wxSize siz = wxSize(-1, -1));
211  wxBitmap GetPreferencesBitmap(wxSize siz = wxSize(-1, -1));
212  wxBitmap GetCutBitmap(wxSize siz = wxSize(-1, -1));
213  wxBitmap GetCopyBitmap(wxSize siz = wxSize(-1, -1));
214  wxBitmap GetPasteBitmap(wxSize siz = wxSize(-1, -1));
215  wxBitmap GetSelectAllBitmap(wxSize siz = wxSize(-1, -1));
216  wxBitmap GetFindBitmap(wxSize siz = wxSize(-1, -1));
217  wxBitmap GetRestartBitmap(wxSize siz = wxSize(-1, -1));
218  wxBitmap GetInterruptBitmap(wxSize siz = wxSize(-1, -1));
219  wxBitmap GetEvalTillHereBitmap(wxSize siz = wxSize(-1, -1));
220  wxBitmap GetHelpBitmap(wxSize siz = wxSize(-1, -1));
221  wxBitmap GetEvalRestBitmap(wxSize siz = wxSize(-1, -1));
222  wxBitmap GetHideCodeBitmap(wxSize siz = wxSize(-1, -1));
223 
224  bool ShowCopyPaste(){bool show = true;wxConfig::Get()->Read("Toolbar/showCopyPaste",&show);
225  return show;}
226  void ShowCopyPaste(bool show){wxConfig::Get()->Write("Toolbar/showCopyPaste",show);}
227 
228  bool ShowOpenSave(){bool show = true;wxConfig::Get()->Read("Toolbar/showOpenSave",&show);
229  return show;}
230  void ShowOpenSave(bool show){wxConfig::Get()->Write("Toolbar/showOpenSave",show);}
231 
232  bool ShowNew(){bool show = true;wxConfig::Get()->Read("Toolbar/showNew",&show);
233  return show;}
234  void ShowNew(bool show){wxConfig::Get()->Write("Toolbar/showNew",show);}
235 
236  bool ShowSearch(){bool show = true;wxConfig::Get()->Read("Toolbar/showSearch",&show);
237  return show;}
238  void ShowSearch(bool show){wxConfig::Get()->Write("Toolbar/showSearch",show);}
239 
240  bool ShowHelp(){bool show = true;wxConfig::Get()->Read("Toolbar/showHelp",&show);
241  return show;}
242  void ShowHelp(bool show){wxConfig::Get()->Write("Toolbar/showHelp",show);}
243 
244  bool ShowPrint(){bool show = true;wxConfig::Get()->Read("Toolbar/showPrint",&show);
245  return show;}
246  void ShowPrint(bool show){wxConfig::Get()->Write("Toolbar/showPrint",show);}
247 
248  bool ShowOptions(){bool show = true;wxConfig::Get()->Read("Toolbar/showOptions",&show);
249  return show;}
250  void ShowOptions(bool show){wxConfig::Get()->Write("Toolbar/showOptions",show);}
251 
252  bool ShowSelectAll(){bool show = true;wxConfig::Get()->Read("Toolbar/showSelectAll",&show);
253  return show;}
254  void ShowSelectAll(bool show){wxConfig::Get()->Write("Toolbar/showSelectAll",show);}
255 
256 protected:
257  void OnSize(wxSizeEvent &event);
258  void OnMouseRightDown(wxMouseEvent &event);
259  void OnMenu(wxMenuEvent &event);
260 private:
262  wxSize m_ppi;
264  GroupType m_defaultCellStyle;
266  wxChoice *m_textStyle;
268  int m_animationDisplayedIndex;
270  int m_animationMaxIndex;
271  bool m_canCopy_old;
272  bool m_canCut_old;
273  bool m_canSave_old;
274  bool m_canPrint_old;
275  bool m_canEvalTillHere_old;
276  bool m_canEvalThisCell_old;
277  std::unique_ptr<struct NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
278  bool m_worksheetEmpty_old;
279  AnimationStartStopState m_AnimationStartStopState;
281  bool m_needsInformation;
282 };
283 
284 #endif
ToolBar
Definition: ToolBar.h:39
GroupCell.h
ToolBar::ShowUserInputBitmap
void ShowUserInputBitmap()
Show that user input is needed for maxima to continue.
Definition: ToolBar.h:70
ToolBar::SetDefaultCellStyle
void SetDefaultCellStyle()
The current style is the new style for new cells.
Definition: ToolBar.cpp:462
ToolBar::SetCellStyle
void SetCellStyle(GroupType style)
Set the cell style to show for the current cell.
Definition: ToolBar.cpp:522
ToolBar::SetDefaultCellStyle
void SetDefaultCellStyle(GroupType style)
Set the default cell style for new cells.
Definition: ToolBar.h:199
ToolBar::ShowFollowBitmap
void ShowFollowBitmap()
Stop showing that user input is needed for maxima to continue.
Definition: ToolBar.h:80
GroupType
GroupType
All types a GroupCell can be of.
Definition: GroupCell.h:38
ToolBar::AddTools
void AddTools()
Remove all ools and then add all tools that are requested/fit in the toolbar/...
Definition: ToolBar.cpp:159
ToolBar::Event
Event
Definition: ToolBar.h:93
AnimationCell
Definition: AnimationCell.h:45
ToolBar::Running
@ Running
The animation is running.
Definition: ToolBar.h:47
ToolBar::UpdateBitmaps
void UpdateBitmaps()
Update the bitmaps on ppi changes.
Definition: ToolBar.cpp:322
ToolBar::m_plotSlider
wxSlider * m_plotSlider
The slider for animations.
Definition: ToolBar.h:111
ToolBar::Inactive
@ Inactive
No animation is currently running.
Definition: ToolBar.h:49
ToolBar::AnimationStartStopState
AnimationStartStopState
Definition: ToolBar.h:45
ToolBar::Stopped
@ Stopped
The animation is stopped.
Definition: ToolBar.h:48
ToolBar::UnsetCellStyle
void UnsetCellStyle()
Called if there is no cell to show the style for.
Definition: ToolBar.h:197
ToolBar::UpdateSlider
void UpdateSlider(AnimationCell *cell)
Updates the slider to match the Slide Show cell.
Definition: ToolBar.cpp:109
AnimationCell.h
ToolBar::GetCellType
GroupType GetCellType()
Get the cell style for new cells.
Definition: ToolBar.cpp:495