Debian Codegraph @

Source/DialogTemplate.h

raw
1 /*
2 * DialogTemplate.h
3 *
4 * This file is a part of NSIS.
5 *
6 * Copyright (C) 2002-2026 Amir Szekely <[email protected]> and Contributors
7 *
8 * Licensed under the zlib/libpng license (the "License");
9 * you may not use this file except in compliance with the License.
10 *
11 * Licence details can be found in the file COPYING.
12 *
13 * This software is provided 'as-is', without any express or implied
14 * warranty.
15 *
16 * Reviewed for Unicode support by Jim Park -- 08/21/2007
17 */
18
19 #if !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
20 #define AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_
21
22 #if _MSC_VER > 1000
23 #pragma once
24 #endif // _MSC_VER > 1000
25
26 #include "Platform.h"
27 #include "winchar.h"
28
29 #include <vector>
30 #include <stdexcept>
31
32 #ifndef __BIG_ENDIAN__
33 # define EXTENDED_DIALOG ((DWORD) 0xFFFF0001)
34 #else
35 # define EXTENDED_DIALOG ((DWORD) 0x0100FFFF)
36 #endif
37
38 struct DialogItemTemplate {
39 DWORD dwHelpId; // Extended only
40
41 short sX;
42 short sY;
43 short sWidth;
44 short sHeight;
45 DWORD dwExtStyle;
46 DWORD dwStyle;
47 WORD wId;
48
49 WINWCHAR *szClass;
50 WINWCHAR *szTitle;
51 char *szCreationData;
52
53 WORD wCreateDataSize;
54 };
55
56 #pragma pack(1)
57
58 #ifndef _WIN32
59 typedef struct {
60 DWORD style;
61 DWORD dwExtendedStyle;
62 WORD cdit;
63 short x;
64 short y;
65 short cx;
66 short cy;
67 } DLGTEMPLATE;
68 #endif
69
70 typedef struct {
71 WORD dlgVer;
72 WORD signature;
73 DWORD helpID;
74 DWORD exStyle;
75 DWORD style;
76 WORD cDlgItems;
77 short x;
78 short y;
79 short cx;
80 short cy;
81 } DLGTEMPLATEEX;
82
83 #ifndef _WIN32
84 typedef struct {
85 DWORD style;
86 DWORD dwExtendedStyle;
87 short x;
88 short y;
89 short cx;
90 short cy;
91 WORD id;
92 } DLGITEMTEMPLATE;
93 #endif
94
95 typedef struct {
96 DWORD helpID;
97 DWORD exStyle;
98 DWORD style;
99 short x;
100 short y;
101 short cx;
102 short cy;
103 WORD id;
104 WORD _microsoft_docs_are_wrong;
105 } DLGITEMTEMPLATEEX;
106
107 #pragma pack()
108
109 class CDialogTemplate {
110 public:
111 CDialogTemplate(BYTE* pbData, bool build_unicode, unsigned int uCodePage=CP_ACP);
112 virtual ~CDialogTemplate();
113
114 short GetWidth();
115 short GetHeight();
116 DialogItemTemplate* GetItem(WORD wId);
117 DialogItemTemplate* GetItemByIdx(DWORD i);
118 int RemoveItem(WORD wId);
119 void SetFont(TCHAR* szFaceName, WORD wFontSize);
120 void AddItem(DialogItemTemplate item);
121 #ifdef _WIN32
122 HWND CreateDummyDialog();
123 #endif
124 void MoveAll(short x, short y);
125 void Resize(short x, short y);
126 void PixelsToDlgUnits(short& x, short& y);
127 void DlgUnitsToPixels(short& x, short& y);
128 #ifdef _WIN32
129 static inline bool SupportsDialogUnitComputation() { return true; }
130 void PixelsToDlgUnits(SIZE& siz);
131 SIZE GetStringSize(WORD id, TCHAR *str);
132 void RTrimToString(WORD id, TCHAR *str, int margins);
133 void LTrimToString(WORD id, TCHAR *str, int margins);
134 void CTrimToString(WORD id, TCHAR *str, int margins);
135 #else
136 static inline bool SupportsDialogUnitComputation() { return false; }
137 #endif
138 void ConvertToRTL();
139 BYTE* Save(DWORD& dwSize);
140 static void FreeSavedTemplate(BYTE*pDT) { delete [] pDT; }
141 DWORD GetSize();
142
143 private:
144 bool m_bExtended;
145 bool m_build_unicode;
146
147 DWORD m_dwHelpId; // Extended only
148
149 short m_sX;
150 short m_sY;
151 short m_sWidth;
152 short m_sHeight;
153 DWORD m_dwExtStyle;
154 DWORD m_dwStyle;
155
156 WINWCHAR *m_szMenu;
157 WINWCHAR *m_szClass;
158 WINWCHAR *m_szTitle;
159
160 // Only if DS_FONT style is set
161 short m_sFontSize;
162 short m_sFontWeight; // Extended only
163 BYTE m_bItalic; // Extended only
164 BYTE m_bCharset; // Extended only
165 WINWCHAR *m_szFont;
166
167 // For (en/de)coding Unicode
168 unsigned int m_uCodePage;
169
170 // Items vector
171 std::vector<DialogItemTemplate*> m_vItems;
172 };
173
174 #endif // !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)