| 1 | /* |
| 2 | * $Id: SIZE.java,v 1.2 2006/03/01 20:54:18 hastings Exp $ |
| 3 | * |
| 4 | * (c) Copyright, Moebius Solutions, Inc., 2004 |
| 5 | * |
| 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This material may be reproduced by or for the U. S. Government |
| 9 | * pursuant to the copyright license under the clause at |
| 10 | * DFARS 252.227-7014 (OCT 2001). |
| 11 | */ |
| 12 | |
| 13 | package com.moesol.bindings.platform_sdk.windows_api; |
| 14 | |
| 15 | /** |
| 16 | * SIZE structure |
| 17 | */ |
| 18 | public class SIZE extends com.moesol.bindings.NativeStructure { |
| 19 | /** |
| 20 | * Create a new instance. |
| 21 | */ |
| 22 | public SIZE() { |
| 23 | super(new byte[sizeof()]); |
| 24 | } |
| 25 | /** |
| 26 | * Create a new instance on a byte buffer. |
| 27 | */ |
| 28 | public SIZE(java.nio.ByteBuffer bb) { |
| 29 | super(bb); |
| 30 | // set limit based on the dynamic size in byte in bb. |
| 31 | bb.limit(getDynamicSize()); |
| 32 | } |
| 33 | public static int sizeof() { |
| 34 | return 8; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Represent a native array of these structures |
| 39 | */ |
| 40 | public static class Array extends com.moesol.bindings.NativeArrayOfStructs { |
| 41 | public Array(java.nio.ByteBuffer bb) { |
| 42 | super(bb); |
| 43 | } |
| 44 | public SIZE get(int index) { |
| 45 | return new SIZE(getElementSlice(index, SIZE.sizeof())); |
| 46 | } |
| 47 | public void put(int index, SIZE value) { |
| 48 | get(index).putStruct(0, SIZE.sizeof(), value); |
| 49 | } |
| 50 | public int length() { |
| 51 | return _getByteBuffer().limit() / SIZE.sizeof(); |
| 52 | } |
| 53 | public int getDynamicSize() { |
| 54 | return _getByteBuffer().limit(); |
| 55 | } |
| 56 | public String toString() { |
| 57 | StringBuffer sb = new StringBuffer(); |
| 58 | for (int i = 0; i < length(); i++) { |
| 59 | sb.append(get(i)); |
| 60 | } |
| 61 | return sb.toString(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | |
| 66 | |
| 67 | public static final int OFFSET_cx = 0; |
| 68 | /** |
| 69 | * |
| 70 | * @param v new cx value |
| 71 | */ |
| 72 | public void set_cx(int v) { |
| 73 | putInt(0, v); |
| 74 | } |
| 75 | /** |
| 76 | * |
| 77 | * @return cx value |
| 78 | */ |
| 79 | public int get_cx() { |
| 80 | return getInt(0); |
| 81 | } |
| 82 | |
| 83 | public static final int OFFSET_cy = 4; |
| 84 | /** |
| 85 | * |
| 86 | * @param v new cy value |
| 87 | */ |
| 88 | public void set_cy(int v) { |
| 89 | putInt(4, v); |
| 90 | } |
| 91 | /** |
| 92 | * |
| 93 | * @return cy value |
| 94 | */ |
| 95 | public int get_cy() { |
| 96 | return getInt(4); |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Get dynamic size in bytes. |
| 101 | * If this structure contains a variable size array, |
| 102 | * return the number of bytes needed to hold the fixed |
| 103 | * part and the variable sized array based on the [length_is()] |
| 104 | * attribute. Note that the sizeof method on returns the |
| 105 | * size of the fixed part plus the size of one array entry. |
| 106 | * |
| 107 | * @return dynamic size in bytes. |
| 108 | */ |
| 109 | public int getDynamicSize() { |
| 110 | return sizeof(); |
| 111 | } |
| 112 | |
| 113 | public String toString() { |
| 114 | StringBuffer sb = new StringBuffer(); |
| 115 | sb.append("\nSIZE("); |
| 116 | sb.append("cx("); |
| 117 | sb.append(get_cx()); |
| 118 | sb.append(")"); |
| 119 | |
| 120 | sb.append("cy("); |
| 121 | sb.append(get_cy()); |
| 122 | sb.append(")"); |
| 123 | |
| 124 | sb.append(')'); |
| 125 | return sb.toString(); |
| 126 | } |
| 127 | } |