From 2e88cd311bdf121ed2bc47f6b9218348e15d11d7 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Sat, 18 Feb 2006 22:09:03 +0000 Subject: [PATCH] Small fix to grid class Originally committed to SVN as r63. --- core/base_grid.cpp | 36 +++++++++++++++++++++++++----------- core/base_grid.h | 1 + 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/core/base_grid.cpp b/core/base_grid.cpp index d5d24b8b7..f2a9f6665 100644 --- a/core/base_grid.cpp +++ b/core/base_grid.cpp @@ -59,6 +59,7 @@ BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wx lastRow = -1; yPos = 0; bmp = NULL; + holding = true; // Set font wxString fontname = Options.AsText(_T("Font Face")); @@ -101,7 +102,15 @@ void BaseGrid::SelectRow(int row, bool addToSelected, bool select) { bool cur = selMap.at(row); if (select != cur) { selMap.at(row) = select; - Refresh(false); + + if (!addToSelected) Refresh(false); + + else { + int w = 0; + int h = 0; + GetClientSize(&w,&h); + RefreshRect(wxRect(0,(row+1-yPos)*lineHeight,w,lineHeight),false); + } } } catch (...) {} @@ -429,7 +438,8 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) { // Click type bool click = event.ButtonDown(wxMOUSE_BTN_LEFT); - bool hold = event.ButtonIsDown(wxMOUSE_BTN_LEFT); + if (click) holding = true; + if (!event.ButtonIsDown(wxMOUSE_BTN_LEFT)) holding = false; // Row that mouse is over int row = event.GetY()/lineHeight + yPos - 1; @@ -437,14 +447,24 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) { if (!validRow) row = -1; // Click - if ((click || hold) && validRow) { + if ((click || holding) && validRow) { // Toggle selected if (click && ctrl && !shift) { SelectRow(row,true,!IsInSelection(row,0)); + return; + } + + // Normal click + if (click && !shift && !ctrl && !alt) { + editBox->SetToLine(row); + parentFrame->SetSelectionFlag(validRow); + SelectRow(row,false); + lastRow = row; + return; } // Block select - if ((click && shift && !ctrl) || (hold)) { + if ((click && shift && !ctrl) || (holding)) { if (lastRow != -1) { // Set boundaries int i1 = row; @@ -462,15 +482,9 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) { notFirst = true; } } + return; } - // Normal click - if (click && !shift && !ctrl && !alt) { - editBox->SetToLine(row); - parentFrame->SetSelectionFlag(validRow); - SelectRow(row,false); - lastRow = row; - } return; } diff --git a/core/base_grid.h b/core/base_grid.h index be0a1c7eb..b2b641207 100644 --- a/core/base_grid.h +++ b/core/base_grid.h @@ -62,6 +62,7 @@ private: int colWidth[16]; int yPos; int lastRow; + bool holding; wxFont font; wxScrollBar *scrollBar; wxBitmap *bmp;