From 597acb605cf28ab243fa3ea26fd873b51fbef62f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 30 Mar 2000 22:26:34 +0000 Subject: [PATCH] 1. fixed apparent bug in wxGrid code 2. fixed WM_CHAR handling in combobox 3. fixed controls positioning in the toolbar with older comctl32.dll/mingw32 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7005 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/combobox.h | 22 ++++++----- src/generic/grid.cpp | 79 ++++++++++++++++++++------------------- src/msw/combobox.cpp | 17 ++++++++- src/msw/tbar95.cpp | 2 +- 4 files changed, 69 insertions(+), 51 deletions(-) diff --git a/include/wx/msw/combobox.h b/include/wx/msw/combobox.h index 1828e0045a..67a49e1e76 100644 --- a/include/wx/msw/combobox.h +++ b/include/wx/msw/combobox.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: combobox.h +// Name: wx/msw/combobox.h // Purpose: wxComboBox class // Author: Julian Smart // Modified by: @@ -46,14 +46,16 @@ public: Create(parent, id, value, pos, size, n, choices, style, validator, name); } - bool Create(wxWindow *parent, wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); + bool Create(wxWindow *parent, + wxWindowID id, + const wxString& value = wxEmptyString, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + int n = 0, + const wxString choices[] = NULL, + long style = 0, + const wxValidator& validator = wxDefaultValidator, + const wxString& name = wxComboBoxNameStr); // List functions: see wxChoice @@ -75,7 +77,9 @@ public: virtual void SetSelection(long from, long to); virtual void SetEditable(bool editable); + // implementation only from now on virtual bool MSWCommand(WXUINT param, WXWORD id); + bool MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam); protected: virtual void DoMoveWindow(int x, int y, int width, int height); diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 3e55670f77..fdfaf6dce2 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5427,8 +5427,10 @@ void wxGrid::DrawGridSpace( wxDC& dc ) int right, bottom; CalcUnscrolledPosition( cw, ch, &right, &bottom ); - if ( right > (m_numCols>0) ? GetColRight(m_numCols-1) : 0 || - bottom > (m_numRows>0) ? GetRowBottom(m_numRows-1) : 0 ) + int rightCol = m_numCols > 0 ? GetColRight(m_numCols - 1) : 0; + int bottomRow = m_numRows > 0 ? GetRowBottom(m_numRows - 1) : 0 ; + + if ( right > rightCol || bottom > bottomRow ) { int left, top; CalcUnscrolledPosition( 0, 0, &left, &top ); @@ -5436,17 +5438,16 @@ void wxGrid::DrawGridSpace( wxDC& dc ) dc.SetBrush( wxBrush(GetDefaultCellBackgroundColour(), wxSOLID) ); dc.SetPen( *wxTRANSPARENT_PEN ); - if ( right > (m_numCols>0) ? GetColRight(m_numCols-1) : 0 ) - dc.DrawRectangle( (m_numCols>0) ? GetColRight(m_numCols-1) : 0, - top, right - (m_numCols>0) ? - GetColRight(m_numCols-1) : 0, ch ); + if ( right > rightCol ) + { + dc.DrawRectangle( rightCol, top, right - rightCol, ch); + } - if ( bottom > (m_numRows>0) ? GetRowBottom(m_numRows-1) : 0 ) - dc.DrawRectangle( left, - (m_numRows>0) ? GetRowBottom(m_numRows-1) : 0, - cw, - bottom - ((m_numRows>0) ? GetRowBottom(m_numRows-1) : 0 )); - } + if ( bottom > bottomRow ) + { + dc.DrawRectangle( left, bottomRow, cw, bottom - bottomRow); + } + } } @@ -6300,13 +6301,13 @@ bool wxGrid::MoveCursorUp( bool expandSelection ) { if ( m_selectingKeyboard == wxGridNoCellCoords ) m_selectingKeyboard = m_currentCellCoords; - if ( m_selectingKeyboard.GetRow() > 0 ) - { - m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() - 1 ); - MakeCellVisible( m_selectingKeyboard.GetRow(), - m_selectingKeyboard.GetCol() ); - SelectBlock( m_currentCellCoords, m_selectingKeyboard ); - } + if ( m_selectingKeyboard.GetRow() > 0 ) + { + m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() - 1 ); + MakeCellVisible( m_selectingKeyboard.GetRow(), + m_selectingKeyboard.GetCol() ); + SelectBlock( m_currentCellCoords, m_selectingKeyboard ); + } } else { @@ -6332,13 +6333,13 @@ bool wxGrid::MoveCursorDown( bool expandSelection ) { if ( m_selectingKeyboard == wxGridNoCellCoords ) m_selectingKeyboard = m_currentCellCoords; - if ( m_selectingKeyboard.GetRow() < m_numRows-1 ) - { - m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() + 1 ); - MakeCellVisible( m_selectingKeyboard.GetRow(), - m_selectingKeyboard.GetCol() ); - SelectBlock( m_currentCellCoords, m_selectingKeyboard ); - } + if ( m_selectingKeyboard.GetRow() < m_numRows-1 ) + { + m_selectingKeyboard.SetRow( m_selectingKeyboard.GetRow() + 1 ); + MakeCellVisible( m_selectingKeyboard.GetRow(), + m_selectingKeyboard.GetCol() ); + SelectBlock( m_currentCellCoords, m_selectingKeyboard ); + } } else { @@ -6364,13 +6365,13 @@ bool wxGrid::MoveCursorLeft( bool expandSelection ) { if ( m_selectingKeyboard == wxGridNoCellCoords ) m_selectingKeyboard = m_currentCellCoords; - if ( m_selectingKeyboard.GetCol() > 0 ) - { - m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() - 1 ); - MakeCellVisible( m_selectingKeyboard.GetRow(), - m_selectingKeyboard.GetCol() ); - SelectBlock( m_currentCellCoords, m_selectingKeyboard ); - } + if ( m_selectingKeyboard.GetCol() > 0 ) + { + m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() - 1 ); + MakeCellVisible( m_selectingKeyboard.GetRow(), + m_selectingKeyboard.GetCol() ); + SelectBlock( m_currentCellCoords, m_selectingKeyboard ); + } } else { @@ -6397,12 +6398,12 @@ bool wxGrid::MoveCursorRight( bool expandSelection ) if ( m_selectingKeyboard == wxGridNoCellCoords ) m_selectingKeyboard = m_currentCellCoords; if ( m_selectingKeyboard.GetCol() < m_numCols - 1 ) - { - m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() + 1 ); - MakeCellVisible( m_selectingKeyboard.GetRow(), - m_selectingKeyboard.GetCol() ); - SelectBlock( m_currentCellCoords, m_selectingKeyboard ); - } + { + m_selectingKeyboard.SetCol( m_selectingKeyboard.GetCol() + 1 ); + MakeCellVisible( m_selectingKeyboard.GetRow(), + m_selectingKeyboard.GetCol() ); + SelectBlock( m_currentCellCoords, m_selectingKeyboard ); + } } else { diff --git a/src/msw/combobox.cpp b/src/msw/combobox.cpp index 311c1a1c92..5b5df687ed 100644 --- a/src/msw/combobox.cpp +++ b/src/msw/combobox.cpp @@ -76,9 +76,12 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd, if ( message == WM_CHAR ) { HWND hwndCombo = ::GetParent(hWnd); - wxCHECK_MSG( hwndCombo, 0, _T("should have combo as parent") ); + wxWindow *win = wxFindWinFromHandle((WXHWND)hwndCombo); + wxComboBox *combo = wxDynamicCast(win, wxComboBox); + wxCHECK_MSG( combo, 0, _T("should have combo as parent") ); - ::SendMessage(hwndCombo, message, wParam, lParam); + if ( combo->MSWProcessEditMsg(message, wParam, lParam) ) + return 0; } return ::CallWindowProc(CASTWNDPROC gs_wndprocEdit, hWnd, message, wParam, lParam); @@ -88,6 +91,16 @@ LRESULT APIENTRY _EXPORT wxComboEditWndProc(HWND hWnd, // wxComboBox // ---------------------------------------------------------------------------- +bool wxComboBox::MSWProcessEditMsg(WXUINT msg, WXWPARAM wParam, WXLPARAM lParam) +{ + if ( msg == WM_CHAR ) + { + return HandleChar(wParam, lParam, TRUE /* isASCII */); + } + + return FALSE; +} + bool wxComboBox::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { switch ( param ) diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index a14d491a8b..a2ef84f155 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -580,7 +580,7 @@ bool wxToolBar::Realize() TBBUTTON tbb; wxZeroMemory(tbb); tbb.idCommand = 0; - tbb.fsState = TBSTATE_ENABLED | TBSTATE_HIDDEN; + tbb.fsState = TBSTATE_ENABLED; tbb.fsStyle = TBSTYLE_SEP; size_t nSeparators = size.x / widthSep;