plugins/svgui/svgui.py
changeset 181 f01bcc3c9157
parent 165 f9c6c9e36725
child 186 ed2a408d79b6
equal deleted inserted replaced
180:f7dc9acda79e 181:f01bcc3c9157
   332                 text += "%s _copy%s;\n"%(element_c_type, variable)
   332                 text += "%s _copy%s;\n"%(element_c_type, variable)
   333             text +="\n"
   333             text +="\n"
   334         return text
   334         return text
   335     
   335     
   336     def GenerateGlobalVarsAndFuncs(self, size):
   336     def GenerateGlobalVarsAndFuncs(self, size):
   337         text = """#include \"iec_types.h\"
   337         text = """#include "iec_types.h"
   338 
       
   339 #ifdef __WXMSW__
   338 #ifdef __WXMSW__
   340 #define COMPARE_AND_SWAP_VAL(Destination, comparand, exchange) InterlockedCompareExchange(Destination, exchange, comparand)
   339 #define COMPARE_AND_SWAP_VAL(Destination, comparand, exchange) InterlockedCompareExchange(Destination, exchange, comparand)
   341 #define THREAD_RETURN_TYPE DWORD WINAPI
   340 #define THREAD_RETURN_TYPE DWORD WINAPI
   342 #define STATE_TYPE long int
   341 #define STATE_TYPE long int
   343 #else
   342 #else
   351         text += self.GenerateIECVars()
   350         text += self.GenerateIECVars()
   352         
   351         
   353         text += """IMPLEMENT_APP_NO_MAIN(SVGViewApp);
   352         text += """IMPLEMENT_APP_NO_MAIN(SVGViewApp);
   354 IMPLEMENT_WX_THEME_SUPPORT;
   353 IMPLEMENT_WX_THEME_SUPPORT;
   355 SVGViewApp *myapp = NULL;
   354 SVGViewApp *myapp = NULL;
       
   355 wxSemaphore MyInitSem;
   356 
   356 
   357 #ifdef __WXMSW__
   357 #ifdef __WXMSW__
   358 HANDLE wxMainLoop;
   358 HANDLE wxMainLoop;
   359 DWORD wxMainLoopId;
   359 DWORD wxMainLoopId;
   360 #else
   360 #else
   422 #ifdef __WXMSW__
   422 #ifdef __WXMSW__
   423   wxMainLoop = CreateThread(NULL, 0, InitWxEntry, 0, 0, &wxMainLoopId);
   423   wxMainLoop = CreateThread(NULL, 0, InitWxEntry, 0, 0, &wxMainLoopId);
   424 #else
   424 #else
   425   pthread_create(&wxMainLoop, NULL, InitWxEntry, NULL);
   425   pthread_create(&wxMainLoop, NULL, InitWxEntry, NULL);
   426 #endif
   426 #endif
       
   427   MyInitSem.Wait();
   427   return 0;
   428   return 0;
   428 }
   429 }
   429 
   430 
   430 void __cleanup_%(location)s()
   431 void __cleanup_%(location)s()
   431 {
   432 {
   625                 text += """    if (_copy__QB%(location)s_%(id)d_3 != ((SVGUINoteBook*)element)->GetCurrentPage())
   626                 text += """    if (_copy__QB%(location)s_%(id)d_3 != ((SVGUINoteBook*)element)->GetCurrentPage())
   626       ((SVGUINoteBook*)element)->SetCurrentPage(_copy__QB%(location)s_%(id)d_3);
   627       ((SVGUINoteBook*)element)->SetCurrentPage(_copy__QB%(location)s_%(id)d_3);
   627 """%texts
   628 """%texts
   628             elif element_type == ITEM_TRANSFORM:
   629             elif element_type == ITEM_TRANSFORM:
   629                 text += """    if (_copy__QD%(location)s_%(id)d_3 != ((SVGUITransform*)element)->GetX() ||
   630                 text += """    if (_copy__QD%(location)s_%(id)d_3 != ((SVGUITransform*)element)->GetX() ||
   630         copy__QD%(location)s_%(id)d_4 != ((SVGUITransform*)element)->GetY())
   631         _copy__QD%(location)s_%(id)d_4 != ((SVGUITransform*)element)->GetY())
   631       transform->Move(_copy__QD%(location)s_%(id)d_3, _copy__QD%(location)s_%(id)d_4);
   632       ((SVGUITransform*)element)->Move(_copy__QD%(location)s_%(id)d_3, _copy__QD%(location)s_%(id)d_4);
   632     if (_copy__QD%(location)s_%(id)d_5 != ((SVGUITransform*)element)->GetXScale() ||
   633     if (_copy__QD%(location)s_%(id)d_5 != ((SVGUITransform*)element)->GetXScale() ||
   633         copy__QD%(location)s_%(id)d_6 != ((SVGUITransform*)element)->GetYScale())
   634         _copy__QD%(location)s_%(id)d_6 != ((SVGUITransform*)element)->GetYScale())
   634       transform->Scale(_copy__QD%(location)s_%(id)d_5, _copy__QD%(location)s_%(id)d_6);
   635       ((SVGUITransform*)element)->Scale(_copy__QD%(location)s_%(id)d_5, _copy__QD%(location)s_%(id)d_6);
   635     if (_copy__QD%(location)s_%(id)d_7 != ((SVGUITransform*)element)->GetAngle())
   636     if (_copy__QD%(location)s_%(id)d_7 != ((SVGUITransform*)element)->GetAngle())
   636       transform->Rotate(_copy__QD%(location)s_%(id)d_7);
   637       ((SVGUITransform*)element)->Rotate(_copy__QD%(location)s_%(id)d_7);
   637 """%texts
   638 """%texts
   638             text += "    COMPARE_AND_SWAP_VAL(&out_state_%(id)d, GUI_BUSY, UNCHANGED);\n  }\n"%texts
   639             text += "    COMPARE_AND_SWAP_VAL(&out_state_%(id)d, GUI_BUSY, UNCHANGED);\n  }\n"%texts
   639             
   640             
   640         text += """  wxMutexGuiLeave();
   641         text += """  wxMutexGuiLeave();
   641 
   642 
   709             element_type = GetElementType(element)
   710             element_type = GetElementType(element)
   710             texts = {"location" : current_location, "id" : element.getid()}
   711             texts = {"location" : current_location, "id" : element.getid()}
   711             
   712             
   712             text += """
   713             text += """
   713   element = (SVGUIElement*)GetElementById(wxT("%(id)d"));
   714   element = (SVGUIElement*)GetElementById(wxT("%(id)d"));
   714   beremiz__QX%(location)s_%(id)d_1 = 1;
   715   beremiz__QX%(location)s_%(id)d_1 = _copy__QX%(location)s_%(id)d_1 = 1;
   715   _copy__QX%(location)s_%(id)d_1 = 1;
   716   beremiz__QX%(location)s_%(id)d_2 = _copy__QX%(location)s_%(id)d_2 = 1;
   716   beremiz__QX%(location)s_%(id)d_2 = 1;
       
   717   _copy__QX%(location)s_%(id)d_2 = 1;
       
   718 """%texts
   717 """%texts
   719             if element_type == ITEM_BUTTON:
   718             if element_type == ITEM_BUTTON:
   720                 text += "  _copy__IX%(location)s_%(id)d_1 = ((SVGUIButton*)element)->GetToggle();\n"%texts
   719                 text += "  beremiz__IX%(location)s_%(id)d_1 = _copy__IX%(location)s_%(id)d_1 = ((SVGUIButton*)element)->GetToggle();\n"%texts
   721             elif element_type == ITEM_TEXT:
   720             elif element_type == ITEM_TEXT:
   722                 text += "  _copy__IB%(location)s_%(id)d_1 = ((SVGUITextCtrl*)element)->GetValue();\n"%texts
   721                 text += "  beremiz__IB%(location)s_%(id)d_1 = _copy__IB%(location)s_%(id)d_1 = ((SVGUITextCtrl*)element)->GetValue();\n"%texts
   723             elif element_type == ITEM_SCROLLBAR:
   722             elif element_type == ITEM_SCROLLBAR:
   724                 text += "  _copy__IW%(location)s_%(id)d_1 = ((SVGUIScrollBar*)element)->GetThumbPosition();\n"%texts
   723                 text += "  beremiz__IW%(location)s_%(id)d_1 = _copy__IW%(location)s_%(id)d_1 = ((SVGUIScrollBar*)element)->GetThumbPosition();\n"%texts
   725             elif element_type == ITEM_ROTATING:
   724             elif element_type == ITEM_ROTATING:
   726                 text += "  _copy__ID%(location)s_%(id)d_1 = ((SVGUIRotatingCtrl*)element)->GetAngle();\n"%texts
   725                 text += "   beremiz__ID%(location)s_%(id)d_1 = _copy__ID%(location)s_%(id)d_1 = ((SVGUIRotatingCtrl*)element)->GetAngle();\n"%texts
   727             elif element_type == ITEM_NOTEBOOK:
   726             elif element_type == ITEM_NOTEBOOK:
   728                 text += "  _copy__IB%(location)s_%(id)d_1 = ((SVGUINoteBook*)element)->GetCurrentPage();\n"%texts
   727                 text += "  beremiz__IB%(location)s_%(id)d_1 = _copy__IB%(location)s_%(id)d_1 = ((SVGUINoteBook*)element)->GetCurrentPage();\n"%texts
   729             elif element_type == ITEM_TRANSFORM:
   728             elif element_type == ITEM_TRANSFORM:
   730                 text += "  _copy__ID%(location)s_%(id)d_1 = ((SVGUITransform*)element)->GetX();\n"%texts
   729                 text += "  beremiz__QD%(location)s_%(id)d_3 = _copy__QD%(location)s_%(id)d_3 = ((SVGUITransform*)element)->GetX();\n"%texts
   731                 text += "  _copy__ID%(location)s_%(id)d_2 = ((SVGUITransform*)element)->GetY();\n"%texts
   730                 text += "  beremiz__QD%(location)s_%(id)d_4 = _copy__QD%(location)s_%(id)d_4 = ((SVGUITransform*)element)->GetY();\n"%texts
       
   731                 text += "  beremiz__QD%(location)s_%(id)d_5 = _copy__QD%(location)s_%(id)d_5 = ((SVGUITransform*)element)->GetXScale();\n"%texts
       
   732                 text += "  beremiz__QD%(location)s_%(id)d_6 = _copy__QD%(location)s_%(id)d_6 = ((SVGUITransform*)element)->GetYScale();\n"%texts
       
   733                 text += "  beremiz__QD%(location)s_%(id)d_7 = _copy__QD%(location)s_%(id)d_7 = ((SVGUITransform*)element)->GetAngle();\n"%texts
       
   734                 text += "  beremiz__ID%(location)s_%(id)d_1 = _copy__ID%(location)s_%(id)d_1 = ((SVGUITransform*)element)->GetX();\n"%texts
       
   735                 text += "  beremiz__ID%(location)s_%(id)d_2 = _copy__ID%(location)s_%(id)d_2 = ((SVGUITransform*)element)->GetY();\n"%texts
       
   736                 text += "  MyInitSem.Post();\n"
   732         text += "}\n\n"
   737         text += "}\n\n"
   733         
   738         
   734         return text
   739         return text