├── .gitignore
├── LICENSE
├── README.md
└── VertexUI
├── VertexUI.ClickArea.h
├── VertexUI.Colors.h
├── VertexUI.Panel.h
├── VertexUI.min.h
├── framework.h
└── sign
/.gitignore:
--------------------------------------------------------------------------------
1 | build
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 CimiMoly
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # VertexUI
2 | 一个用于C++Win32桌面的简单界面API,正在开发
3 | 本UI库使用windowless框架,使用GDI(利用其轻的特点)作为绘图底层,目前已经完成封装双缓冲和抗锯齿.
4 |
5 | ### 用法 ###
6 | 请先创建一个Windows应用程序,并包含VertexUI界面库.
7 | ```C++
8 | #include "VertexUI/VertexUI.min.h"
9 | VertexUIInit;
10 | ```
11 | 在开始之前,请先在WM_CREATE中传出hWnd.
12 | ```C++
13 | case WM_CREATE:
14 | {
15 | GhWnd = hWnd;
16 | }
17 | ```
18 | VertexUI用Panel(面板)来定义界面,每一个Panel的点击域都是不同的,界面也是不同的,同时,Panel需要您自己创建.
19 | ```C++
20 | void Panel1(HWND hWnd, HDC hdc)
21 | {
22 | RECT rc;
23 | GetClientRect(hWnd, &rc);
24 | CreateFillArea(hWnd, hdc, RGB(20, 20, 20));//填充整个窗口
25 | CreateSimpleButton(hWnd, hdc, rc.left + 40, rc.top + 40, 140, 40, L"按钮");
26 | }
27 | void Panel2(HWND hWnd, HDC hdc)
28 | {
29 | RECT rc;
30 | GetClientRect(hWnd, &rc);
31 | CreateFillArea(hWnd, hdc, VERTEXUICOLOR_DARKNIGHT);
32 | TextPreDrawEx(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, L"文本", 40, 1, VERTEXUICOLOR_WHITE);
33 | CreateSimpleButton(hWnd, hdc, rc.right - 170, rc.bottom - 80, 150, 40, L"返回");
34 | }
35 | ```
36 | 同时,您需要为每一个按钮做好鼠标事件,一般这会在WM_MOUSEMOVE中实现,(如果您不需要hover,可以在WM_LBUTTONUP中调用ClickAreaEx,但我不建议这么做.)
37 | 使用SwitchPanel来切换面板.
38 | ```C++
39 | RUNFUN Button2()
40 | {
41 | SwitchPanel(L"Panel2");
42 | return 0;
43 | }
44 | RUNFUN Button1()
45 | {
46 | SwitchPanel(L"Panel2");
47 | return 0;
48 | }
49 | //鼠标事件
50 | int hState = 0;
51 | int AreaEvent(HWND hWnd, LPARAM lParam)
52 | {
53 |
54 | int val = 0;
55 | RECT winrc;
56 | GetClientRect(hWnd, &winrc);
57 |
58 | if (PanelID == L"Init" || PanelID == L"Panel1")
59 | {
60 | RECT rc = {};
61 | if ((GetAreaPtInfo(hWnd, rc.left + 40, rc.top + 40, 140, 40, rc, lParam)) == 1)
62 | {
63 | if (ClickMsg == 1)
64 | {
65 | ClickMsg = 0;
66 | Button1();
67 | }
68 | if (hState == 0)
69 | {
70 | HDC hdc = GetDC(hWnd);
71 | CreateRect(hWnd, hdc, rc.left, rc.bottom - 5, rc.right - rc.left, 5, VERTEXUICOLOR_GREENDEEPSEA);
72 | DeleteObject(hdc);
73 | ReleaseDC(hWnd, hdc);
74 | DeleteDC(hdc);
75 | hState = 1;
76 | }
77 | return 0;
78 | }
79 | else
80 | {
81 | if (hState == 1)
82 | {
83 | hState = 0;
84 | InvalidateRect(hWnd, &winrc, 0);
85 | }
86 | return 0;
87 | }
88 | }
89 | if (PanelID == L"Panel2")
90 | {
91 | RECT rc = {};
92 | if ((GetAreaPtInfo(hWnd, winrc.right - 170, winrc.bottom - 80, 150, 40, rc, lParam)) == 1)
93 | {
94 | if (ClickMsg == 1)
95 | {
96 | ClickMsg = 0;
97 | Button2();
98 | }
99 | if (hState == 0)
100 | {
101 | HDC hdc = GetDC(hWnd);
102 | //CreateRect(hWnd, hdc, x, rc.bottom - 2, rc.right - rc.left, 2, VERTEXUICOLOR_GREENDEEPSEA);
103 | CreateRect(hWnd, hdc, rc.left, rc.bottom - 5, rc.right - rc.left, 5, VERTEXUICOLOR_GREENDEEPSEA);
104 | DeleteObject(hdc);
105 | ReleaseDC(hWnd, hdc);
106 | DeleteDC(hdc);
107 | hState = 1;
108 | }
109 | return 0;
110 | }
111 | else
112 | {
113 | if (hState == 1)
114 | {
115 | hState = 0;
116 | InvalidateRect(hWnd, &winrc, 0);
117 | return 0;
118 | }
119 | }
120 | }
121 | if (PanelID != 0)
122 | {
123 |
124 | }
125 |
126 | return 0;
127 | }
128 | //WndProc中
129 | case WM_MOUSEMOVE:
130 | {
131 | AreaEvent(hWnd, lParam);
132 | break;
133 | }
134 | case WM_ERASEBKGND:
135 | {
136 | break; //不擦除背景以实现动画叠层和减小窗体拖动可能出现的闪烁,请在最大化窗体的时候InvalidateRect或者删除这段代码.
137 | }
138 | case WM_LBUTTONUP:
139 | {
140 | SnedClickEvent(hWnd, wParam, lParam); //发送Click,mousemove检测ClickMsg
141 | return 0;
142 | }
143 | ```
144 | 现在,总体布置已经ok啦!最后一步,只需要在WM_PAINT中相应每一个Panel的绘制就好啦!
145 | ```C++
146 | case WM_PAINT:
147 | {
148 | PAINTSTRUCT ps;
149 | HDC hdc = BeginPaint(hWnd, &ps);
150 | // 切换
151 | if (PanelID == L"Init")
152 | {
153 | CreatePanelByFlag(hWnd, hdc, Panel1);
154 | }
155 | if (PanelID == L"Panel2")
156 | {
157 | CreatePanelByFlag(hWnd, hdc, Panel2);
158 | }
159 | EndPaint(hWnd, &ps);
160 | break;
161 | }
162 | ```
163 | ### 感谢使用VertexUI. ###
164 |
--------------------------------------------------------------------------------
/VertexUI/VertexUI.ClickArea.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EnderMo/VertexUI/4d803b3a127d0b2068ef930d7bcec76220c9f7a9/VertexUI/VertexUI.ClickArea.h
--------------------------------------------------------------------------------
/VertexUI/VertexUI.Colors.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "framework.h"
3 |
4 | #define VERTEXUICOLOR_DARKEN RGB(20,20,20)
5 |
6 | #define VERTEXUICOLOR_TABDARKEN RGB(57, 62, 71)
7 |
8 | #define VERTEXUICOLOR_WHITE RGB(244,244,244)
9 |
10 | #define VERTEXUICOLOR_SEA RGB(45,137,239)
11 |
12 | #define VERTEXUICOLOR_DEEPSEA RGB(15,107,209)
13 |
14 | #define VERTEXUICOLOR_LAVENDER RGB(108,92,200)
15 |
16 | #define VERTEXUICOLOR_LAVENDER_ RGB(128,112,220)
17 |
18 | #define VERTEXUICOLOR_BLOOMLAVENDER RGB(158,142,250)
19 |
20 | #define VERTEXUICOLOR_GREENSEA RGB(26,188,156)
21 |
22 | #define VERTEXUICOLOR_GREENDEEPSEA RGB(4,138,106)
23 |
24 | #define VERTEXUICOLOR_DARKENX RGB(10,10,10)
25 |
26 | #define VERTEXUICOLOR_PEACHRED RGB(232,77,61)
27 |
28 | #define VERTEXUICOLOR_MIDNIGHT RGB(52, 57, 66)
29 |
30 | #define VERTEXUICOLOR_MIDNIGHTPLUS RGB(72, 77, 86)
31 |
32 | #define VERTEXUICOLOR_DARKNIGHT RGB(42, 47, 56)
33 |
34 | #define VERTEXUICOLOR_FOREST RGB(38,212,110)
35 |
36 | #define VERTEXUICOLOR_DAWN RGB(255,115,119)
37 |
38 | #define VERTEXUICOLOR_LDARK RGB(77,82,91)
39 |
40 | #define VERTEXUICOLOR_OTHER_GITHUB RGB(88,166,255)
41 |
42 | #define VERTEXUI_DARKEN RGB(20,20,20)
43 |
44 | #define VERTEXUI_WHITE RGB(244,244,244)
45 |
46 | #define VERTEXUI_GREENSEA RGB(26,188,156)
--------------------------------------------------------------------------------
/VertexUI/VertexUI.Panel.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | /*
3 | *
4 | * VertexUI PanelDrawingInterface
5 | *
6 | * VertexStudio 2021
7 | *
8 | */
9 | #include "framework.h"
10 | #include "VertexUI.Colors.h"
11 | #include
12 | #define VERTEXUI_FLAGS_ANIMATION 0
13 |
14 | #define VERTEXUI_FLAGS_NOANIMATION 1
15 |
16 | #define VERTEXUI_FLAGS_MEMDRAW 2
17 |
18 | #define VERTEXUI_FLAGS_CACHE 1
19 |
20 | #define VERTEXUI_DEVMODE
21 |
22 | #define RCWID (rc.right -rc.left)
23 |
24 | #define InitCtl(ctlname,x,y,cx,cy,fun,txt) {ctlname,x,y,cx,cy,fun,txt}
25 | namespace VertexUI
26 | {
27 | typedef void (DRAWPANEL)(HWND, HDC);
28 |
29 | typedef void (SDRAWPANEL)(HDC);
30 | typedef struct VERTEXUICTL {
31 | const wchar_t* CtlName;
32 | int x;
33 | int y;
34 | int sizex;
35 | int sizey;
36 | int (*runfun)() = 0;
37 | const wchar_t* Text;
38 | }VUICTL;
39 | typedef struct PanelHandleFun
40 | {
41 | HDC hdc;
42 | HDC hmdc;
43 | RECT rc;
44 | HBITMAP hpbp;
45 | HBITMAP hmbp;
46 | int x;
47 | int y;
48 | int cx;
49 | int cy;
50 | DRAWPANEL* exDraw;
51 | COLORREF c1;
52 | COLORREF c2;
53 | HWND h;
54 | };
55 | typedef struct PanelDCCache
56 | {
57 | HDC inhdc;//兼容VertexUI内建
58 | HDC hdc;
59 | HDC hMemDC;
60 | };
61 | int dystate = 1;
62 | const wchar_t* ListPanel = L"ListPanel";
63 | const wchar_t* PanelID = L"Init";
64 | const wchar_t* PrevPanelID = L"Init";
65 | const wchar_t* ButtonText = L"Button";
66 | int g_hoverstate = 0;
67 | namespace Panel
68 | {
69 | //CreatePanel only passed in parameters below:(HWND,HDC).
70 |
71 | //It convert (x,y,sizex,sizey) into RECT {x,y,x+sizex,y+sizey}.
72 | void RectTypeConvert(RECT& rc, int x, int y, int sizex, int sizey)
73 | {
74 | rc = { x,y,x + sizex,y + sizey };
75 | }
76 |
77 | //DrawRect
78 | void CreateRect(HWND h, HDC hdc, int x, int y, int sizex, int sizey, COLORREF cl)
79 | {
80 | RECT mRc;
81 | RectTypeConvert(mRc, x, y, sizex, sizey);
82 | HBRUSH hb = CreateSolidBrush(cl);
83 | HBRUSH bhb = (HBRUSH)SelectObject(hdc, hb);
84 | SelectObject(hdc, hb);
85 | FillRect(hdc, &mRc, hb);
86 | SelectObject(hdc, bhb);
87 | DeleteObject(hb);
88 | }
89 |
90 | //Fill the whole window
91 | void CreateFillArea(HWND h, HDC hdc, COLORREF cl)
92 | {
93 | RECT Rc;
94 | GetClientRect(h, &Rc);
95 | RectTypeConvert(Rc, Rc.left, Rc.top, Rc.right, Rc.bottom);
96 | HBRUSH hb = CreateSolidBrush(cl);
97 | HBRUSH bhb = (HBRUSH)SelectObject(hdc, hb);
98 | SelectObject(hdc, hb);
99 | FillRect(hdc, &Rc, hb);
100 | SelectObject(hdc, bhb);
101 | DeleteObject(hb);
102 | }
103 |
104 | //Text
105 | void TextPreDraw(HDC hdc, int x, int y, int sizex, int sizey, const wchar_t* txt, COLORREF cl)
106 | {
107 | RECT rc;
108 | RectTypeConvert(rc, x, y, sizex, sizey);
109 | LOGFONT lf;
110 | HFONT hFont = 0;
111 | SetTextColor(hdc, cl);
112 | SetBkMode(hdc, TRANSPARENT);
113 | if (hFont == 0)
114 | {
115 | memset(&lf, 0, sizeof(LOGFONT));
116 | lf.lfHeight = -18;
117 | wcscpy_s(lf.lfFaceName, L"Segoe UI");
118 | hFont = CreateFontIndirect(&lf); // create the font
119 | }
120 | HFONT old = (HFONT)SelectObject(hdc, hFont);
121 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
122 | DeleteObject(hFont);
123 | SelectObject(hdc, old);
124 | }
125 |
126 | //Flags: 0.ToLeft 1.Center
127 | void TextPreDrawEx(HDC hdc, int x, int y, int sizex, int sizey, const wchar_t* txt, int sz, int flag, COLORREF cl)
128 | {
129 | RECT rc;
130 | RectTypeConvert(rc, x, y, sizex, sizey);
131 | LOGFONT lf;
132 | HFONT hFont = 0;
133 | SetTextColor(hdc, cl);
134 | SetBkMode(hdc, TRANSPARENT);
135 | if (hFont == 0)
136 | {
137 | memset(&lf, 0, sizeof(LOGFONT));
138 | lf.lfHeight = -sz;
139 | wcscpy_s(lf.lfFaceName, L"Segoe UI");
140 | hFont = CreateFontIndirect(&lf); // create the font
141 | }
142 | HFONT old = (HFONT)SelectObject(hdc, hFont);
143 | if (flag == 0)
144 | {
145 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE | DT_VCENTER);
146 | }
147 | if (flag == 1)
148 | {
149 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
150 | }
151 | if (flag == 2)
152 | {
153 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE);
154 | }
155 | if (flag == 3)
156 | {
157 | DrawText(hdc, txt, wcslen(txt), &rc, DT_CENTER | DT_VCENTER);
158 | }
159 | DeleteObject(hFont);
160 | SelectObject(hdc, old);
161 | }
162 | void _TextPreDrawEx(HDC hdc, int x, int y, int sizex, int sizey, const wchar_t* txt, int sz, const wchar_t* Font, int flag, COLORREF cl)
163 | {
164 | RECT rc;
165 | RectTypeConvert(rc, x, y, sizex, sizey);
166 | LOGFONT lf;
167 | HFONT hFont = 0;
168 | SetTextColor(hdc, cl);
169 | SetBkMode(hdc, TRANSPARENT);
170 | if (hFont == 0)
171 | {
172 | memset(&lf, 0, sizeof(LOGFONT));
173 | lf.lfHeight = -sz;
174 | lf.lfQuality = ANTIALIASED_QUALITY;
175 | wcscpy_s(lf.lfFaceName, Font);
176 | hFont = CreateFontIndirect(&lf); // create the font
177 | }
178 | HFONT old = (HFONT)SelectObject(hdc, hFont);
179 | if (flag == 0)
180 | {
181 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE | DT_VCENTER);
182 | }
183 | if (flag == 1)
184 | {
185 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
186 | }
187 | if (flag == 2)
188 | {
189 | DrawText(hdc, txt, wcslen(txt), &rc, DT_SINGLELINE);
190 | }
191 | if (flag == 3)
192 | {
193 | DrawText(hdc, txt, wcslen(txt), &rc, DT_CENTER | DT_VCENTER);
194 | }
195 | if (flag == 4)
196 | {
197 | DrawText(hdc, txt, wcslen(txt), &rc, DT_VCENTER);
198 | }
199 | DeleteObject(hFont);
200 | SelectObject(hdc, old);
201 | }
202 | //Only straight Line
203 | void PanelDrawSTLine(HDC pDC, int X0, int Y0, int X1, int Y1, COLORREF clrLine)
204 | {
205 | if (Y0 > Y1) { int Temp = Y0; Y0 = Y1; Y1 = Temp; Temp = X0; X0 = X1; X1 = Temp; }SetPixel(pDC, X0, Y0, clrLine);
206 | int XDir, DeltaX = X1 - X0; if (DeltaX >= 0) { XDir = 1; }
207 | else { XDir = -1; DeltaX = 0 - DeltaX; }int DeltaY = Y1 - Y0;
208 | if (DeltaY == 0) { while (DeltaX-- != 0) { X0 += XDir; SetPixel(pDC, X0, Y0, clrLine); }return; }
209 | if (DeltaX == 0) { do { Y0++; SetPixel(pDC, X0, Y0, clrLine); } while (--DeltaY != 0); return; }
210 | if (DeltaX == DeltaY) { do { X0 += XDir; Y0++; SetPixel(pDC, X0, Y0, clrLine); } while (--DeltaY != 0); return; }SetPixel(pDC, X1, Y1, clrLine);
211 | }
212 |
213 | //Frame
214 |
215 | void PanelDrawOutFrame(HWND h, HDC hdc, COLORREF cl)
216 | {
217 | RECT rc;
218 | GetClientRect(h, &rc);
219 | PanelDrawSTLine(hdc, 0, 0, rc.right, 0, cl);
220 | PanelDrawSTLine(hdc, 0, 0, 0, rc.bottom, cl);
221 | PanelDrawSTLine(hdc, 0, rc.bottom - 1, rc.right - rc.left, rc.bottom - 1, cl);
222 | PanelDrawSTLine(hdc, rc.right - 1, 0, rc.right - 1, rc.bottom - 1, cl);
223 | }
224 | void PanelDrawCloseBtn(HWND h, HDC hdc, int x, int y, int x1, int y1, int inframepos, COLORREF cl)
225 | {
226 | RECT rc;
227 | RectTypeConvert(rc, x, y, x1, y1);
228 | HPEN hpen;
229 | hpen = CreatePen(PS_SOLID, 1, cl);
230 | HPEN prhp = (HPEN)SelectObject(hdc, hpen);
231 | SelectObject(hdc, hpen);
232 | MoveToEx(hdc, rc.left + inframepos + 1, rc.top + inframepos + 1, NULL);
233 | LineTo(hdc, rc.right - inframepos, rc.bottom - inframepos);
234 |
235 | MoveToEx(hdc, rc.left + inframepos + 1, rc.bottom - inframepos - 1, NULL);
236 | LineTo(hdc, rc.right - inframepos, rc.top + inframepos);
237 | DeleteObject(hpen);
238 | SelectObject(hdc, prhp);
239 | }
240 | void PanelDrawDisplayBtn(HWND h, HDC hdc, int x, int y, int x1, int y1, int inframepos, int mdpos, COLORREF cl)
241 | {
242 | RECT rc;
243 | RectTypeConvert(rc, x, y, x1, y1);
244 | HPEN hpen;
245 | hpen = CreatePen(PS_SOLID, 1, cl);
246 | HPEN prhp = (HPEN)SelectObject(hdc, hpen);
247 | SelectObject(hdc, hpen);
248 | MoveToEx(hdc, rc.left + inframepos + 1, rc.top + inframepos + 1 + mdpos, NULL);
249 | LineTo(hdc, rc.left + (x1 / 2) - inframepos, rc.top + (y1 / 2) - inframepos + mdpos);
250 | MoveToEx(hdc, rc.left + (x1 / 2) + (x1 / 4) - 1 - inframepos - 1, rc.top + inframepos + 1 + mdpos, NULL);
251 | LineTo(hdc, rc.right - (x1 / 2) - inframepos - 1, rc.bottom - (y1 / 2) - inframepos + mdpos);
252 | //MoveToEx(hdc, rc.left + inframepos + 1, rc.bottom - inframepos - 1, NULL);
253 | //LineTo(hdc, rc.right - inframepos, rc.top + inframepos);
254 | DeleteObject(hpen);
255 | SelectObject(hdc, prhp);
256 | }
257 | //Button
258 | void CreateSimpleButton(HWND h, HDC hdc, int x, int y, int sizex, int sizey, const wchar_t* s)
259 | {
260 | CreateRect(h, hdc, x, y, sizex, sizey, VERTEXUI_GREENSEA);
261 | TextPreDraw(hdc, x, y, sizex, sizey, s, VERTEXUI_WHITE);
262 | }
263 |
264 | //Custom Color Button
265 | void CreateSimpleButtonEx(HWND h, HDC hdc, int x, int y, int sizex, int sizey, COLORREF cl, const wchar_t* s,int ctsz = 0)
266 | {
267 | int tsz = 0;
268 | CreateRect(h, hdc, x, y, sizex, sizey, cl);
269 | if (sizey > 23)
270 | {
271 | tsz = 18;
272 | }
273 | else
274 | {
275 | tsz = 16;
276 | }
277 | if (ctsz != 0)tsz = ctsz;
278 | TextPreDrawEx(hdc, x, y, sizex, sizey, s, tsz, 1, VERTEXUI_WHITE);
279 | }
280 |
281 | void DrawRoundRect(HDC hDrawingDC, int x, int y, int cx, int cy, int cornersize, COLORREF cl)
282 | {
283 | HPEN hGreenPen = ::CreatePen(PS_SOLID, 2, cl);
284 |
285 | HPEN hOldPen = (HPEN)::GetCurrentObject(hDrawingDC, OBJ_PEN);
286 | HBRUSH hOldBrush = (HBRUSH)::GetCurrentObject(hDrawingDC, OBJ_BRUSH);
287 |
288 | ::SelectObject(hDrawingDC, hGreenPen);
289 | ::SelectObject(hDrawingDC, (HBRUSH)CreateSolidBrush(cl));
290 | ::RoundRect(hDrawingDC, x, y, x + cx, y + cy, cornersize, cornersize);
291 |
292 |
293 | ::SelectObject(hDrawingDC, hOldBrush);
294 | ::SelectObject(hDrawingDC, hOldPen);
295 | ::DeleteObject(hGreenPen);
296 | }
297 |
298 | void CreateRoundButton(HDC hdc, int x, int y, int cx, int cy, int cornersize, const wchar_t* txt, COLORREF cl)
299 | {
300 | DrawRoundRect(hdc, x, y, cx, cy, cornersize, cl);
301 | TextPreDraw(hdc, x, y, cx, cy, txt, VERTEXUICOLOR_WHITE);
302 | }
303 | void CreateRoundButtonEx(HDC hdc, int x, int y, int cx, int cy, int cornersize, const wchar_t* txt, int txtsz, COLORREF cl)
304 | {
305 | DrawRoundRect(hdc, x, y, cx, cy, cornersize, cl);
306 | TextPreDrawEx(hdc, x, y, cx, cy, txt, txtsz, 1, VERTEXUICOLOR_WHITE);
307 | }
308 | void DrawPloygon(HDC hDrawingDC, const POINT* pt, int ang, COLORREF cl)
309 | {
310 | HPEN hGreenPen = ::CreatePen(PS_SOLID, 2, cl);
311 |
312 | HPEN hOldPen = (HPEN)::GetCurrentObject(hDrawingDC, OBJ_PEN);
313 | HBRUSH hOldBrush = (HBRUSH)::GetCurrentObject(hDrawingDC, OBJ_BRUSH);
314 |
315 | ::SelectObject(hDrawingDC, hGreenPen);
316 | ::SelectObject(hDrawingDC, (HBRUSH)CreateSolidBrush(cl));
317 | Polygon(hDrawingDC, pt, ang);
318 |
319 |
320 | ::SelectObject(hDrawingDC, hOldBrush);
321 | ::SelectObject(hDrawingDC, hOldPen);
322 | ::DeleteObject(hGreenPen);
323 | }
324 | void CreateSTab(HDC hdc, int x, int y, bool isopen, int scale = 1)
325 | {
326 | if (isopen == false)
327 | {
328 | DrawRoundRect(hdc, x * scale, y * scale, 50 * scale, 20 * scale, 15 * scale, VERTEXUICOLOR_MIDNIGHTPLUS);
329 | DrawRoundRect(hdc, x * scale, y * scale, 20 * scale, 20 * scale, 15 * scale, VERTEXUICOLOR_GREENSEA);
330 | }
331 | if (isopen == true)
332 | {
333 | DrawRoundRect(hdc, x * scale, y * scale, 50 * scale, 20 * scale, 15 * scale, VERTEXUICOLOR_MIDNIGHTPLUS);
334 | DrawRoundRect(hdc, (x + 30) * scale, y * scale, 20 * scale, 20 * scale, 15 * scale, VERTEXUICOLOR_GREENSEA);
335 | }
336 | }
337 | void CreateCtl(HWND hWnd,HDC hdc,VUICTL vctl)
338 | {
339 | if (vctl.CtlName == L"Button")
340 | {
341 | CreateSimpleButton(hWnd, hdc, vctl.x, vctl.y, vctl.sizex, vctl.sizey, vctl.Text);
342 | }
343 | }
344 | HBITMAP hwndToHbitmap(HWND hwnd,HDC hDC)
345 | {
346 |
347 | //HDC hDC = GetDC(hwnd);
348 |
349 |
350 | RECT rect;
351 |
352 | GetClientRect(hwnd, &rect);
353 |
354 |
355 | HDC hDCMem = CreateCompatibleDC(hDC);
356 |
357 |
358 | HBITMAP hBitMap = CreateCompatibleBitmap(hDC, rect.right, rect.bottom);
359 |
360 |
361 | HBITMAP hOldMap = (HBITMAP)SelectObject(hDCMem, hBitMap);
362 |
363 |
364 | BitBlt(hDCMem, 0, 0, rect.right, rect.bottom, hDC, 0, 0, SRCCOPY);
365 | hBitMap = (HBITMAP)SelectObject(hDCMem, hOldMap);
366 | return hBitMap;
367 | }
368 | HDC in_ghdc = 0;
369 | //Create a Drawing Panel.
370 | void _CreatePanel(HWND h, HDC hdc, DRAWPANEL DrawFun)
371 | {
372 | HDC hMemDC;
373 | HBITMAP hBmpMem;
374 | HBITMAP hPreBmp;
375 | RECT rc;
376 | GetClientRect(h, &rc);
377 | hMemDC = CreateCompatibleDC(hdc);
378 |
379 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
380 |
381 | hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
382 | //On hMemDC.
383 | DrawFun(h, hMemDC);
384 |
385 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
386 |
387 | SelectObject(hMemDC, hPreBmp);
388 |
389 | DeleteObject(hBmpMem);
390 |
391 | DeleteDC(hMemDC);
392 |
393 |
394 | }
395 |
396 | //
397 | void CreatePanel(HWND h, HDC hdc, DRAWPANEL DrawFun)
398 | {
399 | HDC hMemDC;
400 | HBITMAP hBmpMem;
401 | HBITMAP hPreBmp;
402 | RECT rc;
403 | GetClientRect(h, &rc);
404 | hMemDC = CreateCompatibleDC(hdc);
405 |
406 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
407 |
408 | hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
409 | //On hMemDC.
410 | DrawFun(h, hMemDC);
411 |
412 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
413 |
414 |
415 | SelectObject(hMemDC, hPreBmp);
416 |
417 |
418 | DeleteObject(hBmpMem);
419 |
420 | DeleteDC(hMemDC);
421 | }
422 |
423 | //
424 |
425 |
426 | void SetPanelID(const wchar_t* id)
427 | {
428 | PrevPanelID = PanelID;
429 | PanelID = id;
430 | }
431 | void SwitchPanel(const wchar_t* ID)
432 | {
433 | SetPanelID(ID);
434 | RECT rc;
435 | GetClientRect(GhWnd, &rc);
436 | InvalidateRect(GhWnd, &rc, 1);
437 | }
438 | void RefreshWindow(HWND h)
439 | {
440 | RECT rc;
441 | GetClientRect(h, &rc);
442 | dystate = 1;
443 | InvalidateRect(h, &rc, 0);
444 | }
445 | }
446 | //--
447 |
448 |
449 | }
450 |
451 | namespace VertexUI::Panel
452 | {
453 | void XSleep(UINT Delay_ms)
454 | {
455 | DWORD dwTick = GetTickCount64() + Delay_ms;
456 | while (GetTickCount64() < dwTick)
457 | {
458 | MSG msg;
459 | if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
460 | {
461 | if (msg.message == WM_QUIT) break;
462 | TranslateMessage(&msg);
463 | DispatchMessage(&msg);
464 | }
465 | Sleep(0);
466 | }
467 | }
468 |
469 | int anistat = 0;
470 | DWORD WINAPI VUIPAnimationThread(LPVOID pf)
471 | {
472 | PanelHandleFun* p = (PanelHandleFun*)pf;
473 | HDC hdc = p->hdc;
474 | HDC hMemDC = p->hmdc;
475 | RECT rc = p->rc;
476 | HBITMAP hPreBmp = p->hpbp;
477 | HBITMAP hBmpMem = p->hmbp;
478 | #ifndef _MINANIMATION
479 | BitBlt(hdc, rc.right - 2, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
480 | XSleep(8);
481 | BitBlt(hdc, rc.right - 5, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
482 | XSleep(8);
483 | BitBlt(hdc, rc.right - 18, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
484 | XSleep(8);
485 | BitBlt(hdc, rc.right - 36, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
486 | XSleep(8);
487 | BitBlt(hdc, rc.right - 59, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
488 | XSleep(8);
489 | BitBlt(hdc, rc.right - 100, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
490 | XSleep(8);
491 | BitBlt(hdc, rc.right - 158, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
492 | XSleep(8);
493 | BitBlt(hdc, rc.right - 213, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
494 | XSleep(8);
495 | BitBlt(hdc, rc.right - 300, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
496 | XSleep(8);
497 | BitBlt(hdc, rc.right - 350, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
498 | XSleep(8);
499 | BitBlt(hdc, rc.right - 400, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
500 | XSleep(8);
501 | BitBlt(hdc, rc.right - 450, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
502 | XSleep(8);
503 | BitBlt(hdc, rc.right - 530, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
504 | XSleep(8);
505 | #endif
506 | BitBlt(hdc, 300, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
507 | #ifdef _MINANIMATION
508 | XSleep(10);
509 | BitBlt(hdc, 295, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
510 | XSleep(10);
511 | BitBlt(hdc, 282, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
512 | #endif
513 | XSleep(8);
514 | BitBlt(hdc, 262, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
515 | XSleep(8);
516 | BitBlt(hdc, 243, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
517 | XSleep(8);
518 | BitBlt(hdc, 214, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
519 | XSleep(8);
520 | BitBlt(hdc, 171, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
521 | XSleep(8);
522 | BitBlt(hdc, 116, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
523 | XSleep(8);
524 | BitBlt(hdc, 71, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
525 | XSleep(8);
526 | BitBlt(hdc, 41, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
527 | XSleep(8);
528 | BitBlt(hdc, 29, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
529 | XSleep(8);
530 | BitBlt(hdc, 17, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
531 | XSleep(8);
532 | BitBlt(hdc, 11, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
533 | XSleep(8);
534 | BitBlt(hdc, 8, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
535 | XSleep(8);
536 | BitBlt(hdc, 5, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
537 | XSleep(8);
538 | BitBlt(hdc, 3, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
539 | XSleep(8);
540 | BitBlt(hdc, 2, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
541 | XSleep(8);
542 | BitBlt(hdc, 1, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
543 | XSleep(8);
544 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
545 |
546 | SelectObject(hMemDC, hPreBmp);
547 |
548 |
549 | DeleteObject(hBmpMem);
550 |
551 | DeleteDC(hMemDC);
552 | return 0;
553 | }
554 | int CreatePanelAnimation(HWND h, HDC hdc, DRAWPANEL DrawFun)
555 | {
556 | HDC hMemDC;
557 | HBITMAP hBmpMem;
558 | HBITMAP hPreBmp;
559 | RECT rc;
560 | GetClientRect(h, &rc);
561 | //InvalidateRect(h, &rc, 1);
562 | hMemDC = CreateCompatibleDC(hdc);
563 |
564 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
565 |
566 | hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
567 | //On hMemDC.
568 | DrawFun(h, hMemDC);
569 | if (anistat == 1)
570 | {
571 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
572 | anistat = 0;
573 | return -1;
574 | }
575 | if (anistat == 0)
576 | {
577 | PanelHandleFun p{};
578 | p.hdc = hdc;
579 | p.hmdc = hMemDC;
580 | p.rc = rc;
581 | p.hpbp = hPreBmp;
582 | p.hmbp = hBmpMem;
583 | HANDLE thread = CreateThread(NULL, NULL, VUIPAnimationThread, &p, 0, 0);
584 | if (thread)
585 | {
586 | WaitForSingleObject(thread, INFINITE);
587 | CloseHandle(thread);
588 | }
589 |
590 | anistat = 1;
591 | return -1;
592 | }
593 |
594 | SelectObject(hMemDC, hPreBmp);
595 |
596 |
597 | DeleteObject(hBmpMem);
598 |
599 | DeleteDC(hMemDC);
600 |
601 | return 0;
602 | }
603 | int _VertexUI_PanelFlag = 0;
604 | void CreatePanelByFlag(HWND h, HDC hdc, DRAWPANEL DrawFun, int Flag = 0)
605 | {
606 |
607 | //On hMemDC.
608 | if (PanelID == PrevPanelID)
609 | {
610 | _CreatePanel(h, hdc, DrawFun);
611 | anistat = 0;
612 | }
613 | if (PanelID != PrevPanelID)
614 | {
615 | if (Flag == 0)
616 | {
617 | CreatePanelAnimation(h, hdc, DrawFun);
618 | }
619 | if (Flag == 1)
620 | {
621 | _CreatePanel(h, hdc, DrawFun);
622 | }
623 | PrevPanelID = PanelID;
624 | anistat = 0;
625 | }
626 | }
627 | HDC inhdc;
628 |
629 | HBITMAP inbmp;
630 | HBITMAP CopyBitmap(HBITMAP hbm) {
631 | HDC hdcSrc = CreateCompatibleDC(NULL);
632 | HDC hdcDst = CreateCompatibleDC(NULL);
633 | HBITMAP hbmOld, hbmOld2, hbmNew;
634 | BITMAP bm;
635 | GetObject(hbm, sizeof(bm), &bm);
636 | hbmOld = (HBITMAP)SelectObject(hdcSrc, hbm);
637 | hbmNew = CreateBitmap(bm.bmWidth, bm.bmHeight, bm.bmPlanes,
638 | bm.bmBitsPixel,
639 | NULL);
640 | hbmOld2 = (HBITMAP)SelectObject(hdcDst, hbmNew);
641 | BitBlt(hdcDst, 0, 0, bm.bmWidth, bm.bmHeight, hdcSrc, 0, 0, SRCCOPY);
642 | SelectObject(hdcSrc, hbmOld);
643 | SelectObject(hdcDst, hbmOld2);
644 | DeleteDC(hdcSrc);
645 | DeleteDC(hdcDst);
646 | return hbmNew;
647 | }
648 | int gindc;
649 | void CreatePanelDynamic(HWND h, HDC hdc, DRAWPANEL DrawFun, int Flag = 0, int updateFlag = 0)
650 | {
651 |
652 | //On hMemDC.
653 | if (PanelID == PrevPanelID)
654 | {
655 | if (dystate == 0)
656 | {
657 | //BitBlt
658 | RECT rc;
659 | GetClientRect(h, &rc);
660 | HDC hMemDC;
661 | HBITMAP hBmpMem;
662 | HBITMAP hPreBmp;
663 |
664 | hMemDC = CreateCompatibleDC(hdc);
665 |
666 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
667 |
668 | hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
669 | //On hMemDC.
670 |
671 | BitBlt(hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, inhdc, 0, 0, SRCCOPY);
672 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
673 |
674 |
675 | SelectObject(hMemDC, hPreBmp);
676 |
677 |
678 | DeleteObject(hBmpMem);
679 |
680 | DeleteDC(hMemDC);
681 | }
682 | if (dystate == 1) //First time
683 | {
684 |
685 | HBITMAP hBmpMem;
686 | HBITMAP hPreBmp;
687 | RECT rc;
688 | GetClientRect(h, &rc);
689 | inhdc = CreateCompatibleDC(hdc);
690 |
691 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
692 |
693 | hPreBmp = (HBITMAP)SelectObject(inhdc, hBmpMem);
694 | //On hMemDC.
695 | DrawFun(h, inhdc);
696 |
697 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, inhdc, 0, 0, SRCCOPY);
698 |
699 |
700 | //SelectObject(inhdc, hPreBmp);
701 |
702 |
703 | DeleteObject(hBmpMem);
704 | dystate = 0;
705 | }
706 | anistat = 0;
707 | }
708 | if (PanelID != PrevPanelID)
709 | {
710 | if (Flag == 0)
711 | {
712 | CreatePanelAnimation(h, hdc, DrawFun);
713 | }
714 | if (Flag == 1)
715 | {
716 | _CreatePanel(h, hdc, DrawFun);
717 | }
718 | if (updateFlag == 0)
719 | {
720 | dystate = 1;
721 | }
722 | PrevPanelID = PanelID;
723 | anistat = 0;
724 | }
725 | }
726 | void CreateButton(HWND hWnd, HDC hdc, int x, int y, int sizex, int sizey, int cid, const wchar_t* CTLTXT)
727 | {
728 | //VERTEXUICTL btn;
729 | //btn.Text = L"114514";
730 | CreateSimpleButton(hWnd, hdc, x, y, sizex, sizey, CTLTXT);
731 | }
732 |
733 |
734 | void DrawGradient(HDC pDC, RECT rRect, COLORREF crFrom, COLORREF crTo)
735 | {
736 |
737 | int iHeight = rRect.bottom - rRect.top;
738 |
739 | int iWidth = rRect.right - 1;
740 |
741 | //
742 |
743 | int iR = GetRValue(crFrom);
744 |
745 | int iG = GetGValue(crFrom);
746 |
747 | int iB = GetBValue(crFrom);
748 |
749 | //
750 |
751 | int idR = (256 * (GetRValue(crTo) - iR)) / iWidth;
752 |
753 | int idG = (256 * (GetGValue(crTo) - iG)) / iWidth;
754 |
755 | int idB = (256 * (GetBValue(crTo) - iB)) / iWidth;
756 |
757 |
758 |
759 | iR *= 256;
760 |
761 | iG *= 256;
762 |
763 | iB *= 256;
764 |
765 | // ->
766 |
767 | for (int i = rRect.left; i <= iWidth; i++, iR += idR, iG += idG, iB += idB)
768 | {
769 | RECT rcx;
770 | RectTypeConvert(rcx, i, rRect.top, 1, iHeight);
771 | HBRUSH hbr = CreateSolidBrush(RGB(iR / 256, iG / 256, iB / 256));
772 | HBRUSH hOld = (HBRUSH)SelectObject(pDC, hbr);
773 | FillRect(pDC, &rcx, hbr);
774 | DeleteObject(hbr);
775 | SelectObject(pDC, hOld);
776 | }
777 |
778 | }
779 | void DrawGradientEx(HDC pDC, int x, int y, int cx, int cy, COLORREF crFrom, COLORREF crTo)
780 | {
781 |
782 | int iHeight = cy;
783 |
784 | int iWidth = cx;
785 |
786 | //
787 |
788 | int iR = GetRValue(crFrom);
789 |
790 | int iG = GetGValue(crFrom);
791 |
792 | int iB = GetBValue(crFrom);
793 |
794 | //
795 |
796 | int idR = (256 * (GetRValue(crTo) - iR)) / iWidth;
797 |
798 | int idG = (256 * (GetGValue(crTo) - iG)) / iWidth;
799 |
800 | int idB = (256 * (GetBValue(crTo) - iB)) / iWidth;
801 |
802 |
803 |
804 | iR *= 256;
805 |
806 | iG *= 256;
807 |
808 | iB *= 256;
809 |
810 | // ->
811 |
812 | for (int i = x; i <= iWidth; i++, iR += idR, iG += idG, iB += idB)
813 | {
814 | RECT rcx;
815 | RectTypeConvert(rcx, i, y, 1, iHeight);
816 | HBRUSH hbr = CreateSolidBrush(RGB(iR / 256, iG / 256, iB / 256));
817 | HBRUSH hOld = (HBRUSH)SelectObject(pDC, hbr);
818 | FillRect(pDC, &rcx, hbr);
819 | DeleteObject(hbr);
820 | SelectObject(pDC, hOld);
821 | }
822 |
823 | }
824 |
825 |
826 | int in_test()
827 | {
828 | return 0;
829 | }
830 | typedef struct VERTEXUILISTPANEL
831 | {
832 | typedef int RUNFUN;
833 | std::vectorlisttxt = { 128,(L"") };
834 | std::vectorlistclick = { 128,(in_test) };
835 | COLORREF PanelBkColor = VERTEXUICOLOR_DARKNIGHT;
836 |
837 | }tagVertexUIList;
838 |
839 | typedef void (DRAWLISTPANEL)(HWND, HDC, VERTEXUILISTPANEL);
840 | void _VUIListPanel(HWND hWnd, HDC hdc, VERTEXUILISTPANEL vlp)
841 | {
842 | RECT rc;
843 | GetClientRect(hWnd, &rc);
844 | int tsz = 40;
845 | CreateFillArea(hWnd, hdc, vlp.PanelBkColor);
846 | for (int i = 1; i <= 128; i++)
847 | {
848 | if (vlp.listtxt[i] == L"")
849 | {
850 | break;
851 | }
852 |
853 | CreateRect(hWnd, hdc, 40, i * 60 + tsz, 512, 40, VERTEXUICOLOR_MIDNIGHTPLUS);
854 | TextPreDrawEx(hdc, 50, i * 60 + tsz + 5, 512, 24, vlp.listtxt[i], 20, 0, VERTEXUICOLOR_WHITE);
855 | }
856 | CreateRect(hWnd, hdc, 1, tsz, rc.right - rc.left, 40, RGB(30, 35, 44));
857 | CreateSimpleButtonEx(hWnd, hdc, 1, tsz, 40, 40, VERTEXUICOLOR_GREENSEA, L"<", 30);
858 | }
859 | tagVertexUIList VertexUIList;
860 | void _CreateListPanel(HWND h, HDC hdc, VERTEXUILISTPANEL vlp, DRAWPANEL exDraw = 0)
861 | {
862 | HDC hMemDC;
863 | HBITMAP hBmpMem;
864 | HBITMAP hPreBmp;
865 | RECT rc;
866 | GetClientRect(h, &rc);
867 | hMemDC = CreateCompatibleDC(hdc);
868 |
869 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
870 |
871 | hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
872 | //On hMemDC.
873 |
874 | _VUIListPanel(h, hMemDC, vlp);
875 | if (exDraw != 0)
876 | {
877 | exDraw(h, hMemDC);
878 | }
879 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
880 |
881 |
882 | SelectObject(hMemDC, hPreBmp);
883 |
884 |
885 | DeleteObject(hBmpMem);
886 |
887 | DeleteDC(hMemDC);
888 | }
889 | int _CreateListPanelAnimation(HWND h, HDC hdc, VERTEXUILISTPANEL vlp, DRAWPANEL exDraw = 0)
890 | {
891 | HDC hMemDC;
892 | HBITMAP hBmpMem;
893 | HBITMAP hPreBmp;
894 | RECT rc;
895 | GetClientRect(h, &rc);
896 | //InvalidateRect(h, &rc, 1);
897 | hMemDC = CreateCompatibleDC(hdc);
898 |
899 | hBmpMem = CreateCompatibleBitmap(hdc, rc.right - rc.left, rc.bottom - rc.top);
900 |
901 | hPreBmp = (HBITMAP)SelectObject(hMemDC, hBmpMem);
902 | //On hMemDC.
903 | _VUIListPanel(h, hMemDC, vlp);
904 | if (exDraw != 0)
905 | {
906 | exDraw(h, hMemDC);
907 | }
908 |
909 | if (anistat == 1)
910 | {
911 | BitBlt(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, SRCCOPY);
912 | anistat = 0;
913 | return -1;
914 | }
915 | if (anistat == 0)
916 | {
917 | BLENDFUNCTION bf = { 0 };
918 | bf.BlendOp = AC_SRC_OVER;
919 | bf.BlendFlags = 0;
920 | bf.SourceConstantAlpha = 1;
921 | bf.AlphaFormat = 0;
922 | Sleep(10);
923 | bf.SourceConstantAlpha = 10;
924 | AlphaBlend(hdc, 40, 40, rc.right - rc.left - 40 * 2, rc.bottom - rc.top - 40 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
925 | Sleep(10);
926 | bf.SourceConstantAlpha = 20;
927 | AlphaBlend(hdc, 35, 35, rc.right - rc.left - 35 * 2, rc.bottom - rc.top - 35 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
928 | Sleep(10);
929 | bf.SourceConstantAlpha = 30;
930 | AlphaBlend(hdc, 30, 30, rc.right - rc.left - 30 * 2, rc.bottom - rc.top - 30 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
931 | Sleep(10);
932 | bf.SourceConstantAlpha = 40;
933 | AlphaBlend(hdc, 25, 25, rc.right - rc.left - 25 * 2, rc.bottom - rc.top - 25 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
934 | Sleep(10);
935 | bf.SourceConstantAlpha = 55;
936 | AlphaBlend(hdc, 20, 20, rc.right - rc.left - 20 * 2, rc.bottom - rc.top - 20 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
937 | Sleep(10);
938 | bf.SourceConstantAlpha = 67;
939 | AlphaBlend(hdc, 16, 16, rc.right - rc.left - 16 * 2, rc.bottom - rc.top - 16 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
940 | Sleep(10);
941 | bf.SourceConstantAlpha = 91;
942 | AlphaBlend(hdc, 13, 13, rc.right - rc.left - 13 * 2, rc.bottom - rc.top - 13 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
943 | Sleep(10);
944 | bf.SourceConstantAlpha = 110;
945 | AlphaBlend(hdc, 10, 10, rc.right - rc.left - 10 * 2, rc.bottom - rc.top - 10 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
946 | Sleep(10);
947 | bf.SourceConstantAlpha = 150;
948 | AlphaBlend(hdc, 7, 7, rc.right - rc.left - 7 * 2, rc.bottom - rc.top - 7 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
949 | Sleep(10);
950 | bf.SourceConstantAlpha = 210;
951 | AlphaBlend(hdc, 5, 5, rc.right - rc.left - 5 * 2, rc.bottom - rc.top - 5 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
952 | Sleep(10);
953 | bf.SourceConstantAlpha = 230;
954 | AlphaBlend(hdc, 3, 3, rc.right - rc.left - 3 * 2, rc.bottom - rc.top - 3 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
955 | Sleep(10);
956 | bf.SourceConstantAlpha = 240;
957 | AlphaBlend(hdc, 2, 2, rc.right - rc.left - 2 * 2, rc.bottom - rc.top - 2 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
958 | Sleep(10);
959 | bf.SourceConstantAlpha = 249;
960 | AlphaBlend(hdc, 1, 1, rc.right - rc.left - 1 * 2, rc.bottom - rc.top - 1 * 2, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
961 | Sleep(10);
962 | bf.SourceConstantAlpha = 255;
963 | AlphaBlend(hdc, 0, 0, rc.right - rc.left, rc.bottom - rc.top, hMemDC, 0, 0, rc.right - rc.left, rc.bottom - rc.top, bf);
964 | anistat = 1;
965 | return -1;
966 | }
967 |
968 | SelectObject(hMemDC, hPreBmp);
969 |
970 |
971 | DeleteObject(hBmpMem);
972 |
973 | DeleteDC(hMemDC);
974 |
975 | return 0;
976 | }
977 |
978 | void CreateListPanel(HWND h, VERTEXUILISTPANEL vlp)
979 | {
980 | VertexUIList = {};
981 | VertexUIList = vlp;
982 | SwitchPanel(ListPanel);
983 | }
984 | void CreateListPanelByFlag(HWND h, HDC hdc, VERTEXUILISTPANEL vlp, DRAWPANEL DrawFun, int Flag = 0)
985 | {
986 |
987 | //On hMemDC.
988 | if (PanelID == PrevPanelID)
989 | {
990 | _CreateListPanel(h, hdc, vlp, DrawFun);
991 | anistat = 0;
992 | }
993 | if (PanelID != PrevPanelID)
994 | {
995 | if (Flag == 0)
996 | {
997 | _CreateListPanelAnimation(h, hdc, vlp, DrawFun);
998 | }
999 | if (Flag == 1)
1000 | {
1001 | _CreateListPanel(h, hdc, vlp, DrawFun);
1002 | }
1003 | PrevPanelID = PanelID;
1004 | anistat = 0;
1005 | }
1006 | }
1007 | #define ListPanelEvent \
1008 | if (PanelID == ListPanel)\
1009 | {\
1010 | RECT rc;\
1011 | for (int i = 1; i <= 128; i++)\
1012 | {\
1013 | \
1014 | int tsz = 40;\
1015 | if (VertexUIList.listtxt[i] == L"")\
1016 | {\
1017 | break;\
1018 | }\
1019 | AddBoxClickArea_Animation(hWnd, lParam, 40, i * 60 + tsz, 512, 40, VertexUIList.listclick[i])\
1020 | \
1021 | }\
1022 | TitleBarEvent \
1023 | AddBoxClickArea(hWnd,lParam,1,40,40,40,GoPagePrev)\
1024 | else\
1025 | {\
1026 | if (hState == 1)\
1027 | {\
1028 | hState = 0;\
1029 | RECT winrc2;\
1030 | GetClientRect(hWnd, &winrc2);\
1031 | InvalidateRect(hWnd, &winrc2, 0);\
1032 | return 0;\
1033 | }\
1034 | }\
1035 | \
1036 | }\
1037 |
1038 | }
1039 |
1040 | #ifdef VERTEXUI_DEVMODE
1041 | using namespace::VertexUI;
1042 | using namespace::VertexUI::Panel;
1043 |
1044 | //Other
1045 |
1046 |
1047 | #endif
1048 |
1049 | #ifdef test
1050 | void TESTDrawLine(HDC pDC, int X0, int Y0, int X1, int Y1, COLORREF clrLine)
1051 | {
1052 | HDC mDC = pDC;
1053 | if (Y0 > Y1)
1054 | {
1055 | int Temp = Y0; Y0 = Y1; Y1 = Temp;
1056 | Temp = X0; X0 = X1; X1 = Temp;
1057 | }
1058 |
1059 | SetPixel(pDC, X0, Y0, clrLine);
1060 |
1061 | int XDir, DeltaX = X1 - X0;
1062 | if (DeltaX >= 0)
1063 | {
1064 | XDir = 1;
1065 | }
1066 | else
1067 | {
1068 | XDir = -1;
1069 | DeltaX = 0 - DeltaX;
1070 | }
1071 |
1072 | int DeltaY = Y1 - Y0;
1073 | if (DeltaY == 0)
1074 | {
1075 | /* Horizontal line */
1076 | while (DeltaX-- != 0)
1077 | {
1078 | X0 += XDir;
1079 | SetPixel(pDC, X0, Y0, clrLine);
1080 | }
1081 | return;
1082 | }
1083 | if (DeltaX == 0)
1084 | {
1085 | /* Vertical line */
1086 | do
1087 | {
1088 | Y0++;
1089 | SetPixel(pDC, X0, Y0, clrLine);
1090 | } while (--DeltaY != 0);
1091 | return;
1092 | }
1093 |
1094 | if (DeltaX == DeltaY)
1095 | {
1096 | /* Diagonal line */
1097 | do
1098 | {
1099 | X0 += XDir;
1100 | Y0++;
1101 | SetPixel(pDC, X0, Y0, clrLine);
1102 | } while (--DeltaY != 0);
1103 | return;
1104 | }
1105 |
1106 | unsigned short ErrorAdj;
1107 | unsigned short ErrorAccTemp, Weighting;
1108 |
1109 |
1110 | unsigned short ErrorAcc = 0;
1111 |
1112 | BYTE rl = GetRValue(clrLine);
1113 | BYTE gl = GetGValue(clrLine);
1114 | BYTE bl = GetBValue(clrLine);
1115 | double grayl = rl * 0.299 + gl * 0.587 + bl * 0.114;
1116 |
1117 | if (DeltaY > DeltaX)
1118 | {
1119 |
1120 | ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY;
1121 | while (--DeltaY) {
1122 | ErrorAccTemp = ErrorAcc;
1123 | ErrorAcc += ErrorAdj;
1124 | if (ErrorAcc <= ErrorAccTemp) {
1125 |
1126 | X0 += XDir;
1127 | }
1128 | Y0++;
1129 |
1130 | Weighting = ErrorAcc >> 8;
1131 | assert(Weighting < 256);
1132 | assert((Weighting ^ 255) < 256);
1133 |
1134 | COLORREF clrBackGround = ::GetPixel(mDC, X0, Y0);
1135 | BYTE rb = GetRValue(clrBackGround);
1136 | BYTE gb = GetGValue(clrBackGround);
1137 | BYTE bb = GetBValue(clrBackGround);
1138 | double grayb = rb * 0.299 + gb * 0.587 + bb * 0.114;
1139 |
1140 | BYTE rr = (rb > rl ? ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (rb - rl) + rl)) : ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (rl - rb) + rb)));
1141 | BYTE gr = (gb > gl ? ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (gb - gl) + gl)) : ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (gl - gb) + gb)));
1142 | BYTE br = (bb > bl ? ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (bb - bl) + bl)) : ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (bl - bb) + bb)));
1143 | SetPixel(pDC, X0, Y0, RGB(rr, gr, br));
1144 |
1145 | clrBackGround = ::GetPixel(mDC, X0 + XDir, Y0);
1146 | rb = GetRValue(clrBackGround);
1147 | gb = GetGValue(clrBackGround);
1148 | bb = GetBValue(clrBackGround);
1149 | grayb = rb * 0.299 + gb * 0.587 + bb * 0.114;
1150 |
1151 | rr = (rb > rl ? ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (rb - rl) + rl)) : ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (rl - rb) + rb)));
1152 | gr = (gb > gl ? ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (gb - gl) + gl)) : ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (gl - gb) + gb)));
1153 | br = (bb > bl ? ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (bb - bl) + bl)) : ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (bl - bb) + bb)));
1154 | SetPixel(pDC, X0 + XDir, Y0, RGB(rr, gr, br));
1155 | }
1156 |
1157 | SetPixel(pDC, X1, Y1, clrLine);
1158 | return;
1159 | }
1160 |
1161 | ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX;
1162 |
1163 | while (--DeltaX) {
1164 | ErrorAccTemp = ErrorAcc;
1165 | ErrorAcc += ErrorAdj;
1166 | if (ErrorAcc <= ErrorAccTemp) {
1167 |
1168 | Y0++;
1169 | }
1170 | X0 += XDir;
1171 |
1172 | Weighting = ErrorAcc >> 8;
1173 | assert(Weighting < 256);
1174 | assert((Weighting ^ 255) < 256);
1175 |
1176 | COLORREF clrBackGround = ::GetPixel(mDC, X0, Y0);
1177 | BYTE rb = GetRValue(clrBackGround);
1178 | BYTE gb = GetGValue(clrBackGround);
1179 | BYTE bb = GetBValue(clrBackGround);
1180 | double grayb = rb * 0.299 + gb * 0.587 + bb * 0.114;
1181 |
1182 | BYTE rr = (rb > rl ? ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (rb - rl) + rl)) : ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (rl - rb) + rb)));
1183 | BYTE gr = (gb > gl ? ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (gb - gl) + gl)) : ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (gl - gb) + gb)));
1184 | BYTE br = (bb > bl ? ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (bb - bl) + bl)) : ((BYTE)(((double)(grayl < grayb ? Weighting : (Weighting ^ 255))) / 255.0 * (bl - bb) + bb)));
1185 |
1186 | SetPixel(pDC, X0, Y0, RGB(rr, gr, br));
1187 |
1188 | clrBackGround = ::GetPixel(mDC, X0, Y0 + 1);
1189 | rb = GetRValue(clrBackGround);
1190 | gb = GetGValue(clrBackGround);
1191 | bb = GetBValue(clrBackGround);
1192 | grayb = rb * 0.299 + gb * 0.587 + bb * 0.114;
1193 |
1194 | rr = (rb > rl ? ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (rb - rl) + rl)) : ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (rl - rb) + rb)));
1195 | gr = (gb > gl ? ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (gb - gl) + gl)) : ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (gl - gb) + gb)));
1196 | br = (bb > bl ? ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (bb - bl) + bl)) : ((BYTE)(((double)(grayl < grayb ? (Weighting ^ 255) : Weighting)) / 255.0 * (bl - bb) + bb)));
1197 |
1198 | SetPixel(pDC, X0, Y0 + 1, RGB(rr, gr, br));
1199 | }
1200 |
1201 | SetPixel(pDC, X1, Y1, clrLine);
1202 | }
1203 | #endif
--------------------------------------------------------------------------------
/VertexUI/VertexUI.min.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "framework.h"
3 | #include "VertexUI.Colors.h"
4 | #include "VertexUI.ClickArea.h"
5 | #include "VertexUI.Panel.h"
6 |
7 | #define VertexUIInit \
8 | using namespace::VertexUI; \
9 | using namespace::VertexUI::Panel; \
10 | using namespace::VertexUI::Click
--------------------------------------------------------------------------------
/VertexUI/framework.h:
--------------------------------------------------------------------------------
1 | // header.h: 标准系统包含文件的包含文件,
2 | // 或特定于项目的包含文件
3 | //
4 |
5 | #pragma once
6 |
7 | #include "targetver.h"
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
--------------------------------------------------------------------------------
/VertexUI/sign:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------