321 for element in elements: |
321 for element in elements: |
322 element_type = GetElementType(element) |
322 element_type = GetElementType(element) |
323 element_name = element.getname() |
323 element_name = element.getname() |
324 if element_type == ITEM_BUTTON: |
324 if element_type == ITEM_BUTTON: |
325 text += " EVT_BUTTON (SVGUIID(\"%s\"), Program::On%sClick)\n"%(element_name, element_name) |
325 text += " EVT_BUTTON (SVGUIID(\"%s\"), Program::On%sClick)\n"%(element_name, element_name) |
326 elif element_type in [ITEM_SCROLLBAR, ITEM_ROTATING]: |
326 elif element_type in [ITEM_SCROLLBAR, ITEM_ROTATING, ITEM_TRANSFORM]: |
327 text += " EVT_COMMAND_SCROLL_THUMBTRACK (SVGUIID(\"%s\"), Program::On%sChanged)\n"%(element_name, element_name) |
327 text += " EVT_COMMAND_SCROLL_THUMBTRACK (SVGUIID(\"%s\"), Program::On%sChanging)\n"%(element_name, element_name) |
328 elif element_type == ITEM_NOTEBOOK: |
328 elif element_type == ITEM_NOTEBOOK: |
329 text += " EVT_NOTEBOOK_PAGE_CHANGED (SVGUIID(\"%s\"), Program::On%sTabChanged)\n"%(element_name, element_name) |
329 text += " EVT_NOTEBOOK_PAGE_CHANGED (SVGUIID(\"%s\"), Program::On%sTabChanged)\n"%(element_name, element_name) |
330 ## elif element_type in [ITEM_CONTAINER, ITEM_TRANSFORM]: |
330 text += " EVT_CUSTOM(EVT_PLC, wxID_ANY, Program::OnPlcOutEvent)\n" |
331 ## text += " EVT_PAINT(Program::On%sPaint)\n"%element_name |
|
332 text += " EVT_LEFT_UP (Program::OnClick)\n" |
|
333 text += " EVT_CUSTOM( EVT_PLC, wxID_ANY, Program::OnPlcOutEvent )\n" |
|
334 text += "END_EVENT_TABLE()\n\n" |
331 text += "END_EVENT_TABLE()\n\n" |
335 return text |
332 return text |
336 |
333 |
337 def GenerateProgramInitFrame(self, elements): |
334 def GenerateProgramInitFrame(self, elements): |
338 text = """MainFrame::MainFrame(wxWindow *parent, const wxString& title, const wxPoint& pos,const wxSize& size, long style): wxFrame(parent, wxID_ANY, title, pos, size, style) |
335 text = """MainFrame::MainFrame(wxWindow *parent, const wxString& title, const wxPoint& pos,const wxSize& size, long style): wxFrame(parent, wxID_ANY, title, pos, size, style) |
383 text += element_state%"GUI_BUSY" |
380 text += element_state%"GUI_BUSY" |
384 text += " _copy__IX%s_%d_1 = button->GetToggle();\n"%(current_location, element.getid()) |
381 text += " _copy__IX%s_%d_1 = button->GetToggle();\n"%(current_location, element.getid()) |
385 text += element_state%"CHANGED" |
382 text += element_state%"CHANGED" |
386 text += " event.Skip();\n}\n\n" |
383 text += " event.Skip();\n}\n\n" |
387 elif element_type == ITEM_ROTATING: |
384 elif element_type == ITEM_ROTATING: |
388 text += """void Program::On%sChanged(wxScrollEvent& event) |
385 text += """void Program::On%sChanging(wxScrollEvent& event) |
389 { |
386 { |
390 SVGUIRotatingCtrl* rotating = (SVGUIRotatingCtrl*)GetElementByName(wxT("%s")); |
387 SVGUIRotatingCtrl* rotating = (SVGUIRotatingCtrl*)GetElementByName(wxT("%s")); |
391 """%(element_name, element_name) |
388 """%(element_name, element_name) |
392 text += element_state%"GUI_BUSY" |
389 text += element_state%"GUI_BUSY" |
393 text += " _copy__ID%s_%d_1 = rotating->GetAngle();\n"%(current_location, element.getid()) |
390 text += " _copy__ID%s_%d_1 = rotating->GetAngle();\n"%(current_location, element.getid()) |
401 text += element_state%"GUI_BUSY" |
398 text += element_state%"GUI_BUSY" |
402 text += " _copy__IB%s_%d_1 = notebook->GetCurrentPage();\n"%(current_location, element.getid()) |
399 text += " _copy__IB%s_%d_1 = notebook->GetCurrentPage();\n"%(current_location, element.getid()) |
403 text += element_state%"CHANGED" |
400 text += element_state%"CHANGED" |
404 text += " event.Skip();\n}\n\n" |
401 text += " event.Skip();\n}\n\n" |
405 elif element_type == ITEM_TRANSFORM: |
402 elif element_type == ITEM_TRANSFORM: |
406 text += """void Program::On%sPaint(wxPaintEvent& event) |
403 text += """void Program::On%sChanging(wxScrollEvent& event) |
407 { |
404 { |
408 SVGUITransform* transform = (SVGUITransform*)GetElementByName(wxT("%s")); |
405 SVGUITransform* transform = (SVGUITransform*)GetElementByName(wxT("%s")); |
409 """%(element_name, element_name) |
406 """%(element_name, element_name) |
410 text += element_state%"GUI_BUSY" |
407 text += element_state%"GUI_BUSY" |
411 text += " _copy__ID%s_%d_1 = transform->GetX();\n"%(current_location, element.getid()) |
408 text += " _copy__ID%s_%d_1 = transform->GetX();\n"%(current_location, element.getid()) |
412 text += " _copy__ID%s_%d_2 = transform->GetY();\n"%(current_location, element.getid()) |
409 text += " _copy__ID%s_%d_2 = transform->GetY();\n"%(current_location, element.getid()) |
413 text += element_state%"CHANGED" |
410 text += element_state%"CHANGED" |
414 text += " event.Skip();\n}\n\n" |
411 text += " event.Skip();\n}\n\n" |
415 |
|
416 text += """void Program::OnChar(wxKeyEvent& event) |
|
417 { |
|
418 SVGUIContainer* container = GetSVGUIRootElement(); |
|
419 if (container->GetFocusedElementName() == wxT("TextCtrl")) |
|
420 { |
|
421 wxString focusedId = container->GetFocusedElement(); |
|
422 SVGUITextCtrl* text = (SVGUITextCtrl*)GetElementById(focusedId); |
|
423 text->OnChar(event); |
|
424 """ |
|
425 for element in elements: |
|
426 element_type = GetElementType(element) |
|
427 if element_type == ITEM_TEXT: |
|
428 texts = {"location" : current_location, "id" : element.getid()} |
|
429 |
|
430 text += """ if (focusedId == wxT("%(id)d")) |
|
431 { |
|
432 in_state_%(id)d = GUI_BUSY; |
|
433 _copy__IB%(location)s_%(id)d_1 = wxStringToIEC_STRING(text->GetValue()); |
|
434 _copy__IX%(location)s_%(id)d_2 = true; |
|
435 in_state_%(id)d = CHANGED; |
|
436 } |
|
437 """%texts |
|
438 |
|
439 text += " }\n event.Skip();\n}\n\n" |
|
440 |
|
441 |
|
442 text += """void Program::OnClick(wxMouseEvent& event) |
|
443 { |
|
444 SVGUIContainer* container = GetSVGUIRootElement(); |
|
445 if (container->GetFocusedElementName() == wxT("ScrollBar")) |
|
446 { |
|
447 wxString focusedId = container->GetFocusedElement(); |
|
448 SVGUIScrollBar* scrollbar = (SVGUIScrollBar*)GetElementById(focusedId); |
|
449 scrollbar->OnLeftDown(event); |
|
450 """ |
|
451 for element in elements: |
|
452 element_type = GetElementType(element) |
|
453 if element_type == ITEM_SCROLLBAR: |
|
454 texts = {"location" : current_location, "id" : element.getid()} |
|
455 |
|
456 text += """ if (focusedId == wxT("%(id)d")) |
|
457 { |
|
458 unsigned int scrollPos = scrollbar->GetThumbPosition(); |
|
459 _copy__IW%(location)s_%(id)d_1 = scrollPos; |
|
460 _copy__IX%(location)s_%(id)d_2 = true;\n" |
|
461 } |
|
462 """%texts |
|
463 |
|
464 text += " }\n event.Skip();\n}\n\n" |
|
465 |
|
466 |
412 |
467 text += "/* OnPlcOutEvent update GUI with provided IEC __Q* PLC output variables */\n" |
413 text += "/* OnPlcOutEvent update GUI with provided IEC __Q* PLC output variables */\n" |
468 text += """void Program::OnPlcOutEvent(wxEvent& event) |
414 text += """void Program::OnPlcOutEvent(wxEvent& event) |
469 { |
415 { |
470 SVGUIElement* element; |
416 SVGUIElement* element; |
471 |
417 |
472 refreshing = true; |
418 refreshing = true; |
473 |
419 |
474 wxMutexGuiEnter(); |
420 wxMutexGuiEnter(); |
475 """ |
421 """ |
476 for element in elements: |
422 for element in elements: |