added: the program shows some kind of errors itself

added: checking whether an user inserts a correct value of a variable or a function
added: a last column in the variables' and functions' list is resized into the whole space
fixed: some small artefacts on the bitmap in the about dialog


git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@20 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2007-03-02 20:29:27 +00:00
parent 211f0dada4
commit b51fdddf70
8 changed files with 97 additions and 31 deletions

4
TODO
View File

@ -7,6 +7,6 @@ TODO TTCalc
new computer)
* 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
* To add navigation from the keyboard (in the two lists - funtions and variables)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

After

Width:  |  Height:  |  Size: 143 KiB

View File

@ -177,6 +177,33 @@ char buffer[20];
}
void WmTabCommand_AddFunctionShowError(HWND hWnd, ttmath::ErrorCode error)
{
const char * message;
switch( error )
{
case ttmath::err_object_exists:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_function_exists);
break;
case ttmath::err_incorrect_name:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_incorrect_name);
break;
default:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::unknown_error);
break;
}
MessageBox( hWnd, message,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
}
BOOL WmTabCommand_AddFunction(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
caption = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_caption);
@ -194,17 +221,10 @@ BOOL WmTabCommand_AddFunction(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
code = GetPrgRes()->GetFunctions()->Add(name, value, parameters);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code == ttmath::err_object_exists )
{
MessageBox( hWnd,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_function_function_exists),
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
return true;
}
AddNewItemToFunctionList(list, name, value, parameters);
if( code != ttmath::err_ok )
WmTabCommand_AddFunctionShowError(hWnd, code);
else
AddNewItemToFunctionList(list, name, value, parameters);
}
return true;

View File

@ -195,8 +195,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(dialog_box_add_variable_caption,"Add a new variable");
InsertGuiPair(dialog_box_edit_variable_caption,"Edit a variable");
InsertGuiPair(dialog_box_add_variable_incorrect_name,"Incorrect name of variable");
InsertGuiPair(dialog_box_add_variable_incorrect_value,"Incorrect value of variable");
InsertGuiPair(dialog_box_add_variable_incorrect_name,"An incorrect name of the variable");
InsertGuiPair(dialog_box_add_variable_incorrect_value,"An incorrect value of the variable");
InsertGuiPair(dialog_box_add_variable_variable_exists,"This variable already exists");
InsertGuiPair(dialog_box_edit_variable_unknown_variable,"There isn't this variable in my table. There's probably an internal error!");
InsertGuiPair(dialog_box_delete_variable_confirm,"Are you sure that you want to delete those variables?");
@ -207,6 +207,7 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(dialog_box_edit_function_unknown_function,"There isn't this function in my table. There's probably an internal error!");
InsertGuiPair(dialog_box_delete_function_confirm,"Are you sure that you want to delete those functions?");
InsertGuiPair(dialog_box_function_not_all_deleted,"There are some functions which I was not able to delete. Probably an internal error!");
InsertGuiPair(dialog_box_add_function_incorrect_name,"An incorrect name of the function");
InsertGuiPair(list_variables_header_1,"Name");
InsertGuiPair(list_variables_header_2,"Value");
@ -285,6 +286,7 @@ void Languages::InitGuiMessagesTab()
" the developer or programmer just contact with me."
);
InsertGuiPair(about_box_title, "About");
InsertGuiPair(unknown_error, "An unknown error has occurred");
@ -309,6 +311,8 @@ void Languages::InitGuiMessagesTab()
InsertGuiPair(dialog_box_edit_function_unknown_function,"Podanej funkcji nie ma w tablicy. Prawdopodobnie b³¹d wewnêtrzny programu.");
InsertGuiPair(dialog_box_delete_function_confirm,"Czy napewno usun¹æ zaznaczone funkcje?");
InsertGuiPair(dialog_box_function_not_all_deleted,"Zosta³o kilka funkcji których nie mo¿na by³o skasowaæ. Prawdopodobnie b³¹d wewnêtrzny programu.");
InsertGuiPair(dialog_box_add_function_incorrect_name,"Nieprawid³owa nazwa funkcji");
InsertGuiPair(list_variables_header_1,"Nazwa");
InsertGuiPair(list_variables_header_2,"WartoϾ");
@ -388,6 +392,8 @@ void Languages::InitGuiMessagesTab()
" poprostu skontaktuj siê ze mn¹."
);
InsertGuiPair(about_box_title, "O programie");
InsertGuiPair(unknown_error, "Nieznany kod b³êdu");
}

