Opened 13 years ago
Closed 10 years ago
#554 closed enhancement/feature request (Incomplete/Missing infos)
WIN-Mo 6.5 - Icons for Wvga (800x480)
Reported by: | schappi2610 | Owned by: | kazer |
---|---|---|---|
Priority: | minor | Milestone: | version 0.2.1 |
Component: | port/wince | Version: | git master |
Severity: | Keywords: | wince, ui | |
Cc: | mbitter, thomas0782@… |
Description
Icons and font for large WinCE resolutions do not apply. Icons and fonts are lying over each other. Streetnames are often not readable. working with nightlybuild 2976 for WinCE.
Attachments (10)
Change History (20)
comment:1 Changed 13 years ago by kazer
- Component changed from gui/internal to port/wince
- Owner changed from cp15 to kazer
- Status changed from new to assigned
comment:2 Changed 13 years ago by mbitter
- Cc mbitter added
The previous patch my contain a leak of GDI+ font objects. The attatched patch fixes some more problems I have found:
- When Navit crashes on WinCE the task bar is still missing. Using aygshell fixes this
- WinCE allows a sleeptime of 10 seconds for the screen lock, so I changed the interval for calling SystemIdleTimerReset from 29 to 9 seconds
- The text position was not right. I added the distance between the font-base-line and the lowest pixel
- When mesuring the bbox of the text I'm using the right font
- Always delete the GDI+ font object
Index: navit/graphics/win32/graphics_win32.c =================================================================== --- navit/graphics/win32/graphics_win32.c (Revision 3129) +++ navit/graphics/win32/graphics_win32.c (Arbeitskopie) @@ -20,6 +20,10 @@ #include "profile.h" #include "keys.h" +#ifdef HAVE_API_WIN32_CE +#include <aygshell.h> +#endif + //#define FAST_TRANSPARENCY 1 typedef BOOL (WINAPI *FP_AlphaBlend) ( HDC hdcDest, @@ -97,14 +101,7 @@ SaveDC (hdc) ; -#ifndef HAVE_API_WIN32_CE - SetGraphicsMode (hdc, GM_ADVANCED) ; - ModifyWorldTransform (hdc, NULL, MWT_IDENTITY) ; -#endif SetViewportOrgEx (hdc, 0, 0, NULL) ; -#ifndef HAVE_API_WIN32_CE - SetWindowOrgEx (hdc, 0, 0, NULL) ; -#endif if (fLogRes) { @@ -123,9 +120,6 @@ pt.x = (int) (iDeciPtWidth * cxDpi / 72) ; pt.y = (int) (iDeciPtHeight * cyDpi / 72) ; -#ifndef HAVE_API_WIN32_CE - DPtoLP (hdc, &pt, 1) ; -#endif lf.lfHeight = - (int) (fabs (pt.y) / 10.0 + 0.5) ; lf.lfWidth = 0 ; lf.lfEscapement = 0 ; @@ -237,7 +231,7 @@ hdc = GetDC( gr->wnd_handle ); // Creates memory DC gr->hMemDC = CreateCompatibleDC(hdc); - dbg(0, "resize memDC to: %d %d \n", gr->width, gr->height ); + dbg(1, "resize memDC to: %d %d \n", gr->width, gr->height ); #ifndef FAST_TRANSPARENCY @@ -275,7 +269,7 @@ { TCHAR key = (TCHAR) wParam; char *s=NULL; - dbg(0,"HandleKey %d\n",key); + dbg(1,"HandleKey %d\n",key); switch (key) { default: s=(char []){key, 0}; @@ -288,7 +282,7 @@ static void HandleKeyDown(struct graphics_priv *gra_priv, WPARAM wParam) { int key = (int) wParam; - dbg(0,"HandleKey %d\n",key); + dbg(1,"HandleKey %d\n",key); char *s=NULL; switch (key) { case 37: @@ -369,7 +363,7 @@ gra_priv->width = LOWORD( lParam ); gra_priv->height = HIWORD( lParam ); create_memory_dc(gra_priv); - dbg(0, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height ); + dbg(1, "resize gfx to: %d %d \n", gra_priv->width, gra_priv->height ); callback_list_call_attr_2(gra_priv->cbl, attr_resize, (void *)gra_priv->width, (void *)gra_priv->height); } break; @@ -529,18 +523,25 @@ { #ifdef HAVE_API_WIN32_CE - HWND hwndTaskbar = FindWindow(L"HHTaskBar", NULL); + // From the MSDN example at http://msdn.microsoft.com/en-us/library/aa930139.aspx + DWORD dwState; + RECT rc; - if (on) { - ShowWindow(hwndTaskbar, SW_HIDE); - MoveWindow(g_hwnd, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), FALSE); - } else { - ShowWindow(hwndTaskbar, SW_SHOW); - RECT taskbar_rect; - GetWindowRect( hwndTaskbar, &taskbar_rect); - MoveWindow(g_hwnd, 0, taskbar_rect.bottom, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) - taskbar_rect.bottom, FALSE); + if (on) { + // To switch to full screen mode, first hide all of the shell parts. + dwState = (SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON); + SHFullScreen(g_hwnd, dwState); + // Next resize the main window to the size of the screen. + SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + MoveWindow(g_hwnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); + } else { + // To switch to normal mode, first show all of the shell parts. + dwState = (SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); + SHFullScreen(g_hwnd, dwState); + // Next resize the main window to the size of the work area. + SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, FALSE); + MoveWindow(g_hwnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE); } - #else if (on) { ShowWindow(g_hwnd, SW_MAXIMIZE); @@ -564,7 +565,7 @@ if ( win_priv && !win_priv->hBackLight ) { win_priv->hBackLight = SetPowerRequirement(TEXT("BKL1:"), 0, 0x01, NULL, 0); - event_win32_add_timeout(29000, 1, callback_new(SystemIdleTimerReset, 0, NULL)); + event_win32_add_timeout(9000, 1, callback_new(SystemIdleTimerReset, 0, NULL)); } SystemIdleTimerReset(); @@ -963,13 +964,16 @@ angle += 360; SetTextAlign (gr->hMemDC, TA_BASELINE) ; - SetViewportOrgEx (gr->hMemDC, p->x, p->y, NULL) ; font->lf.lfEscapement = font->lf.lfOrientation = ( angle * 10 ) ; DeleteObject (font->hfont) ; font->hfont = CreateFontIndirect (&font->lf); HFONT hOldFont = SelectObject(gr->hMemDC, font->hfont ); + TEXTMETRIC tm; + GetTextMetrics(gr->hMemDC, &tm); + SetViewportOrgEx (gr->hMemDC, p->x, p->y - tm.tmDescent , NULL) ; + { wchar_t utf16[1024]; const UTF8 *utf8 = (UTF8 *)text; @@ -987,6 +991,7 @@ SelectObject(gr->hMemDC, hOldFont); DeleteObject (font->hfont) ; + font->hfont = NULL; SetBkMode( gr->hMemDC, prevBkMode ); @@ -998,6 +1003,7 @@ if ( font->hfont ) { DeleteObject(font->hfont); + font->hfont = NULL; } g_free(font); } @@ -1413,6 +1419,40 @@ int yMax = 13*font->size/256; int xMax = 9*font->size*len/256; + if ( NULL == font->hfont ) + { +#ifdef WIN_USE_SYSFONT + font->hfont = (HFONT) GetStockObject (SYSTEM_FONT); + GetObject (font->hfont, sizeof (LOGFONT), &font->lf); +#else + font->hfont = EzCreateFont (gr->hMemDC, TEXT ("Arial"), font->size/2, 0, 0, TRUE); + GetObject ( font->hfont, sizeof (LOGFONT), &font->lf) ; +#endif + } + + HFONT hOldFont = SelectObject(gr->hMemDC, font->hfont ); + + { + wchar_t utf16[1024]; + const UTF8 *utf8 = (UTF8 *)text; + UTF16 *utf16p = (UTF16 *) utf16; + if (ConvertUTF8toUTF16(&utf8, utf8+strlen(text), + &utf16p, utf16p+sizeof(utf16), + lenientConversion) == conversionOK) + { + SIZE size; + if (GetTextExtentPointW(gr->hMemDC, utf16, (wchar_t*) utf16p - utf16, &size)) { + yMax = size.cy; + xMax = size.cx; + } + } + } + + SelectObject(gr->hMemDC, hOldFont); + + DeleteObject(font->hfont); + font->hfont = NULL; + ret[0].x = xMin; ret[0].y = -yMin; ret[1].x = xMin; @@ -1519,7 +1559,7 @@ { MSG msg; - dbg(0,"enter\n"); + dbg(1,"enter\n"); while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); /* Keyboard input. */ @@ -1530,7 +1570,7 @@ static void event_win32_main_loop_quit(void) { - dbg(0,"enter\n"); + dbg(1,"enter\n"); #ifdef HAVE_API_WIN32_CE HWND hwndTaskbar = FindWindow(L"HHTaskBar", NULL); ShowWindow(hwndTaskbar, SW_SHOW); @@ -1542,14 +1582,14 @@ static struct event_watch * event_win32_add_watch(void *h, enum event_watch_cond cond, struct callback *cb) { - dbg(0,"enter\n"); + dbg(1,"enter\n"); return NULL; } static void event_win32_remove_watch(struct event_watch *ev) { - dbg(0,"enter\n"); + dbg(1,"enter\n"); } static GList *timers; Index: navit/Makefile.am =================================================================== --- navit/Makefile.am (Revision 3129) +++ navit/Makefile.am (Arbeitskopie) @@ -108,7 +108,7 @@ if SUPPORT_WIN32 navit_LDADD += resource.rsc if SUPPORT_WIN32CE - navit_LDADD += -lcommctrl -Lsupport/libc + navit_LDADD += -lcommctrl -laygshell -Lsupport/libc else navit_LDADD += -lgdi32 -lcomctl32 -lwinmm endif
The following patch enables resolutions bigger than 320x240 for Win-CE devices. But I don't know if this has any changes to win32.
Index: navit/gui/win32/resources/resource.rc =================================================================== --- navit/gui/win32/resources/resource.rc (Revision 3129) +++ navit/gui/win32/resources/resource.rc (Arbeitskopie) @@ -12,3 +12,6 @@ IDB_NAVITTOOLBAR BITMAP DISCARDABLE "toolbar.bmp" IDI_NAVIT ICON DISCARDABLE "navit.ico" + +HI_RES_AWARE CEUX {1} +
All this is tested with arm-mingw32ce-gcc and Windows Mobile 6.1 on a ASUS mobile phone with a screen size of 640x480
comment:3 Changed 13 years ago by mvglasow (2)
I've tried the compiled EXE and made two observations: First, after a crash the task bar is still missing. (I used a regular navit install and just dropped in the new exe file.) Second, when resuming after a suspend, the task bar appears (even in fullscreen mode).
comment:4 Changed 12 years ago by kazer
The resource patch has been applied in r3722
comment:5 Changed 12 years ago by thomas0782
- Cc thomas0782@… added
I splitted the patches depending on the purpose and updated to be appliad to the last svn state. The files are attached and named by modification.
Changed 12 years ago by thomas0782
Changed 12 years ago by thomas0782
Changed 12 years ago by thomas0782
Changed 12 years ago by thomas0782
Changed 12 years ago by thomas0782
Changed 12 years ago by thomas0782
Changed 12 years ago by thomas0782
comment:6 Changed 12 years ago by thomas0782
- fullscreen: working, more elegant than #698, disables sip-button, taskbar and startbutton
- freegdi: no errors, freeing some gdi objects
- EzCreateFont?, draw_text, text_box: working, menu drawing looks much better
- debug: no errors
- systemidletimer: no errors
I think the patches can be appliad and the bug be closed.
comment:7 Changed 12 years ago by tryagain.myopenid.com
Given these a look.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.fullscreen.patch uses aygshell. AFAIK it's not available on all personal navigation devices. I've seen documentation for software suggesting to get aygshell.dll from warez sites, we're not going do do this, are we? So I'd better try not to use it. At least we should prepare to build a version without reference to aygshell.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.freegdi.patch shouldn't do any hurt, just cleans up already freed handles, looks good.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.EzCreateFont.patch looks like it will change Windows version, not WinCE one.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.draw_text.patch looks good.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.systemidletimer.patch looks good.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.text_bbox.patch - I'd better used a dynamic buffer for utf16. But still looks good.
- http://trac.navit-project.org/attachment/ticket/554/mbitter.debug.patch looks good.
Will try to apply these and report results here later.
comment:8 Changed 12 years ago by tryagain.myopenid.com
http://trac.navit-project.org/attachment/ticket/554/mbitter.EzCreateFont.patch notably degrades graphics perfomance of Desktop Windows version, significantly increasing CPU used by navit process when scrolling map.
comment:9 Changed 12 years ago by tryagain.myopenid.com
http://trac.navit-project.org/attachment/ticket/554/mbitter.fullscreen.patch doesn't apply cleanly to current SVN, and don't forget my note on aygshell at all.
http://trac.navit-project.org/attachment/ticket/554/mbitter.freegdi.patch applies well
http://trac.navit-project.org/attachment/ticket/554/mbitter.draw_text.patch rejected, applied it by hand.
http://trac.navit-project.org/attachment/ticket/554/mbitter.systemidletimer.patch applies well
http://trac.navit-project.org/attachment/ticket/554/mbitter.text_bbox.patch applies well
http://trac.navit-project.org/attachment/ticket/554/mbitter.debug.patch hunk# 4 failed, applied it by hand
Overall result for Desktop Windows: Entered text fits worse into Town Search, Create Bookmarks Folder entry fields. Now center of the entered text seems to go on the upper border of text entry field. Before applying the patches text was slightly exceeding upper border of entry field.
Didn't try this on WinCE yet.
Changed 12 years ago by tryagain.myopenid.com
Diff to current graphics_win32.c with patches applied as described above, mbitter.EzCreateFont?.patch and mbitter.fullscreen.patch are not applied.
comment:10 Changed 10 years ago by usul
- Keywords wince ui added
- Resolution set to Incomplete/Missing infos
- Status changed from assigned to closed
Seem to be unclear if this patch got into mainline and if the issue is fixed.
Please give any feedback if you can provide a device with such requirements.
As the issue is pending, I send the ticket to CFP.
In fact MBitter already submitted a patch for this issue, i'll post it for further references.