[927] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.plugin.mfc;
|
---|
[1] | 16 |
|
---|
[1006] | 17 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIElementTree;
|
---|
| 18 | import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElementSpec;
|
---|
| 19 | import de.ugoe.cs.autoquest.plugin.mfc.guimodel.MFCGUIElementSpec;
|
---|
[940] | 20 | import de.ugoe.cs.autoquest.plugin.mfc.guimodel.MFCWindowTree;
|
---|
[1] | 21 |
|
---|
[171] | 22 | /**
|
---|
| 23 | * <p>
|
---|
[940] | 24 | * Message handler for {@code WM_CREATE} messages. The handler maintains the {@link MFCWindowTree}.
|
---|
[171] | 25 | * </p>
|
---|
| 26 | *
|
---|
| 27 | * @author Steffen Herbold
|
---|
| 28 | * @version 1.0
|
---|
| 29 | */
|
---|
[1] | 30 | public class HandlerCreate extends MessageHandler {
|
---|
| 31 |
|
---|
[619] | 32 | /**
|
---|
| 33 | * <p>
|
---|
| 34 | * Constructor. Creates a new HandlerCreate.
|
---|
| 35 | * </p>
|
---|
| 36 | *
|
---|
[1006] | 37 | * @param guiElementTree the tree of GUI element specifications to be created and adapted during
|
---|
[619] | 38 | * parsing
|
---|
| 39 | */
|
---|
[1006] | 40 | public HandlerCreate(GUIElementTree guiElementTree) {
|
---|
| 41 | super(guiElementTree);
|
---|
[619] | 42 | }
|
---|
[1] | 43 |
|
---|
[619] | 44 | /**
|
---|
| 45 | * <p>
|
---|
| 46 | * Name of the created window.
|
---|
| 47 | * </p>
|
---|
| 48 | */
|
---|
| 49 | private String windowName;
|
---|
[171] | 50 |
|
---|
[619] | 51 | /**
|
---|
| 52 | * <p>
|
---|
| 53 | * HWND of the created window.
|
---|
| 54 | * </p>
|
---|
| 55 | */
|
---|
| 56 | private long hwnd;
|
---|
[171] | 57 |
|
---|
[619] | 58 | /**
|
---|
| 59 | * <p>
|
---|
| 60 | * HWND of the created window's parent.
|
---|
| 61 | * </p>
|
---|
| 62 | */
|
---|
| 63 | private long parentHwnd;
|
---|
[171] | 64 |
|
---|
[619] | 65 | /**
|
---|
| 66 | * <p>
|
---|
| 67 | * Resource Id of the created window.
|
---|
| 68 | * </p>
|
---|
| 69 | */
|
---|
| 70 | private int resourceId;
|
---|
[171] | 71 |
|
---|
[619] | 72 | /**
|
---|
| 73 | * <p>
|
---|
| 74 | * Window class of the created window.
|
---|
| 75 | * </p>
|
---|
| 76 | */
|
---|
| 77 | private String className;
|
---|
[171] | 78 |
|
---|
[619] | 79 | /**
|
---|
| 80 | * <p>
|
---|
| 81 | * Modality of the created window.
|
---|
| 82 | * </p>
|
---|
| 83 | */
|
---|
| 84 | private boolean isModal;
|
---|
[171] | 85 |
|
---|
[619] | 86 | /*
|
---|
| 87 | * (non-Javadoc)
|
---|
| 88 | *
|
---|
[922] | 89 | * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onEndElement()
|
---|
[619] | 90 | */
|
---|
| 91 | @Override
|
---|
| 92 | public void onEndElement() {
|
---|
| 93 | if (hwnd != 0) {
|
---|
[1006] | 94 | IGUIElementSpec spec = new MFCGUIElementSpec(hwnd, windowName, resourceId, className, isModal);
|
---|
| 95 | super.getGUIElementTree().add(hwnd, parentHwnd, spec);
|
---|
[619] | 96 | }
|
---|
| 97 | }
|
---|
[1] | 98 |
|
---|
[619] | 99 | /*
|
---|
| 100 | * (non-Javadoc)
|
---|
| 101 | *
|
---|
[922] | 102 | * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onParameter(java.lang.String ,
|
---|
[619] | 103 | * java.lang.String)
|
---|
| 104 | */
|
---|
| 105 | @Override
|
---|
| 106 | public void onParameter(String name, String value) {
|
---|
| 107 | if (name.equals("window.hwnd")) {
|
---|
| 108 | hwnd = Long.parseLong(value);
|
---|
| 109 | }
|
---|
| 110 | else if (name.equals("window.name")) {
|
---|
| 111 | windowName = value;
|
---|
| 112 | }
|
---|
| 113 | else if (name.equals("window.parent.hwnd")) {
|
---|
| 114 | parentHwnd = Long.parseLong(value);
|
---|
| 115 | }
|
---|
| 116 | else if (name.equals("window.resourceId")) {
|
---|
| 117 | resourceId = Integer.parseInt(value);
|
---|
| 118 | }
|
---|
| 119 | else if (name.equals("window.class")) {
|
---|
| 120 | if (value.startsWith("Afx:")) {
|
---|
| 121 | className = "Afx:";
|
---|
| 122 | }
|
---|
| 123 | else {
|
---|
| 124 | className = value;
|
---|
| 125 | }
|
---|
| 126 | }
|
---|
| 127 | else if (name.equals("window.ismodal")) {
|
---|
| 128 | if (value.equals("true") || value.equals("1")) {
|
---|
| 129 | isModal = true;
|
---|
| 130 | }
|
---|
| 131 | }
|
---|
| 132 | }
|
---|
[1] | 133 |
|
---|
[619] | 134 | /*
|
---|
| 135 | * (non-Javadoc)
|
---|
| 136 | *
|
---|
[922] | 137 | * @see de.ugoe.cs.autoquest.plugin.mfc.MessageHandler#onStartElement()
|
---|
[619] | 138 | */
|
---|
| 139 | @Override
|
---|
| 140 | public void onStartElement() {
|
---|
| 141 | windowName = "";
|
---|
| 142 | hwnd = 0;
|
---|
| 143 | parentHwnd = 0;
|
---|
| 144 | resourceId = 0;
|
---|
| 145 | className = "";
|
---|
| 146 | isModal = false;
|
---|
| 147 | }
|
---|
[1] | 148 |
|
---|
| 149 | }
|
---|