View File

@ -68,6 +68,7 @@ public:
dialog_box_edit_function_unknown_function,
dialog_box_delete_function_confirm,
dialog_box_function_not_all_deleted,
dialog_box_add_function_incorrect_name,
list_variables_header_1,
list_variables_header_2,
list_functions_header_1,
@ -122,7 +123,8 @@ public:
about_text,
about_box_title,
display_digit,
display_group_scientific
display_group_scientific,
unknown_error
};
// the first item must be with zero index

View File

@ -673,6 +673,13 @@ using TabWindowFunctions::last_code;
EnableWindow(button_err, true);
if( last_code == ttmath::err_unknown_variable ||
last_code == ttmath::err_division_by_zero ||
last_code == ttmath::err_overflow ||
last_code == ttmath::err_unknown_function ||
last_code == ttmath::err_improper_argument )
TabWindowFunctions::PrintErrorCode();
return true;
}

View File

@ -983,7 +983,7 @@ return messages.Call(message, hWnd, message, wParam, lParam);
void SetSizeOfFunctionVariableList(int tab_id, int list_id)
void SetSizeOfFunctionVariableList(int tab_id, int list_id, int last_column)
{
HWND main = GetPrgRes()->GetMainWindow();
HWND tab = GetDlgItem(main, IDC_TAB);
@ -1016,18 +1016,26 @@ RECT r_main, r;
p2.x -= r_main.left;
p2.y -= r_main.top;
ScreenToClient(dialog, &p);
MoveWindow(list, p.x, p.y, cx-p2.x-border_x-2, cy-p2.y-border_y-2, true);
int list_cx = cx-p2.x-border_x-2;
MoveWindow(list, p.x, p.y, list_cx, cy-p2.y-border_y-2, true);
int sum = 0;
for(int i=0 ; i<last_column ; ++i)
sum += ListView_GetColumnWidth(list, i);
if( sum < list_cx - 30 )
ListView_SetColumnWidth(list, last_column, list_cx-sum-10);
}
void SetSizeOfVariablesList()
{
SetSizeOfFunctionVariableList(TabWindowFunctions::tab_variables, IDC_VARIABLES_LIST);
SetSizeOfFunctionVariableList(TabWindowFunctions::tab_variables, IDC_VARIABLES_LIST, 1);
}
void SetSizeOfFunctionsList()
{
SetSizeOfFunctionVariableList(TabWindowFunctions::tab_functions, IDC_FUNCTIONS_LIST);
SetSizeOfFunctionVariableList(TabWindowFunctions::tab_functions, IDC_FUNCTIONS_LIST, 2);
}

View File

@ -62,6 +62,7 @@ char * p;
return string;
}
char * StripWhiteCharacters(char * string)
{
char * start, * end;
@ -73,6 +74,7 @@ char * start, * end;
return start;
}
BOOL CALLBACK DialogProcVariables(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static const int temporary_buffer_size = 200;
@ -174,6 +176,34 @@ ttmath::ErrorCode code;
}
void WmTabCommand_AddVariableShowError(HWND hWnd, ttmath::ErrorCode error)
{
const char * message;
switch( error )
{
case ttmath::err_object_exists:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_variable_variable_exists);
break;
case ttmath::err_incorrect_name:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_variable_incorrect_name);
break;
default:
message = GetPrgRes()->GetLanguages()->GuiMessage(Languages::unknown_error);
break;
}
MessageBox( hWnd, message,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
}
BOOL WmTabCommand_AddVariable(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
caption = GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_variable_caption);
@ -190,17 +220,10 @@ BOOL WmTabCommand_AddVariable(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
code = GetPrgRes()->GetVariables()->Add(name, value);
GetPrgRes()->GetThreadController()->StartCalculating();
if( code == ttmath::err_object_exists )
{
MessageBox( hWnd,
GetPrgRes()->GetLanguages()->GuiMessage(Languages::dialog_box_add_variable_variable_exists),
GetPrgRes()->GetLanguages()->GuiMessage(Languages::message_box_caption),
MB_ICONERROR);
return true;
}
AddNewItemToVariableList(list, name, value);
if( code != ttmath::err_ok )
WmTabCommand_AddVariableShowError(hWnd, code);
else
AddNewItemToVariableList(list, name, value);
}
return true;