X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c1855476b1c7afadef8c6df741d3155f94fab3ce..a29b55cdf6c1f8547c615a5e928813ba78566e9a:/src/msw/toplevel.cpp diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index ee7bed0b1f..3cf38606e3 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -42,10 +42,11 @@ #include "wx/module.h" #include "wx/msw/private.h" -#if defined(__WXWINCE__) +#if defined(__WXWINCE__) && !defined(__HANDHELDPC__) #include #include - #if _WIN32_WCE < 400 + // Standard SDK doesn't have aygshell.dll: see include/wx/msw/wince/libraries.h + #if _WIN32_WCE < 400 || !defined(__WINCE_STANDARDSDK__) #include #endif #include "wx/msw/wince/missing.h" @@ -84,11 +85,12 @@ wxDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); // globals // ---------------------------------------------------------------------------- -// list of all frames and modeless dialogs -wxWindowList wxModelessWindows; - -// the name of the default wxWindows class +// the name of the default wxWidgets class +#ifdef __WXWINCE__ +extern wxChar *wxCanvasClassName; +#else extern const wxChar *wxCanvasClassName; +#endif // ---------------------------------------------------------------------------- // wxTLWHiddenParentModule: used to manage the hidden parent window (we need a @@ -141,6 +143,10 @@ void wxTopLevelWindowMSW::Init() m_fsIsShowing = FALSE; m_winLastFocused = (wxWindow *)NULL; + +#ifdef __SMARTPHONE__ + m_MenuBarHWND = 0; +#endif } WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const @@ -167,6 +173,7 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const } //else: WS_OVERLAPPED is 0 anyhow, so it is on by default +#ifndef __SMARTPHONE__ // border and caption styles if ( style & wxRESIZE_BORDER ) msflags |= WS_THICKFRAME; @@ -176,6 +183,7 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const msflags |= WS_BORDER; else msflags |= WS_POPUP; +#endif // normally we consider that all windows without caption must be popups, // but CE is an exception: there windows normally do not have the caption @@ -206,11 +214,11 @@ WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const // Keep this here because it saves recoding this function in wxTinyFrame if ( style & (wxTINY_CAPTION_VERT | wxTINY_CAPTION_HORIZ) ) msflags |= WS_CAPTION; - + if ( exflags ) { // there is no taskbar under CE, so omit all this -#ifndef __WXWINCE__ +#if !defined(__WXWINCE__) if ( !(GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) ) { if ( style & wxFRAME_TOOL_WINDOW ) @@ -384,10 +392,12 @@ bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, y = (sizeDpy.y - h) / 2; } +#if !defined(__WXWINCE__) || defined(__WINCE_STANDARDSDK__) if ( !::MoveWindow(GetHwnd(), x, y, w, h, FALSE) ) { wxLogLastError(wxT("MoveWindow")); } +#endif if ( !title.empty() ) { @@ -407,7 +417,17 @@ bool wxTopLevelWindowMSW::CreateFrame(const wxString& title, WXDWORD exflags; WXDWORD flags = MSWGetCreateWindowFlags(&exflags); - return MSWCreate(wxCanvasClassName, title, pos, size, flags, exflags); +#if !defined(__HANDHELDPC__) && ((defined(_WIN32_WCE) && _WIN32_WCE < 400) || \ + defined(__POCKETPC__) || \ + defined(__SMARTPHONE__)) + // Always expand to fit the screen in PocketPC or SmartPhone + wxSize sz(wxDefaultSize); + wxUnusedVar(size); +#else // other (including normal desktop) Windows + wxSize sz(size); +#endif + + return MSWCreate(wxCanvasClassName, title, pos, sz, flags, exflags); } bool wxTopLevelWindowMSW::Create(wxWindow *parent, @@ -500,14 +520,23 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, ); } + // Native look is full screen window on Smartphones and Standard SDK +#if defined(__WXWINCE__) + if ( style & wxMAXIMIZE ) + { + this->Maximize(); + } +#endif + +#ifdef __SMARTPHONE__ + SetRightMenu(); // to nothing for initialization +#endif + return ret; } wxTopLevelWindowMSW::~wxTopLevelWindowMSW() { - if ( wxModelessWindows.Find(this) ) - wxModelessWindows.DeleteObject(this); - // after destroying an owned window, Windows activates the next top level // window in Z order but it may be different from our owner (to reproduce // this simply Alt-TAB to another application and back before closing the @@ -547,6 +576,11 @@ bool wxTopLevelWindowMSW::Show(bool show) // show and maximize nShowCmd = SW_MAXIMIZE; + // This is necessary, or no window appears +#ifdef __WINCE_STANDARDSDK__ + DoShowWindow(SW_SHOW); +#endif + m_maximizeOnShow = FALSE; } else // just show @@ -564,6 +598,13 @@ bool wxTopLevelWindowMSW::Show(bool show) DoShowWindow(nShowCmd); +#if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) + // Addornments have to be added when the frame is the correct size + wxFrame* frame = wxDynamicCast(this, wxFrame); + if (frame && frame->GetMenuBar()) + frame->GetMenuBar()->AddAdornments(GetWindowStyleFlag()); +#endif + if ( show ) { ::BringWindowToTop(GetHwnd()); @@ -726,7 +767,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) rect.x, rect.y, rect.width, rect.height, flags); -#if defined(__WXWINCE__) && _WIN32_WCE < 400 +#if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400)) ::SHFullScreen(GetHwnd(), SHFS_HIDETASKBAR | SHFS_HIDESIPBUTTON); #endif @@ -736,7 +777,7 @@ bool wxTopLevelWindowMSW::ShowFullScreen(bool show, long style) } else // stop showing full screen { -#if defined(__WXWINCE__) && _WIN32_WCE < 400 +#if !defined(__HANDHELDPC__) && (defined(__WXWINCE__) && (_WIN32_WCE < 400)) ::SHFullScreen(GetHwnd(), SHFS_SHOWTASKBAR | SHFS_SHOWSIPBUTTON); #endif Maximize(m_fsIsMaximized); @@ -800,12 +841,13 @@ bool wxTopLevelWindowMSW::EnableCloseButton(bool enable) return FALSE; } - +#ifndef __WXWINCE__ // update appearance immediately if ( !::DrawMenuBar(GetHwnd()) ) { wxLogLastError(_T("DrawMenuBar")); } +#endif #endif // !__WXMICROWIN__ return TRUE; @@ -913,25 +955,46 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) } } -// the DialogProc for all wxWindows dialogs +// the DialogProc for all wxWidgets dialogs LONG APIENTRY _EXPORT -wxDlgProc(HWND WXUNUSED(hDlg), +wxDlgProc(HWND hDlg, UINT message, WPARAM WXUNUSED(wParam), LPARAM WXUNUSED(lParam)) { - switch ( message ) + if ( message == WM_INITDIALOG ) { - case WM_INITDIALOG: - // for this message, returning TRUE tells system to set focus to - // the first control in the dialog box, but as we set the focus - // ourselves, we return FALSE from here as well, so fall through - - default: - // for all the other ones, FALSE means that we didn't process the - // message - return FALSE; + // under CE, add a "Ok" button in the dialog title bar and make it full + // screen + // + // VZ: we should probably allow for overriding this, e.g. by including + // MAXIMIZED flag in the dialog style by default and doing this + // only if it is present... + + // Standard SDK doesn't have aygshell.dll: see + // include/wx/msw/wince/libraries.h +#if defined(__WXWINCE__) && !defined(__WINCE_STANDARDSDK__) && !defined(__HANDHELDPC__) + SHINITDLGINFO shidi; + shidi.dwMask = SHIDIM_FLAGS; + shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN +#ifndef __SMARTPHONE__ + | SHIDIF_DONEBUTTON +#endif + ; + shidi.hDlg = hDlg; + SHInitDialog( &shidi ); +#else // no SHInitDialog() + wxUnusedVar(hDlg); +#endif } + + // for almost all messages, returning FALSE means that we didn't process + // the message + // + // for WM_INITDIALOG, returning TRUE tells system to set focus to + // the first control in the dialog box, but as we set the focus + // ourselves, we return FALSE for it as well + return FALSE; } // ============================================================================