diff options
author | Neil <nyamatongwe@gmail.com> | 2015-09-25 13:51:41 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-09-25 13:51:41 +1000 |
commit | b2d0a7063b7e7c243e00e5b535e434222249d2ac (patch) | |
tree | b060fe41b26e64ece49b84a36413c87300952cb2 | |
parent | 3cb23dc27dcc62510c9d74f37afee2316bd2db9a (diff) | |
download | scintilla-mirror-b2d0a7063b7e7c243e00e5b535e434222249d2ac.tar.gz |
Replace reinterpret_cast with static_cast where possible.
-rw-r--r-- | win32/PlatWin.cxx | 70 | ||||
-rw-r--r-- | win32/ScintillaWin.cxx | 20 |
2 files changed, 45 insertions, 45 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 401cd4a17..79fccc22f 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -325,7 +325,7 @@ FontCached::FontCached(const FontParameters &fp) : fid = 0; if (technology == SCWIN_TECH_GDI) { HFONT hfont = ::CreateFontIndirectW(&lf); - fid = reinterpret_cast<void *>(new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet)); + fid = static_cast<void *>(new FormatAndMetrics(hfont, fp.extraFontFlag, fp.characterSet)); } else { #if defined(USE_D2D) IDWriteTextFormat *pTextFormat; @@ -365,7 +365,7 @@ FontCached::FontCached(const FontParameters &fp) : pTextLayout->Release(); pTextFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_UNIFORM, lineMetrics[0].height, lineMetrics[0].baseline); } - fid = reinterpret_cast<void *>(new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading)); + fid = static_cast<void *>(new FormatAndMetrics(pTextFormat, fp.extraFontFlag, fp.characterSet, yAscent, yDescent, yInternalLeading)); } #endif } @@ -388,7 +388,7 @@ bool FontCached::SameAs(const FontParameters &fp) { } void FontCached::Release() { - delete reinterpret_cast<FormatAndMetrics *>(fid); + delete static_cast<FormatAndMetrics *>(fid); fid = 0; } @@ -628,7 +628,7 @@ void SurfaceGDI::Init(WindowID) { void SurfaceGDI::Init(SurfaceID sid, WindowID) { Release(); - hdc = reinterpret_cast<HDC>(sid); + hdc = static_cast<HDC>(sid); ::SetTextAlign(hdc, TA_BASELINE); } @@ -670,14 +670,14 @@ void SurfaceGDI::BrushColor(ColourDesired back) { void SurfaceGDI::SetFont(Font &font_) { if (font_.GetID() != font) { - FormatAndMetrics *pfm = reinterpret_cast<FormatAndMetrics *>(font_.GetID()); + FormatAndMetrics *pfm = static_cast<FormatAndMetrics *>(font_.GetID()); PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_GDI); if (fontOld) { ::SelectObject(hdc, pfm->hfont); } else { fontOld = static_cast<HFONT>(::SelectObject(hdc, pfm->hfont)); } - font = reinterpret_cast<HFONT>(pfm->hfont); + font = pfm->hfont; } } @@ -799,7 +799,7 @@ void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fil static_cast<byte>(GetGValue(outline.AsLong()) * alphaOutline / 255), static_cast<byte>(GetRValue(outline.AsLong()) * alphaOutline / 255), static_cast<byte>(alphaOutline)); - DWORD *pixels = reinterpret_cast<DWORD *>(image); + DWORD *pixels = static_cast<DWORD *>(image); for (int y=0; y<height; y++) { for (int x=0; x<width; x++) { if ((x==0) || (x==width-1) || (y == 0) || (y == height-1)) { @@ -1204,7 +1204,7 @@ void SurfaceD2D::Init(WindowID /* wid */) { void SurfaceD2D::Init(SurfaceID sid, WindowID) { Release(); SetScale(); - pRenderTarget = reinterpret_cast<ID2D1RenderTarget *>(sid); + pRenderTarget = static_cast<ID2D1RenderTarget *>(sid); } void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID) { @@ -1255,7 +1255,7 @@ void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) { } void SurfaceD2D::SetFont(Font &font_) { - FormatAndMetrics *pfm = reinterpret_cast<FormatAndMetrics *>(font_.GetID()); + FormatAndMetrics *pfm = static_cast<FormatAndMetrics *>(font_.GetID()); PLATFORM_ASSERT(pfm->technology == SCWIN_TECH_DIRECTWRITE); pTextFormat = pfm->pTextFormat; yAscent = pfm->yAscent; @@ -1785,7 +1785,7 @@ Window::~Window() { void Window::Destroy() { if (wid) - ::DestroyWindow(reinterpret_cast<HWND>(wid)); + ::DestroyWindow(static_cast<HWND>(wid)); wid = 0; } @@ -1795,12 +1795,12 @@ bool Window::HasFocus() { PRectangle Window::GetPosition() { RECT rc; - ::GetWindowRect(reinterpret_cast<HWND>(wid), &rc); + ::GetWindowRect(static_cast<HWND>(wid), &rc); return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); } void Window::SetPosition(PRectangle rc) { - ::SetWindowPos(reinterpret_cast<HWND>(wid), + ::SetWindowPos(static_cast<HWND>(wid), 0, static_cast<int>(rc.left), static_cast<int>(rc.top), static_cast<int>(rc.Width()), static_cast<int>(rc.Height()), SWP_NOZORDER | SWP_NOACTIVATE); } @@ -1824,10 +1824,10 @@ static RECT RectFromMonitor(HMONITOR hMonitor) { } void Window::SetPositionRelative(PRectangle rc, Window w) { - LONG style = ::GetWindowLong(reinterpret_cast<HWND>(wid), GWL_STYLE); + LONG style = ::GetWindowLong(static_cast<HWND>(wid), GWL_STYLE); if (style & WS_POPUP) { POINT ptOther = {0, 0}; - ::ClientToScreen(reinterpret_cast<HWND>(w.GetID()), &ptOther); + ::ClientToScreen(static_cast<HWND>(w.GetID()), &ptOther); rc.Move(static_cast<XYPOSITION>(ptOther.x), static_cast<XYPOSITION>(ptOther.y)); RECT rcMonitor = RectFromPRectangle(rc); @@ -1860,28 +1860,28 @@ void Window::SetPositionRelative(PRectangle rc, Window w) { PRectangle Window::GetClientPosition() { RECT rc={0,0,0,0}; if (wid) - ::GetClientRect(reinterpret_cast<HWND>(wid), &rc); + ::GetClientRect(static_cast<HWND>(wid), &rc); return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); } void Window::Show(bool show) { if (show) - ::ShowWindow(reinterpret_cast<HWND>(wid), SW_SHOWNOACTIVATE); + ::ShowWindow(static_cast<HWND>(wid), SW_SHOWNOACTIVATE); else - ::ShowWindow(reinterpret_cast<HWND>(wid), SW_HIDE); + ::ShowWindow(static_cast<HWND>(wid), SW_HIDE); } void Window::InvalidateAll() { - ::InvalidateRect(reinterpret_cast<HWND>(wid), NULL, FALSE); + ::InvalidateRect(static_cast<HWND>(wid), NULL, FALSE); } void Window::InvalidateRectangle(PRectangle rc) { RECT rcw = RectFromPRectangle(rc); - ::InvalidateRect(reinterpret_cast<HWND>(wid), &rcw, FALSE); + ::InvalidateRect(static_cast<HWND>(wid), &rcw, FALSE); } static LRESULT Window_SendMessage(Window *w, UINT msg, WPARAM wParam=0, LPARAM lParam=0) { - return ::SendMessage(reinterpret_cast<HWND>(w->GetID()), msg, wParam, lParam); + return ::SendMessage(static_cast<HWND>(w->GetID()), msg, wParam, lParam); } void Window::SetFont(Font &font) { @@ -1961,7 +1961,7 @@ void Window::SetCursor(Cursor curs) { } void Window::SetTitle(const char *s) { - ::SetWindowTextA(reinterpret_cast<HWND>(wid), s); + ::SetWindowTextA(static_cast<HWND>(wid), s); } /* Returns rectangle of monitor pt is on, both rect and pt are in Window's @@ -2140,7 +2140,7 @@ void ListBoxX::Create(Window &parent_, int ctrlID_, Point location_, int lineHei lineHeight = lineHeight_; unicodeMode = unicodeMode_; technology = technology_; - HWND hwndParent = reinterpret_cast<HWND>(parent->GetID()); + HWND hwndParent = static_cast<HWND>(parent->GetID()); HINSTANCE hinstanceParent = GetWindowInstance(hwndParent); // Window created as popup so not clipped within parent client area wid = ::CreateWindowEx( @@ -2162,7 +2162,7 @@ void ListBoxX::SetFont(Font &font) { ::DeleteObject(fontCopy); fontCopy = 0; } - FormatAndMetrics *pfm = reinterpret_cast<FormatAndMetrics *>(font.GetID()); + FormatAndMetrics *pfm = static_cast<FormatAndMetrics *>(font.GetID()); fontCopy = pfm->HFont(); ::SendMessage(lb, WM_SETFONT, reinterpret_cast<WPARAM>(fontCopy), 0); } @@ -2181,7 +2181,7 @@ int ListBoxX::GetVisibleRows() const { } HWND ListBoxX::GetHWND() const { - return reinterpret_cast<HWND>(GetID()); + return static_cast<HWND>(GetID()); } PRectangle ListBoxX::GetDesiredRect() { @@ -2686,7 +2686,7 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA case WM_PAINT: { PAINTSTRUCT ps; HDC hDC = ::BeginPaint(hWnd, &ps); - ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd))); + ListBoxX *lbx = static_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd))); if (lbx) lbx->Paint(hDC); ::EndPaint(hWnd, &ps); @@ -2712,7 +2712,7 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA return 0; case WM_LBUTTONDBLCLK: { - ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd))); + ListBoxX *lbx = static_cast<ListBoxX *>(PointerFromWindow(::GetParent(hWnd))); if (lbx) { lbx->OnDoubleClick(); } @@ -2738,7 +2738,7 @@ LRESULT PASCAL ListBoxX::ControlWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { switch (iMessage) { case WM_CREATE: { - HINSTANCE hinstanceParent = GetWindowInstance(reinterpret_cast<HWND>(parent->GetID())); + HINSTANCE hinstanceParent = GetWindowInstance(static_cast<HWND>(parent->GetID())); // Note that LBS_NOINTEGRALHEIGHT is specified to fix cosmetic issue when resizing the list // but has useful side effect of speeding up list population significantly lb = ::CreateWindowEx( @@ -2774,7 +2774,7 @@ LRESULT ListBoxX::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam case WM_COMMAND: // This is not actually needed now - the registered double click action is used // directly to action a choice from the list. - ::SendMessage(reinterpret_cast<HWND>(parent->GetID()), iMessage, wParam, lParam); + ::SendMessage(static_cast<HWND>(parent->GetID()), iMessage, wParam, lParam); break; case WM_MEASUREITEM: { @@ -2872,7 +2872,7 @@ LRESULT PASCAL ListBoxX::StaticWndProc( SetWindowPointer(hWnd, pCreate->lpCreateParams); } // Find C++ object associated with window. - ListBoxX *lbx = reinterpret_cast<ListBoxX *>(PointerFromWindow(hWnd)); + ListBoxX *lbx = static_cast<ListBoxX *>(PointerFromWindow(hWnd)); if (lbx) { return lbx->WndProc(hWnd, iMessage, wParam, lParam); } else { @@ -2915,14 +2915,14 @@ void Menu::CreatePopUp() { void Menu::Destroy() { if (mid) - ::DestroyMenu(reinterpret_cast<HMENU>(mid)); + ::DestroyMenu(static_cast<HMENU>(mid)); mid = 0; } void Menu::Show(Point pt, Window &w) { - ::TrackPopupMenu(reinterpret_cast<HMENU>(mid), + ::TrackPopupMenu(static_cast<HMENU>(mid), TPM_RIGHTBUTTON, static_cast<int>(pt.x - 4), static_cast<int>(pt.y), 0, - reinterpret_cast<HWND>(w.GetID()), NULL); + static_cast<HWND>(w.GetID()), NULL); Destroy(); } @@ -3045,12 +3045,12 @@ bool Platform::IsKeyDown(int key) { long Platform::SendScintilla(WindowID w, unsigned int msg, unsigned long wParam, long lParam) { // This should never be called - its here to satisfy an old interface - return static_cast<long>(::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, lParam)); + return static_cast<long>(::SendMessage(static_cast<HWND>(w), msg, wParam, lParam)); } long Platform::SendScintillaPointer(WindowID w, unsigned int msg, unsigned long wParam, void *lParam) { // This should never be called - its here to satisfy an old interface - return static_cast<long>(::SendMessage(reinterpret_cast<HWND>(w), msg, wParam, + return static_cast<long>(::SendMessage(static_cast<HWND>(w), msg, wParam, reinterpret_cast<LPARAM>(lParam))); } @@ -3170,7 +3170,7 @@ int Platform::Clamp(int val, int minVal, int maxVal) { void Platform_Initialise(void *hInstance) { ::InitializeCriticalSection(&crPlatformLock); - hinstPlatformRes = reinterpret_cast<HINSTANCE>(hInstance); + hinstPlatformRes = static_cast<HINSTANCE>(hInstance); // This may be called from DllMain, in which case the call to LoadLibrary // is bad because it can upset the DLL load order. if (!hDLLImage) { diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index 17443a744..d0ea62a31 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -569,7 +569,7 @@ void ScintillaWin::DropRenderTarget() { #endif HWND ScintillaWin::MainHWND() { - return reinterpret_cast<HWND>(wMain.GetID()); + return static_cast<HWND>(wMain.GetID()); } bool ScintillaWin::DragThreshold(Point ptStart, Point ptNow) { @@ -1211,7 +1211,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam switch (iMessage) { case WM_CREATE: - ctrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID())); + ctrlID = ::GetDlgCtrlID(static_cast<HWND>(wMain.GetID())); // Get Intellimouse scroll line parameters GetIntelliMouseParameters(); ::RegisterDragDrop(MainHWND(), reinterpret_cast<IDropTarget *>(&dt)); @@ -1257,7 +1257,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_MOUSEWHEEL: // if autocomplete list active then send mousewheel message to it if (ac.Active()) { - HWND hWnd = reinterpret_cast<HWND>(ac.lb->GetID()); + HWND hWnd = static_cast<HWND>(ac.lb->GetID()); ::SendMessage(hWnd, iMessage, wParam, lParam); break; } @@ -1496,7 +1496,7 @@ sptr_t ScintillaWin::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam case WM_KILLFOCUS: { HWND wOther = reinterpret_cast<HWND>(wParam); HWND wThis = MainHWND(); - HWND wCT = reinterpret_cast<HWND>(ct.wCallTip.GetID()); + HWND wCT = static_cast<HWND>(ct.wCallTip.GetID()); if (!wParam || !(::IsChild(wThis, wOther) || (wOther == wCT))) { SetFocusState(false); @@ -1937,11 +1937,11 @@ void ScintillaWin::NotifyFocus(bool focus) { } void ScintillaWin::SetCtrlID(int identifier) { - ::SetWindowID(reinterpret_cast<HWND>(wMain.GetID()), identifier); + ::SetWindowID(static_cast<HWND>(wMain.GetID()), identifier); } int ScintillaWin::GetCtrlID() { - return ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID())); + return ::GetDlgCtrlID(static_cast<HWND>(wMain.GetID())); } void ScintillaWin::NotifyParent(SCNotification scn) { @@ -2270,7 +2270,7 @@ void ScintillaWin::CreateCallTipWindow(PRectangle) { } void ScintillaWin::AddToPopUp(const char *label, int cmd, bool enabled) { - HMENU hmenuPopup = reinterpret_cast<HMENU>(popup.GetID()); + HMENU hmenuPopup = static_cast<HMENU>(popup.GetID()); if (!label[0]) ::AppendMenuA(hmenuPopup, MF_SEPARATOR, 0, ""); else if (enabled) @@ -3238,7 +3238,7 @@ BOOL ScintillaWin::DestroySystemCaret() { LRESULT PASCAL ScintillaWin::CTWndProc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { // Find C++ object associated with window. - ScintillaWin *sciThis = reinterpret_cast<ScintillaWin *>(PointerFromWindow(hWnd)); + ScintillaWin *sciThis = static_cast<ScintillaWin *>(PointerFromWindow(hWnd)); try { // ctp will be zero if WM_CREATE not seen yet if (sciThis == 0) { @@ -3358,7 +3358,7 @@ LRESULT PASCAL ScintillaWin::SWndProc( //Platform::DebugPrintf("S W:%x M:%x WP:%x L:%x\n", hWnd, iMessage, wParam, lParam); // Find C++ object associated with window. - ScintillaWin *sci = reinterpret_cast<ScintillaWin *>(PointerFromWindow(hWnd)); + ScintillaWin *sci = static_cast<ScintillaWin *>(PointerFromWindow(hWnd)); // sci will be zero if WM_CREATE not seen yet if (sci == 0) { try { @@ -3390,7 +3390,7 @@ LRESULT PASCAL ScintillaWin::SWndProc( // Must be called once only. int Scintilla_RegisterClasses(void *hInstance) { Platform_Initialise(hInstance); - bool result = ScintillaWin::Register(reinterpret_cast<HINSTANCE>(hInstance)); + bool result = ScintillaWin::Register(static_cast<HINSTANCE>(hInstance)); #ifdef SCI_LEXER Scintilla_LinkLexers(); #endif |