partial work on the converting tab
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@52 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
758d881510
commit
000d884d36
|
@ -432,3 +432,149 @@ void Languages::InitGuiMessagesTab()
|
||||||
InsertGuiPair(cant_open_project_page, "Nie mogę otworzyć strony projektu");
|
InsertGuiPair(cant_open_project_page, "Nie mogę otworzyć strony projektu");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Languages::ConvertingAddType(const char * name)
|
||||||
|
{
|
||||||
|
if( converting_type.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
ConvType temp;
|
||||||
|
temp.name = name;
|
||||||
|
|
||||||
|
converting_type.back().push_back(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Languages::ConvertingAddUnit(const char * name)
|
||||||
|
{
|
||||||
|
if( converting_type.empty() || converting_unit.empty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
ConvUnit temp;
|
||||||
|
temp.name = name;
|
||||||
|
temp.type = static_cast<unsigned int>(converting_type.size()-1);
|
||||||
|
|
||||||
|
converting_unit.back().push_back(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Languages::InitConverting()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// en
|
||||||
|
converting_type.push_back( std::vector<ConvType>() );
|
||||||
|
converting_unit.push_back( std::vector<ConvUnit>() );
|
||||||
|
|
||||||
|
ConvertingAddType("none");
|
||||||
|
|
||||||
|
ConvertingAddType("length");
|
||||||
|
ConvertingAddUnit("metre");
|
||||||
|
ConvertingAddUnit("mile");
|
||||||
|
|
||||||
|
ConvertingAddType("area");
|
||||||
|
ConvertingAddUnit("are");
|
||||||
|
ConvertingAddUnit("square metre");
|
||||||
|
|
||||||
|
|
||||||
|
// pl
|
||||||
|
converting_type.push_back( std::vector<ConvType>() );
|
||||||
|
converting_unit.push_back( std::vector<ConvUnit>() );
|
||||||
|
|
||||||
|
ConvertingAddType("brak");
|
||||||
|
|
||||||
|
ConvertingAddType("d³ugoœæ");
|
||||||
|
ConvertingAddUnit("metr");
|
||||||
|
ConvertingAddUnit("mila");
|
||||||
|
|
||||||
|
ConvertingAddType("obszar");
|
||||||
|
ConvertingAddUnit("ar");
|
||||||
|
ConvertingAddUnit("metr kwadratowy");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char * Languages::ConvertingType(Country country, unsigned int id)
|
||||||
|
{
|
||||||
|
const char * unk_err = "unknown";
|
||||||
|
|
||||||
|
if( converting_type.empty() )
|
||||||
|
InitConverting();
|
||||||
|
|
||||||
|
unsigned int cid = static_cast<unsigned int>( country );
|
||||||
|
if( cid >= converting_type.size() )
|
||||||
|
return unk_err;
|
||||||
|
|
||||||
|
if( id >= converting_type[cid].size() )
|
||||||
|
return unk_err;
|
||||||
|
|
||||||
|
return converting_type[cid][id].name.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char * Languages::ConvertingUnit(Country country, unsigned int id)
|
||||||
|
{
|
||||||
|
const char * unk_err = "unknown";
|
||||||
|
|
||||||
|
if( converting_unit.empty() )
|
||||||
|
InitConverting();
|
||||||
|
|
||||||
|
unsigned int cid = static_cast<unsigned int>( country );
|
||||||
|
if( cid >= converting_unit.size() )
|
||||||
|
return unk_err;
|
||||||
|
|
||||||
|
if( id >= converting_unit[cid].size() )
|
||||||
|
return unk_err;
|
||||||
|
|
||||||
|
return converting_unit[cid][id].name.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char * Languages::ConvertingType(unsigned int id)
|
||||||
|
{
|
||||||
|
return ConvertingType(current_country, id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const char * Languages::ConvertingUnit(unsigned int id)
|
||||||
|
{
|
||||||
|
return ConvertingUnit(current_country, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int Languages::ConvertingTypeSize(Country country)
|
||||||
|
{
|
||||||
|
if( converting_type.empty() )
|
||||||
|
InitConverting();
|
||||||
|
|
||||||
|
unsigned int cid = static_cast<unsigned int>( country );
|
||||||
|
if( cid >= converting_type.size() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return static_cast<unsigned int>(converting_type[cid].size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int Languages::ConvertingUnitSize(Country country)
|
||||||
|
{
|
||||||
|
if( converting_unit.empty() )
|
||||||
|
InitConverting();
|
||||||
|
|
||||||
|
unsigned int cid = static_cast<unsigned int>( country );
|
||||||
|
if( cid >= converting_unit.size() )
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return static_cast<unsigned int>(converting_unit[cid].size());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int Languages::ConvertingTypeSize()
|
||||||
|
{
|
||||||
|
return ConvertingTypeSize(current_country);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int Languages::ConvertingUnitSize()
|
||||||
|
{
|
||||||
|
return ConvertingUnitSize(current_country);
|
||||||
|
}
|
||||||
|
|
|
@ -146,6 +146,20 @@ public:
|
||||||
en = 0, pl
|
en = 0, pl
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ConvType
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
// int id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ConvUnit
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
// int id;
|
||||||
|
unsigned int type;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Country current_country;
|
Country current_country;
|
||||||
|
@ -159,10 +173,16 @@ private:
|
||||||
void InsertGuiPair(GuiMsg code, const char * message);
|
void InsertGuiPair(GuiMsg code, const char * message);
|
||||||
void InitGuiMessagesTab();
|
void InitGuiMessagesTab();
|
||||||
|
|
||||||
|
std::vector<std::vector<ConvType> > converting_type;
|
||||||
|
std::vector<std::vector<ConvUnit> > converting_unit;
|
||||||
|
|
||||||
|
void ConvertingAddType(const char * name);
|
||||||
|
void ConvertingAddUnit(const char * name);
|
||||||
|
|
||||||
|
void InitConverting();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Languages()
|
Languages()
|
||||||
{
|
{
|
||||||
current_country = en;
|
current_country = en;
|
||||||
|
@ -183,6 +203,15 @@ public:
|
||||||
const char * GuiMessage(Country country, GuiMsg code);
|
const char * GuiMessage(Country country, GuiMsg code);
|
||||||
const char * GuiMessage(GuiMsg code);
|
const char * GuiMessage(GuiMsg code);
|
||||||
|
|
||||||
|
const char * ConvertingType(Country country, unsigned int id);
|
||||||
|
const char * ConvertingUnit(Country country, unsigned int id);
|
||||||
|
unsigned int ConvertingTypeSize(Country country);
|
||||||
|
unsigned int ConvertingUnitSize(Country country);
|
||||||
|
const char * ConvertingType(unsigned int id);
|
||||||
|
const char * ConvertingUnit(unsigned int id);
|
||||||
|
unsigned int ConvertingTypeSize();
|
||||||
|
unsigned int ConvertingUnitSize();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -390,6 +390,8 @@ ProgramResources::ProgramResources()
|
||||||
y_size_normal = 0;
|
y_size_normal = 0;
|
||||||
y_size_compact = 0;
|
y_size_compact = 0;
|
||||||
x_size_min = 0;
|
x_size_min = 0;
|
||||||
|
|
||||||
|
conv_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -574,6 +576,9 @@ void ProgramResources::CheckCoordinates()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IniParser::Error ProgramResources::ReadFromFile()
|
IniParser::Error ProgramResources::ReadFromFile()
|
||||||
{
|
{
|
||||||
IniParser iparser;
|
IniParser iparser;
|
||||||
|
@ -706,4 +711,14 @@ int ProgramResources::GetBadLine()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetConvType(int c)
|
||||||
|
{
|
||||||
|
conv_type = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int ProgramResources::GetConvType()
|
||||||
|
{
|
||||||
|
return conv_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -268,12 +268,25 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
it returns a number of line where there was an error
|
it returns a number of a line where there was an error
|
||||||
during last parsing
|
during last parsing
|
||||||
*/
|
*/
|
||||||
int GetBadLine();
|
int GetBadLine();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
these methods set and return the kind of conversion which should be performed
|
||||||
|
|
||||||
|
0 - none
|
||||||
|
1 - ...
|
||||||
|
2 - ...
|
||||||
|
*/
|
||||||
|
void SetConvType(int c);
|
||||||
|
int GetConvType();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool IsWhiteCharacter(int c);
|
bool IsWhiteCharacter(int c);
|
||||||
|
@ -318,6 +331,8 @@ private:
|
||||||
int display_rounding;
|
int display_rounding;
|
||||||
|
|
||||||
int bad_line;
|
int bad_line;
|
||||||
|
|
||||||
|
int conv_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -200,7 +200,7 @@ BEGIN
|
||||||
LTEXT "Conversion type",IDC_STATIC_UNIT_CONVERSION,3,2,63,8
|
LTEXT "Conversion type",IDC_STATIC_UNIT_CONVERSION,3,2,63,8
|
||||||
LTEXT "Input",IDC_STATIC_UNIT_INPUT,80,2,73,8
|
LTEXT "Input",IDC_STATIC_UNIT_INPUT,80,2,73,8
|
||||||
LTEXT "Output",IDC_STATIC_UNIT_OUTPUT,167,2,80,8
|
LTEXT "Output",IDC_STATIC_UNIT_OUTPUT,167,2,80,8
|
||||||
CONTROL "List1",IDC_LIST_UNIT_TYPE,"SysListView32",LVS_REPORT |
|
CONTROL "List1",IDC_LIST_UNIT_TYPE,"SysListView32",LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT |
|
||||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,3,12,67,56
|
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,3,12,67,56
|
||||||
CONTROL "List2",IDC_LIST_UNIT_INPUT1,"SysListView32",LVS_REPORT |
|
CONTROL "List2",IDC_LIST_UNIT_INPUT1,"SysListView32",LVS_REPORT |
|
||||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,80,12,26,56
|
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,80,12,26,56
|
||||||
|
|
49
src/tabs.cpp
49
src/tabs.cpp
|
@ -446,6 +446,21 @@ int i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
|
||||||
|
-1 if there's no such item
|
||||||
|
*/
|
||||||
|
int FindItem(HWND list, int i)
|
||||||
|
{
|
||||||
|
LVFINDINFO info;
|
||||||
|
|
||||||
|
info.flags = LVFI_PARAM;
|
||||||
|
info.lParam = i;
|
||||||
|
|
||||||
|
return ListView_FindItem(list, -1, &info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetLanguageTabConvert(HWND hWnd)
|
void SetLanguageTabConvert(HWND hWnd)
|
||||||
{
|
{
|
||||||
Languages * plang = GetPrgRes()->GetLanguages();
|
Languages * plang = GetPrgRes()->GetLanguages();
|
||||||
|
@ -454,8 +469,32 @@ Languages * plang = GetPrgRes()->GetLanguages();
|
||||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_INPUT, plang->GuiMessage(Languages::convert_input) );
|
SetDlgItemText(hWnd, IDC_STATIC_UNIT_INPUT, plang->GuiMessage(Languages::convert_input) );
|
||||||
SetDlgItemText(hWnd, IDC_STATIC_UNIT_OUTPUT, plang->GuiMessage(Languages::convert_output) );
|
SetDlgItemText(hWnd, IDC_STATIC_UNIT_OUTPUT, plang->GuiMessage(Languages::convert_output) );
|
||||||
SetDlgItemText(hWnd, IDC_COMBO_DYNAMIC_OUTPUT, plang->GuiMessage(Languages::convert_dynamic_output) );
|
SetDlgItemText(hWnd, IDC_COMBO_DYNAMIC_OUTPUT, plang->GuiMessage(Languages::convert_dynamic_output) );
|
||||||
|
|
||||||
|
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||||
|
|
||||||
|
ListView_DeleteAllItems(list1);
|
||||||
|
|
||||||
|
LVITEM item;
|
||||||
|
item.mask = LVIF_PARAM | LVIF_TEXT;
|
||||||
|
item.iSubItem = 0;
|
||||||
|
|
||||||
|
unsigned int conv_type_size = plang->ConvertingTypeSize();
|
||||||
|
|
||||||
|
for(unsigned int i = 0 ; i<conv_type_size ; ++i)
|
||||||
|
{
|
||||||
|
item.lParam = i;
|
||||||
|
item.iItem = i;
|
||||||
|
item.pszText = const_cast<char*>(plang->ConvertingType(i));
|
||||||
|
|
||||||
|
ListView_InsertItem(list1, &item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int type = FindItem(list1, GetPrgRes()->GetConvType() );
|
||||||
|
if( type != -1 )
|
||||||
|
ListView_SetItemState(list1, type, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SetLanguage(HWND hTab)
|
void SetLanguage(HWND hTab)
|
||||||
|
@ -1014,13 +1053,21 @@ char buffer[20];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BOOL WmInitTabConvert(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmInitTabConvert(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||||
|
|
||||||
|
ListView_SetExtendedListViewStyle(list1, LVS_EX_FULLROWSELECT);
|
||||||
|
|
||||||
|
LVCOLUMN col;
|
||||||
|
|
||||||
|
col.mask = LVCF_FMT | LVCF_WIDTH;
|
||||||
|
col.fmt = LVCFMT_LEFT;
|
||||||
|
col.cx = 90;
|
||||||
|
|
||||||
|
ListView_InsertColumn(list1, 0, &col);
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -99,4 +99,6 @@ extern ttmath::ErrorCode last_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
using TabWindowFunctions::Variables::GetSelectedItem;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue