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