From 6ed98c6a3b7f2be77ea16b5d26467796c1be9f4d Mon Sep 17 00:00:00 2001 From: David Webster Date: Tue, 28 May 2002 21:50:34 +0000 Subject: [PATCH] Catching up for the week git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15703 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/os2/popupwin.h | 21 ++++++ include/wx/os2/toplevel.h | 7 ++ include/wx/os2/window.h | 3 + src/os2/popupwin.cpp | 72 +++++++++++++++++++ src/os2/region.cpp | 145 ++++++++++++++++---------------------- src/os2/toplevel.cpp | 41 +++++++++++ src/os2/window.cpp | 59 ++++++---------- src/os2/wx23.def | 52 ++++++++++---- 8 files changed, 263 insertions(+), 137 deletions(-) diff --git a/include/wx/os2/popupwin.h b/include/wx/os2/popupwin.h index 9dbaac6564..9341ecdd5c 100644 --- a/include/wx/os2/popupwin.h +++ b/include/wx/os2/popupwin.h @@ -26,6 +26,22 @@ public: bool Create( wxWindow* pParent ,int nFlags = wxBORDER_NONE ); + // + // Implementation only from now on + // ------------------------------- + // + + // + // Override Show() to prevent wxPopupWindow from being activated + // + virtual bool Show(bool show = TRUE); + + // + // Find a shown popup window with the given window as parent, return NULL + // if none + // + static wxPopupWindow *FindPopupFor(wxWindow* pWin); + protected: virtual void DoGetPosition( int* pnX ,int* pny @@ -34,6 +50,11 @@ protected: virtual WXDWORD OS2GetStyle( long lFlags ,WXDWORD* dwExstyle ) const; + // + // The list of all currently shown popup windows used by FindPopupFor() + // + static wxWindowList m_svShownPopups; + DECLARE_DYNAMIC_CLASS(wxPopupWindow) }; // end of CLASS wxPopupWindow diff --git a/include/wx/os2/toplevel.h b/include/wx/os2/toplevel.h index e9045aacf6..d0e1a3e469 100644 --- a/include/wx/os2/toplevel.h +++ b/include/wx/os2/toplevel.h @@ -131,6 +131,12 @@ protected: virtual WXDWORD OS2GetStyle( long lFlag ,WXDWORD* pdwExstyle ) const; + + // + // Choose the right parent to use with CreateWindow() + // + virtual WXHWND OS2GetParent(void) const; + // // Is the frame currently iconized? // @@ -155,6 +161,7 @@ protected: SWP m_vSwp; SWP m_vSwpClient; static bool m_sbInitialized; + static wxWindow* m_spHiddenParent; }; // end of CLASS wxTopLevelWindowOS2 // diff --git a/include/wx/os2/window.h b/include/wx/os2/window.h index 620b445553..12e1debc20 100644 --- a/include/wx/os2/window.h +++ b/include/wx/os2/window.h @@ -272,6 +272,9 @@ public: { return OS2GetStyle(GetWindowStyle(), pdwExflags); } + // get the HWND to be used as parent of this window with CreateWindow() + virtual WXHWND OS2GetParent(void) const; + // returns TRUE if the window has been created bool OS2Create( PSZ zClass ,const char* zTitle diff --git a/src/os2/popupwin.cpp b/src/os2/popupwin.cpp index adc25e8f9c..4c0ca2757a 100644 --- a/src/os2/popupwin.cpp +++ b/src/os2/popupwin.cpp @@ -30,6 +30,8 @@ #include "wx/popupwin.h" +wxWindowList wxPopupWindow::m_svShownPopups; + // ============================================================================ // implementation // ============================================================================ @@ -74,3 +76,73 @@ WXDWORD wxPopupWindow::OS2GetStyle( return dwStyle; } // end of wxPopupWindow::OS2GetStyle +bool wxPopupWindow::Show( + bool bShow +) +{ + SWP vSwp; + // + // Skip wxWindow::Show() which calls wxBringWindowToTop(): this results in + // activating the popup window and stealing the atcivation from our parent + // which means that the parent frame becomes deactivated when opening a + // combobox, for example -- definitely not what we want + // + if (!wxWindowBase::Show(bShow)) + return FALSE; + + if (bShow) + { + m_svShownPopups.Append(this); + } + else // remove from the shown list + { + m_svShownPopups.DeleteObject(this); + } + ::WinQueryWindowPos(GetHwnd(), &vSwp); + + if (bShow) + { + ::WinSetWindowPos( GetHwnd() + ,HWND_TOP + ,vSwp.x + ,vSwp.y + ,vSwp.cx + ,vSwp.cy + ,SWP_DEACTIVATE | SWP_SHOW | SWP_ZORDER + ); + } + else + { + ::WinSetWindowPos( GetHwnd() + ,HWND_BOTTOM + ,vSwp.x + ,vSwp.y + ,vSwp.cx + ,vSwp.cy + ,SWP_HIDE | SWP_ZORDER + ); + } + return TRUE; +} // end of wxPopupWindow::Show + +/* static */ +wxPopupWindow* wxPopupWindow::FindPopupFor( + wxWindow* pWinParent +) +{ + // + // Find a popup with the given parent in the linked list of all shown + // popups + // + for ( wxWindowList::Node *node = m_svShownPopups.GetFirst(); + node; + node = node->GetNext() ) + { + wxWindow* pWin = node->GetData(); + + if (pWin->GetParent() == pWinParent ) + return (wxPopupWindow *)pWin; + } + return NULL; +} // end of wxPopupWindow::FindPopupFor + diff --git a/src/os2/region.cpp b/src/os2/region.cpp index 5404bf64db..c56301d723 100644 --- a/src/os2/region.cpp +++ b/src/os2/region.cpp @@ -76,6 +76,7 @@ public: }; #define M_REGION (((wxRegionRefData*)m_refData)->m_hRegion) +#define M_REGION_OF(rgn) (((wxRegionRefData*)(rgn.m_refData))->m_hRegion) //----------------------------------------------------------------------------- // wxRegion @@ -277,58 +278,7 @@ bool wxRegion::Combine( , wxRegionOp eOp ) { - AllocExclusive(); - - // - // If ref count is 1, that means it's 'ours' anyway so no action. - // - RECTL vRect; - - vRect.xLeft = x; - vRect.xRight = x + vWidth; - vRect.yBottom = y; - vRect.yTop = y + vHeight; - - HRGN hRgn = ::GpiCreateRegion( ((wxRegionRefData*)m_refData)->m_hPS - ,1 - ,&vRect - ); - LONG lMode = 0L; - - switch (eOp) - { - case wxRGN_AND: - lMode = CRGN_AND; - break; - - case wxRGN_OR: - lMode = CRGN_OR; - break; - - case wxRGN_XOR: - lMode = CRGN_XOR; - break; - - case wxRGN_DIFF: - lMode = CRGN_DIFF; - break; - - case wxRGN_COPY: - default: - lMode = CRGN_COPY; - break; - } - bool bSuccess = ::GpiCombineRegion( ((wxRegionRefData*)m_refData)->m_hPS - ,M_REGION - ,M_REGION - ,hRgn - ,lMode - ); - ::GpiDestroyRegion ( ((wxRegionRefData*)m_refData)->m_hPS - ,hRgn - ); - - return bSuccess; + return Combine(wxRegion(x, y, vWidth, vHeight), eOp); } // end of wxRegion::Combine // @@ -339,42 +289,67 @@ bool wxRegion::Combine( , wxRegionOp eOp ) { - if (rRegion.Empty()) - return FALSE; - - AllocExclusive(); + // + // We can't use the API functions if we don't have a valid region handle + // + if (!m_refData) + { + // combining with an empty/invalid region works differently depending + // on the operation + switch (eOp) + { + case wxRGN_COPY: + case wxRGN_OR: + case wxRGN_XOR: + *this = rRegion; + break; + + default: + wxFAIL_MSG( _T("unknown region operation") ); + // fall through + + case wxRGN_AND: + case wxRGN_DIFF: + // leave empty/invalid + return FALSE; + } + } + else // we have a valid region + { - LONG lMode = 0; + LONG lMode = 0; - switch (eOp) - { - case wxRGN_AND: - lMode = CRGN_AND; - break; - - case wxRGN_OR: - lMode = CRGN_OR; - break; - - case wxRGN_XOR: - lMode = CRGN_XOR; - break; - - case wxRGN_DIFF: - lMode = CRGN_DIFF; - break; - - case wxRGN_COPY: - default: - lMode = CRGN_COPY; - break; + switch (eOp) + { + case wxRGN_AND: + lMode = CRGN_AND; + break; + + case wxRGN_OR: + lMode = CRGN_OR; + break; + + case wxRGN_XOR: + lMode = CRGN_XOR; + break; + + case wxRGN_DIFF: + lMode = CRGN_DIFF; + break; + + case wxRGN_COPY: + default: + lMode = CRGN_COPY; + break; + } + return (::GpiCombineRegion( ((wxRegionRefData*)rRegion.m_refData)->m_hPS + ,M_REGION + ,M_REGION + ,((wxRegionRefData*)rRegion.m_refData)->m_hRegion + ,lMode + ) != RGN_ERROR); } - return (::GpiCombineRegion( ((wxRegionRefData*)rRegion.m_refData)->m_hPS - ,M_REGION - ,M_REGION - ,((wxRegionRefData*)rRegion.m_refData)->m_hRegion - ,lMode - ) != RGN_ERROR); + return TRUE; } // end of wxRegion::Combine bool wxRegion::Combine( diff --git a/src/os2/toplevel.cpp b/src/os2/toplevel.cpp index 82cc9d5629..4e74fa9343 100644 --- a/src/os2/toplevel.cpp +++ b/src/os2/toplevel.cpp @@ -57,6 +57,7 @@ extern void wxAssociateWinWithHandle( HWND hWnd ,wxWindowOS2* pWin ); bool wxTopLevelWindowOS2::m_sbInitialized = FALSE; +wxWindow* wxTopLevelWindowOS2::m_spHiddenParent = NULL; // ============================================================================ // wxTopLevelWindowMSW implementation @@ -166,6 +167,46 @@ WXDWORD wxTopLevelWindowOS2::OS2GetStyle( return lMsflags; } // end of wxTopLevelWindowOS2::OS2GetCreateWindowFlags +WXHWND wxTopLevelWindowOS2::OS2GetParent() const +{ + // + // For the frames without wxFRAME_FLOAT_ON_PARENT style we should use NULL + // parent HWND or it would be always on top of its parent which is not what + // we usually want (in fact, we only want it for frames with the + // wxFRAME_FLOAT_ON_PARENT flag) + // + wxWindow* pParent; + + if (HasFlag(wxFRAME_FLOAT_ON_PARENT) ) + { + pParent = GetParent(); + + // this flag doesn't make sense then and will be ignored + wxASSERT_MSG( pParent, + _T("wxFRAME_FLOAT_ON_PARENT but no parent?") ); + } + else // don't float on parent, must not be owned + { + pParent = NULL; + } + if (HasFlag(wxFRAME_NO_TASKBAR) && !pParent) + { + if (!m_spHiddenParent) + { + m_spHiddenParent = new wxTopLevelWindowOS2(NULL, -1, _T("")); + + // + // We shouldn't leave it in wxTopLevelWindows or we wouldn't + // terminate the app when the last user-created frame is deleted -- + // see ~wxTopLevelWindowMSW + // + wxTopLevelWindows.DeleteObject(m_spHiddenParent); + } + pParent = m_spHiddenParent; + } + return pParent ? pParent->GetHWND() : NULL; +} // end of wxTopLevelWindowOS2::OS2GetParent + bool wxTopLevelWindowOS2::CreateDialog( ULONG ulDlgTemplate , const wxString& rsTitle diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 42c6c75783..12a47e3f5d 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -3097,6 +3097,11 @@ bool wxWindowOS2::OS2GetCreateWindowCoords( return bNonDefault; } // end of wxWindowOS2::OS2GetCreateWindowCoords +WXHWND wxWindowOS2::OS2GetParent() const +{ + return m_parent ? m_parent->GetHWND() : NULL; +} + bool wxWindowOS2::OS2Create( PSZ zClass , const char* zTitle @@ -3129,31 +3134,6 @@ bool wxWindowOS2::OS2Create( ,nHeight ); - if (GetWindowStyleFlag() & wxPOPUP_WINDOW) - hParent = HWND_DESKTOP; - else - { - if ((bIsChild || HasFlag(wxFRAME_TOOL_WINDOW)) && pParent ) - { - // - // This is either a normal child window or a top level window with - // wxFRAME_TOOL_WINDOW style (see below) - // - hParent = GetHwndOf(pParent); - } - else - { - // - // This is either a window for which no parent was specified (not - // much we can do then) or a frame without wxFRAME_TOOL_WINDOW - // style: we should use NULL parent HWND for it or it would be - // always on top of its parent which is not what we usually want - // (in fact, we only want it for frames with the special - // wxFRAME_TOOL_WINDOW as above) - // - hParent = NULL; - } - } if (bIsChild) { lControlId = GetId(); @@ -3171,20 +3151,20 @@ bool wxWindowOS2::OS2Create( { sClassName += wxT("NR"); } - m_hWnd = (WXHWND)::WinCreateWindow( (HWND)hParent - ,(PSZ)sClassName.c_str() - ,(PSZ)zTitle ? zTitle : "" - ,(ULONG)dwStyle - ,(LONG)0L - ,(LONG)0L - ,(LONG)0L - ,(LONG)0L - ,NULLHANDLE - ,HWND_TOP - ,(ULONG)lControlId - ,pCtlData - ,NULL - ); + m_hWnd = (WXHWND)::WinCreateWindow( (HWND)OS2GetParent() + ,(PSZ)sClassName.c_str() + ,(PSZ)zTitle ? zTitle : "" + ,(ULONG)dwStyle + ,(LONG)0L + ,(LONG)0L + ,(LONG)0L + ,(LONG)0L + ,NULLHANDLE + ,HWND_TOP + ,(ULONG)lControlId + ,pCtlData + ,NULL + ); if (!m_hWnd) { vError = ::WinGetLastError(wxGetInstance()); @@ -3946,6 +3926,7 @@ void wxWindowOS2::InitMouseEvent( rEvent.m_rightDown = ((uFlags & VK_BUTTON2) != 0); rEvent.SetTimestamp(s_currentMsg.time); rEvent.m_eventObject = this; + rEvent.SetId(GetId()); #if wxUSE_MOUSEEVENT_HACK m_lastMouseX = nX; diff --git a/src/os2/wx23.def b/src/os2/wx23.def index d647fdcadd..84f70ef783 100644 --- a/src/os2/wx23.def +++ b/src/os2/wx23.def @@ -4,7 +4,7 @@ DATA MULTIPLE NONSHARED READWRITE LOADONCALL CODE LOADONCALL EXPORTS -;From library: F:\DEV\WX2\WXWINDOWS\LIB\wx.lib +;From library: H:\Dev\Wx2\WxWindows\lib\WX.lib ;From object file: dummy.cpp ;PUBDEFs (Symbols available from object file): wxDummyChar @@ -229,16 +229,16 @@ EXPORTS __ct__21wxPageSetupDialogDataFRC11wxPrintData ;wxPageSetupDialogData::operator=(const wxPageSetupDialogData&) __as__21wxPageSetupDialogDataFRC21wxPageSetupDialogData - ;wxPrintData::wxPrintData() - __ct__11wxPrintDataFv + ;wxFontDialogBase::~wxFontDialogBase() + __dt__16wxFontDialogBaseFv ;wxConstructorForwxPageSetupDialogData() wxConstructorForwxPageSetupDialogData__Fv ;wxPrintDialogData::~wxPrintDialogData() __dt__17wxPrintDialogDataFv - ;wxFontDialogBase::~wxFontDialogBase() - __dt__16wxFontDialogBaseFv ;wxColourData::wxColourData() __ct__12wxColourDataFv + ;wxPrintData::wxPrintData() + __ct__11wxPrintDataFv ;wxPageSetupDialogData::CalculatePaperSizeFromId() CalculatePaperSizeFromId__21wxPageSetupDialogDataFv ;wxPageSetupDialogData::CalculateIdFromPaperSize() @@ -1798,8 +1798,8 @@ EXPORTS wxEVT_KILL_FOCUS wxEVT_COMMAND_RIGHT_DCLICK wxEVT_CLOSE_WINDOW - ;wxEvtHandler::ProcessEvent(wxEvent&) - ProcessEvent__12wxEvtHandlerFR7wxEvent + ;wxMouseEvent::Assign(const wxMouseEvent&) + Assign__12wxMouseEventFRC12wxMouseEvent wxEVT_SCROLL_LINEUP wxEVT_PAINT wxEVT_NULL @@ -1827,6 +1827,8 @@ EXPORTS sm_classwxEraseEvent__12wxEraseEvent ;wxEvtHandler::SearchEventTable(wxEventTable&,wxEvent&) SearchEventTable__12wxEvtHandlerFR12wxEventTableR7wxEvent + ;wxEvtHandler::ProcessEvent(wxEvent&) + ProcessEvent__12wxEvtHandlerFR7wxEvent ;wxMouseEvent::wxMouseEvent(int) __ct__12wxMouseEventFi wxEVT_JOY_ZMOVE @@ -1940,7 +1942,7 @@ EXPORTS wxEVT_NC_LEFT_DCLICK wxEVT_INIT_DIALOG wxEVT_COMMAND_SET_FOCUS - ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\extended.c + ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\extended.c ;PUBDEFs (Symbols available from object file): ConvertToIeeeExtended ConvertFromIeeeExtended @@ -3149,8 +3151,8 @@ EXPORTS GetImageCount__7wxImageFR13wxInputStreaml ;wxImage::FindFirstUnusedColour(unsigned char*,unsigned char*,unsigned char*,unsigned char,unsigned char,unsigned char) const FindFirstUnusedColour__7wxImageCFPUcN21UcN24 - ;wxImage::Scale(int,int) const - Scale__7wxImageCFiT1 + ;wxImageHandler::CallDoCanRead(wxInputStream&) + CallDoCanRead__14wxImageHandlerFR13wxInputStream ;wxImage::sm_handlers sm_handlers__7wxImage ;wxImage::wxImage(const wxImage&) @@ -3159,6 +3161,8 @@ EXPORTS __ct__7wxImageFR13wxInputStreamRC8wxStringi ;wxImage::SetPalette(const wxPalette&) SetPalette__7wxImageFRC9wxPalette + ;wxImage::Scale(int,int) const + Scale__7wxImageCFiT1 ;wxImage::LoadFile(const wxString&,long,int) LoadFile__7wxImageFRC8wxStringli ;wxImageHandler::LoadFile(wxImage*,wxInputStream&,unsigned long,int) @@ -6142,7 +6146,7 @@ EXPORTS Read32__17wxTextInputStreamFv ;wxTextInputStream::SkipIfEndOfLine(char) SkipIfEndOfLine__17wxTextInputStreamFc - ;From object file: F:\DEV\WX2\WXWINDOWS\src\common\unzip.c + ;From object file: H:\DEV\WX2\WXWINDOWS\src\common\unzip.c ;PUBDEFs (Symbols available from object file): unzReadCurrentFile unzGetCurrentFileInfo @@ -7056,6 +7060,12 @@ EXPORTS GetHelpText__12wxWindowBaseCFv ;wxWindowBase::GetAncestorWithCustomPalette() const GetAncestorWithCustomPalette__12wxWindowBaseCFv + ;wxWindowBase::FindWindowByLabel(const wxString&,const wxWindow*) + FindWindowByLabel__12wxWindowBaseFRC8wxStringPC8wxWindow + ;wxWindowBase::FindWindowByName(const wxString&,const wxWindow*) + FindWindowByName__12wxWindowBaseFRC8wxStringPC8wxWindow + ;wxWindowBase::FindWindowById(long,const wxWindow*) + FindWindowById__12wxWindowBaseFlPC8wxWindow ;wxWindowBase::SetFont(const wxFont&) SetFont__12wxWindowBaseFRC6wxFont ;wxWindowBase::MakeModal(unsigned long) @@ -7072,6 +7082,8 @@ EXPORTS InitBase__12wxWindowBaseFv ;wxWindowBase::SetCursor(const wxCursor&) SetCursor__12wxWindowBaseFRC8wxCursor + ;wxWindowBase::SatisfyConstraints() + SatisfyConstraints__12wxWindowBaseFv ;wxWindowBase::ResetConstraints() ResetConstraints__12wxWindowBaseFv ;wxWindowBase::GetDefaultBorder() const @@ -10795,10 +10807,12 @@ EXPORTS WriteCustomization__15wxHtmlHelpFrameFP12wxConfigBaseRC8wxString ;wxHtmlHelpFrameOptionsDialog::sm_eventTable sm_eventTable__28wxHtmlHelpFrameOptionsDialog - ;wxHtmlHelpFrame::OnIndexAll(wxCommandEvent&) - OnIndexAll__15wxHtmlHelpFrameFR14wxCommandEvent + ;wxHtmlHelpFrame::OnActivate(wxActivateEvent&) + OnActivate__15wxHtmlHelpFrameFR15wxActivateEvent __vft28wxHtmlHelpFrameOptionsDialog8wxObject __vft15wxHtmlHelpFrame8wxObject + ;wxHtmlHelpFrame::OnIndexAll(wxCommandEvent&) + OnIndexAll__15wxHtmlHelpFrameFR14wxCommandEvent ;wxHtmlHelpFrame::wxHtmlHelpFrame(wxWindow*,int,const wxString&,int,wxHtmlHelpData*) __ct__15wxHtmlHelpFrameFP8wxWindowiRC8wxStringT2P14wxHtmlHelpData ;wxHtmlHelpFrame::DisplayContents() @@ -13849,6 +13863,12 @@ EXPORTS __vft13wxPopupWindow8wxObject ;wxPopupWindow::DoGetPosition(int*,int*) const DoGetPosition__13wxPopupWindowCFPiT1 + ;wxPopupWindow::FindPopupFor(wxWindow*) + FindPopupFor__13wxPopupWindowFP8wxWindow + ;wxPopupWindow::Show(unsigned long) + Show__13wxPopupWindowFUl + ;wxPopupWindow::m_svShownPopups + m_svShownPopups__13wxPopupWindow ;wxPopupWindow::OS2GetStyle(long,unsigned long*) const OS2GetStyle__13wxPopupWindowCFlPUl ;wxPopupWindow::Create(wxWindow*,int) @@ -14818,12 +14838,16 @@ EXPORTS Init__19wxTopLevelWindowOS2Fv ;wxTopLevelWindowOS2::m_sbInitialized m_sbInitialized__19wxTopLevelWindowOS2 + ;wxTopLevelWindowOS2::OS2GetParent() const + OS2GetParent__19wxTopLevelWindowOS2CFv ;wxTopLevelWindowOS2::Iconize(unsigned long) Iconize__19wxTopLevelWindowOS2FUl ;wxTopLevelWindowOS2::DoSetClientSize(int,int) DoSetClientSize__19wxTopLevelWindowOS2FiT1 ;wxTopLevelWindowOS2::IsMaximized() const IsMaximized__19wxTopLevelWindowOS2CFv + ;wxTopLevelWindowOS2::m_spHiddenParent + m_spHiddenParent__19wxTopLevelWindowOS2 ;wxTopLevelWindowOS2::SetIcon(const wxIcon&) SetIcon__19wxTopLevelWindowOS2FRC6wxIcon ;wxTopLevelWindowOS2::Restore() @@ -14996,6 +15020,8 @@ EXPORTS UnsubclassWin__8wxWindowFv ;wxWindow::Raise() Raise__8wxWindowFv + ;wxWindow::OS2GetParent() const + OS2GetParent__8wxWindowCFv ;wxWindow::Lower() Lower__8wxWindowFv ;wxWindow::HandleMaximize() -- 2.45.2