#define INT32 WIN32_INT32
// this has to precede the others so we don't get collisions on min/max
-#include <org/xwt/js/JS.h>
-#include <org/xwt/Box.h>
+#include <org/ibex/js/JS.h>
+#include <org/ibex/Box.h>
#include <stdint.h>
#include <stdlib.h>
#include <java/lang/Integer.h>
#include <java/util/Hashtable.h>
-#include <org/xwt/Box.h>
-#include <org/xwt/Surface.h>
-#include <org/xwt/PixelBuffer.h>
-#include <org/xwt/Picture.h>
-#include <org/xwt/Platform.h>
-#include <org/xwt/plat/Win32.h>
-#include <org/xwt/plat/Win32$Win32Surface.h>
-#include <org/xwt/plat/Win32$Win32PixelBuffer.h>
-#include <org/xwt/plat/Win32$Win32Picture.h>
-#include <org/xwt/util/Log.h>
-#include <org/xwt/util/Semaphore.h>
+#include <org/ibex/Box.h>
+#include <org/ibex/Surface.h>
+#include <org/ibex/PixelBuffer.h>
+#include <org/ibex/Picture.h>
+#include <org/ibex/Platform.h>
+#include <org/ibex/plat/Win32.h>
+#include <org/ibex/plat/Win32$Win32Surface.h>
+#include <org/ibex/plat/Win32$Win32PixelBuffer.h>
+#include <org/ibex/plat/Win32$Win32Picture.h>
+#include <org/ibex/util/Log.h>
+#include <org/ibex/util/Semaphore.h>
// for debugging
#include <java/lang/System.h>
// Callbacks ////////////////////////////////////////////////////////////////////
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
- org::xwt::plat::Win32$Win32Surface* surface =
- (org::xwt::plat::Win32$Win32Surface*)org::xwt::plat::Win32::hwndToWin32SurfaceMap->get(new java::lang::Integer((jint)hwnd));
+ org::ibex::plat::Win32$Win32Surface* surface =
+ (org::ibex::plat::Win32$Win32Surface*)org::ibex::plat::Win32::hwndToWin32SurfaceMap->get(new java::lang::Integer((jint)hwnd));
if (surface != NULL) {
return (LRESULT)surface->WndProc((jint)hwnd, (jint)iMsg, (jint)wParam, (jint)lParam);
static int window_class_counter = 0;
-jstring org::xwt::plat::Win32::getTempPath() {
+jstring org::ibex::plat::Win32::getTempPath() {
char buf[1024];
DWORD ret = GetTempPath(1024, buf);
if (ret == 0) criticalAbort(JvNewStringLatin1("GetTempPath() failed"));
0xFF, 0xFF, 0xFF, 0xFF
};
-void org::xwt::plat::Win32::natPreInit() {
- if (org::xwt::util::Log::verbose) {
+void org::ibex::plat::Win32::natPreInit() {
+ if (org::ibex::util::Log::verbose) {
AllocConsole();
freopen("CONOUT$", "w+t", stderr);
}
}
-void org::xwt::plat::Win32::natInit() {
+void org::ibex::plat::Win32::natInit() {
// grab desktop dc/handle
desktop_handle = (jint)GetDesktopWindow();
desktop_dc = (jint)GetDC((HWND)desktop_handle);
// create cursors
- org::xwt::plat::Win32::wait_cursor = (jint)LoadCursor(NULL, IDC_WAIT);
- org::xwt::plat::Win32::default_cursor = (jint)LoadCursor(NULL, IDC_ARROW);
- org::xwt::plat::Win32::crosshair_cursor = (jint)LoadCursor(NULL, IDC_CROSS);
- org::xwt::plat::Win32::text_cursor = (jint)LoadCursor(NULL, IDC_IBEAM);
- org::xwt::plat::Win32::move_cursor = (jint)LoadCursor(NULL, IDC_SIZEALL);
- org::xwt::plat::Win32::sizenesw_cursor = (jint)LoadCursor(NULL, IDC_SIZENESW);
- org::xwt::plat::Win32::sizens_cursor = (jint)LoadCursor(NULL, IDC_SIZENS);
- org::xwt::plat::Win32::sizenwse_cursor = (jint)LoadCursor(NULL, IDC_SIZENWSE);
- org::xwt::plat::Win32::sizewe_cursor = (jint)LoadCursor(NULL, IDC_SIZEWE);
- org::xwt::plat::Win32::hand_cursor = (jint)CreateCursor(GetModuleHandle(NULL), 14, 1, 32, 32, hand_cursor_and, hand_cursor_xor);
+ org::ibex::plat::Win32::wait_cursor = (jint)LoadCursor(NULL, IDC_WAIT);
+ org::ibex::plat::Win32::default_cursor = (jint)LoadCursor(NULL, IDC_ARROW);
+ org::ibex::plat::Win32::crosshair_cursor = (jint)LoadCursor(NULL, IDC_CROSS);
+ org::ibex::plat::Win32::text_cursor = (jint)LoadCursor(NULL, IDC_IBEAM);
+ org::ibex::plat::Win32::move_cursor = (jint)LoadCursor(NULL, IDC_SIZEALL);
+ org::ibex::plat::Win32::sizenesw_cursor = (jint)LoadCursor(NULL, IDC_SIZENESW);
+ org::ibex::plat::Win32::sizens_cursor = (jint)LoadCursor(NULL, IDC_SIZENS);
+ org::ibex::plat::Win32::sizenwse_cursor = (jint)LoadCursor(NULL, IDC_SIZENWSE);
+ org::ibex::plat::Win32::sizewe_cursor = (jint)LoadCursor(NULL, IDC_SIZEWE);
+ org::ibex::plat::Win32::hand_cursor = (jint)CreateCursor(GetModuleHandle(NULL), 14, 1, 32, 32, hand_cursor_and, hand_cursor_xor);
messagePumpThread = (jint)GetCurrentThreadId();
messagePumpStarted->release();
while(GetMessage(&msg, (HWND)NULL, 0, 0) > 0) {
if (msg.message == WM_USER_CREATEWINDOW) {
- org::xwt::plat::Win32$Win32Surface *surface = (org::xwt::plat::Win32$Win32Surface*)msg.lParam;
+ org::ibex::plat::Win32$Win32Surface *surface = (org::ibex::plat::Win32$Win32Surface*)msg.lParam;
// we must create a unique window class name for each
// window so that minimization icons can be set independantly
char buf[255];
- sprintf(buf, "XWT_WINDOW_CLASS_%i", window_class_counter++);
+ sprintf(buf, "Ibex_WINDOW_CLASS_%i", window_class_counter++);
WNDCLASSEX wc;
wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
// Platform Methods ///////////////////////////////////////////////////////////////////
-jstring org::xwt::plat::Win32::_getEnv(jstring key) {
+jstring org::ibex::plat::Win32::_getEnv(jstring key) {
int len = JvGetStringUTFLength(key);
char buf[len + 1];
JvGetStringUTFRegion(key, 0, len, buf);
return NULL;
}
-jstring org::xwt::plat::Win32::_fileDialog(jstring suggestedFileName, jboolean write) {
+jstring org::ibex::plat::Win32::_fileDialog(jstring suggestedFileName, jboolean write) {
char buf[1024];
OPENFILENAME ofn;
return ret == 0 ? NULL : JvNewStringLatin1(buf);
}
-void org::xwt::plat::Win32::__detectProxy(JArray<jstring>* container) {
+void org::ibex::plat::Win32::__detectProxy(JArray<jstring>* container) {
HKEY hkey;
char buf[1024];
elements(container)[1] = JvNewStringLatin1(buf);
}
-jstring org::xwt::plat::Win32::_getClipBoard() {
+jstring org::ibex::plat::Win32::_getClipBoard() {
OpenClipboard((HWND)desktop_handle);
HGLOBAL hmem = GetClipboardData(CF_TEXT);
if (hmem == NULL) return NULL;
return ret;
}
-void org::xwt::plat::Win32::_setClipBoard(jstring s) {
+void org::ibex::plat::Win32::_setClipBoard(jstring s) {
OpenClipboard((HWND)desktop_handle);
HGLOBAL hmem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, JvGetStringUTFLength(s) + 1);
if (hmem == NULL) return;
CloseClipboard();
}
-void org::xwt::plat::Win32::_criticalAbort(jstring message) {
+void org::ibex::plat::Win32::_criticalAbort(jstring message) {
char buf[JvGetStringUTFLength(message) + 1];
buf[JvGetStringUTFLength(message)] = '\0';
JvGetStringUTFRegion(message, 0, JvGetStringUTFLength(message), buf);
- MessageBox (NULL, buf, "XWT Cannot Continue", MB_OK | MB_ICONSTOP | MB_TASKMODAL | MB_SETFOREGROUND);
+ MessageBox (NULL, buf, "Ibex Cannot Continue", MB_OK | MB_ICONSTOP | MB_TASKMODAL | MB_SETFOREGROUND);
java::lang::System::exit(-1);
}
-jint org::xwt::plat::Win32::_getScreenWidth() {
+jint org::ibex::plat::Win32::_getScreenWidth() {
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
return rect.right - rect.left;
}
-jint org::xwt::plat::Win32::_getScreenHeight() {
+jint org::ibex::plat::Win32::_getScreenHeight() {
RECT rect;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);
return rect.bottom - rect.top;
}
-jboolean org::xwt::plat::Win32::_newBrowserWindow_(jstring url) {
+jboolean org::ibex::plat::Win32::_newBrowserWindow_(jstring url) {
int len = min(2048, JvGetStringUTFLength(url));
char buf[len + 1];
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
-void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* source0,
+void org::ibex::plat::Win32$Win32PixelBuffer::drawPicture(org::ibex::Picture* source0,
jint dx, jint dy,
jint cx1, jint cy1, jint cx2, jint cy2,
jint rgb, jboolean alphaOnly) {
- org::xwt::plat::Win32$Win32Picture* source = (org::xwt::plat::Win32$Win32Picture*)source0;
+ org::ibex::plat::Win32$Win32Picture* source = (org::ibex::plat::Win32$Win32Picture*)source0;
cx1 = max(dx, cx1);
cy1 = max(dy, cy1);
// create section DIB
scratch = CreateDIBSection(NULL, &bitmapinfo, DIB_RGB_COLORS, (void**)&scratch_bits, NULL, 0);
- scratch_dc = CreateCompatibleDC((HDC)org::xwt::plat::Win32::desktop_dc);
+ scratch_dc = CreateCompatibleDC((HDC)org::ibex::plat::Win32::desktop_dc);
SelectObject(scratch_dc, scratch);
}
}
-void org::xwt::plat::Win32$Win32PixelBuffer::fillRect(jint x, jint y, jint x2, jint y2, jint color) {
+void org::ibex::plat::Win32$Win32PixelBuffer::fillRect(jint x, jint y, jint x2, jint y2, jint color) {
jint w = x2 - x;
jint h = y2 - y;
DeleteObject(brush);
}
-void org::xwt::plat::Win32$Win32Surface::blit(org::xwt::PixelBuffer* s, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
+void org::ibex::plat::Win32$Win32Surface::blit(org::ibex::PixelBuffer* s, jint sx, jint sy, jint dx, jint dy, jint dx2, jint dy2) {
// we create the DC lazily to get around some strange race condition in WinXP
if (hdc == 0) hdc = (jint)GetDC((HWND)hwnd);
- BitBlt((HDC)hdc, dx, dy, dx2 - dx, dy2 - dy, (HDC)(((org::xwt::plat::Win32$Win32PixelBuffer*)s)->hdc), sx, sy, SRCCOPY);
+ BitBlt((HDC)hdc, dx, dy, dx2 - dx, dy2 - dy, (HDC)(((org::ibex::plat::Win32$Win32PixelBuffer*)s)->hdc), sx, sy, SRCCOPY);
}
-void org::xwt::plat::Win32$Win32PixelBuffer::natInit() {
- hbitmap = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, w, h);
- hdc = (jint)CreateCompatibleDC((HDC)org::xwt::plat::Win32::desktop_dc);
+void org::ibex::plat::Win32$Win32PixelBuffer::natInit() {
+ hbitmap = (jint)CreateCompatibleBitmap((HDC)org::ibex::plat::Win32::desktop_dc, w, h);
+ hdc = (jint)CreateCompatibleDC((HDC)org::ibex::plat::Win32::desktop_dc);
SetBkMode((HDC)hdc, TRANSPARENT);
SelectObject((HDC)hdc, (HBITMAP)hbitmap);
}
-void org::xwt::plat::Win32$Win32PixelBuffer::finalize() {
+void org::ibex::plat::Win32$Win32PixelBuffer::finalize() {
DeleteObject((void*)hdc);
DeleteObject((void*)hbitmap);
}
// Win32Picture /////////////////////////////////////////////////////////////////////////
-void org::xwt::plat::Win32$Win32Picture::natInit() {
+void org::ibex::plat::Win32$Win32Picture::natInit() {
BITMAPINFO bitmapinfo;
memset(&bitmapinfo, 0, sizeof(BITMAPINFO));
bitmapinfo.bmiHeader.biBitCount = 32;
bitmapinfo.bmiHeader.biCompression = BI_RGB;
- hbitmap = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, width, height);
- hdc = (jint)CreateCompatibleDC((HDC)org::xwt::plat::Win32::desktop_dc);
+ hbitmap = (jint)CreateCompatibleBitmap((HDC)org::ibex::plat::Win32::desktop_dc, width, height);
+ hdc = (jint)CreateCompatibleDC((HDC)org::ibex::plat::Win32::desktop_dc);
SelectObject((HDC)hdc, (HBITMAP)hbitmap);
uint32_t* dat = (uint32_t*)elements(data);
for(int i=0; i<data->length; i++) if ((dat[i] & 0xFF000000) == 0x00000000) dat[i] = 0x00000000;
}
// hmask = (jint)CreateBitmap(w, h, 1, 1, NULL);
- hmask = (jint)CreateCompatibleBitmap((HDC)org::xwt::plat::Win32::desktop_dc, width, height);
+ hmask = (jint)CreateCompatibleBitmap((HDC)org::ibex::plat::Win32::desktop_dc, width, height);
maskdc = (jint)CreateCompatibleDC(NULL);
SelectObject((HDC)maskdc, (HBITMAP)hmask);
StretchDIBits((HDC)maskdc, 0, 0, width, height, 0, 0, width, height, copy, &bitmapinfo, DIB_RGB_COLORS, SRCCOPY);
// Win32Surface /////////////////////////////////////////////////////////////////////////////
-void org::xwt::plat::Win32$Win32Surface::natInit(jboolean framed) {
+void org::ibex::plat::Win32$Win32Surface::natInit(jboolean framed) {
// Ask the message-handling thread to create a window for us
- PostThreadMessage((DWORD)org::xwt::plat::Win32::messagePumpThread, WM_USER + 2, (WPARAM)framed, (LPARAM)this);
+ PostThreadMessage((DWORD)org::ibex::plat::Win32::messagePumpThread, WM_USER + 2, (WPARAM)framed, (LPARAM)this);
hwndCreated->block();
// turn on incremental GC now that we have a user-visible interface
ShowWindow ((HWND)hwnd, SW_SHOWDEFAULT);
}
-void org::xwt::plat::Win32$Win32Surface::finalize() { /* DeleteObject((void*)hwnd); */ }
-void org::xwt::plat::Win32$Win32Surface::toFront() { BringWindowToTop((HWND)hwnd); }
-void org::xwt::plat::Win32$Win32Surface::toBack() { SetWindowPos((HWND)hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); }
-void org::xwt::plat::Win32$Win32Surface::_dispose() { PostMessage((HWND)hwnd, WM_USER_DISPOSE, 0, 0); }
-void org::xwt::plat::Win32$Win32Surface::setInvisible(jboolean h) { ShowWindow((HWND)hwnd, h ? SW_HIDE : SW_SHOWNORMAL); }
-void org::xwt::plat::Win32$Win32Surface::_setMinimized(jboolean m) { ShowWindow((HWND)hwnd, m ? SW_SHOWMINIMIZED : SW_SHOWNORMAL); }
-void org::xwt::plat::Win32$Win32Surface::_setMaximized(jboolean m) { ShowWindow((HWND)hwnd, m ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL); }
-void org::xwt::plat::Win32$Win32Surface::postCursorChange() { PostMessage((HWND)hwnd, WM_USER_SETCURSOR, 0, 0); }
+void org::ibex::plat::Win32$Win32Surface::finalize() { /* DeleteObject((void*)hwnd); */ }
+void org::ibex::plat::Win32$Win32Surface::toFront() { BringWindowToTop((HWND)hwnd); }
+void org::ibex::plat::Win32$Win32Surface::toBack() { SetWindowPos((HWND)hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); }
+void org::ibex::plat::Win32$Win32Surface::_dispose() { PostMessage((HWND)hwnd, WM_USER_DISPOSE, 0, 0); }
+void org::ibex::plat::Win32$Win32Surface::setInvisible(jboolean h) { ShowWindow((HWND)hwnd, h ? SW_HIDE : SW_SHOWNORMAL); }
+void org::ibex::plat::Win32$Win32Surface::_setMinimized(jboolean m) { ShowWindow((HWND)hwnd, m ? SW_SHOWMINIMIZED : SW_SHOWNORMAL); }
+void org::ibex::plat::Win32$Win32Surface::_setMaximized(jboolean m) { ShowWindow((HWND)hwnd, m ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL); }
+void org::ibex::plat::Win32$Win32Surface::postCursorChange() { PostMessage((HWND)hwnd, WM_USER_SETCURSOR, 0, 0); }
-void org::xwt::plat::Win32$Win32Surface::setLocation() {
+void org::ibex::plat::Win32$Win32Surface::setLocation() {
POINT point;
RECT rect;
point.x = 0;
SetWindowPos((HWND)hwnd, NULL, root->x - (point.x - rect.left), root->y - (point.y - rect.top), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
-void org::xwt::plat::Win32$Win32Surface::_setSize(jint w, jint h) {
+void org::ibex::plat::Win32$Win32Surface::_setSize(jint w, jint h) {
RECT client_rect, window_rect;
GetClientRect((HWND)hwnd, &client_rect);
GetWindowRect((HWND)hwnd, &window_rect);
SetWindowPos((HWND)hwnd, NULL, 0, 0, width, height, SWP_NOZORDER | SWP_NOMOVE);
}
-void org::xwt::plat::Win32$Win32Surface::setTitleBarText(java::lang::String* title) {
+void org::ibex::plat::Win32$Win32Surface::setTitleBarText(java::lang::String* title) {
int len = min(1024, JvGetStringUTFLength(title));
char buf[len + 1];
buf[len] = '\0';
SetWindowText((HWND)hwnd, buf);
}
-void org::xwt::plat::Win32$Win32Surface::setIcon(org::xwt::Picture* p0) {
+void org::ibex::plat::Win32$Win32Surface::setIcon(org::ibex::Picture* p0) {
- org::xwt::plat::Win32$Win32Picture* p = (org::xwt::plat::Win32$Win32Picture*)p0;
+ org::ibex::plat::Win32$Win32Picture* p = (org::ibex::plat::Win32$Win32Picture*)p0;
int icon_width = GetSystemMetrics(SM_CXSMICON);
int icon_height = GetSystemMetrics(SM_CYSMICON);
}
static jstring keyToString(WPARAM wParam);
-jint org::xwt::plat::Win32$Win32Surface::WndProc(jint _hwnd, jint _iMsg, jint _wParam, jint _lParam) {
+jint org::ibex::plat::Win32$Win32Surface::WndProc(jint _hwnd, jint _iMsg, jint _wParam, jint _lParam) {
UINT iMsg = (UINT)_iMsg;
WPARAM wParam = (WPARAM)_wParam;
mmi->ptMinTrackSize.x = ((uint32_t)root->minwidth) + addwidth;
mmi->ptMinTrackSize.y = ((uint32_t)root->minheight) + addheight;
resizable = !((root->minwidth == root->maxwidth) && (root->minheight == root->maxheight));
- mmi->ptMaxTrackSize.x = resizable ? org::xwt::plat::Win32::getScreenWidth() : mmi->ptMinTrackSize.x;
- mmi->ptMaxTrackSize.y = resizable ? org::xwt::plat::Win32::getScreenHeight() : mmi->ptMinTrackSize.y;
+ mmi->ptMaxTrackSize.x = resizable ? org::ibex::plat::Win32::getScreenWidth() : mmi->ptMinTrackSize.x;
+ mmi->ptMaxTrackSize.y = resizable ? org::ibex::plat::Win32::getScreenHeight() : mmi->ptMinTrackSize.y;
return 0;
case WM_PAINT:
PAINTSTRUCT ps;
- BeginPaint((HWND)org::xwt::plat::Win32$Win32Surface::hwnd, &ps);
+ BeginPaint((HWND)org::ibex::plat::Win32$Win32Surface::hwnd, &ps);
Dirty(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top);
- EndPaint((HWND)org::xwt::plat::Win32$Win32Surface::hwnd, &ps);
+ EndPaint((HWND)org::ibex::plat::Win32$Win32Surface::hwnd, &ps);
return 0;
default: break;