Skip to content

Commit 5072f97

Browse files
ozone10donho
authored andcommitted
Prepare style name constants for pugixml replacement
Ref: notepad-plus-plus#16175 Close notepad-plus-plus#17452
1 parent 8529a0b commit 5072f97

File tree

10 files changed

+102
-69
lines changed

10 files changed

+102
-69
lines changed

PowerEditor/src/MISC/Common/NppConstants.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ inline constexpr int MAX_EXTERNAL_LEXER_NAME_LEN = 128;
346346
inline constexpr int RECENTFILES_SHOWFULLPATH = -1;
347347
inline constexpr int RECENTFILES_SHOWONLYFILENAME = 0;
348348

349+
inline constexpr const wchar_t nppLogNetworkDriveIssue[] = L"nppLogNetworkDriveIssue"; // issue xml/log file name
350+
inline constexpr const wchar_t nppLogNulContentCorruptionIssue[] = L"nppLogNulContentCorruptionIssue"; // issue xml/log file name
351+
349352
// Parameters
350353

351354
// UserDefineLangReference
@@ -355,3 +358,46 @@ inline constexpr int extsLenMax = 256;
355358
inline constexpr int max_char = 1024 * 30;
356359

357360
// UserDefineLangReference
361+
362+
// TabBar
363+
364+
inline constexpr int g_TabIconSize = 16;
365+
inline constexpr int g_TabHeight = 22;
366+
inline constexpr int g_TabHeightLarge = 25;
367+
inline constexpr int g_TabWidth = 45;
368+
inline constexpr int g_TabWidthButton = 60;
369+
inline constexpr int g_TabCloseBtnSize = 11;
370+
inline constexpr int g_TabPinBtnSize = 11;
371+
inline constexpr int g_TabCloseBtnSize_DM = 16;
372+
inline constexpr int g_TabPinBtnSize_DM = 16;
373+
374+
// TabBar
375+
376+
// Style names
377+
378+
inline constexpr const wchar_t TABBAR_ACTIVEFOCUSEDINDCATOR[] = L"Active tab focused indicator";
379+
inline constexpr const wchar_t TABBAR_ACTIVEUNFOCUSEDINDCATOR[] = L"Active tab unfocused indicator";
380+
inline constexpr const wchar_t TABBAR_ACTIVETEXT[] = L"Active tab text";
381+
inline constexpr const wchar_t TABBAR_INACTIVETEXT[] = L"Inactive tabs";
382+
383+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_1[] = L"Tab color 1";
384+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_2[] = L"Tab color 2";
385+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_3[] = L"Tab color 3";
386+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_4[] = L"Tab color 4";
387+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_5[] = L"Tab color 5";
388+
389+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_DM_1[] = L"Tab color dark mode 1";
390+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_DM_2[] = L"Tab color dark mode 2";
391+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_DM_3[] = L"Tab color dark mode 3";
392+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_DM_4[] = L"Tab color dark mode 4";
393+
inline constexpr const wchar_t TABBAR_INDIVIDUALCOLOR_DM_5[] = L"Tab color dark mode 5";
394+
395+
inline constexpr const wchar_t VIEWZONE_DOCUMENTMAP[] = L"Document map";
396+
397+
inline constexpr const wchar_t FINDDLG_STAUSNOTFOUND_COLOR[] = L"Find status: Not found";
398+
inline constexpr const wchar_t FINDDLG_STAUSMESSAGE_COLOR[] = L"Find status: Message";
399+
inline constexpr const wchar_t FINDDLG_STAUSREACHED_COLOR[] = L"Find status: Search end reached";
400+
401+
inline constexpr const wchar_t g_npcStyleName[] = L"Non-printing characters custom color";
402+
403+
// Style names

PowerEditor/src/Parameters.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,9 @@ EolType convertIntToFormatType(int value, EolType defvalue = EolType::osdefault)
7979
#define PURE_LC_BOL 1
8080
#define PURE_LC_WSP 2
8181

