Commit dd94038e authored by lcgamboa's avatar lcgamboa

chg: Code refactor - Fix Spin and Combo events !minor

parent e54291ef
......@@ -2,5 +2,5 @@ PACKAGE=picsimlab
MAINVER=0
MINORVER=9
VERSION=0.9.1
DATE=240131
DATE=240201
VERSION_STABLE=0.9.1
......@@ -35,14 +35,18 @@ enum PICSimLabWPropAction {
WPA_COMBOSETITEMS,
WPA_COMBOSETTEXT,
WPA_COMBOGETTEXT,
WPA_COMBOENABLEEV,
WPA_SPINDSETMAX,
WPA_SPINDSETMIN,
WPA_SPINDSETVALUE,
WPA_SPINDGETVALUE,
WPA_SPINSETMAX,
WPA_SPINSETMIN,
WPA_SPINSETVALUE,
WPA_SPINGETVALUE,
WPA_SPINENABLEEV,
WPA_TEXTCLEAR,
WPA_TEXTADDLINE,
......
......@@ -640,6 +640,8 @@ void cpart_keypad::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("combo11", WPA_COMBOSETTEXT, "DOWN");
SpareParts.WPropCmd("combo12", WPA_COMBOSETITEMS, "4x4,4x3,2x5,");
SpareParts.WPropCmd("combo12", WPA_COMBOENABLEEV, "1");
switch (type) {
case KT4x4:
SpareParts.WPropCmd("label1", WPA_LABELSETTEXT, "P1 - L1");
......
......@@ -267,6 +267,7 @@ void cpart_pot::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("spin7", WPA_SPINSETMAX, "4");
SpareParts.WPropCmd("spin7", WPA_SPINSETMIN, "1");
SpareParts.WPropCmd("spin7", WPA_SPINSETVALUE, std::to_string(Size).c_str());
SpareParts.WPropCmd("spin7", WPA_SPINENABLEEV, "1");
SpinChange(NULL, NULL, Size);
}
......
......@@ -293,6 +293,7 @@ void cpart_pot_r::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("spin7", WPA_SPINSETMAX, "4");
SpareParts.WPropCmd("spin7", WPA_SPINSETMIN, "1");
SpareParts.WPropCmd("spin7", WPA_SPINSETVALUE, std::to_string(Size).c_str());
SpareParts.WPropCmd("spin7", WPA_SPINENABLEEV, "1");
SpinChange(NULL, NULL, Size);
}
......
......@@ -417,6 +417,7 @@ void cpart_pbuttons::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("spin13", WPA_SPINSETMAX, "8");
SpareParts.WPropCmd("spin13", WPA_SPINSETMIN, "1");
SpareParts.WPropCmd("spin13", WPA_SPINSETVALUE, std::to_string(Size).c_str());
SpareParts.WPropCmd("spin13", WPA_SPINENABLEEV, "1");
SpinChange(NULL, NULL, Size);
}
......
......@@ -407,6 +407,7 @@ void cpart_switches::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("spin13", WPA_SPINSETMAX, "8");
SpareParts.WPropCmd("spin13", WPA_SPINSETMIN, "1");
SpareParts.WPropCmd("spin13", WPA_SPINSETVALUE, std::to_string(Size).c_str());
SpareParts.WPropCmd("spin13", WPA_SPINENABLEEV, "1");
SpinChange(NULL, NULL, Size);
}
......
......@@ -442,7 +442,9 @@ void cpart_Jumpers::ConfigurePropertiesWindow(void) {
char childname[256];
SpareParts.WPropCmd("combo1", WPA_COMBOSETITEMS, "F,M,");
SpareParts.WPropCmd("combo1", WPA_COMBOENABLEEV, "1");
SpareParts.WPropCmd("combo18", WPA_COMBOSETITEMS, "F,M,");
SpareParts.WPropCmd("combo18", WPA_COMBOENABLEEV, "1");
if (jtype & 0x02)
SpareParts.WPropCmd("combo1", WPA_COMBOSETTEXT, "F");
......
......@@ -580,6 +580,7 @@ void cpart_7s_display::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("combo13", WPA_COMBOSETTEXT, "LOW ");
SpareParts.WPropCmd("combo14", WPA_COMBOSETITEMS, "4 Mux.,Single,");
SpareParts.WPropCmd("combo14", WPA_COMBOENABLEEV, "1");
if (dtype == 0)
SpareParts.WPropCmd("combo14", WPA_COMBOSETTEXT, "4 Mux.");
else {
......
......@@ -576,6 +576,8 @@ void cpart_LCD_ili9341::ConfigurePropertiesWindow(void) {
}
break;
}
SpareParts.WPropCmd("combo6", WPA_COMBOENABLEEV, "1");
}
void cpart_LCD_ili9341::ReadPropertiesWindow(void) {
......
......@@ -265,6 +265,7 @@ void cpart_leds::ConfigurePropertiesWindow(void) {
SpareParts.WPropCmd("spin10", WPA_SPINSETMAX, "8");
SpareParts.WPropCmd("spin10", WPA_SPINSETMIN, "1");
SpareParts.WPropCmd("spin10", WPA_SPINSETVALUE, std::to_string(Size).c_str());
SpareParts.WPropCmd("spin10", WPA_SPINENABLEEV, "1");
SpareParts.WPropCmd("combo_1", WPA_COMBOSETITEMS, Colors.c_str());
SpareParts.WPropCmd("combo_1", WPA_COMBOSETTEXT, Colorname[colors[0]]);
......
......@@ -200,7 +200,6 @@ void CPWindow5::pmenu2_Properties_EvMenuActive(CControl* control) {
combo->SetX(x + 68);
combo->SetY(y);
wprop.CreateChild(combo);
combo->EvOnComboChange = EVONCOMBOCHANGE & CPWindow5::PropComboChange;
break;
case PCW_LABEL: {
char lb[21];
......@@ -274,7 +273,6 @@ void CPWindow5::pmenu2_Properties_EvMenuActive(CControl* control) {
spin->SetX(x + 68);
spin->SetY(y);
wprop.CreateChild(spin);
spin->EvOnChangeSpin = EVONCHANGESPIN & CPWindow5::PropSpinChange;
break;
case PCW_EDIT:
sprintf(name, "label%i", i + 1);
......@@ -417,12 +415,6 @@ void CPWindow5::pmenu2_Properties_EvMenuActive(CControl* control) {
button->EvMouseButtonRelease = EVMOUSEBUTTONRELEASE & CPWindow5::PropButtonRelease;
}
// FIXME -- Only to work with ili9341 old interface - remove
CCombo* combo = ((CCombo*)wprop.GetChildByName("combo6"));
if (combo) {
combo->EvOnComboChange = EVONCOMBOCHANGE & CPWindow5::PropComboChange;
}
wprop.SetX(SpareParts.GetPart(PartSelected)->GetX() + GetX() - offsetx);
wprop.SetY(SpareParts.GetPart(PartSelected)->GetY() + GetY() - offsety);
......@@ -1109,6 +1101,14 @@ int CPWindow5::OnWPropCmd(const char* ControlName, const PICSimLabWPropAction ac
strcpy((char*)ReturnBuff, ((CCombo*)ctrl)->GetText().c_str());
return strlen((char*)ReturnBuff);
break;
case WPA_COMBOENABLEEV:
if (!strcmp(Value, "1")) {
((CCombo*)ctrl)->EvOnComboChange = EVONCOMBOCHANGE & CPWindow5::PropComboChange;
} else {
((CCombo*)ctrl)->EvOnComboChange = NULL;
}
break;
case WPA_SPINDSETMAX:
((CSpind*)ctrl)->SetMax(std::stof(Value));
break;
......@@ -1134,6 +1134,13 @@ int CPWindow5::OnWPropCmd(const char* ControlName, const PICSimLabWPropAction ac
case WPA_SPINGETVALUE:
*((int*)ReturnBuff) = ((CSpin*)ctrl)->GetValue();
break;
case WPA_SPINENABLEEV:
if (!strcmp(Value, "1")) {
((CSpin*)ctrl)->EvOnChangeSpin = EVONCHANGESPIN & CPWindow5::PropSpinChange;
} else {
((CSpin*)ctrl)->EvOnChangeSpin = NULL;
}
break;
case WPA_TEXTCLEAR:
((CText*)ctrl)->Clear();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment