added: new language: Swedish

translation made by: Lars 'Bäfvert' Gäfvert <lars.gafvert at gmail dot com>



git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@188 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2009-09-08 01:24:56 +00:00
parent 783bebc269
commit 8880e87af6
14 changed files with 378 additions and 172 deletions

View File

@@ -58,7 +58,6 @@
typedef ttmath::Big<4,27> TTMathBig3;
typedef TTMathBig3 TTMathBigMax;
#else
/* portable */

View File

@@ -55,8 +55,8 @@
*/
#define TTCALC_MAJOR_VER 0
#define TTCALC_MINOR_VER 8
#define TTCALC_REVISION_VER 6
#define TTCALC_PRERELEASE_VER 0
#define TTCALC_REVISION_VER 7
#define TTCALC_PRERELEASE_VER 1

View File

@@ -109,7 +109,7 @@ void Languages::InitErrorMessagesTab()
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_too_big_factorial,"A too big argument for the factorial() function");
//InsertErrorPair(ttmath::err_too_big_factorial,"A too big argument for the factorial() function");
@@ -143,7 +143,7 @@ void Languages::InitErrorMessagesTab()
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_too_big_factorial,"Zbyt du¿y argument dla funkcji factorial()");
//InsertErrorPair(ttmath::err_too_big_factorial,"Zbyt du¿y argument dla funkcji factorial()");
/*
@@ -176,7 +176,7 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_functions_loop,"Recurrencia entre funciones");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Variables o funciones solo pueden retornar un valor");
InsertErrorPair(ttmath::err_still_calculating,"Calculando ...");
InsertErrorPair(ttmath::err_too_big_factorial,"Argumento muy grande para la funcion factorial()");
//InsertErrorPair(ttmath::err_too_big_factorial,"Argumento muy grande para la funcion factorial()");
/*
@@ -208,7 +208,7 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_functions_loop,"Der er en gentagelse mellem funktioner");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Variabler eller funktioner skal kun returnere én værdi");
InsertErrorPair(ttmath::err_still_calculating,"Regner...");
InsertErrorPair(ttmath::err_too_big_factorial,"Et for stort argument for factorial() funktionen");
//InsertErrorPair(ttmath::err_too_big_factorial,"Et for stort argument for factorial() funktionen");
/*
@@ -240,7 +240,7 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_functions_loop,"º¯ÊýÑ­»·");
InsertErrorPair(ttmath::err_must_be_only_one_value,"±äÁ¿»òº¯Êý±ØÐëÓзµ»ØÖµ");
InsertErrorPair(ttmath::err_still_calculating,"ÕýÔÚ¼ÆËã...");
InsertErrorPair(ttmath::err_too_big_factorial,"½×³Ëº¯ÊýµÄ²ÎÊýÌ«´ó");
//InsertErrorPair(ttmath::err_too_big_factorial,"½×³Ëº¯ÊýµÄ²ÎÊýÌ«´ó");
/*
@@ -272,12 +272,50 @@ void Languages::InitErrorMessagesTab()
InsertErrorPair(ttmath::err_functions_loop,"Ôóíêöèè ðåêóððåíòíû");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Ïåðåìåííûå èëè ôóíêöèè äîëæíû âîçâðàùàòü òîëüêî îäíî çíà÷åíèå");
InsertErrorPair(ttmath::err_still_calculating,"Ïîäñ÷èòûâàåì...");
InsertErrorPair(ttmath::err_too_big_factorial,"Ñëèøêîì áîëüøîé àðãóìåíò äëÿ ôóíêöèè factorial()");
//InsertErrorPair(ttmath::err_too_big_factorial,"Ñëèøêîì áîëüøîé àðãóìåíò äëÿ ôóíêöèè factorial()");
/*
swedish messages relating to ttmath library
*/
error_messages_tab.push_back( std::map<ttmath::ErrorCode, std::string>() );
InsertErrorPair(ttmath::err_ok,"ok");
InsertErrorPair(ttmath::err_nothing_has_read,"");
InsertErrorPair(ttmath::err_unknown_character,"Ett okänt tecken");
InsertErrorPair(ttmath::err_unexpected_final_bracket,"En oförväntat slutlig klass");
InsertErrorPair(ttmath::err_stack_not_clear,"Ett okänt tecken saknas");
InsertErrorPair(ttmath::err_unknown_variable,"En okänd variabel");
InsertErrorPair(ttmath::err_division_by_zero,"Division med noll");
InsertErrorPair(ttmath::err_interrupt,"Beräkningen har avbrutits");
InsertErrorPair(ttmath::err_overflow,"Overflow fel");
InsertErrorPair(ttmath::err_unknown_function,"En okänd funktion");
InsertErrorPair(ttmath::err_unknown_operator,"En okänd operator");
InsertErrorPair(ttmath::err_unexpected_semicolon_operator,"En okänd semikolonoperator");
InsertErrorPair(ttmath::err_improper_amount_of_arguments,"Felaktig mängd argument");
InsertErrorPair(ttmath::err_improper_argument,"Ogiltig argumentation");
InsertErrorPair(ttmath::err_unexpected_end,"Oförväntat fel");
InsertErrorPair(ttmath::err_internal_error,"Ett internt fel");
InsertErrorPair(ttmath::err_incorrect_name,"Ogiltigt namn för en variabel eller funktion");
InsertErrorPair(ttmath::err_incorrect_value,"Ogiltigt värde för en variabel eller funktion");
InsertErrorPair(ttmath::err_variable_exists,"Denna variabel existerar redan");
InsertErrorPair(ttmath::err_variable_loop,"Det är en upprepepning mellan variabler");
InsertErrorPair(ttmath::err_functions_loop,"Det är en upprepning mellan funktioner");
InsertErrorPair(ttmath::err_must_be_only_one_value,"Variabler eller funktioner skall kunna avge ett värde");
InsertErrorPair(ttmath::err_still_calculating,"Räknar bävrar...");
//InsertErrorPair(ttmath::err_too_big_factorial,"Ett för stort argument för factorial() funktionen");
}
// for gui messages
@@ -411,6 +449,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_danish, "&Danish");
InsertGuiPair(menu_view_lang_chinese, "&Chinese");
InsertGuiPair(menu_view_lang_russian, "&Russian");
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
InsertGuiPair(menu_view_close_program, "&Close");
InsertGuiPair(menu_edit_undo, "&Undo");
InsertGuiPair(menu_edit_paste, "&Paste");
@@ -544,6 +583,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_danish, "&Duñski");
InsertGuiPair(menu_view_lang_chinese, "&Chiñski");
InsertGuiPair(menu_view_lang_russian, "&Russian");
InsertGuiPair(menu_view_lang_swedish, "&Szwedzki");
InsertGuiPair(menu_view_close_program, "&Zamknij");
InsertGuiPair(menu_edit_undo, "&Cofnij");
InsertGuiPair(menu_edit_paste, "&Wklej");
@@ -681,6 +721,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_danish, "&Danés"); // 'Danés' is a correct translation for 'Danish'?
InsertGuiPair(menu_view_lang_chinese, "&Chino"); // 'Chino' is a correct translation for 'Chinese'?
InsertGuiPair(menu_view_lang_russian, "&Russian");
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
InsertGuiPair(menu_view_close_program, "&Close");
InsertGuiPair(menu_edit_undo, "&Deshacer");
InsertGuiPair(menu_edit_paste, "&Pegar");
@@ -814,6 +855,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_danish, "&Dansk");
InsertGuiPair(menu_view_lang_chinese, "&Kinesisk"); // 'Kinesisk' is a correct translation for 'Chinese'?
InsertGuiPair(menu_view_lang_russian, "&Russian");
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
InsertGuiPair(menu_view_close_program, "&Afslut");
InsertGuiPair(menu_edit_undo, "&Fortryd");
InsertGuiPair(menu_edit_paste, "&Sæt ind");
@@ -946,6 +988,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_danish, "&µ¤ÂóÓï");
InsertGuiPair(menu_view_lang_chinese, "&¼òÌåÖÐÎÄ");
InsertGuiPair(menu_view_lang_russian, "&Russian");
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
InsertGuiPair(menu_view_close_program, "&¹Ø±Õ");
InsertGuiPair(menu_edit_undo, "&È¡Ïû");
InsertGuiPair(menu_edit_paste, "&Õ³Ìù");
@@ -1076,6 +1119,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(menu_view_lang_danish, "&Äàòñêèé");
InsertGuiPair(menu_view_lang_chinese, "&Êèòàéñêèé");
InsertGuiPair(menu_view_lang_russian, "&Ðóññêèé");
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
InsertGuiPair(menu_view_close_program, "&Çàêðûòü");
InsertGuiPair(menu_edit_undo, "&Îòìåíèòü äåéñòâèå");
InsertGuiPair(menu_edit_paste, "&Âñòàâèòü");
@@ -1120,6 +1164,140 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(cant_find_help, "Íå óäàåòñÿ íàéòè ôàéëû ïîìîùè");
InsertGuiPair(cant_open_project_page, "Íå óäàåòñÿ îòêðûòü ñàéò ïðîåêòà");
/*
swedish gui messages
*/
gui_messages_tab.push_back( std::map<GuiMsg, std::string>() );
InsertGuiPair(button_ok,"Ok");
InsertGuiPair(button_cancel,"Avbryt");
InsertGuiPair(message_box_caption,"TTCalc");
InsertGuiPair(dialog_box_add_variable_caption,"Lägg till en ny variabel");
InsertGuiPair(dialog_box_edit_variable_caption,"Redigera en variabel");
InsertGuiPair(dialog_box_add_variable_incorrect_name,"Ogiltigt namn för variabel");
InsertGuiPair(dialog_box_add_variable_incorrect_value,"Ogiltigt värde för variabel");
InsertGuiPair(dialog_box_add_variable_variable_exists,"Denna variabel finns redan");
InsertGuiPair(dialog_box_edit_variable_unknown_variable,"Denna variabel saknas i tabellen. Förmodligen ett internt fel!");
InsertGuiPair(dialog_box_delete_variable_confirm,"Vill du förgöra dessa variabler?");
InsertGuiPair(dialog_box_variable_not_all_deleted,"Några variabler gick ej att ta kål på. Det måste vara ett internt fel!");
InsertGuiPair(dialog_box_add_function_caption,"Lägg till en ny funktion");
InsertGuiPair(dialog_box_edit_function_caption,"Redigera en funktion");
InsertGuiPair(dialog_box_add_function_function_exists,"Denna funktion finns redan");
InsertGuiPair(dialog_box_edit_function_unknown_function,"Denna funktion saknas i tabellen. Förmodligen ett internt fel!");
InsertGuiPair(dialog_box_delete_function_confirm,"Vill du förgöra dessa funktioner?");
InsertGuiPair(dialog_box_function_not_all_deleted,"Några funktioner gick inte att förgöra. Jag tror vi har att göra med ett internt fel!");
InsertGuiPair(dialog_box_add_function_incorrect_name,"Ogiltigt namn för funktionen");
InsertGuiPair(list_variables_header_1,"Namn");
InsertGuiPair(list_variables_header_2,"Värde");
InsertGuiPair(list_functions_header_1,"Namn");
InsertGuiPair(list_functions_header_2,"Param.");
InsertGuiPair(list_functions_header_3,"Värde");
InsertGuiPair(button_add,"Lägga till");
InsertGuiPair(button_edit,"Redigera");
InsertGuiPair(button_delete,"Förgöra");
InsertGuiPair(button_clear,"C");
InsertGuiPair(tab_standard,"Standard");
InsertGuiPair(tab_variables,"Variabler");
InsertGuiPair(tab_functions,"Funktioner");
InsertGuiPair(tab_precision,"Precision");
InsertGuiPair(tab_display,"Visning");
InsertGuiPair(tab_convert,"Konvertera");
InsertGuiPair(radio_precision_1,"Liten - 96 bitar för mantissan, 32 bitar för exponenten");
InsertGuiPair(radio_precision_2,"Mellan - 288 bitar för mantissan, 64 bitar för exponenten");
InsertGuiPair(radio_precision_3,"Stor - 864 bitar för mantissan, 128 bitar för exponenten");
InsertGuiPair(precision_1_info,"(+/-)6.9 e+646457021, 26 giltiga siffror (decimaler)");
InsertGuiPair(precision_2_info,"(+/-)3.4e+2776511644261678652, 85 giltiga siffror");
InsertGuiPair(precision_3_info,"(+/-)6.7e+51217599719369681875006054625051616609, 258 siffror");
InsertGuiPair(overflow_during_printing,"Overflow under printning");
InsertGuiPair(combo_rounding_none,"Ingen");
InsertGuiPair(combo_rounding_integer,"till heltal");
InsertGuiPair(combo_rounding_to_number,"till");
InsertGuiPair(combo_rounding_after_comma,"siffror(cifre)");
InsertGuiPair(check_remove_zeroes,"Radera sista överflödiga nollor");
InsertGuiPair(display_input, "Input");
InsertGuiPair(display_output, "Output");
InsertGuiPair(display_rounding, "Avrundning");
InsertGuiPair(display_always_scientific,"Alltid");
InsertGuiPair(display_not_always_scientific,"När exponenten är större än:");
InsertGuiPair(display_group_scientific, "Visa resultatet som vetenskapligt värde");
InsertGuiPair(display_decimal_point, "Decimalpunkt");
InsertGuiPair(display_deg_rad_grad, "sin/cos asin/acos");
InsertGuiPair(convert_type, "Type");
InsertGuiPair(convert_input, "Input");
InsertGuiPair(convert_output, "Output");
InsertGuiPair(convert_dynamic_output, "Auto prefix");
InsertGuiPair(menu_view, "&Visa");
InsertGuiPair(menu_edit, "&Redigera");
InsertGuiPair(menu_help, "&Hjälp");
InsertGuiPair(menu_language, "&Språg");
InsertGuiPair(menu_view_new_window, "&Nytt fönster");
InsertGuiPair(menu_view_normal_view, "No&rmal visning");
InsertGuiPair(menu_view_compact_view, "K&ompakt visning");
InsertGuiPair(menu_view_always_on_top, "&Alltid överst");
InsertGuiPair(menu_view_lang_english, "&Engelska");
InsertGuiPair(menu_view_lang_polish, "&Polska");
InsertGuiPair(menu_view_lang_spanish, "&Spanska");
InsertGuiPair(menu_view_lang_danish, "&Danska");
InsertGuiPair(menu_view_lang_chinese, "&Kinesiska"); // 'Kinesisk' is a correct translation for 'Chinese'?
InsertGuiPair(menu_view_lang_russian, "&Ryska");
InsertGuiPair(menu_view_lang_swedish, "&Swedish");
InsertGuiPair(menu_view_close_program, "&Avsluta");
InsertGuiPair(menu_edit_undo, "&Ångra");
InsertGuiPair(menu_edit_paste, "&Klistra in");
InsertGuiPair(menu_edit_copy_result, "&Kopiera result");
InsertGuiPair(menu_help_help, "&Hjälp");
InsertGuiPair(menu_help_project_page, "&Projektsida");
InsertGuiPair(menu_help_about, "&Om");
InsertGuiPair(cant_init_calculations, "Beräkningen kunde inte initieras!");
InsertGuiPair(message_box_error_caption,"TTCalc");
InsertGuiPair(cant_create_thread, "Den andra tråden för uträkning kunde inte skapas");
InsertGuiPair(cant_create_main_window, "Applikationens huvudfönster kunde inte skapas");
InsertGuiPair(cant_init_common_controls,"Inställningarna kunde inte initieras (InitCommonControlsEx)");
InsertGuiPair(about_text,
"Matematisk kalkylator TTCalc %d.%d.%d%s%s\r\n"
"Upphovsman: Tomasz Sowa\r\n"
"Kontakt: t.sowa@ttmath.org\r\n"
"Licens: BSD (open source)\r\n"
"Projektsida: http://ttcalc.sourceforge.net\r\n"
"Bignumbiblotek: TTMath %d.%d.%d%s\r\n"
"Programmeringsspråk: C++\r\n"
"Kompilator: %s\r\n"
"%s" // for upx
"\r\n"
"TTCalc använder sig av TTMath bignum bibloteket"
" som kan hittas här: http://sourceforge.net/projects/ttmath\r\n"
"\r\n"
#ifdef TTCALC_PORTABLE
"Detta är den portabla versionen av TTCalc. I denna version "
"kan du räkna med begränsad precision, dvs (96 bitar för "
"mantissan och 32 bitar för exponenten) det är omkring +/-6.9e+646457021.\r\n"
"\r\n"
#endif
"Har du frågor, goda råd eller interessanta idéer beträffande"
" detta program eller vill du rentav bidra med din kompetens som"
" utvecklare eller programmerare är du välkommen att kontakta upphovsmannen."
);
InsertGuiPair(about_text_portable_version, " transportabel version");
InsertGuiPair(about_text_exe_packer, "EXE Packer: UPX 3.03\r\n");
InsertGuiPair(about_box_title, "Om");
InsertGuiPair(about_box_button_close, "Bäver");
InsertGuiPair(unknown_error, "Det har inträffat ett okänt fel");
InsertGuiPair(cant_find_help, "Kunde inte hitta några hjälpfiler");
InsertGuiPair(cant_open_project_page, "Projektsidan kunde inte öppnas");
}

View File

@@ -121,6 +121,7 @@ public:
menu_view_lang_danish,
menu_view_lang_chinese,
menu_view_lang_russian,
menu_view_lang_swedish,
menu_view_close_program,
menu_edit_undo,
menu_edit_paste,
@@ -149,7 +150,7 @@ public:
// (after conversion to 'int' we pass it into the std::vector)
enum Country
{
en = 0, pl, sp, da, chn, ru
en = 0, pl, sp, da, chn, ru, swe
};

View File

@@ -408,6 +408,7 @@ HMENU menu = GetMenu(hWnd);
SetMenuLanguageItem(menu, IDM_LANGUAGE_DANISH, Languages::menu_view_lang_danish);
SetMenuLanguageItem(menu, IDM_LANGUAGE_CHINESE, Languages::menu_view_lang_chinese);
SetMenuLanguageItem(menu, IDM_LANGUAGE_RUSSIAN, Languages::menu_view_lang_russian);
SetMenuLanguageItem(menu, IDM_LANGUAGE_SWEDISH, Languages::menu_view_lang_swedish);
SetMenuLanguageItem(menu, IDM_CLOSE_PROGRAM, Languages::menu_view_close_program);
SetMenuLanguageItem(menu, IDM_EDIT_UNDO, Languages::menu_edit_undo);
SetMenuLanguageItem(menu, IDM_EDIT_PASTE, Languages::menu_edit_paste);
@@ -772,6 +773,7 @@ void WmInitMenuPopUpView(HMENU menu)
CheckMenuItem(menu, IDM_LANGUAGE_DANISH, MF_BYCOMMAND|MF_UNCHECKED);
CheckMenuItem(menu, IDM_LANGUAGE_CHINESE, MF_BYCOMMAND|MF_UNCHECKED);
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, MF_BYCOMMAND|MF_UNCHECKED);
CheckMenuItem(menu, IDM_LANGUAGE_SWEDISH, MF_BYCOMMAND|MF_UNCHECKED);
Languages::Country lang = GetPrgRes()->GetLanguages()->GetCurrentLanguage();
@@ -792,6 +794,9 @@ void WmInitMenuPopUpView(HMENU menu)
else
if( lang == Languages::ru )
CheckMenuItem(menu, IDM_LANGUAGE_RUSSIAN, MF_BYCOMMAND|MF_CHECKED);
else
if( lang == Languages::swe )
CheckMenuItem(menu, IDM_LANGUAGE_SWEDISH, MF_BYCOMMAND|MF_CHECKED);
}
@@ -1087,6 +1092,16 @@ BOOL WmCommand_LanguageRussian(HWND hWnd, UINT message, WPARAM wParam, LPARAM lP
return true;
}
BOOL WmCommand_LanguageSwedish(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::swe);
SetMenuLanguage(hWnd);
SetOutputEditLanguage(hWnd);
TabWindowFunctions::SetLanguage( GetDlgItem(hWnd, IDC_TAB) );
return true;
}
BOOL WmHelp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@@ -1159,6 +1174,7 @@ void CreateCommandMessagesTable(Messages & cmessages)
cmessages.Associate(IDM_LANGUAGE_DANISH, WmCommand_LanguageDanish);
cmessages.Associate(IDM_LANGUAGE_CHINESE, WmCommand_LanguageChinese);
cmessages.Associate(IDM_LANGUAGE_RUSSIAN, WmCommand_LanguageRussian);
cmessages.Associate(IDM_LANGUAGE_SWEDISH, WmCommand_LanguageSwedish);
cmessages.Associate(IDM_HELP_HELP, WmHelp);
cmessages.Associate(IDM_HELP_PROJECT_PAGE, WmProjectPage);
}

View File

@@ -110,7 +110,6 @@ public:
private:
#ifndef TTCALC_PORTABLE
ttmath::Parser<TTMathBig1> parser1;
ttmath::Parser<TTMathBig2> parser2;
ttmath::Parser<TTMathBig3> parser3;

View File

@@ -803,6 +803,9 @@ std::string ini_value[20];
SetDisplayRounding( atoi(ini_value[11].c_str()) );
SetRemovingZeroes( bool(atoi(ini_value[15].c_str())) );
if( ini_value[13] == "6" )
languages.SetCurrentLanguage(Languages::swe);
else
if( ini_value[13] == "5" )
languages.SetCurrentLanguage(Languages::ru);
else

View File

@@ -198,6 +198,7 @@
#define IDM_LANGUAGE_DANISH 40013
#define IDM_LANGUAGE_CHINESE 40014
#define IDM_LANGUAGE_RUSSIAN 40015
#define IDM_LANGUAGE_SWEDISH 40016
#define IDM_CLOSE_PROGRAM 40020
#define IDM_EDIT_UNDO 40030
#define IDM_EDIT_PASTE 40031

View File

@@ -32,6 +32,7 @@ BEGIN
MENUITEM "&Danish", 40013
MENUITEM "&Chinese", 40014
MENUITEM "&Russian", 40015
MENUITEM "&Swedish", 40016
END
MENUITEM SEPARATOR
MENUITEM "&Close", 40020

