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 // 5 // This program 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 2 of the License, or 8 // (at your option) any later version. 9 // 10 // This program 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. 14 // 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 // 20 // SPDX-License-Identifier: GPL-2.0+ 21 22 #ifndef CONFIGURATION_H 23 #define CONFIGURATION_H 24 25 #include <wx/wx.h> 26 #include <wx/config.h> 27 #include <wx/display.h> 28 #include <wx/fontenum.h> 29 #include "LoggingMessageDialog.h" 30 #include "TextStyle.h" 31 32 #define MC_LINE_SKIP Scale_Px(2) 33 #define MC_TEXT_PADDING Scale_Px(1) 34 35 #define PAREN_OPEN_TOP_UNICODE "\u239b" 36 #define PAREN_OPEN_EXTEND_UNICODE "\u239c" 37 #define PAREN_OPEN_BOTTOM_UNICODE "\u239d" 38 #define PAREN_CLOSE_TOP_UNICODE "\u239e" 39 #define PAREN_CLOSE_EXTEND_UNICODE "\u239f" 40 #define PAREN_CLOSE_BOTTOM_UNICODE "\u23a0" 41 #define SUM_SIGN "\u2211" 42 #define PROD_SIGN "\u220F" 43 #define SUM_DEC 2 44 45 //! The width of the horizontally-drawn cursor 46 #define MC_HCARET_WIDTH 25 47 48 #define MC_EXP_INDENT 2 49 #define MC_MIN_SIZE 6 50 #define MC_MAX_SIZE 48 51 52 #define CMEX10 "jsMath-cmex10" 53 #define CMSY10 "jsMath-cmsy10" 54 #define CMR10 "jsMath-cmr10" 55 #define CMMI10 "jsMath-cmmi10" 56 #define CMTI10 "jsMath-cmti10" 57 58 #define LIBERTINE1 "LinLibertine_DRah.ttf" 59 #define LIBERTINE2 "LinLibertine_I.ttf" 60 #define LIBERTINE3 "LinLibertine_Mah.ttf" 61 #define LIBERTINE4 "LinLibertine_Rah.ttf" 62 #define LIBERTINE5 "LinLibertine_RBah.ttf" 63 #define LIBERTINE6 "LinLibertine_RBIah.ttf" 64 #define LIBERTINE7 "LinLibertine_RIah.ttf" 65 #define LIBERTINE8 "LinLibertine_RZah.ttf" 66 #define LIBERTINE9 "LinLibertine_RZIah.ttf" 67 68 /*! The configuration storage for the current worksheet. 69 70 Caching the information here means we don't need to search for the configuration 71 value's name every time we need the information: Reading configuration values from 72 the system's configuration storage can be quite time consuming, especially on a 73 MSW with a long registry. 74 75 In order to make all cells temporary listen to a different set of configuration 76 than the default one all that has to be done is to create a new configuration 77 object that contains hold the right settings for printing/export as bitmap or 78 similar: Configuration::Get() will always return the last Configuration that was 79 created and therefore as long as the new configuration object exist will return 80 a pointer to this object if configuration is needed. 81 */ 82 class Configuration 83 { 84 public: 85 //! The export formats we support for HTML equations 86 enum htmlExportFormat 87 { 88 mathJaX_TeX = 0, 89 bitmap = 1, 90 mathML_mathJaX = 2, 91 svg = 3 92 }; 93 94 enum showLabels 95 { 96 labels_automatic = 0, 97 labels_prefer_user = 1, 98 labels_useronly = 2, 99 labels_none = 3 100 }; 101 102 enum drawMode 103 { 104 ascii, //!< Use ascii characters only 105 assembled_unicode_fallbackfont, //!< Unicode, fallbackfont 1 106 assembled_unicode, //!< Unicode, current font 107 assembled_unicode_fallbackfont2, //!< Unicode, fallbackfont 2 108 handdrawn, //!< A parenthesis sign that was created using draw commands 109 unknown 110 }; 111 112 WX_DECLARE_STRING_HASH_MAP(wxString, StringHash); 113 //! A list of all symbols that can be entered using Esc-Codes 114 StringHash m_escCodes; 115 116 //! Set maxima's working directory SetWorkingDirectory(wxString dir)117 void SetWorkingDirectory(wxString dir) 118 { m_workingdir = dir; } 119 GetWorkingDirectory()120 wxString GetWorkingDirectory() const 121 { return m_workingdir; } 122 123 void ReadConfig(); 124 125 /*! The constructor 126 127 \param dc The drawing context that is to be used for drawing objects 128 */ 129 explicit Configuration(wxDC *dc = NULL); 130 131 //! Set the drawing context that is currently active SetContext(wxDC & dc)132 void SetContext(wxDC &dc) 133 { 134 m_dc = &dc; 135 m_antialiassingDC = NULL; 136 } 137 138 void SetBackgroundBrush(wxBrush brush); GetBackgroundBrush()139 wxBrush GetBackgroundBrush() const {return m_BackgroundBrush;} GetTooltipBrush()140 wxBrush GetTooltipBrush() const {return m_tooltipBrush;} SetAntialiassingDC(wxDC & antialiassingDC)141 void SetAntialiassingDC(wxDC &antialiassingDC) 142 {m_antialiassingDC = &antialiassingDC;} 143 UnsetAntialiassingDC()144 void UnsetAntialiassingDC() 145 {m_antialiassingDC = NULL;} 146 147 ~Configuration(); 148 149 static wxString m_maximaLocation_override; 150 static wxString m_configfileLocation_override; 151 GetMinZoomFactor()152 static double GetMinZoomFactor() 153 { return 0.1; } 154 GetMaxZoomFactor()155 static double GetMaxZoomFactor() 156 { return 32.0; } 157 158 /*! Extra space to leave between two equations in output cells. 159 160 Extra space between equations is useful if we don't display labels that show 161 which line begins a new equation and which line merely continues a multi-line 162 equation. 163 */ GetInterEquationSkip()164 double GetInterEquationSkip() const 165 { 166 if (ShowAutomaticLabels()) 167 return 0; 168 else 169 return GetZoomFactor() * m_mathFontSize / 2; 170 } 171 GetCellBracketWidth()172 long GetCellBracketWidth() const 173 { 174 return (int) (GetZoomFactor() * 16); 175 } 176 177 //! Hide brackets that are not under the pointer? HideBrackets()178 bool HideBrackets() const 179 { return m_hideBrackets; } 180 181 //! Define if we want to hide brackets that are not under the pointer. HideBrackets(bool hide)182 void HideBrackets(bool hide) 183 { 184 wxConfig::Get()->Write(wxT("hideBrackets"), m_hideBrackets = hide); 185 } 186 187 //! Hide brackets that are not under the pointer? PrintScale()188 double PrintScale() const 189 { return m_printScale; } 190 191 //! Define if we want to hide brackets that are not under the pointer. PrintScale(double scale)192 void PrintScale(double scale) 193 { 194 wxConfig::Get()->Write(wxT("printScale"), m_printScale = scale); 195 } 196 197 //! Sets the zoom factor the worksheet is displayed at 198 void SetZoomFactor(double newzoom); 199 200 //! Sets the zoom factor without storing the new value in the config file/registry. SetZoomFactor_temporarily(double newzoom)201 void SetZoomFactor_temporarily(double newzoom){ 202 if(m_zoomFactor != newzoom) 203 { 204 RecalculationForce(true); 205 FontChanged(true); 206 } 207 m_zoomFactor = newzoom; 208 } 209 210 /*! Scales a distance [in pixels] according to the zoom factor 211 212 Is used for displaying/printing/exporting of text/maths. 213 */ 214 long Scale_Px(double px) const; 215 216 //! Determines the zoom factor the worksheet is displayed at GetZoomFactor()217 double GetZoomFactor() const 218 { return m_zoomFactor; } 219 220 //! Get a drawing context suitable for size calculations GetDC()221 wxDC *GetDC() 222 { return m_dc; } 223 224 //! Get a drawing context suitable for size calculations GetAntialiassingDC()225 wxDC *GetAntialiassingDC() 226 { 227 if ((m_antialiassingDC != NULL) && m_antiAliasLines) 228 return m_antialiassingDC; 229 else 230 return m_dc; 231 } 232 233 wxString GetFontName(long type = TS_DEFAULT) const; 234 235 // cppcheck-suppress functionStatic 236 // cppcheck-suppress functionConst 237 wxString GetSymbolFontName() const; 238 239 wxFontWeight IsBold(long st) const; 240 241 wxFontStyle IsItalic(long st) const; 242 IsUnderlined(long st)243 bool IsUnderlined(long st) const {return m_styles[st].Underlined();} 244 245 //! Force a full recalculation? RecalculationForce(bool force)246 void RecalculationForce(bool force) 247 { 248 m_forceUpdate = force; 249 } 250 251 //! Force a full recalculation? RecalculationForce()252 bool RecalculationForce() const 253 { 254 return m_forceUpdate; 255 } 256 GetFontEncoding()257 wxFontEncoding GetFontEncoding() const 258 { 259 return m_fontEncoding; 260 } 261 SetFontEncoding(wxFontEncoding encoding)262 void SetFontEncoding(wxFontEncoding encoding) 263 { 264 m_fontEncoding = encoding; 265 } 266 GetLabelWidth()267 long GetLabelWidth() const 268 { return m_labelWidth * 14; } 269 270 //! Get the indentation of GroupCells. GetIndent()271 long GetIndent() const 272 { 273 if (m_indent < 0) 274 return 3 * GetCellBracketWidth() / 2; 275 else 276 return m_indent; 277 } 278 279 //! Get the resolution of the display showing the worksheet GetPPI()280 wxSize GetPPI() const {return GetPPI(GetWorkSheet());} 281 282 // cppcheck-suppress functionStatic 283 // cppcheck-suppress functionConst 284 //! Get the resolution of an arbitrary display 285 wxSize GetPPI(wxWindow *win) const; 286 287 //! How much vertical space is to be left between two group cells? GetCursorWidth()288 long GetCursorWidth() const 289 { 290 long ppi; 291 292 if(!m_printing) 293 ppi = GetPPI().x; 294 else 295 ppi = 96; 296 297 if (ppi / 45 < 1) 298 return 1; 299 else 300 return ppi / 45; 301 } 302 303 //! The y position the worksheet starts at GetBaseIndent()304 long GetBaseIndent() const 305 { 306 if (GetCursorWidth() < 12) 307 return 12; 308 else 309 return 4 + GetCursorWidth(); 310 } 311 312 //! The vertical space between GroupCells GetGroupSkip()313 long GetGroupSkip() const 314 { 315 if (GetCursorWidth() < 10) 316 return 20; 317 else 318 return 10 + GetCursorWidth(); 319 } 320 321 /*! Set the indentation of GroupCells 322 323 Normally this parameter is automatically calculated 324 */ SetIndent(long indent)325 void SetIndent(long indent) 326 { 327 if(m_indent != indent) 328 RecalculationForce(true); 329 m_indent = indent; 330 } 331 332 //! Set the width of the visible window for GetClientWidth() SetClientWidth(long width)333 void SetClientWidth(long width) 334 { 335 if(m_clientWidth != width) 336 RecalculationForce(true); 337 m_clientWidth = width; 338 } 339 //! Has a font changed? FontChanged()340 bool FontChanged() const {return m_fontChanged;} 341 WX_DECLARE_STRING_HASH_MAP( bool, CharsInFontMap); 342 CharsInFontMap m_charsInFontMap; 343 //! Has a font changed? FontChanged(bool fontChanged)344 void FontChanged(bool fontChanged) 345 { 346 m_fontChanged = fontChanged; 347 if(fontChanged) 348 RecalculationForce(true); 349 m_charsInFontMap.clear(); 350 } 351 352 //! Set the height of the visible window for GetClientHeight() SetClientHeight(long height)353 void SetClientHeight(long height) 354 { m_clientHeight = height; } 355 356 //! Returns the width of the visible portion of the worksheet GetClientWidth()357 long GetClientWidth() const 358 { return m_clientWidth; } 359 360 //! Returns the height of the visible portion of the worksheet GetClientHeight()361 long GetClientHeight() const 362 { return m_clientHeight; } 363 364 //! Calculates the default line width for the worksheet GetDefaultLineWidth()365 double GetDefaultLineWidth() const 366 { 367 if (GetZoomFactor() < 1.0) 368 return 1.0; 369 else 370 return GetZoomFactor(); 371 } 372 373 //! The minimum sensible line width in withs of a letter. LineWidth_em()374 long LineWidth_em() const 375 { 376 if(!m_printing) 377 return m_lineWidth_em; 378 else 379 return 10000; 380 } 381 AutoSaveAsTempFile()382 bool AutoSaveAsTempFile() const {return m_autoSaveAsTempFile;} AutoSaveAsTempFile(bool asTempFile)383 void AutoSaveAsTempFile(bool asTempFile){wxConfig::Get()->Write(wxT("AutoSaveAsTempFile"), m_autoSaveAsTempFile = asTempFile);} 384 385 //! Set the minimum sensible line width in widths of a letter. LineWidth_em(long width)386 void LineWidth_em(long width) 387 { m_lineWidth_em = width; } 388 389 //! Returns the maximum sensible width for a text line [in characters]: 390 // On big 16:9 screens text tends to get \b very wide before it hits the right margin. 391 // But text blocks that are 1 meter wide and 2 cm high feel - weird. 392 long GetLineWidth() const; 393 GetDefaultFontSize()394 long GetDefaultFontSize() const 395 { return m_styles[TS_DEFAULT].FontSize(); } 396 SetDefaultFontSize(long fontSize)397 void SetDefaultFontSize(long fontSize) 398 { 399 m_styles[TS_DEFAULT].FontSize(fontSize); 400 } 401 GetMathFontSize()402 long GetMathFontSize() const 403 { return m_mathFontSize; } 404 SetMathFontSize(double size)405 void SetMathFontSize(double size) 406 { m_mathFontSize = size; } 407 408 //! Do we want to have automatic line breaks for text cells? GetAutoWrap()409 bool GetAutoWrap() const 410 { return m_autoWrap > 0; } 411 412 // cppcheck-suppress functionStatic 413 //! Do we want to have automatic line breaks for code cells? GetAutoWrapCode()414 bool GetAutoWrapCode() const 415 { return false; } 416 417 /*! Sets the auto wrap mode 418 \param autoWrap 419 - 0: No automatic line breaks 420 - 1: Automatic line breaks only for text cells 421 - 2: Automatic line breaks for text and code cells. 422 */ SetAutoWrap(long autoWrap)423 void SetAutoWrap(long autoWrap) 424 { 425 wxConfig::Get()->Write(wxT("autoWrapMode"), m_autoWrap = autoWrap); 426 } 427 428 //! Do we want automatic indentation? GetAutoIndent()429 bool GetAutoIndent() const 430 { return m_autoIndent; } 431 SetAutoIndent(bool autoIndent)432 void SetAutoIndent(bool autoIndent) 433 { 434 wxConfig::Get()->Write(wxT("autoIndent"), m_autoIndent = autoIndent); 435 } 436 437 //! Do we want to indent all maths? IndentMaths()438 bool IndentMaths() const {return m_indentMaths;} IndentMaths(bool indent)439 void IndentMaths(bool indent){wxConfig::Get()->Write(wxT("indentMaths"), m_indentMaths=indent);} GetFontSize(TextStyle st)440 long GetFontSize(TextStyle st) const 441 { 442 if (st == TS_TEXT || st == TS_HEADING5 || st == TS_HEADING6 || st == TS_SUBSUBSECTION || st == TS_SUBSECTION || st == TS_SECTION || st == TS_TITLE) 443 return m_styles[st].FontSize(); 444 return 0; 445 } 446 447 /*! Reads the style settings 448 449 If a file name is given the settings are read from a file. 450 */ 451 452 void ReadStyles(wxString file = wxEmptyString); 453 454 /*! Saves the style settings 455 456 If a file name is given the settings are written to a file. 457 */ 458 void WriteStyles(wxString file = wxEmptyString); 459 Outdated(bool outdated)460 void Outdated(bool outdated) 461 { m_outdated = outdated; } 462 CheckTeXFonts()463 bool CheckTeXFonts() const 464 { return m_TeXFonts; } 465 CheckTeXFonts(bool check)466 void CheckTeXFonts(bool check) 467 { m_TeXFonts = check; } 468 CheckKeepPercent()469 bool CheckKeepPercent() const 470 { return m_keepPercent; } 471 GetTeXCMRI()472 wxString GetTeXCMRI() const 473 { return m_fontCMRI; } 474 GetTeXCMSY()475 wxString GetTeXCMSY() const 476 { return m_fontCMSY; } 477 GetTeXCMEX()478 wxString GetTeXCMEX() const 479 { return m_fontCMEX; } 480 GetTeXCMMI()481 wxString GetTeXCMMI() const 482 { return m_fontCMMI; } 483 GetTeXCMTI()484 wxString GetTeXCMTI() const 485 { return m_fontCMTI; } 486 ShowCodeCells()487 bool ShowCodeCells() const 488 { return m_showCodeCells; } 489 490 void ShowCodeCells(bool show); 491 492 /*! Are we currently printing? 493 494 This affects the bitmap scale as well as the fact if we want 495 to output objects that are outside the region that currently is 496 redrawn. 497 */ 498 void SetPrinting(bool printing); 499 500 /*! Are we currently printing? 501 502 This affects the bitmap scale as well as the fact if we want 503 to output objects that are outside the region that currently is 504 redrawn. 505 */ GetPrinting()506 bool GetPrinting() const 507 { return m_printing; } 508 509 //! Gets the color for a text style 510 wxColour GetColor(TextStyle style); 511 512 //! Inverts a color: In 2020 wxColor still lacks this functionality 513 wxColour InvertColour(wxColour col); 514 515 /*! Make this color differ from the background by a noticeable amount 516 517 Useful for black/white background theme changes 518 */ 519 wxColor MakeColorDifferFromBackground(wxColor color); 520 GetMatchParens()521 bool GetMatchParens() const 522 { return m_matchParens; } SetMatchParens(bool matchParens)523 void SetMatchParens(bool matchParens) 524 { wxConfig::Get()->Write(wxT("matchParens"), m_matchParens = matchParens); } 525 GetChangeAsterisk()526 bool GetChangeAsterisk() const 527 { return m_changeAsterisk; } 528 SetChangeAsterisk(bool changeAsterisk)529 void SetChangeAsterisk(bool changeAsterisk) 530 { 531 wxConfig::Get()->Write(wxT("changeAsterisk"), m_changeAsterisk = changeAsterisk); 532 } 533 HidemultiplicationSign()534 bool HidemultiplicationSign() const 535 { 536 return m_hidemultiplicationsign; 537 } 538 HidemultiplicationSign(bool show)539 void HidemultiplicationSign(bool show) 540 { 541 wxConfig::Get()->Write(wxT("hidemultiplicationsign"), m_hidemultiplicationsign = show); 542 } 543 Latin2Greek()544 bool Latin2Greek() const 545 {return m_latin2greek;} 546 Latin2Greek(bool latin2greek)547 void Latin2Greek(bool latin2greek) 548 { 549 wxConfig::Get()->Write(wxT("latin2greek"), m_latin2greek = latin2greek); 550 } 551 GreekSidebar_ShowLatinLookalikes()552 bool GreekSidebar_ShowLatinLookalikes() const 553 {return m_greekSidebar_ShowLatinLookalikes;} GreekSidebar_ShowLatinLookalikes(bool show)554 void GreekSidebar_ShowLatinLookalikes(bool show) 555 {wxConfig::Get()->Write(wxT("greekSidebar_ShowLatinLookalikes"), 556 m_greekSidebar_ShowLatinLookalikes = show);} 557 GreekSidebar_Show_mu()558 bool GreekSidebar_Show_mu() const 559 {return m_greekSidebar_Show_mu;} GreekSidebar_Show_mu(bool show)560 void GreekSidebar_Show_mu(bool show) 561 {wxConfig::Get()->Write(wxT("greekSidebar_Show_mu"), 562 m_greekSidebar_Show_mu = show);} 563 SymbolPaneAdditionalChars()564 wxString SymbolPaneAdditionalChars() const 565 {return m_symbolPaneAdditionalChars;} SymbolPaneAdditionalChars(wxString symbols)566 void SymbolPaneAdditionalChars(wxString symbols) 567 {wxConfig::Get()->Write(wxT("symbolPaneAdditionalChars"), 568 m_symbolPaneAdditionalChars = symbols);} 569 570 571 //! Notify the user if maxima is idle? NotifyIfIdle()572 bool NotifyIfIdle() const 573 { return m_notifyIfIdle; } 574 NotifyIfIdle(bool notify)575 void NotifyIfIdle(bool notify) 576 { 577 wxConfig::Get()->Write(wxT("notifyIfIdle"), m_notifyIfIdle = notify); 578 } 579 580 /*! Returns the maximum number of displayed digits 581 582 m_displayedDigits is always >= 20, so we can guarantee the number we return to be unsigned. 583 */ GetDisplayedDigits()584 long GetDisplayedDigits() const 585 { return m_displayedDigits; } 586 SetDisplayedDigits(long displayedDigits)587 void SetDisplayedDigits(long displayedDigits) 588 { 589 wxASSERT_MSG(displayedDigits >= 20, _("Bug: Maximum number of digits that is to be displayed is too low!")); 590 wxConfig::Get()->Write(wxT("displayedDigits"), m_displayedDigits = displayedDigits); 591 } 592 GetUpdateRegion()593 wxRect GetUpdateRegion() const {return m_updateRegion;} SetUpdateRegion(wxRect rect)594 void SetUpdateRegion(wxRect rect){m_updateRegion = rect;} GetInsertAns()595 bool GetInsertAns() const 596 { return m_insertAns; } 597 SetInsertAns(bool insertAns)598 void SetInsertAns(bool insertAns) 599 { 600 wxConfig::Get()->Write(wxT("insertAns"), m_insertAns = insertAns); 601 } 602 GetOpenHCaret()603 bool GetOpenHCaret() const 604 { return m_openHCaret; } 605 SetOpenHCaret(bool openHCaret)606 void SetOpenHCaret(bool openHCaret) 607 { 608 wxConfig::Get()->Write(wxT("openHCaret"), m_openHCaret = openHCaret); 609 } 610 RestartOnReEvaluation()611 bool RestartOnReEvaluation() const 612 { return m_restartOnReEvaluation; } 613 RestartOnReEvaluation(bool arg)614 void RestartOnReEvaluation(bool arg) 615 { 616 wxConfig::Get()->Write(wxT("restartOnReEvaluation"), m_restartOnReEvaluation = arg); 617 } 618 619 //! Reads the size of the current worksheet's visible window. See SetCanvasSize GetCanvasSize()620 wxSize GetCanvasSize() const 621 { return m_canvasSize; } 622 623 //! Sets the size of the current worksheet's visible window. SetCanvasSize(wxSize siz)624 void SetCanvasSize(wxSize siz) 625 { m_canvasSize = siz; } 626 627 //! Show the cell brackets [displayed left to each group cell showing its extend]? ShowBrackets()628 bool ShowBrackets() const 629 { return m_showBrackets; } 630 ShowBrackets(bool show)631 bool ShowBrackets(bool show) 632 { return m_showBrackets = show; } 633 634 //! Prlong the cell brackets [displayed left to each group cell showing its extend]? PrintBrackets()635 bool PrintBrackets() const 636 { return m_printBrackets; } 637 GetLabelChoice()638 showLabels GetLabelChoice() const 639 { return m_showLabelChoice; } 640 InvertBackground()641 bool InvertBackground(){return m_invertBackground;} InvertBackground(bool invert)642 void InvertBackground(bool invert) 643 { 644 wxConfig::Get()->Write("invertBackground", m_invertBackground = invert); 645 } 646 647 //! Do we want to show maxima's automatic labels (%o1, %t1, %i1,...)? ShowAutomaticLabels()648 bool ShowAutomaticLabels() const 649 { return (m_showLabelChoice < labels_useronly); } 650 651 //! Do we want at all to show labels? UseUserLabels()652 bool UseUserLabels() const 653 { return m_showLabelChoice > labels_automatic; } 654 655 //! Do we want at all to show labels? ShowLabels()656 bool ShowLabels() const 657 { return m_showLabelChoice < labels_none; } 658 659 //! Sets the value of the Configuration ChoiceBox that treads displaying labels SetLabelChoice(showLabels choice)660 void SetLabelChoice(showLabels choice) 661 { 662 wxConfig::Get()->Write(wxT("showLabelChoice"), (int) (m_showLabelChoice = choice)); 663 } 664 PrintBrackets(bool print)665 bool PrintBrackets(bool print) 666 { 667 wxConfig::Get()->Write(wxT("printBrackets"), m_printBrackets = print); 668 return print; 669 } 670 671 //! Autodetect maxima's location? (If false the user-specified location is used) AutodetectMaxima()672 bool AutodetectMaxima() const {return m_autodetectMaxima;} 673 //! Autodetect maxima's location? AutodetectMaxima(bool autodetectmaxima)674 void AutodetectMaxima(bool autodetectmaxima){wxConfig::Get()->Write( 675 wxT("autodetectMaxima"), 676 m_autodetectMaxima = autodetectmaxima); 677 } 678 679 //! Parameters to the maxima binary MaximaParameters()680 wxString MaximaParameters() const {return m_maximaParameters;} 681 //! The parameters we pass to the maxima binary MaximaParameters(wxString parameters)682 void MaximaParameters(wxString parameters){wxConfig::Get()->Write( 683 "parameters", 684 m_maximaParameters = parameters); 685 } 686 687 //! The auto-detected maxima location 688 static wxString MaximaDefaultLocation(); 689 690 //! Returns the location of the maxima binary. 691 wxString MaximaLocation() const; 692 693 //! Returns the location of the maxima binary the user has selected. MaximaUserLocation()694 wxString MaximaUserLocation() const {return m_maximaUserLocation;} 695 696 //! Sets the location of the maxima binary. MaximaUserLocation(wxString maxima)697 void MaximaUserLocation(wxString maxima) 698 { 699 wxConfig::Get()->Write(wxT("maxima"), m_maximaUserLocation = maxima); 700 } 701 702 /*! Could a maxima binary be found in the path we expect it to be in? 703 704 \param location The location to search for maxima in. 705 If location == wxEmptyString the default location from the configuration 706 is taken. 707 */ 708 static bool MaximaFound(wxString location = wxEmptyString); 709 710 //! Renumber out-of-order cell labels on saving. FixReorderedIndices()711 bool FixReorderedIndices() const 712 { return m_fixReorderedIndices; } 713 FixReorderedIndices(bool fix)714 void FixReorderedIndices(bool fix) 715 { 716 wxConfig::Get()->Write(wxT("fixReorderedIndices"), m_fixReorderedIndices = fix); 717 } 718 719 //! Returns the URL MathJaX can be found at. MathJaXURL()720 wxString MathJaXURL() const {if(m_mathJaxURL_UseUser) return m_mathJaxURL; else return MathJaXURL_Auto();} MathJaXURL_User()721 wxString MathJaXURL_User() const { return m_mathJaxURL;} MathJaXURL_UseUser()722 bool MathJaXURL_UseUser() const { return m_mathJaxURL_UseUser;} MathJaXURL_UseUser(bool useUser)723 void MathJaXURL_UseUser(bool useUser){wxConfig::Get()->Write(wxT("mathJaxURL_UseUser"), 724 m_mathJaxURL_UseUser = useUser);} 725 EnterEvaluates()726 bool EnterEvaluates() const {return m_enterEvaluates;} EnterEvaluates(bool enterEvaluates)727 void EnterEvaluates(bool enterEvaluates) {wxConfig::Get()->Write(wxT("enterEvaluates"), 728 m_enterEvaluates = enterEvaluates);} MathJaXURL_Auto()729 static wxString MathJaXURL_Auto() { return wxT("https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.6/MathJax.js?config=TeX-AMS_HTML");} 730 //! Returns the URL MathJaX can be found at. MathJaXURL(wxString url)731 void MathJaXURL(wxString url){wxConfig::Get()->Write(wxT("mathJaxURL"), m_mathJaxURL = url);} AntiAliasLines()732 bool AntiAliasLines() const {return m_antiAliasLines;} AntiAliasLines(bool antiAlias)733 void AntiAliasLines(bool antiAlias) 734 { 735 wxConfig::Get()->Write(wxT("antiAliasLines"), m_antiAliasLines = antiAlias ); 736 } 737 CopyBitmap()738 bool CopyBitmap() const {return m_copyBitmap;} CopyBitmap(bool copyBitmap)739 void CopyBitmap(bool copyBitmap) 740 { 741 wxConfig::Get()->Write(wxT("copyBitmap"), m_copyBitmap = copyBitmap ); 742 } 743 CopyMathML()744 bool CopyMathML() const {return m_copyMathML;} CopyMathML(bool copyMathML)745 void CopyMathML(bool copyMathML) 746 { 747 wxConfig::Get()->Write(wxT("copyMathML"), m_copyMathML = copyMathML ); 748 } CopyMathMLHTML()749 bool CopyMathMLHTML() const {return m_copyMathMLHTML;} CopyMathMLHTML(bool copyMathMLHTML)750 void CopyMathMLHTML(bool copyMathMLHTML) 751 { 752 wxConfig::Get()->Write(wxT("copyMathMLHTML"), m_copyMathMLHTML = copyMathMLHTML ); 753 } CopyRTF()754 bool CopyRTF() const {return m_copyRTF;} CopyRTF(bool copyRTF)755 void CopyRTF(bool copyRTF) 756 { 757 wxConfig::Get()->Write(wxT("copyRTF"), m_copyRTF = copyRTF ); 758 } CopySVG()759 bool CopySVG() const {return m_copySVG;} CopySVG(bool copySVG)760 void CopySVG(bool copySVG) 761 { 762 wxConfig::Get()->Write(wxT("copySVG"), m_copySVG = copySVG ); 763 } CopyEMF()764 bool CopyEMF() const {return m_copyEMF;} CopyEMF(bool copyEMF)765 void CopyEMF(bool copyEMF) 766 { 767 wxConfig::Get()->Write(wxT("copyEMF"), m_copyEMF = copyEMF ); 768 } UseSVG()769 bool UseSVG(){return m_useSVG;} UseSVG(bool useSVG)770 void UseSVG(bool useSVG) 771 { 772 wxConfig::Get()->Write(wxT("useSVG"), m_useSVG = useSVG ); 773 } ShowLength(long length)774 void ShowLength(long length) 775 { 776 wxConfig::Get()->Write(wxT("showLength"), m_showLength = length); 777 } ShowLength()778 long ShowLength() const {return m_showLength;} 779 780 //! Sets the default toolTip for new cells SetDefaultCellToolTip(wxString defaultToolTip)781 void SetDefaultCellToolTip(wxString defaultToolTip){m_defaultToolTip = defaultToolTip;} 782 //! Gets the default toolTip for new cells GetDefaultCellToolTip()783 wxString GetDefaultCellToolTip() const {return m_defaultToolTip;} 784 //! Which way do we want to draw parenthesis? SetGrouphesisDrawMode(drawMode mode)785 void SetGrouphesisDrawMode(drawMode mode){m_parenthesisDrawMode = mode;} 786 TocShowsSectionNumbers(bool showSectionNumbers)787 void TocShowsSectionNumbers(bool showSectionNumbers) 788 { 789 wxConfig::Get()->Write(wxT("TOCshowsSectionNumbers"), (m_TOCshowsSectionNumbers = showSectionNumbers)); 790 } 791 TocShowsSectionNumbers()792 bool TocShowsSectionNumbers() const {return m_TOCshowsSectionNumbers;} 793 UseUnicodeMaths(bool useunicodemaths)794 void UseUnicodeMaths(bool useunicodemaths) 795 { 796 wxConfig::Get()->Write(wxT("useUnicodeMaths"), (m_useUnicodeMaths = useunicodemaths)); 797 } UseUnicodeMaths()798 bool UseUnicodeMaths() const {return m_useUnicodeMaths;} 799 800 drawMode GetParenthesisDrawMode(); 801 /*! Get the font for a given text style 802 803 \param textStyle The text style to get the font for 804 \param fontSize Only relevant for math cells: Super- and subscripts can have different 805 font styles than the rest. 806 */ 807 wxFont GetFont(TextStyle textStyle, long fontSize) const; 808 809 //! Get the worksheet this configuration storage is valid for GetWorkSheet()810 wxWindow *GetWorkSheet() const {return m_workSheet;} 811 //! Set the worksheet this configuration storage is valid for SetWorkSheet(wxWindow * workSheet)812 void SetWorkSheet(wxWindow *workSheet){m_workSheet = workSheet;} 813 DefaultPort()814 long DefaultPort() const {return m_defaultPort;} DefaultPort(long port)815 void DefaultPort(long port){wxConfig::Get()->Write("defaultPort",m_defaultPort = port);} GetAbortOnError()816 bool GetAbortOnError() const {return m_abortOnError;} SetAbortOnError(bool abortOnError)817 void SetAbortOnError(bool abortOnError) 818 {wxConfig::Get()->Write("abortOnError",m_abortOnError = abortOnError);} 819 GetLanguage()820 int GetLanguage() const {return m_language;} SetLanguage(int language)821 void SetLanguage(int language) 822 {wxConfig::Get()->Write("language",m_language = language);} 823 824 //! The maximum number of Megabytes of gnuplot sources we should store MaxGnuplotMegabytes()825 long MaxGnuplotMegabytes() const {return m_maxGnuplotMegabytes;} MaxGnuplotMegabytes(long megaBytes)826 void MaxGnuplotMegabytes(long megaBytes) 827 {wxConfig::Get()->Write("maxGnuplotMegabytes",m_maxGnuplotMegabytes = megaBytes);} 828 OfferKnownAnswers()829 bool OfferKnownAnswers() const {return m_offerKnownAnswers;} OfferKnownAnswers(bool offerKnownAnswers)830 void OfferKnownAnswers(bool offerKnownAnswers) 831 {wxConfig::Get()->Write("offerKnownAnswers",m_offerKnownAnswers = offerKnownAnswers);} 832 Documentclass()833 wxString Documentclass() const {return m_documentclass;} Documentclass(wxString clss)834 void Documentclass(wxString clss){wxConfig::Get()->Write("documentclass",m_documentclass = clss);} DocumentclassOptions()835 wxString DocumentclassOptions() const {return m_documentclassOptions;} DocumentclassOptions(wxString classOptions)836 void DocumentclassOptions(wxString classOptions){wxConfig::Get()->Write("documentclassoptions",m_documentclassOptions = classOptions);} 837 838 HTMLequationFormat()839 htmlExportFormat HTMLequationFormat() const {return m_htmlEquationFormat;} HTMLequationFormat(htmlExportFormat HTMLequationFormat)840 void HTMLequationFormat(htmlExportFormat HTMLequationFormat) 841 {wxConfig::Get()->Write("HTMLequationFormat", (int) (m_htmlEquationFormat = HTMLequationFormat));} 842 FontName()843 wxString FontName()const {return m_fontName;} FontName(wxString name)844 void FontName(wxString name){wxConfig::Get()->Write("Style/Default/Style/Text/fontname",m_fontName = name);} MathFontName(wxString name)845 void MathFontName(wxString name){wxConfig::Get()->Write("Style/Math/fontname",m_mathFontName = name);} MathFontName()846 wxString MathFontName()const {return m_mathFontName;} 847 //! Get the worksheet this configuration storage is valid for GetAutosubscript_Num()848 long GetAutosubscript_Num() const {return m_autoSubscript;} SetAutosubscript_Num(long autosubscriptnum)849 void SetAutosubscript_Num(long autosubscriptnum) 850 {wxConfig::Get()->Write("autosubscript",m_autoSubscript = autosubscriptnum);} 851 wxString GetAutosubscript_string() const; 852 //! Determine the default background color of the worksheet 853 wxColor DefaultBackgroundColor(); 854 //! Determine the default background color of editorcells 855 wxColor EditorBackgroundColor(); 856 //! Do we want to save time by only redrawing the area currently shown on the screen? ClipToDrawRegion()857 bool ClipToDrawRegion() const {return m_clipToDrawRegion;} 858 //! Do we want to save time by only redrawing the area currently shown on the screen? ClipToDrawRegion(bool clipToDrawRegion)859 void ClipToDrawRegion(bool clipToDrawRegion){m_clipToDrawRegion = clipToDrawRegion; m_forceUpdate = true;} 860 //! Request adjusting the worksheet size? AdjustWorksheetSize(bool adjust)861 void AdjustWorksheetSize(bool adjust) 862 { m_adjustWorksheetSizeNeeded = adjust; } AdjustWorksheetSize()863 bool AdjustWorksheetSize() const 864 { return m_adjustWorksheetSizeNeeded; } SetVisibleRegion(wxRect visibleRegion)865 void SetVisibleRegion(wxRect visibleRegion){m_visibleRegion = visibleRegion;} GetVisibleRegion()866 wxRect GetVisibleRegion() const {return m_visibleRegion;} SetWorksheetPosition(wxPoint worksheetPosition)867 void SetWorksheetPosition(wxPoint worksheetPosition){m_worksheetPosition = worksheetPosition;} GetWorksheetPosition()868 wxPoint GetWorksheetPosition() const {return m_worksheetPosition;} MaximaShareDir()869 wxString MaximaShareDir() const {return m_maximaShareDir;} MaximaShareDir(wxString dir)870 void MaximaShareDir(wxString dir){m_maximaShareDir = dir;} InLispMode(bool lisp)871 void InLispMode(bool lisp){m_inLispMode = lisp;} InLispMode()872 bool InLispMode() const {return m_inLispMode;} 873 Style m_styles[NUMBEROFSTYLES]; 874 private: 875 //! true = Autosave doesn't save into the current file. 876 bool m_autoSaveAsTempFile; 877 //! The number of the language wxMaxima uses. 878 long m_language; 879 //! Autodetect maxima's location? 880 bool m_autodetectMaxima; 881 //! The worksheet all cells are drawn on 882 wxRect m_updateRegion; 883 //! Has the font changed? 884 bool m_fontChanged; 885 //! Which objects do we want to convert into subscripts if they occur after an underscore? 886 long m_autoSubscript; 887 //! The worksheet this configuration storage is valid for 888 wxWindow *m_workSheet; 889 //! A replacement for the non-existing "==" operator for wxBitmaps. 890 static bool IsEqual(wxBitmap bitmap1, wxBitmap bitmap2); 891 /*! Do these chars exist in the given font? 892 893 wxWidgets currently doesn't define such a function. But we can do the following: 894 - Test if any of these characters has the width or height 0 (or even less) 895 which clearly indicates that this char doesn't exist. 896 - Test if any two of the characters are equal when rendered as bitmaps: 897 If they are we most probably didn't get render real characters but rather 898 render placeholders for characters. 899 900 As these might be costly operations it is important to cache the result 901 of this function. 902 */ 903 bool CharsExistInFont(wxFont font, wxString char1, wxString char2, wxString char3); 904 //! Caches the information on how to draw big parenthesis for GetParenthesisDrawMode(). 905 drawMode m_parenthesisDrawMode; 906 wxString m_workingdir; 907 908 wxString m_maximaUserLocation; 909 //! Hide brackets that are not under the pointer 910 bool m_hideBrackets; 911 //! The scale for printing 912 double m_printScale; 913 //! The size of the canvas our cells have to be drawn on 914 wxSize m_canvasSize; 915 //! Show the cell brackets [displayed left to each group cell showing its extend]? 916 bool m_showBrackets; 917 //! Prlong the cell brackets [displayed left to each group cell showing its extend]? 918 bool m_printBrackets; 919 /*! Replace a "*" by a centered dot? 920 921 Normally we ask the parser for this piece of information. But during recalculation 922 of widths while selecting text we don't know our parser. 923 */ 924 bool m_changeAsterisk; 925 //! Notify the user if maxima is idle 926 bool m_notifyIfIdle; 927 //! How many digits of a number we show by default? 928 long m_displayedDigits; 929 //! Automatically wrap long lines? 930 long m_autoWrap; 931 //! Automatically indent long lines? 932 bool m_autoIndent; 933 //! Do we want to automatically close parenthesis? 934 bool m_matchParens; 935 //! Do we want to automatically insert new cells containing a "%" at the end of every command? 936 bool m_insertAns; 937 //! Do we want to automatically open a new cell if maxima has finished evaluating its input? 938 bool m_openHCaret; 939 //! The width of input and output labels [in chars] 940 long m_labelWidth; 941 long m_indent; 942 bool m_latin2greek; 943 bool m_antiAliasLines; 944 double m_zoomFactor; 945 wxDC *m_dc; 946 wxDC *m_antialiassingDC; 947 wxString m_fontName; 948 long m_mathFontSize; 949 wxString m_mathFontName; 950 wxString m_maximaShareDir; 951 bool m_forceUpdate; 952 bool m_clipToDrawRegion; 953 bool m_outdated; 954 wxString m_maximaParameters; 955 wxString m_defaultToolTip; 956 bool m_TeXFonts; 957 bool m_keepPercent; 958 bool m_restartOnReEvaluation; 959 wxString m_fontCMRI, m_fontCMSY, m_fontCMEX, m_fontCMMI, m_fontCMTI; 960 long m_clientWidth; 961 long m_clientHeight; 962 wxFontEncoding m_fontEncoding; 963 bool m_printing; 964 long m_lineWidth_em; 965 showLabels m_showLabelChoice; 966 bool m_fixReorderedIndices; 967 wxString m_mathJaxURL; 968 bool m_mathJaxURL_UseUser; 969 bool m_showCodeCells; 970 bool m_copyBitmap; 971 bool m_copyMathML; 972 bool m_copyMathMLHTML; 973 long m_showLength; 974 //!< don't add ; in lisp mode 975 bool m_inLispMode; 976 bool m_enterEvaluates; 977 bool m_useSVG; 978 bool m_copyRTF; 979 bool m_copySVG; 980 bool m_copyEMF; 981 bool m_TOCshowsSectionNumbers; 982 bool m_useUnicodeMaths; 983 bool m_indentMaths; 984 bool m_abortOnError; 985 bool m_hidemultiplicationsign; 986 bool m_offerKnownAnswers; 987 long m_defaultPort; 988 long m_maxGnuplotMegabytes; 989 wxString m_documentclass; 990 wxString m_documentclassOptions; 991 htmlExportFormat m_htmlEquationFormat; 992 bool m_adjustWorksheetSizeNeeded; 993 //! The rectangle of the worksheet that is currently visible. 994 wxRect m_visibleRegion; 995 //! The position of the worksheet in the wxMaxima window 996 wxPoint m_worksheetPosition; 997 998 wxColour m_defaultBackgroundColor; 999 //! The brush the normal cell background is painted with 1000 wxBrush m_BackgroundBrush; 1001 wxBrush m_tooltipBrush; 1002 bool m_greekSidebar_ShowLatinLookalikes; 1003 bool m_greekSidebar_Show_mu; 1004 wxString m_symbolPaneAdditionalChars; 1005 bool m_invertBackground; 1006 }; 1007 1008 //! Sets the configuration's "printing" flag until this class is left. 1009 class Printing 1010 { 1011 public: Printing(Configuration * configuration)1012 explicit Printing(Configuration *configuration) 1013 { 1014 m_configuration = configuration; 1015 m_configuration->SetPrinting(true); 1016 m_configuration->ClipToDrawRegion(false); 1017 } ~Printing()1018 ~Printing() 1019 { 1020 m_configuration->SetPrinting(false); 1021 m_configuration->ClipToDrawRegion(true); 1022 } 1023 private: 1024 Configuration * m_configuration; 1025 }; 1026 1027 //! Clears the configuration's "Clip to draw region" flag until this class is left. 1028 class NoClipToDrawRegion 1029 { 1030 public: NoClipToDrawRegion(Configuration * configuration)1031 explicit NoClipToDrawRegion(Configuration *configuration) 1032 { 1033 m_configuration = configuration; 1034 m_configuration->ClipToDrawRegion(false); 1035 } ~NoClipToDrawRegion()1036 ~NoClipToDrawRegion() 1037 { 1038 m_configuration->ClipToDrawRegion(true); 1039 } 1040 private: 1041 Configuration * m_configuration; 1042 }; 1043 1044 #endif // CONFIGURATION_H 1045