source: trunk/quest-plugin-mfc/src/main/java/de/ugoe/cs/quest/plugin/mfc/HandlerCreate.java @ 619

Last change on this file since 619 was 619, checked in by pharms, 12 years ago
  • adapted implementation to now generate a full GUI model as well as concrete GUI interaction events
File size: 3.0 KB
Line 
1
2package de.ugoe.cs.quest.plugin.mfc;
3
4import de.ugoe.cs.quest.plugin.mfc.guimodel.WindowTree;
5
6/**
7 * <p>
8 * Message handler for {@code WM_CREATE} messages. The handler maintains the {@link WindowTree}.
9 * </p>
10 *
11 * @author Steffen Herbold
12 * @version 1.0
13 */
14public class HandlerCreate extends MessageHandler {
15
16    /**
17     * <p>
18     * Constructor. Creates a new HandlerCreate.
19     * </p>
20     *
21     * @param windowTree the tree of GUI element specifications to be created and adapted during
22     *                   parsing
23     */
24    public HandlerCreate(WindowTree windowTree) {
25        super(windowTree);
26    }
27
28    /**
29     * <p>
30     * Name of the created window.
31     * </p>
32     */
33    private String windowName;
34
35    /**
36     * <p>
37     * HWND of the created window.
38     * </p>
39     */
40    private long hwnd;
41
42    /**
43     * <p>
44     * HWND of the created window's parent.
45     * </p>
46     */
47    private long parentHwnd;
48
49    /**
50     * <p>
51     * Resource Id of the created window.
52     * </p>
53     */
54    private int resourceId;
55
56    /**
57     * <p>
58     * Window class of the created window.
59     * </p>
60     */
61    private String className;
62
63    /**
64     * <p>
65     * Modality of the created window.
66     * </p>
67     */
68    private boolean isModal;
69
70    /*
71     * (non-Javadoc)
72     *
73     * @see de.ugoe.cs.quest.plugin.mfc.MessageHandler#onEndElement()
74     */
75    @Override
76    public void onEndElement() {
77        if (hwnd != 0) {
78            super.getWindowTree().add(parentHwnd, hwnd, windowName, resourceId, className, isModal);
79        }
80    }
81
82    /*
83     * (non-Javadoc)
84     *
85     * @see de.ugoe.cs.quest.plugin.mfc.MessageHandler#onParameter(java.lang.String ,
86     * java.lang.String)
87     */
88    @Override
89    public void onParameter(String name, String value) {
90        if (name.equals("window.hwnd")) {
91            hwnd = Long.parseLong(value);
92        }
93        else if (name.equals("window.name")) {
94            windowName = value;
95        }
96        else if (name.equals("window.parent.hwnd")) {
97            parentHwnd = Long.parseLong(value);
98        }
99        else if (name.equals("window.resourceId")) {
100            resourceId = Integer.parseInt(value);
101        }
102        else if (name.equals("window.class")) {
103            if (value.startsWith("Afx:")) {
104                className = "Afx:";
105            }
106            else {
107                className = value;
108            }
109        }
110        else if (name.equals("window.ismodal")) {
111            if (value.equals("true") || value.equals("1")) {
112                isModal = true;
113            }
114        }
115    }
116
117    /*
118     * (non-Javadoc)
119     *
120     * @see de.ugoe.cs.quest.plugin.mfc.MessageHandler#onStartElement()
121     */
122    @Override
123    public void onStartElement() {
124        windowName = "";
125        hwnd = 0;
126        parentHwnd = 0;
127        resourceId = 0;
128        className = "";
129        isModal = false;
130    }
131
132}
Note: See TracBrowser for help on using the repository browser.