From 08b97268061292f7c3794dae243a6490b23a42f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Sun, 13 Nov 2005 11:46:24 +0000 Subject: [PATCH] Resize all top level windows when SIP changes visibility. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36162 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/tlw.tex | 9 +++ docs/latex/wx/wxmsw.tex | 4 +- include/wx/msw/frame.h | 15 ++--- include/wx/msw/toplevel.h | 14 +++++ src/msw/frame.cpp | 49 +-------------- src/msw/toplevel.cpp | 124 +++++++++++++++++++++++++++++++------- 7 files changed, 135 insertions(+), 81 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index dd3f962412..2eb8dec213 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -42,6 +42,7 @@ wxWinCE: - Pressing build-in joystick on WinCE phones fires wxEVT_JOY_BUTTON_DOWN event. - Native wxCheckListBox implementation. +- All wxTopLevelWindows resizes accordingly to SIP visibility. Unix: diff --git a/docs/latex/wx/tlw.tex b/docs/latex/wx/tlw.tex index c4e0534a30..6224124362 100644 --- a/docs/latex/wx/tlw.tex +++ b/docs/latex/wx/tlw.tex @@ -69,6 +69,15 @@ Gets a string containing the window title. \helpref{wxTopLevelWindow::SetTitle}{wxtoplevelwindowsettitle} +\membersection{wxTopLevelWindow::HandleSettingChange}\label{wxtoplevelwindowhandlesettingchange} + +\func{virtual bool}{HandleSettingChange}{\param{WXWPARAM}{ wParam}, \param{WXLPARAM}{ lParam}} + +Unique to the wxWinCE port. Responds to showing/hiding SIP (soft input panel) area and resize +accordingly window accordingly. Override this if you want to avoid resinzing or do additional +operations. + + \membersection{wxTopLevelWindow::IsActive}\label{wxtoplevelwindowisactive} \constfunc{bool}{IsActive}{\void} diff --git a/docs/latex/wx/wxmsw.tex b/docs/latex/wx/wxmsw.tex index a8689ef7e4..933b94bf43 100644 --- a/docs/latex/wx/wxmsw.tex +++ b/docs/latex/wx/wxmsw.tex @@ -117,8 +117,8 @@ that will do the right thing on each platform.) If the screen orientation changes, the windows will automatically be resized so no further action needs to be taken (unless you want to change the layout according to the orientation, which you could detect in idle time, for example). -However, if the input panel (SIP) is shown, windows do not yet resize accordingly. This will -be implemented soon. +When input panel (SIP) is shown, top level windows (frames and dialogs) resize +accordingly (see \helpref{wxTopLevelWindow::HandleSettingChange}{wxtoplevelwindowhandlesettingchange}). \subsubsection{Closing top-level windows in wxWinCE} diff --git a/include/wx/msw/frame.h b/include/wx/msw/frame.h index c90c105978..10c17972d5 100644 --- a/include/wx/msw/frame.h +++ b/include/wx/msw/frame.h @@ -18,12 +18,12 @@ public: // construction wxFrame() { Init(); } wxFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) + wxWindowID id, + const wxString& title, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + long style = wxDEFAULT_FRAME_STYLE, + const wxString& name = wxFrameNameStr) { Init(); @@ -149,9 +149,6 @@ private: #if wxUSE_TOOLTIPS WXHWND m_hwndToolTip; #endif // tooltips -#if defined(__SMARTPHONE__) || defined(__POCKETPC__) - void* m_activateInfo; -#endif // used by IconizeChildFrames(), see comments there bool m_wasMinimized; diff --git a/include/wx/msw/toplevel.h b/include/wx/msw/toplevel.h index 8e28a4bbab..56c99693b4 100644 --- a/include/wx/msw/toplevel.h +++ b/include/wx/msw/toplevel.h @@ -86,6 +86,11 @@ public: bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); #endif // __SMARTPHONE__ && __WXWINCE__ +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + // Soft Input Panel (SIP) change notification + virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam); +#endif + protected: // common part of all ctors void Init(); @@ -111,6 +116,9 @@ protected: // choose the right parent to use with CreateWindow() virtual WXHWND MSWGetParent() const; + // window proc for the frames + WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); + // is the window currently iconized? bool m_iconized; @@ -163,6 +171,12 @@ protected: void ReloadAllButtons(); #endif // __SMARTPHONE__ && __WXWINCE__ +private: + +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + void* m_activateInfo; +#endif + DECLARE_EVENT_TABLE() DECLARE_NO_COPY_CLASS(wxTopLevelWindowMSW) }; diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 69248ea9d6..1f6b31bce7 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: msw/frame.cpp +// Name: src/msw/frame.cpp // Purpose: wxFrame // Author: Julian Smart // Modified by: @@ -179,14 +179,6 @@ void wxFrame::Init() m_hwndToolTip = 0; #endif -#if defined(__SMARTPHONE__) || defined(__POCKETPC__) - SHACTIVATEINFO* info = new SHACTIVATEINFO; - memset(info, 0, sizeof(SHACTIVATEINFO)); - info->cbSize = sizeof(SHACTIVATEINFO); - - m_activateInfo = (void*) info; -#endif - m_wasMinimized = false; } @@ -223,12 +215,6 @@ wxFrame::~wxFrame() { m_isBeingDeleted = true; DeleteAllBars(); - -#if defined(__SMARTPHONE__) || defined(__POCKETPC__) - SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; - delete info; - m_activateInfo = NULL; -#endif } // ---------------------------------------------------------------------------- @@ -967,39 +953,6 @@ WXLRESULT wxFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lPara switch ( message ) { -#if defined(__SMARTPHONE__) || defined(__POCKETPC__) - case WM_ACTIVATE: - { - SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; - if (info) - SHHandleWMActivate(GetHwnd(), wParam, lParam, info, FALSE); - - // This implicitly sends a wxEVT_ACTIVATE_APP event - if (wxTheApp) - wxTheApp->SetActive(wParam != 0, FindFocus()); - break; - } - case WM_SETTINGCHANGE: - { - SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; - if (info) - SHHandleWMSettingChange(GetHwnd(), wParam, lParam, info); - processed = true; - break; - } - case WM_HIBERNATE: - { - wxActivateEvent event(wxEVT_HIBERNATE, true, wxID_ANY); - event.SetEventObject(wxTheApp); - - if (wxTheApp) - { - processed = wxTheApp->ProcessEvent(event); - } - break; - } -#endif - case WM_CLOSE: // if we can't close, tell the system that we processed the // message - otherwise it would close us diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index f1dfb54d5c..e5e40c269c 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -144,6 +144,14 @@ void wxTopLevelWindowMSW::Init() #if defined(__SMARTPHONE__) && defined(__WXWINCE__) m_MenuBarHWND = 0; #endif + +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + SHACTIVATEINFO* info = new SHACTIVATEINFO; + wxZeroMemory(*info); + info->cbSize = sizeof(SHACTIVATEINFO); + + m_activateInfo = (void*) info; +#endif } WXDWORD wxTopLevelWindowMSW::MSWGetStyle(long style, WXDWORD *exflags) const @@ -304,6 +312,61 @@ WXHWND wxTopLevelWindowMSW::MSWGetParent() const return (WXHWND)hwndParent; } +bool wxTopLevelWindowMSW::HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam) +{ + SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; + if (!info) return false; + return SHHandleWMSettingChange(GetHwnd(), wParam, lParam, info) == TRUE; +} + +WXLRESULT wxTopLevelWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +{ + WXLRESULT rc = 0; + bool processed = false; + + switch ( message ) + { +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + case WM_ACTIVATE: + { + SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; + if (info) + { + DWORD flags = 0; + if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) flags = SHA_INPUTDIALOG; + SHHandleWMActivate(GetHwnd(), wParam, lParam, info, flags); + } + + // This implicitly sends a wxEVT_ACTIVATE_APP event + if (wxTheApp) + wxTheApp->SetActive(wParam != 0, FindFocus()); + + break; + } + case WM_SETTINGCHANGE: + { + processed = HandleSettingChange(wParam,lParam); + break; + } + case WM_HIBERNATE: + { + if (wxTheApp) + { + wxActivateEvent event(wxEVT_HIBERNATE, true, wxID_ANY); + event.SetEventObject(wxTheApp); + processed = wxTheApp->ProcessEvent(event); + } + break; + } +#endif + } + + if ( !processed ) + rc = wxTopLevelWindowBase::MSWWindowProc(message, wParam, lParam); + + return rc; +} + bool wxTopLevelWindowMSW::CreateDialog(const void *dlgTemplate, const wxString& title, const wxPoint& pos, @@ -550,6 +613,12 @@ bool wxTopLevelWindowMSW::Create(wxWindow *parent, wxTopLevelWindowMSW::~wxTopLevelWindowMSW() { +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + SHACTIVATEINFO* info = (SHACTIVATEINFO*) m_activateInfo; + delete info; + m_activateInfo = NULL; +#endif + // 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 @@ -1019,40 +1088,51 @@ void wxTopLevelWindowMSW::OnActivate(wxActivateEvent& event) LONG APIENTRY _EXPORT wxDlgProc(HWND hDlg, UINT message, - WPARAM WXUNUSED(wParam), - LPARAM WXUNUSED(lParam)) + WPARAM wParam, + LPARAM lParam) { - if ( message == WM_INITDIALOG ) + switch ( message ) { - // under CE, add a "Ok" button in the dialog title bar and make it full - // screen - // - // TODO: find the window for this HWND, and take into account - // wxMAXIMIZE and wxCLOSE_BOX. For now, assume both are present. - // - // Standard SDK doesn't have aygshell.dll: see - // include/wx/msw/wince/libraries.h + case WM_INITDIALOG: + { + // under CE, add a "Ok" button in the dialog title bar and make it full + // screen + // + // TODO: find the window for this HWND, and take into account + // wxMAXIMIZE and wxCLOSE_BOX. For now, assume both are 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_SIZEDLG // take account of the SIP or menubar + SHINITDLGINFO shidi; + shidi.dwMask = SHIDIM_FLAGS; + shidi.dwFlags = SHIDIF_SIZEDLG // take account of the SIP or menubar #ifndef __SMARTPHONE__ - | SHIDIF_DONEBUTTON + | SHIDIF_DONEBUTTON #endif ; - shidi.hDlg = hDlg; - SHInitDialog( &shidi ); + shidi.hDlg = hDlg; + SHInitDialog( &shidi ); #else // no SHInitDialog() - wxUnusedVar(hDlg); + wxUnusedVar(hDlg); +#endif + // 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; + } + +#if defined(__SMARTPHONE__) || defined(__POCKETPC__) + case WM_SETTINGCHANGE: + { + wxTopLevelWindow *tlw = wxDynamicCast(wxGetWindowFromHWND(hDlg), wxTopLevelWindow); + if(tlw) return tlw->HandleSettingChange(wParam,lParam) ? TRUE : FALSE; + } #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; } -- 2.45.2