82-
// issue xml/log file name
83-
const wchar_t nppLogNetworkDriveIssue[] = L"nppLogNetworkDriveIssue";
84-
const wchar_t nppLogNulContentCorruptionIssue[] = L"nppLogNulContentCorruptionIssue";
85-
8682
void cutString(const wchar_t *str2cut, std::vector<std::wstring> & patternVect);
8783
void cutStringBy(const wchar_t *str2cut, std::vector<std::wstring> & patternVect, char byChar, bool allowEmptyStr);
8884

89-
// style names
90-
const wchar_t g_npcStyleName[] = L"Non-printing characters custom color";
91-
9285
struct Position
9386
{
9487
intptr_t _firstVisibleLine = 0;

PowerEditor/src/ScintillaComponent/DocTabView.cpp

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,30 @@
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717

18-
1918
#include "DocTabView.h"
20-
#include "ScintillaEditView.h"
21-
22-
#ifndef _WIN32_IE
23-
#define _WIN32_IE 0x0600
24-
#endif //_WIN32_IE
2519

26-
int docTabIconIDs[] = { IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON, IDI_READONLYSYS_ICON, IDI_MONITORING_ICON };
27-
int docTabIconIDs_darkMode[] = { IDI_SAVED_DM_ICON, IDI_UNSAVED_DM_ICON, IDI_READONLY_DM_ICON, IDI_READONLYSYS_DM_ICON, IDI_MONITORING_DM_ICON };
28-
int docTabIconIDs_alt[] = { IDI_SAVED_ALT_ICON, IDI_UNSAVED_ALT_ICON, IDI_READONLY_ALT_ICON, IDI_READONLYSYS_ALT_ICON, IDI_MONITORING_ICON };
20+
#include <cwchar>
2921

22+
#include "Buffer.h"
23+
#include "NppConstants.h"
24+
#include "Parameters.h"
25+
#include "ScintillaEditView.h"
26+
#include "TabBar.h"
27+
#include "Windows.h"
28+
#include "resource.h"
3029

30+
enum ImgIdx
31+
{
32+
SAVED_IMG_INDEX,
33+
UNSAVED_IMG_INDEX,
34+
REDONLY_IMG_INDEX,
35+
REDONLYSYS_IMG_INDEX,
36+
MONITORING_IMG_INDEX,
37+
};
38+
39+
static constexpr int docTabIconIDs[] = { IDI_SAVED_ICON, IDI_UNSAVED_ICON, IDI_READONLY_ICON, IDI_READONLYSYS_ICON, IDI_MONITORING_ICON };
40+
static constexpr int docTabIconIDs_darkMode[] = { IDI_SAVED_DM_ICON, IDI_UNSAVED_DM_ICON, IDI_READONLY_DM_ICON, IDI_READONLYSYS_DM_ICON, IDI_MONITORING_DM_ICON };
41+
static constexpr int docTabIconIDs_alt[] = { IDI_SAVED_ALT_ICON, IDI_UNSAVED_ALT_ICON, IDI_READONLY_ALT_ICON, IDI_READONLYSYS_ALT_ICON, IDI_MONITORING_ICON };
3142

3243
void DocTabView::init(HINSTANCE hInst, HWND parent, ScintillaEditView* pView, unsigned char indexChoice, unsigned char buttonsStatus)
3344
{

PowerEditor/src/ScintillaComponent/DocTabView.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

17+
1718
#pragma once
1819

19-
#include "TabBar.h"
20-
#include "Buffer.h"
20+
#include <windows.h>
2121

22-
const int SAVED_IMG_INDEX = 0;
23-
const int UNSAVED_IMG_INDEX = 1;
24-
const int REDONLY_IMG_INDEX = 2;
25-
const int REDONLYSYS_IMG_INDEX = 3;
26-
const int MONITORING_IMG_INDEX = 4;
22+
#include <vector>
23+
24+
#include "Buffer.h"
25+
#include "ImageListSet.h"
26+
#include "NppConstants.h"
27+
#include "ScintillaEditView.h"
28+
#include "TabBar.h"
29+
#include "Window.h"
2730

2831

2932
class DocTabView : public TabBarPlus
@@ -96,4 +99,7 @@ private :
9699

97100
std::vector<IconList *> _pIconListVector;
98101
int _iconListIndexChoice = -1;
102+
103+
using Window::init;
104+
using TabBar::init;
99105
};

PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@
3232
#define WM_UPDATESCINTILLAS (WORDSTYLE_USER + 1) // WM_UPDATESCINTILLAS (BOOL doChangePanel, 0)
3333
#define WM_UPDATEMAINMENUBITMAPS (WORDSTYLE_USER + 2)
3434

35-
const wchar_t FINDDLG_STAUSNOTFOUND_COLOR[64] = L"Find status: Not found";
36-
const wchar_t FINDDLG_STAUSMESSAGE_COLOR[64] = L"Find status: Message";
37-
const wchar_t FINDDLG_STAUSREACHED_COLOR[64] = L"Find status: Search end reached";
38-
3935
enum fontStyleType {BOLD_STATUS, ITALIC_STATUS, UNDERLINE_STATUS};
4036

4137
class WordStyleDlg : public StaticDialog

PowerEditor/src/WinControls/DocumentMap/documentMap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
#define DM_PANELTITLE L"Document Map"
2424

25-
const wchar_t VIEWZONE_DOCUMENTMAP[64] = L"Document map";
26-
2725
class ScintillaEditView;
2826
class Buffer;
2927
struct MapPosition;
@@ -148,4 +146,5 @@ class DocumentMap : public DockingDlgInterface {
148146
std::wstring id4dockingCont = DM_NOFOCUSWHILECLICKINGCAPTION;
149147

150148
using DockingDlgInterface::init;
149+
using StaticDialog::create;
151150
};

PowerEditor/src/WinControls/ImageListSet/ImageListSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void IconList::init(HINSTANCE hInst, int iconSize)
4343
}
4444

