diff --git a/CHANGELOG b/CHANGELOG index 139597f..17afe19 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,2 +1,6 @@ - - +Version 0.7.1 (2007.02.08): + * added a button 'err' (error) on the first tab + * the input edit can have 2048 characters now + * added remembering the vertical size into the config file + * fixed a problem with the 'tab' key + * added a message 'Calculating...' when an user clicks on the 'err' button during calculating something diff --git a/TODO b/TODO index 027e908..33bdbd4 100644 --- a/TODO +++ b/TODO @@ -1,17 +1,12 @@ TODO TTCalc =========== -* increase the input edit -* when the program should be run as the maximalized window, the window is only - resizing horizontly -* doesn't set 'always on top' if it was in the configuration file -* add the button 'error' which shows us where is incorrect character (in input edit) -* add the test when program is being starded which checks if the coordinates of the +* To add the test when program is being starded which checks if the coordinates of the main window actually pointing at the valid area (for example when someone take his configuration file into a new computer) -* add some physical constants -* make the help -* the focus (from tab key) doesn't go from tabs into their controls -* when compiling under Cygwin the program has a problem with line-ends in - the configuration file (/r/n) +* To add some physical constants +* To make the help +* To resize the last column in lists (variabies and functions) to the main window +* To block the possibility of putting digits as names of variables and funtions + diff --git a/src/Makefile b/src/Makefile index f930729..d382cb1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,6 @@ CC = g++ o = resource.o calculation.o functions.o iniparser.o languages.o mainwindow.o parsermanager.o programresources.o tabs.o variables.o winmain.o -CFLAGS = -Wall -pedantic -s -O3 -mwindows -mthreads -I../../../ttmath +CFLAGS = -Wall -pedantic -s -O1 -mwindows -mthreads -I../../../ttmath name = ttcalc.exe diff --git a/src/calculation.cpp b/src/calculation.cpp index ef3052a..c7d446e 100644 --- a/src/calculation.cpp +++ b/src/calculation.cpp @@ -1,29 +1,52 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "parsermanager.h" - +#include "tabs.h" #include /*! the function for the second thread */ -//DWORD WINAPI CalculationsProcedure(LPVOID lpParameter) unsigned __stdcall CalculationsProcedure(void *) { -/* - using namespace ttmath; - - Parser > parser; - - parser.Parse("6"); - std::string buf; - - parser.stack[0].value.ToString(buf); - MessageBox(0, buf.c_str(), "", 0); -*/ - - ParserManager parser_manager; - + HWND main_window = GetPrgRes()->GetMainWindow(); parser_manager.Init(); // the main loop of calculations @@ -33,22 +56,27 @@ unsigned __stdcall CalculationsProcedure(void *) // (at this moment all calling from the main thread are stopped) parser_manager.MakeCopyOfVariables(); - // then we can set 'thread_controller' as being ready for 'stop' signal + // then we can set 'thread_controller' as being ready for the 'stop' signal GetPrgRes()->GetThreadController()->ReadyForStop(); - // (now the main thread can call various methods for changing state) + // (now the main thread can call various methods for changing the state) - // and finally we're cleaning the output window and parsing the input string - SetDlgItemText(GetPrgRes()->GetMainWindow(),IDC_OUTPUT_EDIT,""); + // and we're cleaning the output edit and sending a message about calculating + SetDlgItemText(main_window, IDC_OUTPUT_EDIT, ""); + PostMessage(main_window, WM_SET_LAST_ERROR, (WPARAM)ttmath::err_still_calculating, 0); + + // and finally we're parsing the input string parser_manager.Parse(); - // if there was a stop signal we continue the main loop without printing any values - if( GetPrgRes()->GetThreadController()->WasStopSignal() ) - continue; + // after parsing we're sending a message about the result of parsing + PostMessage(main_window, WM_SET_LAST_ERROR, (WPARAM)parser_manager.GetLastCode(), 0); // at the end we're printing the result - parser_manager.PrintResult(); + // if there was a stop signal we continue the main loop without printing any values + if( ! GetPrgRes()->GetThreadController()->WasStopSignal() ) + parser_manager.PrintResult(); } + _endthreadex(0); return 0; } diff --git a/src/compileconfig.h b/src/compileconfig.h index 9786adf..e978568 100644 --- a/src/compileconfig.h +++ b/src/compileconfig.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilecompileconfig #define headerfilecompileconfig @@ -10,19 +47,13 @@ -/*! - the number of build - (autoincrement by a compile script) -*/ -#define TTCALC_BUILD 1 - - /*! the version of the application */ #define TTCALC_MAJOR_VER 0 #define TTCALC_MINOR_VER 7 -#define TTCALC_REVISION_VER 0 +#define TTCALC_REVISION_VER 1 + /*! diff --git a/src/functions.cpp b/src/functions.cpp index e27da89..6af4bd8 100644 --- a/src/functions.cpp +++ b/src/functions.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "tabs.h" diff --git a/src/iniparser.cpp b/src/iniparser.cpp index 5de19e6..59a1fe9 100644 --- a/src/iniparser.cpp +++ b/src/iniparser.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "iniparser.h" diff --git a/src/iniparser.h b/src/iniparser.h index 6491aec..8c835d8 100644 --- a/src/iniparser.h +++ b/src/iniparser.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfileiniparser #define headerfileiniparser diff --git a/src/languages.cpp b/src/languages.cpp index f8cc493..1fb9428 100644 --- a/src/languages.cpp +++ b/src/languages.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "languages.h" @@ -70,8 +107,8 @@ void Languages::InitErrorMessagesTab() InsertErrorPair(ttmath::err_variable_loop,"There's a recurrence between variables"); InsertErrorPair(ttmath::err_functions_loop,"There's a recurrence between functions"); InsertErrorPair(ttmath::err_must_be_only_one_value,"Variables or functions must return only one value"); + InsertErrorPair(ttmath::err_still_calculating,"Calculating..."); - InsertErrorPair(ttmath::err_this_cant_be_used,"?"); // pl @@ -99,8 +136,9 @@ void Languages::InitErrorMessagesTab() InsertErrorPair(ttmath::err_variable_loop,"Pomiędzy zmiennymi zachodzi wywołanie rekurencyjne"); InsertErrorPair(ttmath::err_functions_loop,"Pomiędzy funkcjami zachodzi wywołanie rekurencyjne"); InsertErrorPair(ttmath::err_must_be_only_one_value,"Zmienne albo funkcje mogą posiadać (zwracać) tylko jedną wartość"); + InsertErrorPair(ttmath::err_still_calculating,"Obliczanie..."); + - InsertErrorPair(ttmath::err_this_cant_be_used,"?"); diff --git a/src/languages.h b/src/languages.h index 06ac591..cc2fa9b 100644 --- a/src/languages.h +++ b/src/languages.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilelanguages #define headerfilelanguages diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 3ddbdbd..5cc027c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1,13 +1,99 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "winmain.h" - + namespace MainWindowFunctions { +/*! + this function sets the focus on a specific control + (the standard procedure from the operating system doesn't work well because + the tab control would be omitted) + + remember to set WS_EX_CONTROLPARENT to the tab control and + to all dialog boxes on the tab +*/ +void SetNextFocus() +{ + HWND next = 0; + + HWND main_window = GetPrgRes()->GetMainWindow(); + HWND focus = GetFocus(); + HWND output_edit = GetDlgItem(main_window, IDC_OUTPUT_EDIT); + HWND tab = GetDlgItem(main_window, IDC_TAB); + bool shift = (GetKeyState(VK_SHIFT) & 0xffff0000) != 0; + + + if( focus==output_edit && !shift ) + { + next = tab; + } + else + if( focus == tab ) + { + if( shift ) + { + next = output_edit; + } + else + { + int tab_sel = TabCtrl_GetCurSel(tab); + HWND tab_dialog = GetPrgRes()->GetTabWindow(tab_sel); + next = GetNextDlgTabItem(tab_dialog, 0, false); + } + } + else + { + next = GetNextDlgTabItem(main_window, focus, shift); + + if( shift && focus!=tab && next==output_edit ) + next = tab; + } + + if( next ) + SetFocus(next); +} + void SetActiveTab(unsigned int i) { @@ -185,7 +271,6 @@ TCITEM tab_item; - BOOL WmInitDialog(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { HWND hTab = GetDlgItem(hWnd,IDC_TAB); @@ -347,6 +432,7 @@ POINT p; { GetWindowRect(hWnd,&r); GetPrgRes()->SetXSize( r.right - r.left ); + GetPrgRes()->SetYSize( r.bottom - r.top ); } return 0; @@ -526,7 +612,7 @@ BOOL WmCommand_InputEditNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP return false; GetPrgRes()->GetThreadController()->StopCalculating(); - GetDlgItemText(hWnd,IDC_INPUT_EDIT, (char*)GetPrgRes()->GetBuffer(), GetPrgRes()->GetBufferSize()-1); + GetDlgItemText(hWnd,IDC_INPUT_EDIT, (char*)GetPrgRes()->GetBuffer(), GetPrgRes()->GetBufferSize()); GetPrgRes()->GetThreadController()->StartCalculating(); return true; @@ -571,16 +657,35 @@ return true; } +BOOL WmSetLastError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + TabWindowFunctions::last_code = (ttmath::ErrorCode)wParam; + +return true; +} + + +void SetOutputEditLanguage(HWND hWnd) +{ + if( TabWindowFunctions::last_code != ttmath::err_ok ) + { + if( SendDlgItemMessage(hWnd, IDC_OUTPUT_EDIT, WM_GETTEXTLENGTH, 0, 0) > 0 ) + { + // there should be an error string on the output edit + // and we change it into a new language + TabWindowFunctions::PrintErrorCode(); + } + } +} + BOOL WmCommand_LanguageEnglish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - GetPrgRes()->GetThreadController()->StopCalculating(); GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en); - GetPrgRes()->GetThreadController()->StartCalculating(); SetMenuLanguage(hWnd); + SetOutputEditLanguage(hWnd); TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) ); - GetPrgRes()->GetThreadController()->StartCalculating(); return true; } @@ -588,13 +693,11 @@ return true; BOOL WmCommand_LanguagePolish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - GetPrgRes()->GetThreadController()->StopCalculating(); GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::pl); - GetPrgRes()->GetThreadController()->StartCalculating(); SetMenuLanguage(hWnd); + SetOutputEditLanguage(hWnd); TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) ); - GetPrgRes()->GetThreadController()->StartCalculating(); return true; } @@ -638,6 +741,7 @@ return command_messages.Call(LOWORD(wParam), hWnd, message, wParam, lParam); } + void CreateMainMessagesTable(Messages & messages) { messages.Associate(WM_INITDIALOG, WmInitDialog); @@ -649,8 +753,10 @@ void CreateMainMessagesTable(Messages & messages) messages.Associate(WM_COMMAND, WmCommand); messages.Associate(WM_NOTIFY, WmNotify); messages.Associate(WM_SIZING, WmSizing); + messages.Associate(WM_SET_LAST_ERROR, WmSetLastError); } + /*! this method prepares a text which is printed on the about dialog box */ diff --git a/src/messages.h b/src/messages.h index 8a63f6b..06f88f0 100644 --- a/src/messages.h +++ b/src/messages.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilemessages #define headerfilemessages @@ -5,15 +42,6 @@ #include - - - - - - - - - class Messages { public: diff --git a/src/parsermanager.cpp b/src/parsermanager.cpp index dd0d43f..14a442c 100644 --- a/src/parsermanager.cpp +++ b/src/parsermanager.cpp @@ -1,10 +1,47 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "parsermanager.h" -ParserManager::ParserManager() : buffer_len(300) +ParserManager::ParserManager() : buffer_len(2048) { buffer = 0; base_input = base_output = 10; @@ -39,6 +76,12 @@ ParserManager::~ParserManager() } +ttmath::ErrorCode ParserManager::GetLastCode() +{ + return code; +} + + ttmath::ErrorCode ParserManager::Parse() { try @@ -141,9 +184,21 @@ void ParserManager::PrintResult() // at the beginning of the program and will never be changed later // by the first thread + // note that we're using a long form of a method ErrorMessage i.g. + // ErrorMessage(Country country, ttmath::ErrorCode code) + // and not ErrorMessage(ttmath::ErrorCode code) + // because someone can change the country when we're calling this method + // (in the main thread) and the latter function would be using its own + // 'current_country' value which could be inconsistent + + // now, displying an error message is making in the main windows + // (after pressing a special key) + + /* SetDlgItemText( GetPrgRes()->GetMainWindow(), IDC_OUTPUT_EDIT, GetPrgRes()->GetLanguages()->ErrorMessage(country, code) ); + */ } } diff --git a/src/parsermanager.h b/src/parsermanager.h index 90bbf79..7be5905 100644 --- a/src/parsermanager.h +++ b/src/parsermanager.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilecalculation #define headerfilecalculation @@ -37,6 +74,12 @@ public: ttmath::ErrorCode Parse(); + /* + it returns the last error code which was during parsing + */ + ttmath::ErrorCode GetLastCode(); + + /*! we call this method directly after when we have left WaitForCalculatingAndBlockForStop() method from the ThreadController diff --git a/src/programresources.cpp b/src/programresources.cpp index 4d3adc0..f2bbd9a 100644 --- a/src/programresources.cpp +++ b/src/programresources.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "programresources.h" @@ -99,9 +136,9 @@ void ProgramResources::SetView(ProgramResources::View v) view = v; if( v == view_normal) - MoveWindow(main_window, x_pos, y_pos, x_size, y_size_normal, true); + MoveWindow(main_window, x_pos, y_pos, x_size, y_size, true); else - MoveWindow(main_window, x_pos, y_pos, y_size, y_size_compact, true); + MoveWindow(main_window, x_pos, y_pos, x_size, y_size_compact, true); } @@ -317,7 +354,10 @@ int ProgramResources::GetPrecision() ProgramResources::ProgramResources() { - buffer_size = 300; + // if you want to change the input buffer you have also to change + // ParserManager::ParserManager() : buffer_len(2048) in parsermanager.cpp + buffer_size = 2048; + buffer = new char[buffer_size]; buffer[0] = 0; @@ -469,7 +509,7 @@ return status; void ProgramResources::SetNameOfConfigurationFile() { static const char simple_file_name[] = "ttcalc.ini"; -static const char simple_directory_name[] = "ttcalc"; +static const char simple_directory_name[] = "TTCalc"; std::string application_data; // if there'll be an error we assume that the current directory will be used @@ -511,7 +551,7 @@ IniParser::Error ProgramResources::ReadFromFile() IniParser iparser; IniParser::Section temp_variables, temp_functions; IniParser::Section::iterator ic; -std::string ini_value[12]; +std::string ini_value[20]; iparser.Associate( "global|always.on.top", &ini_value[0] ); @@ -526,6 +566,7 @@ std::string ini_value[12]; iparser.Associate( "global|disp.alw.scientific", &ini_value[9] ); iparser.Associate( "global|disp.when.scientific", &ini_value[10] ); iparser.Associate( "global|disp.rounding", &ini_value[11] ); + iparser.Associate( "global|size.y", &ini_value[12] ); iparser.Associate( "variables", &temp_variables ); iparser.Associate( "functions", &temp_functions ); @@ -559,6 +600,7 @@ std::string ini_value[12]; x_pos = atoi( ini_value[3].c_str() ); y_pos = atoi( ini_value[4].c_str() ); x_size = atoi( ini_value[5].c_str() ); + y_size = atoi( ini_value[12].c_str() ); SetPrecision( atoi(ini_value[6].c_str()) ); SetBaseInput( atoi(ini_value[7].c_str()) ); @@ -592,6 +634,7 @@ std::ofstream file( configuration_file.c_str() ); file << "x = " << x_pos << std::endl; file << "y = " << y_pos << std::endl; file << "size.x = " << x_size << std::endl; + file << "size.y = " << y_size << std::endl; file << "precision = " << precision << std::endl; file << "disp.input = " << base_input << std::endl; file << "disp.output = " << base_output << std::endl; diff --git a/src/programresources.h b/src/programresources.h index 2f8d887..ab22e98 100644 --- a/src/programresources.h +++ b/src/programresources.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfileprogramresources #define headerfileprogramresources diff --git a/src/resource.h b/src/resource.h index d2bd38c..7d12297 100644 --- a/src/resource.h +++ b/src/resource.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfileresource #define headerfileresource @@ -34,6 +71,9 @@ // (for all dialogs which will be kinds of the tab control) // standard tab + +#define IDC_BUTTON_ERROR 1070 + // values from IDC_BUTTON_PRESS_0 to IDC_BUTTON_PRESS_9 should be with the step equal one #define IDC_BUTTON_PRESS_0 1100 #define IDC_BUTTON_PRESS_1 1101 @@ -68,6 +108,7 @@ #define IDC_BUTTON_ROUND 1130 #define IDC_BUTTON_EXP 1131 + // variables tab #define IDC_VARIABLES_LIST 1132 #define IDC_BUTTON_ADD_VARIABLE 1133 diff --git a/src/resource.rc b/src/resource.rc index 94fb0ac..68c3a02 100644 --- a/src/resource.rc +++ b/src/resource.rc @@ -47,7 +47,7 @@ FONT 8, "MS Sans Serif" BEGIN CONTROL "",1000,"EDIT",ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,0,6,260,14 CONTROL "",1001,"EDIT",ES_READONLY |ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,0,21,260,14 - CONTROL "",1010,"SysTabControl32",WS_CHILD |WS_TABSTOP |WS_VISIBLE ,0,39,261,110 + CONTROL "",1010,"SysTabControl32",WS_CHILD |WS_TABSTOP | WS_VISIBLE ,0,39,261,110, WS_EX_CONTROLPARENT END 102 DIALOG 0, 0, 265, 61 @@ -63,23 +63,24 @@ BEGIN CONTROL "value:",1137,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,7,30,27,8 END -103 DIALOG 0, 0, 265, 73 -STYLE DS_FIXEDSYS |DS_SETFONT |DS_CENTER |WS_POPUP |WS_VISIBLE |WS_THICKFRAME |WS_CAPTION +103 DIALOG DISCARDABLE 0, 0, 273, 73 +STYLE DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_THICKFRAME CAPTION "Add a new function" FONT 8, "Ms Shell Dlg" BEGIN - CONTROL "Ok",1,"BUTTON",BS_DEFPUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,205,10,50,14 - CONTROL "Cancel",2,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,205,28,50,14 - CONTROL "",1144,"EDIT",ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,46,10,67,14 - CONTROL "",1146,"COMBOBOX",CBS_DROPDOWNLIST |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,46,28,67,130 - CONTROL "",1145,"EDIT",ES_AUTOHSCROLL |ES_LEFT |WS_CHILD |WS_BORDER |WS_TABSTOP |WS_VISIBLE ,46,45,147,14 - CONTROL "name:",1147,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,7,12,31,8 - CONTROL "value:",1149,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,7,47,33,8 - CONTROL "param:",1148,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,7,30,33,8 + DEFPUSHBUTTON "Ok",1,205,10,50,14,BS_CENTER | BS_VCENTER + PUSHBUTTON "Cancel",2,205,27,50,14,BS_CENTER | BS_VCENTER + EDITTEXT 1144,46,10,67,14,ES_AUTOHSCROLL + COMBOBOX 1146,46,29,67,130,CBS_DROPDOWNLIST | WS_TABSTOP + EDITTEXT 1145,46,47,210,14,ES_AUTOHSCROLL + LTEXT "name:",1147,7,12,31,8 + LTEXT "value:",1149,7,49,33,8 + LTEXT "param:",1148,7,30,33,8 END 110 DIALOG 0, 0, 287, 90 -STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD +STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD |WS_TABSTOP +EXSTYLE WS_EX_CONTROLPARENT FONT 8, "Ms Shell Dlg" BEGIN CONTROL "Clear",1110,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,3,3,26,14 @@ -114,10 +115,12 @@ BEGIN CONTROL "!",1127,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,189,3,26,14 CONTROL "e",1118,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,229,3,26,14 CONTROL "pi",1119,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,229,20,26,14 + CONTROL "err",1070,"BUTTON",BS_PUSHBUTTON |BS_VCENTER |BS_CENTER |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,229,71,26,14 END 111 DIALOG 0, 0, 287, 90 STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT CAPTION "tab2" FONT 8, "Ms Shell Dlg" BEGIN @@ -129,6 +132,7 @@ END 112 DIALOG 0, 0, 287, 90 STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT CAPTION "tab3" FONT 8, "Ms Shell Dlg" BEGIN @@ -140,19 +144,21 @@ END 113 DIALOG 0, 0, 287, 90 STYLE DS_3DLOOK |DS_FIXEDSYS |DS_SETFONT |WS_CHILD +EXSTYLE WS_EX_CONTROLPARENT CAPTION "tab4" FONT 8, "Ms Shell Dlg" BEGIN CONTROL "precision 1",1150,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,15,4,252,10 - CONTROL "precision 2",1151,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,15,33,252,10 - CONTROL "precision 3",1152,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD |WS_TABSTOP |WS_VISIBLE ,15,62,252,10 - CONTROL "info 1",1153,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,28,17,245,8 - CONTROL "info 2",1154,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,28,46,245,8 - CONTROL "info 3",1155,"STATIC",SS_LEFT |WS_CHILD |WS_GROUP |WS_VISIBLE ,28,74,245,8 + CONTROL "precision 2",1151,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD | WS_VISIBLE ,15,33,252,10 + CONTROL "precision 3",1152,"BUTTON",BS_AUTORADIOBUTTON |BS_LEFT |WS_CHILD | WS_VISIBLE ,15,62,252,10 + CONTROL "info 1",1153,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,17,245,8 + CONTROL "info 2",1154,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,46,245,8 + CONTROL "info 3",1155,"STATIC",SS_LEFT |WS_CHILD |WS_VISIBLE ,28,74,245,8 END 114 DIALOG DISCARDABLE 0, 0, 255, 90 STYLE DS_3DLOOK | DS_FIXEDSYS | WS_CHILD | WS_CAPTION +EXSTYLE WS_EX_CONTROLPARENT CAPTION "tab5" FONT 8, "Ms Shell Dlg" BEGIN @@ -160,15 +166,12 @@ BEGIN COMBOBOX 1157,58,19,63,200,CBS_DROPDOWNLIST | WS_TABSTOP LTEXT "Input",1162,11,7,27,8 LTEXT "Output",1163,11,22,29,8 - CONTROL "Always",1160,"Button",BS_AUTORADIOBUTTON | BS_LEFT | - WS_TABSTOP,19,65,44,10 - CONTROL "When exp greater than:",1161,"Button", - BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,77,65,112,10 LTEXT "Rounding",1164,11,36,43,8 COMBOBOX 1159,58,33,121,200,CBS_DROPDOWNLIST | WS_TABSTOP - CONTROL "",1165,"msctls_updown32",UDS_SETBUDDYINT | - UDS_ALIGNRIGHT | UDS_ARROWKEYS,213,37,11,14 - EDITTEXT 1166,194,63,29,14,ES_NUMBER + CONTROL "Always",1160,"Button",BS_AUTORADIOBUTTON | BS_LEFT | WS_TABSTOP,19,65,44,10 + CONTROL "When exp greater than:",1161,"Button", BS_AUTORADIOBUTTON | BS_LEFT ,77,65,112,10 + EDITTEXT 1166,194,63,29,14,WS_TABSTOP | ES_NUMBER + CONTROL "",1165,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS ,213,37,11,14 GROUPBOX "Print scientific value",1168,11,51,240,31 LTEXT "Digit",1167,227,65,20,8 END diff --git a/src/stopcalculating.h b/src/stopcalculating.h index 1444092..12e9665 100644 --- a/src/stopcalculating.h +++ b/src/stopcalculating.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilestopcalculating #define headerfilestopcalculating diff --git a/src/tabs.cpp b/src/tabs.cpp index 2a70253..a9dd241 100644 --- a/src/tabs.cpp +++ b/src/tabs.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "tabs.h" @@ -9,25 +46,37 @@ int tab_functions; int tab_precision; int tab_display; - -void WpiszTekst(const char * tekst, int cofnac = 0) -{ - SetFocus(GetDlgItem(GetPrgRes()->GetMainWindow(),IDC_INPUT_EDIT)); - - for( ; *tekst ; ++tekst ) - SendDlgItemMessage(GetPrgRes()->GetMainWindow(),IDC_INPUT_EDIT,WM_CHAR,*tekst,0x20001); +ttmath::ErrorCode last_code = ttmath::err_ok; - if(cofnac) + +void PrintErrorCode() +{ + SetDlgItemText(GetPrgRes()->GetMainWindow(),IDC_OUTPUT_EDIT, + GetPrgRes()->GetLanguages()->ErrorMessage(last_code) ); +} + +/* + this functions inserts a given string into the first edit control + and then moves the caret +*/ +void InsertText(const char * text, int move = 0) +{ +HWND input_edit = GetDlgItem( GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT ); + + SetFocus(input_edit); + + SendMessage(input_edit, EM_REPLACESEL, true, (LPARAM)text); + + if( move != 0 ) { DWORD l1,l2; - SendDlgItemMessage(GetPrgRes()->GetMainWindow(),IDC_INPUT_EDIT,EM_GETSEL,(WPARAM)&l1,(LPARAM)&l2); - // l1 bedzie rowne l2 gdyz wczesniej posylalismy WM_CHAR - - SendDlgItemMessage(GetPrgRes()->GetMainWindow(),IDC_INPUT_EDIT,EM_SETSEL,l1+cofnac,l2+cofnac); + SendMessage(input_edit, EM_GETSEL, (WPARAM)&l1, (LPARAM)&l2 ); + SendMessage(input_edit, EM_SETSEL, l1+move, l2+move ); } } + /* a function for WM_COMMAND and LOWORD(wParam) from IDC_BUTTON_PRESS_0 to IDC_BUTTON_PRESS_9 @@ -41,12 +90,9 @@ return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON28 -*/ BOOL WmTabCommand_Press_e(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("e",0); + InsertText("e",0); return true; } @@ -54,171 +100,129 @@ return true; BOOL WmTabCommand_Press_comma(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst(".",0); + InsertText(".",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON27 -*/ BOOL WmTabCommand_Press_pi(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("pi",0); + InsertText("pi",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON10 -*/ BOOL WmTabCommand_Press_sin(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("sin()",-1); + InsertText("sin()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON11 -*/ BOOL WmTabCommand_Press_cos(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("cos()",-1); + InsertText("cos()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON12 -*/ BOOL WmTabCommand_Press_tan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("tan()",-1); + InsertText("tan()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON13 -*/ BOOL WmTabCommand_Press_ctan(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("ctan()",-1); + InsertText("ctan()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON14 -*/ BOOL WmTabCommand_Press_ln(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("ln()",-1); + InsertText("ln()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON24 -*/ BOOL WmTabCommand_Press_log(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("log( ; )",-4); + InsertText("log( ; )",-4); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON26 -*/ BOOL WmTabCommand_Press_abs(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("abs()",-1); + InsertText("abs()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ BOOL WmTabCommand_Press_factorial(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("factorial()",-1); + InsertText("factorial()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + BOOL WmTabCommand_Press_div(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("/", 0); + InsertText("/", 0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ BOOL WmTabCommand_Press_mul(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("*",0); + InsertText("*",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ BOOL WmTabCommand_Press_sub(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("-",0); + InsertText("-",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ BOOL WmTabCommand_Press_add(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("+",0); + InsertText("+",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + + BOOL WmTabCommand_Press_first_bracket(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("(",0); + InsertText("(",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + + BOOL WmTabCommand_Press_last_bracket(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst(")",0); + InsertText(")",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + BOOL WmTabCommand_Press_clear(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { SetDlgItemText(GetPrgRes()->GetMainWindow(), IDC_INPUT_EDIT, ""); @@ -226,48 +230,50 @@ BOOL WmTabCommand_Press_clear(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + +BOOL WmTabCommand_Press_error(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + if( last_code != ttmath::err_ok ) + { + PrintErrorCode(); + } + +return true; +} + + BOOL WmTabCommand_Press_power(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("^",0); + InsertText("^",0); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + + BOOL WmTabCommand_Press_int(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("int()",-1); + InsertText("int()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + + BOOL WmTabCommand_Press_round(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("round()",-1); + InsertText("round()",-1); return true; } -/* - a function for WM_COMMAND and LOWORD(wParam)==IDC_BUTTON25 -*/ + BOOL WmTabCommand_Press_exp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - WpiszTekst("exp()",-1); + InsertText("exp()",-1); return true; } - - - BOOL WmTabCommand_Ok(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int tab = TabCtrl_GetCurSel(GetParent(hWnd)); @@ -310,6 +316,7 @@ void SetLanguageTabVariables(HWND hWnd) ListView_SetColumn(list,1,&column); } + void SetLanguageTabFunctions(HWND hWnd) { SetDlgItemText( hWnd,IDC_BUTTON_ADD_FUNCTION, GetPrgRes()->GetLanguages()->GuiMessage(Languages::button_add) ); @@ -344,6 +351,7 @@ void SetLanguageTabPrecision(HWND hWnd) SetDlgItemText(hWnd, IDC_LABEL_PRECISION_3_INFO, GetPrgRes()->GetLanguages()->GuiMessage(Languages::precision_3_info) ); } + void SetLanguageTabDisplay(HWND hWnd) { char buffer[50]; @@ -430,6 +438,7 @@ BOOL WmTabCommand_SetPrecision1(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return true; } + BOOL WmTabCommand_SetPrecision2(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // there are another messages besides that one @@ -444,6 +453,7 @@ BOOL WmTabCommand_SetPrecision2(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return true; } + BOOL WmTabCommand_SetPrecision3(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { // there are another messages besides that one @@ -458,6 +468,7 @@ BOOL WmTabCommand_SetPrecision3(HWND hWnd, UINT message, WPARAM wParam, LPARAM l return true; } + BOOL WmTabCommand_DisplayInputChanged(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if( HIWORD(wParam) != CBN_SELCHANGE ) @@ -608,6 +619,7 @@ void CreateTabCommandMessagesTable(Messages & cmessages) cmessages.Associate(IDC_BUTTON_ABS, WmTabCommand_Press_abs); cmessages.Associate(IDC_BUTTON_FACTORIAL, WmTabCommand_Press_factorial); + cmessages.Associate(IDC_BUTTON_DIV, WmTabCommand_Press_div); cmessages.Associate(IDC_BUTTON_MUL, WmTabCommand_Press_mul); @@ -617,6 +629,7 @@ void CreateTabCommandMessagesTable(Messages & cmessages) cmessages.Associate(IDC_BUTTON_LAST_BRACKET, WmTabCommand_Press_last_bracket); cmessages.Associate(IDC_BUTTON_CLEAR, WmTabCommand_Press_clear); + cmessages.Associate(IDC_BUTTON_ERROR, WmTabCommand_Press_error); @@ -667,24 +680,9 @@ BOOL WmTabInitDialog(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return true; } -/* -int SetSizeOfList(HWND list) -{ - return 0; - - RECT r1,r2; - GetWindowRect(GetParent(list), &r1); - GetWindowRect(list, &r2); - - int cx = (r1.right - r1.left) - GetSystemMetrics(SM_CXEDGE) - 87; - SetWindowPos(list,0,0,0,cx,r2.bottom-r2.top,SWP_NOOWNERZORDER|SWP_NOMOVE); - -return cx; -} -*/ /*! - this function is enabling or disabling the 'edit' and 'delete' buttons + this function enables or disables the 'edit' and 'delete' buttons on the variable's tab depending on how many variables are selected in the list */ void SetDisablingEditDeleteVariableButtons(HWND hWnd) @@ -707,7 +705,7 @@ int count = ListView_GetSelectedCount(list); /*! - this function is enabling or disabling the 'edit' and 'delete' buttons + this function enables or disables the 'edit' and 'delete' buttons on the function's tab depending on how many variables are selected in the list */ void SetDisablingEditDeleteFunctionButtons(HWND hWnd) @@ -728,6 +726,7 @@ int count = ListView_GetSelectedCount(list); EnableWindow(GetDlgItem(hWnd, IDC_BUTTON_DELETE_FUNCTION), false); } + void FillUpVariableList(HWND list) { // we don't have to block the second thread here @@ -739,6 +738,7 @@ void FillUpVariableList(HWND list) Variables::AddNewItemToVariableList(list, iv->first, iv->second.value); } + void FillUpFunctionList(HWND list) { // we don't have to block the second thread here @@ -871,6 +871,7 @@ char buffer[20]; return true; } + BOOL WmNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { NMHDR * pnmh = (LPNMHDR) lParam; diff --git a/src/tabs.h b/src/tabs.h index 48f8204..9e93e9c 100644 --- a/src/tabs.h +++ b/src/tabs.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfiletabs #define headerfiletabs @@ -20,6 +57,7 @@ #define WM_INIT_TAB_FUNCTIONS WM_APP+1 #define WM_INIT_TAB_PRECISION WM_APP+2 #define WM_INIT_TAB_DISPLAY WM_APP+3 +#define WM_SET_LAST_ERROR WM_APP+4 namespace TabWindowFunctions { @@ -28,7 +66,9 @@ extern int tab_variables; extern int tab_functions; extern int tab_precision; extern int tab_display; +extern ttmath::ErrorCode last_code; + void PrintErrorCode(); BOOL CALLBACK TabWindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); void SetLanguage(HWND hTab); void SetSizeOfVariablesList(); diff --git a/src/threadcontroller.h b/src/threadcontroller.h index cc0fcde..63dfb46 100644 --- a/src/threadcontroller.h +++ b/src/threadcontroller.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilethreadcontroller #define headerfilethreadcontroller diff --git a/src/variables.cpp b/src/variables.cpp index 155a96e..64bd536 100644 --- a/src/variables.cpp +++ b/src/variables.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "tabs.h" diff --git a/src/winmain.cpp b/src/winmain.cpp index 15a89db..a3aac69 100644 --- a/src/winmain.cpp +++ b/src/winmain.cpp @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #include "compileconfig.h" #include "winmain.h" @@ -6,6 +43,8 @@ \brief There's defined the entry point to the application */ +#include + /*! @@ -63,6 +102,7 @@ return static_cast( error_code ); } + /*! the main loop of messages */ @@ -74,12 +114,21 @@ MSG msg; { bool sended = false; + if( msg.message==WM_KEYDOWN && msg.wParam==VK_TAB ) + { + MainWindowFunctions::SetNextFocus(); + sended = true; + } + // firt we try to send our message to dialogs // (the dialogs on the tab control) - for(unsigned int i=0 ; iHowManyTabWindows() && !sended ; ++i) + if( !sended ) { - if( IsDialogMessage(GetPrgRes()->GetTabWindow(i), &msg) ) - sended = true; + for(unsigned int i=0 ; iHowManyTabWindows() && !sended ; ++i) + { + if( IsDialogMessage(GetPrgRes()->GetTabWindow(i), &msg) ) + sended = true; + } } // if it's not a message to any of our dialogs we send it diff --git a/src/winmain.h b/src/winmain.h index bd09497..740ddfb 100644 --- a/src/winmain.h +++ b/src/winmain.h @@ -1,3 +1,40 @@ +/* + * This file is a part of TTCalc - a mathematical calculator + * and is distributed under the (new) BSD licence. + * Author: Tomasz Sowa + */ + +/* + * Copyright (c) 2006-2007, Tomasz Sowa + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name Tomasz Sowa nor the names of contributors to this + * project may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + #ifndef headerfilewinmain #define headerfilewinmain @@ -19,7 +56,6 @@ BOOL CALLBACK MainWindowProc(HWND hWnd, UINT messge, WPARAM wParam, LPARAM lParam); -//DWORD WINAPI CalculationsProcedure(LPVOID lpParameter); unsigned __stdcall CalculationsProcedure(void *); int ShowError( Languages::GuiMsg error_code ); void MainMessagesLoop(); @@ -27,6 +63,7 @@ void MainMessagesLoop(); namespace MainWindowFunctions { + void SetNextFocus(); void CreateMainMessagesTable(Messages & messages); BOOL CALLBACK AboutProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); }