diff options
author | Neil <nyamatongwe@gmail.com> | 2020-05-20 20:39:10 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2020-05-20 20:39:10 +1000 |
commit | 22628ce86b10f1569bbe4f7aaef4b9c0f56b0b26 (patch) | |
tree | 8e77f4d992925ce81762c56f8a5627dc0eedc0e2 | |
parent | 76fccd8c4d3faf99bc69c19265fe6607e950110d (diff) | |
download | scintilla-mirror-22628ce86b10f1569bbe4f7aaef4b9c0f56b0b26.tar.gz |
Fix some minor warnings.
-rw-r--r-- | win32/PlatWin.cxx | 29 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 14 |
2 files changed, 21 insertions, 22 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index d4d7b8026..b1e08782d 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -643,7 +643,7 @@ void SurfaceGDI::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesi BrushColour(back); std::vector<POINT> outline; for (size_t i=0; i<npts; i++) { - POINT pt = POINTFromPoint(pts[i]); + const POINT pt = POINTFromPoint(pts[i]); outline.push_back(pt); } ::Polygon(hdc, &outline[0], static_cast<int>(npts)); @@ -793,8 +793,8 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig const BITMAPINFO bpih = {{sizeof(BITMAPINFOHEADER), width, height, 1, 32, BI_RGB, 0, 0, 0, 0, 0}, {{0, 0, 0, 0}}}; void *image = nullptr; - HBITMAP hbmMem = CreateDIBSection(hMemDC, &bpih, - DIB_RGB_COLORS, &image, NULL, 0); + HBITMAP hbmMem = ::CreateDIBSection(hMemDC, &bpih, + DIB_RGB_COLORS, &image, {}, 0); if (hbmMem) { HBITMAP hbmOld = SelectBitmap(hMemDC, hbmMem); @@ -1641,13 +1641,13 @@ void ScreenLineLayout::FillTextLayoutFormats(const IScreenLine *screenLine, IDWr for (size_t bytePosition = 0; bytePosition < screenLine->Length();) { const unsigned char uch = screenLine->Text()[bytePosition]; const unsigned int byteCount = UTF8BytesOfLead[uch]; - const UINT32 codeUnits = static_cast<UINT32>(UTF16LengthFromUTF8ByteCount(byteCount)); + const UINT32 codeUnits = UTF16LengthFromUTF8ByteCount(byteCount); const DWRITE_TEXT_RANGE textRange = { layoutPosition, codeUnits }; XYPOSITION representationWidth = screenLine->RepresentationWidth(bytePosition); if ((representationWidth == 0.0f) && (screenLine->Text()[bytePosition] == '\t')) { Point realPt; - DWRITE_HIT_TEST_METRICS realCaretMetrics; + DWRITE_HIT_TEST_METRICS realCaretMetrics {}; textLayout->HitTestTextPosition( layoutPosition, false, // trailing if false, else leading edge @@ -1758,9 +1758,9 @@ size_t ScreenLineLayout::PositionFromX(XYPOSITION xDistance, bool charPosition) // If hitting the trailing side of a cluster, return the // leading edge of the following text position. - BOOL isTrailingHit; - BOOL isInside; - DWRITE_HIT_TEST_METRICS caretMetrics; + BOOL isTrailingHit = FALSE; + BOOL isInside = FALSE; + DWRITE_HIT_TEST_METRICS caretMetrics {}; textLayout->HitTestPoint( xDistance, @@ -1770,7 +1770,7 @@ size_t ScreenLineLayout::PositionFromX(XYPOSITION xDistance, bool charPosition) &caretMetrics ); - DWRITE_HIT_TEST_METRICS hitTestMetrics = {}; + DWRITE_HIT_TEST_METRICS hitTestMetrics {}; if (isTrailingHit) { FLOAT caretX = 0.0f; FLOAT caretY = 0.0f; @@ -1810,7 +1810,7 @@ XYPOSITION ScreenLineLayout::XFromPosition(size_t caretPosition) { const size_t position = GetPositionInLayout(text, caretPosition); // Translate text character offset to point x,y. - DWRITE_HIT_TEST_METRICS caretMetrics; + DWRITE_HIT_TEST_METRICS caretMetrics {}; Point pt; textLayout->HitTestTextPosition( @@ -1905,7 +1905,7 @@ void SurfaceD2D::DrawTextCommon(PRectangle rc, const Font &font_, XYPOSITION yba } // Explicitly creating a text layout appears a little faster - IDWriteTextLayout *pTextLayout; + IDWriteTextLayout *pTextLayout = nullptr; const HRESULT hr = pIDWriteFactory->CreateTextLayout(tbuf.buffer, tbuf.tlen, pTextFormat, rc.Width(), rc.Height(), &pTextLayout); if (SUCCEEDED(hr)) { @@ -2222,8 +2222,7 @@ void Window::InvalidateRectangle(PRectangle rc) { } void Window::SetFont(Font &font) { - ::SendMessage(HwndFromWindowID(wid), WM_SETFONT, - reinterpret_cast<WPARAM>(font.GetID()), 0); + SetWindowFont(HwndFromWindowID(wid), font.GetID(), 0); } namespace { @@ -2476,7 +2475,7 @@ void ListBoxX::SetFont(Font &font) { } FormatAndMetrics *pfm = static_cast<FormatAndMetrics *>(font.GetID()); fontCopy = pfm->HFont(); - ::SendMessage(lb, WM_SETFONT, reinterpret_cast<WPARAM>(fontCopy), 0); + SetWindowFont(lb, fontCopy, 0); } } @@ -3307,7 +3306,7 @@ bool Platform::ShowAssertionPopUps(bool assertionPopUps_) { } void Platform::Assert(const char *c, const char *file, int line) { - char buffer[2000]; + char buffer[2000] {}; sprintf(buffer, "Assertion [%s] failed at %s %d%s", c, file, line, assertionPopUps ? "" : "\r\n"); if (assertionPopUps) { const int idButton = ::MessageBoxA(0, buffer, "Assertion failure", diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 046ff7f10..bb6dbd101 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -356,7 +356,7 @@ class ScintillaWin : sptr_t HandleCompositionInline(uptr_t wParam, sptr_t lParam); static bool KoreanIME() noexcept; void MoveImeCarets(Sci::Position offset); - void DrawImeIndicator(int indicator, int len); + void DrawImeIndicator(int indicator, Sci::Position len); void SetCandidateWindowPos(); void SelectionToHangul(); void EscapeHanja(); @@ -964,7 +964,7 @@ void ScintillaWin::MoveImeCarets(Sci::Position offset) { } } -void ScintillaWin::DrawImeIndicator(int indicator, int len) { +void ScintillaWin::DrawImeIndicator(int indicator, Sci::Position len) { // Emulate the visual style of IME characters with indicators. // Draw an indicator on the character before caret by the character bytes of len // so it should be called after InsertCharacter(). @@ -1161,7 +1161,7 @@ sptr_t ScintillaWin::HandleCompositionInline(uptr_t, sptr_t lParam) { InsertCharacter(docChar, CharacterSource::tentativeInput); - DrawImeIndicator(imeIndicator[i], static_cast<unsigned int>(docChar.size())); + DrawImeIndicator(imeIndicator[i], docChar.size()); i += ucWidth; } @@ -1546,7 +1546,7 @@ sptr_t ScintillaWin::KeyMessage(unsigned int iMessage, uptr_t wParam, sptr_t lPa return 1; } else { wchar_t wcs[3] = { 0 }; - const unsigned int wclen = UTF16FromUTF32Character(static_cast<unsigned int>(wParam), wcs); + const size_t wclen = UTF16FromUTF32Character(static_cast<unsigned int>(wParam), wcs); AddWString(std::wstring_view(wcs, wclen), CharacterSource::directInput); return FALSE; } @@ -1649,7 +1649,7 @@ sptr_t ScintillaWin::EditMessage(unsigned int iMessage, uptr_t wParam, sptr_t lP if (static_cast<Sci::Position>(wParam) < 0) { wParam = SelectionStart().Position(); } - return pdoc->LineFromPosition(static_cast<Sci::Position>(wParam)); + return pdoc->LineFromPosition(wParam); case EM_EXLINEFROMCHAR: return pdoc->LineFromPosition(lParam); @@ -1674,7 +1674,7 @@ sptr_t ScintillaWin::EditMessage(unsigned int iMessage, uptr_t wParam, sptr_t lP break; case EM_SETSEL: { - Sci::Position nStart = static_cast<Sci::Position>(wParam); + Sci::Position nStart = wParam; Sci::Position nEnd = lParam; if (nStart == 0 && nEnd == -1) { nEnd = pdoc->Length(); @@ -2829,7 +2829,7 @@ void ScintillaWin::ImeStartComposition() { // The negative is to allow for leading lf.lfHeight = -(std::abs(deviceHeight / SC_FONT_SIZE_MULTIPLIER)); lf.lfWeight = vs.styles[styleHere].weight; - lf.lfItalic = static_cast<BYTE>(vs.styles[styleHere].italic ? 1 : 0); + lf.lfItalic = vs.styles[styleHere].italic ? 1 : 0; lf.lfCharSet = DEFAULT_CHARSET; lf.lfFaceName[0] = L'\0'; if (vs.styles[styleHere].fontName) { |