mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
New rotation system (see forum thread).
Major changes: - when rotating, the top left corner of the rectangle stays in place. - ValueViewers get a dc that is pre-rotated/translated for them, i.e. (0,0) is the top-left of the viewer (with ValueViewer::getRotation). - moved 'angle' from individual Styles to the Style base class. - any rotation angle is now possible. angle is still an int for now. This warrants a version bump git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@782 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -210,15 +210,19 @@ void DataEditor::onLeftDown(wxMouseEvent& ev) {
|
||||
}
|
||||
void DataEditor::onLeftUp(wxMouseEvent& ev) {
|
||||
if (HasCapture()) ReleaseMouse();
|
||||
RealPoint pos = mousePoint(ev);
|
||||
if (current_editor && current_viewer && current_viewer->containsPoint(pos)) {
|
||||
current_editor->onLeftUp(pos, ev);
|
||||
if (current_editor && current_viewer) {
|
||||
RealPoint pos = mousePoint(ev, *current_viewer);
|
||||
if (current_viewer->containsPoint(pos)) {
|
||||
current_editor->onLeftUp(pos, ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
void DataEditor::onLeftDClick(wxMouseEvent& ev) {
|
||||
RealPoint pos = mousePoint(ev);
|
||||
if (current_editor && current_viewer && current_viewer->containsPoint(pos)) {
|
||||
current_editor->onLeftDClick(pos, ev);
|
||||
if (current_editor && current_viewer) {
|
||||
RealPoint pos = mousePoint(ev, *current_viewer);
|
||||
if (current_viewer->containsPoint(pos)) {
|
||||
current_editor->onLeftDClick(pos, ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
void DataEditor::onRightDown(wxMouseEvent& ev) {
|
||||
@@ -227,22 +231,25 @@ void DataEditor::onRightDown(wxMouseEvent& ev) {
|
||||
selectField(ev, &ValueEditor::onRightDown);
|
||||
}
|
||||
void DataEditor::onMouseWheel(wxMouseEvent& ev) {
|
||||
RealPoint pos = mousePoint(ev);
|
||||
if (current_editor && current_viewer && current_viewer->containsPoint(pos)) {
|
||||
if (current_editor->onMouseWheel(pos, ev)) return;
|
||||
if (current_editor && current_viewer) {
|
||||
RealPoint pos = mousePoint(ev, *current_viewer);
|
||||
if (current_viewer->containsPoint(pos)) {
|
||||
if (current_editor->onMouseWheel(pos, ev)) return;
|
||||
}
|
||||
}
|
||||
ev.Skip();
|
||||
}
|
||||
|
||||
void DataEditor::onMotion(wxMouseEvent& ev) {
|
||||
RealPoint pos = mousePoint(ev);
|
||||
if (current_editor && ev.LeftIsDown()) {
|
||||
if (current_editor && current_viewer) {
|
||||
RealPoint pos = mousePoint(ev, *current_viewer);
|
||||
current_editor->onMotion(pos, ev);
|
||||
}
|
||||
if (!HasCapture()) {
|
||||
// find editor under mouse
|
||||
ValueViewer* new_hovered_viewer = nullptr;
|
||||
FOR_EACH_REVERSE(v,viewers) { // find high z index fields first
|
||||
RealPoint pos = mousePoint(ev, *v);
|
||||
if (v->containsPoint(pos) && v->getField()->editable) {
|
||||
new_hovered_viewer = v.get();
|
||||
break;
|
||||
@@ -250,6 +257,7 @@ void DataEditor::onMotion(wxMouseEvent& ev) {
|
||||
}
|
||||
if (hovered_viewer && hovered_viewer != new_hovered_viewer) {
|
||||
ValueEditor* e = hovered_viewer->getEditor();
|
||||
RealPoint pos = mousePoint(ev, *hovered_viewer);
|
||||
if (e) e->onMouseLeave(pos, ev);
|
||||
}
|
||||
hovered_viewer = new_hovered_viewer;
|
||||
@@ -257,6 +265,7 @@ void DataEditor::onMotion(wxMouseEvent& ev) {
|
||||
wxFrame* frame = dynamic_cast<wxFrame*>( wxGetTopLevelParent(this) );
|
||||
if (hovered_viewer) {
|
||||
ValueEditor* e = hovered_viewer->getEditor();
|
||||
RealPoint pos = mousePoint(ev, *hovered_viewer);
|
||||
wxCursor c;
|
||||
if (e) c = e->cursor(pos);
|
||||
if (c.Ok()) SetCursor(c);
|
||||
@@ -274,7 +283,7 @@ void DataEditor::onMouseLeave(wxMouseEvent& ev) {
|
||||
// on mouse leave for editor
|
||||
if (hovered_viewer) {
|
||||
ValueEditor* e = hovered_viewer->getEditor();
|
||||
if (e) e->onMouseLeave(mousePoint(ev), ev);
|
||||
if (e) e->onMouseLeave(mousePoint(ev,*hovered_viewer), ev);
|
||||
hovered_viewer = nullptr;
|
||||
}
|
||||
// clear status text
|
||||
@@ -283,18 +292,20 @@ void DataEditor::onMouseLeave(wxMouseEvent& ev) {
|
||||
}
|
||||
|
||||
void DataEditor::selectField(wxMouseEvent& ev, bool (ValueEditor::*event)(const RealPoint&, wxMouseEvent&)) {
|
||||
RealPoint pos = mousePoint(ev);
|
||||
// change viewer/editor
|
||||
ValueEditor* old_editor = current_editor;
|
||||
selectFieldNoEvents(pos);
|
||||
selectFieldNoEvents(ev);
|
||||
if (old_editor != current_editor) {
|
||||
// selection has changed, send focus events
|
||||
if (old_editor) old_editor->onLoseFocus();
|
||||
if (current_editor) current_editor->onFocus();
|
||||
}
|
||||
// pass event
|
||||
if (current_editor && current_viewer && current_viewer->containsPoint(pos)) {
|
||||
(current_editor->*event)(pos, ev);
|
||||
if (current_editor && current_viewer) {
|
||||
RealPoint pos = mousePoint(ev, *current_viewer);
|
||||
if (current_viewer->containsPoint(pos)) {
|
||||
(current_editor->*event)(pos, ev);
|
||||
}
|
||||
}
|
||||
// refresh?
|
||||
if (old_editor != current_editor) {
|
||||
@@ -303,10 +314,10 @@ void DataEditor::selectField(wxMouseEvent& ev, bool (ValueEditor::*event)(const
|
||||
onChange();
|
||||
}
|
||||
}
|
||||
void DataEditor::selectFieldNoEvents(const RealPoint& p) {
|
||||
void DataEditor::selectFieldNoEvents(const wxMouseEvent& ev) {
|
||||
FOR_EACH_EDITOR_REVERSE { // find high z index fields first
|
||||
if (v->getField()->editable && (v->containsPoint(p) ||
|
||||
(nativeLook() && p.y >= v->getStyle()->top && p.y < v->getStyle()->bottom) )) {
|
||||
if (v->getField()->editable && (v->containsPoint(mousePoint(ev,*v)) ||
|
||||
(nativeLook() && ev.GetY() >= v->getStyle()->top && ev.GetY() < v->getStyle()->bottom) )) {
|
||||
current_viewer = v.get();
|
||||
current_editor = e;
|
||||
return;
|
||||
@@ -314,8 +325,10 @@ void DataEditor::selectFieldNoEvents(const RealPoint& p) {
|
||||
}
|
||||
}
|
||||
|
||||
RealPoint DataEditor::mousePoint(const wxMouseEvent& ev) {
|
||||
return getRotation().trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
RealPoint DataEditor::mousePoint(const wxMouseEvent& ev, const ValueViewer& viewer) {
|
||||
Rotation rot = getRotation();
|
||||
Rotater r(rot,viewer.getRotation());
|
||||
return rot.trInv(RealPoint(ev.GetX(), ev.GetY()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Keyboard events
|
||||
|
||||
@@ -118,9 +118,9 @@ class DataEditor : public CardViewer {
|
||||
/** Sends an event to the event function of the current viewer */
|
||||
void selectField(wxMouseEvent& ev, bool (ValueEditor::*event)(const RealPoint&, wxMouseEvent&));
|
||||
// selectField, but don't send events
|
||||
void selectFieldNoEvents(const RealPoint& pos);
|
||||
void selectFieldNoEvents(const wxMouseEvent&);
|
||||
/// Convert mouse coordinates to internal coordinates
|
||||
RealPoint mousePoint(const wxMouseEvent&);
|
||||
RealPoint mousePoint(const wxMouseEvent&, const ValueViewer& viewer);
|
||||
|
||||
// Create tab index ordering of the (editable) viewers
|
||||
void createTabIndex();
|
||||
|
||||
@@ -38,7 +38,7 @@ wxSize CardViewer::DoGetBestSize() const {
|
||||
void CardViewer::redraw(const ValueViewer& v) {
|
||||
if (drawing) return;
|
||||
up_to_date = false;
|
||||
RefreshRect(getRotation().tr(v.boundingBox()), false);
|
||||
RefreshRect(getRotation().trRectToBB(v.boundingBox()), false);
|
||||
}
|
||||
|
||||
void CardViewer::onChange() {
|
||||
@@ -98,7 +98,7 @@ bool CardViewer::shouldDraw(const ValueViewer& v) const {
|
||||
// int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL);
|
||||
// wxRegion clip = GetUpdateRegion();
|
||||
// clip.Offset(dx, dy);
|
||||
return GetUpdateRegion().Contains(getRotation().tr(v.boundingBox().toRect()).toRect()) != wxOutRegion;
|
||||
return GetUpdateRegion().Contains(getRotation().trRectToBB(v.boundingBox().toRect()).toRect()) != wxOutRegion;
|
||||
}
|
||||
|
||||
// helper class for overdrawDC()
|
||||
@@ -133,7 +133,7 @@ Rotation CardViewer::getRotation() const {
|
||||
if (!stylesheet) stylesheet = set->stylesheet;
|
||||
StyleSheetSettings& ss = settings.stylesheetSettingsFor(*stylesheet);
|
||||
int dx = GetScrollPos(wxHORIZONTAL), dy = GetScrollPos(wxVERTICAL);
|
||||
return Rotation(ss.card_angle(), stylesheet->getCardRect().move(-dx,-dy,0,0), ss.card_zoom(), 1.0, true);
|
||||
return Rotation(ss.card_angle(), stylesheet->getCardRect().move(-dx,-dy,0,0), ss.card_zoom(), 1.0, ROTATION_ATTACH_TOP_LEFT);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Event table
|
||||
|
||||
@@ -39,14 +39,14 @@ void NativeLookEditor::drawViewer(RotatedDC& dc, ValueViewer& v) {
|
||||
Style& s = *v.getStyle();
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
dc.DrawRectangle(s.getRect().grow(1));
|
||||
dc.DrawRectangle(s.getInternalRect().grow(1));
|
||||
// draw label
|
||||
dc.SetFont(*wxNORMAL_FONT);
|
||||
// TODO : tr using stylesheet or using game?
|
||||
dc.DrawText(tr(*set->game, s.fieldP->name, capitalize_sentence(s.fieldP->name)),
|
||||
RealPoint(margin_left, s.top + 1));
|
||||
RealPoint(margin_left - s.left, 1));
|
||||
// draw 3D border
|
||||
draw_control_border(this, dc.getDC(), dc.tr(RealRect(s.left - 1, s.top - 1, s.width + 2, s.height + 2)));
|
||||
draw_control_border(this, dc.getDC(), dc.trRectStraight(s.getInternalRect().grow(1)));
|
||||
}
|
||||
// draw viewer
|
||||
v.draw(dc);
|
||||
@@ -152,10 +152,10 @@ void NativeLookEditor::onScroll(wxScrollWinEvent& ev) {
|
||||
}
|
||||
void NativeLookEditor::onMouseWheel(wxMouseEvent& ev) {
|
||||
// send scroll event to field under cursor
|
||||
RealPoint pos = mousePoint(ev);
|
||||
FOR_EACH_EDITOR_REVERSE { // find high z index fields first
|
||||
RealPoint pos = mousePoint(ev, *v);
|
||||
if (v->containsPoint(pos) && v->getField()->editable) {
|
||||
bool scrolled = e->onMouseWheel(mousePoint(ev), ev);
|
||||
bool scrolled = e->onMouseWheel(pos, ev);
|
||||
if (scrolled) return;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,9 @@ void DropDownList::show(bool in_place, wxPoint pos, RealRect* rect) {
|
||||
int parent_height = 0;
|
||||
if (!in_place && viewer) {
|
||||
// Position the drop down list below the editor control (based on the style)
|
||||
RealRect r = viewer->viewer.getRotation().trNoNeg(rect ? *rect : viewer->getStyle()->getRect());
|
||||
Rotation rot = viewer->viewer.getRotation();
|
||||
Rotater rr(rot, viewer->getRotation());
|
||||
RealRect r = rot.trRectToBB(rect ? *rect : rot.getInternalRect());
|
||||
if (viewer->viewer.nativeLook()) {
|
||||
pos = RealPoint(r.x - 3, r.y - 3);
|
||||
size.width = max(size.width, r.width + 6);
|
||||
@@ -233,7 +235,8 @@ void DropDownList::redrawArrowOnParent() {
|
||||
CardEditor& editor = static_cast<CardEditor&>(viewer->viewer);
|
||||
shared_ptr<RotatedDC> dcP = editor.overdrawDC();
|
||||
RotatedDC& dc = *dcP;
|
||||
draw_drop_down_arrow(&editor, dc.getDC(), dc.tr(viewer->getStyle()->getRect().grow(1)), IsShown());
|
||||
Rotater r(dc, viewer->getRotation());
|
||||
draw_drop_down_arrow(&editor, dc.getDC(), dc.trRectToBB(dc.getInternalRect().grow(1)), IsShown());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ void ImageSliceSelector::draw(DC& dc) {
|
||||
dc.DestroyClippingRegion();
|
||||
}
|
||||
// bitmap : unselected
|
||||
dc.DrawBitmap(bitmap_no_sel, border, border);
|
||||
dc.DrawBitmap(bitmap_no_sel, border, border, true);
|
||||
// draw selected part ungreyed over it
|
||||
{
|
||||
wxMemoryDC mdc;
|
||||
|
||||
@@ -57,7 +57,8 @@ void SymbolSelectEditor::draw(DC& dc) {
|
||||
// draw selection rectangle
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.SetPen(wxPen(*wxCYAN,1,wxDOT));
|
||||
RealRect rect = control.rotation.tr(RealRect(selection_rect_a, RealSize(selection_rect_b - selection_rect_a)));
|
||||
//% TODO: use RotatedDC?
|
||||
RealRect rect = control.rotation.trRectToBB(RealRect(selection_rect_a, RealSize(selection_rect_b - selection_rect_a)));
|
||||
dc.DrawRectangle(rect);
|
||||
} else {
|
||||
// draw handles
|
||||
|
||||
@@ -299,7 +299,7 @@ void ChoiceValueEditor::onLoseFocus() {
|
||||
void ChoiceValueEditor::draw(RotatedDC& dc) {
|
||||
ChoiceValueViewer::draw(dc);
|
||||
if (nativeLook()) {
|
||||
draw_drop_down_arrow(&editor(), dc.getDC(), dc.tr(style().getRect().grow(1)), drop_down->IsShown());
|
||||
draw_drop_down_arrow(&editor(), dc.getDC(), dc.trRectStraight(style().getInternalRect().grow(1)), drop_down->IsShown());
|
||||
}
|
||||
}
|
||||
void ChoiceValueEditor::determineSize(bool) {
|
||||
|
||||
@@ -141,7 +141,7 @@ void ColorValueEditor::onLoseFocus() {
|
||||
void ColorValueEditor::draw(RotatedDC& dc) {
|
||||
ColorValueViewer::draw(dc);
|
||||
if (nativeLook()) {
|
||||
draw_drop_down_arrow(&editor(), dc.getDC(), dc.tr(style().getRect().grow(1)), drop_down->IsShown());
|
||||
draw_drop_down_arrow(&editor(), dc.getDC(), dc.trRectStraight(dc.getInternalRect().grow(1)), drop_down->IsShown());
|
||||
}
|
||||
}
|
||||
void ColorValueEditor::determineSize(bool) {
|
||||
|
||||
@@ -25,7 +25,7 @@ void SymbolValueEditor::draw(RotatedDC& dc) {
|
||||
dc.SetFont(wxFont(10,wxSWISS,wxNORMAL,wxNORMAL));
|
||||
dc.SetTextForeground(*wxBLACK);
|
||||
RealSize text_size = dc.GetTextExtent(_("double click to edit symbol"));
|
||||
dc.DrawText(_("double click to edit symbol"), align_in_rect(ALIGN_MIDDLE_CENTER, text_size, style().getRect()));
|
||||
dc.DrawText(_("double click to edit symbol"), align_in_rect(ALIGN_MIDDLE_CENTER, text_size, style().getInternalRect()));
|
||||
}
|
||||
if (nativeLook()) {
|
||||
// draw editor buttons
|
||||
@@ -38,8 +38,8 @@ void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text
|
||||
bool down = button == button_down;
|
||||
double height = style().height;
|
||||
double width = style().height + 2;
|
||||
double x = style().right - width - (width + 1) * button;
|
||||
double y = style().top;
|
||||
double x = style().width - width - (width + 1) * button;
|
||||
double y = 0;
|
||||
// draw button
|
||||
dc.SetPen(*wxTRANSPARENT_PEN);
|
||||
dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||
@@ -60,8 +60,8 @@ void SymbolValueEditor::drawButton(RotatedDC& dc, int button, const String& text
|
||||
}
|
||||
|
||||
int SymbolValueEditor::findButton(const RealPoint& pos) {
|
||||
if (pos.y < style().top || pos.y >= style().bottom) return -1;
|
||||
int button = (int)floor( (style().right - pos.x) / (style().height + 3) );
|
||||
if (pos.y < 0 || pos.y >= style().height) return -1;
|
||||
int button = (int)floor( (style().width - pos.x) / (style().height + 3) );
|
||||
if (button >= 0 && button <= 1) return button;
|
||||
return -1;
|
||||
}
|
||||
|
||||
+23
-24
@@ -333,15 +333,14 @@ TextValueEditor::~TextValueEditor() {
|
||||
|
||||
bool TextValueEditor::onLeftDown(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
select_words = false;
|
||||
RealPoint pos2 = style().getRotation().trInv(pos);
|
||||
// on word list dropdown button?
|
||||
WordListPosP wl_pos = findWordList(pos2);
|
||||
WordListPosP wl_pos = findWordList(pos);
|
||||
if (wl_pos) {
|
||||
wordListDropDown(wl_pos);
|
||||
} else {
|
||||
// no, select text
|
||||
selecting = true;
|
||||
moveSelection(TYPE_INDEX, v.indexAt(pos2), !ev.ShiftDown(), MOVE_MID);
|
||||
moveSelection(TYPE_INDEX, v.indexAt(pos), !ev.ShiftDown(), MOVE_MID);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -354,7 +353,7 @@ bool TextValueEditor::onLeftUp(const RealPoint& pos, wxMouseEvent&) {
|
||||
bool TextValueEditor::onMotion(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
if (dropDownShown()) return false;
|
||||
if (ev.LeftIsDown() && selecting) {
|
||||
size_t index = v.indexAt(style().getRotation().trInv(pos));
|
||||
size_t index = v.indexAt(pos);
|
||||
if (select_words) {
|
||||
// on the left, swap start and end
|
||||
bool left = selection_end_i < selection_start_i;
|
||||
@@ -385,7 +384,7 @@ bool TextValueEditor::onLeftDClick(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
if (dropDownShown()) return false;
|
||||
select_words = true;
|
||||
selecting = true;
|
||||
size_t index = v.indexAt(style().getRotation().trInv(pos));
|
||||
size_t index = v.indexAt(pos);
|
||||
moveSelection(TYPE_INDEX, prevWordBoundary(index), true, MOVE_MID);
|
||||
moveSelection(TYPE_INDEX, nextWordBoundary(index), false, MOVE_MID);
|
||||
return true;
|
||||
@@ -393,7 +392,7 @@ bool TextValueEditor::onLeftDClick(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
|
||||
bool TextValueEditor::onRightDown(const RealPoint& pos, wxMouseEvent& ev) {
|
||||
if (dropDownShown()) return false;
|
||||
size_t index = v.indexAt(style().getRotation().trInv(pos));
|
||||
size_t index = v.indexAt(pos);
|
||||
if (index < min(selection_start_i, selection_end_i) ||
|
||||
index > max(selection_start_i, selection_end_i)) {
|
||||
// only move cursor when outside selection
|
||||
@@ -587,9 +586,10 @@ void TextValueEditor::redrawSelection(size_t old_selection_start_i, size_t old_s
|
||||
// Move selection
|
||||
shared_ptr<RotatedDC> dcP = editor().overdrawDC();
|
||||
RotatedDC& dc = *dcP;
|
||||
Rotater r(dc, getRotation());
|
||||
if (nativeLook()) {
|
||||
// clip the dc to the region of this control
|
||||
dc.SetClippingRegion(style().getRect());
|
||||
dc.SetClippingRegion(style().getInternalRect());
|
||||
}
|
||||
// clear old selection by drawing it again
|
||||
if (!old_drop_down_shown) {
|
||||
@@ -622,8 +622,7 @@ void TextValueEditor::redrawSelection(size_t old_selection_start_i, size_t old_s
|
||||
wxCursor rotated_ibeam;
|
||||
|
||||
wxCursor TextValueEditor::cursor(const RealPoint& pos) const {
|
||||
RealPoint pos2 = style().getRotation().trInv(pos);
|
||||
WordListPosP p = findWordList(pos2);
|
||||
WordListPosP p = findWordList(pos);
|
||||
if (p) {
|
||||
if (hovered_words != p.get()) {
|
||||
hovered_words = p.get();
|
||||
@@ -631,12 +630,13 @@ wxCursor TextValueEditor::cursor(const RealPoint& pos) const {
|
||||
}
|
||||
return wxCursor();
|
||||
} else {
|
||||
p = findWordListBody(pos2);
|
||||
p = findWordListBody(pos);
|
||||
if (hovered_words != p.get()) {
|
||||
hovered_words = p.get();
|
||||
const_cast<TextValueEditor*>(this)->redrawWordListIndicators();
|
||||
}
|
||||
if (viewer.getRotation().sideways() ^ style().getRotation().sideways()) { // 90 or 270 degrees
|
||||
int angle = viewer.getRotation().getAngle() + style().angle;
|
||||
if (sideways(angle)) { // 90 or 270 degrees
|
||||
if (!rotated_ibeam.Ok()) {
|
||||
rotated_ibeam = wxCursor(load_resource_cursor(_("rot_text")));
|
||||
}
|
||||
@@ -648,17 +648,16 @@ wxCursor TextValueEditor::cursor(const RealPoint& pos) const {
|
||||
}
|
||||
|
||||
bool TextValueEditor::containsPoint(const RealPoint& pos) const {
|
||||
if (TextValueViewer::containsPoint(pos)) return true;
|
||||
RealPoint pos2(pos.x * style().getStretch(), pos.y);
|
||||
if (TextValueViewer::containsPoint(pos2)) return true;
|
||||
if (word_lists.empty()) return false;
|
||||
RealPoint pos2 = style().getRotation().trInv(pos);
|
||||
return findWordList(pos2);
|
||||
return findWordList(pos);
|
||||
}
|
||||
RealRect TextValueEditor::boundingBox() const {
|
||||
if (word_lists.empty()) return ValueViewer::boundingBox();
|
||||
RealRect r = style().getRect().grow(1);
|
||||
Rotation rot = style().getRotation();
|
||||
RealRect r = style().getInternalRect().grow(1);
|
||||
FOR_EACH_CONST(wl, word_lists) {
|
||||
r.width = max(r.width, rot.tr(wl->rect).right() + 9);
|
||||
r.width = max(r.width, wl->rect.right() + 9);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -794,7 +793,7 @@ void TextValueEditor::showCaret() {
|
||||
}
|
||||
// Rotation
|
||||
Rotation rot(viewer.getRotation());
|
||||
Rotater rot2(rot, style().getRotation());
|
||||
Rotater rot2(rot, getRotation());
|
||||
// The caret
|
||||
wxCaret* caret = editor().GetCaret();
|
||||
// cursor rectangle
|
||||
@@ -841,7 +840,8 @@ void TextValueEditor::showCaret() {
|
||||
}
|
||||
}
|
||||
// rotate
|
||||
cursor = rot.tr(cursor);
|
||||
// TODO: handle rotated cursor
|
||||
cursor = rot.trRectToBB(cursor);
|
||||
// set size
|
||||
wxSize size = cursor.size();
|
||||
if (size.GetWidth() == 0) size.SetWidth (1);
|
||||
@@ -1154,9 +1154,10 @@ void TextValueEditor::determineSize(bool force_fit) {
|
||||
if (scrollbar) {
|
||||
// muliline, determine scrollbar size
|
||||
Rotation rot = viewer.getRotation();
|
||||
Rotater r(rot, getRotation());
|
||||
if (!force_fit) style().height = 100;
|
||||
int sbw = wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
||||
RealPoint pos = rot.tr(style().getPos());
|
||||
RealPoint pos = rot.tr(RealPoint(0,0));
|
||||
scrollbar->SetSize(
|
||||
(int)(pos.x + rot.trX(style().width) + 1 - sbw),
|
||||
(int)pos.y - 1,
|
||||
@@ -1275,7 +1276,6 @@ void TextValueEditor::findWordLists() {
|
||||
|
||||
void TextValueEditor::clearWordListIndicators(RotatedDC& dc) {
|
||||
if (word_lists.empty()) return;
|
||||
Rotater rot(dc, style().getRotation());
|
||||
bool current = isCurrent();
|
||||
FOR_EACH(wl, word_lists) {
|
||||
if (current && drop_down && drop_down->IsShown() && drop_down->getPos() == wl) {
|
||||
@@ -1287,7 +1287,7 @@ void TextValueEditor::clearWordListIndicators(RotatedDC& dc) {
|
||||
}
|
||||
// restore background
|
||||
if (wl->behind.Ok()) {
|
||||
dc.DrawPreRotatedBitmap(wl->behind, wl->rect.topRight() + RealSize(0,-1));
|
||||
dc.DrawPreRotatedBitmap(wl->behind, RealRect(wl->rect.right(), wl->rect.y - 1, 10, wl->rect.height+3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1298,7 +1298,6 @@ void TextValueEditor::redrawWordListIndicators(bool toggling_dropdown) {
|
||||
|
||||
void TextValueEditor::drawWordListIndicators(RotatedDC& dc, bool redrawing) {
|
||||
if (word_lists.empty()) return;
|
||||
Rotater rot(dc, style().getRotation());
|
||||
bool current = isCurrent();
|
||||
// Draw lines around fields
|
||||
FOR_EACH(wl, word_lists) {
|
||||
@@ -1410,7 +1409,7 @@ bool TextValueEditor::wordListDropDown(const WordListPosP& wl) {
|
||||
} else {
|
||||
drop_down.reset(new DropDownWordList(&editor(), false, *this, wl, wl->word_list));
|
||||
}
|
||||
RealRect rect = style().getRotation().tr(wl->rect).move(0, -1, 0, 2);
|
||||
RealRect rect = wl->rect.grow(1);
|
||||
drop_down->show(false, wxPoint(0,0), &rect);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user