2003/09/27 06:42:26
[org.ibex.core.git] / src / org / xwt / plat / Win32.cc
index 06c5195..7f5799c 100644 (file)
 #include <org/xwt/Surface.h>
 #include <org/xwt/PixelBuffer.h>
 #include <org/xwt/Picture.h>
-#include <org/xwt/ByteStream.h>
 #include <org/xwt/Platform.h>
-#include <org/xwt/Platform$ParsedFont.h>
 #include <org/xwt/plat/Win32.h>
-#include <org/xwt/plat/Win32$Win32Font.h>
 #include <org/xwt/plat/Win32$Win32Surface.h>
 #include <org/xwt/plat/Win32$Win32PixelBuffer.h>
 #include <org/xwt/plat/Win32$Win32Picture.h>
@@ -64,25 +61,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam) {
     }
 }
 
-// This function iterates over each family (lparam == 0), and then over each size (lparam == 1)
-int CALLBACK fontproc(const LOGFONTA* enumlogfont, const TEXTMETRICA* tm, long unsigned int type, LPARAM lparam) {
-
-    if (lparam == 0) {
-        LOGFONT lf;
-        lf.lfCharSet = ANSI_CHARSET;
-        strncpy(lf.lfFaceName, enumlogfont->lfFaceName, 32);
-        lf.lfPitchAndFamily = 0;
-        EnumFontFamiliesEx((HDC)org::xwt::plat::Win32::desktop_dc, &lf, fontproc, 1, 0);
-
-    } else {
-        org::xwt::plat::Win32::addFont(JvNewStringLatin1(enumlogfont->lfFaceName),
-                                       ((type & RASTER_FONTTYPE) == 0) ? 0 : tm->tmHeight,
-                                       tm->tmItalic == 0 ? 0 : 1, 
-                                       tm->tmWeight <= 400 ? 0 : 1);
-    }
-    return 1;
-}
-
 
 // Initialization ////////////////////////////////////////////////////////////////////
 
@@ -186,13 +164,6 @@ void org::xwt::plat::Win32::natInit() {
     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);
 
-    // enumerate fonts
-    LOGFONT lf;
-    lf.lfCharSet = ANSI_CHARSET;
-    lf.lfFaceName[0] = 0;
-    lf.lfPitchAndFamily = 0;
-    EnumFontFamiliesEx((HDC)desktop_dc, &lf, fontproc, 0, 0);
-
     messagePumpThread = (jint)GetCurrentThreadId();
     messagePumpStarted->release();
 
@@ -353,50 +324,6 @@ jint org::xwt::plat::Win32::_getScreenHeight() {
     return rect.bottom - rect.top;
 }
 
-org::xwt::plat::Win32$Win32Font* org::xwt::plat::Win32::mapFont(org::xwt::Platform$ParsedFont* pf) {
-    org::xwt::plat::Win32$Win32Font* ret = new org::xwt::plat::Win32$Win32Font();
-    LOGFONT logfont;
-    memset(&logfont, 0, sizeof(LOGFONT));
-    logfont.lfHeight = -MulDiv(pf->size, GetDeviceCaps((HDC)org::xwt::plat::Win32::desktop_dc, LOGPIXELSY), 72);
-    if (pf->italic) logfont.lfItalic = 1;
-    if (pf->bold) logfont.lfWeight = FW_BOLD;
-    logfont.lfCharSet = ANSI_CHARSET;
-
-    JvGetStringUTFRegion(pf->name, 0, min(31, JvGetStringUTFLength(pf->name)), logfont.lfFaceName);
-    logfont.lfFaceName[min(31, JvGetStringUTFLength(pf->name))] = 0;
-
-    ret->hfont = (jint)CreateFontIndirect(&logfont);
-    SelectObject((HDC)desktop_dc, (HFONT)(ret->hfont));
-
-    TEXTMETRIC tm;
-    GetTextMetrics((HDC)desktop_dc, &tm);
-    POINT p;
-    p.x = 0; p.y = tm.tmAscent;
-    LPtoDP((HDC)desktop_dc, &p, 1); 
-    ret->maxAscent = p.y;
-
-    p.x = 0; p.y = tm.tmDescent;
-    LPtoDP((HDC)desktop_dc, &p, 1);
-    ret->maxDescent = p.y;
-
-    return ret;
-}
-
-jint org::xwt::plat::Win32::_stringWidth(jstring font, jstring text) {
-
-    HFONT hfont = (HFONT)(getFont(font)->hfont);
-    SelectObject((HDC)org::xwt::plat::Win32::desktop_dc, hfont);
-
-    int len = min(1024, JvGetStringUTFLength(text));
-    char buf[len + 1];
-    buf[len] = '\0';
-    JvGetStringUTFRegion(text, 0, len, buf);
-    
-    SIZE size;
-    GetTextExtentPoint32((HDC)org::xwt::plat::Win32::desktop_dc, buf, len, &size);
-    return size.cx;
-}
-
 jboolean org::xwt::plat::Win32::_newBrowserWindow_(jstring url) {
 
     int len = min(2048, JvGetStringUTFLength(url));
@@ -494,23 +421,6 @@ void org::xwt::plat::Win32$Win32PixelBuffer::drawPicture(org::xwt::Picture* sour
 
 }
 
-void org::xwt::plat::Win32$Win32PixelBuffer::drawString(jstring font, jstring text, jint x, jint y, jint color) {
-
-    org::xwt::plat::Win32$Win32Font* wf = org::xwt::plat::Win32::getFont(font);
-    SelectObject((HDC)hdc, (HFONT)(wf->hfont));
-
-    // Platform API passes us the y-pos of the bottom of the text; we need the top
-    y -= wf->maxAscent;
-
-    int len = min(1024, JvGetStringUTFLength(text));
-    char buf[len + 1];
-    buf[len] = '\0';
-    JvGetStringUTFRegion(text, 0, len, buf);
-
-    SetTextColor((HDC)hdc, PALETTERGB((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, color & 0xFF));
-    TextOut((HDC)hdc, x, y, buf, len);
-}
-
 void org::xwt::plat::Win32$Win32PixelBuffer::fillRect(jint x, jint y, jint x2, jint y2, jint color) {
     jint w = x2 - x;
     jint h = y2 - y;
@@ -626,14 +536,14 @@ void org::xwt::plat::Win32$Win32Surface::_setMinimized(jboolean m) { ShowWindow(
 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::xwt::plat::Win32$Win32Surface::setLocation(jint x, jint y) {
+void org::xwt::plat::Win32$Win32Surface::setLocation() {
     POINT point;
     RECT rect;
     point.x = 0;
     point.y = 0;
     ClientToScreen((HWND)hwnd, &point);
     GetWindowRect((HWND)hwnd, &rect);
-    SetWindowPos((HWND)hwnd, NULL, x - (point.x - rect.left), y - (point.y - rect.top), 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+    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) {
@@ -711,7 +621,6 @@ jint org::xwt::plat::Win32$Win32Surface::WndProc(jint _hwnd, jint _iMsg, jint _w
     switch(iMsg) {
     case WM_DEVMODECHANGE: break;    // FEATURE: color depth changed
     case WM_DISPLAYCHANGE: break;    // FEATURE: screen size changed
-    case WM_FONTCHANGE: break;       // FEATURE: set of fonts changed
     case WM_MOUSEWHEEL: break;       // FEATURE: Mouse Wheel
 
     case WM_SYSKEYDOWN: if (GetKeyState(VK_MENU) >> (sizeof(SHORT) * 8 - 1) == 0) return 0;