diff --git a/toolkit/mozapps/update/src/updater/Makefile.in b/toolkit/mozapps/update/src/updater/Makefile.in index 44b662cbc0a..7d3c77e49c9 100644 --- a/toolkit/mozapps/update/src/updater/Makefile.in +++ b/toolkit/mozapps/update/src/updater/Makefile.in @@ -84,12 +84,17 @@ endif ifeq ($(OS_ARCH),WINCE) USE_STATIC_LIBS = 1 HAVE_PROGRESSUI = 1 -RCINCLUDE = updater_wince.rc CPPSRCS += \ updater_wince.cpp \ progressui_win.cpp \ $(NULL) OS_LIBS += $(call EXPAND_LIBNAME,commctrl ws2) +ifdef WINCE_WINDOWS_MOBILE +OS_LIBS += $(call EXPAND_LIBNAME,aygshell) +RCINCLUDE = updater_winmo.rc +else +RCINCLUDE = updater_wince.rc +endif DEFINES += -DUNICODE -D_UNICODE RCFLAGS += -I$(srcdir) REQUIRES += string diff --git a/toolkit/mozapps/update/src/updater/progressui_win.cpp b/toolkit/mozapps/update/src/updater/progressui_win.cpp index 4c1ea85a869..a4b836b453f 100644 --- a/toolkit/mozapps/update/src/updater/progressui_win.cpp +++ b/toolkit/mozapps/update/src/updater/progressui_win.cpp @@ -42,6 +42,11 @@ #include #include #include + +#ifdef WINCE_WINDOWS_MOBILE +#include +#endif + #include "resource.h" #include "progressui.h" #include "readstrings.h" @@ -168,9 +173,7 @@ InitDialog(HWND hDlg) RECT infoSize, textSize; HWND hWndInfo = GetDlgItem(hDlg, IDC_INFO); - // We need the current size and font to calculate the adjustment. - GetClientRect(hWndInfo, &infoSize); - + // Get the control's font for calculating the new size for the control HDC hDCInfo = GetDC(hWndInfo); HFONT hInfoFont, hOldFont; hInfoFont = (HFONT)SendMessage(hWndInfo, WM_GETFONT, 0, 0); @@ -178,12 +181,101 @@ InitDialog(HWND hDlg) if (hInfoFont) hOldFont = (HFONT)SelectObject(hDCInfo, hInfoFont); - // Measure the space needed for the text - DT_CALCRECT means nothing is drawn. - if (DrawText(hDCInfo, szwInfo, wcslen(szwInfo) + 1, &textSize, - DT_CALCRECT | DT_NOCLIP | DT_SINGLELINE)) { + // There are three scenarios that need to be handled differently + // 1. Windows Mobile where dialog should be full screen. + // 2. Windows CE where the dialog might wrap. + // 3. Windows where the dialog should never wrap. The Windows CE and Windows + // scenarios could be combined but then we would have to calculate the + // extra border space added by the Aero theme which just adds complexity. +#ifdef WINCE +#ifdef WINCE_WINDOWS_MOBILE + RECT rcDlgInner1, rcDlgInner2, rcInfoOuter1, rcInfoOuter2; + // The dialog's client rectangle and the window rectangle for the text before + // making the dialog full screen are needed to calculate the change in border + // sizes. + GetClientRect(hDlg, &rcDlgInner1); + GetWindowRect(hWndInfo, &rcInfoOuter1); + + // Make the dialog fullscreen + SHINITDLGINFO shidi; + shidi.dwMask = SHIDIM_FLAGS; + shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN; + shidi.hDlg = hDlg; + SHInitDialog(&shidi); + if (!SHInitDialog(&shidi)) + return; + + // Hide the OK button + SHDoneButton(hDlg, SHDB_HIDE); + + GetClientRect(hDlg, &rcDlgInner2); + GetWindowRect(hWndInfo, &rcInfoOuter2); + textSize.left = 0; + // Calculate the maximum possible width for the text by adding to the + // existing text rectangle's window width the change in the dialog rectangle's + // client width and the change in the text rectangle's window left position + // after the dialog has been made full screen. + textSize.right = (rcInfoOuter2.right - rcInfoOuter2.left) + \ + (rcDlgInner2.right - rcDlgInner1.right) + \ + (rcInfoOuter1.left - rcInfoOuter2.left); +#else + RECT rcWorkArea, rcInfoOuter1; + GetWindowRect(hWndInfo, &rcInfoOuter1); + SystemParametersInfo(SPI_GETWORKAREA, NULL, &rcWorkArea, NULL); + textSize.left = 0; + // Calculate the maximum possible width for the text by subtracting from the + // existing working area's width the text rectangle's margin. + textSize.right = (rcWorkArea.right - rcWorkArea.left) - \ + (rcInfoOuter1.left + rcInfoOuter1.right); +#endif + // Measure the space needed for the text allowing multiple lines if necessary. + // DT_CALCRECT means nothing is drawn. + if (DrawText(hDCInfo, szwInfo, -1, &textSize, + DT_CALCRECT | DT_NOCLIP | DT_WORDBREAK)) { + GetClientRect(hWndInfo, &infoSize); SIZE extra; - extra.cx = (textSize.right - textSize.left) - (infoSize.right - infoSize.left); - extra.cy = (textSize.bottom - textSize.top) - (infoSize.bottom - infoSize.top); + // Calculate the additional space needed for the text by subtracting from + // the rectangle returned by DrawText the existing client rectangle's width + // and height. + extra.cx = (textSize.right - textSize.left) - \ + (infoSize.right - infoSize.left); + extra.cy = (textSize.bottom - textSize.top) - \ + (infoSize.bottom - infoSize.top); + // XXX rstrong - add 2 pixels to the width to prevent the text from wrapping + // due to Windows CE and Windows Mobile adding an extra pixel to the + // beginning and the end of the text. Though I have found no good reason for + // this it has been consistent with multiple font sizes. + extra.cx += 2; + + RESIZE_WINDOW(hWndInfo, extra.cx, extra.cy); + RESIZE_WINDOW(hWndPro, extra.cx, 0); + +#ifdef WINCE_WINDOWS_MOBILE + // Move the controls 1 pixel to the left on Windows Mobile to compensate for + // the 2 extra pixels added to the controls above. This isn't needed on + // Windows CE for reasons of the unknown variety. + MOVE_WINDOW(hWndInfo, -1, 0); + MOVE_WINDOW(hWndPro, -1, extra.cy); +#else + RESIZE_WINDOW(hDlg, extra.cx, extra.cy); + MOVE_WINDOW(hWndPro, 0, extra.cy); +#endif + } + +#else + // Measure the space needed for the text on a single line. DT_CALCRECT means + // nothing is drawn. + if (DrawText(hDCInfo, szwInfo, -1, &textSize, + DT_CALCRECT | DT_NOCLIP | DT_SINGLELINE)) { + GetClientRect(hWndInfo, &infoSize); + SIZE extra; + // Calculate the additional space needed for the text by subtracting from + // the rectangle returned by DrawText the existing client rectangle's width + // and height. + extra.cx = (textSize.right - textSize.left) - \ + (infoSize.right - infoSize.left); + extra.cy = (textSize.bottom - textSize.top) - \ + (infoSize.bottom - infoSize.top); if (extra.cx < 0) extra.cx = 0; if (extra.cy < 0) @@ -195,13 +287,17 @@ InitDialog(HWND hDlg) MOVE_WINDOW(hWndPro, 0, extra.cy); } } +#endif if (hOldFont) SelectObject(hDCInfo, hOldFont); ReleaseDC(hWndInfo, hDCInfo); + // On Windows Mobile the dialog is full screen so don't center it. +#ifndef WINCE_WINDOWS_MOBILE CenterDialog(hDlg); // make dialog appear in the center of the screen +#endif SetTimer(hDlg, TIMER_ID, TIMER_INTERVAL, NULL); } diff --git a/toolkit/mozapps/update/src/updater/updater.rc b/toolkit/mozapps/update/src/updater/updater.rc index 0681b7be1c7..1afbee5314e 100644 --- a/toolkit/mozapps/update/src/updater/updater.rc +++ b/toolkit/mozapps/update/src/updater/updater.rc @@ -44,9 +44,8 @@ IDD_DIALOG DIALOGEX 0, 0, 253, 41 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,24,239, - 10 - LTEXT "",IDC_INFO,7,8,239,13 + CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,24,239,10 + LTEXT "",IDC_INFO,7,8,239,13,SS_NOPREFIX END diff --git a/toolkit/mozapps/update/src/updater/updater_wince.rc b/toolkit/mozapps/update/src/updater/updater_wince.rc index a18f65c54d9..65de4b3b47c 100644 --- a/toolkit/mozapps/update/src/updater/updater_wince.rc +++ b/toolkit/mozapps/update/src/updater/updater_wince.rc @@ -38,7 +38,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION FONT 8, "MS Shell Dlg" BEGIN CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,24,139,10 - LTEXT "",IDC_INFO,7,8,139,13 + LTEXT "",IDC_INFO,7,8,139,13,SS_NOPREFIX END diff --git a/toolkit/mozapps/update/src/updater/updater_winmo.rc b/toolkit/mozapps/update/src/updater/updater_winmo.rc new file mode 100644 index 00000000000..79aaed2b0ae --- /dev/null +++ b/toolkit/mozapps/update/src/updater/updater_winmo.rc @@ -0,0 +1,106 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winuser.h" +#include "aygshell.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +IDI_DIALOG ICON "updater.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_DIALOG DIALOG 0, 0, 153, 41 +STYLE DS_SETFONT | WS_POPUP | WS_CAPTION | WS_NONAVDONEBUTTON +EXSTYLE 0x80000000L +FONT 8, "MS Shell Dlg" +BEGIN + CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER,7,20,139,10 + LTEXT "",IDC_INFO,7,4,139,13,SS_NOPREFIX +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 146 + TOPMARGIN, 3 + BOTTOMMARGIN, 39 + END +END +#endif // APSTUDIO_INVOKED + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winuser.h""\r\n" + "#include ""aygshell.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED +