forked from mia/Aegisub
Small fix to grid class
Originally committed to SVN as r63.
This commit is contained in:
parent
f4daf0e020
commit
2e88cd311b
2 changed files with 26 additions and 11 deletions
|
@ -59,6 +59,7 @@ BaseGrid::BaseGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wx
|
||||||
lastRow = -1;
|
lastRow = -1;
|
||||||
yPos = 0;
|
yPos = 0;
|
||||||
bmp = NULL;
|
bmp = NULL;
|
||||||
|
holding = true;
|
||||||
|
|
||||||
// Set font
|
// Set font
|
||||||
wxString fontname = Options.AsText(_T("Font Face"));
|
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);
|
bool cur = selMap.at(row);
|
||||||
if (select != cur) {
|
if (select != cur) {
|
||||||
selMap.at(row) = select;
|
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 (...) {}
|
catch (...) {}
|
||||||
|
@ -429,7 +438,8 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
|
|
||||||
// Click type
|
// Click type
|
||||||
bool click = event.ButtonDown(wxMOUSE_BTN_LEFT);
|
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
|
// Row that mouse is over
|
||||||
int row = event.GetY()/lineHeight + yPos - 1;
|
int row = event.GetY()/lineHeight + yPos - 1;
|
||||||
|
@ -437,14 +447,24 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
if (!validRow) row = -1;
|
if (!validRow) row = -1;
|
||||||
|
|
||||||
// Click
|
// Click
|
||||||
if ((click || hold) && validRow) {
|
if ((click || holding) && validRow) {
|
||||||
// Toggle selected
|
// Toggle selected
|
||||||
if (click && ctrl && !shift) {
|
if (click && ctrl && !shift) {
|
||||||
SelectRow(row,true,!IsInSelection(row,0));
|
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
|
// Block select
|
||||||
if ((click && shift && !ctrl) || (hold)) {
|
if ((click && shift && !ctrl) || (holding)) {
|
||||||
if (lastRow != -1) {
|
if (lastRow != -1) {
|
||||||
// Set boundaries
|
// Set boundaries
|
||||||
int i1 = row;
|
int i1 = row;
|
||||||
|
@ -462,15 +482,9 @@ void BaseGrid::OnMouseEvent(wxMouseEvent &event) {
|
||||||
notFirst = true;
|
notFirst = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal click
|
|
||||||
if (click && !shift && !ctrl && !alt) {
|
|
||||||
editBox->SetToLine(row);
|
|
||||||
parentFrame->SetSelectionFlag(validRow);
|
|
||||||
SelectRow(row,false);
|
|
||||||
lastRow = row;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,6 +62,7 @@ private:
|
||||||
int colWidth[16];
|
int colWidth[16];
|
||||||
int yPos;
|
int yPos;
|
||||||
int lastRow;
|
int lastRow;
|
||||||
|
bool holding;
|
||||||
wxFont font;
|
wxFont font;
|
||||||
wxScrollBar *scrollBar;
|
wxScrollBar *scrollBar;
|
||||||
wxBitmap *bmp;
|
wxBitmap *bmp;
|
||||||
|
|
Loading…
Reference in a new issue