From 26ff1bba505f093c4755e4afd6eade6c3d582b7f Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 3 May 2014 18:01:22 +1000 Subject: Turn on MSVC 'possible loss of data' warnings and add explicit casts. --- src/ScintillaBase.cxx | 55 ++++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 27 deletions(-) (limited to 'src/ScintillaBase.cxx') diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index e36d31389..9736c52f0 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -233,7 +233,7 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { int heightLB = ac.heightLBDefault; int widthLB = ac.widthLBDefault; if (pt.x >= rcClient.right - widthLB) { - HorizontalScrollTo(xOffset + pt.x - rcClient.right + widthLB); + HorizontalScrollTo(static_cast(xOffset + pt.x - rcClient.right + widthLB)); Redraw(); pt = PointMainCaret(); } @@ -248,17 +248,17 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { pt.y >= (rcPopupBounds.bottom + rcPopupBounds.top) / 2) { // and there is more room above. rcac.top = pt.y - heightLB; if (rcac.top < rcPopupBounds.top) { - heightLB -= (rcPopupBounds.top - rcac.top); + heightLB -= static_cast(rcPopupBounds.top - rcac.top); rcac.top = rcPopupBounds.top; } } else { rcac.top = pt.y + vs.lineHeight; } rcac.right = rcac.left + widthLB; - rcac.bottom = Platform::Minimum(rcac.top + heightLB, rcPopupBounds.bottom); + rcac.bottom = static_cast(Platform::Minimum(static_cast(rcac.top) + heightLB, static_cast(rcPopupBounds.bottom))); ac.lb->SetPositionRelative(rcac, wMain); ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font); - unsigned int aveCharWidth = vs.styles[STYLE_DEFAULT].aveCharWidth; + unsigned int aveCharWidth = static_cast(vs.styles[STYLE_DEFAULT].aveCharWidth); ac.lb->SetAverageCharWidth(aveCharWidth); ac.lb->SetDoubleClickAction(AutoCompleteDoubleClick, this); @@ -266,8 +266,8 @@ void ScintillaBase::AutoCompleteStart(int lenEntered, const char *list) { // Fiddle the position of the list so it is right next to the target and wide enough for all its strings PRectangle rcList = ac.lb->GetDesiredRect(); - int heightAlloced = rcList.bottom - rcList.top; - widthLB = Platform::Maximum(widthLB, rcList.right - rcList.left); + int heightAlloced = static_cast(rcList.bottom - rcList.top); + widthLB = Platform::Maximum(widthLB, static_cast(rcList.right - rcList.left)); if (maxListWidth != 0) widthLB = Platform::Minimum(widthLB, aveCharWidth*maxListWidth); // Make an allowance for large strings in list @@ -416,7 +416,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) { // If the call-tip window would be out of the client // space PRectangle rcClient = GetClientRectangle(); - int offset = vs.lineHeight + rc.Height(); + int offset = vs.lineHeight + static_cast(rc.Height()); // adjust so it displays above the text. if (rc.bottom > rcClient.bottom) { rc.top -= offset; @@ -749,7 +749,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara switch (iMessage) { case SCI_AUTOCSHOW: listType = 0; - AutoCompleteStart(wParam, reinterpret_cast(lParam)); + AutoCompleteStart(static_cast(wParam), reinterpret_cast(lParam)); break; case SCI_AUTOCCANCEL: @@ -813,21 +813,21 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.ignoreCase; case SCI_AUTOCSETCASEINSENSITIVEBEHAVIOUR: - ac.ignoreCaseBehaviour = wParam; + ac.ignoreCaseBehaviour = static_cast(wParam); break; case SCI_AUTOCGETCASEINSENSITIVEBEHAVIOUR: return ac.ignoreCaseBehaviour; case SCI_AUTOCSETORDER: - ac.autoSort = wParam; + ac.autoSort = static_cast(wParam); break; case SCI_AUTOCGETORDER: return ac.autoSort; case SCI_USERLISTSHOW: - listType = wParam; + listType = static_cast(wParam); AutoCompleteStart(0, reinterpret_cast(lParam)); break; @@ -846,25 +846,26 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.dropRestOfWord; case SCI_AUTOCSETMAXHEIGHT: - ac.lb->SetVisibleRows(wParam); + ac.lb->SetVisibleRows(static_cast(wParam)); break; case SCI_AUTOCGETMAXHEIGHT: return ac.lb->GetVisibleRows(); case SCI_AUTOCSETMAXWIDTH: - maxListWidth = wParam; + maxListWidth = static_cast(wParam); break; case SCI_AUTOCGETMAXWIDTH: return maxListWidth; case SCI_REGISTERIMAGE: - ac.lb->RegisterImage(wParam, reinterpret_cast(lParam)); + ac.lb->RegisterImage(static_cast(wParam), reinterpret_cast(lParam)); break; case SCI_REGISTERRGBAIMAGE: - ac.lb->RegisterRGBAImage(wParam, sizeRGBAImage.x, sizeRGBAImage.y, reinterpret_cast(lParam)); + ac.lb->RegisterRGBAImage(static_cast(wParam), static_cast(sizeRGBAImage.x), static_cast(sizeRGBAImage.y), + reinterpret_cast(lParam)); break; case SCI_CLEARREGISTEREDIMAGES: @@ -879,7 +880,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ac.GetTypesep(); case SCI_CALLTIPSHOW: - CallTipShow(LocationFromPosition(wParam), + CallTipShow(LocationFromPosition(static_cast(wParam)), reinterpret_cast(lParam)); break; @@ -894,32 +895,32 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara return ct.posStartCallTip; case SCI_CALLTIPSETPOSSTART: - ct.posStartCallTip = wParam; + ct.posStartCallTip = static_cast(wParam); break; case SCI_CALLTIPSETHLT: - ct.SetHighlight(wParam, lParam); + ct.SetHighlight(static_cast(wParam), static_cast(lParam)); break; case SCI_CALLTIPSETBACK: - ct.colourBG = ColourDesired(wParam); + ct.colourBG = ColourDesired(static_cast(wParam)); vs.styles[STYLE_CALLTIP].back = ct.colourBG; InvalidateStyleRedraw(); break; case SCI_CALLTIPSETFORE: - ct.colourUnSel = ColourDesired(wParam); + ct.colourUnSel = ColourDesired(static_cast(wParam)); vs.styles[STYLE_CALLTIP].fore = ct.colourUnSel; InvalidateStyleRedraw(); break; case SCI_CALLTIPSETFOREHLT: - ct.colourSel = ColourDesired(wParam); + ct.colourSel = ColourDesired(static_cast(wParam)); InvalidateStyleRedraw(); break; case SCI_CALLTIPUSESTYLE: - ct.SetTabSize((int)wParam); + ct.SetTabSize(static_cast(wParam)); InvalidateStyleRedraw(); break; @@ -934,7 +935,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara #ifdef SCI_LEXER case SCI_SETLEXER: - DocumentLexState()->SetLexer(wParam); + DocumentLexState()->SetLexer(static_cast(wParam)); break; case SCI_GETLEXER: @@ -942,10 +943,10 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara case SCI_COLOURISE: if (DocumentLexState()->lexLanguage == SCLEX_CONTAINER) { - pdoc->ModifiedAt(wParam); - NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : lParam); + pdoc->ModifiedAt(static_cast(wParam)); + NotifyStyleToNeeded((lParam == -1) ? pdoc->Length() : static_cast(lParam)); } else { - DocumentLexState()->Colourise(wParam, lParam); + DocumentLexState()->Colourise(static_cast(wParam), static_cast(lParam)); } Redraw(); break; @@ -963,7 +964,7 @@ sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lPara reinterpret_cast(lParam)); case SCI_GETPROPERTYINT: - return DocumentLexState()->PropGetInt(reinterpret_cast(wParam), lParam); + return DocumentLexState()->PropGetInt(reinterpret_cast(wParam), static_cast(lParam)); case SCI_SETKEYWORDS: DocumentLexState()->SetWordList(wParam, reinterpret_cast(lParam)); -- cgit v1.2.3