aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2016-05-03 12:09:33 +1000
committerNeil <nyamatongwe@gmail.com>2016-05-03 12:09:33 +1000
commitc6cbb4d76afafbd4aa496fee7e3f8f8add1a5527 (patch)
tree4e940be9abcd520b26aec93bbc0d1b130f10df85
parentb11991abf6f1c8f5dbe864c6c8c980b73acf9a79 (diff)
downloadscintilla-mirror-c6cbb4d76afafbd4aa496fee7e3f8f8add1a5527.tar.gz
Avoid use of const_cast when retrieving window positions.
-rw-r--r--gtk/ScintillaGTK.cxx2
-rw-r--r--src/Editor.cxx2
-rw-r--r--win32/PlatWin.cxx9
3 files changed, 7 insertions, 6 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 7e2ba25cd..14b861348 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -1174,7 +1174,7 @@ void ScintillaGTK::FullPaint() {
}
PRectangle ScintillaGTK::GetClientRectangle() const {
- Window &win = const_cast<Window &>(wMain);
+ Window win = wMain;
PRectangle rc = win.GetClientPosition();
if (verticalScrollBarVisible)
rc.right -= verticalScrollBarWidth;
diff --git a/src/Editor.cxx b/src/Editor.cxx
index eddc0e623..9a41bab09 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -303,7 +303,7 @@ int Editor::TopLineOfMain() const {
}
PRectangle Editor::GetClientRectangle() const {
- Window &win = const_cast<Window &>(wMain);
+ Window win = wMain;
return win.GetClientPosition();
}
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 26b7adb3f..b9926a366 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -2582,6 +2582,9 @@ void ListBoxX::StartResize(WPARAM hitCode) {
}
LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const {
+ Window win = *this; // Copy HWND to avoid const problems
+ const PRectangle rc = win.GetPosition();
+
LRESULT hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam);
// There is an apparent bug in the DefWindowProc hit test code whereby it will
// return HTTOPXXX if the window in question is shorter than the default
@@ -2589,7 +2592,6 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const {
// the frame, so workaround that here
if (hit >= HTTOP && hit <= HTTOPRIGHT) {
int minHeight = GetSystemMetrics(SM_CYMINTRACK);
- PRectangle rc = const_cast<ListBoxX*>(this)->GetPosition();
int yPos = GET_Y_LPARAM(lParam);
if ((rc.Height() < minHeight) && (yPos > ((rc.top + rc.bottom)/2))) {
hit += HTBOTTOM - HTTOP;
@@ -2607,7 +2609,6 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const {
case HTTOP:
case HTTOPRIGHT: {
- PRectangle rc = const_cast<ListBoxX*>(this)->GetPosition();
// Valid only if caret below list
if (location.y < rc.top)
hit = HTERROR;
@@ -2616,7 +2617,6 @@ LRESULT ListBoxX::NcHitTest(WPARAM wParam, LPARAM lParam) const {
case HTBOTTOM:
case HTBOTTOMRIGHT: {
- PRectangle rc = const_cast<ListBoxX*>(this)->GetPosition();
// Valid only if caret above list
if (rc.bottom <= location.y)
hit = HTERROR;
@@ -2635,7 +2635,8 @@ void ListBoxX::OnDoubleClick() {
}
POINT ListBoxX::GetClientExtent() const {
- PRectangle rc = const_cast<ListBoxX*>(this)->GetClientPosition();
+ Window win = *this; // Copy HWND to avoid const problems
+ const PRectangle rc = win.GetPosition();
POINT ret;
ret.x = static_cast<LONG>(rc.Width());
ret.y = static_cast<LONG>(rc.Height());