001: /* Copyright (c) 2007 Timothy Wall, All Rights Reserved
002: *
003: * This library is free software; you can redistribute it and/or
004: * modify it under the terms of the GNU Lesser General Public
005: * License as published by the Free Software Foundation; either
006: * version 2.1 of the License, or (at your option) any later version.
007: * <p/>
008: * This library is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: */
013: package org.netbeans.core.nativeaccess.transparency.win32;
014:
015: import java.awt.Rectangle;
016:
017: import com.sun.jna.Native;
018: import com.sun.jna.Pointer;
019: import com.sun.jna.Structure;
020: import com.sun.jna.ptr.PointerByReference;
021:
022: /** Definition (incomplete) of <code>gdi32.dll</code>. */
023: public interface GDI32 extends W32API {
024:
025: GDI32 INSTANCE = (GDI32) Native.loadLibrary("gdi32", GDI32.class,
026: DEFAULT_OPTIONS);
027:
028: public static class RECT extends Structure {
029: public int left;
030: public int top;
031: public int right;
032: public int bottom;
033:
034: public Rectangle toRectangle() {
035: return new Rectangle(left, top, right - left, bottom - top);
036: }
037:
038: public String toString() {
039: return "[(" + left + "," + top + ")(" + right + ","
040: + bottom + ")]";
041: }
042: }
043:
044: int RDH_RECTANGLES = 1;
045:
046: public static class RGNDATAHEADER extends Structure {
047: public int dwSize = size();
048: public int iType = RDH_RECTANGLES; // required
049: public int nCount;
050: public int nRgnSize;
051: public RECT rcBound;
052: }
053:
054: public static class RGNDATA extends Structure {
055: public RGNDATAHEADER rdh;
056: public byte[] Buffer;
057:
058: public RGNDATA(int bufferSize) {
059: Buffer = new byte[bufferSize];
060: allocateMemory();
061: }
062: }
063:
064: public HRGN ExtCreateRegion(Pointer lpXform, int nCount,
065: RGNDATA lpRgnData);
066:
067: int RGN_AND = 1;
068: int RGN_OR = 2;
069: int RGN_XOR = 3;
070: int RGN_DIFF = 4;
071: int RGN_COPY = 5;
072:
073: int ERROR = 0;
074: int NULLREGION = 1;
075: int SIMPLEREGION = 2;
076: int COMPLEXREGION = 3;
077:
078: int CombineRgn(HRGN hrgnDest, HRGN hrgnSrc1, HRGN hrgnSrc2,
079: int fnCombineMode);
080:
081: HRGN CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
082: int nBottomRect);
083:
084: HRGN CreateRoundRectRgn(int nLeftRect, int nTopRect,
085: int nRightRect, int nBottomRect, int nWidthEllipse,
086: int nHeightEllipse);
087:
088: boolean SetRectRgn(HRGN hrgn, int nLeftRect, int nTopRect,
089: int nRightRect, int nBottomRect);
090:
091: int SetPixel(HDC hDC, int x, int y, int crColor);
092:
093: HDC CreateCompatibleDC(HDC hDC);
094:
095: boolean DeleteDC(HDC hDC);
096:
097: int BI_RGB = 0;
098: int BI_RLE8 = 1;
099: int BI_RLE4 = 2;
100: int BI_BITFIELDS = 3;
101: int BI_JPEG = 4;
102: int BI_PNG = 5;
103:
104: public static class BITMAPINFOHEADER extends Structure {
105: public int biSize = size();
106: public int biWidth;
107: public int biHeight;
108: public short biPlanes;
109: public short biBitCount;
110: public int biCompression;
111: public int biSizeImage;
112: public int biXPelsPerMeter;
113: public int biYPelsPerMeter;
114: public int biClrUsed;
115: public int biClrImportant;
116: }
117:
118: public static class RGBQUAD extends Structure {
119: public byte rgbBlue;
120: public byte rgbGreen;
121: public byte rgbRed;
122: public byte rgbReserved = 0;
123: }
124:
125: public static class BITMAPINFO extends Structure {
126: public BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER();
127: //RGBQUAD:
128: //byte rgbBlue;
129: //byte rgbGreen;
130: //byte rgbRed;
131: //byte rgbReserved = 0;
132: int[] bmiColors = new int[1];
133:
134: public BITMAPINFO() {
135: this (1);
136: }
137:
138: public BITMAPINFO(int size) {
139: bmiColors = new int[size];
140: allocateMemory();
141: }
142: }
143:
144: int DIB_RGB_COLORS = 0;
145: int DIB_PAL_COLORS = 1;
146:
147: HBITMAP CreateDIBitmap(HDC hDC, BITMAPINFOHEADER lpbmih,
148: int fdwInit, Pointer lpbInit, BITMAPINFO lpbmi, int fuUsage);
149:
150: HBITMAP CreateDIBSection(HDC hDC, BITMAPINFO pbmi, int iUsage,
151: PointerByReference ppvBits, Pointer hSection, int dwOffset);
152:
153: HBITMAP CreateCompatibleBitmap(HDC hDC, int width, int height);
154:
155: HANDLE SelectObject(HDC hDC, HANDLE hGDIObj);
156:
157: boolean DeleteObject(HANDLE p);
158: }
|