From 54ffa10747e51b9fa8c52b7f864e187e82fd4919 Mon Sep 17 00:00:00 2001 From: David Webster Date: Tue, 22 Jan 2002 23:19:28 +0000 Subject: [PATCH 1/1] OS/2 bug fixes and new mod file git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13755 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/app.cpp | 46 +++++++++++++++++++++++++---------------- src/os2/font.cpp | 4 +++- src/os2/fontutil.cpp | 49 ++++++++++++++++++++++++++------------------ src/os2/frame.cpp | 20 ++++++++++++++++++ src/os2/textctrl.cpp | 7 +++++++ src/os2/toplevel.cpp | 16 +++++++++++---- src/os2/window.cpp | 15 ++++++++++++++ src/os2/wx23.def | 8 ++++++-- 8 files changed, 120 insertions(+), 45 deletions(-) diff --git a/src/os2/app.cpp b/src/os2/app.cpp index 5d137de3d3..a2608efbf2 100644 --- a/src/os2/app.cpp +++ b/src/os2/app.cpp @@ -253,22 +253,6 @@ bool wxApp::Initialize( #endif //wxUSE_CONSOLEDEBUG #endif - // - // OS2 has to have an anchorblock - // - vHab = WinInitialize(0); - - if (!vHab) - return FALSE; - else - vHabmain = vHab; - - // Some people may wish to use this, but - // probably it shouldn't be here by default. -#ifdef __WXDEBUG__ - // wxRedirectIOToConsole(); -#endif - wxBuffer = new wxChar[1500]; // FIXME; why? wxClassInfo::InitializeClasses(); @@ -289,7 +273,22 @@ bool wxApp::Initialize( wxBitmap::InitStandardHandlers(); - RegisterWindowClasses(vHab); + // + // OS2 has to have an anchorblock + // + vHab = WinInitialize(0); + + if (!vHab) + return FALSE; + else + vHabmain = vHab; + + // Some people may wish to use this, but + // probably it shouldn't be here by default. +#ifdef __WXDEBUG__ + // wxRedirectIOToConsole(); +#endif + wxWinHandleList = new wxList(wxKEY_INTEGER); // This is to foil optimizations in Visual C++ that throw out dummy.obj. @@ -304,6 +303,7 @@ bool wxApp::Initialize( wxModule::RegisterModules(); if (!wxModule::InitializeModules()) return FALSE; + RegisterWindowClasses(vHab); return TRUE; } // end of wxApp::Initialize @@ -413,7 +413,7 @@ bool wxApp::RegisterWindowClasses( if (!::WinRegisterClass( vHab ,wxCanvasClassName ,wxWndProc - ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT | CS_CLIPCHILDREN + ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT ,sizeof(ULONG) )) { @@ -901,6 +901,16 @@ bool wxApp::ProcessMessage( if (pMsg->msg == WM_TIMER) wxTimerProc(NULL, 0, (int)pMsg->mp1, 0); + // + // Allow the window to prevent certain messages from being + // translated/processed (this is currently used by wxTextCtrl to always + // grab Ctrl-C/V/X, even if they are also accelerators in some parent) + // + if (pWndThis && !pWndThis->OS2ShouldPreProcessMessage(pWxmsg)) + { + return FALSE; + } + // // For some composite controls (like a combobox), wndThis might be NULL // because the subcontrol is not a wxWindow, but only the control itself diff --git a/src/os2/font.cpp b/src/os2/font.cpp index 623f7fd444..c6a9b75646 100644 --- a/src/os2/font.cpp +++ b/src/os2/font.cpp @@ -368,7 +368,7 @@ bool wxFontRefData::Alloc( { wxFillLogFont( &m_vNativeFontInfo.fa ,&m_vNativeFontInfo.fn - ,m_hPS + ,&m_hPS ,&flId ,sFaceName ,pFont @@ -425,6 +425,8 @@ bool wxFontRefData::Alloc( m_nFamily = wxSCRIPT; else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier New") == 0) m_nFamily = wxMODERN; + else if (strcmp(m_vNativeFontInfo.fa.szFacename, "Courier") == 0) + m_nFamily = wxMODERN; else m_nFamily = wxSWISS; diff --git a/src/os2/fontutil.cpp b/src/os2/fontutil.cpp index 052537053e..31bbcaac3d 100644 --- a/src/os2/fontutil.cpp +++ b/src/os2/fontutil.cpp @@ -261,7 +261,7 @@ bool wxTestFontEncoding( void wxFillLogFont( LOGFONT* pFattrs // OS2 GPI FATTRS , PFACENAMEDESC pFaceName -, HPS hPS +, HPS* phPS , long* pflId , wxString& sFaceName , wxFont* pFont @@ -269,7 +269,7 @@ void wxFillLogFont( { LONG lNumFonts = 0L; // For system font count ERRORID vError; // For logging API errors - LONG lTemp; + LONG lTemp = 0L; bool bInternalPS = FALSE; // if we have to create one PFONTMETRICS pFM = NULL; @@ -277,22 +277,30 @@ void wxFillLogFont( // Initial house cleaning to free data buffers and ensure we have a // functional PS to work with // - if (!hPS) + if (!*phPS) { - hPS = ::WinGetPS(HWND_DESKTOP); + *phPS = ::WinGetPS(HWND_DESKTOP); bInternalPS = TRUE; } // // Determine the number of fonts. // - lNumFonts = ::GpiQueryFonts( hPS - ,QF_PUBLIC - ,NULL - ,&lTemp - ,(LONG) sizeof(FONTMETRICS) - ,NULL - ); + if((lNumFonts = ::GpiQueryFonts( *phPS + ,QF_PUBLIC + ,NULL + ,&lTemp + ,(LONG) sizeof(FONTMETRICS) + ,NULL + )) < 0L) + { + ERRORID vError; + wxString sError; + + vError = ::WinGetLastError(wxGetInstance()); + sError = wxPMErrorToStr(vError); + return; + } // // Allocate space for the font metrics. @@ -303,7 +311,7 @@ void wxFillLogFont( // Retrieve the font metrics. // lTemp = lNumFonts; - lTemp = ::GpiQueryFonts( hPS + lTemp = ::GpiQueryFonts( *phPS ,QF_PUBLIC ,NULL ,&lTemp @@ -355,7 +363,7 @@ void wxFillLogFont( // We should now have the correct FATTRS set with the selected // font, so now we need to generate an ID // - long lNumLids = ::GpiQueryNumberSetIds(hPS); + long lNumLids = ::GpiQueryNumberSetIds(*phPS); long lGpiError; if(lNumLids ) @@ -364,7 +372,7 @@ void wxFillLogFont( STR8 azNames[255]; long alIds[255]; - if(!::GpiQuerySetIds( hPS + if(!::GpiQuerySetIds( *phPS ,lNumLids ,alTypes ,azNames @@ -372,7 +380,7 @@ void wxFillLogFont( )) { if (bInternalPS) - ::WinReleasePS(hPS); + ::WinReleasePS(*phPS); return; } @@ -382,16 +390,17 @@ void wxFillLogFont( if(*pflId > 254) // wow, no id available! { if (bInternalPS) - ::WinReleasePS(hPS); + ::WinReleasePS(*phPS); return; } } - + else + *pflId = 1L; // // Release and delete the current font // - ::GpiSetCharSet(hPS, LCID_DEFAULT);/* release the font before deleting */ - ::GpiDeleteSetId(hPS, 1L); /* delete the logical font */ + ::GpiSetCharSet(*phPS, LCID_DEFAULT);/* release the font before deleting */ + ::GpiDeleteSetId(*phPS, 1L); /* delete the logical font */ // // Now build a facestring @@ -400,7 +409,7 @@ void wxFillLogFont( strcpy(zFacename, pFattrs->szFacename); - if(::GpiQueryFaceString( hPS + if(::GpiQueryFaceString( *phPS ,zFacename ,pFaceName ,FACESIZE diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index d6087502a3..0f687f7f86 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -248,6 +248,26 @@ wxStatusBar* wxFrame::OnCreateStatusBar( if( !pStatusBar ) return NULL; + wxClientDC vDC(pStatusBar); + int nY; + + // + // Set the height according to the font and the border size + // + vDC.SetFont(pStatusBar->GetFont()); // Screws up the menues for some reason + vDC.GetTextExtent( "X" + ,NULL + ,&nY + ); + + int nHeight = ((11 * nY) / 10 + 2 * pStatusBar->GetBorderY()); + + pStatusBar->SetSize( -1 + ,-1 + ,-1 + ,nHeight + ); + ::WinSetParent( pStatusBar->GetHWND() ,m_hFrame ,FALSE diff --git a/src/os2/textctrl.cpp b/src/os2/textctrl.cpp index 69f0914f4b..4070a29689 100644 --- a/src/os2/textctrl.cpp +++ b/src/os2/textctrl.cpp @@ -965,6 +965,13 @@ WXHBRUSH wxTextCtrl::OnCtlColor( return (WXHBRUSH)pBackgroundBrush->GetResourceHandle(); } // end of wxTextCtrl::OnCtlColor +bool wxTextCtrl::OS2ShouldPreProcessMessage( + WXMSG* pMsg +) +{ + return wxControl::OS2ShouldPreProcessMessage(pMsg); +} // end of wxTextCtrl::OS2ShouldPreProcessMessage + void wxTextCtrl::OnChar( wxKeyEvent& rEvent ) diff --git a/src/os2/toplevel.cpp b/src/os2/toplevel.cpp index 0362889309..abbd5c5c21 100644 --- a/src/os2/toplevel.cpp +++ b/src/os2/toplevel.cpp @@ -351,7 +351,7 @@ bool wxTopLevelWindowOS2::CreateFrame( wxAssociateWinWithHandle(m_hWnd, this); wxAssociateWinWithHandle(m_hFrame, this); - m_backgroundColour.Set(wxString("GREY")); + m_backgroundColour.Set(wxString("DARK GREY")); LONG lColor = (LONG)m_backgroundColour.GetPixel(); @@ -403,6 +403,14 @@ bool wxTopLevelWindowOS2::CreateFrame( wxLogError("Error sizing frame. Error: %s\n", sError); return FALSE; } + lStyle = ::WinQueryWindowULong( m_hWnd + ,QWL_STYLE + ); + lStyle |= WS_CLIPCHILDREN; + ::WinSetWindowULong( m_hWnd + ,QWL_STYLE + ,lStyle + ); return TRUE; } // end of wxTopLevelWindowOS2::CreateFrame @@ -584,7 +592,7 @@ void wxTopLevelWindowOS2::DoShowWindow( int nShowCmd ) { - ::WinShowWindow(m_hFrame, (BOOL)nShowCmd); + ::WinShowWindow(m_hFrame, (BOOL)(nShowCmd & SWP_SHOW)); m_bIconized = nShowCmd == SWP_MINIMIZE; } // end of wxTopLevelWindowOS2::DoShowWindow @@ -600,12 +608,12 @@ bool wxTopLevelWindowOS2::Show( { if (m_bMaximizeOnShow) { - nShowCmd = SWP_SHOW; + nShowCmd = SWP_MAXIMIZE; m_bMaximizeOnShow = FALSE; } else { - nShowCmd = SWP_HIDE; + nShowCmd = SWP_SHOW; } } else // hide diff --git a/src/os2/window.cpp b/src/os2/window.cpp index 9bc6c64ae5..30ac8d5c44 100644 --- a/src/os2/window.cpp +++ b/src/os2/window.cpp @@ -2265,6 +2265,14 @@ bool wxWindowOS2::OS2TranslateMessage( #endif //wxUSE_ACCEL } // end of wxWindowOS2::OS2TranslateMessage +bool wxWindowOS2::OS2ShouldPreProcessMessage( + WXMSG* pMsg +) +{ + // preprocess all messages by default + return TRUE; +} // end of wxWindowOS2::OS2ShouldPreProcessMessage + // --------------------------------------------------------------------------- // message params unpackers // --------------------------------------------------------------------------- @@ -3138,6 +3146,13 @@ bool wxWindowOS2::HandleSetFocus( WXHWND WXUNUSED(hWnd) ) { + // + // Notify the parent keeping track of focus for the kbd navigation + // purposes that we got it + // + wxChildFocusEvent vEventFocus((wxWindow *)this); + (void)GetEventHandler()->ProcessEvent(vEventFocus); + #if wxUSE_CARET // // Deal with caret diff --git a/src/os2/wx23.def b/src/os2/wx23.def index c35afce4db..871fd0b3b7 100644 --- a/src/os2/wx23.def +++ b/src/os2/wx23.def @@ -12321,8 +12321,8 @@ EXPORTS wxGetNativeFontEncoding__F14wxFontEncodingP20wxNativeEncodingInfo ;wxOS2SelectMatchingFontByName(_FATTRS*,_FACENAMEDESC*,_FONTMETRICS*,int,const wxFont*) wxOS2SelectMatchingFontByName__FP7_FATTRSP13_FACENAMEDESCP12_FONTMETRICSiPC6wxFont - ;wxFillLogFont(_FATTRS*,_FACENAMEDESC*,unsigned long,long*,wxString&,wxFont*) - wxFillLogFont__FP7_FATTRSP13_FACENAMEDESCUlPlR8wxStringP6wxFont + ;wxFillLogFont(_FATTRS*,_FACENAMEDESC*,unsigned long*,long*,wxString&,wxFont*) + wxFillLogFont__FP7_FATTRSP13_FACENAMEDESCPUlPlR8wxStringP6wxFont ;wxGpiStrcmp(char*,char*) wxGpiStrcmp__FPcT1 ;wxNativeEncodingInfo::FromString(const wxString&) @@ -14019,6 +14019,8 @@ EXPORTS Cut__10wxTextCtrlFv ;wxTextCtrl::SetInsertionPointEnd() SetInsertionPointEnd__10wxTextCtrlFv + ;wxTextCtrl::OS2ShouldPreProcessMessage(void**) + OS2ShouldPreProcessMessage__10wxTextCtrlFPPv ;wxTextCtrl::DiscardEdits() DiscardEdits__10wxTextCtrlFv ;wxTextCtrl::CanUndo() const @@ -14650,6 +14652,8 @@ EXPORTS OS2WindowProc__8wxWindowFUiPvT2 ;wxWindow::OS2TranslateMessage(void**) OS2TranslateMessage__8wxWindowFPPv + ;wxWindow::OS2ShouldPreProcessMessage(void**) + OS2ShouldPreProcessMessage__8wxWindowFPPv ;wxWindow::OS2DefWindowProc(unsigned int,void*,void*) OS2DefWindowProc__8wxWindowFUiPvT2 ;wxWindow::HandleMinimize() -- 2.45.2