diff options
| -rw-r--r-- | cocoa/PlatCocoa.mm | 14 | ||||
| -rw-r--r-- | gtk/PlatGTK.cxx | 16 | ||||
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 3 | ||||
| -rw-r--r-- | include/Platform.h | 70 | ||||
| -rw-r--r-- | qt/ScintillaEditBase/PlatQt.cpp | 16 | ||||
| -rw-r--r-- | src/Editor.cxx | 3 | ||||
| -rw-r--r-- | src/ScintillaBase.cxx | 10 | ||||
| -rw-r--r-- | win32/PlatWin.cxx | 18 | ||||
| -rw-r--r-- | win32/ScintillaWin.cxx | 5 | 
9 files changed, 74 insertions, 81 deletions
| diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index 9e0cf81f7..bdf0d3997 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -73,7 +73,7 @@ inline CGRect PRectangleToCGRect(PRectangle &rc) {  //----------------- Font --------------------------------------------------------------------------- -Font::Font(): fid(0) { +Font::Font() noexcept : fid(0) {  }  //-------------------------------------------------------------------------------------------------- @@ -1018,7 +1018,7 @@ static CGFloat ScreenMax() {  //-------------------------------------------------------------------------------------------------- -PRectangle Window::GetPosition() { +PRectangle Window::GetPosition() const {  	if (wid) {  		NSRect rect;  		id idWin = (__bridge id)(wid); @@ -1070,8 +1070,8 @@ void Window::SetPosition(PRectangle rc) {  //-------------------------------------------------------------------------------------------------- -void Window::SetPositionRelative(PRectangle rc, Window window) { -	PRectangle rcOther = window.GetPosition(); +void Window::SetPositionRelative(PRectangle rc, const Window *window) { +	PRectangle rcOther = window->GetPosition();  	rc.left += rcOther.left;  	rc.right += rcOther.left;  	rc.top += rcOther.top; @@ -1081,7 +1081,7 @@ void Window::SetPositionRelative(PRectangle rc, Window window) {  //-------------------------------------------------------------------------------------------------- -PRectangle Window::GetClientPosition() { +PRectangle Window::GetClientPosition() const {  	// This means, in MacOS X terms, get the "frame bounds". Call GetPosition, just like on Win32.  	return GetPosition();  } @@ -1693,7 +1693,7 @@ void ListBoxImpl::SelectionChange() {  // ListBox is implemented by the ListBoxImpl class. -ListBox::ListBox() { +ListBox::ListBox() noexcept {  }  ListBox::~ListBox() { @@ -1743,7 +1743,7 @@ NSMenu  //----------------- Menu --------------------------------------------------------------------------- -Menu::Menu() +Menu::Menu() noexcept  	: mid(0) {  } diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index 1a9aa4c6e..bb8f7575c 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -106,7 +106,7 @@ static GtkWidget *PWidget(WindowID wid) {  	return static_cast<GtkWidget *>(wid);  } -Font::Font() : fid(0) {} +Font::Font() noexcept : fid(0) {}  Font::~Font() {} @@ -962,7 +962,7 @@ void Window::Destroy() {  	}  } -PRectangle Window::GetPosition() { +PRectangle Window::GetPosition() const {  	// Before any size allocated pretend its 1000 wide so not scrolled  	PRectangle rc(0, 0, 1000, 1000);  	if (wid) { @@ -1006,15 +1006,15 @@ GdkRectangle MonitorRectangleForWidget(GtkWidget *wid) {  } -void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) {  	int ox = 0;  	int oy = 0; -	GdkWindow *wndRelativeTo = WindowFromWidget(PWidget(relativeTo.wid)); +	GdkWindow *wndRelativeTo = WindowFromWidget(PWidget(relativeTo->wid));  	gdk_window_get_origin(wndRelativeTo, &ox, &oy);  	ox += rc.left;  	oy += rc.top; -	GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(relativeTo.wid)); +	GdkRectangle rcMonitor = MonitorRectangleForWidget(PWidget(relativeTo->wid));  	/* do some corrections to fit into screen */  	int sizex = rc.right - rc.left; @@ -1033,7 +1033,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {  	gtk_window_resize(GTK_WINDOW(wid), sizex, sizey);  } -PRectangle Window::GetClientPosition() { +PRectangle Window::GetClientPosition() const {  	// On GTK+, the client position is the window position  	return GetPosition();  } @@ -1144,7 +1144,7 @@ static void list_image_free(gpointer, gpointer value, gpointer) {  	g_free(list_image);  } -ListBox::ListBox() { +ListBox::ListBox() noexcept {  }  ListBox::~ListBox() { @@ -1867,7 +1867,7 @@ void ListBoxX::SetList(const char *listText, char separator, char typesep) {  	}  } -Menu::Menu() : mid(0) {} +Menu::Menu() noexcept : mid(0) {}  void Menu::CreatePopUp() {  	Destroy(); diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index 43dc82704..b75a96c5d 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -980,8 +980,7 @@ void ScintillaGTK::FullPaint() {  }  PRectangle ScintillaGTK::GetClientRectangle() const { -	Window win = wMain; -	PRectangle rc = win.GetClientPosition(); +	PRectangle rc = wMain.GetClientPosition();  	if (verticalScrollBarVisible)  		rc.right -= verticalScrollBarWidth;  	if (horizontalScrollBarVisible && !Wrapping()) diff --git a/include/Platform.h b/include/Platform.h index a97dded28..fdf41e6e7 100644 --- a/include/Platform.h +++ b/include/Platform.h @@ -250,7 +250,7 @@ struct FontParameters {  		bool italic_=false,  		int extraFontFlag_=0,  		int technology_=0, -		int characterSet_=0) : +		int characterSet_=0) noexcept :  		faceName(faceName_),  		size(size_), @@ -267,19 +267,21 @@ struct FontParameters {  class Font {  protected:  	FontID fid; -	// Private so Font objects can not be copied -	Font(const Font &); -	Font &operator=(const Font &);  public: -	Font(); +	Font() noexcept; +	// Deleted so Font objects can not be copied +	Font(const Font &) = delete; +	Font(Font &&) = delete; +	Font &operator=(const Font &) = delete; +	Font &operator=(Font &&) = delete;  	virtual ~Font();  	virtual void Create(const FontParameters &fp);  	virtual void Release(); -	FontID GetID() { return fid; } +	FontID GetID() const noexcept { return fid; }  	// Alias another font - caller guarantees not to Release -	void SetID(FontID fid_) { fid = fid_; } +	void SetID(FontID fid_) noexcept { fid = fid_; }  	friend class Surface;  	friend class SurfaceImpl;  }; @@ -346,30 +348,25 @@ class Window {  protected:  	WindowID wid;  public: -	Window() : wid(0), cursorLast(cursorInvalid) { +	Window() noexcept : wid(0), cursorLast(cursorInvalid) {  	} -	Window(const Window &source) : wid(source.wid), cursorLast(cursorInvalid) { -	} -	virtual ~Window(); -	Window &operator=(WindowID wid_) { +	Window(const Window &source) = delete; +	Window(Window &&) = delete; +	Window &operator=(WindowID wid_) noexcept {  		wid = wid_;  		cursorLast = cursorInvalid;  		return *this;  	} -	Window &operator=(const Window &other) { -		if (this != &other) { -			wid = other.wid; -			cursorLast = other.cursorLast; -		} -		return *this; -	} -	WindowID GetID() const { return wid; } -	bool Created() const { return wid != 0; } +	Window &operator=(const Window &) = delete; +	Window &operator=(Window &&) = delete; +	virtual ~Window(); +	WindowID GetID() const noexcept { return wid; } +	bool Created() const noexcept { return wid != 0; }  	void Destroy(); -	PRectangle GetPosition(); +	PRectangle GetPosition() const;  	void SetPosition(PRectangle rc); -	void SetPositionRelative(PRectangle rc, Window relativeTo); -	PRectangle GetClientPosition(); +	void SetPositionRelative(PRectangle rc, const Window *relativeTo); +	PRectangle GetClientPosition() const;  	void Show(bool show=true);  	void InvalidateAll();  	void InvalidateRectangle(PRectangle rc); @@ -389,7 +386,7 @@ private:  struct ListBoxEvent {  	enum class EventType { selectionChange, doubleClick } event; -	ListBoxEvent(EventType event_) : event(event_) { +	ListBoxEvent(EventType event_) noexcept : event(event_) {  	}  }; @@ -400,7 +397,7 @@ public:  class ListBox : public Window {  public: -	ListBox(); +	ListBox() noexcept;  	~ListBox() override;  	static ListBox *Allocate(); @@ -431,8 +428,8 @@ public:  class Menu {  	MenuID mid;  public: -	Menu(); -	MenuID GetID() { return mid; } +	Menu() noexcept; +	MenuID GetID() const noexcept { return mid; }  	void CreatePopUp();  	void Destroy();  	void Show(Point pt, Window &w); @@ -451,7 +448,7 @@ public:   */  class DynamicLibrary {  public: -	virtual ~DynamicLibrary() {} +	virtual ~DynamicLibrary() = default;  	/// @return Pointer to function "name", or NULL on failure.  	virtual Function FindFunction(const char *name) = 0; @@ -478,21 +475,20 @@ public:   * and chrome colour. Not a creatable object, more of a module with several functions.   */  class Platform { -	// Private so Platform objects can not be copied -	Platform(const Platform &) {} -	Platform &operator=(const Platform &) { return *this; }  public: -	// Should be private because no new Platforms are ever created -	// but gcc warns about this -	Platform() {} -	~Platform() {} +	Platform() = default; +	Platform(const Platform &) = delete; +	Platform(Platform &&) = delete; +	Platform &operator=(const Platform &) = delete; +	Platform &operator=(Platform &&) = delete; +	~Platform() = default;  	static ColourDesired Chrome();  	static ColourDesired ChromeHighlight();  	static const char *DefaultFont();  	static int DefaultFontSize();  	static unsigned int DoubleClickTime();  	static void DebugDisplay(const char *s); -	static long LongFromTwoShorts(short a,short b) { +	static long LongFromTwoShorts(short a,short b) noexcept {  		return (a) | ((b) << 16);  	} diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index fd8974fdf..ac8fbc9cc 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -113,7 +113,7 @@ static QFont *FontPointer(Font &f)  {  	return reinterpret_cast<FontAndCharacterSet *>(f.GetID())->pfont;  } -Font::Font() : fid(nullptr) {} +Font::Font() noexcept : fid(nullptr) {}  Font::~Font()  {  	delete reinterpret_cast<FontAndCharacterSet *>(fid); @@ -584,7 +584,7 @@ Surface *Surface::Allocate(int)  //----------------------------------------------------------------------  namespace { -QWidget *window(WindowID wid) +QWidget *window(WindowID wid) noexcept  {  	return static_cast<QWidget *>(wid);  } @@ -598,7 +598,7 @@ void Window::Destroy()  		delete window(wid);  	wid = nullptr;  } -PRectangle Window::GetPosition() +PRectangle Window::GetPosition() const  {  	// Before any size allocated pretend its 1000 wide so not scrolled  	return wid ? PRectFromQRect(window(wid)->frameGeometry()) : PRectangle(0, 0, 1000, 1000); @@ -610,9 +610,9 @@ void Window::SetPosition(PRectangle rc)  		window(wid)->setGeometry(QRectFromPRect(rc));  } -void Window::SetPositionRelative(PRectangle rc, Window relativeTo) +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo)  { -	QPoint oPos = window(relativeTo.wid)->mapToGlobal(QPoint(0,0)); +	QPoint oPos = window(relativeTo->wid)->mapToGlobal(QPoint(0,0));  	int ox = oPos.x();  	int oy = oPos.y();  	ox += rc.left; @@ -638,7 +638,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo)  	window(wid)->resize(sizex, sizey);  } -PRectangle Window::GetClientPosition() +PRectangle Window::GetClientPosition() const  {  	// The client position is the window position  	return GetPosition(); @@ -996,7 +996,7 @@ ListWidget *ListBoxImpl::GetWidget() const  	return static_cast<ListWidget *>(wid);  } -ListBox::ListBox() {} +ListBox::ListBox() noexcept {}  ListBox::~ListBox() {}  ListBox *ListBox::Allocate() @@ -1040,7 +1040,7 @@ QStyleOptionViewItem ListWidget::viewOptions() const  	return result;  }  //---------------------------------------------------------------------- -Menu::Menu() : mid(nullptr) {} +Menu::Menu() noexcept : mid(nullptr) {}  void Menu::CreatePopUp()  {  	Destroy(); diff --git a/src/Editor.cxx b/src/Editor.cxx index 3a357f37e..c89f3b6b8 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -308,8 +308,7 @@ Sci::Line Editor::TopLineOfMain() const {  }  PRectangle Editor::GetClientRectangle() const { -	Window win = wMain; -	return win.GetClientPosition(); +	return wMain.GetClientPosition();  }  PRectangle Editor::GetClientDrawingRectangle() { diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index f24e7ca6f..71f42d856 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -275,7 +275,7 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list  		Redraw();  		pt = PointMainCaret();  	} -	if (wMargin.GetID()) { +	if (wMargin.Created()) {  		const Point ptOrigin = GetVisibleOriginInMain();  		pt.x += ptOrigin.x;  		pt.y += ptOrigin.y; @@ -294,7 +294,7 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list  	}  	rcac.right = rcac.left + widthLB;  	rcac.bottom = static_cast<XYPOSITION>(std::min(static_cast<int>(rcac.top) + heightLB, static_cast<int>(rcPopupBounds.bottom))); -	ac.lb->SetPositionRelative(rcac, wMain); +	ac.lb->SetPositionRelative(rcac, &wMain);  	ac.lb->SetFont(vs.styles[STYLE_DEFAULT].font);  	const unsigned int aveCharWidth = static_cast<unsigned int>(vs.styles[STYLE_DEFAULT].aveCharWidth);  	ac.lb->SetAverageCharWidth(aveCharWidth); @@ -318,7 +318,7 @@ void ScintillaBase::AutoCompleteStart(Sci::Position lenEntered, const char *list  		rcList.top = pt.y + vs.lineHeight;  	}  	rcList.bottom = rcList.top + heightAlloced; -	ac.lb->SetPositionRelative(rcList, wMain); +	ac.lb->SetPositionRelative(rcList, &wMain);  	ac.Show(true);  	if (lenEntered != 0) {  		AutoCompleteMoveToCurrentWord(); @@ -462,7 +462,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {  	if (ct.UseStyleCallTip()) {  		ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);  	} -	if (wMargin.GetID()) { +	if (wMargin.Created()) {  		const Point ptOrigin = GetVisibleOriginInMain();  		pt.x += ptOrigin.x;  		pt.y += ptOrigin.y; @@ -492,7 +492,7 @@ void ScintillaBase::CallTipShow(Point pt, const char *defn) {  	}  	// Now display the window.  	CreateCallTipWindow(rc); -	ct.wCallTip.SetPositionRelative(rc, wMain); +	ct.wCallTip.SetPositionRelative(rc, &wMain);  	ct.wCallTip.Show();  } diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index ccfb65e32..43b27cf7b 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -447,8 +447,7 @@ void FontCached::ReleaseId(FontID fid_) {  	::LeaveCriticalSection(&crPlatformLock);  } -Font::Font() { -	fid = 0; +Font::Font() noexcept : fid(0) {  }  Font::~Font() { @@ -1805,7 +1804,7 @@ void Window::Destroy() {  	wid = nullptr;  } -PRectangle Window::GetPosition() { +PRectangle Window::GetPosition() const {  	RECT rc;  	::GetWindowRect(HwndFromWindowID(wid), &rc);  	return PRectangle::FromInts(rc.left, rc.top, rc.right, rc.bottom); @@ -1837,11 +1836,11 @@ static RECT RectFromMonitor(HMONITOR hMonitor) {  } -void Window::SetPositionRelative(PRectangle rc, Window relativeTo) { +void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) {  	const LONG style = ::GetWindowLong(HwndFromWindowID(wid), GWL_STYLE);  	if (style & WS_POPUP) {  		POINT ptOther = {0, 0}; -		::ClientToScreen(HwndFromWindowID(relativeTo.GetID()), &ptOther); +		::ClientToScreen(HwndFromWindowID(relativeTo->GetID()), &ptOther);  		rc.Move(static_cast<XYPOSITION>(ptOther.x), static_cast<XYPOSITION>(ptOther.y));  		const RECT rcMonitor = RectFromPRectangle(rc); @@ -1868,7 +1867,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {  	SetPosition(rc);  } -PRectangle Window::GetClientPosition() { +PRectangle Window::GetClientPosition() const {  	RECT rc={0,0,0,0};  	if (wid)  		::GetClientRect(HwndFromWindowID(wid), &rc); @@ -2033,7 +2032,7 @@ public:  const TCHAR ListBoxX_ClassName[] = TEXT("ListBoxX"); -ListBox::ListBox() { +ListBox::ListBox() noexcept {  }  ListBox::~ListBox() { @@ -2559,8 +2558,7 @@ 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(); +	const PRectangle rc = GetPosition();  	LRESULT hit = ::DefWindowProc(GetHWND(), WM_NCHITTEST, wParam, lParam);  	// There is an apparent bug in the DefWindowProc hit test code whereby it will @@ -2894,7 +2892,7 @@ bool ListBoxX_Unregister() {  } -Menu::Menu() : mid(0) { +Menu::Menu() noexcept : mid(0) {  }  void Menu::CreatePopUp() { diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index bcb078e86..869b1909a 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -2318,12 +2318,13 @@ void ScintillaWin::Paste() {  void ScintillaWin::CreateCallTipWindow(PRectangle) {  	if (!ct.wCallTip.Created()) { -		ct.wCallTip = ::CreateWindow(callClassName, TEXT("ACallTip"), +		HWND wnd = ::CreateWindow(callClassName, TEXT("ACallTip"),  					     WS_POPUP, 100, 100, 150, 20,  					     MainHWND(), 0,  					     GetWindowInstance(MainHWND()),  					     this); -		ct.wDraw = ct.wCallTip; +		ct.wCallTip = wnd; +		ct.wDraw = wnd;  	}  } | 
