partial work on the convert tab
git-svn-id: svn://ttmath.org/publicrep/ttcalc/trunk@53 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
000d884d36
commit
f59f1e1580
|
@ -448,12 +448,12 @@ void Languages::ConvertingAddType(const char * name)
|
||||||
|
|
||||||
void Languages::ConvertingAddUnit(const char * name)
|
void Languages::ConvertingAddUnit(const char * name)
|
||||||
{
|
{
|
||||||
if( converting_type.empty() || converting_unit.empty() )
|
if( converting_type.empty() || converting_type.back().empty() || converting_unit.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ConvUnit temp;
|
ConvUnit temp;
|
||||||
temp.name = name;
|
temp.name = name;
|
||||||
temp.type = static_cast<unsigned int>(converting_type.size()-1);
|
temp.type = static_cast<int>(converting_type.back().size()-1);
|
||||||
|
|
||||||
converting_unit.back().push_back(temp);
|
converting_unit.back().push_back(temp);
|
||||||
}
|
}
|
||||||
|
@ -461,9 +461,6 @@ void Languages::ConvertingAddUnit(const char * name)
|
||||||
|
|
||||||
void Languages::InitConverting()
|
void Languages::InitConverting()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// en
|
// en
|
||||||
converting_type.push_back( std::vector<ConvType>() );
|
converting_type.push_back( std::vector<ConvType>() );
|
||||||
converting_unit.push_back( std::vector<ConvUnit>() );
|
converting_unit.push_back( std::vector<ConvUnit>() );
|
||||||
|
@ -495,7 +492,7 @@ void Languages::InitConverting()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * Languages::ConvertingType(Country country, unsigned int id)
|
const char * Languages::ConvertingType(Country country, int id)
|
||||||
{
|
{
|
||||||
const char * unk_err = "unknown";
|
const char * unk_err = "unknown";
|
||||||
|
|
||||||
|
@ -506,14 +503,14 @@ const char * unk_err = "unknown";
|
||||||
if( cid >= converting_type.size() )
|
if( cid >= converting_type.size() )
|
||||||
return unk_err;
|
return unk_err;
|
||||||
|
|
||||||
if( id >= converting_type[cid].size() )
|
if( id< 0 || id >= static_cast<int>(converting_type[cid].size()) )
|
||||||
return unk_err;
|
return unk_err;
|
||||||
|
|
||||||
return converting_type[cid][id].name.c_str();
|
return converting_type[cid][id].name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * Languages::ConvertingUnit(Country country, unsigned int id)
|
const char * Languages::ConvertingUnit(Country country, int id)
|
||||||
{
|
{
|
||||||
const char * unk_err = "unknown";
|
const char * unk_err = "unknown";
|
||||||
|
|
||||||
|
@ -524,26 +521,26 @@ const char * unk_err = "unknown";
|
||||||
if( cid >= converting_unit.size() )
|
if( cid >= converting_unit.size() )
|
||||||
return unk_err;
|
return unk_err;
|
||||||
|
|
||||||
if( id >= converting_unit[cid].size() )
|
if( id < 0 || id >= static_cast<int>(converting_unit[cid].size()) )
|
||||||
return unk_err;
|
return unk_err;
|
||||||
|
|
||||||
return converting_unit[cid][id].name.c_str();
|
return converting_unit[cid][id].name.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * Languages::ConvertingType(unsigned int id)
|
const char * Languages::ConvertingType(int id)
|
||||||
{
|
{
|
||||||
return ConvertingType(current_country, id);
|
return ConvertingType(current_country, id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * Languages::ConvertingUnit(unsigned int id)
|
const char * Languages::ConvertingUnit(int id)
|
||||||
{
|
{
|
||||||
return ConvertingUnit(current_country, id);
|
return ConvertingUnit(current_country, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int Languages::ConvertingTypeSize(Country country)
|
int Languages::ConvertingTypeSize(Country country)
|
||||||
{
|
{
|
||||||
if( converting_type.empty() )
|
if( converting_type.empty() )
|
||||||
InitConverting();
|
InitConverting();
|
||||||
|
@ -552,11 +549,11 @@ unsigned int Languages::ConvertingTypeSize(Country country)
|
||||||
if( cid >= converting_type.size() )
|
if( cid >= converting_type.size() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return static_cast<unsigned int>(converting_type[cid].size());
|
return static_cast<int>(converting_type[cid].size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int Languages::ConvertingUnitSize(Country country)
|
int Languages::ConvertingUnitSize(Country country)
|
||||||
{
|
{
|
||||||
if( converting_unit.empty() )
|
if( converting_unit.empty() )
|
||||||
InitConverting();
|
InitConverting();
|
||||||
|
@ -565,16 +562,37 @@ unsigned int Languages::ConvertingUnitSize(Country country)
|
||||||
if( cid >= converting_unit.size() )
|
if( cid >= converting_unit.size() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return static_cast<unsigned int>(converting_unit[cid].size());
|
return static_cast<int>(converting_unit[cid].size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int Languages::ConvertingTypeSize()
|
int Languages::ConvertingTypeSize()
|
||||||
{
|
{
|
||||||
return ConvertingTypeSize(current_country);
|
return ConvertingTypeSize(current_country);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int Languages::ConvertingUnitSize()
|
int Languages::ConvertingUnitSize()
|
||||||
{
|
{
|
||||||
return ConvertingUnitSize(current_country);
|
return ConvertingUnitSize(current_country);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int Languages::ConvertingUnitType(Country country, int id)
|
||||||
|
{
|
||||||
|
if( converting_unit.empty() )
|
||||||
|
InitConverting();
|
||||||
|
|
||||||
|
unsigned int cid = static_cast<unsigned int>( country );
|
||||||
|
if( cid >= converting_unit.size() )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if( id >= static_cast<int>(converting_unit[cid].size()) )
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return converting_unit[cid][id].type;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Languages::ConvertingUnitType(int id)
|
||||||
|
{
|
||||||
|
return ConvertingUnitType(current_country, id);
|
||||||
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ public:
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
// int id;
|
// int id;
|
||||||
unsigned int type;
|
int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,14 +203,17 @@ 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 * ConvertingType(Country country, int id);
|
||||||
const char * ConvertingUnit(Country country, unsigned int id);
|
const char * ConvertingUnit(Country country, int id);
|
||||||
unsigned int ConvertingTypeSize(Country country);
|
int ConvertingUnitType(Country country, int id);
|
||||||
unsigned int ConvertingUnitSize(Country country);
|
int ConvertingTypeSize(Country country);
|
||||||
const char * ConvertingType(unsigned int id);
|
int ConvertingUnitSize(Country country);
|
||||||
const char * ConvertingUnit(unsigned int id);
|
|
||||||
unsigned int ConvertingTypeSize();
|
const char * ConvertingType(int id);
|
||||||
unsigned int ConvertingUnitSize();
|
const char * ConvertingUnit(int id);
|
||||||
|
int ConvertingUnitType(int id);
|
||||||
|
int ConvertingTypeSize();
|
||||||
|
int ConvertingUnitSize();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -392,6 +392,7 @@ ProgramResources::ProgramResources()
|
||||||
x_size_min = 0;
|
x_size_min = 0;
|
||||||
|
|
||||||
conv_type = 0;
|
conv_type = 0;
|
||||||
|
ConvUnitCheckAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -722,3 +723,54 @@ int ProgramResources::GetConvType()
|
||||||
return conv_type;
|
return conv_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::ConvUnitCheck(int type)
|
||||||
|
{
|
||||||
|
if( conv_unit[type].input < -1 || conv_unit[type].input >= GetLanguages()->ConvertingUnitSize() )
|
||||||
|
conv_unit[type].input = 0;
|
||||||
|
|
||||||
|
if( conv_unit[type].output < -1 || conv_unit[type].output >= GetLanguages()->ConvertingUnitSize() )
|
||||||
|
conv_unit[type].output = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::ConvUnitCheckAll()
|
||||||
|
{
|
||||||
|
int len = GetLanguages()->ConvertingTypeSize();
|
||||||
|
|
||||||
|
if( static_cast<int>( conv_unit.size() ) != len )
|
||||||
|
conv_unit.resize(len);
|
||||||
|
|
||||||
|
for(int i = 0 ; i<len ; ++i)
|
||||||
|
ConvUnitCheck(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ProgramResources::SetConvUnit(int type, int input, int output)
|
||||||
|
{
|
||||||
|
int len = GetLanguages()->ConvertingTypeSize();
|
||||||
|
|
||||||
|
if( type >= len )
|
||||||
|
return;
|
||||||
|
|
||||||
|
conv_unit[type].input = input;
|
||||||
|
conv_unit[type].output = output;
|
||||||
|
ConvUnitCheck(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ProgramResources::GetConvUnit(int type, int & input, int & output)
|
||||||
|
{
|
||||||
|
int len = GetLanguages()->ConvertingTypeSize();
|
||||||
|
|
||||||
|
if( type >= len )
|
||||||
|
{
|
||||||
|
input = output = -1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
input = conv_unit[type].input;
|
||||||
|
output = conv_unit[type].output;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
#include "threadcontroller.h"
|
#include "threadcontroller.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@ -286,6 +287,8 @@ public:
|
||||||
void SetConvType(int c);
|
void SetConvType(int c);
|
||||||
int GetConvType();
|
int GetConvType();
|
||||||
|
|
||||||
|
void SetConvUnit(int c, int input, int output);
|
||||||
|
bool GetConvUnit(int c, int & input, int & output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -333,6 +336,21 @@ private:
|
||||||
int bad_line;
|
int bad_line;
|
||||||
|
|
||||||
int conv_type;
|
int conv_type;
|
||||||
|
|
||||||
|
struct ConvUnit
|
||||||
|
{
|
||||||
|
int input, output;
|
||||||
|
|
||||||
|
ConvUnit()
|
||||||
|
{
|
||||||
|
input = output = -1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<ConvUnit> conv_unit;
|
||||||
|
|
||||||
|
void ConvUnitCheck(int type);
|
||||||
|
void ConvUnitCheckAll();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -202,18 +202,18 @@ BEGIN
|
||||||
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_SHOWSELALWAYS | LVS_SINGLESEL | 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 "List2a",IDC_LIST_UNIT_INPUT1,"SysListView32",LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT |
|
||||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,80,12,26,56
|
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,80,12,26,56
|
||||||
CONTROL "List3",IDC_LIST_UNIT_INPUT2,"SysListView32",LVS_REPORT |
|
CONTROL "List2b",IDC_LIST_UNIT_INPUT2,"SysListView32",LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT |
|
||||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,109,12,49,56
|
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,109,12,55,56
|
||||||
CONTROL "List4",IDC_LIST_UNIT_OUTPUT1,"SysListView32",LVS_REPORT |
|
CONTROL "List3a",IDC_LIST_UNIT_OUTPUT1,"SysListView32",LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT |
|
||||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,167,12,26,56
|
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,171,12,26,56
|
||||||
CONTROL "List5",IDC_LIST_UNIT_OUTPUT2,"SysListView32",LVS_REPORT |
|
CONTROL "List3b",IDC_LIST_UNIT_OUTPUT2,"SysListView32",LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_REPORT |
|
||||||
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,196,12,60,56
|
LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP,200,12,55,56
|
||||||
EDITTEXT IDC_EDIT_OUTPUT_INFO,3,72,156,14,ES_AUTOHSCROLL |
|
EDITTEXT IDC_EDIT_OUTPUT_INFO,3,72,161,14,ES_AUTOHSCROLL |
|
||||||
ES_READONLY
|
ES_READONLY
|
||||||
CONTROL "dynamically output",IDC_COMBO_DYNAMIC_OUTPUT,"Button",
|
CONTROL "dynamically output",IDC_COMBO_DYNAMIC_OUTPUT,"Button",
|
||||||
BS_AUTOCHECKBOX | WS_TABSTOP,167,74,88,10
|
BS_AUTOCHECKBOX | WS_TABSTOP,172,74,88,10
|
||||||
END
|
END
|
||||||
|
|
||||||
#ifndef TTCALC_PORTABLE
|
#ifndef TTCALC_PORTABLE
|
||||||
|
|
205
src/tabs.cpp
205
src/tabs.cpp
|
@ -461,6 +461,144 @@ return ListView_FindItem(list, -1, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TabConvertFillUpUnitList(HWND list, int conv_type)
|
||||||
|
{
|
||||||
|
Languages * plang = GetPrgRes()->GetLanguages();
|
||||||
|
unsigned int len = plang->ConvertingUnitSize();
|
||||||
|
unsigned int i, index;
|
||||||
|
|
||||||
|
ListView_DeleteAllItems(list);
|
||||||
|
|
||||||
|
LVITEM item;
|
||||||
|
item.mask = LVIF_PARAM | LVIF_TEXT;
|
||||||
|
item.iSubItem = 0;
|
||||||
|
|
||||||
|
for( i=index=0 ; i<len ; ++i )
|
||||||
|
{
|
||||||
|
if( plang->ConvertingUnitType(i) == conv_type )
|
||||||
|
{
|
||||||
|
item.lParam = i;
|
||||||
|
item.iItem = index++;
|
||||||
|
item.pszText = const_cast<char*>(plang->ConvertingUnit(i));
|
||||||
|
|
||||||
|
ListView_InsertItem(list, &item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TabConvertFillUpUnitLists(HWND hWnd)
|
||||||
|
{
|
||||||
|
HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
||||||
|
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||||
|
int input, output;
|
||||||
|
|
||||||
|
int convtype = GetPrgRes()->GetConvType();
|
||||||
|
|
||||||
|
TabConvertFillUpUnitList(list2b, convtype);
|
||||||
|
TabConvertFillUpUnitList(list3b, convtype);
|
||||||
|
GetPrgRes()->GetConvUnit( convtype, input, output);
|
||||||
|
|
||||||
|
if( input >= 0 )
|
||||||
|
{
|
||||||
|
int i = FindItem(list2b, input);
|
||||||
|
|
||||||
|
if( i >= 0 )
|
||||||
|
ListView_SetItemState(list2b, i, LVIS_SELECTED, LVIS_SELECTED); //LVIS_FOCUSED
|
||||||
|
}
|
||||||
|
|
||||||
|
if( output >= 0 )
|
||||||
|
{
|
||||||
|
int i = FindItem(list3b, output);
|
||||||
|
|
||||||
|
if( i>=0 )
|
||||||
|
ListView_SetItemState(list3b, i, LVIS_SELECTED, LVIS_SELECTED); //LVIS_FOCUSED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
we must check whether the item id is really selected
|
||||||
|
(this method is called from WM_NOTIFY and can be another states on the item)
|
||||||
|
*/
|
||||||
|
void TabConvertTypeChanged(HWND hWnd, int id)
|
||||||
|
{
|
||||||
|
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||||
|
|
||||||
|
if( ListView_GetItemState(list1, id, LVIS_SELECTED | LVIS_FOCUSED) != (LVIS_SELECTED | LVIS_FOCUSED) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
// the item is selected now
|
||||||
|
LVITEM item;
|
||||||
|
item.iItem = id;
|
||||||
|
item.iSubItem = 0;
|
||||||
|
item.mask = LVIF_PARAM;
|
||||||
|
if( !ListView_GetItem(list1, &item) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
GetPrgRes()->SetConvType( (int)item.lParam );
|
||||||
|
TabConvertFillUpUnitLists(hWnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
we must check whether the item id is really selected
|
||||||
|
(this method is called from WM_NOTIFY and can be another states on the item)
|
||||||
|
*/
|
||||||
|
void TabConvertUnitInputChanged(HWND hWnd, int id)
|
||||||
|
{
|
||||||
|
HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
||||||
|
|
||||||
|
if( ListView_GetItemState(list2b, id, LVIS_SELECTED | LVIS_FOCUSED) != (LVIS_SELECTED | LVIS_FOCUSED) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// the item is selected
|
||||||
|
LVITEM item;
|
||||||
|
item.iItem = id;
|
||||||
|
item.iSubItem = 0;
|
||||||
|
item.mask = LVIF_PARAM;
|
||||||
|
if( !ListView_GetItem(list2b, &item) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int convtype = GetPrgRes()->GetConvType();
|
||||||
|
int input, output;
|
||||||
|
GetPrgRes()->GetConvUnit(convtype, input, output);
|
||||||
|
GetPrgRes()->SetConvUnit(convtype, (int)item.lParam, output );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
we must check whether the item id is really selected
|
||||||
|
(this method is called from WM_NOTIFY and can be another states on the item)
|
||||||
|
*/
|
||||||
|
void TabConvertUnitOutputChanged(HWND hWnd, int id)
|
||||||
|
{
|
||||||
|
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||||
|
|
||||||
|
if( ListView_GetItemState(list3b, id, LVIS_SELECTED | LVIS_FOCUSED) != (LVIS_SELECTED | LVIS_FOCUSED) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
// the item is selected
|
||||||
|
LVITEM item;
|
||||||
|
item.iItem = id;
|
||||||
|
item.iSubItem = 0;
|
||||||
|
item.mask = LVIF_PARAM;
|
||||||
|
if( !ListView_GetItem(list3b, &item) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
int convtype = GetPrgRes()->GetConvType();
|
||||||
|
int input, output;
|
||||||
|
GetPrgRes()->GetConvUnit(convtype, input, output);
|
||||||
|
GetPrgRes()->SetConvUnit(convtype, input, (int)item.lParam );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void SetLanguageTabConvert(HWND hWnd)
|
void SetLanguageTabConvert(HWND hWnd)
|
||||||
{
|
{
|
||||||
Languages * plang = GetPrgRes()->GetLanguages();
|
Languages * plang = GetPrgRes()->GetLanguages();
|
||||||
|
@ -475,16 +613,16 @@ Languages * plang = GetPrgRes()->GetLanguages();
|
||||||
ListView_DeleteAllItems(list1);
|
ListView_DeleteAllItems(list1);
|
||||||
|
|
||||||
LVITEM item;
|
LVITEM item;
|
||||||
item.mask = LVIF_PARAM | LVIF_TEXT;
|
item.mask = LVIF_PARAM | LVIF_TEXT;
|
||||||
item.iSubItem = 0;
|
item.iSubItem = 0;
|
||||||
|
|
||||||
unsigned int conv_type_size = plang->ConvertingTypeSize();
|
unsigned int conv_type_size = plang->ConvertingTypeSize();
|
||||||
|
|
||||||
for(unsigned int i = 0 ; i<conv_type_size ; ++i)
|
for(unsigned int i = 0 ; i<conv_type_size ; ++i)
|
||||||
{
|
{
|
||||||
item.lParam = i;
|
item.lParam = i;
|
||||||
item.iItem = i;
|
item.iItem = i;
|
||||||
item.pszText = const_cast<char*>(plang->ConvertingType(i));
|
item.pszText = const_cast<char*>(plang->ConvertingType(i));
|
||||||
|
|
||||||
ListView_InsertItem(list1, &item);
|
ListView_InsertItem(list1, &item);
|
||||||
}
|
}
|
||||||
|
@ -492,6 +630,7 @@ Languages * plang = GetPrgRes()->GetLanguages();
|
||||||
int type = FindItem(list1, GetPrgRes()->GetConvType() );
|
int type = FindItem(list1, GetPrgRes()->GetConvType() );
|
||||||
if( type != -1 )
|
if( type != -1 )
|
||||||
ListView_SetItemState(list1, type, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
ListView_SetItemState(list1, type, LVIS_FOCUSED|LVIS_SELECTED, LVIS_FOCUSED|LVIS_SELECTED);
|
||||||
|
// there'll be generated wm_notify message and the next lists will be changed then
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -796,6 +935,9 @@ void CreateTabCommandMessagesTable(Messages & cmessages)
|
||||||
cmessages.Associate(IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayNotAlwaysScientific);
|
cmessages.Associate(IDC_RADIO_DISPLAY_NOT_ALWAYS_SCIENTIFIC, WmTabCommand_SetDisplayNotAlwaysScientific);
|
||||||
cmessages.Associate(IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, WmTabCommand_SetDisplayWhenScientific);
|
cmessages.Associate(IDC_EDIT_DISPLAY_WHEN_SCIENTIFIC, WmTabCommand_SetDisplayWhenScientific);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1058,17 +1200,26 @@ 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);
|
HWND list1 = GetDlgItem(hWnd, IDC_LIST_UNIT_TYPE);
|
||||||
|
HWND list2b = GetDlgItem(hWnd, IDC_LIST_UNIT_INPUT2);
|
||||||
|
HWND list3b = GetDlgItem(hWnd, IDC_LIST_UNIT_OUTPUT2);
|
||||||
|
|
||||||
ListView_SetExtendedListViewStyle(list1, LVS_EX_FULLROWSELECT);
|
ListView_SetExtendedListViewStyle(list1, LVS_EX_FULLROWSELECT);
|
||||||
|
ListView_SetExtendedListViewStyle(list2b, LVS_EX_FULLROWSELECT);
|
||||||
|
ListView_SetExtendedListViewStyle(list3b, LVS_EX_FULLROWSELECT);
|
||||||
|
|
||||||
LVCOLUMN col;
|
LVCOLUMN col;
|
||||||
|
|
||||||
col.mask = LVCF_FMT | LVCF_WIDTH;
|
col.mask = LVCF_FMT | LVCF_WIDTH;
|
||||||
col.fmt = LVCFMT_LEFT;
|
col.fmt = LVCFMT_LEFT;
|
||||||
col.cx = 90;
|
|
||||||
|
|
||||||
|
col.cx = 90;
|
||||||
ListView_InsertColumn(list1, 0, &col);
|
ListView_InsertColumn(list1, 0, &col);
|
||||||
|
|
||||||
|
col.cx = 70;
|
||||||
|
ListView_InsertColumn(list2b, 0, &col);
|
||||||
|
|
||||||
|
col.cx = 70;
|
||||||
|
ListView_InsertColumn(list3b, 0, &col);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1076,9 +1227,14 @@ return true;
|
||||||
|
|
||||||
BOOL WmNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
BOOL WmNotify(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
NMHDR * pnmh = (LPNMHDR) lParam;
|
NMHDR * pnmh = (LPNMHDR) lParam;
|
||||||
HWND var_list = GetDlgItem(hWnd,IDC_VARIABLES_LIST);
|
HWND var_list = GetDlgItem(hWnd,IDC_VARIABLES_LIST);
|
||||||
HWND fun_list = GetDlgItem(hWnd,IDC_FUNCTIONS_LIST);
|
HWND fun_list = GetDlgItem(hWnd,IDC_FUNCTIONS_LIST);
|
||||||
|
HWND conv_list1 = GetDlgItem(hWnd,IDC_LIST_UNIT_TYPE);
|
||||||
|
HWND conv_list2b = GetDlgItem(hWnd,IDC_LIST_UNIT_INPUT2);
|
||||||
|
HWND conv_list3b = GetDlgItem(hWnd,IDC_LIST_UNIT_OUTPUT2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( pnmh->hwndFrom == var_list )
|
if( pnmh->hwndFrom == var_list )
|
||||||
{
|
{
|
||||||
|
@ -1127,6 +1283,27 @@ HWND fun_list = GetDlgItem(hWnd,IDC_FUNCTIONS_LIST);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if( pnmh->hwndFrom==conv_list1 || pnmh->hwndFrom==conv_list2b || pnmh->hwndFrom==conv_list3b )
|
||||||
|
{
|
||||||
|
if( pnmh->code == LVN_ITEMCHANGED )
|
||||||
|
{
|
||||||
|
NMLISTVIEW * pnmv = (NMLISTVIEW*) lParam;
|
||||||
|
|
||||||
|
if( pnmv->iItem != -1 )
|
||||||
|
{
|
||||||
|
if( pnmh->hwndFrom == conv_list1 )
|
||||||
|
TabConvertTypeChanged(hWnd, pnmv->iItem);
|
||||||
|
if( pnmh->hwndFrom == conv_list2b )
|
||||||
|
TabConvertUnitInputChanged(hWnd, pnmv->iItem);
|
||||||
|
else
|
||||||
|
if( pnmh->hwndFrom == conv_list3b )
|
||||||
|
TabConvertUnitOutputChanged(hWnd, pnmv->iItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
GetPrgRes()->GetLanguages()->SetCurrentLanguage(Languages::en);
|
||||||
GetPrgRes()->SetNameOfConfigurationFile();
|
GetPrgRes()->SetNameOfConfigurationFile();
|
||||||
GetPrgRes()->ReadFromFile();
|
GetPrgRes()->ReadFromFile();
|
||||||
|
|
||||||
INITCOMMONCONTROLSEX common_ctrl;
|
INITCOMMONCONTROLSEX common_ctrl;
|
||||||
common_ctrl.dwSize = sizeof(common_ctrl);
|
common_ctrl.dwSize = sizeof(common_ctrl);
|
||||||
common_ctrl.dwICC = ICC_WIN95_CLASSES;
|
common_ctrl.dwICC = ICC_WIN95_CLASSES;
|
||||||
|
@ -76,7 +76,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
||||||
if( !GetPrgRes()->GetMainWindow() )
|
if( !GetPrgRes()->GetMainWindow() )
|
||||||
return ShowError( Languages::cant_create_main_window );
|
return ShowError( Languages::cant_create_main_window );
|
||||||
|
|
||||||
|
|
||||||
// there's the main loop of messages here
|
// there's the main loop of messages here
|
||||||
MainMessagesLoop();
|
MainMessagesLoop();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue