mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
fixed flickering cursor in text control
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@146 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -26,15 +26,16 @@ Rotation TextCtrl::getRotation() const {
|
||||
}
|
||||
|
||||
void TextCtrl::draw(DC& dc) {
|
||||
if (!viewers.empty()) {
|
||||
wxSize cs = GetClientSize();
|
||||
Style& style = *viewers.front()->getStyle();
|
||||
style.width = cs.GetWidth() - 2;
|
||||
style.height = cs.GetHeight() - 2;
|
||||
}
|
||||
RotatedDC rdc(dc, getRotation(), false);
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||
DataViewer::draw(rdc, wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
}
|
||||
void TextCtrl::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
// draw background
|
||||
Style& s = *v.getStyle();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.DrawRectangle(s.getRect().grow(1));
|
||||
// draw viewer
|
||||
v.draw(dc);
|
||||
}
|
||||
@@ -49,6 +50,7 @@ void TextCtrl::setValue(String* value) {
|
||||
TextValueP value(new TextValue(field));
|
||||
// set stuff
|
||||
field->index = 0;
|
||||
field->multi_line = true;
|
||||
style->width = 100;
|
||||
style->height = 20;
|
||||
style->left = style->top = 1;
|
||||
@@ -95,12 +97,7 @@ void TextCtrl::onInit() {
|
||||
}
|
||||
|
||||
void TextCtrl::onSize(wxSizeEvent&) {
|
||||
if (!viewers.empty()) {
|
||||
wxSize cs = GetClientSize();
|
||||
Style& style = *viewers.front()->getStyle();
|
||||
style.width = cs.GetWidth() - 2;
|
||||
style.height = cs.GetHeight() - 2;
|
||||
}
|
||||
Refresh(false);
|
||||
}
|
||||
|
||||
BEGIN_EVENT_TABLE(TextCtrl, DataEditor)
|
||||
|
||||
+30
-22
@@ -78,8 +78,13 @@ void TextValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
if (ev.LeftIsDown()) {
|
||||
size_t index = v.indexAt(style().getRotation().trInv(pos));
|
||||
if (select_words) {
|
||||
// TODO: on the left, swap start and end
|
||||
moveSelection(TYPE_INDEX, index < selection_start_i ? prevWordBoundry(index) : nextWordBoundry(index), false, MOVE_MID);
|
||||
// on the left, swap start and end
|
||||
bool left = index < max(selection_start_i, selection_end_i);
|
||||
if (left != (selection_end_i < selection_start_i)) {
|
||||
swap(selection_start_i, selection_end_i);
|
||||
}
|
||||
// //if (left && selection_end_i < selection_start_i
|
||||
moveSelection(TYPE_INDEX, left ? prevWordBoundry(index) : nextWordBoundry(index), false, MOVE_MID);
|
||||
} else {
|
||||
moveSelection(TYPE_INDEX, index, false, MOVE_MID);
|
||||
}
|
||||
@@ -472,27 +477,30 @@ void TextValueEditor::moveSelection(IndexType t, size_t new_end, bool also_move_
|
||||
// Hide caret
|
||||
wxCaret* caret = editor().GetCaret();
|
||||
if (caret->IsVisible()) caret->Hide();
|
||||
// Move selection
|
||||
shared_ptr<DC> dc = editor().overdrawDC();
|
||||
RotatedDC rdc(*dc, viewer.getRotation(), false);
|
||||
if (nativeLook()) {
|
||||
// clip the dc to the region of this control
|
||||
rdc.SetClippingRegion(style().getRect());
|
||||
}
|
||||
// clear old selection by drawing it again
|
||||
v.drawSelection(rdc, style(), selection_start_i, selection_end_i);
|
||||
// move
|
||||
moveSelectionNoRedraw(t, new_end, also_move_start, dir);
|
||||
// scroll?
|
||||
// scrollWithCursor = true;
|
||||
// if (onMove()) {
|
||||
// // we can't redraw just the selection because we must scroll
|
||||
// updateScrollbar();
|
||||
// editor.refreshEditor();
|
||||
// } else {
|
||||
// draw new selection
|
||||
// Destroy the clientDC before reshowing the caret, prevent flicker on MSW
|
||||
{
|
||||
// Move selection
|
||||
shared_ptr<DC> dc = editor().overdrawDC();
|
||||
RotatedDC rdc(*dc, viewer.getRotation(), false);
|
||||
if (nativeLook()) {
|
||||
// clip the dc to the region of this control
|
||||
rdc.SetClippingRegion(style().getRect());
|
||||
}
|
||||
// clear old selection by drawing it again
|
||||
v.drawSelection(rdc, style(), selection_start_i, selection_end_i);
|
||||
// }
|
||||
// move
|
||||
moveSelectionNoRedraw(t, new_end, also_move_start, dir);
|
||||
// scroll?
|
||||
// scrollWithCursor = true;
|
||||
// if (onMove()) {
|
||||
// // we can't redraw just the selection because we must scroll
|
||||
// updateScrollbar();
|
||||
// editor.refreshEditor();
|
||||
// } else {
|
||||
// draw new selection
|
||||
v.drawSelection(rdc, style(), selection_start_i, selection_end_i);
|
||||
// }
|
||||
}
|
||||
showCaret();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user