From a885d89ae9c9d6ff5275cb5b1ea3087132aacf8c Mon Sep 17 00:00:00 2001 From: David Webster Date: Mon, 21 Feb 2000 05:12:34 +0000 Subject: [PATCH] Frame and Window coding git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/choice.h | 2 +- include/wx/os2/dialog.h | 2 +- include/wx/os2/frame.h | 6 +- include/wx/os2/mdi.h | 8 +- include/wx/os2/statbox.h | 2 +- include/wx/os2/stattext.h | 2 +- include/wx/os2/toolbar.h | 3 +- include/wx/os2/window.h | 26 +- src/os2/choice.cpp | 4 +- src/os2/dialog.cpp | 4 +- src/os2/frame.cpp | 738 ++++++++++++++++++++++---------------- src/os2/mdi.cpp | 11 +- src/os2/statbox.cpp | 4 +- src/os2/stattext.cpp | 4 +- src/os2/toolbar.cpp | 3 +- src/os2/window.cpp | 267 ++++++++++---- 16 files changed, 659 insertions(+), 427 deletions(-) diff --git a/include/wx/os2/choice.h b/include/wx/os2/choice.h index f2c7efe954..6289745486 100644 --- a/include/wx/os2/choice.h +++ b/include/wx/os2/choice.h @@ -61,7 +61,7 @@ public: // OS2 only virtual bool OS2Command(WXUINT param, WXWORD id); - MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); + MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); protected: virtual void DoSetItemClientData( int n, void* clientData ); diff --git a/include/wx/os2/dialog.h b/include/wx/os2/dialog.h index 5bdea1a1d4..ac570e9c29 100644 --- a/include/wx/os2/dialog.h +++ b/include/wx/os2/dialog.h @@ -110,7 +110,7 @@ public: // implementation // -------------- - virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); + virtual MRESULT OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); diff --git a/include/wx/os2/frame.h b/include/wx/os2/frame.h index 31cd9c9ffd..c61b9100ab 100644 --- a/include/wx/os2/frame.h +++ b/include/wx/os2/frame.h @@ -53,7 +53,7 @@ public: virtual bool ShowFullScreen( bool bShow ,long lStyle = wxFULLSCREEN_ALL ); - virtual bool IsFullScreen(void) const { return m_bFfsIsShowing; }; + virtual bool IsFullScreen(void) const { return m_bFsIsShowing; }; // implementation only from now on @@ -131,8 +131,8 @@ public: // tooltip management #if wxUSE_TOOLTIPS - WXHWND GetToolTipCtrl(void) const { return m_hHwndToolTip; } - void SetToolTipCtrl(WXHWND hHwndTT) { m_hHwndToolTip = hHwndTT; } + WXHWND GetToolTipCtrl(void) const { return m_hWndToolTip; } + void SetToolTipCtrl(WXHWND hHwndTT) { m_hWndToolTip = hHwndTT; } #endif // tooltips protected: diff --git a/include/wx/os2/mdi.h b/include/wx/os2/mdi.h index ba390372c1..eaab8a9289 100644 --- a/include/wx/os2/mdi.h +++ b/include/wx/os2/mdi.h @@ -86,9 +86,9 @@ public: bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); // override window proc for MDI-specific message processing - virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); + virtual MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); - virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT, WXWPARAM, WXLPARAM); + virtual MRESULT OS2DefWindowProc(WXUINT, WXWPARAM, WXLPARAM); virtual bool OS2TranslateMessage(WXMSG* msg); protected: @@ -144,8 +144,8 @@ public: bool HandleWindowPosChanging(void *lpPos); bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control); - virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); - virtual MRESULT OS2DefWindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); + virtual MRESULT OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); + virtual MRESULT OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam); virtual bool OS2TranslateMessage(WXMSG *msg); virtual void OS2DestroyWindow(); diff --git a/include/wx/os2/statbox.h b/include/wx/os2/statbox.h index a8f504fec2..147e7beb38 100644 --- a/include/wx/os2/statbox.h +++ b/include/wx/os2/statbox.h @@ -49,7 +49,7 @@ class WXDLLEXPORT wxStaticBox: public wxControl void OnEraseBackground(wxEraseEvent& event); - virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); + virtual MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); diff --git a/include/wx/os2/stattext.h b/include/wx/os2/stattext.h index b410f9787b..00bf410d99 100644 --- a/include/wx/os2/stattext.h +++ b/include/wx/os2/stattext.h @@ -53,7 +53,7 @@ class WXDLLEXPORT wxStaticText: public wxControl // callbacks virtual WXHBRUSH OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, WXUINT message, WXWPARAM wParam, WXLPARAM lParam); - virtual MRESULT OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); + virtual MRESULT OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam); protected: virtual wxSize DoGetBestSize() const; diff --git a/include/wx/os2/toolbar.h b/include/wx/os2/toolbar.h index 828fc4dd67..a07398667a 100644 --- a/include/wx/os2/toolbar.h +++ b/include/wx/os2/toolbar.h @@ -100,8 +100,7 @@ protected: void UpdateSize(void); // override WndProc to process WM_SIZE - virtual MRESULT OS2WindowProc( HWND hWnd - ,WXUINT ulMsg + virtual MRESULT OS2WindowProc( WXUINT ulMsg ,WXWPARAM wParam ,WXLPARAM lParam ); diff --git a/include/wx/os2/window.h b/include/wx/os2/window.h index 735da9fa70..06fa84fd4c 100644 --- a/include/wx/os2/window.h +++ b/include/wx/os2/window.h @@ -46,8 +46,6 @@ enum class WXDLLEXPORT wxWindow : public wxWindowBase { - DECLARE_DYNAMIC_CLASS(wxWindow); - public: wxWindow() { Init(); } @@ -205,6 +203,7 @@ public: // event handlers // -------------- + void OnSetFocus(wxFocusEvent& rEvent); void OnEraseBackground(wxEraseEvent& rEvent); void OnIdle(wxIdleEvent& rEvent); @@ -424,15 +423,13 @@ public: ); // Window procedure - virtual MRESULT OS2WindowProc( HWND hwnd - ,WXUINT uMsg + virtual MRESULT OS2WindowProc( WXUINT uMsg ,WXWPARAM wParam ,WXLPARAM lParam ); // Calls an appropriate default window procedure - virtual MRESULT OS2DefWindowProc( HWND hwnd - ,WXUINT uMsg + virtual MRESULT OS2DefWindowProc( WXUINT uMsg ,WXWPARAM wParam ,WXLPARAM lParam ); @@ -469,6 +466,17 @@ public: ); protected: + // PM can't create some MSW styles natively but can perform these after + // creation by sending messages + typedef enum extra_flags { kFrameToolWindow = 0x0001 + ,kVertCaption = 0x0002 + ,kHorzCaption = 0x0004 + } EExtraFlags; + // Some internal sizeing id's to make it easy for event handlers + typedef enum size_types { kSizeNormal + ,kSizeMax + ,kSizeMin + } ESizeTypes; // the window handle WXHWND m_hWnd; @@ -557,13 +565,17 @@ private: ,WXLPARAM lParam ,WXLPARAM* pResult ); + // the helper functions used by HandleChar/KeyXXX methods + wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const; + + DECLARE_DYNAMIC_CLASS(wxWindow); DECLARE_NO_COPY_CLASS(wxWindow); DECLARE_EVENT_TABLE() private: // Virtual function hiding supression inline virtual bool Reparent(wxWindowBase* pNewParent) { return(wxWindowBase::Reparent(pNewParent));}; -}; +}; // end of wxWindow // --------------------------------------------------------------------------- // global functions diff --git a/src/os2/choice.cpp b/src/os2/choice.cpp index f834ab1fbc..84758c1bb8 100644 --- a/src/os2/choice.cpp +++ b/src/os2/choice.cpp @@ -246,7 +246,7 @@ wxSize wxChoice::DoGetBestSize() const return wxSize(wChoice, hChoice); } -MRESULT wxChoice::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxChoice::OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // TODO: /* @@ -264,7 +264,7 @@ MRESULT wxChoice::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARA return 0; } */ - return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam); + return wxWindow::OS2WindowProc(nMsg, wParam, lParam); } bool wxChoice::OS2Command(WXUINT param, WXWORD WXUNUSED(id)) diff --git a/src/os2/dialog.cpp b/src/os2/dialog.cpp index 7a5fd77c65..874a9c90a2 100644 --- a/src/os2/dialog.cpp +++ b/src/os2/dialog.cpp @@ -423,7 +423,7 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) Refresh(); } -MRESULT wxDialog::OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxDialog::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { MRESULT rc = 0; bool processed = FALSE; @@ -438,7 +438,7 @@ MRESULT wxDialog::OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLP } if ( !processed ) - rc = wxWindow::OS2WindowProc(hwnd, message, wParam, lParam); + rc = wxWindow::OS2WindowProc(message, wParam, lParam); return rc; } diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index 6041cc2b5a..a4b2fc5ddf 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -66,9 +66,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) // ---------------------------------------------------------------------------- #if wxUSE_NATIVE_STATUSBAR - bool wxFrame::m_useNativeStatusBar = TRUE; + bool wxFrame::m_bUseNativeStatusBar = TRUE; #else - bool wxFrame::m_useNativeStatusBar = FALSE; + bool wxFrame::m_bUseNativeStatusBar = FALSE; #endif // ---------------------------------------------------------------------------- @@ -80,7 +80,7 @@ void wxFrame::Init() m_bIconized = FALSE; #if wxUSE_TOOLTIPS - m_hHwndToolTip = 0; + m_hWndToolTip = 0; #endif // Data to save/restore when calling ShowFullScreen m_lFsStyle = 0L; @@ -98,7 +98,7 @@ bool wxFrame::Create( , const wxString& rsTitle , const wxPoint& rPos , const wxSize& rSize -, long lStyle +, long lulStyle , const wxString& rsName ) { @@ -108,7 +108,7 @@ bool wxFrame::Create( int nHeight = rSize.y; SetName(rsName); - m_windowStyle = lStyle; + m_windowStyle = lulStyle; m_frameMenuBar = NULL; m_frameToolBar = NULL; m_frameStatusBar = NULL; @@ -129,7 +129,7 @@ bool wxFrame::Create( // We pass NULL as parent to MSWCreate because frames with parents behave // very strangely under Win95 shell. // Alteration by JACS: keep normal Windows behaviour (float on top of parent) - // with this style. + // with this ulStyle. // if ((m_windowStyle & wxFRAME_FLOAT_ON_PARENT) == 0) pParent = NULL; @@ -146,7 +146,7 @@ bool wxFrame::Create( ,nY ,nWidth ,nHeight - ,lStyle + ,lulStyle ); wxModelessWindows.Append(this); @@ -204,7 +204,7 @@ void wxFrame::DoGetClientSize( ) const { // - // OS/2 PM's coordinates go from bottom-left not + // OS/2 PM's coordinates go from bottom-left not // top-left thus the += instead of the -= // RECTL vRect; @@ -214,13 +214,13 @@ void wxFrame::DoGetClientSize( // PM has no GetClientRect that inherantly knows about the client window // We have to explicitly go fetch it! // - hWndClient = ::WinWindowFromId(GetHwnd(), FID_CLIENT); + hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(hWndClient, &vRect); #if wxUSE_STATUSBAR if ( GetStatusBar() ) { - int nStatusX + int nStatusX; int nStatusY; GetStatusBar()->GetClientSize( &nStatusX @@ -231,9 +231,9 @@ void wxFrame::DoGetClientSize( #endif // wxUSE_STATUSBAR wxPoint vPoint(GetClientAreaOrigin()); - - vRect.bottom += pt.y; - vRect.right -= pt.x; + + vRect.yBottom += vPoint.y; + vRect.xRight -= vPoint.x; if (pX) *pX = vRect.xRight; @@ -241,7 +241,7 @@ void wxFrame::DoGetClientSize( *pY = vRect.yBottom; } // end of wxFrame::DoGetClientSize -// +// // Set the client size (i.e. leave the calculation of borders etc. // to wxWindows) // @@ -255,7 +255,7 @@ void wxFrame::DoSetClientSize( RECTL vRect; RECT vRect2; - hWndClient = ::WinWindowFromId(GetHwnd(), FID_CLIENT); + hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(hWndClient, &vRect); ::WinQueryWindowRect(hWnd, &vRect2); @@ -326,7 +326,7 @@ void wxFrame::DoGetPosition( ) const { RECTL vRect; - POINT vPoint; + POINTL vPoint; ::WinQueryWindowRect(GetHwnd(), &vRect); vPoint.x = vRect.xLeft; @@ -356,7 +356,7 @@ bool wxFrame::Show( bool bShow ) { - DoShowWindow(show ? SWP_SHOW : SW_HIDE); + DoShowWindow(bShow ? SWP_SHOW : SWP_HIDE); if (bShow) { @@ -419,8 +419,8 @@ bool wxFrame::IsIconized() const SWP vSwp; bool bIconic; - ::WinQueryWindowPos(GetHwnd(), &vSwp) - + ::WinQueryWindowPos(GetHwnd(), &vSwp); + if (vSwp.fl & SWP_MINIMIZE) ((wxFrame*)this)->m_bIconized = TRUE; else @@ -434,7 +434,7 @@ bool wxFrame::IsMaximized() const SWP vSwp; bool bIconic; - ::WinQueryWindowPos(GetHwnd(), &vSwp) + ::WinQueryWindowPos(GetHwnd(), &vSwp); return (vSwp.fl & SWP_MAXIMIZE); } // end of wxFrame::IsMaximized @@ -446,18 +446,18 @@ void wxFrame::SetIcon( if (m_icon.Ok()) { - WinSendMessage( GetHwnd() - ,WM_SETICON - ,(HICON) m_icon.GetHICON() - ,NULL - ) + WinSendMsg( GetHwnd() + ,WM_SETICON + ,(MPARAM)((HICON)m_icon.GetHICON()) + ,NULL + ); } } // end of wxFrame::SetIcon #if wxUSE_STATUSBAR wxStatusBar* wxFrame::OnCreateStatusBar( int nNumber -, long lStyle +, long lulStyle , wxWindowID vId , const wxString& rName ) @@ -465,7 +465,7 @@ wxStatusBar* wxFrame::OnCreateStatusBar( wxStatusBar* pStatusBar = NULL; pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber - ,lStyle + ,lulStyle ,vId ,rName ); @@ -479,18 +479,18 @@ void wxFrame::PositionStatusBar() // if (m_frameStatusBar) { - int nWidth + int nWidth; int nHeight; - int nStatbarWidth + int nStatbarWidth; int nStatbarHeight; HWND hWndClient; RECTL vRect; - hWndClient = ::WinWindowFromId(GetHwnd(), FID_CLIENT); + hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); ::WinQueryWindowRect(hWndClient, &vRect); nWidth = vRect.xRight - vRect.xLeft; - nHeight = vRect.xTop - vRect.xBottom; - + nHeight = vRect.yTop - vRect.yBottom; + m_frameStatusBar->GetSize( &nStatbarWidth ,&nStatbarHeight ); @@ -518,7 +518,7 @@ void wxFrame::DetachMenuBar() } // end of wxFrame::DetachMenuBar void wxFrame::SetMenuBar( - wxMenuBar* pMenuBbar + wxMenuBar* pMenuBar ) { if (!pMenuBar) @@ -532,13 +532,13 @@ void wxFrame::SetMenuBar( if (m_frameMenuBar) delete m_frameMenuBar; - m_hMenu = pMenuBbar->Create(); - m_ulMenubarId = pMenubar->GetMenubarId(); + m_hMenu = pMenuBar->Create(); + m_ulMenubarId = pMenuBar->GetMenubarId(); if (m_ulMenubarId != FID_MENU) { - ::WinSetWIndowUShort( m_hMenu + ::WinSetWindowUShort( m_hMenu ,QWS_ID - ,(unsigned short(m_ulMenubarId) + ,(unsigned short)m_ulMenubarId ); } @@ -547,146 +547,179 @@ void wxFrame::SetMenuBar( InternalSetMenuBar(); - m_frameMenuBar = menu_bar; - menu_bar->Attach(this); + m_frameMenuBar = pMenuBar; + pMenuBar->Attach(this); } // end of wxFrame::SetMenuBar void wxFrame::InternalSetMenuBar() { - + ::WinPostMsg( GetHwnd() ,WM_UPDATEFRAME - ,FCF_MENU + ,(MPARAM)FCF_MENU ,NULL ); } // end of wxFrame::InternalSetMenuBar -// Responds to colour changes, and passes event on to children. -void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) +// +// Responds to colour changes, and passes event on to children +// +void wxFrame::OnSysColourChanged( + wxSysColourChangedEvent& rEvent +) { -// TODO: -/* SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); Refresh(); - if ( m_frameStatusBar ) + if (m_frameStatusBar) { - wxSysColourChangedEvent event2; - event2.SetEventObject( m_frameStatusBar ); - m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); + wxSysColourChangedEvent vEvent2; + + vEvent2.SetEventObject(m_frameStatusBar); + m_frameStatusBar->GetEventHandler()->ProcessEvent(vEvent2); } + // // Propagate the event to the non-top-level children - wxWindow::OnSysColourChanged(event); -*/ -} - -/* - * Frame window - * - */ - -bool wxFrame::OS2Create(int id, wxWindow *parent, const wxChar *wclass, wxWindow *wx_win, const wxChar *title, - int x, int y, int width, int height, long style) + // + wxWindow::OnSysColourChanged(rEvent); +} // end of wxFrame::OnSysColourChanged +// +// Frame window +// +bool wxFrame::OS2Create( + int nId +, wxWindow* pParent +, const wxChar* zWclass +, wxWindow* pWxWin +, const wxChar* zTitle +, int nX +, int nY +, int nWidth +, int nHeight +, long ulStyle +) { - m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); - - // If child windows aren't properly drawn initially, WS_CLIPCHILDREN - // could be the culprit. But without it, you can get a lot of flicker. - -// TODO: -/* - DWORD msflags = 0; - if ((style & wxCAPTION) == wxCAPTION) - msflags = WS_OVERLAPPED; - else - msflags = WS_POPUP; - - if (style & wxMINIMIZE_BOX) - msflags |= WS_MINIMIZEBOX; - if (style & wxMAXIMIZE_BOX) - msflags |= WS_MAXIMIZEBOX; - if (style & wxTHICK_FRAME) - msflags |= WS_THICKFRAME; - if (style & wxSYSTEM_MENU) - msflags |= WS_SYSMENU; - if ((style & wxMINIMIZE) || (style & wxICONIZE)) - msflags |= WS_MINIMIZE; - if (style & wxMAXIMIZE) - msflags |= WS_MAXIMIZE; - if (style & wxCAPTION) - msflags |= WS_CAPTION; - if (style & wxCLIP_CHILDREN) - msflags |= WS_CLIPCHILDREN; - - // Keep this in wxFrame because it saves recoding this function - // in wxTinyFrame + ULONG ulPmFlags = 0; + ULONG ulExtraFlags = 0; + ULONG ulTempFlags = FCF_TITLEBAR | + FCF_SYSMENU | + FCF_MINBUTTON | + FCF_MAXBUTTON | + FCF_SIZEBORDER | + FCF_ICON | + FCF_MENU | + FCF_ACCELTABLE | + FCF_SHELLPOSITION | + FCF_TASKLIST; + + m_hDefaultIcon = (WXHICON) (wxSTD_FRAME_ICON ? wxSTD_FRAME_ICON : wxDEFAULT_FRAME_ICON); + + if ((ulStyle & wxCAPTION) == wxCAPTION) + ulPmFlags = FCF_TASKLIST; + else + ulPmFlags = FCF_NOMOVEWITHOWNER; + + if (ulStyle & wxMINIMIZE_BOX) + ulPmFlags |= FCF_MINBUTTON; + if (ulStyle & wxMAXIMIZE_BOX) + ulPmFlags |= FCF_MAXBUTTON; + if (ulStyle & wxTHICK_FRAME) + ulPmFlags |= FCF_DLGBORDER; + if (ulStyle & wxSYSTEM_MENU) + ulPmFlags |= FCF_SYSMENU; + if ((ulStyle & wxMINIMIZE) || (ulStyle & wxICONIZE)) + ulPmFlags |= WS_MINIMIZED; + if (ulStyle & wxMAXIMIZE) + ulPmFlags |= WS_MAXIMIZED; + if (ulStyle & wxCAPTION) + ulPmFlags |= FCF_TASKLIST; + if (ulStyle & wxCLIP_CHILDREN) + { + // Invalid for frame windows under PM + } + + // + // Keep this in wxFrame because it saves recoding this function + // in wxTinyFrame + // #if wxUSE_ITSY_BITSY - if (style & wxTINY_CAPTION_VERT) - msflags |= IBS_VERTCAPTION; - if (style & wxTINY_CAPTION_HORIZ) - msflags |= IBS_HORZCAPTION; + if (ulStyle & wxTINY_CAPTION_VERT) + ulExtraFlags |= kVertCaption; + if (ulStyle & wxTINY_CAPTION_HORIZ) + ulExtraFlags |= kHorzCaption; #else - if (style & wxTINY_CAPTION_VERT) - msflags |= WS_CAPTION; - if (style & wxTINY_CAPTION_HORIZ) - msflags |= WS_CAPTION; + if (ulStyle & wxTINY_CAPTION_VERT) + ulPmFlags |= FCF_TASKLIST; + if (ulStyle & wxTINY_CAPTION_HORIZ) + ulPmFlags |= FCF_TASKLIST; #endif - if ((style & wxTHICK_FRAME) == 0) - msflags |= WS_BORDER; + if ((ulStyle & wxTHICK_FRAME) == 0) + ulPmFlags |= FCF_BORDER; + if (ulStyle & wxFRAME_TOOL_WINDOW) + ulExtraFlags = kFrameToolWindow; - WXDWORD extendedStyle = MakeExtendedStyle(style); - -#if !defined(__WIN16__) && !defined(__SC__) - if (style & wxFRAME_TOOL_WINDOW) - extendedStyle |= WS_EX_TOOLWINDOW; -#endif + if (ulStyle & wxSTAY_ON_TOP) + ulPmFlags |= FCF_SYSMODAL; - if (style & wxSTAY_ON_TOP) - extendedStyle |= WS_EX_TOPMOST; - - m_iconized = FALSE; - if ( !wxWindow::MSWCreate(id, parent, wclass, wx_win, title, x, y, width, height, - msflags, NULL, extendedStyle) ) - return FALSE; - - // Seems to be necessary if we use WS_POPUP - // style instead of WS_OVERLAPPED - if (width > -1 && height > -1) - ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(width, height)); -*/ - return TRUE; -} + if (ulPmFlags & ulTempFlags) + ulPmFlags = FCF_STANDARD; + // + // Clear the visible flag, we always call show + // + ulPmFlags &= (unsigned long)~WS_VISIBLE; + m_bIconized = FALSE; + if ( !wxWindow::OS2Create( nId + ,pParent + ,zWclass + ,pWxWin + ,zTitle + ,nX + ,nY + ,nWidth + ,nHeight + ,ulPmFlags + ,NULL + ,ulExtraFlags)) + { + return FALSE; + } + return TRUE; +} // end of wxFrame::OS2Create +// // Default activation behaviour - set the focus for the first child // subwindow found. -void wxFrame::OnActivate(wxActivateEvent& event) +// +void wxFrame::OnActivate( + wxActivateEvent& rEvent +) { - for ( wxWindowList::Node *node = GetChildren().GetFirst(); - node; - node = node->GetNext() ) + for (wxWindowList::Node* pNode = GetChildren().GetFirst(); + pNode; + pNode = pNode->GetNext()) { // FIXME all this is totally bogus - we need to do the same as wxPanel, // but how to do it without duplicating the code? // restore focus - wxWindow *child = node->GetData(); + wxWindow* pChild = pNode->GetData(); - if ( !child->IsTopLevel() + if (!pChild->IsTopLevel() #if wxUSE_TOOLBAR - && !wxDynamicCast(child, wxToolBar) + && !wxDynamicCast(pChild, wxToolBar) #endif // wxUSE_TOOLBAR #if wxUSE_STATUSBAR - && !wxDynamicCast(child, wxStatusBar) + && !wxDynamicCast(pChild, wxStatusBar) #endif // wxUSE_STATUSBAR ) { - child->SetFocus(); + pChild->SetFocus(); return; } } -} +} // end of wxFrame::OnActivate // ---------------------------------------------------------------------------- // wxFrame size management: we exclude the areas taken by menu/status/toolbars @@ -697,47 +730,29 @@ void wxFrame::OnActivate(wxActivateEvent& event) // Checks if there is a toolbar, and returns the first free client position wxPoint wxFrame::GetClientAreaOrigin() const { - wxPoint pt(0, 0); + wxPoint vPoint(0, 0); + if (GetToolBar()) { - int w, h; - GetToolBar()->GetSize(& w, & h); + int nWidth; + int nHeight; + + GetToolBar()->GetSize( &nWidth + ,&nHeight + ); if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) { - pt.x += w; + vPoint.x += nWidth; } else { - pt.y += h; + // PM is backwards from windows + vPoint.y += nHeight; } } - return pt; -} - -void wxFrame::DoScreenToClient(int *x, int *y) const -{ - wxWindow::DoScreenToClient(x, y); - - // We may be faking the client origin. - // So a window that's really at (0, 30) may appear - // (to wxWin apps) to be at (0, 0). - wxPoint pt(GetClientAreaOrigin()); - *x -= pt.x; - *y -= pt.y; -} - -void wxFrame::DoClientToScreen(int *x, int *y) const -{ - // We may be faking the client origin. - // So a window that's really at (0, 30) may appear - // (to wxWin apps) to be at (0, 0). - wxPoint pt1(GetClientAreaOrigin()); - *x += pt1.x; - *y += pt1.y; - - wxWindow::DoClientToScreen(x, y); -} + return vPoint; +} // end of wxFrame::GetClientAreaOrigin // ---------------------------------------------------------------------------- // tool/status bar stuff @@ -745,74 +760,100 @@ void wxFrame::DoClientToScreen(int *x, int *y) const #if wxUSE_TOOLBAR -wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) +wxToolBar* wxFrame::CreateToolBar( + long lStyle +, wxWindowID vId +, const wxString& rName +) { - if ( wxFrameBase::CreateToolBar(style, id, name) ) + if (wxFrameBase::CreateToolBar( lStyle + ,vId + ,rName + )) { PositionToolBar(); } - return m_frameToolBar; -} +} // end of wxFrame::CreateToolBar void wxFrame::PositionToolBar() { -// TODO: -/* - RECT rect; - ::GetClientRect(GetHwnd(), &rect); + HWND hWndClient; + RECTL vRect; + + hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); + ::WinQueryWindowRect(hWndClient, &vRect); #if wxUSE_STATUSBAR - if ( GetStatusBar() ) + if (GetStatusBar()) { - int statusX, statusY; - GetStatusBar()->GetClientSize(&statusX, &statusY); - rect.bottom -= statusY; + int nStatusX; + int nStatusY; + + GetStatusBar()->GetClientSize( &nStatusX + ,&nStatusY + ); + // PM is backwards from windows + vRect.yBottom += nStatusY; } #endif // wxUSE_STATUSBAR if ( GetToolBar() ) { - int tw, th; - GetToolBar()->GetSize(&tw, &th); + int nToolbarWidth; + int nToolbarHeight; + + GetToolBar()->GetSize( &nToolbarWidth + ,&nToolbarHeight + ); - if ( GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL ) + if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) { - th = rect.bottom; + nToolbarHeight = vRect.yBottom; } else { - tw = rect.right; + nToolbarWidth = vRect.xRight; } - // Use the 'real' MSW position here - GetToolBar()->SetSize(0, 0, tw, th, wxSIZE_NO_ADJUSTMENTS); + // + // Use the 'real' PM position here + // + GetToolBar()->SetSize( 0 + ,0 + ,nToolbarWidth + ,nToolbarHeight + ,wxSIZE_NO_ADJUSTMENTS + ); } -*/ -} +} // end of wxFrame::PositionToolBar #endif // wxUSE_TOOLBAR // ---------------------------------------------------------------------------- // frame state (iconized/maximized/...) // ---------------------------------------------------------------------------- +// // propagate our state change to all child frames: this allows us to emulate X // Windows behaviour where child frames float independently of the parent one // on the desktop, but are iconized/restored with it -void wxFrame::IconizeChildFrames(bool bIconize) +// +void wxFrame::IconizeChildFrames( + bool bIconize +) { - for ( wxWindowList::Node *node = GetChildren().GetFirst(); - node; - node = node->GetNext() ) + for (wxWindowList::Node* pNode = GetChildren().GetFirst(); + pNode; + pNode = pNode->GetNext() ) { - wxWindow *win = node->GetData(); + wxWindow* pWin = pNode->GetData(); - if ( win->IsKindOf(CLASSINFO(wxFrame)) ) + if (pWin->IsKindOf(CLASSINFO(wxFrame)) ) { - ((wxFrame *)win)->Iconize(bIconize); + ((wxFrame *)pWin)->Iconize(bIconize); } } -} +} // end of wxFrame::IconizeChildFrames // =========================================================================== // message processing @@ -821,64 +862,73 @@ void wxFrame::IconizeChildFrames(bool bIconize) // --------------------------------------------------------------------------- // preprocessing // --------------------------------------------------------------------------- - -bool wxFrame::OS2TranslateMessage(WXMSG* pMsg) +bool wxFrame::OS2TranslateMessage( + WXMSG* pMsg +) { -// TODO: -/* - if ( wxWindow::OS2TranslateMessage(pMsg) ) + if (wxWindow::OS2TranslateMessage(pMsg)) return TRUE; -*/ + // // try the menu bar accels - wxMenuBar *menuBar = GetMenuBar(); - if ( !menuBar ) + // + wxMenuBar* pMenuBar = GetMenuBar(); + + if (!pMenuBar ) return FALSE; - const wxAcceleratorTable& acceleratorTable = menuBar->GetAccelTable(); - return acceleratorTable.Translate(this, pMsg); -} + const wxAcceleratorTable& rAcceleratorTable = pMenuBar->GetAccelTable(); + return rAcceleratorTable.Translate(this, pMsg); +} // end of wxFrame::OS2TranslateMessage // --------------------------------------------------------------------------- // our private (non virtual) message handlers // --------------------------------------------------------------------------- - bool wxFrame::HandlePaint() { -// TODO: -/* - RECT rect; - if ( GetUpdateRect(GetHwnd(), &rect, FALSE) ) + RECTL vRect; + + if (::WinQueryUpdateRect(GetHwnd(), &vRect)) { - if ( m_iconized ) + if (m_bIconized) { - HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) - : (HICON)m_defaultIcon; + // + // Icons in PM are the same as "pointers" + // + HPOINTER hIcon; + if (m_icon.Ok()) + hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L); + else + hIcon = (HPOINTER)m_hDefaultIcon; + + // // Hold a pointer to the dc so long as the OnPaint() message // is being processed - PAINTSTRUCT ps; - HDC hdc = ::BeginPaint(GetHwnd(), &ps); + // + RECTL vRect2; + HPS hPs = ::WinBeginPaint(GetHwnd(), NULLHANDLE, &vRect2); + // // Erase background before painting or we get white background - MSWDefWindowProc(WM_ICONERASEBKGND, (WORD)(LONG)ps.hdc, 0L); + // + OS2DefWindowProc(WM_ERASEBACKGROUND, (MPARAM)hPs, (MPARAM)&vRect2); - if ( hIcon ) + if (hIcon) { - RECT rect; - ::GetClientRect(GetHwnd(), &rect); + HWND hWndClient; + RECTL vRect3; - // FIXME: why hardcoded? - static const int icon_width = 32; - static const int icon_height = 32; + hWndClient = ::WinWindowFromID(GetHwnd(), FID_CLIENT); + ::WinQueryWindowRect(hWndClient, &vRect3); - int icon_x = (int)((rect.right - icon_width)/2); - int icon_y = (int)((rect.bottom - icon_height)/2); + static const int nIconWidth = 32; + static const int nIconHeight = 32; + int nIconX = (int)((vRect3.xRight - nIconWidth)/2); + int nIconY = (int)((vRect3.yBottom + nIconHeight)/2); - ::DrawIcon(hdc, icon_x, icon_y, hIcon); + ::WinDrawPointer(hPs, nIconX, nIconY, hIcon, DP_NORMAL); } - - ::EndPaint(GetHwnd(), &ps); - + ::WinEndPaint(hPs); return TRUE; } else @@ -891,188 +941,246 @@ bool wxFrame::HandlePaint() // nothing to paint - processed return TRUE; } -*/ return FALSE; -} +} // end of wxFrame::HandlePaint -bool wxFrame::HandleSize(int x, int y, WXUINT id) +bool wxFrame::HandleSize( + int nX +, int nY +, WXUINT nId +) { - bool processed = FALSE; + bool bProcessed = FALSE; -// TODO: -/* - switch ( id ) + switch (nId) { - case SIZENORMAL: - // only do it it if we were iconized before, otherwise resizing the + case kSizeNormal: + // + // Only do it it if we were iconized before, otherwise resizing the // parent frame has a curious side effect of bringing it under it's // children - if ( !m_iconized ) + if (!m_bIconized ) break; + // // restore all child frames too + // IconizeChildFrames(FALSE); + // // fall through + // - case SIZEFULLSCREEN: - m_iconized = FALSE; + case kSizeMax: + m_bIconized = FALSE; break; - case SIZEICONIC: - // iconize all child frames too + case kSizeMin: + // + // Iconize all child frames too + // IconizeChildFrames(TRUE); - - m_iconized = TRUE; + m_bIconized = TRUE; break; } - if ( !m_iconized ) + if (!m_bIconized) { + // // forward WM_SIZE to status bar control + // #if wxUSE_NATIVE_STATUSBAR if (m_frameStatusBar && m_frameStatusBar->IsKindOf(CLASSINFO(wxStatusBar95))) { - wxSizeEvent event(wxSize(x, y), m_frameStatusBar->GetId()); - event.SetEventObject( m_frameStatusBar ); + wxSizeEvent vEvent( wxSize( nX + ,nY + ) + ,m_frameStatusBar->GetId() + ); - ((wxStatusBar95 *)m_frameStatusBar)->OnSize(event); + vEvent.SetEventObject(m_frameStatusBar); + m_frameStatusBar->OnSize(vEvent); } #endif // wxUSE_NATIVE_STATUSBAR PositionStatusBar(); PositionToolBar(); + wxSizeEvent vEvent( wxSize( nX + ,nY + ) + ,m_windowId + ); - wxSizeEvent event(wxSize(x, y), m_windowId); - event.SetEventObject( this ); - processed = GetEventHandler()->ProcessEvent(event); + vEvent.SetEventObject(this); + bProcessed = GetEventHandler()->ProcessEvent(vEvent); } -*/ - return processed; -} + return bProcessed; +} // end of wxFrame::HandleSize -bool wxFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND control) +bool wxFrame::HandleCommand( + WXWORD nId +, WXWORD nCmd +, WXHWND hControl +) { -// TODO: -/* - if ( control ) + if (hControl) { + // // In case it's e.g. a toolbar. - wxWindow *win = wxFindWinFromHandle(control); - if ( win ) - return win->MSWCommand(cmd, id); + // + wxWindow* pWin = wxFindWinFromHandle(hControl); + + if (pWin) + return pWin->OS2Command( nCmd + ,nId + ); } - // handle here commands from menus and accelerators - if ( cmd == 0 || cmd == 1 ) + // + // Handle here commands from menus and accelerators + // + if (nCmd == 0 || nCmd == 1) { - if ( wxCurrentPopupMenu ) + if (wxCurrentPopupMenu) { - wxMenu *popupMenu = wxCurrentPopupMenu; + wxMenu* pPopupMenu = wxCurrentPopupMenu; + wxCurrentPopupMenu = NULL; - return popupMenu->MSWCommand(cmd, id); + return pPopupMenu->OS2Command( nCmd + ,nId + ); } - if ( ProcessCommand(id) ) + if (ProcessCommand(nId)) { return TRUE; } } -*/ return FALSE; -} +} // end of wxFrame::HandleCommand -bool wxFrame::HandleMenuSelect(WXWORD nItem, WXWORD flags, WXHMENU hMenu) +bool wxFrame::HandleMenuSelect( + WXWORD nItem +, WXWORD nFlags +, WXHMENU hMenu +) { - int item; - if ( flags == 0xFFFF && hMenu == 0 ) + int nMenuItem; + + if (nFlags == 0xFFFF && hMenu == 0) { - // menu was removed from screen - item = -1; + // + // Menu was removed from screen + // + nMenuItem = -1; } -// TODO: -/* - else if ( !(flags & MF_POPUP) && !(flags & MF_SEPARATOR) ) + else if (!(nFlags & MIS_SUBMENU) && !(nFlags & MIS_SEPARATOR)) { - item = nItem; + nMenuItem = nItem; } else { - // don't give hints for separators (doesn't make sense) nor for the + // + // Don't give hints for separators (doesn't make sense) nor for the // items opening popup menus (they don't have them anyhow) + // return FALSE; } -*/ - wxMenuEvent event(wxEVT_MENU_HIGHLIGHT, item); - event.SetEventObject( this ); + wxMenuEvent vEvent(wxEVT_MENU_HIGHLIGHT, nMenuItem); - return GetEventHandler()->ProcessEvent(event); -} + vEvent.SetEventObject(this); + return GetEventHandler()->ProcessEvent(vEvent); +} // end of wxFrame::HandleMenuSelect // --------------------------------------------------------------------------- // the window proc for wxFrame // --------------------------------------------------------------------------- -MRESULT wxFrame::OS2WindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxFrame::OS2WindowProc( + WXUINT uMessage +, WXWPARAM wParam +, WXLPARAM lParam +) { - long rc = 0; - bool processed = FALSE; + MRESULT mRc = 0L; + bool bProcessed = FALSE; -// TODO: -/* - switch ( message ) + switch (uMessage) { case WM_CLOSE: - // if we can't close, tell the system that we processed the + // + // If we can't close, tell the system that we processed the // message - otherwise it would close us - processed = !Close(); + // + bProcessed = !Close(); break; case WM_COMMAND: { - WORD id, cmd; - WXHWND hwnd; - UnpackCommand((WXWPARAM)wParam, (WXLPARAM)lParam, - &id, &hwnd, &cmd); - - processed = HandleCommand(id, cmd, (WXHWND)hwnd); + WORD wId; + WORD wCmd; + WXHWND hWnd; + + UnpackCommand( (WXWPARAM)wParam + ,(WXLPARAM)lParam + ,&wId + ,&hWnd + ,&wCmd + ); + bProcessed = HandleCommand( wId + ,wCmd + ,(WXHWND)hWnd + ); } break; case WM_MENUSELECT: { - WXWORD item, flags; - WXHMENU hmenu; - UnpackMenuSelect(wParam, lParam, &item, &flags, &hmenu); - - processed = HandleMenuSelect(item, flags, hmenu); + WXWORD wItem; + WXWORD wFlags; + WXHMENU hMenu; + + UnpackMenuSelect( wParam + ,lParam + ,&wItem + ,&wFlags + ,&hMenu + ); + bProcessed = HandleMenuSelect( wItem + ,wFlags + ,hMenu + ); } break; case WM_PAINT: - processed = HandlePaint(); + bProcessed = HandlePaint(); break; - case WM_QUERYDRAGICON: + case CM_QUERYDRAGIMAGE: { - HICON hIcon = m_icon.Ok() ? GetHiconOf(m_icon) - : (HICON)(m_defaultIcon); - rc = (long)hIcon; - processed = rc != 0; + HPOINTER hIcon; + + if (m_icon.Ok()) + hIcon = (HPOINTER)::WinSendMsg(GetHwnd(), WM_QUERYICON, 0L, 0L); + else + hIcon = (HPOINTER)m_hDefaultIcon; + mRc = (MRESULT)hIcon; + bProcessed = mRc != 0; } break; case WM_SIZE: - processed = HandleSize(LOWORD(lParam), HIWORD(lParam), wParam); + bProcessed = HandleSize(LOWORD(lParam), HIWORD(lParam), (WXUINT)wParam); break; } - if ( !processed ) - rc = wxWindow::MSWWindowProc(message, wParam, lParam); - - return rc; -*/ + if (!bProcessed ) + mRc = wxWindow::OS2WindowProc( uMessage + ,wParam + ,lParam + ); return (MRESULT)0; -} +} // wxFrame::OS2WindowProc diff --git a/src/os2/mdi.cpp b/src/os2/mdi.cpp index 0a21118334..b0142bab68 100644 --- a/src/os2/mdi.cpp +++ b/src/os2/mdi.cpp @@ -288,8 +288,7 @@ void wxMDIParentFrame::ActivatePrevious() // the MDI parent frame window proc // --------------------------------------------------------------------------- -MRESULT wxMDIParentFrame::OS2WindowProc(HWND hwnd, - WXUINT message, +MRESULT wxMDIParentFrame::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { @@ -504,8 +503,7 @@ bool wxMDIParentFrame::HandleCommand(WXWORD id, WXWORD cmd, WXHWND hwnd) return FALSE; } -MRESULT wxMDIParentFrame::OS2DefWindowProc(HWND hwnd, - WXUINT message, +MRESULT wxMDIParentFrame::OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { @@ -774,8 +772,7 @@ void wxMDIChildFrame::Activate() // MDI window proc and message handlers // --------------------------------------------------------------------------- -MRESULT wxMDIChildFrame::OS2WindowProc(HWND hwnd, - WXUINT message, +MRESULT wxMDIChildFrame::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { @@ -987,7 +984,7 @@ bool wxMDIChildFrame::HandleWindowPosChanging(void *pos) // MDI specific message translation/preprocessing // --------------------------------------------------------------------------- -MRESULT wxMDIChildFrame::OS2DefWindowProc(HWND hwnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxMDIChildFrame::OS2DefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { // TODO /* diff --git a/src/os2/statbox.cpp b/src/os2/statbox.cpp index 3f1bd033fb..85270d2462 100644 --- a/src/os2/statbox.cpp +++ b/src/os2/statbox.cpp @@ -174,7 +174,7 @@ void wxStaticBox::OnEraseBackground(wxEraseEvent& event) */ } -MRESULT wxStaticBox::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxStaticBox::OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // TODO: /* @@ -192,7 +192,7 @@ MRESULT wxStaticBox::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLP } */ - return wxControl::OS2WindowProc(hwnd, nMsg, wParam, lParam); + return wxControl::OS2WindowProc(nMsg, wParam, lParam); } diff --git a/src/os2/stattext.cpp b/src/os2/stattext.cpp index bf3141e961..00c3e2e32d 100644 --- a/src/os2/stattext.cpp +++ b/src/os2/stattext.cpp @@ -138,7 +138,7 @@ WXHBRUSH wxStaticText::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, return (WXHBRUSH)0; } -MRESULT wxStaticText::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxStaticText::OS2WindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // Ensure that static items get messages. Some controls don't like this // message to be intercepted (e.g. RichEdit), hence the tests. @@ -147,6 +147,6 @@ MRESULT wxStaticText::OS2WindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXL if (nMsg == WM_NCHITTEST) return (long)HTCLIENT; */ - return wxWindow::OS2WindowProc(hwnd, nMsg, wParam, lParam); + return wxWindow::OS2WindowProc(nMsg, wParam, lParam); } diff --git a/src/os2/toolbar.cpp b/src/os2/toolbar.cpp index 03734d30b4..804f2bc3fd 100644 --- a/src/os2/toolbar.cpp +++ b/src/os2/toolbar.cpp @@ -919,8 +919,7 @@ void wxToolBar::OnMouseEvent( } MRESULT wxToolBar::OS2WindowProc( - HWND hWnd -, WXUINT ulMsg + WXUINT ulMsg , MPARAM wParam , MPARAM lParam ) diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 088db7e071..dd6e9411d5 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -9,7 +9,9 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// // For compilers that support precompilation, includes "wx.h". +// #include "wx/wxprec.h" #ifndef WX_PRECOMP @@ -64,14 +66,21 @@ #include -// place compiler, OS specific includes here - +// +// Place compiler, OS specific includes here +// -// standard macros -- these are for OS/2 PM, but most GUI's have something similar +// +// Standard macros -- these are for OS/2 PM, but most GUI's have something similar +// #ifndef GET_X_LPARAM +// // SHORT1FROMMP -- LOWORD +// #define GET_X_LPARAM(mp) ((unsigned short)(unsigned long)(mp)) +// // SHORT2FROMMP -- HIWORD +// #define GET_Y_LPARAM(mp) ((unsigned short)(unsigned long)(mp >> 16)) #endif // GET_X_LPARAM @@ -79,18 +88,23 @@ // global variables // --------------------------------------------------------------------------- -// the last Windows message we got (MT-UNSAFE) -extern WXMSGID s_currentMsg; -extern wxList WXDLLEXPORT wxPendingDelete; -extern wxChar wxCanvasClassName[]; +// +// The last Windows message we got (MT-UNSAFE) +// +extern WXMSGID s_currentMsg; -wxMenu *wxCurrentPopupMenu = NULL; -wxList *wxWinHandleList = NULL; +wxMenu* wxCurrentPopupMenu = NULL; +extern wxList WXDLLEXPORT wxPendingDelete; +extern wxChar* wxCanvasClassName; +wxList* wxWinHandleList = NULL; // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- + +// // the window proc for all our windows; most gui's have something similar +// MRESULT wxWndProc( HWND hWnd ,ULONG message ,MPARAM mp1 @@ -101,10 +115,27 @@ MRESULT wxWndProc( HWND hWnd const char *wxGetMessageName(int message); #endif //__WXDEBUG__ -void wxRemoveHandleAssociation(wxWindow *win); -void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); -wxWindow *wxFindWinFromHandle(WXHWND hWnd); +void wxRemoveHandleAssociation(wxWindow* pWin); +void wxAssociateWinWithHandle( HWND hWnd + ,wxWindow* pWin + ); +wxWindow* wxFindWinFromHandle(WXHWND hWnd); +// +// This magical function is used to translate VK_APPS key presses to right +// mouse clicks +// +static void TranslateKbdEventToMouse( wxWindow* pWin + ,int* pX + ,int* pY + ,MPARAM* pFlags + ); + +// +// get the current state of SHIFT/CTRL keys +// +static inline bool IsShiftDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000) != 0; } +static inline bool IsCtrlDown() { return (::WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000) != 0; } // --------------------------------------------------------------------------- // event tables // --------------------------------------------------------------------------- @@ -122,40 +153,47 @@ END_EVENT_TABLE() // implementation // =========================================================================== +// // Find an item given the PM Window id +// wxWindow* wxWindow::FindItem( - long ulId + long lId ) const { + wxControl* pItem = wxDynamicCast( this + ,wxControl + ); + + if (pItem) + { + // + // I it we or one of our "internal" children? + // + if (pItem->GetId() == lId || + (pItem->GetSubcontrols().Index(lId) != wxNOT_FOUND)) + { + return pItem; + } + } + wxWindowList::Node* pCurrent = GetChildren().GetFirst(); while (pCurrent) { wxWindow* pChildWin = pCurrent->GetData(); - wxWindow* pWnd = pChildWin->FindItem(ulId); + wxWindow* pWnd = pChildWin->FindItem(lId); if (pWnd) return pWnd; - if (pChildWin->IsKindOf(CLASSINFO(wxControl))) - { - wxControl* pItem = (wxControl *)pChildWin; - - if (pItem->GetId() == ulId) - return(pItem); - else - { - // In case it's a 'virtual' control (e.g. radiobox) - if (pItem->GetSubcontrols().Member((wxObject *)ulId)) - return(pItem); - } - } pCurrent = pCurrent->GetNext(); } return(NULL); -} +} // end of wxWindow::FindItem +// // Find an item given the PM Window handle +// wxWindow* wxWindow::FindItemByHWND( WXHWND hWnd , bool bControlOnly @@ -167,7 +205,9 @@ wxWindow* wxWindow::FindItemByHWND( { wxWindow* pParent = pCurrent->GetData(); + // // Do a recursive search. + // wxWindow* pWnd = pParent->FindItemByHWND(hWnd); if (pWnd) @@ -188,9 +228,11 @@ wxWindow* wxWindow::FindItemByHWND( pCurrent = pCurrent->GetNext(); } return(NULL); -} +} // end of wxWindow::FindItemByHWND +// // Default command handler +// bool wxWindow::OS2Command( WXUINT WXUNUSED(uParam) , WXWORD WXUNUSED(uId) @@ -205,10 +247,14 @@ bool wxWindow::OS2Command( void wxWindow::Init() { - // generic + // + // Generic + // InitBase(); + // // PM specific + // m_bDoubleClickAllowed = 0; m_bWinCaptured = FALSE; @@ -217,19 +263,23 @@ void wxWindow::Init() m_bUseCtl3D = FALSE; m_bMouseInWindow = FALSE; + // // wxWnd + // m_hMenu = 0; - m_hWnd = 0; - // pass WM_GETDLGCODE to DefWindowProc() + // + // Pass WM_GETDLGCODE to DefWindowProc() m_lDlgCode = 0; m_nXThumbSize = 0; m_nYThumbSize = 0; m_bBackgroundTransparent = FALSE; - // as all windows are created with WS_VISIBLE style... + // + // As all windows are created with WS_VISIBLE style... + // m_isShown = TRUE; #if wxUSE_MOUSEEVENT_HACK @@ -237,26 +287,29 @@ void wxWindow::Init() m_lLastMouseY = -1; m_nLastMouseEvent = -1; #endif // wxUSE_MOUSEEVENT_HACK -} +} // wxWindow::Init +// // Destructor +// wxWindow::~wxWindow() { m_isBeingDeleted = TRUE; OS2DetachWindowMenu(); - // delete handlers? if (m_parent) m_parent->RemoveChild(this); DestroyChildren(); if (m_hWnd) { - if(!WinDestroyWindow(GetHWND())) + if(!::WinDestroyWindow(GetHWND())) wxLogLastError(wxT("DestroyWindow")); + // // remove hWnd <-> wxWindow association + // wxRemoveHandleAssociation(this); } -} +} // end of wxWindow::~wxWindow bool wxWindow::Create( wxWindow* pParent @@ -281,10 +334,39 @@ bool wxWindow::Create( pParent->AddChild(this); + ULONG ulFlags = 0L; + + // + // Frame windows and their derivatives only + // + if (lStyle & wxBORDER) + ulFlags |= FCF_BORDER; + if (lStyle & wxTHICK_FRAME ) + ulFlags |= FCF_SIZEBORDER; + + // + // Some generic window styles + // + ulFlags |= WS_VISIBLE; + if (lStyle & wxCLIP_CHILDREN ) + ulFlags |= WS_CLIPCHILDREN; + bool bWant3D; WXDWORD dwExStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &bWant3D); - DWORD ulFlags = 0L; + // + // OS/2 PM doesn't have "extended" styles but if the library specifies + // them and we are creating a frame window then at least give it a border + // + if ( bWant3D || + (m_windowStyle & wxSIMPLE_BORDER) || + (m_windowStyle & wxRAISED_BORDER ) || + (m_windowStyle & wxSUNKEN_BORDER) || + (m_windowStyle & wxDOUBLE_BORDER) + ) + { + ulFlags |= FCF_BORDER; + } OS2Create( m_windowId ,pParent ,wxCanvasClassName @@ -299,7 +381,7 @@ bool wxWindow::Create( ,dwExStyle ); return(TRUE); -} +} // end of wxWindow::Create // --------------------------------------------------------------------------- // basic operations @@ -311,7 +393,7 @@ void wxWindow::SetFocus() if (hWnd) ::WinSetFocus(HWND_DESKTOP, hWnd); -} +} // end of wxWindow::SetFocus wxWindow* wxWindowBase::FindFocus() { @@ -322,7 +404,7 @@ wxWindow* wxWindowBase::FindFocus() return wxFindWinFromHandle((WXHWND)hWnd); } return NULL; -} +} // wxWindowBase::FindFocus bool wxWindow::Enable( bool bEnable @@ -346,7 +428,7 @@ bool wxWindow::Enable( pNode = pNode->GetNext(); } return(TRUE); -} +} // end of wxWindow::Enable bool wxWindow::Show( bool bShow @@ -361,32 +443,32 @@ bool wxWindow::Show( if (bShow) { - ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE); + ::WinSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); } return(TRUE); -} +} // end of wxWindow::Show void wxWindow::Raise() { - ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ACTIVATE); -} + ::WinSetWindowPos(GetHwnd(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER | SWP_ACTIVATE); +} // end of wxWindow::Raise void wxWindow::Lower() { - ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_DEACTIVATE); -} + ::WinSetWindowPos(GetHwnd(), HWND_BOTTOM, 0, 0, 0, 0, SWP_ZORDER | SWP_DEACTIVATE); +} // end of wxWindow::Lower void wxWindow::SetTitle( const wxString& rTitle ) { ::WinSetWindowText(GetHwnd(), rTitle.c_str()); -} +} // end of wxWindow::SetTitle wxString wxWindow::GetTitle() const { return wxGetWindowText(GetHWND()); -} +} // end of wxWindow::GetTitle void wxWindow::CaptureMouse() { @@ -397,16 +479,16 @@ void wxWindow::CaptureMouse() ::WinSetCapture(HWND_DESKTOP, hWnd); m_bWinCaptured = TRUE; } -} +} // end of wxWindow::GetTitle void wxWindow::ReleaseMouse() { - if ( m_bWinCaptured ) + if (m_bWinCaptured) { ::WinSetCapture(HWND_DESKTOP, NULLHANDLE); m_bWinCaptured = FALSE; } -} +} // end of wxWindow::ReleaseMouse bool wxWindow::SetFont( const wxFont& rFont @@ -458,15 +540,26 @@ bool wxWindow::SetCursor( if ((::GpiPtInRegion(hPS, hRGN, &vPoint) == PRGN_INSIDE) && !wxIsBusy()) { -// ::SetCursor((HCURSOR)m_cursor.GetHCURSOR()); + ::WinSetPointer(HWND_DESKTOP, (HPOINTER)m_cursor.GetHCURSOR()); } return TRUE; -} +} // end of wxWindow::SetCursor -void wxWindow::WarpPointer(int x_pos, int y_pos) +void wxWindow::WarpPointer( + int nXPos +, int nYPos +) { - // TODO: -} + int nX = nXPos; + int nY = nYPos; + RECTL vRect; + + ::WinQueryWindowRect(GetHwnd(), &vRect); + nX += vRect.xLeft; + nY += vRect.yBottom; + + ::WinSetPointerPos(HWND_DESKTOP, (LONG)nX, (LONG)(nY)); +} // end of wxWindow::WarpPointer #if WXWIN_COMPATIBILITY void wxWindow::OS2DeviceToLogical (float *x, float *y) const @@ -479,27 +572,51 @@ void wxWindow::OS2DeviceToLogical (float *x, float *y) const // --------------------------------------------------------------------------- #if WXWIN_COMPATIBILITY -void wxWindow::SetScrollRange(int orient, int range, bool refresh) +void wxWindow::SetScrollRange( + int nOrient +, int nRange +, bool bRefresh +) { - // TODO: -} + ::WinSendMsg(GetHwnd(), SBM_SETSCROLLBAR, (MPARAM)0, MPFROM2SHORT(0, nRange)); +} // end of wxWindow::SetScrollRange -void wxWindow::SetScrollPage(int orient, int page, bool refresh) +void wxWindow::SetScrollPage( + int nOrient +, int nPage +, bool bRefresh +) { - // TODO: + if ( orient == wxHORIZONTAL ) + m_xThumbSize = page; + else + m_yThumbSize = page; } -int wxWindow::OldGetScrollRange(int orient) const +int wxWindow::OldGetScrollRange( + int nOrient +) const { - // TODO: - return 0; -} + MRESULT mRc; + HWND hWnd = GetHwnd(); -int wxWindow::GetScrollPage(int orient) const + if (hWnd) + { + mRc = WinSendMsg(hWnd, SBM_QUERYRANGE, (MPARAM)0L, (MPARAM)0L); + return(SHORT2FROMMR(mRc)); + } + return 0; +} // end of wxWindow::OldGetScrollRange + +int wxWindow::GetScrollPage( + int nOrient +) const { - // TODO: - return(1); -} + if (nOrient == wxHORIZONTAL) + return m_xThumbSize; + else + return m_yThumbSize; +} // end of wxWindow::GetScrollPage #endif // WXWIN_COMPATIBILITY int wxWindow::GetScrollPos(int orient) const @@ -905,7 +1022,7 @@ bool wxWindow::DoPopupMenu( wxMenu *menu, int x, int y ) // pre/post message processing // =========================================================================== -MRESULT wxWindow::OS2DefWindowProc(HWND hwnd, WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxWindow::OS2DefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // TODO: return (MRESULT)0; @@ -1008,13 +1125,13 @@ MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam) { // FIXME: why do we do this? wnd->SetHWND((WXHWND) hWnd); - rc = wnd->OS2DefWindowProc(hWnd, message, wParam, lParam ); + rc = wnd->OS2DefWindowProc(message, wParam, lParam ); wnd->SetHWND(0); } else { if ( wnd ) - rc = wnd->OS2WindowProc(hWnd, message, wParam, lParam); + rc = wnd->OS2WindowProc(message, wParam, lParam); else rc = 0; //TODO: DefWindowProc( hWnd, message, wParam, lParam ); } @@ -1022,7 +1139,7 @@ MRESULT wxWndProc(HWND hWnd, ULONG message, MPARAM wParam, MPARAM lParam) return rc; } -MRESULT wxWindow::OS2WindowProc(HWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +MRESULT wxWindow::OS2WindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { // did we process the message? bool processed = FALSE; -- 2.45.2