draw lines with drawLines

This commit is contained in:
gazer 2016-01-29 10:38:26 +03:00
parent bd5d275003
commit de42d281b6
2 changed files with 25 additions and 38 deletions

View File

@ -960,12 +960,10 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
// draw caret // draw caret
Rect caretRc = caretRect(); Rect caretRc = caretRect();
if (caretRc.intersects(_clientRect)) { if (caretRc.intersects(_clientRect)) {
Rect rc1 = caretRc;
rc1.right = rc1.left + 1;
caretRc.left++; caretRc.left++;
if (_replaceMode) if (_replaceMode)
buf.fillRect(caretRc, _caretColorReplace); buf.fillRect(caretRc, _caretColorReplace);
buf.fillRect(rc1, _caretColor); buf.drawLine(Point(caretRc.left, caretRc.bottom), Point(caretRc.left, caretRc.top), _caretColor);
} }
} }
} }

View File

@ -1407,11 +1407,6 @@ class StringGridWidget : StringGridWidgetBase {
/// draw cell background /// draw cell background
protected override void drawHeaderCellBackground(DrawBuf buf, Rect rc, int c, int r) { protected override void drawHeaderCellBackground(DrawBuf buf, Rect rc, int c, int r) {
Rect vborder = rc;
Rect hborder = rc;
vborder.left = vborder.right - 1;
hborder.top = hborder.bottom - 1;
hborder.right--;
bool selectedCol = (c == col) && !_rowSelect; bool selectedCol = (c == col) && !_rowSelect;
bool selectedRow = r == row; bool selectedRow = r == row;
bool selectedCell = selectedCol && selectedRow; bool selectedCell = selectedCol && selectedRow;
@ -1426,8 +1421,30 @@ class StringGridWidget : StringGridWidgetBase {
cl = _cellHeaderSelectedBackgroundColor; cl = _cellHeaderSelectedBackgroundColor;
} }
buf.fillRect(rc, cl); buf.fillRect(rc, cl);
buf.fillRect(vborder, _cellHeaderBorderColor); buf.drawLine(Point(rc.right, rc.bottom), Point(rc.right, rc.top), _cellHeaderBorderColor); // vertical
buf.fillRect(hborder, _cellHeaderBorderColor); buf.drawLine(Point(rc.left, rc.bottom), Point(rc.right - 1, rc.bottom), _cellHeaderBorderColor); // horizontal
}
/// draw cell background
protected override void drawCellBackground(DrawBuf buf, Rect rc, int c, int r) {
bool selectedCol = c == col;
bool selectedRow = r == row;
bool selectedCell = selectedCol && selectedRow;
if (_rowSelect && selectedRow)
selectedCell = true;
// normal cell background
if (c < fixedCols || r < fixedRows) {
// fixed cell background
buf.fillRect(rc, _fixedCellBackgroundColor);
}
buf.drawLine(Point(rc.left, rc.bottom + 1), Point(rc.left, rc.top), _cellBorderColor); // vertical
buf.drawLine(Point(rc.left, rc.bottom), Point(rc.right - 1, rc.bottom), _cellBorderColor); // horizontal
if (selectedCell) {
if (_rowSelect)
buf.drawFrame(rc, _selectionColorRowSelect, Rect(0,1,0,1), _cellBorderColor);
else
buf.drawFrame(rc, _selectionColor, Rect(1,1,1,1), _cellBorderColor);
}
} }
@ -1442,34 +1459,6 @@ class StringGridWidget : StringGridWidgetBase {
_cellHeaderSelectedBackgroundColor = style.customColor("grid_cell_background_header_selected", 0x80FFC040); _cellHeaderSelectedBackgroundColor = style.customColor("grid_cell_background_header_selected", 0x80FFC040);
super.onThemeChanged(); super.onThemeChanged();
} }
/// draw cell background
protected override void drawCellBackground(DrawBuf buf, Rect rc, int c, int r) {
Rect vborder = rc;
Rect hborder = rc;
vborder.left = vborder.right - 1;
hborder.top = hborder.bottom - 1;
hborder.right--;
bool selectedCol = c == col;
bool selectedRow = r == row;
bool selectedCell = selectedCol && selectedRow;
if (_rowSelect && selectedRow)
selectedCell = true;
// normal cell background
if (c < fixedCols || r < fixedRows) {
// fixed cell background
buf.fillRect(rc, _fixedCellBackgroundColor);
}
buf.fillRect(vborder, _cellBorderColor);
buf.fillRect(hborder, _cellBorderColor);
if (selectedCell) {
if (_rowSelect)
buf.drawFrame(rc, _selectionColorRowSelect, Rect(0,1,0,1), _cellBorderColor);
else
buf.drawFrame(rc, _selectionColor, Rect(1,1,1,1), _cellBorderColor);
}
}
} }
import dlangui.widgets.metadata; import dlangui.widgets.metadata;