summaryrefslogtreecommitdiff
path: root/MainWindow.cpp
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-07-02 11:38:07 +0930
committerDaniel Jones <admin@danieljon.es>2020-07-02 11:38:07 +0930
commit6658e28681480939ba0aaf46ecda9ea6d3642eb9 (patch)
tree5aa7f73e3a89890a951916981e52d89aac37b5a8 /MainWindow.cpp
parent91e0ff8b0327f2e8d1c3851e2cd5a7784ea2f36b (diff)
downloadfoxlogicgates-6658e28681480939ba0aaf46ecda9ea6d3642eb9.tar.gz
foxlogicgates-6658e28681480939ba0aaf46ecda9ea6d3642eb9.zip
Functionality link deleting for binary display works
Diffstat (limited to 'MainWindow.cpp')
-rw-r--r--MainWindow.cpp49
1 files changed, 37 insertions, 12 deletions
diff --git a/MainWindow.cpp b/MainWindow.cpp
index 87eaf07..2c21df9 100644
--- a/MainWindow.cpp
+++ b/MainWindow.cpp
@@ -360,7 +360,6 @@ MainWindow::draw()
{
class BinaryDisplay *bdsp = (class BinaryDisplay*)(*g1).get();
Object *input;
- int gap = 5;
if ((input = bdsp->get_input0()))
{
if (input == selected_input.object) { dc_image.setForeground(FXRGB(255, 0, 0)); }
@@ -591,7 +590,6 @@ MainWindow::find_selected_input(int x, int y)
}
case Object::BINARYDISPLAY:
{
- // forgive me
BinaryDisplay *bdsp = (BinaryDisplay*)object;
int relypos = y-bdsp->get_y();
if (relypos <= 15) { input = 7; input_object = bdsp->get_input7(); }
@@ -1248,19 +1246,46 @@ MainWindow::on_key_release(FXObject *sender, FXSelector sel, void *ptr)
if (selected_input.object != nullptr)
{
/* delete link */
- // FIXME make object
- Gate *gate = (Gate*)selected_object;
- switch (selected_input.input)
+ switch (selected_object->get_object_type())
{
- case 1:
- gate->get_input_gate1()->remove_output_object_id(selected_object->get_id());
- gate->set_input_gate1(nullptr);
+ case Object::GATE:
+ {
+ Gate *gate = (Gate*)selected_object;
+ switch (selected_input.input)
+ {
+ case 1:
+ gate->get_input_gate1()->remove_output_object_id(selected_object->get_id());
+ gate->set_input_gate1(nullptr);
+ break;
+ case 2:
+ gate->get_input_gate2()->remove_output_object_id(selected_object->get_id());
+ gate->set_input_gate2(nullptr);
+ break;
+ default: break;
+ }
break;
- case 2:
- gate->get_input_gate2()->remove_output_object_id(selected_object->get_id());
- gate->set_input_gate2(nullptr);
+ }
+ case Object::BINARYDISPLAY:
+ {
+ BinaryDisplay &bdsp = (BinaryDisplay&)*selected_object;
+ switch (selected_input.input)
+ {
+ case 0: bdsp.get_input0()->remove_output_object_id(bdsp.get_id()); bdsp.set_input0(nullptr); break;
+ case 1: bdsp.get_input1()->remove_output_object_id(bdsp.get_id()); bdsp.set_input1(nullptr); break;
+ case 2: bdsp.get_input2()->remove_output_object_id(bdsp.get_id()); bdsp.set_input2(nullptr); break;
+ case 3: bdsp.get_input3()->remove_output_object_id(bdsp.get_id()); bdsp.set_input3(nullptr); break;
+ case 4: bdsp.get_input4()->remove_output_object_id(bdsp.get_id()); bdsp.set_input4(nullptr); break;
+ case 5: bdsp.get_input5()->remove_output_object_id(bdsp.get_id()); bdsp.set_input5(nullptr); break;
+ case 6: bdsp.get_input6()->remove_output_object_id(bdsp.get_id()); bdsp.set_input6(nullptr); break;
+ case 7: bdsp.get_input7()->remove_output_object_id(bdsp.get_id()); puts("7"); bdsp.set_input7(nullptr); break;
+ default: puts("input not handled in bdsp"); break;
+ }
+ break;
+ }
+ case Object::NONE:
+ default:
+ printf("remove selected input not implemented for object\n");
break;
- default: break;
}
update_object_state(selected_object);
update_object_state(selected_input.object);