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