View File

@@ -1,159 +1,159 @@
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2008, 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
/*!
\file stopcalculating.h
\brief it tells us whether there was a stop signal or not
*/
#include <ttmath/ttmathtypes.h>
#include <windows.h>
/*!
\brief it tells us whether there was a stop signal or not
we can pass a pointer to the object of this class to the certain
calculating methods especially for the method which calculates the
Factorial (1*2*3*4....), such methods as the Factorial takes a lot of time
and sometimes we want to break the calculations for example when we've got
a new input string
those methods which take a lot of time check the object of type NewStopCalculating
and if there was a stop signal they stop and return immediately without returning
a correct result
the stop signal can be caused by another thread in our case by the first (gui) thread
there'll be only one object of this class
(it'll be as an variable of ThreadController class)
*/
class NewStopCalculating : public ttmath::StopCalculating
{
public:
/*!
the constructor
*/
NewStopCalculating()
{
stop = 0;
}
/*!
the destructor
*/
~NewStopCalculating()
{
if(stop) CloseHandle(stop);
}
/*!
it initializes an object of this class
this method will be called from Init() of the ThreadController object
*/
bool Init() volatile
{
char buffer[80];
// with 'GetTickCount()' we're generating an unique identifier of our event
// (there can be another window of ttcalc)
sprintf(buffer,"TTCalcStopEventForStoppingCalculations7756%u",
(unsigned int)GetTickCount());
// 'stop' will be manual-reseted and initialized as non-signaled
if( (stop = CreateEvent(0,true,false,buffer))==NULL)
return false;
return true;
}
/*!
when we want to stop the calculations for example when the user changed somewhat
we call the Stop() method from the first (gui) thread
*/
void Stop() volatile
{
SetEvent(stop);
}
/*!
when we start the calculations we call this method
(we call it from WaitForCalculatingAndBlockForStop() method of
ThreadController class)
*/
void Start() volatile
{
ResetEvent(stop);
}
/*!
it returns 'true' if there was a stop signal
it's useful for the second thread and functions which take plenty of time
for calculating, when this method returns 'true' those methods break the
calculations and return without returning a correct value
*/
virtual bool WasStopSignal() const volatile
{
if( WaitForSingleObject(stop,0) == WAIT_OBJECT_0 )
return true;
return false;
}
private:
// manual-reset, initialized as non-signaled
HANDLE stop;
};
#endif
/*
* This file is a part of TTCalc - a mathematical calculator
* and is distributed under the (new) BSD licence.
* Author: Tomasz Sowa <t.sowa@slimaczek.pl>
*/
/*
* Copyright (c) 2006-2008, 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
/*!
\file stopcalculating.h
\brief it tells us whether there was a stop signal or not
*/
#include <ttmath/ttmathtypes.h>
#include <windows.h>
/*!
\brief it tells us whether there was a stop signal or not
we can pass a pointer to the object of this class to the certain
calculating methods especially for the method which calculates the
Factorial (1*2*3*4....), such methods as the Factorial takes a lot of time
and sometimes we want to break the calculations for example when we've got
a new input string
those methods which take a lot of time check the object of type NewStopCalculating
and if there was a stop signal they stop and return immediately without returning
a correct result
the stop signal can be caused by another thread in our case by the first (gui) thread
there'll be only one object of this class
(it'll be as an variable of ThreadController class)
*/
class NewStopCalculating : public ttmath::StopCalculating
{
public:
/*!
the constructor
*/
NewStopCalculating()
{
stop = 0;
}
/*!
the destructor
*/
~NewStopCalculating()
{
if(stop) CloseHandle(stop);
}
/*!
it initializes an object of this class
this method will be called from Init() of the ThreadController object
*/
bool Init() volatile
{
char buffer[80];
// with 'GetTickCount()' we're generating an unique identifier of our event
// (there can be another window of ttcalc)
sprintf(buffer,"TTCalcStopEventForStoppingCalculations7756%u",
(unsigned int)GetTickCount());
// 'stop' will be manual-reseted and initialized as non-signaled
if( (stop = CreateEvent(0,true,false,buffer))==NULL)
return false;
return true;
}
/*!
when we want to stop the calculations for example when the user changed somewhat
we call the Stop() method from the first (gui) thread
*/
void Stop() volatile
{
SetEvent(stop);
}
/*!
when we start the calculations we call this method
(we call it from WaitForCalculatingAndBlockForStop() method of
ThreadController class)
*/
void Start() volatile
{
ResetEvent(stop);
}
/*!
it returns 'true' if there was a stop signal
it's useful for the second thread and functions which take plenty of time
for calculating, when this method returns 'true' those methods break the
calculations and return without returning a correct value
*/
virtual bool WasStopSignal() const volatile
{
if( WaitForSingleObject(stop,0) == WAIT_OBJECT_0 )
return true;
return false;
}
private:
// manual-reset, initialized as non-signaled
HANDLE stop;
};
#endif

View File

@@ -44,6 +44,7 @@
*/
#include <string>
#include <ttmath/ttmath.h>
/*!
@@ -194,3 +195,5 @@ static Messages messages;
// so that we have the logarythmic time to find the special function to call
return messages.Call(message, hWnd, message, wParam, lParam);
}