xj qian
2024-12-05 bd09edf1b441dcc6ab098f277bea86a72c009879
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <wobject/xstring.hpp>
#include <wobject/xwin.hpp>
#include <wobject/xaserver.hpp>
#include <wobject/xaserverarg.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xlayersheet.hpp>
 
using xml = KXMLDOMDocument;
class export XDevEditCode : public xwin
{
    public:
    XDevEditCode(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd),mle_output(nullptr) {}
public:
    static XDevEditCode* CreateInstance(void* implPtr, void* hWnd)
    {
        XDevEditCode* pWin = new XDevEditCode(implPtr, (HWND)hWnd);
        return pWin;
    }
private:    //
    xnode    m_agentNode;    //Agent Condition
    string    m_agentCond;    //Agent Node
    int SetAgent()
    {
        /*
        string xfNodeAgentArea  = "agentarea";
        xnode anode = GetAgentNode(xfNodeAgentArea);
        var xframeElement =  GetElement();
        var agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]/*");
        if(agent)
        {
            string s = agent.xml;
            m_agentNode =  SetAgentNodeContent (anode,s);
        }
        */
        return 1;
    }
 
    //½¹µã¼¤»î´¦Àíº¯Êý
    int OnSetFocus(ref TEvent evt,int param)
    {
        SetAgent();
 
        //ÖØÖù¤¾ßÌõ
        return 1;
    }
 
    //ÃüÁî·¢²¼º¯Êý
    int OnCmdDispatch(string comdid)
    {
        if (comdid == "xmFileSaveEx")
        {
            xsedit xc = this.GetControl("codecontent");
 
            int hCursor = xutil::SetCursorWait();
 
            string code;
            //save tpp content
            xc.GetContent(code);
            this.SaveContent(code);
            //
            xutil::RestoreCursor(hCursor);
 
            return 1;
        }
        return 0;
    }
 
    //ÃüÁî´¦Àíʼþ
    int OnXCommand(ref TXCommandEvent evt,int param)
    {
        return OnCmdDispatch(evt.pStrID);
    }
 
    int OnAttachEvent()
    {
        //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
        AttachEvent("WM_XCOMMAND",OnXCommand);
        //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
        AttachEvent("WM_SETFOCUS",OnSetFocus);
    }
 
    int LoadData()
    {
        if (!this.GetParam()) return 1;
 
        xwin w = GetFrameWindow();
        xtree tv_folder = w.GetControl("DevExplorer");
        int hItem = this.GetParam();
        IXMLDOMElement e = tv_folder.GetItemData(hItem);
        string caption = e.getAttribute("caption");
 
        xsedit xc = this.GetControl("codecontent");
        string code = this.GetData();
        if (code == "")code == " ";
       if (caption.find(".vl",0) >= 0 || caption.find(".vm",0) >= 0 || caption.find(".vf",0) >= 0 || caption.find("voc",0) >= 0 || caption.find("vc",0) >= 0)
      {
          xc.LoadContent(code,".vl");
       }
       else if (caption.find(".scm",0) >= 0)
          xc.LoadContent(code,".scm");
       else
          xc.LoadContent(code,".cpp");
 
        return 1;
    }
 
    int OnInitial()
    {
        SetAgent();
 
        OnAttachEvent();
 
        return 1;
    }
 
    int onload()
    {
        OnInitial();
        LoadData();
        return 1;
    }
};