Skip to content

Commit 46b5cb3

Browse files
committed
1 parent 3eb8fc4 commit 46b5cb3

File tree

1 file changed

+72
-60
lines changed

1 file changed

+72
-60
lines changed

external/npp/Window.h

Lines changed: 72 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
//this file is part of notepad++
2-
//Copyright (C)2003 Don HO <[email protected]>
3-
//
4-
//This program is free software; you can redistribute it and/or
5-
//modify it under the terms of the GNU General Public License
6-
//as published by the Free Software Foundation; either
7-
//version 2 of the License, or (at your option) any later version.
1+
// This file is part of Notepad++ project
2+
// Copyright (C)2022 Don HO <[email protected]>
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// at your option any later version.
88
//
9-
//This program is distributed in the hope that it will be useful,
10-
//but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
//GNU General Public License for more details.
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
1313
//
14-
//You should have received a copy of the GNU General Public License
15-
//along with this program; if not, write to the Free Software
16-
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1716

18-
#ifndef WINDOW_CONTROL_H
19-
#define WINDOW_CONTROL_H
2017

18+
#pragma once
2119
#include <windows.h>
2220

2321
class Window
2422
{
2523
public:
26-
Window(): _hInst(NULL), _hParent(NULL), _hSelf(NULL){};
27-
virtual ~Window() {};
24+
//! \name Constructors & Destructor
25+
//@{
26+
Window() = default;
27+
Window(const Window&) = delete;
28+
virtual ~Window() = default;
29+
//@}
30+
2831

2932
virtual void init(HINSTANCE hInst, HWND parent)
3033
{
@@ -34,81 +37,90 @@ class Window
3437

3538
virtual void destroy() = 0;
3639

37-
virtual void display(bool toShow = true) const {
38-
::ShowWindow(_hSelf, toShow?SW_SHOW:SW_HIDE);
39-
};
40-
40+
virtual void display(bool toShow = true) const
41+
{
42+
::ShowWindow(_hSelf, toShow ? SW_SHOW : SW_HIDE);
43+
}
44+
45+
4146
virtual void reSizeTo(RECT & rc) // should NEVER be const !!!
42-
{
47+
{
4348
::MoveWindow(_hSelf, rc.left, rc.top, rc.right, rc.bottom, TRUE);
4449
redraw();
45-
};
50+
}
51+
4652

47-
virtual void reSizeToWH(RECT & rc) // should NEVER be const !!!
48-
{
53+
virtual void reSizeToWH(RECT& rc) // should NEVER be const !!!
54+
{
4955
::MoveWindow(_hSelf, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, TRUE);
5056
redraw();
51-
};
57+
}
58+
5259

53-
virtual void redraw(bool forceUpdate = false) const {
54-
::InvalidateRect(_hSelf, NULL, TRUE);
60+
virtual void redraw(bool forceUpdate = false) const
61+
{
62+
::InvalidateRect(_hSelf, nullptr, TRUE);
5563
if (forceUpdate)
5664
::UpdateWindow(_hSelf);
57-
};
58-
59-
virtual void getClientRect(RECT & rc) const {
65+
}
66+
67+
68+
virtual void getClientRect(RECT & rc) const
69+
{
6070
::GetClientRect(_hSelf, &rc);
61-
};
71+
}
6272

63-
virtual void getWindowRect(RECT & rc) const {
73+
virtual void getWindowRect(RECT & rc) const
74+
{
6475
::GetWindowRect(_hSelf, &rc);
65-
};
76+
}
6677

67-
virtual int getWidth() const {
78+
virtual int getWidth() const
79+
{
6880
RECT rc;
6981
::GetClientRect(_hSelf, &rc);
7082
return (rc.right - rc.left);
71-
};
83+
}
7284

73-
virtual int getHeight() const {
85+
virtual int getHeight() const
86+
{
7487
RECT rc;
7588
::GetClientRect(_hSelf, &rc);
7689
if (::IsWindowVisible(_hSelf) == TRUE)
7790
return (rc.bottom - rc.top);
7891
return 0;
79-
};
92+
}
8093

81-
virtual bool isVisible() const {
94+
virtual bool isVisible() const
95+
{
8296
return (::IsWindowVisible(_hSelf)?true:false);
83-
};
97+
}
8498

85-
HWND getHSelf() const {
86-
//assert(_hSelf);
99+
HWND getHSelf() const
100+
{
87101
return _hSelf;
88-
};
102+
}
89103

90104
HWND getHParent() const {
91105
return _hParent;
92-
};
106+
}
93107

94108
void getFocus() const {
95109
::SetFocus(_hSelf);
96-
};
97-
98-
HINSTANCE getHinst() const {
99-
if (!_hInst)
100-
{
101-
::MessageBox(NULL, TEXT("_hInst == NULL"), TEXT("class Window"), MB_OK);
102-
throw int(1999);
103-
}
110+
}
111+
112+
HINSTANCE getHinst() const
113+
{
114+
//assert(_hInst != 0);
104115
return _hInst;
105-
};
106-
protected:
107-
HINSTANCE _hInst;
108-
HWND _hParent;
109-
HWND _hSelf;
110-
};
116+
}
111117

112-
#endif //WINDOW_CONTROL_H
113118

119+
Window& operator = (const Window&) = delete;
114120

121+
122+
protected:
123+
HINSTANCE _hInst = NULL;
124+
HWND _hParent = NULL;
125+
HWND _hSelf = NULL;
126+
};

0 commit comments

Comments
 (0)