4545

46-
void IconList::create(int iconSize, HINSTANCE hInst, int* iconIDArray, int iconIDArraySize)
46+
void IconList::create(int iconSize, HINSTANCE hInst, const int* iconIDArray, int iconIDArraySize)
4747
{
4848
init(hInst, iconSize);
4949
_pIconIDArray = iconIDArray;

PowerEditor/src/WinControls/ImageListSet/ImageListSet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class IconList
2929
public :
3030
IconList() = default;
3131
void init(HINSTANCE hInst, int iconSize);
32-
void create(int iconSize, HINSTANCE hInst, int *iconIDArray, int iconIDArraySize);
32+
void create(int iconSize, HINSTANCE hInst, const int* iconIDArray, int iconIDArraySize);
3333

3434
void destroy() {
3535
ImageList_Destroy(_hImglst);
@@ -48,7 +48,7 @@ public :
4848
private :
4949
HIMAGELIST _hImglst = nullptr;
5050
HINSTANCE _hInst = nullptr;
51-
int *_pIconIDArray = nullptr;
51+
const int* _pIconIDArray = nullptr;
5252
int _iconIDArraySize = 0;
5353
int _iconSize = 0;
5454

PowerEditor/src/WinControls/TabBar/ControlsTab.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717

1818
#pragma once
1919

20+
#include <windows.h>
21+
22+
#include <string>
23+
#include <vector>
24+
2025
#include "TabBar.h"
2126
#include "Window.h"
22-
#include "Common.h"
2327

2428
struct DlgInfo
2529
{
@@ -30,7 +34,7 @@ struct DlgInfo
3034
DlgInfo(Window *dlg, const wchar_t *name, const wchar_t *internalName = L""): _dlg(dlg), _name(name), _internalName(internalName) {}
3135
};
3236

33-
typedef std::vector<DlgInfo> WindowVector;
37+
using WindowVector = std::vector<DlgInfo>;
3438

3539

3640
class ControlsTab final : public TabBar
@@ -51,7 +55,7 @@ public :
5155

5256
void clickedUpdate()
5357
{
54-
int indexClicked = int(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
58+
const auto indexClicked = static_cast<int>(::SendMessage(_hSelf, TCM_GETCURSEL, 0, 0));
5559
activateWindowAt(indexClicked);
5660
}
5761
void renameTab(size_t index, const wchar_t *newName);
@@ -60,4 +64,6 @@ public :
6064
private:
6165
WindowVector *_pWinVector = nullptr;
6266
int _current = 0;
67+
68+
using TabBar::init;
6369
};

PowerEditor/src/WinControls/TabBar/TabBar.h

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717

1818
#pragma once
1919

20-
#ifndef _WIN32_IE
21-
#define _WIN32_IE 0x0600
22-
#endif //_WIN32_IE
23-
2420
#include <windows.h>
21+
2522
#include <commctrl.h>
23+
2624
#include "Window.h"
2725
#include "dpiManagerV2.h"
2826

@@ -37,34 +35,7 @@
3735

3836
#define WM_TABSETSTYLE (WM_APP + 0x024)
3937

40-
const int nbCtrlMax = 10;
41-
42-
const wchar_t TABBAR_ACTIVEFOCUSEDINDCATOR[64] = L"Active tab focused indicator";
43-
const wchar_t TABBAR_ACTIVEUNFOCUSEDINDCATOR[64] = L"Active tab unfocused indicator";
44-
const wchar_t TABBAR_ACTIVETEXT[64] = L"Active tab text";
45-
const wchar_t TABBAR_INACTIVETEXT[64] = L"Inactive tabs";
46-
47-
const wchar_t TABBAR_INDIVIDUALCOLOR_1[64] = L"Tab color 1";
48-
const wchar_t TABBAR_INDIVIDUALCOLOR_2[64] = L"Tab color 2";
49-
const wchar_t TABBAR_INDIVIDUALCOLOR_3[64] = L"Tab color 3";
50-
const wchar_t TABBAR_INDIVIDUALCOLOR_4[64] = L"Tab color 4";
51-
const wchar_t TABBAR_INDIVIDUALCOLOR_5[64] = L"Tab color 5";
52-
53-
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_1[64] = L"Tab color dark mode 1";
54-
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_2[64] = L"Tab color dark mode 2";
55-
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_3[64] = L"Tab color dark mode 3";
56-
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_4[64] = L"Tab color dark mode 4";
57-
const wchar_t TABBAR_INDIVIDUALCOLOR_DM_5[64] = L"Tab color dark mode 5";
58-
59-
constexpr int g_TabIconSize = 16;
60-
constexpr int g_TabHeight = 22;
61-
constexpr int g_TabHeightLarge = 25;
62-
constexpr int g_TabWidth = 45;
63-
constexpr int g_TabWidthButton = 60;
64-
constexpr int g_TabCloseBtnSize = 11;
65-
constexpr int g_TabPinBtnSize = 11;
66-
constexpr int g_TabCloseBtnSize_DM = 16;
67-
constexpr int g_TabPinBtnSize_DM = 16;
38+
inline constexpr int nbCtrlMax = 10;
6839

6940
struct TBHDR
7041
{
@@ -80,7 +51,7 @@ class TabBar : public Window
8051
TabBar() = default;
8152
~TabBar() override = default;
8253
void destroy() override;
83-
virtual void init(HINSTANCE hInst, HWND parent, bool isVertical = false, bool isMultiLine = false);
54+
virtual void init(HINSTANCE hInst, HWND parent, bool isVertical, bool isMultiLine);
8455
void reSizeTo(RECT& rc2Adjust) override;
8556
int insertAtEnd(const wchar_t *subTabName);
8657
void activateAt(int index) const;
@@ -132,8 +103,10 @@ class TabBar : public Window
132103
DPIManagerV2 _dpiManager;
133104

134105
long getRowCount() const {
135-
return long(::SendMessage(_hSelf, TCM_GETROWCOUNT, 0, 0));
106+
return static_cast<long>(::SendMessage(_hSelf, TCM_GETROWCOUNT, 0, 0));
136107
}
108+
109+
using Window::init;
137110
};
138111

139112

@@ -288,4 +261,7 @@ public :
288261

289262
void notify(int notifyCode, int tabIndex);
290263
void trackMouseEvent(DWORD event2check);
264+
265+
using Window::init;
266+
using TabBar::init;
291267
};

0 commit comments

Comments
 (0)